Ejemplo n.º 1
0
 public void UpdateTrainers(U_WeChatRegistered ruser)
 {
     using (SqlSugarClient _dbSql = SugarDao_LandaVSql.GetInstance())
     {
         _dbSql.Update <AllTrainers>(new { MobilePhone = ruser.mobile }, c => c.EmployeeNO == ruser.userid);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建微信通讯录中的用户
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static string CreateUser(string accessToken, U_WeChatRegistered user)
        {
            string createUserUrl = "https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token={0}";
            string url           = string.Format(createUserUrl, accessToken);
            string jsonData      = "{\"userid\":\"" + user.userid + "\",\"name\":\"" + user.name + "\",\"department\":[2],\"position\":\"司机\",\"mobile\":\"" + user.mobile + "\",\"gender\":\"" + user.gender + "\"}";
            string respText      = PostWebRequest(url, jsonData, Encoding.UTF8);

            return(respText);
        }
Ejemplo n.º 3
0
        public AllTrainers GetTrainers(U_WeChatRegistered ruser)
        {
            AllTrainers trainers = null;

            using (SqlSugarClient _dbSql = SugarDao_LandaVSql.GetInstance())
            {
                List <AllTrainers> allTrainers = _dbSql.Queryable <AllTrainers>().Where(c => c.EmployeeNO == ruser.userid).ToList();
                if (allTrainers.Count > 0)
                {
                    trainers = allTrainers[0];
                }
            }
            return(trainers);
        }
Ejemplo n.º 4
0
        public void InsertTrainers(U_WeChatRegistered ruser)
        {
            AllTrainers trainer = new AllTrainers();

            trainer.IDCard     = ruser.idcard;
            trainer.Name       = ruser.name;
            trainer.EmployeeNO = ruser.userid;
            trainer.Gender     = 1;
            if (!string.IsNullOrEmpty(ruser.gender))
            {
                trainer.Gender = Convert.ToInt32(ruser.gender);
            }
            trainer.MobilePhone = ruser.mobile;
            using (SqlSugarClient _dbSql = SugarDao_LandaVSql.GetInstance())
            {
                AllTrainers train = _dbSql.Queryable <AllTrainers>().Where(c => c.EmployeeNO == ruser.userid).FirstOrDefault();
                if (train == null)
                {
                    _dbSql.Insert(trainer);
                }
            }
        }
Ejemplo n.º 5
0
 public AllTrainers GetTrainers(U_WeChatRegistered ruser)
 {
     return(_us.GetTrainers(ruser));
 }
Ejemplo n.º 6
0
 public void UpdateTrainers(U_WeChatRegistered ruser)
 {
     _us.UpdateTrainers(ruser);
 }
Ejemplo n.º 7
0
 public void InsertTrainers(U_WeChatRegistered ruser)
 {
     _us.InsertTrainers(ruser);
 }
Ejemplo n.º 8
0
        public JsonResult WeChatMobileChange(string SECURITYKEY, string pushparam)
        {
            ExecutionResult result = new ExecutionResult();

            try
            {
                if (API_Authentication(SECURITYKEY))
                {
                    string             accessToken   = Common.WeChatPush.WeChatTools.GetAccessoken(true);
                    U_WeChatRegistered user          = Extend.JsonToModel <U_WeChatRegistered>(pushparam);
                    UserInfoLogic      userInfoLogic = new UserInfoLogic();
                    var muser = userInfoLogic.GetPerson(user.idcard);
                    if (muser != null)
                    {
                        userInfoLogic.UpdatePhoneNumber(muser.UserID, user.mobile);
                        //userInfoLogic.DeleteUserInfo(new string[] { muser.Vguid.ToString() });
                        string pushResult   = WeChatTools.DeleteUser(accessToken, muser.UserID);
                        var    wechatResult = Extend.JsonToModel <U_WechatResult>(pushResult);
                        if (wechatResult.errcode != "0")
                        {
                            result.Message = pushResult;
                        }
                        else
                        {
                            UserInfoLogic logic       = new UserInfoLogic();
                            var           allTrainers = logic.GetTrainers(user);
                            if (allTrainers != null)
                            {
                                user.userid = allTrainers.IDCard;
                                user.name   = allTrainers.Name;
                                user.gender = allTrainers.Gender.ToString();
                                //string pushResult = WeChatTools.WeChatMobileChange(accessToken, muser.UserID, user.mobile);

                                pushResult   = WeChatTools.CreateUser(accessToken, user);
                                wechatResult = Extend.JsonToModel <U_WechatResult>(pushResult);
                                if (wechatResult.errcode == "0")
                                {
                                    logic.UpdateTrainers(user);
                                    result.Success = true;
                                }
                                result.Message = pushResult;
                            }
                            else
                            {
                                result.Message = string.Format("该身份证号码:{0} 用户在培训注册表中不存在!", user.idcard);
                            }
                        }
                    }
                    else
                    {
                        result.Message = string.Format("该身份证号码:{0} 用户不存在", user.idcard);
                    }
                }
                else
                {
                    result.Message = "SECURITYKEY 无效!";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                LogHelper.WriteLog(ex.Message);
            }
            ExecHistry("WeChatRegistered", pushparam, JsonHelper.ModelToJson(result));
            return(Json(result));
        }
Ejemplo n.º 9
0
        public JsonResult WeChatRegistered(string SECURITYKEY, string pushparam)
        {
            ExecutionResult result = new ExecutionResult();

            try
            {
                if (API_Authentication(SECURITYKEY))
                {
                    //if (!APICount())
                    //{
                    //    result.Message = "删除微信官方通讯录次数已经用完!";
                    //}
                    //else
                    //{

                    string             accessToken = WeChatTools.GetAccessoken(true);
                    U_WeChatRegistered user        = Extend.JsonToModel <U_WeChatRegistered>(pushparam);

                    string pushResult   = WeChatTools.CreateUser(accessToken, user);
                    var    wechatResult = Extend.JsonToModel <U_WechatResult>(pushResult);
                    if (wechatResult.errcode == "0")
                    {
                        UserInfoLogic logic = new UserInfoLogic();
                        logic.InsertTrainers(user);
                        result.Success = true;
                    }
                    result.Message = pushResult;


                    //string accessToken = WeChatTools.GetAccessoken(true);
                    //U_WeChatRegistered user = Extend.JsonToModel<U_WeChatRegistered>(pushparam);
                    //var wResult = WeChatTools.GetUserInfoByUserID(accessToken, user.idcard);
                    //var wechatResult = Extend.JsonToModel<U_WechatResult>(wResult);
                    //if (wechatResult.errcode == "0")
                    //{
                    //    WeChatTools.DeleteUser(accessToken, user.idcard);
                    //}
                    //wResult = WeChatTools.GetUserId(accessToken, user.mobile);
                    //Dictionary<string, string> dicReuslt = Extend.JsonToModel<Dictionary<string, string>>(wResult);
                    //if (dicReuslt["errcode"] == "0")
                    //{
                    //    string userid = dicReuslt["userid"];
                    //    WeChatTools.DeleteUser(accessToken, userid);
                    //}

                    //string pushResult = WeChatTools.CreateUser(accessToken, user);
                    //wechatResult = Extend.JsonToModel<U_WechatResult>(pushResult);
                    //if (wechatResult.errcode == "0")
                    //{
                    //    UserInfoLogic logic = new UserInfoLogic();
                    //    logic.InsertTrainers(user);
                    //    result.Success = true;
                    //}
                    //result.Message = pushResult;
                    //}
                }
                else
                {
                    result.Message = "SECURITYKEY 无效!";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                LogHelper.WriteLog(ex.Message);
            }
            ExecHistry("WeChatRegistered", pushparam, JsonHelper.ModelToJson(result));
            return(Json(result));
        }
Ejemplo n.º 10
0
        public JsonResult WeChatRegistrationVerification(string SECURITYKEY, string pushparam)
        {
            ExecutionResult result = new ExecutionResult();

            try
            {
                if (API_Authentication(SECURITYKEY))
                {
                    U_WeChatRegistered  user        = Extend.JsonToModel <U_WeChatRegistered>(pushparam);
                    string              accessToken = WeChatTools.GetAccessoken(true);
                    string              pushResult  = WeChatTools.GetUserInfo(accessToken);
                    U_WechatUsersResult usersResult = Extend.JsonToModel <U_WechatUsersResult>(pushResult);

                    var fuser = usersResult.userlist.Find(c => c.userid == c.mobile && c.mobile == user.mobile);
                    if (fuser != null)
                    {
                        result.Success = true;
                        result.Message = string.Format("存在微信USERID为{0},手机号码为{1}的用户!", fuser.userid, fuser.mobile);
                        result.Result  = 1;//USERID为手机号,手机号一致
                        return(Json(result));
                    }
                    fuser = usersResult.userlist.Find(c => c.userid == user.idcard && c.mobile == user.mobile);
                    if (fuser != null)
                    {
                        result.Success = true;
                        result.Message = string.Format("存在微信USERID为{0},手机号码为{1}的用户!", fuser.userid, fuser.mobile);
                        result.Result  = 2;//USERID为身份证号,手机号一致
                        return(Json(result));
                    }
                    fuser = usersResult.userlist.Find(c => c.userid == user.mobile);
                    if (fuser != null)
                    {
                        result.Success = true;
                        result.Message = string.Format("存在微信USERID为{0},手机号码为{1}的用户!", fuser.userid, fuser.mobile);
                        result.Result  = 3;//USERID为手机号,手机号不一致
                        return(Json(result));
                    }
                    fuser = usersResult.userlist.Find(c => c.userid == user.idcard);
                    if (fuser != null)
                    {
                        result.Success = true;
                        result.Message = string.Format("存在微信USERID为{0},手机号码为{1}的用户!", fuser.userid, fuser.mobile);
                        result.Result  = 4;//USERID为身份证号,手机号不一致
                        return(Json(result));
                    }
                    fuser = usersResult.userlist.Find(c => c.mobile == user.mobile);
                    if (fuser != null)
                    {
                        result.Success = true;
                        result.Message = string.Format("存在微信USERID为{0},手机号码为{1}的用户!", fuser.userid, fuser.mobile);
                        result.Result  = 5;//手机号一致,USERID不一致
                        return(Json(result));
                    }
                    result.Success = true;
                    result.Message = "微信不存在该用户!";
                    result.Result  = 0;//
                    return(Json(result));
                }
            }

            catch (Exception ex)
            {
                result.Message = ex.Message;
                LogHelper.WriteLog(ex.Message);
            }
            return(Json(result));
        }