示例#1
0
        public string login()
        {
            objUserData                   = new UserData();
            CommonAPI.LoginInfo           = objUserData;
            objUserData.uuid              = Guid.NewGuid().ToString();
            objUserData.WorkStationSerial = Tools.generateWorkStationGUID();

            SymmetricCryptography symmetricCryptography_0;            //加密器

            symmetricCryptography_0 = new SymmetricCryptography(SymmetricProvider.Rijndael);
            byte[] key = null;
            byte[] iV  = null;

            //系统默认是根据uuid 生成一个算法key的,或者简单理解为uuid就是加密和解密的密码
            CommonAPI.GenerateKey(objUserData.uuid, ref key, ref iV, SymmetricProvider.Rijndael);
            symmetricCryptography_0.Key = key;
            symmetricCryptography_0.IV  = iV;


            objUserData.UserId     = symmetricCryptography_0.EncryptString(m_strUser);         //demo
            objUserData.Password   = symmetricCryptography_0.EncryptString(m_strPassword);     //DEMO
            objUserData.AppServer  = m_strServer;
            objUserData.LanguageID = "zh-CN";
            objUserData.cSubID     = "DP";
            objUserData.operDate   = m_strDate;

            objUserData.DataSource = m_strDataSource;

            Debugger.Log(0, null, UserDataTools.userData2String(objUserData));
            var paras       = new CommonParameters();
            var loginHeader = new LoginedDataHead();

            loginHeader.ChangePwd          = false;
            loginHeader.KickOutWorkStation = false;
            loginHeader.NewPassword        = symmetricCryptography_0.EncryptString("");     //DEMO

            paras.Para1 = "TARGET\\ENTERPRISEPORTAL.EXE";
            paras.Para2 = true;
            paras.Para3 = loginHeader;

            try {
                credit.BFDispatch("Authenticate", objUserData, ref paras);

                if (!string.IsNullOrEmpty(paras.Para1))
                {
                    return(paras.Para1);
                }
            } catch (CustomError cEx) {
                //MessageBox.Show(cEx.Message);
                throw;
            } finally {
            }
        }
示例#2
0
        public static string userData2String(UserData userData)
        {
            var bStrFormat = new StringBuilder();
            var fieldList  = new List <string>(new [] { "UserId", "Password", "AccID", "iYear", "cSubID", "AppServer", "uuid",
                                                        "DataSource", "ConnString", "operDate", "WorkStationSerial", "RightServer",
                                                        "LanguageID", "IsCompanyVer" });
            var i = 0;

            bStrFormat.AppendLine(string.Format("UserId            string          登录名            :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("Password          string          密码              :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("AccID             string          帐套号            :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("iYear             string          年度              :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("cSubID            string          模块              :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("AppServer         string          应用服务器        :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("uuid              string          加密UUID          :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("DataSource        string          数据源            :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("ConnString        string          数据库连接字符串  :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("operDate          string          登录日期          :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("WorkStationSerial string          WorkStationSerial :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("RightServer       string          权限服务器        :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("LanguageID        string          语言              :{{{0}}}", i++));
            bStrFormat.AppendLine(string.Format("IsCompanyVer      bool            IsCompanyVer      :{{{0}}}", i++));


            if (UserDataTools.IsContainField("SecondConnString"))
            {
                bStrFormat.AppendLine(string.Format("SecondConnString  Hashtable       SecondConnString  :{{{0}}}", i++));
                fieldList.Add("SecondConnString");
            }
            if (UserDataTools.IsContainField("EmployeeId"))
            {
                bStrFormat.AppendLine(string.Format("EmployeeId        string          职员              :{{{0}}}", i++));
                fieldList.Add("EmployeeId");
            }
            if (UserDataTools.IsContainField("EntTypeID"))
            {
                bStrFormat.AppendLine(string.Format("EntTypeID         string          EntTypeID         :{{{0}}}", i++));
                fieldList.Add("EntTypeID");
            }
            if (UserDataTools.IsContainField("IsAdmin"))
            {
                bStrFormat.AppendLine(string.Format("IsAdmin           bool            是否帐套管理员    :{{{0}}}", i++));
                fieldList.Add("IsAdmin");
            }
            if (UserDataTools.IsContainField("UserName"))
            {
                bStrFormat.AppendLine(string.Format("UserName          string          登录用户名        :{{{0}}}", i++));
                fieldList.Add("UserName");
            }
            if (UserDataTools.IsContainField("AccName"))
            {
                bStrFormat.AppendLine(string.Format("AccName           string          帐套名称          :{{{0}}}", i++));
                fieldList.Add("AccName");
            }
            if (UserDataTools.IsContainField("iMonth"))
            {
                bStrFormat.AppendLine(string.Format("iMonth            int             登录月份          :{{{0}}}", i++));
                fieldList.Add("iMonth");
            }
            if (UserDataTools.IsContainField("AppServerSerial"))
            {
                bStrFormat.AppendLine(string.Format("AppServerSerial   string          AppServerSerial   :{{{0}}}", i++));
                fieldList.Add("AppServerSerial");
            }
            if (UserDataTools.IsContainField("Roles"))
            {
                bStrFormat.AppendLine(string.Format("Roles             string          Roles             :{{{0}}}", i++));
                fieldList.Add("Roles");
            }
            if (UserDataTools.IsContainField("Auditor"))
            {
                bStrFormat.AppendLine(string.Format("Auditor           _AuditorContext Auditor           :{{{0}}}", i++));
                fieldList.Add("Auditor");
            }
            if (UserDataTools.IsContainField("ProtocolPort"))
            {
                bStrFormat.AppendLine(string.Format("ProtocolPort      Hashtable       ProtocolPort      :{{{0}}}", i++));
                fieldList.Add("ProtocolPort");
            }
            if (UserDataTools.IsContainField("BarCode"))
            {
                bStrFormat.AppendLine(string.Format("BarCode           string          加密狗号          :{{{0}}}", i++));
                fieldList.Add("BarCode");
            }
            if (UserDataTools.IsContainField("Customer"))
            {
                bStrFormat.AppendLine(string.Format("Customer          string          Customer          :{{{0}}}", i++));
                fieldList.Add("Customer");
            }
            if (UserDataTools.IsContainField("AuthenMode"))
            {
                bStrFormat.AppendLine(string.Format("AuthenMode        int             AuthenMode        :{{{0}}}", i++));
                fieldList.Add("AuthenMode");
            }
            if (UserDataTools.IsContainField("AuthenExtraInfo"))
            {
                bStrFormat.AppendLine(string.Format("AuthenExtraInfo   string          AuthenExtraInfo   :{{{0}}}", i++));
                fieldList.Add("AuthenExtraInfo");
            }
            if (UserDataTools.IsContainField("IndustryType"))
            {
                bStrFormat.AppendLine(string.Format("IndustryType      string          IndustryType      :{{{0}}}", i++));
                fieldList.Add("IndustryType");
            }
            if (UserDataTools.IsContainField("isSendIM"))
            {
                bStrFormat.AppendLine(string.Format("isSendIM          bool            isSendIM          :{{{0}}}", i++));
                fieldList.Add("isSendIM");
            }
            if (UserDataTools.IsContainField("iBeginYear"))
            {
                bStrFormat.AppendLine(string.Format("iBeginYear        string          iBeginYear        :{{{0}}}", i++));
                fieldList.Add("AuthenMode");
            }
            if (UserDataTools.IsContainField("AIOServer"))
            {
                bStrFormat.AppendLine(string.Format("AIOServer         string          AIOServer         :{{{0}}}", i++));
                fieldList.Add("AIOServer");
            }
            if (UserDataTools.IsContainField("CrmServer"))
            {
                bStrFormat.AppendLine(string.Format("CrmServer         string          CrmServer         :{{{0}}}", i++));
                fieldList.Add("CrmServer");
            }
            if (UserDataTools.IsContainField("UTUServer"))
            {
                bStrFormat.AppendLine(string.Format("UTUServer         string          UTUServer         :{{{0}}}", i++));
                fieldList.Add("UTUServer");
            }
            if (UserDataTools.IsContainField("isRemind"))
            {
                bStrFormat.AppendLine(string.Format("isRemind          bool            isRemind          :{{{0}}}", i++));
                fieldList.Add("isRemind");
            }
            if (UserDataTools.IsContainField("UserMode"))
            {
                bStrFormat.AppendLine(string.Format("UserMode          int             UserMode          :{{{0}}}", i++));
                fieldList.Add("UserMode");
            }
            if (UserDataTools.IsContainField("ValidateSPS"))
            {
                bStrFormat.AppendLine(string.Format("ValidateSPS       bool            ValidateSPS       :{{{0}}}", i++));
                fieldList.Add("ValidateSPS");
            }
            if (UserDataTools.IsContainField("SysUpgradeDate"))
            {
                bStrFormat.AppendLine(string.Format("SysUpgradeDate    string          SysUpgradeDate    :{{{0}}}", i++));
                fieldList.Add("SysUpgradeDate");
            }

            var objsPara = new String[i];

            for (int j = 0; j < i; j++)
            {
                objsPara[j] = Convert.ToString(FIELDMAP[fieldList[j]].GetValue(userData));
            }


            return(string.Format(bStrFormat.ToString(), objsPara));
        }