Ejemplo n.º 1
0
        private void btnReg_Click(object sender, System.EventArgs e)
        {
            //读硬盘的序列号
            string       str_SerialNumber;
            HardDiskInfo hdd = AtapiDevice.GetHddInfo(0);             // 第一个硬盘

            str_SerialNumber = hdd.SerialNumber.ToString();

            DESEncryptor dese1 = new DESEncryptor();

            dese1.InputString = str_SerialNumber;
            dese1.EncryptKey  = "lhgynkm0";
            dese1.DesEncrypt();
            string miWen = dese1.OutString;

            dese1 = null;

            err = null;
            string strresult = cs.Register(miWen, SysInitial.LocalDeptName, SysInitial.CurOps.strOperName, out err);

            if (strresult == "connection")
            {
                MessageBox.Show("中心数据库连接失败,请检查网再重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            else
            {
                MessageBox.Show("注册申请已经发送至中心,请等待注册完成后,再重新启动系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return;
            }
        }
Ejemplo n.º 2
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            if (this.comboBox1.SelectedIndex == 0)
            {
                string       seckey  = "tjlx4Xd_dXa6xsC3pq-uX92h";
                DESEncryptor cryptor = new DESEncryptor(seckey);
                this.txtEncrypt.Text = cryptor.Encrypt(this.txtPlain.Text);
            }
            if (this.comboBox1.SelectedIndex == 1)
            {
                RSAEncryptor cryptor = new RSAEncryptor(null, null);
                this.txtEncrypt.Text = cryptor.Encrypt(this.txtPlain.Text);
            }
            if (this.comboBox1.SelectedIndex == 2) //HMACSHA256
            {
                RSAEncryptor cryptor = new RSAEncryptor(null, null);
                this.txtEncrypt.Text = cryptor.Encrypt(this.txtPlain.Text);
            }
            else
            {
                string   pwd = "800:6cc3cfc47dbd03c1cbc60398b0988a:186e5678c8b40921e56e847807b7de";
                string[] arr = pwd.Split(':');


                HMACSHA1Encryptor eb = new HMACSHA1Encryptor(arr[1], Convert.ToInt32(arr[0]));

                string arreer = eb.Encrypt("1");
            }
        }
Ejemplo n.º 3
0
        public static string DecodePassword(string password, EPasswordFormat passwordFormat, string passwordSalt)
        {
            var retval = string.Empty;

            if (passwordFormat == EPasswordFormat.Clear)
            {
                retval = password;
            }
            else if (passwordFormat == EPasswordFormat.Hashed)
            {
                throw new Exception("can not decode hashed password");
            }
            else if (passwordFormat == EPasswordFormat.Encrypted)
            {
                var encryptor = new DESEncryptor
                {
                    InputString = password,
                    DecryptKey  = passwordSalt
                };
                encryptor.DesDecrypt();

                retval = encryptor.OutString;
            }
            return(retval);
        }
Ejemplo n.º 4
0
        public void Init()
        {
            DES _newDes = DESEncryptor.CreateDES("yanzhiweizhuzhouhunanchina");

            _newDes.IV = new byte[8] {
                0x01, 0x02, 0x03, 0x4, 0x05, 0x06, 0x07, 0x08
            };
            desHelper = new DESEncryptor(_newDes.Key, _newDes.IV);
        }
Ejemplo n.º 5
0
        internal static string DecryptStorageString(string sKey, string sValue)
        {
            DESEncryptor Mydes = new DESEncryptor();
            Mydes.DecryptKey = sKey;
            Mydes.InputString = sValue;
            Mydes.DesDecrypt();

            return Mydes.OutString;
        }
Ejemplo n.º 6
0
 internal static string DecryptTransString(string sValue)
 {
     DESEncryptor Mydes = new DESEncryptor();
     Mydes.DecryptKey = DateTime.Now.ToString("yyyy-MM-dd");
     Mydes.InputString = sValue;
     Mydes.DesDecrypt();
     
     return Mydes.OutString;
 }
Ejemplo n.º 7
0
        internal static string DecryptTransString(string sValue)
        {
            DESEncryptor Mydes = new DESEncryptor();

            Mydes.DecryptKey  = DateTime.Now.ToString("yyyy-MM-dd");
            Mydes.InputString = sValue;
            Mydes.DesDecrypt();

            return(Mydes.OutString);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 加密字符串
        /// </summary>
        /// <param name="strText">明文</param>
        /// <returns>密文</returns>
        public static string Encrypt(string strText)
        {
            //return Encrypt(strText,ENCRYPT_KEY + ENCRYPT_KEY);
            DESEncryptor dese = new DESEncryptor();

            dese.InputString = strText;
            dese.EncryptKey  = "cmsmyykx";
            dese.DesEncrypt();
            return(dese.OutString);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 解密字符串
        /// </summary>
        /// <param name="strCrypto">密文</param>
        /// <returns>明文</returns>
        public static string Decrypt(string strCrypto)
        {
            //return Decrypt(strCrypto,ENCRYPT_KEY + ENCRYPT_KEY);
            DESEncryptor dese = new DESEncryptor();

            dese.InputString = strCrypto;
            dese.DecryptKey  = "cmsmyykx";
            dese.DesDecrypt();
            return(dese.OutString);
        }
Ejemplo n.º 10
0
        internal static string DecryptStorageString(string sKey, string sValue)
        {
            DESEncryptor Mydes = new DESEncryptor();

            Mydes.DecryptKey  = sKey;
            Mydes.InputString = sValue;
            Mydes.DesDecrypt();

            return(Mydes.OutString);
        }
Ejemplo n.º 11
0
        static public void desConstring(string strpath)
        {
            string strdes = "";

            if (strDesFlag == "0")
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(strpath + @"\CMSM.exe.config");
                XmlNode keyNode = null;

                DESEncryptor dese = new DESEncryptor();
                dese.InputString = ConString;
                dese.EncryptKey  = "cmsmyykx";
                dese.DesEncrypt();
                strdes = dese.OutString;
                dese   = null;

                keyNode = doc.SelectSingleNode("/configuration/appSettings/add[@key='DBAMSCM']");
                keyNode.Attributes["value"].Value = strdes;

                dese             = new DESEncryptor();
                dese.InputString = CenterConString;
                dese.EncryptKey  = "cmsmyykx";
                dese.DesEncrypt();
                strdes = dese.OutString;
                dese   = null;

                keyNode = doc.SelectSingleNode("/configuration/appSettings/add[@key='DBAMSCMCenter']");
                keyNode.Attributes["value"].Value = strdes;

                keyNode = doc.SelectSingleNode("/configuration/appSettings/add[@key='DFLAG']");
                keyNode.Attributes["value"].Value = "1";
                doc.Save(strpath + @"\CMSM.exe.config");
            }
            else
            {
                DESEncryptor dese = new DESEncryptor();
                dese.InputString = ConString;
                dese.DecryptKey  = "cmsmyykx";
                dese.DesDecrypt();
                strdes = dese.OutString;
                dese   = null;

                ConString = strdes;

                dese             = new DESEncryptor();
                dese.InputString = CenterConString;
                dese.DecryptKey  = "cmsmyykx";
                dese.DesDecrypt();
                strdes = dese.OutString;
                dese   = null;

                CenterConString = strdes;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 记录用户登录信息
        /// </summary>
        /// <param name="model">用户登录返回信息类</param>
        protected void RecordUserCookies(Model.User user)
        {
            var userMemberId = new HttpCookie("uid")
            {
                Value   = DESEncryptor.Encrypt(user.UserId.ToString()),
                Domain  = defaultDomain,
                Expires = DateTime.MinValue
            };

            Response.Cookies.Add(userMemberId);
        }
Ejemplo n.º 13
0
        public void TestDesEncy()
        {
            DESEncryptor Mydes = new DESEncryptor();
            Mydes.EncryptKey = "Client2";
            Mydes.InputString = "1234567890";
            
            Mydes.DesEncrypt();

            string sResult = Mydes.OutString;

            Assert.IsNotNullOrEmpty(sResult);
        }
Ejemplo n.º 14
0
        public void TestDesEncy()
        {
            DESEncryptor Mydes = new DESEncryptor();

            Mydes.EncryptKey  = "Client2";
            Mydes.InputString = "1234567890";

            Mydes.DesEncrypt();

            string sResult = Mydes.OutString;

            Assert.IsNotNullOrEmpty(sResult);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 把用户信息存到cookie和session中
        /// </summary>
        /// <param name="_customer"></param>
        /// <param name="_isPersistent"></param>
        /// <param name="_expiresTime"></param>
        private void passPort(Model.Customer _customer, bool _isPersistent, DateTime?_expiresTime)
        {
            System.Web.HttpContext context = System.Web.HttpContext.Current;

            context.Session[sessionKey] = _customer;
            HttpCookie newcookie = new HttpCookie(idCookieKey);

            newcookie.Value = DESEncryptor.Encrypt(_customer.CusId.ToString());
#if !DEBUG
            newcookie.Domain = defaultDomain;
#endif
            context.Response.AppendCookie(newcookie);
        }
        private void Login2(HttpContext context)
        {
            if ((RequestUsername != null && RequestUsername.Length > 0) && (RequestPWD != null && RequestPWD.Length > 0))
            {
                int    ret = 0;
                string url = string.Empty;

                //域账号
                string username = RequestUsername.ToLower();

                ret = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(username, DESEncryptor.Encrypt(RequestPWD));
                if (ret > 0)
                {
                    currentContext.Session["UserName"] = username;
                    BitAuto.YanFa.SysRightManager.Common.UserInfo.passport(ret);
                    string gourl = ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath").Replace("~", "");//ConfigurationUtil.GetAppSettingValue("NotAccessMsgPagePath")
                    if (!string.IsNullOrEmpty(RequestGoURL))
                    {
                        gourl = RequestGoURL;
                    }
                    else
                    {
                        DataTable dtParent = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetParentModuleInfoByUserID(Convert.ToInt32(currentContext.Session["userid"]), sysID);
                        if (dtParent != null)
                        {
                            DataTable dtChild = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetChildModuleByUserId(Convert.ToInt32(currentContext.Session["userid"]), sysID, dtParent.Rows[0]["moduleid"].ToString());
                            if (dtChild.Rows.Count > 0)
                            {
                                gourl = dtChild.Rows[0]["url"].ToString();
                            }
                        }
                    }
                    ret = 1;//登陆成功
                    string content = string.Format("用户{1}(ID:{0})登录成功。", currentContext.Session["userid"], currentContext.Session["truename"]);
                    BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Login, content);
                    url = gourl;
                }
                else if (ret == -1)
                {
                    ret = -8;
                }
                else if (ret == -2)
                {
                    ret = -7;
                }
                //int msg = Bll.UserInfo.Login(Page.Request.Form["username"].Trim(), Page.Request.Form["pwd"].Trim());
                context.Response.Write(ret.ToString() + "," + url);
                context.Response.End();
                return;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Create a new instance of Usuario application service
        /// </summary>
        /// <param name="repository">Repository dependency</param>
        public UsuarioAppService(IUsuarioRepository repository)
        {
            if (repository == null)
            {
                throw new ArgumentNullException("repository", ApplicationResources.exception_WithoutRepository);
            }
            _repositoryUsuario = repository;
            DES _newDes = DESEncryptor.CreateDES("WebApp.AppServices");

            _newDes.IV = new byte[8] {
                0x01, 0x02, 0x03, 0x4, 0x05, 0x06, 0x07, 0x08
            };
            desHelper = new DESEncryptor(_newDes.Key, _newDes.IV);
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 数据库初始化
 /// </summary>
 private void DBInit()
 {
     MongoHelper<User> helperUser = new MongoHelper<User>();
     if (helperUser.Count() == 0)
     {
         User user;
         user = new User();
         user.usercode = "admin";
         user.pwd = DESEncryptor.DesEncrypt("123456");
         user.email = "*****@*****.**";
         user.username = "******";
         helperUser.Insert(user);
     }
 }
Ejemplo n.º 19
0
        private bool CreateNotice(string strdownfiles, string strid)
        {
            #region 加载系统通知
            ArrayList alDownNoti = new ArrayList();
            alDownNoti = m1.DownNotice(strid);
            if (alDownNoti == null)
            {
                clog.WriteLine("加载系统通知错误");
                return(false);
            }
            #endregion

            StreamWriter   swFile = new StreamWriter(strdownfiles + ".tmp", true);
            StructToString sts    = new StructToString();

            #region 写系统通知
            CMSMStruct.NoticeStruct notitmp = null;
            swFile.WriteLine("NOTITOL=" + alDownNoti.Count.ToString());
            for (int i = 0; i < alDownNoti.Count; i++)
            {
                notitmp = alDownNoti[i] as CMSMStruct.NoticeStruct;
                swFile.WriteLine(sts.ToNoticeString(notitmp));
            }
            swFile.WriteLine("END");
            #endregion

            swFile.Close();

            #region 加密
            DESEncryptor dese = new DESEncryptor();
            dese.InputFilePath = strdownfiles + ".tmp";
            dese.OutFilePath   = strdownfiles;
            dese.EncryptKey    = "cmsmyykx";
            dese.FileDesEncrypt();
            if (dese.NoteMessage != null)
            {
                clog.WriteLine(dese.NoteMessage);
                return(false);
            }
            dese = null;
            #endregion

            if (System.IO.File.Exists(strdownfiles + ".tmp"))
            {
                System.IO.File.Delete(strdownfiles + ".tmp");
            }

            return(true);
        }
Ejemplo n.º 20
0
        private bool CreateDataLocal(string strlasttime, string strdownfiles)
        {
            #region 加载会员资料
            ArrayList alDownUser = new ArrayList();
            alDownUser = m1.DownAssData(strlasttime);
            if (alDownUser == null)
            {
                clog.WriteLine("加载会员资料错误");
                return(false);
            }
            #endregion

            StreamWriter swFile = new StreamWriter(strdownfiles + ".tmp", true);

            #region 写会员资料
            CMSMStruct.AssociatorStruct asstmp = null;
            StructToString sts = new StructToString();
            swFile.WriteLine("USERTOL=" + alDownUser.Count.ToString());
            for (int i = 0; i < alDownUser.Count; i++)
            {
                asstmp = alDownUser[i] as CMSMStruct.AssociatorStruct;
                swFile.WriteLine(sts.ToAssString(asstmp));
            }
            swFile.WriteLine("END");
            #endregion

            swFile.Close();

            #region 加密
            DESEncryptor dese = new DESEncryptor();
            dese.InputFilePath = strdownfiles + ".tmp";
            dese.OutFilePath   = strdownfiles;
            dese.EncryptKey    = "cmsmyykx";
            dese.FileDesEncrypt();
            if (dese.NoteMessage != null)
            {
                clog.WriteLine(dese.NoteMessage);
                return(false);
            }
            dese = null;
            #endregion

            if (System.IO.File.Exists(strdownfiles + ".tmp"))
            {
                System.IO.File.Delete(strdownfiles + ".tmp");
            }

            return(true);
        }
Ejemplo n.º 21
0
        public static string Decrypt(string inputString)
        {
            if (string.IsNullOrEmpty(inputString))
            {
                return(string.Empty);
            }

            var encryptor = new DESEncryptor
            {
                InputString = inputString,
                DecryptKey  = "TgQQk42O"
            };

            encryptor.DesDecrypt();
            return(encryptor.OutString);
        }
Ejemplo n.º 22
0
        public void EncryptionRoundTrip()
        {
            string data = "Hello World!";
              string plainTextData = string.Copy(data);
              string encryptedData;

              var encryptor = new DESEncryptor()
                        {
                          EncryptionKey = "12345678"
                        };

              encryptedData = encryptor.Encrypt(plainTextData);
              plainTextData = encryptor.Decrypt(encryptedData);

              Assert.AreEqual(data, plainTextData);
              Assert.AreNotEqual(data, encryptedData);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 检验是否登录,如果已登录,把用户信息放到session里。
        /// </summary>
        public bool CheckLogin()
        {
            System.Web.HttpContext context = System.Web.HttpContext.Current;
            bool isLogin = true;

            if (context.Request.Cookies[idCookieKey] == null || context.Request.Cookies[idCookieKey].Value == "")
            {
                isLogin = false;
            }
            else
            {
                int            uid     = Int32.Parse(DESEncryptor.Decrypt(context.Request.Cookies[idCookieKey].Value));
                Model.Customer cusInfo = new Monitor().GetCustomerInfoByUserId(uid);
                context.Session[sessionKey] = cusInfo;
            }
            return(isLogin);
        }
Ejemplo n.º 24
0
 public ActionResult BaseCallback(string code, string state)
 {
     Loger.Current.Write("OAuth2RedirectController.BaseCallback() begin code=" + code + ",state=" + state);
     if (!string.IsNullOrEmpty(code))
     {
         var result = OAuth.GetAccessToken(appId, secret, code);
         if (result.errcode == ReturnCode.请求成功)
         {
             Loger.Current.Write("OAuth2RedirectController.BaseCallback() begin openid=" + result.openid);
             //openid存到cookie
             var sOpenId = new HttpCookie("openid")
             {
                 //Value = DESEncryptor.Encrypt(result.openid),
                 Value   = result.openid,
                 Domain  = defaultDomain,
                 Expires = DateTime.MinValue
             };
             Response.Cookies.Add(sOpenId);
             // 根据OpenId找MemberId存到cookie
             var uid = Model.User.GetUserIdByOpenId(result.openid);
             if (uid > 0)
             {
                 var userMemberId = new HttpCookie("uid")
                 {
                     Value   = DESEncryptor.Encrypt(uid.ToString()),
                     Domain  = defaultDomain,
                     Expires = DateTime.MinValue
                 };
                 Response.Cookies.Add(userMemberId);
             }
             else
             {
                 var httpCookie = Request.Cookies["uid"];
                 if (httpCookie != null)
                 {
                     httpCookie.Value   = string.Empty;
                     httpCookie.Expires = DateTime.Now.AddDays(-1);
                 }
             }
         }
     }
     Loger.Current.Write("OAuth2RedirectController.BaseCallback() end");
     return(Redirect(state));
 }
Ejemplo n.º 25
0
        public object submit([FromBody] simpleUser siuser)
        {
            DBInit();//数据库初始化

            string token;
            MongoHelper<User> helperUser = new MongoHelper<User>();
            User user = helperUser.FindAll(x => x.usercode == siuser.usercode).First();
            if (user != null)
            {
                //验证密码
                if (user.pwd == DESEncryptor.DesEncrypt(siuser.password))
                {
                    SSO.SsoHelper.SignIn(new SSO.UserInfo { UserCode = siuser.usercode, UserName = user.username, CreateDate = DateTime.Now }, out token);
                    return new { flag = true, username = user.username, token = token };
                }
            }

            return new { flag = false, username = "", token = "" };
        }
Ejemplo n.º 26
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            IEncryptor cryptor = null;

            if (this.comboBox1.SelectedIndex == 0)
            {
                cryptor = new DESEncryptor(string.Empty);
            }
            else if (this.comboBox1.SelectedIndex == 1)
            {
                cryptor = new RSAEncryptor(null, null);
            }
            else if (this.comboBox1.SelectedIndex == 2)
            {
                cryptor = new HMACSHA256Encryptor(string.Empty);
            }

            this.txtDecrypt.Text = cryptor.Decrypt(this.txtEncrypt.Text);
        }
Ejemplo n.º 27
0
        public static string DecryptStringBySecretKey(string inputString)
        {
            if (string.IsNullOrEmpty(inputString))
            {
                return(string.Empty);
            }

            inputString = inputString.Replace("0add0", "+").Replace("0equals0", "=").Replace("0and0", "&").Replace("0question0", "?").Replace("0quote0", "'").Replace("0slash0", "/");

            var encryptor = new DESEncryptor
            {
                InputString = inputString,
                DecryptKey  = FileConfigManager.Instance.SecretKey
            };

            encryptor.DesDecrypt();

            return(encryptor.OutString);
        }
Ejemplo n.º 28
0
        public static string EncodePassword(string password, EPasswordFormat passwordFormat, out string passwordSalt)
        {
            var retval = string.Empty;

            passwordSalt = string.Empty;

            if (passwordFormat == EPasswordFormat.Clear)
            {
                retval = password;
            }
            else if (passwordFormat == EPasswordFormat.Hashed)
            {
                passwordSalt = GenerateSalt();

                var src     = Encoding.Unicode.GetBytes(password);
                var buffer2 = Convert.FromBase64String(passwordSalt);
                var dst     = new byte[buffer2.Length + src.Length];
                Buffer.BlockCopy(buffer2, 0, dst, 0, buffer2.Length);
                Buffer.BlockCopy(src, 0, dst, buffer2.Length, src.Length);
                var algorithm = HashAlgorithm.Create("SHA1");
                if (algorithm == null)
                {
                    return(retval);
                }
                var inArray = algorithm.ComputeHash(dst);

                retval = Convert.ToBase64String(inArray);
            }
            else if (passwordFormat == EPasswordFormat.Encrypted)
            {
                passwordSalt = GenerateSalt();

                var encryptor = new DESEncryptor
                {
                    InputString = password,
                    EncryptKey  = passwordSalt
                };
                encryptor.DesEncrypt();

                retval = encryptor.OutString;
            }
            return(retval);
        }
Ejemplo n.º 29
0
        public static string EncryptStringBySecretKey(string inputString)
        {
            if (string.IsNullOrEmpty(inputString))
            {
                return(string.Empty);
            }

            var encryptor = new DESEncryptor
            {
                InputString = inputString,
                EncryptKey  = FileConfigManager.Instance.SecretKey
            };

            encryptor.DesEncrypt();

            var retval = encryptor.OutString;

            retval = retval.Replace("+", "0add0").Replace("=", "0equals0").Replace("&", "0and0").Replace("?", "0question0").Replace("'", "0quote0").Replace("/", "0slash0");

            return(retval);
        }
Ejemplo n.º 30
0
        private void button1_Click(object sender, EventArgs e)
        {
            //读硬盘的序列号
            string strInfo   = "";
            string strMyName = "";
            //HardDiskInfo hdd = AtapiDevice.GetHddInfo(0); // 第一个硬盘
            //str_SerialNumber = hdd.SerialNumber.ToString();
            ManagementClass            cimobject = new ManagementClass("Win32_Processor");
            ManagementObjectCollection moc       = cimobject.GetInstances();

            strMyName = Dns.GetHostName();
            foreach (ManagementObject mo in moc)
            {
                strInfo = mo.Properties["ProcessorId"].Value.ToString();
            }
            strMyName += strInfo;

            DESEncryptor dese1 = new DESEncryptor();

            dese1.InputString = strMyName;
            dese1.EncryptKey  = "lhgynkm0";
            dese1.DesEncrypt();
            string miWen = dese1.OutString;

            dese1 = null;

            err = null;
            string strresult = cs.Register(miWen, SysInitial.LocalDeptName, SysInitial.CurOps.strOperName, out err);

            if (strresult == "connection")
            {
                MessageBox.Show("中心数据库连接失败,请检查网再重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            else
            {
                MessageBox.Show("注册申请已经发送至中心,请等待注册完成后,再重新启动系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return;
            }
        }
        private void UpdateUserPassword(HttpContext context)
        {
            string msg = VerifyData();

            if (msg == string.Empty)
            {
                try
                {
                    string oldPwd = DESEncryptor.Encrypt(RequestOldPWD);
                    string pwd    = DESEncryptor.Encrypt(RequestPWD);
                    int    ret    = BitAuto.YanFa.SysRightManager.Common.UserInfo.Login(RequestUsername, oldPwd);
                    if (ret > 0)
                    {
                        BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.UpdateUserPassword(ret, pwd);
                        string content = string.Format("用户{1}(ID:{0})修改密码{2}为{3}成功。", ret, RequestUsername, oldPwd, pwd);
                        BitAuto.YanFa.SysRightManager.Common.LogInfo.Instance.InsertLog(ConfigurationUtil.GetAppSettingValue("LoginLogModuleID"), (int)BitAuto.YanFa.SysRightManager.Common.LogInfo.ActionType.Update, content);
                        msg = "success";
                    }
                    else if (ret == -1)
                    {
                        msg = "原密码不正确";
                    }
                    else if (ret == -2)
                    {
                        msg = "不存在此帐号";
                    }
                    else if (ret == -3)
                    {
                        msg = "此帐号已停用";
                    }
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                }
            }
            context.Response.Write(msg);
            context.Response.End();
        }
Ejemplo n.º 32
0
        private AutoResetEvent _StopEvent;           //线程暂停时件
        #endregion

        #region 构造函数
        public frmSync()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();
            strDBCenterCon = ConfigAdapter.GetConfigNote("appsettings", "DBCenter");
            strDBClientCon = ConfigAdapter.GetConfigNote("connectionstrings", "DBAMSCM", "name", "connectionString");

            string strdes     = "";
            string strDesFlag = ConfigAdapter.GetConfigNote("appsettings", "DFLAG");

            if (strDesFlag == "1")
            {
                DESEncryptor dese = new DESEncryptor();
                dese.InputString = strDBClientCon;
                dese.DecryptKey  = "cmsmyykx";
                dese.DesDecrypt();
                strdes         = dese.OutString;
                dese           = null;
                strDBClientCon = strdes;

                dese             = new DESEncryptor();
                dese.InputString = strDBCenterCon;
                dese.DecryptKey  = "cmsmyykx";
                dese.DesDecrypt();
                strdes         = dese.OutString;
                dese           = null;
                strDBCenterCon = strdes;
            }

            conCenter = new SqlConnection(strDBCenterCon);
            conClient = new SqlConnection(strDBClientCon);


            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
Ejemplo n.º 33
0
        private AutoResetEvent _StopEvent;           //线程暂停时件
//		private enum SyncPlan:string {"LocalToCenter","LoadCenter","CenterToLocal"};
        #endregion

        #region 构造函数
        public frmSync()
        {
            //
            // Windows 窗体设计器支持所必需的
            //
            InitializeComponent();
//			strDBCenterCon="server=127.0.0.1;uid=sa;pwd=sa;database=AMSCMCenter";//测试用
//			strDBClientCon="server=127.0.0.1;uid=sa;pwd=sa;database=AMSCM_DongLai";//测试用
            strDBCenterCon = ConfigAdapter.GetConfigNote("DBCenter");
            strDBClientCon = ConfigAdapter.GetConfigNote("DBAMSCM");
            string strdes     = "";
            string strDesFlag = ConfigAdapter.GetConfigNote("DFLAG");

            if (strDesFlag == "1")
            {
                DESEncryptor dese = new DESEncryptor();
                dese.InputString = strDBClientCon;
                dese.DecryptKey  = "cmsmyykx";
                dese.DesDecrypt();
                strdes         = dese.OutString;
                dese           = null;
                strDBClientCon = strdes;

                dese             = new DESEncryptor();
                dese.InputString = strDBCenterCon;
                dese.DecryptKey  = "cmsmyykx";
                dese.DesDecrypt();
                strdes         = dese.OutString;
                dese           = null;
                strDBCenterCon = strdes;
            }

            conCenter = new SqlConnection(strDBCenterCon);
            conClient = new SqlConnection(strDBClientCon);

            //
            // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            //
        }
        /// <summary>
        /// 监控平台初始化
        /// </summary>
        public static void Init()
        {
            //

            //1.初始化超级用户
            User user;
            MongoHelper <User> helperUser = new MongoHelper <User>(WcfGlobal.MongoConnStr, MonitorPlatformManage.dbName);

            user = helperUser.Find(Query.EQ("usercode", new MongoDB.Bson.BsonString("admin")));
            if (user != null)
            {
                //如果存在先删除
                helperUser.Delete(user);
            }
            user          = new User();
            user.usercode = "admin";
            user.pwd      = DESEncryptor.DesEncrypt("123456");
            user.email    = "*****@*****.**";
            user.username = "******";
            helperUser.Insert(user);
            //2.初始化中间件根节点
            MongoHelper <MidNode> helperNode = new MongoHelper <MidNode>(WcfGlobal.MongoConnStr, MonitorPlatformManage.dbName);
            MidNode node;

            node = helperNode.Find(Query.EQ("identify", new MongoDB.Bson.BsonString(WcfGlobal.Identify)));
            if (node != null)
            {
                //如果存在先删除
                helperNode.Delete(node);
            }
            node             = new MidNode();
            node.nodename    = "根节点";
            node.machinecode = "";
            node.regcode     = CoreFrame.Init.HostSettingConfig.GetValue("cdkey");
            node.identify    = WcfGlobal.Identify;
            node.createdate  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            node.delflag     = 0;
            helperNode.Insert(node);
        }