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<RCODESUB≫ (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.