public static ModelDeleteStatus Delete(int modelID) { UserGroupInfo cacheUserGroupById = UserGroup.GetCacheUserGroupById(modelID); ModelDeleteStatus result; if (cacheUserGroupById == null) { result = ModelDeleteStatus.ModelNotExists; } else if (UserGroup.IsGroupRefingByUser(modelID)) { result = ModelDeleteStatus.UserRef; } else if (BizBase.dbo.DeleteModel <UserGroupInfo>(cacheUserGroupById)) { BizBase.dbo.ExecSQL(" DROP TABLE " + cacheUserGroupById.TableName); CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup"); result = ModelDeleteStatus.Success; } else { CacheUtils.Del("JsonLeeCMS_CacheForGetUserGroup"); result = ModelDeleteStatus.Error; } return(result); }
public static IList <UserFieldInfo> GetFieldListWithValue(int intUserID, int intGroupID) { IList <UserFieldInfo> fieldListByModelID = UserField.GetFieldListByModelID(intGroupID, true); IList <UserFieldInfo> usingFieldList = UserField.GetUsingFieldList(intGroupID); UserGroupInfo cacheUserGroupById = UserGroup.GetCacheUserGroupById(intGroupID); if (cacheUserGroupById != null) { DataTable dataTable = BizBase.dbo.GetDataTable(string.Concat(new object[] { "SELECT * FROM cms_User AS A,", cacheUserGroupById.TableName, " AS B WHERE A.AutoID=", intUserID, " AND B.UserID=", intUserID })); if (dataTable.Rows.Count == 1) { foreach (UserFieldInfo current in fieldListByModelID) { if (dataTable.Columns.Contains(current.FieldName)) { current.Value = dataTable.Rows[0][current.FieldName].ToString(); } else { current.Value = current.DefaultValue; } } } } return(fieldListByModelID); }
public static bool Delete(int intPrimaryKey) { bool result; if (intPrimaryKey <= 0) { result = false; } else { UserInfo dataById = User.GetDataById(intPrimaryKey); UserGroupInfo cacheUserGroupById = UserGroup.GetCacheUserGroupById(dataById.GroupID); if (BizBase.dbo.DeleteTable("cms_User", "AutoID=" + intPrimaryKey.ToString())) { User.Logout(); result = BizBase.dbo.DeleteTable(string.Concat(new object[] { "DELETE FROM ", cacheUserGroupById.TableName, " WHERE UserID=", intPrimaryKey })); } else { result = false; } } return(result); }
public static UserInfo GetUserById(int intUserID) { UserInfo model = BizBase.dbo.GetModel <UserInfo>("cms_User", "AutoID=" + intUserID.ToString()); if (model != null) { model.UserGroup = UserGroup.GetCacheUserGroupById(model.GroupID); model.UserLevel = UserLevel.GetCacheUserLevelById(model.LevelID); model.CustomTable = User.GetCustomContentInfo(intUserID, model.UserGroup.TableName); } return(model); }
public static UserStatus Update(UserInfo userMain, Dictionary <string, UserFieldInfo> dicField) { userMain.RealName = User.GetStringFromDic("RealName", dicField); userMain.Gender = User.GetStringFromDic("Gender", dicField); userMain.Birthday = User.GetDateTimeFromDic("Birthday", dicField, new DateTime(1900, 1, 1)); userMain.NickName = User.GetStringFromDic("NickName", dicField); userMain.HeaderPhoto = User.GetStringFromDic("HeaderPhoto", dicField); userMain.CreditLine = User.GetDecimalFromDic("CreditLine", dicField, 0.0m); userMain.Area = User.GetStringFromDic("Area", dicField); userMain.Country = User.GetStringFromDic("Country", dicField); userMain.Province = User.GetStringFromDic("Province", dicField); userMain.City = User.GetStringFromDic("City", dicField); userMain.County = User.GetStringFromDic("County", dicField); string[] array = userMain.Area.Split(new char[] { ',' }); if (array.Length > 0) { userMain.Province = array[0]; } if (array.Length > 1) { userMain.City = array[1]; } if (array.Length > 2) { userMain.County = array[2]; } userMain.Address = User.GetStringFromDic("Address", dicField); userMain.PostCode = User.GetStringFromDic("PostCode", dicField); userMain.TelePhone = User.GetStringFromDic("TelePhone", dicField); userMain.Remark = User.GetStringFromDic("Remark", dicField); UserStatus result; if (User.IsExistsByName(userMain.UserName, userMain.AutoID)) { result = UserStatus.ExistsUserName; } else if (User.IsExistsByEmail(userMain.Email, userMain.AutoID)) { result = UserStatus.ExistsEmail; } else if (User.IsExistsByMobile(userMain.Mobile, userMain.AutoID)) { result = UserStatus.ExistsMobile; } else if (User.Update(userMain)) { UserGroupInfo cacheUserGroupById = UserGroup.GetCacheUserGroupById(userMain.GroupID); IList <UserFieldInfo> customFieldListByModelID = UserField.GetCustomFieldListByModelID(userMain.GroupID); foreach (UserFieldInfo current in customFieldListByModelID) { if (current.FieldName == "UserID") { current.Value = userMain.AutoID.ToString(); } else { current.Value = User.GetStringFromDic(current.FieldName, dicField); } } User.UpdateCustomUser(userMain.AutoID, cacheUserGroupById.TableName, customFieldListByModelID); result = UserStatus.Success; } else { result = UserStatus.Error; } return(result); }
public static UserStatus Reg(UserInfo userMain, Dictionary <string, UserFieldInfo> dicField, ref int intUserID) { userMain.RealName = User.GetStringFromDic("RealName", dicField); userMain.Gender = User.GetStringFromDic("Gender", dicField); userMain.Birthday = User.GetDateTimeFromDic("Birthday", dicField, new DateTime(1900, 1, 1)); userMain.NickName = User.GetStringFromDic("NickName", dicField); userMain.HeaderPhoto = User.GetStringFromDic("HeaderPhoto", dicField); userMain.CreditLine = User.GetDecimalFromDic("CreditLine", dicField, 0.0m); userMain.Area = User.GetStringFromDic("Area", dicField); userMain.Country = User.GetStringFromDic("Country", dicField); userMain.Province = User.GetStringFromDic("Province", dicField); userMain.City = User.GetStringFromDic("City", dicField); userMain.County = User.GetStringFromDic("County", dicField); userMain.Address = User.GetStringFromDic("Address", dicField); userMain.PostCode = User.GetStringFromDic("PostCode", dicField); userMain.TelePhone = User.GetStringFromDic("TelePhone", dicField); userMain.Remark = User.GetStringFromDic("Remark", dicField); string[] array = userMain.Area.Split(new char[] { ',' }); if (array.Length > 0) { userMain.Province = array[0]; } if (array.Length > 1) { userMain.City = array[1]; } if (array.Length > 2) { userMain.County = array[2]; } userMain.Sort = User.MaxSort + 1; userMain.AutoTimeStamp = DateTime.Now; userMain.LastLoginTime = DateTime.Now; if (userMain.FileSpace.Equals(0)) { userMain.FileSpace = ConfigUtils.GetAppSetting <int>("FileCapacity"); } UserStatus result; if (User.IsExistsByName(userMain.UserName)) { result = UserStatus.ExistsUserName; } else if (User.IsExistsByEmail(userMain.Email)) { result = UserStatus.ExistsEmail; } else if (User.IsExistsByMobile(userMain.Mobile)) { result = UserStatus.ExistsMobile; } else { int num = User.Add(userMain); intUserID = num; if (num > 0) { UserGroupInfo cacheUserGroupById = UserGroup.GetCacheUserGroupById(userMain.GroupID); IList <UserFieldInfo> customFieldListByModelID = UserField.GetCustomFieldListByModelID(userMain.GroupID); foreach (UserFieldInfo current in customFieldListByModelID) { if (current.FieldName == "UserID") { current.Value = num.ToString(); } else { current.Value = User.GetStringFromDic(current.FieldName, dicField); } } User.AddCustomContent(cacheUserGroupById, customFieldListByModelID); result = UserStatus.Success; } else { result = UserStatus.Error; } } return(result); }