Exemplo n.º 1
0
        /// <summary>
        ///  系统登录
        /// </summary>
        /// <param name="branch_id">机构ID</param>
        /// <param name="system_code">子系统代码</param>
        /// <param name="password">口令</param>
        /// <returns>返回错误信息,空为成功</returns>
        public static string Login(int branch_id, string system_code, string password)
        {
            //  完成登录,获取员工相关信息
            //        1. 验证用户口令并获取员工信息记录中的基本内容。
            //        2. 判断子系统使用权限
            //        3. 获取普通角色、行为角色

            List <KeyValuePair <string, string> > parms = new List <KeyValuePair <string, string> >();

            parms.Add(new KeyValuePair <string, string>("branchCode", EnvInfo.BranchCode));
            parms.Add(new KeyValuePair <string, string>("empCode", EmpInfo.Code));
            parms.Add(new KeyValuePair <string, string>("password", DataCryptoHelper.MD5EncryptString(password)));
            parms.Add(new KeyValuePair <string, string>("ip", EnvInfo.ComputerIp));
            CustomException ce       = null;
            int             loginRst = int.Parse(HttpDataHelper.HttpPostFormUrlWithInfo("BASE", "/sys/login", out ce, parms));

            switch (loginRst)
            {
            case -1:
                return("人员不存在!");

            case -2:
                return("密码错误!");

            case 1:
                // 4. 设置环境信息对应的子系统代码、名称
                SelectSystem(system_code, true);
                return(string.Empty);

            default:
                return("服务异常");
            }

            /* TODO 参考
             * EmpInfo.Name = EmpInfo.Id.ToString();
             * EmpInfo.BizEmpName = " 业务" + EmpInfo.Id.ToString();
             * EmpInfo.InputCode = "1";
             *
             * String loginUrl = HttpDataHelper.getUrl("SYSTEM");
             * if (loginUrl != null)
             * {
             *
             *  Dictionary<String, String> dic = HttpDataHelper.PathGet<Dictionary<String, String>>(loginUrl + "login",
             *      new String[] { branch_id.ToString(), system_code, EmpInfo.Id.ToString(), password });
             *
             *  //workplace subSystem判断
             *
             * }
             */
        }
Exemplo n.º 2
0
        public static bool CheckLastDate()
        {
            string key = ConfigurationManager.AppSettings.Get("UserSerial");

            //  检查是否到期
            string lastdate = ConfigurationManager.AppSettings.Get("LastDate");

            lastdate             = DataCryptoHelper.Decrypting(lastdate, key);
            SysInfo.Env.LastDate = Convert.ToDateTime(lastdate);

            if (DateTime.Now > SysInfo.Env.LastDate)
            {
                MessageBox.Show("系统已经过期, 请与供应商联系!");
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 通过配置文件设置机构信息
        /// </summary>
        private static void SetBranchInfo()
        {
            //  获取机构ID,默认为1.
            string sid = ConfigurationManager.AppSettings.Get("BranchId");

            if (!sid.IsNullOrEmpty() && sid.IsInt())
            {
                EnvInfo.BranchId = int.Parse(sid);
            }
            else
            {
                EnvInfo.BranchId = 1;
            }

            string key = ConfigurationManager.AppSettings.Get("UserSerial").Reversal();
            // 获取用户名称
            string rets = ConfigurationManager.AppSettings.Get("UserName");

            if (!string.IsNullOrEmpty(rets))
            {
                rets             = DataCryptoHelper.Decrypting(rets, "Wonder.His" + key);
                EnvInfo.UserName = rets;
            }
            else
            {
                throw new Exception("配置文件中用户名称有误!");
            }

            //try
            //{
            // 系统时间与数据库时间同步
            DateTime d = DateTime.Now;
            //int timezone = int.Parse(DateTime.Now.ToString("%z").Substring(1));

            CustomException ex      = null;
            String          systime = HttpDataHelper.GetStringWithInfo("BASE", "/sys/date", out ex);

            if (ex != null)
            {
                throw ex;
            }
            char[]   spp = new char[] { '-', ':', ' ', '+' };
            string[] tp  = systime.Split(spp, StringSplitOptions.RemoveEmptyEntries);
            int[]    itp = new int[7];
            for (int i = 0; i < 7; i++)
            {
                itp[i] = int.Parse(tp[i]);
            }
            DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(itp[0], itp[1], itp[2], itp[3], itp[4], itp[5]));

            long delta = GetTimeStamp(startTime) - GetTimeStamp(d) - itp[6] * 36000; //时区处理

            if (Math.Abs(delta) < 60000)
            {
                SYSTEMTIME st = new SYSTEMTIME();
                st.FromDateTime(DateTime.Now.AddMilliseconds(delta));
                bool syn = Win32API.SetLocalTime(ref st);
                if (!syn)
                {
                    EnvInfo.ServerTimeDelta = delta;
                }
            }

            //  通过BranchId 查询 名称及代码
            List <KeyValuePair <string, string> > parms = new List <KeyValuePair <string, string> >();

            parms.Add(new KeyValuePair <string, string>("branchId", EnvInfo.BranchId.ToString()));
            CustomException ce     = null;
            CDictBranch     branch = HttpDataHelper.GetWithInfo <CDictBranch>("BASE", "/sys/branch", out ce, parms);

            EnvInfo.BranchCode = branch.Code; // "101";
            EnvInfo.BranchName = branch.Name; // EnvInfo.UserName;

            #region MONGODB 测试
            //ErrorLogInfo eli = new ErrorLogInfo();
            //eli.BranchId = EnvInfo.BranchId;
            //eli.EmpId = EmpInfo.Id;
            //eli.ComputerIp = EnvInfo.ComputerIp;
            //eli.Info = "Try";
            //eli.Message = "Demo message";

            //String json = StringHelper.SerializeObject<ErrorLogInfo>(eli);
            //HttpDataHelper.HttpPostWithInfo"BASE", "/mongo/errorlog/save", json);

            #endregion

            //}
            //catch (Exception ex)
            //{
            //    MessageHelper.ShowError(ex.Message);
            //}
        }