public static bool IsFromMany(AssociationTypes associationType) { return (associationType == AssociationTypes.ManyToMany || associationType == AssociationTypes.ManyToZeroOrOne || associationType == AssociationTypes.ManyToOne); }
public static bool IsToZeroOrOne(AssociationTypes associationType) { return (associationType == AssociationTypes.ZeroOrOneToZeroOrOne || associationType == AssociationTypes.OneToZeroOrOne || associationType == AssociationTypes.ManyToZeroOrOne); }
public static bool IsFromZeroOrOne(AssociationTypes associationType) { return (associationType == AssociationTypes.ZeroOrOneToZeroOrOne || associationType == AssociationTypes.ZeroOrOneToOne || associationType == AssociationTypes.ZeroOrOneToMany); }
public static bool IsFromSingleToSingle(AssociationTypes associationType) { return (associationType == AssociationTypes.ZeroOrOneToZeroOrOne || associationType == AssociationTypes.ZeroOrOneToOne || associationType == AssociationTypes.OneToZeroOrOne || associationType == AssociationTypes.OneToOne); }
public static bool IsSymetric(NavigationProperty property) { AssociationTypes associationType = GetAssociationType(property); return (associationType == AssociationTypes.ZeroOrOneToZeroOrOne || associationType == AssociationTypes.OneToOne); }
public bool ChangeUserToGroupAssociation(MGGroup group, List <int> usersIDs, AssociationTypes associationType) { bool ISChanged = true; DbInfo = new DatabaseWrapper(Lcf); string sql = ""; string partMSG = "'" + associationType + "ing' (" + usersIDs.Count + ") users to Group '" + group.Name + "'"; try { Logger.Log("Start " + partMSG); DbInfo.Connect(); foreach (int userID in usersIDs) { if (associationType == AssociationTypes.Assign) { sql = GroupQB.GetAssignGroupForUserSql(userID, group.ID); } else { sql = GroupQB.GetUnAssignGroupForUserSql(userID, group.ID); } bool success = false; int numChanged = DbInfo.ExecuteSQL(sql, ref success); if (numChanged == 0) { ISChanged = false; } } } catch (Exception ex) { Logger.LogError(5, "Error " + partMSG + " at: " + ex); return(false); } finally { if (ISChanged) { SecureContentWrapper.SecurityHasBeenModifiedThisSession = true; } if (DbInfo != null) { DbInfo.Disconnect(); } } return(ISChanged); }
//--------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Change the group association for a given user. /// It can assign the groups to a user and also can un assign groups linked to a user. /// 30-Jan-2015 - added the bool toggle on whether or not to use the session wrapper. This causes an issue with threaded applications as in the /// worker thread the session wrappers are not available. /// </summary> /// <param name="groupsIDs">Group Ids to Assign or UnAssign</param> /// <param name="associationType">Assign or UnAssign</param> /// <returns>True if successfull, false other wise</returns> public bool ChangeGroupToUserAssociation(int userID, List <int> groupsIDs, AssociationTypes associationType, bool recordModificationInSessionWrapper) { bool isChangeSuccess = true; DbInfo = new DatabaseWrapper(Lcf); string sql = ""; try { DbInfo.Connect(); foreach (int groupID in groupsIDs) { if (associationType == AssociationTypes.Assign) { sql = GroupQB.GetAssignGroupForUserSql(userID, groupID); } else { sql = GroupQB.GetUnAssignGroupForUserSql(userID, groupID); } bool success = false; int numChanged = DbInfo.ExecuteSQL(sql, ref success); if (numChanged == 0) { isChangeSuccess = false; } } } catch (Exception ex) { Logger.LogError(5, "Error in changing group association at: " + ex); isChangeSuccess = false; } finally { if (isChangeSuccess && recordModificationInSessionWrapper) { SecureContentWrapper.SecurityHasBeenModifiedThisSession = true; if (DbInfo != null) { DbInfo.Disconnect(); } } } return(isChangeSuccess); }
private void PopulateAssociationTypes() { var typesData = HttpHelper.Get<AssociationTypesData>(serviceBaseUri+"/AssociationTypes"); var associationTypes = new AssociationTypes(); mapper.MapList(typesData, associationTypes, typeof (AssociationType)); ViewData["associationTypes"] = associationTypes; }
public static bool IsFromSingleToMany(AssociationTypes associationType) { return (associationType == AssociationTypes.ZeroOrOneToMany || associationType == AssociationTypes.OneToMany); }
/// <summary> /// Get Users for a given Group. It populate only (3) three User Information (UserName, JobTitle, Email) /// </summary> /// <param name="group">Group for which to find users.</param> /// <param name="associationTypes">Assigned and Unassigned user to group.</param> /// <returns></returns> public List <MGUser> GetUsersForAGroup(MGGroup group, string searchString, AssociationTypes associationTypes) { List <MGUser> result = null; IDataReader reader = null; string strUserID = null; int userID = -1; string sql = ""; string msgPart = "getting users which are '" + associationTypes + "ed' to Group '" + group.Name + "'"; bool isLockAcquired = Monitor.TryEnter(UserAdministration.USER_ADMIN_LOCK_OBJ, UserAdministration.USER_ADMIN_LOCK_TIMEOUT); if (isLockAcquired) { try { Logger.Log("Start " + msgPart); DbInfo = new DatabaseWrapper(Lcf); DbInfo.Connect(); sql = GroupQB.GetSelectUsersForAGroupSql(group.ID, searchString, associationTypes); reader = DbInfo.RunSqlReader(sql); if (reader == null) { Logger.LogError(5, "Quitting, failed " + msgPart + " with sql : " + sql); return(null); } result = new List <MGUser>(); while (reader.Read()) { strUserID = null; userID = -1; MGUser user = new MGUser(); //Get USER ID if (reader[GroupQB.USER_ID_GENERAL_COL] != System.DBNull.Value) { strUserID = reader[GroupQB.USER_ID_GENERAL_COL].ToString(); if (!int.TryParse(strUserID, out userID)) { userID = -1; Logger.LogError(5, "Error parsing user ID into integer. Quitting"); return(null); } } user.ID = userID; //Get User Name if (reader[GroupQB.USER_NAME_COL] != System.DBNull.Value) { user.Username = SecureStringWrapper.Encrypt((string)reader[GroupQB.USER_NAME_COL]); } else { Logger.LogWarning("Null or empty User is found for ID =" + user.ID + ". Please check the database!"); user.Username = SecureStringWrapper.Encrypt(""); } //Get User EMAIL if (reader[GroupQB.USER_EMAIL_COL] != System.DBNull.Value) { user.Email = SecureStringWrapper.Encrypt((string)reader[GroupQB.USER_EMAIL_COL]); } else { Logger.LogWarning("Null or empty Email is found for ID =" + user.ID + ". Please check the database!"); user.Email = SecureStringWrapper.Encrypt(""); } //Get User Job Title if (reader[GroupQB.USER_JOBTITLE_COL] != System.DBNull.Value) { user.JobTitle = SecureStringWrapper.Encrypt((string)reader[GroupQB.USER_JOBTITLE_COL]); } else { //Logger.LogWarning("Null or empty job title is found for ID =" + user.ID + ". Please check the database!"); user.JobTitle = SecureStringWrapper.Encrypt(""); } result.Add(user); } } catch (Exception ex) { Logger.LogError(5, "Error " + msgPart + " at: " + ex); return(null); } finally { Monitor.Exit(UserAdministration.USER_ADMIN_LOCK_OBJ); if (reader != null && !reader.IsClosed) { reader.Close(); } if (DbInfo != null) { DbInfo.Disconnect(); } } } else { Logger.LogError(5, "Failed to get exclusive lock in GetUsersForAGroup when " + msgPart); return(null); } return(result); }