public ActionResult Index() { string requestXml = WeChatHelper.ReadRequest(this.Request); IHandler handler = HandlerFactory.CreateHandler(requestXml); return(Content(handler.HandleRequest())); }
/// <summary> /// 处理请求 /// </summary> /// <returns></returns> public string ResponseMsg(ReqMsgBase reqMsg) { IHandler handler = HandlerFactory.CreateHandler(reqMsg); if (handler != null) { return(handler.HandleRequest()); } return(string.Empty); }
/// <summary> /// 处理请求 /// </summary> /// <returns></returns> private string ResponseMsg() { string requestXml = Common.ReadRequest(this.Request); IHandler handler = HandlerFactory.CreateHandler(requestXml); if (handler != null) { return(handler.HandleRequest()); } return(string.Empty); }
private dynamic Handler(dynamic parameters) { IHttpContext httpContext = new NancyHttpContext(Context); // Creating a request handler factory for Active Query Builder HandlerFactory factory = new HandlerFactory(); // handling the request var handler = factory.CreateHandler(Context.Request.Path, httpContext); handler.ProcessRequest(); // returning the response return(Context.Response); }
/// <summary> /// 处理请求 /// </summary> /// <returns></returns> private string ResponseMsg() { string requestXml = Common.ReadRequest(this.Request); //Library.WriteTxt(requestXml, HttpContext.Current.Server.MapPath("/log/"), "微信接口调试" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"); IHandler handler = HandlerFactory.CreateHandler(requestXml); if (handler != null) { return(handler.HandleRequest()); } return(string.Empty); }
private static void Main(string[] args) { int subjectId = 0; int typeId = 0; string url = @"http://learning.cmr.com.cn/student/acourse/HomeworkCenter/Modelzhlx.asp?CourseID=bk044a"; const string encoding = "GB2312"; const string fileName = "output.xml"; Console.Write("SubjectId:"); string strModuleId = Console.ReadLine(); subjectId = int.Parse(strModuleId); Console.Write("Url:"); url = Console.ReadLine(); Console.Write("Type(1-Normal;2-Old):"); string strTypeId = Console.ReadLine(); typeId = int.Parse(strTypeId); CmrClient client = new CmrClient(); GenerateNormalHandler.setModules(client.GetSubjectModules(subjectId)); string strResponse = HttpUtility.Get(url, Encoding.GetEncoding(encoding), x => { x.Headers["Authorization"] = "Basic am9objEyMzk1Mjpzd2VldDEyMw=="; }); GenerateHandler handler = HandlerFactory.CreateHandler(typeId); var list = handler.Process(strResponse, subjectId); using (var fsWrite = File.Create(fileName)) { var xs = new XmlSerializer(list.GetType()); xs.Serialize(fsWrite, list); } Process.Start(fileName); Console.WriteLine("OK:" + fileName); Console.ReadKey(); }
public static string Handle(string cmd, uint userId, RequestParams requestParams, Dictionary <string, object> additionalParams) { if (cmd == "dummy") { return(string.Empty); } Logger.Instance.Debug($"User Id :{userId}"); Logger.Instance.Debug($"Parameters :{JsonConvert.SerializeObject(requestParams)}"); ActivityHandler handler = HandlerFactory.CreateHandler(cmd, userId, requestParams, additionalParams); Stopwatch sw = new Stopwatch(); sw.Start(); handler.Execute(); sw.Stop(); Logger.Instance.Info($"execution of {cmd} took {sw.ElapsedMilliseconds} ms"); return(handler.Response); }