예제 #1
0
파일: Handle.cs 프로젝트: zhangwxyc/BPM
    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="account"></param>
    /// <param name="password"></param>
    /// <returns></returns>
    public static string Login(string account, string password)
    {
        bool flag = false;

        //模拟用户都是mobile_域账号,不去验证密码。
        //是否可以启动移动OA的模拟账号,正式环境配置AppSettings IsAllowMobileUser=0;
        string isAllowMobileUser = System.Configuration.ConfigurationManager.AppSettings["IsAllowMobileUser"];
        //移动模拟账号的开头,默认 mobile_
        string mobileTag = System.Configuration.ConfigurationManager.AppSettings["MobileTag"];

        if (string.IsNullOrEmpty(mobileTag))
        {
            mobileTag = "mobile_";
        }
        string mobileUser = account;

        if (account.StartsWith(mobileTag) && isAllowMobileUser != "0")
        {
            account = account.Replace(mobileTag, "");
            flag    = true;
        }
        else
        {
            flag = CheckLogin(account, password);
        }

        //MobileLog.InsertLog("login", string.Format("account={0}", mobileUser), "", account);

        if (flag)
        {
            MobileUserInfo model = RequestProcess.GetMobileUserInfoByAccount(account);
            if (model != null)
            {
                if (model.UserCode == null)
                {
                    return("");
                }
                else
                {
                    //MobileLog.InsertLog("login", string.Format("account={0}", account), "Success", account);

                    model.UserEnCode = EnCode(account);
                    string json = JsonHelper.JsonSerializer(model);
                    return(json);
                }
            }
            return("");
        }
        else
        {
            return("");
        }
    }