コード例 #1
0
        public ActionResult Index()
        {
            string requestXml = WeChatHelper.ReadRequest(this.Request);

            IHandler handler = HandlerFactory.CreateHandler(requestXml);

            return(Content(handler.HandleRequest()));
        }
コード例 #2
0
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <returns></returns>
        public string ResponseMsg(ReqMsgBase reqMsg)
        {
            IHandler handler = HandlerFactory.CreateHandler(reqMsg);

            if (handler != null)
            {
                return(handler.HandleRequest());
            }

            return(string.Empty);
        }
コード例 #3
0
        /// <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);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: john123951/sweetfly.net
        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();
        }
コード例 #7
0
ファイル: RequestHandler.cs プロジェクト: sharons74/koobeca
        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);
        }