protected void Update(XElement xUser, XElement xSecurityEntry) { Modifier.AppendUpdate(xUser); Modifier.AppendCreate(xSecurityEntry); Modifier.Persist(); Modifier.Clear(); }
public static void AppendCreate(this Modifier <XElement> modifier, XElement element, XElement schema) { modifier.AppendCreate(element, element.Name.LocalName, schema); }
public bool Login(string userName, string password, out string errorMessage) { bool result = false; XElement xSecurityEntry = ThreadDataStore.RequestInfo.CreateSecurityEntry(ODataQuerier); xSecurityEntry.SetElementValue("Operation", "Login"); string passwordValue = null; XElement xUser = GetUser(userName); if (xUser == null) { passwordValue = password; errorMessage = "The user name or password is incorrect"; } else { if (ComparePassword(xUser, password)) { if (xUser.Element("IsDisabled").Value == true.ToString()) { errorMessage = "Your account has been disabled, Please contact the administrator"; } else if (xUser.Element("IsLockedOut").Value == true.ToString()) { errorMessage = "Your account has been locked, Please contact the administrator"; } else { errorMessage = null; result = true; UpdateLockedOutState(xUser, true); } xSecurityEntry.SetElementValue("UserId", xUser.Element("Id").Value); xSecurityEntry.SetElementValue("CreatedUserId", xUser.Element("Id").Value); XElement xLoginedUser = GetLoginedUser(userName).Element("element").Elements().First().Elements().First(); xSecurityEntry.SetElementValue("CreatorName", xLoginedUser.Element("Name").Value); } else { passwordValue = password; errorMessage = "The user name or password is incorrect"; UpdateLockedOutState(xUser, false); } } string contents = string.Format("UserName:{0}", userName) + (passwordValue == null ? string.Empty : string.Format(",Password:{0}", passwordValue)); xSecurityEntry.SetElementValue("Contents", contents); xSecurityEntry.SetElementValue("IsFailed", !result); xSecurityEntry.SetElementValue("ErrorMessage", errorMessage); Modifier.AppendCreate(xSecurityEntry); Modifier.Persist(); Modifier.Clear(); return(result); }