示例#1
0
        public string LoginValidate(string token)
        {
            string result = "";

            try
            {
                var json = u_JurisdictionUtils.UserValidationApi(token);
                UserValidateResult userValidateResult = JsonConvert.DeserializeObject <UserValidateResult>(json);
                UserValidate       userValidate       = userValidateResult.uservaliDate;

                SessionUtils.Add("userCode", userValidate.UserCode);
                SessionUtils.Add("departmentId", userValidate.DepartmentId);
                SessionUtils.Add("token", token);
                SessionUtils.Add("token_r", userValidate.Token_R);

                string responsibleDepartment = u_JurisdictionUtils.ResponsibleDepartmentApi(userValidate.Token_R, userValidate.UserCode);  ///负责部门
                if (u_TypeJudgmentUtils.IsNullOrEmptyObj(responsibleDepartment) == false)
                {
                    SessionUtils.Add("responsibleDepartment", responsibleDepartment);
                }
            }
            catch (Exception ex)
            {
                result = "{\"code\":\"0\",\"msg\":\"后台出错" + ex + "\"}";
            }
            return(result);
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            // 测试时暂不使用

            /*var ip = context.Request.UserHostAddress;
             * var ipEntity = BaseServices.GetIpArray("你的access_token");
             * if(ipEntity!=null && !ipEntity.ip_list.Contains(ip))
             * {
             *  context.Response.Write("非法请求");
             *  return;
             * }*/
            // var url = context.Request.RawUrl;

            if (context.Request.HttpMethod == "GET")
            {
                BaseServices.ValidUrl("skywalkerxl");
            }

            else
            {
                //var xml = Utils.GetRequestData();
                //System.Diagnostics.Debug.WriteLine("----------------------Receive the xml message Start----------------------");
                //System.Diagnostics.Debug.WriteLine(xml);
                //System.Diagnostics.Debug.WriteLine("---------------------- Receive the xml message End ----------------------");
                //context.Response.Write("");
                string openid = context.Request.Params["openid"];
                Utils.OutPrint(openid);

                if (SessionUtils.Get("openid") == null)
                {
                    SessionUtils.Add("openid", openid);
                }

                // 判断MsgHandlerEntities是否为空,如果是,则实例化,并将各个消息类型的处理程序实体添加到此列表中
                // 因为MsgHandlerEntities是静态变量,之需绑定一次即可,免去了重复绑定的性能损耗
                if (MsgHandlerEntity.MsgHandlerEntities == null)
                {
                    MsgHandlerEntity.MsgHandlerEntities = new List <MsgHandlerEntity>();

                    #region 文本消息绑定处理

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType = MsgType.TEXT,
                        Action  = TextHandler
                    });
                    #endregion

                    #region 图片消息处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType = MsgType.IMAGE,
                        Action  = ImgHandler
                    });
                    #endregion

                    #region 语音消息处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType = MsgType.VOICE,
                        Action  = VoiceHandler
                    });
                    #endregion

                    #region 视频消息处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType = MsgType.VIDEO,
                        Action  = VideoHandler
                    });
                    #endregion

                    #region 地理位置消息处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType = MsgType.LOCATION,
                        Action  = LocationHandler
                    });
                    #endregion

                    #region 链接消息处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType = MsgType.LINK,
                        Action  = linkHandler
                    });
                    #endregion

                    #region 点击事件处理程序
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.CLICK,
                        Action    = ClickEventHandler
                    });
                    #endregion

                    #region 图片事件处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.PIC_WEIXIN,
                        Action    = PicWeiXinHandler
                    });
                    #endregion

                    #region 订阅事件处理绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.SUBSCRIBE,
                        Action    = SubscribeEventHandler
                    });
                    #endregion

                    /***
                     *
                     *
                     *   其它一系列的事件处理
                     *
                     *
                     ***/
                    // TODO
                    #region 获取地理位置信息事件处理绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.LOCATION,
                        Action    = LocationEventHandler
                    });
                    #endregion

                    #region 浏览事件处理程序绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.VIEW,
                        Action    = ViewEventHandler
                    });
                    #endregion

                    #region 扫码推送事件处理程序绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.SCANCODE_PUSH,
                        Action    = ScanCodePushEventHandler
                    });
                    #endregion

                    #region 扫码等待事件处理程序绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.SCANCODE_WAITMSG,
                        Action    = ScanCOdeWatingEventHandler
                    });
                    #endregion

                    #region 系统照相事件处理程序绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.PIC_SYSPHOTO,
                        Action    = PicSysphotoEventHandler
                    });
                    #endregion

                    #region 系统照相或相册事件处理程序绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.PIC_PHOTO_OR_ALBUM,
                        Action    = PicPhotoOrAlbumEventHandler
                    });
                    #endregion

                    #region 弹出地理位置选择器事件处理绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.LOCATION_SELECT,
                        Action    = LocationSelectEventHandler
                    });
                    #endregion


                    #region 模板消息事件处理绑定
                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.TEMPLATESENDJOBFINISH,
                        Action    = TEMPLATESENDJOBFINISHEventHandler
                    });
                    #endregion


                    #region 群发消息处理绑定

                    MsgHandlerEntity.MsgHandlerEntities.Add(new MsgHandlerEntity
                    {
                        MsgType   = MsgType.EVENT,
                        EventType = EventType.MASSSENDJOBFINISH,
                        Action    = GroupJobHandler
                    });
                    #endregion
                }
                MsgFactory.LoadMsg(MsgHandlerEntity.MsgHandlerEntities);
            }
        }