Development of ASP.net public platform (III.) micro-letter message encapsulation and reflection assignment

Source: Internet
Author: User

The previous article has been set up the overall framework, to achieve the entrance verification,   validation passed to the Lookmsgtype method processing, Lookmsgtype method is mainly to the micro-letter sent to the different message decomposition, different types to the business logic layer of different methods to deal with,   for different types of messages to judge, you can use if, or switch   generally more than 5 if with switch will be better, here posted Lookmsgtype method:

public void Lookmsgtype (string msgtype) {#region Determine message type switch (msgtype)
                    {case "text": Rtext mtext = new Rtext ();
                    Mtext = readxml.getmodel<rtext> (Mtext, Xmlmodel);
                Bllwei.dotext (Dbhome, mtext);//text message break;
                    Case "image": rimg mimg = new rimg ();
                    mimg = readxml.getmodel<rimg> (mimg, Xmlmodel);
                Bllwei.doimg (dbhome,mimg);//Picture break;
                    Case "Voice"://Voice Rvoice Mvoice = new Rvoice ();
                    Mvoice = readxml.getmodel<rvoice> (Mvoice, Xmlmodel);
                    Bllwei.dovoice (Dbhome,mvoice);
    
                Break
                    Case "Videos"://Video Rvideo Mvideo = new Rvideo ();
    Mvideo = readxml.getmodel<rvideo> (Mvideo, Xmlmodel);                Bllwei.dovideo (Dbhome, Mvideo);
    
                Break
                    Case "Location"://geographical location rlocation mlocation = new Rlocation ();
                    Mlocation = readxml.getmodel<rlocation> (mlocation, Xmlmodel);
                    Bllwei.dolocation (dbhome,mlocation);
                Break
                    Case "link"://link Rlink mlink = new Rlink ();
                    Mlink = readxml.getmodel<rlink> (Mlink, Xmlmodel);
                    Bllwei.dolink (Dbhome,mlink);
                Break
                    #region Event Case "event": Switch (Readxml.readmodel ("event", Xmlmodel) {case "subscribe": if (Readxml.readmodel) ("Eventkey", X Mlmodel). IndexOf ("Qrscene_") >= 0) {rcodenotsub mnotsub = new Rcode
                 Notsub ();               Mnotsub = readxml.getmodel<rcodenotsub> (mnotsub, Xmlmodel);
                            Bllwei.docodenotsub (dbhome,mnotsub)//new user not concerned, scanning two-dimensional code with parameters attention} else
                                {Rsub msub = new Rsub ();
                                Msub = readxml.getmodel<rsub> (msub, Xmlmodel);
                        Bllwei.dosub (dbhome,msub);//General concern} break;
                            Case "Unsubscribe": runsub munsub = new Runsub ();
                            Munsub = readxml.getmodel<runsub> (munsub, Xmlmodel);
    
                        Bllwei.dounsub (dbhome,munsub);/cancel the concern break;
                            Case "SCAN": rcodesub mcodesub = new Rcodesub (); Mcodesub = READXML.GETMODEL&LT;RCODESUB&Gt; (Mcodesub, Xmlmodel);
                        Bllwei.docodesub (dbhome,mcodesub);//already concerned with the user scanning with parameters of the two-dimensional code break;
                            Case "LOCATION"://user escalation location rsublocation msubloc = new Rsublocation ();
    
                            Msubloc = readxml.getmodel<rsublocation> (Msubloc, Xmlmodel);
                            Bllwei.dosublocation (Dbhome, Msubloc);
                        Break
                            Case "click"://custom Menu click rmenuclick mmenuclk = new Rmenuclick ();
                            MMENUCLK = readxml.getmodel<rmenuclick> (MMENUCLK, Xmlmodel);
                            Bllwei.domenuclick (Dbhome, MMENUCLK);
                        Break
                            Case "VIEW"://Custom menu Jump event Rmenuview mmenuvw = new Rmenuview ();
     MMENUVW = readxml.getmodel<rmenuview> (MMENUVW, Xmlmodel);                       Bllwei.domenuview (Dbhome, MMENUVW);
                    Break
                    };
                Break #endregion} #endregion}

The outer switch judges the Msgtype, and in the event type, the switch again determines the specific event type (attention, cancellation, custom menu events, and so on), so all the messages sent by the micro-mail are processed. The above code uses the message model and the Readxml.getmodel method to assign values to the model, assign the value to the corresponding method of the business logic layer, and write the message encapsulation and methods for assigning the model.

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.