public static void CreateUserInfo(string openid)
        {
            var          result   = WeiXinApi.GetToken();
            UserInfoJson userinfo = UserApi.Info(result, openid);

            if (DbSession.Default.Count <tb_User>(tb_User._.OpenId == userinfo.openid) == 0)
            {
                tb_User userEntity = new tb_User()
                {
                    OpenId     = userinfo.openid,
                    NickName   = userinfo.nickname,
                    HeadImgUrl = userinfo.headimgurl,
                    Name       = "",
                    Sex        = userinfo.sex,
                    Moblie     = "",
                    State      = 1,
                    Integral   = 0,
                    IsDealer   = false,
                    CreateTime = DateTime.Now,
                    ExpDate    = null
                };
                DbSession.Default.Insert <tb_User>(userEntity);
            }
            else
            {
                tb_User userEntity = DbSession.Default.From <tb_User>().Where(tb_User._.OpenId == userinfo.openid).ToFirst();
                userEntity.Attach();
                userEntity.NickName   = userinfo.nickname;
                userEntity.HeadImgUrl = userinfo.headimgurl;
                DbSession.Default.Update <tb_User>(userEntity);
            }
        }
        public ActionResult Index(string msg)
        {
            msg = AESAlgorithm.AESDecrypt(msg.Replace(" ", "+"));//解密参数

            //string path = Server.MapPath("/App_Data/" + Guid.NewGuid().ToString() + ".txt");//将参数写入文件
            //StreamWriter sw = new StreamWriter(path);
            //sw.Write(msg.Replace("&", "\r\n"));//TextBox2中的文本是可以编辑后的。
            //sw.Close();
            //sw.Dispose();

            NameValueCollection param = UrlCommon.GetQueryString(msg);//获取参数
            string  SchoolNum         = param["SchoolNum"].ToString();
            string  StudentNo         = param["StudentNo"].ToString();
            tb_User user    = DbSession.Default.From <tb_User>().Where(tb_User._.SchoolNo == SchoolNum && tb_User._.StudentNo == StudentNo).ToFirst();
            string  MsgType = param["MsgType"].ToString();

            switch (MsgType)
            {
            case "UserOperation":
                var UserOperation = new UserOperation()
                {
                    first    = new TemplateDataItem(user.Name + " 您好"),
                    keyword1 = new TemplateDataItem(param["Room"].ToString()),
                    keyword2 = new TemplateDataItem(param["SeatNo"].ToString()),
                    keyword3 = new TemplateDataItem(param["AddTime"].ToString()),
                    remark   = new TemplateDataItem(param["Msg"].ToString())
                };
                TemplateApi.SendTemplateMessage(WeiXinApi.GetToken(), user.OpenId, "At7HOxsJ5CW81OV81hipLglDV21O46UVU9Gm_nToXGQ", "#7B68EE", GetAppSettings.SysURL + "/User/SeatState", UserOperation);
                break;

            default:
                var UserOperation1 = new UserOperation()
                {
                    first    = new TemplateDataItem(user.Name + " 您好"),
                    keyword1 = new TemplateDataItem(param["Room"].ToString()),
                    keyword2 = new TemplateDataItem(param["SeatNo"].ToString()),
                    keyword3 = new TemplateDataItem(param["AddTime"].ToString()),
                    remark   = new TemplateDataItem(param["Msg"].ToString())
                };
                TemplateApi.SendTemplateMessage(WeiXinApi.GetToken(), user.OpenId, "At7HOxsJ5CW81OV81hipLglDV21O46UVU9Gm_nToXGQ", "#7B68EE", GetAppSettings.SysURL + "/User/SeatState", UserOperation1);
                break;
            }

            return(Content("0"));
        }