C # converts MSMQ messages into JSON-formatted "optimizations"

Source: Internet
Author: User
Tags allkeys msmq

C # converts MSMQ messages into JSON-formatted "optimizations"

Conversion functions:

private string Converttojson (string label, string body) {//todo:convert to JSON string[] La blelist = label.            Split (' | '); string[] Bodylist = body.                           Split (' | ');            String jsonstr = "{\" ";            NameValueCollection NVC = (NameValueCollection) configurationmanager.getsection ("Lablename"); foreach (String key in NVC.             AllKeys) {jsonstr = Jsonstr + Nvc[key] + "\": \ "" + lablelist[convert.toint32 (Key)-1] + "\", \ "";            } NameValueCollection NVD = (NameValueCollection) configurationmanager.getsection ("Bodyname"); foreach (String key in NVD. AllKeys) {jsonstr = Jsonstr + Nvd[key] + "\": \ "" + bodylist[convert.toint32 (Key)-1] + "\", \ ""                    ;            } jsonstr = Jsonstr.remove (jsonstr.length-2, 2) + "}";             Console.WriteLine (JSONSTR);        return jsonstr; }

Configuration file:

<?xml version= "1.0" encoding= "Utf-8"?><configuration> <configSections> <section name= " Lablename "type=" System.Configuration.NameValueSectionHandler "/> <!--returns the information in the configuration section as a Namevalue key/pair < Section name= "Bodyname" type= "System.Configuration.NameValueSectionHandler"/> <!--  Returns information in the configuration section as a dictionary dictionary key-value pair </configSections> <startup> <supportedruntime version= "v4.0" Sku= ".      netframework,version=v4.5 "/> </startup> <LableName> <add key=" 1 "value=" MessageID "/> <add key= "2" value= "Sendingbasetag"/> <add key= "3" value= "Sendingmachinename"/> <add key= "4" va Lue= "Messagequeuepathname"/> <add key= "5" value= "CustomField1"/> <add key= "6" value= "CustomField2"/&    Gt    </LableName> <BodyName> <add key= "1" value= "Datamode"/> <add key= "2" value= "Datamodeid"/> <add key= "3" value= "Experimentid"/> <addkey= "4" value= "Basepentype"/> <add key= "5" value= "Basepentypeid"/> <add key= "6" value= "MID"/> < Add key= "7" value= "Stationtag"/> <add key= "8" value= "DateTime"/> <add key= "9" value= "Path1"/> < Add key= "value=" EquipmentID1 "/> <add key=" one "value=" Path2 "/> <add key=" Ten "value=" EquipmentID2 "/&gt  ; </BodyName></configuration>

Thank you!

C # converts MSMQ messages into JSON-formatted "optimizations"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.