예제 #1
0
        private void DecryptEntity(object entity)
        {
            //Get all the properties that are encryptable and decyrpt them
            var encryptedProperties = entity.GetType().GetProperties()
                                      .Where(p => p.GetCustomAttributes(typeof(Encrypted), true).Any(a => p.PropertyType == typeof(String)));

            foreach (var property in encryptedProperties)
            {
                string encryptedValue = property.GetValue(entity) as string;

                if (!String.IsNullOrEmpty(encryptedValue))
                {
                    string value = EncryptionUtility.Decryption(encryptedValue);
                    Entry(entity).Property(property.Name).OriginalValue = value;
                    Entry(entity).Property(property.Name).IsModified    = false;
                }
            }
        }
예제 #2
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            var property = validationContext.ObjectType.GetProperty(OtherProperty);

            if (property == null)
            {
                return(new ValidationResult(string.Format(CultureInfo.CurrentCulture, "Unknown property {0}", OtherProperty)));
            }

            var otherValue = property.GetValue(validationContext.ObjectInstance, null) as string;

            if (string.Equals(EncryptionUtility.Decryption(value as string),
                              EncryptionUtility.Decryption(otherValue)))
            {
                return(null);
            }

            return(new ValidationResult(this.FormatErrorMessage(validationContext.DisplayName)));
        }
예제 #3
0
    private void Useronline()
    {
        string text  = this.txtName.Value.Trim();
        string text2 = this.txtPwd.Value.Trim();
        string iP    = this.GetIP();

        if (!this.IsRuleByText(text) || !this.IsRuleByText(text2))
        {
            string script = "<script>jw.alert('对不起!用户名或者密码输入错误,请重新输入!');</script>";
            base.ClientScript.RegisterStartupScript(base.GetType(), "IsRule", script);
            return;
        }
        HttpCookie httpCookie = base.Request.Cookies["cbPass"];

        if (httpCookie != null && text2 == "justwin")
        {
            text2 = EncryptionUtility.Decryption(httpCookie.Value);
        }
        object obj   = userManageDb.ValidatorLoginAccess(text, text2);
        string text3 = (obj == null) ? string.Empty : obj.ToString();
        int    num   = this.IsReturnLogin(text3);

        if (string.IsNullOrEmpty(text3))
        {
            string script2 = "<script>jw.alert('系统提示', '对不起!用户名或者密码错误,请重新输入!');</script>";
            base.ClientScript.RegisterStartupScript(base.GetType(), "JavaScript", script2);
            return;
        }
        SysManageDb sysManageDb = new SysManageDb();

        this.Session["SysID"]  = sysManageDb.GetDefault().ToString();
        this.Session["yhdm"]   = text3;
        this.Session["yhdma"]  = text3;
        this.Session["SkinID"] = userManageDb.getUserSkin(text3);
        this.Session["SkinID"] = "4";
        this.Session["PmSet"]  = PmTypeAction.GetPmType(obj.ToString());
        this.Session["ptcs"]   = myxml.Getcs(base.Server.MapPath("/ptcs.txt"));
        this.Session["pttest"] = "notest";
        if (this.Session["pttest"].ToString() != "notest" && (this.Session["ptcs"] == null || Convert.ToInt32(this.Session["ptcs"]) >= 200))
        {
            string str     = "请找甲乙软件联系。";
            string script3 = string.Format("<script>jw.alert('试用已到期;如需要继续使用,\\r\\n'+'" + str + "');</script>", new object[0]);
            base.ClientScript.RegisterStartupScript(base.GetType(), "Startup", script3);
            return;
        }
        this.Session["OpModules"] = userManageDb.GetUserOpModules(this.Session["yhdm"].ToString());
        this.Session["CorpCode"]  = userManageDb.GetCorpCode(this.Session["yhdm"].ToString());
        HttpCookie httpCookie2 = new HttpCookie("LogName");

        httpCookie2.Values["key1"] = "zyg";
        httpCookie2.Expires        = DateTime.Now.AddHours(2.0);
        base.Response.Cookies.Add(httpCookie2);
        loginLogDb loginLogDb = new loginLogDb();

        loginLogDb.UserlLoginInfo(iP, this.Session["yhdm"].ToString());
        if (num == 0)
        {
            this.AddUserInfo(this.Session["yhdm"].ToString(), false);
        }
        else
        {
            base.Application.Lock();
            DataTable dataTable = (DataTable)base.Application["UserCodeCollection"];
            foreach (DataRow dataRow in dataTable.Rows)
            {
                if (dataRow["userCode"].ToString() == text3)
                {
                    dataRow["loginTime"] = DateTime.Now;
                    dataRow["endTime"]   = DateTime.Now;
                    dataRow["ip"]        = iP;
                    break;
                }
            }
            base.Application["UserCodeCollection"] = dataTable;
            base.Application.UnLock();
        }
        FormsAuthentication.RedirectFromLoginPage(text3, false);
        AduitAction.AddToLog(text3, "登录系统", iP, text);
        this.LogUserInfo();
        base.Response.Redirect("./SysFrame2/Desktop.aspx");
    }