コード例 #1
0
ファイル: SessionInfo.cs プロジェクト: zhangyongproject/Web
    //#region 调用WebService的通用参数准备

    ////这几个参数是用于解释webService返回结果的
    ////没有实际意义
    //private int __mCode;
    //private string __strMessage;
    //private string __strResult;
    //private string __strReserved;

    //private void InitWebServiceParam()
    //{
    //    __mCode = 0;
    //    __strMessage = "";
    //    __strResult = "";
    //    __strReserved = "";
    //}

    //#endregion

    #region (sysService)方法封装

    //public bool InitSystemData()
    //{
    //    //if (!this.HasLogin)
    //    //    return false;

    //    //InitWebServiceParam();
    //    //string strResultXml = mProxy.sysService.InitSystemData(this.LogID, __strReserved);
    //    //return MyXml.ParseResultOK(strResultXml, ref __mCode, ref __strMessage, ref __strResult);
    //}

    /// <summary>
    /// 系统登录
    /// </summary>
    /// <param name="userCode">用户代码,也可以是用户名,即用户可见的标识用户身份的字符串(但系统内部不用此字段作标识)</param>
    /// <param name="userPassword">用户密码</param>
    /// <param name="clientIP">客户端IP</param>
    /// <param name="strMessage">如登录不成功,返回出错信息</param>
    /// <returns>登录是否成功</returns>
    public bool Login(string userCode, string userPassword, string clientIP, ref string strMessage)
    {
        if (this.HasLogin)
        {
            strMessage = "current connecttion has logged in.";
            return(false);
        }
        Dictionary <string, string> dicParam = new Dictionary <string, string>(2);

        dicParam["username"] = userCode;
        dicParam["password"] = userPassword;
        AccessService.AccessServiceSoapClient access = new AccessServiceSoapClient();
        string resultjson = access.Login(Json.Dictionary2Json(dicParam));
        Dictionary <string, object> dicResult = MyJson.JsonToDictionaryObjValue(resultjson);
        bool checkpass = false;

        if (Tools.GetInt32(dicResult["result"], -9) == 1)
        {
            checkpass = true;
        }
        if (!checkpass)
        {
            strMessage = dicResult["resulttext"].ToString();
            return(false);
        }
        //获取用户信息及权限
        Pro.CoreModel.ReturnValue retVal = new Pro.Web.EALogic.UserLogic().GetUserById(new Pro.CoreModel.UserInfo()
        {
            UserName = userCode
        });
        if (retVal.IsSuccess == false)
        {
            strMessage = dicResult["resulttext"].ToString();
            return(false);
        }
        UserInfo info = retVal.RetObj as UserInfo;

        this.mLogID             = Guid.NewGuid().ToString("N");
        this.mUserCode          = userCode;               //
        this.mUserName          = userCode;               //
        this.mUserCall          = mUserCall.Equals(string.Empty) ? mUserName : info.UserNick;
        this.mUserID            = info.UserID.ToString(); //
        this.mUserRight         = new UserRight(info.UserType.ToString());
        this.mUserRight.IsAdmin = info.UserType == 0;

        return(true);
    }