public ForToken LogOn(DataConnection pclsCache, string PwType, string userId, string password, string role)
 {
     int result = usersMethod.CheckPasswordByInput(pclsCache, PwType, userId, password);
     ForToken response = new ForToken();
     response.Status = "";
     response.Token = "";
     if (result == 1)
     {
         //密码验证成功
         string UId = usersMethod.GetIDByInput(pclsCache, PwType, userId); //输入手机号获取用户ID
         if (UId != "")
         {
             string Class = usersMethod.GetActivatedState(pclsCache, UId, role);
             if (Class == "0")
             {
                 int flag = 0;
                 List<string> AllRoleMatch = usersMethod.GetAllRoleMatch(pclsCache, UId);
                 if (AllRoleMatch != null)
                 {
                     for (int i = 0; i < AllRoleMatch.Count; i++)
                     {
                         if (AllRoleMatch[i].ToString() == role)//查询条件
                         {
                             flag = 1;
                             break;
                         }
                     }
                 }
                 if (flag == 1)
                 {
                     string ticks = new CommonMethod().GetServerTime(pclsCache);
                     response.Token = SecurityManager.GenerateToken(userId, password, role, ticks);
                     response.Status = "已注册激活且有权限,登陆成功,跳转到主页";
                     return response; //"已注册激活且有权限,登陆成功,跳转到主页"1;
                 }
                 else
                 {
                     response.Status = "已注册激活,但没有权限"; //"已注册激活 但没有权限"2;
                 }
             }
             else      //Class == "1" or Class == ""
             {
                 response.Status = "您的账号对应的角色未激活,需要先激活;界面跳转到游客页面(已注册但未激活)";            //您的账号对应的角色未激活,需要先激活;界面跳转到游客页面(已注册但未激活)3
             }
         }
         else
         {
             response.Status = "用户不存在"; //"用户不存在"4;
         }
     }
     else if (result == 0)
     {
         response.Status = "密码错误"; //"密码错误"5;
     }
     else
     {
         response.Status = "用户不存在";   //"用户不存在"4
     }
     return response;
 }
Exemple #2
0
        ////GetDoctorDtlInfoMaxItemSeq CSQ 20151106
        //public static int GetDoctorDtlInfoMaxItemSeq(DataConnection pclsCache, string DoctorId, string CategoryCode, string ItemCode)
        //{
        //    int ret = 0;
        //    try
        //    {
        //        if (!pclsCache.Connect())
        //        {
        //            //MessageBox.Show("Cache数据库连接失败");
        //            return ret;

        //        }
        //        ret = (int)Ps.DoctorInfoDetail.GetMaxItemSeq(pclsCache.CacheConnectionObject, DoctorId, CategoryCode, ItemCode);
        //        return ret;
        //    }
        //    catch (Exception ex)
        //    {
        //        //MessageBox.Show(ex.ToString(), "保存失败!");
        //        HygeiaComUtility.WriteClientLog(HygeiaEnum.LogType.ErrorLog, "UsersMethod.GetDoctorDtlInfoMaxItemSeq", "数据库操作异常! error information : " + ex.Message + Environment.NewLine + ex.StackTrace);
        //        return ret;
        //    }
        //    finally
        //    {
        //        pclsCache.DisConnect();
        //    }
        //}

        #region 第二层
        public int RegisterRelated(DataConnection pclsCache, string PwType,string userId,string Password, string UserName,string role,string revUserId,string TerminalName,string  TerminalIP,int DeviceType)
        {
            int ret = 0;
            int Flag1 = Register(pclsCache, PwType, userId, "", Password, UserName, revUserId, TerminalName, TerminalIP, DeviceType);
            //数据库Cm.MstUser和Cm.MstUserDetail表数据写入成功
            if (Flag1 == 1)
            {
                string userID = GetIDByInput(pclsCache, PwType, userId);
                if (userID != "")
                {
                    string InviteNo = new CommonMethod().GetNo(pclsCache, 12, "");
                    if (InviteNo != "")
                    {
                        int test = PsRoleMatchSetData(pclsCache, userID, role, InviteNo, "1", "");
                        if (test == 1)
                        {
                            ret = 1;//"注册成功";
                        }
                        else
                        {
                            ret = 2; // "注册失败!";
                        }
                    }
                }
            }
            return ret;
        }