Esempio n. 1
0
 public JsonResult Delete(WX_LK_FansC3AM _t)
 {
     if (WMFactory.WXLKFansC3AM.Delete(s => s.Id == _t.Id ))
         return Json(ResultMsg.Success("删除成功!"));
     else
         return Json(ResultMsg.Failure("删除失败,请您重试!"));
 }
Esempio n. 2
0
 public JsonResult Post(WX_LK_FansC3AM _t)
 {
     if (WMFactory.WXLKFansC3AM.Insert(_t))
         return Json(ResultMsg.Success("新增成功!"));
     else
         return Json(ResultMsg.Failure("新增失败,请您重试!"));
 }
Esempio n. 3
0
 public JsonResult Put(WX_LK_FansC3AM _t)
 {
     IWXLKFansC3AMService service = WMFactory.WXLKFansC3AM;
     WX_LK_FansC3AM entity = service.GetById(_t.Id.ToString());
     entity = AutoMapper<WX_LK_FansC3AM, WX_LK_FansC3AM>.Convert(_t, entity);
     if (service.Update(entity))
         return Json(ResultMsg.Success("更新成功!"));
     else
         return Json(ResultMsg.Failure("更新失败,请您重试!"));
 }
Esempio n. 4
0
        //绑定用户
        public JsonResult Binding()
        {
            if (string.IsNullOrEmpty(Request["name"]) || string.IsNullOrEmpty(Request["pwd"]) || string.IsNullOrEmpty(Request["oid"]) || string.IsNullOrEmpty(Request["sid"]))
            {
                return Json(ResultMsg.Failure("参数非法!"));
            }
            ResultMsg rst = SSOHelper.Login(Request["name"].Trim(), Server.UrlEncode(Request["pwd"].Trim()), "ITDC(" +
                (Request.UserAgent.Contains("(")&&Request.UserAgent.Contains(")")?Request.UserAgent.Substring(Request.UserAgent.IndexOf("(") + 1, Request.UserAgent.IndexOf(")") - Request.UserAgent.IndexOf("(") - 1):Request.Browser.Platform)
                + "_" + Request.Browser.Type+")", Request.UserHostAddress);
            if (rst.result == 0)
            {
                CertificateDto cert = AuthToken.CurrentUserByTid(rst.msg);
                //20141006,验证是否有手机号码
                if (string.IsNullOrEmpty(cert.Phone) || cert.Phone.Trim().Length <= 0)
                {
                    SSOHelper.LogOut(cert.tokenId);//注销
                    return Json(ResultMsg.Failure("NEEDTELPHONE"));
                }
                //插入到用户绑定表,如果存在则更新数据
                WX_LK_FansC3AM fam = new WX_LK_FansC3AM();

                fam.AccountId = Guid.Parse(Request["sid"]);
                fam.OpenId = Request["oid"];
                fam.CreateUser = "******";
                fam.Uid = Guid.Parse(cert.Id);

                //判断同一个人是否在另一个微信号里,提示请先解除绑定
                Guid uid = Guid.Parse(cert.Id);
                if (WMFactory.WXLKFansC3AM.GetCount(f => f.Uid == uid && f.AccountId == fam.AccountId && f.OpenId!=fam.OpenId) > 0)
                {
                    SSOHelper.LogOut(cert.tokenId);//注销
                    return Json(ResultMsg.Failure("该账户已绑定其他微信号,请先解绑!"));
                }
                IEnumerable<WX_LK_FansC3AM> userList = WMFactory.WXLKFansC3AM.FindByConditions(null, f => f.AccountId == fam.AccountId && f.OpenId == fam.OpenId);
                bool flag = false;
                if (userList != null && userList.Count() == 1)
                {
                    fam = userList.FirstOrDefault();
                    fam.ModifyUser = "******";
                    //如果微信账户和当前认证的账户不是同一个人
                    if (fam.Uid != Guid.Parse(cert.Id))
                    {
                        SSOHelper.LogOut(cert.tokenId);//注销
                        return Json(ResultMsg.Failure("该微信已绑定,回复?解绑"), JsonRequestBehavior.AllowGet);
                    }
                    flag = true;
                }

                fam.UserName = cert.UserName;
                fam.TokenId = Guid.Parse(cert.tokenId);

                if (flag)
                    flag = WMFactory.WXLKFansC3AM.Update(fam);
                else
                    flag = WMFactory.WXLKFansC3AM.Insert(fam);

                if (flag)
                {
                    //绑定成功,清空历史缓存,否则会导致最长23分钟内无效登录的情况
                    CacheHelper.CacheInsertFromMinutes("AMU_" + fam.AccountId.ToString() + "_" + fam.OpenId, fam, 23);
                    return Json(ResultMsg.Success("绑定成功!"), JsonRequestBehavior.AllowGet);
                }
                else
                {
                    SSOHelper.LogOut(cert.tokenId);//注销
                    CacheHelper.CacheNull("AMU_" + fam.AccountId.ToString() + "_" + fam.OpenId);
                    return Json(ResultMsg.Success("绑定失败,请重试!"), JsonRequestBehavior.AllowGet);
                }
            }
            return Json(rst, JsonRequestBehavior.AllowGet);
        }