public void EditForDisplay(SystemUserGDSAccessRight gdsAccessRight) { //System User SystemUser systemUser = new SystemUser(); SystemUserRepository systemUserRepository = new SystemUserRepository(); systemUser = systemUserRepository.GetUserBySystemUserGuid(gdsAccessRight.SystemUserGuid); if (systemUser != null) { gdsAccessRight.SystemUser = systemUser; } }
public void UpdateAdminUserProfile(string userProfileIdentifier, string connectionString) { //try login user SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUser systemUser = systemUserRepository.GetUserBySystemUserGuid(userProfileIdentifier); //store userdata in cookie for Forms Authentication AccountRepository accountRepository = new AccountRepository(); accountRepository.persistUser(systemUser.SystemUserGuid, connectionString); //update login TimeStamp systemUserRepository.UpdateSystemUserLastLoginTimestamp(userProfileIdentifier); }
/// <summary> /// Select a list of connection strings from the web.config /// Only users with the Military and Government user flag checked should be able to access the M&G flagged databases /// If a user does not have the Military and Government user flag checked, the database droplist should not display the M&G instances /// </summary> /// <returns></returns> public List <classConnectionStrings> SelectListConnectionStrings() { List <classConnectionStrings> items = new List <classConnectionStrings>(); string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; SystemUser systemUser = systemUserRepository.GetUserBySystemUserGuid(adminUserGuid); bool userHasMilitaryAndGovernmentAccess = (systemUser.MilitaryAndGovernmentUserFlag == true); if (System.Configuration.ConfigurationManager.ConnectionStrings.Count > 1) { foreach (ConnectionStringSettings cs in System.Configuration.ConfigurationManager.ConnectionStrings) { if (cs.Name != "LocalSqlServer" && cs.Name != "CreditCardDatabase") { if (!isMilitaryAndGovernmentDatabase(cs.Name)) { items.Add( new classConnectionStrings { Name = cs.Name, Value = cs.Name, } ); } else if (userHasMilitaryAndGovernmentAccess && isMilitaryAndGovernmentDatabase(cs.Name)) { items.Add( new classConnectionStrings { Name = cs.Name, Value = cs.Name, } ); } } } } return(items.ToList()); }
//Add Data From Linked Tables for Display public void EditForDisplay(SystemUserTeam systemUserTeam) { SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserTeam.SystemUserGuid); if (systemUser != null) { systemUserTeam.SystemUserName = (systemUser.LastName + ", " + systemUser.FirstName + " " + systemUser.MiddleName).Replace(" ", " "); } TeamRepository teamRepository = new TeamRepository(); Team team = new Team(); team = teamRepository.GetTeam(systemUserTeam.TeamId); if (team != null) { systemUserTeam.TeamName = team.TeamName; } }
//Add Data From Linked Tables for Display public void EditForDisplay(SystemUserGDS systemUserGDS) { SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserGDS.SystemUserGuid); if (systemUser != null) { systemUserGDS.SystemUserName = (systemUser.LastName + ", " + systemUser.FirstName + " " + systemUser.MiddleName).Replace(" ", " "); } GDSRepository gdsRepository = new GDSRepository(); GDS gds = new GDS(); gds = gdsRepository.GetGDS(systemUserGDS.GDSCode); if (gds != null) { systemUserGDS.GDSName = gds.GDSName; } }
//Add Data From Linked Tables for Display public void EditUserRoleForDisplay(AdministratorRoleHierarchyLevelTypeSystemUser administratorRoleHierarchyLevelTypeSystemUser) { SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(administratorRoleHierarchyLevelTypeSystemUser.SystemUserGuid); if (systemUser != null) { administratorRoleHierarchyLevelTypeSystemUser.SystemUserName = (systemUser.LastName + ", " + systemUser.FirstName + " " + systemUser.MiddleName).Replace(" ", " "); } AdministratorRoleHierarchyLevelTypeRepository administratorRoleHierarchyLevelTypeRepository = new AdministratorRoleHierarchyLevelTypeRepository(); AdministratorRoleHierarchyLevelType administratorRoleHierarchyLevelType = new AdministratorRoleHierarchyLevelType(); administratorRoleHierarchyLevelType = administratorRoleHierarchyLevelTypeRepository.GetAdministratorRoleHierarchyLevelType( administratorRoleHierarchyLevelTypeSystemUser.AdministratorRoleId, administratorRoleHierarchyLevelTypeSystemUser.HierarchyLevelTypeId ); if (administratorRoleHierarchyLevelType != null) { administratorRoleHierarchyLevelTypeSystemUser.AdministratorRoleHierarchyLevelTypeName = administratorRoleHierarchyLevelType.AdministratorRoleHierarchyLevelTypeName; } }
//Update Location SystemUsers public WizardMessages UpdateLocationSystemUsers(LocationWizardVM locationChanges, WizardMessages wizardMessages) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; Location location = new Location(); location = locationChanges.Location; bool changesExist = false; // Create the xml document container XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null); doc.AppendChild(dec); XmlElement root = doc.CreateElement("LocationSystemUsers"); doc.AppendChild(root); SystemUserRepository systemUserRepository = new SystemUserRepository(); if (locationChanges.SystemUsersAdded != null) { if (locationChanges.SystemUsersAdded.Count > 0) { changesExist = true; //xml = xml + "<SystemUsersAdded>"; XmlElement xmlSystemUsersAdded = doc.CreateElement("SystemUsersAdded"); foreach (SystemUser item in locationChanges.SystemUsersAdded) { SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid); string systemUserName = systemUser.FirstName + (item.MiddleName != "" ? item.MiddleName + " " : "") + systemUser.LastName; //xml = xml + "<SystemUser>"; //xml = xml + "<SystemUserName>" + systemUserName + "</SystemUserName>"; //xml = xml + "<SystemUserGuid>" + item.SystemUserGuid + "</SystemUserGuid>"; //xml = xml + "</SystemUser>"; XmlElement xmlSystemUser = doc.CreateElement("SystemUser"); xmlSystemUsersAdded.AppendChild(xmlSystemUser); XmlElement xmlSystemUserName = doc.CreateElement("SystemUserName"); xmlSystemUserName.InnerText = systemUserName; xmlSystemUser.AppendChild(xmlSystemUserName); XmlElement xmlSystemUserGuid = doc.CreateElement("SystemUserGuid"); xmlSystemUserGuid.InnerText = item.SystemUserGuid; xmlSystemUser.AppendChild(xmlSystemUserGuid); } root.AppendChild(xmlSystemUsersAdded); //xml = xml + "</SystemUsersAdded>"; } } if (locationChanges.SystemUsersRemoved != null) { if (locationChanges.SystemUsersRemoved.Count > 0) { changesExist = true; //xml = xml + "<SystemUsersRemoved>"; XmlElement xmlSystemUsersRemoved = doc.CreateElement("SystemUsersRemoved"); foreach (SystemUser item in locationChanges.SystemUsersRemoved) { SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid); string systemUserName = systemUser.FirstName + (item.MiddleName != "" ? item.MiddleName + " " : "") + systemUser.LastName; //xml = xml + "<SystemUser>"; //xml = xml + "<SystemUserName>" + systemUserName + "</SystemUserName>"; //xml = xml + "<SystemUserGuid>" + item.SystemUserGuid + "</SystemUserGuid>"; //xml = xml + "</SystemUser>"; XmlElement xmlSystemUser = doc.CreateElement("SystemUser"); xmlSystemUsersRemoved.AppendChild(xmlSystemUser); XmlElement xmlSystemUserName = doc.CreateElement("SystemUserName"); xmlSystemUserName.InnerText = systemUserName; xmlSystemUser.AppendChild(xmlSystemUserName); XmlElement xmlSystemUserGuid = doc.CreateElement("SystemUserGuid"); xmlSystemUserGuid.InnerText = item.SystemUserGuid; xmlSystemUser.AppendChild(xmlSystemUserGuid); } root.AppendChild(xmlSystemUsersRemoved); //xml = xml + "</SystemUsersRemoved>"; } } //xml = xml + "</LocationSystemUsers>"; if (changesExist) { var output = (from n in db.spDDAWizard_UpdateLocationSystemUsers_v1( location.LocationId, System.Xml.Linq.XElement.Parse(doc.OuterXml), adminUserGuid) select n).ToList(); foreach (spDDAWizard_UpdateLocationSystemUsers_v1Result message in output) { wizardMessages.AddMessage(message.MessageText.ToString(), (bool)message.Success); } } return(wizardMessages); }
//Compare two Locations and return a list of messages about changes public WizardMessages BuildLocationChangeMessages(WizardMessages wizardMessages, LocationWizardVM originalLocationViewModel, LocationWizardVM updatedLocationViewModel) { /*Location*/ LocationRepository locationRepository = new LocationRepository(); Location originalLocation = new Location(); Location updatedLocation = new Location(); //If Editing a Location if (originalLocationViewModel != null) { originalLocation = originalLocationViewModel.Location; locationRepository.EditForDisplay(originalLocation); } updatedLocation = updatedLocationViewModel.Location; locationRepository.EditForDisplay(updatedLocation); if (originalLocation.LocationId == 0) { wizardMessages.AddMessage("A new Location \"" + updatedLocation.LocationName + "\" has been added.", true); } else { if (originalLocation.LocationName != updatedLocation.LocationName) { wizardMessages.AddMessage("Location Name will be updated to \"" + updatedLocation.LocationName + "\".", true); } if (originalLocation.CountryCode != updatedLocation.CountryCode) { wizardMessages.AddMessage("Location Country will be updated to \"" + updatedLocation.CountryRegionName + "\".", true); } if (originalLocation.CountryRegionId != updatedLocation.CountryRegionId) { wizardMessages.AddMessage("Location Country Region will be updated to \"" + updatedLocation.CountryRegionName + "\".", true); } } /*Address*/ AddressRepository addressRepository = new AddressRepository(); Address originalAddress = new Address(); Address updatedAddress = new Address(); if (originalLocationViewModel != null) { originalAddress = originalLocationViewModel.Address; if (originalAddress != null) { addressRepository.EditForDisplay(originalAddress); } } updatedAddress = updatedLocationViewModel.Address; addressRepository.EditForDisplay(updatedAddress); if (originalAddress == null) { //need this for Comparisons to work originalAddress = new Address(); } if (originalAddress.FirstAddressLine != updatedAddress.FirstAddressLine || originalAddress.SecondAddressLine != updatedAddress.SecondAddressLine) { wizardMessages.AddMessage("Address Lines will be updated", true); } if (originalAddress.CityName != updatedAddress.CityName) { wizardMessages.AddMessage("City will be updated to \"" + updatedAddress.CityName + "\".", true); } if (originalAddress.StateProvinceCode != updatedAddress.StateProvinceCode) { wizardMessages.AddMessage("State/Province will be updated to \"" + updatedAddress.StateProvinceName + "\".", true); } if (originalAddress.CountyName != updatedAddress.CountyName) { wizardMessages.AddMessage("County will be updated to \"" + updatedAddress.CountyName + "\".", true); } if (originalAddress.LatitudeDecimal != updatedAddress.LatitudeDecimal) { wizardMessages.AddMessage("Latitude will be updated to \"" + updatedAddress.LatitudeDecimal + "\".", true); } if (originalAddress.LongitudeDecimal != updatedAddress.LongitudeDecimal) { wizardMessages.AddMessage("Longitude will be updated to \"" + updatedAddress.LongitudeDecimal + "\".", true); } if (originalAddress.MappingQualityCode != updatedAddress.MappingQualityCode) { wizardMessages.AddMessage("Mapping Quality Code will be updated to \"" + updatedAddress.MappingQualityCode + "\".", true); } if (originalAddress.PostalCode != updatedAddress.PostalCode) { wizardMessages.AddMessage("PostalCode will be updated to \"" + updatedAddress.PostalCode + "\".", true); } if (originalAddress.ReplicatedFromClientMaintenanceFlag != updatedAddress.ReplicatedFromClientMaintenanceFlag) { wizardMessages.AddMessage("Replicated from ClientMaintenance Flag will be updated to \"" + updatedAddress.ReplicatedFromClientMaintenanceFlag + "\".", true); } //Not Needed - Country is also Part of Location //if (originalAddress.CountryCode != updatedAddress.CountryCode) //{ // wizardMessages.AddMessage("Country will be updated to \"" + updatedAddress.CountryName + "\".", true); //} /*Systemusers*/ SystemUserRepository systemUserRepository = new SystemUserRepository(); SystemUserLocationRepository systemUserLocationRepository = new SystemUserLocationRepository(); if (updatedLocationViewModel.SystemUsersAdded != null) { if (updatedLocationViewModel.SystemUsersAdded.Count > 0) { foreach (SystemUser item in updatedLocationViewModel.SystemUsersAdded) { SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid); if (systemUser != null) { wizardMessages.AddMessage("You will add User \"" + systemUser.LastName + "," + (systemUser.MiddleName != "" ? systemUser.MiddleName + " " : "") + systemUser.FirstName + "\".", true); SystemUserLocation systemUserLocation = new SystemUserLocation(); systemUserLocation = systemUserLocationRepository.GetSystemUserLocation(item.SystemUserGuid); if (systemUserLocation != null) { systemUserLocationRepository.EditForDisplay(systemUserLocation); wizardMessages.AddMessage("The user will be moved from Location: " + systemUserLocation.LocationName + ".", true); } } } } } if (updatedLocationViewModel.SystemUsersRemoved != null) { if (updatedLocationViewModel.SystemUsersRemoved.Count > 0) { foreach (SystemUser item in updatedLocationViewModel.SystemUsersRemoved) { SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid); if (systemUser != null) { wizardMessages.AddMessage("You will remove User \"" + systemUser.LastName + "," + (systemUser.MiddleName != "" ? systemUser.MiddleName + " " : "") + systemUser.FirstName + "\".", true); } } } } return(wizardMessages); }
//Compare two Teams and return a list of messages about changes public WizardMessages BuildTeamChangeMessages(WizardMessages wizardMessages, Team originalTeam, TeamWizardVM teamChanges) { TeamRepository teamRepository = new TeamRepository(); ClientSubUnitRepository clientSubUnitRepository = new ClientSubUnitRepository(); SystemUserRepository systemUserRepository = new SystemUserRepository(); Team updatedTeam = new Team(); updatedTeam = teamChanges.Team; //teamRepository.EditGroupForDisplay(updatedTeam); removed- gets info from original Team if (originalTeam == null) { wizardMessages.AddMessage("A new Team \"" + updatedTeam.TeamName + "\"has been added.", true); } else { if (originalTeam.TeamName != updatedTeam.TeamName) { wizardMessages.AddMessage("Team Name will be updated to \"" + updatedTeam.TeamName + "\".", true); } if (originalTeam.TeamEmail != updatedTeam.TeamEmail) { wizardMessages.AddMessage("Team Email will be updated to \"" + updatedTeam.TeamEmail + "\".", true); } if (originalTeam.TeamPhoneNumber != updatedTeam.TeamPhoneNumber) { wizardMessages.AddMessage("Team phone Number will be updated to \"" + updatedTeam.TeamPhoneNumber + "\".", true); } if (originalTeam.CityCode != updatedTeam.CityCode) { wizardMessages.AddMessage("Team City Code will be updated to \"" + updatedTeam.CityCode + "\".", true); } if (originalTeam.TeamQueue != updatedTeam.TeamQueue) { wizardMessages.AddMessage("Team Queue will be updated to \"" + updatedTeam.TeamQueue + "\".", true); } if (originalTeam.TeamTypeCode != updatedTeam.TeamTypeCode) { TeamType teamType = new TeamType(); TeamTypeRepository teamTypeRepository = new TeamTypeRepository(); teamType = teamTypeRepository.GetTeamType(updatedTeam.TeamTypeCode); wizardMessages.AddMessage("Team Type will be updated to \"" + teamType.TeamTypeDescription + "\".", true); } if (originalTeam.HierarchyType != updatedTeam.HierarchyType) { wizardMessages.AddMessage("Hierarchy will be updated to \"" + updatedTeam.HierarchyType + "\".", true); } if (originalTeam.HierarchyItem != updatedTeam.HierarchyItem) { wizardMessages.AddMessage(updatedTeam.HierarchyType + " value will be updated to \"" + updatedTeam.HierarchyItem + "\".", true); } if (originalTeam.TravelerTypeGuid != updatedTeam.TravelerTypeGuid) { wizardMessages.AddMessage("TravelerType will be updated to \"" + updatedTeam.TravelerTypeName + "\".", true); } } if (teamChanges.SystemUsersAdded != null) { if (teamChanges.SystemUsersAdded.Count > 0) { foreach (SystemUser item in teamChanges.SystemUsersAdded) { SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid); if (systemUser != null) { wizardMessages.AddMessage("You will add User \"" + systemUser.LastName + "," + (systemUser.MiddleName != "" ? systemUser.MiddleName + " " : "") + systemUser.FirstName + "\".", true); } } } } if (teamChanges.SystemUsersRemoved != null) { if (teamChanges.SystemUsersRemoved.Count > 0) { foreach (SystemUser item in teamChanges.SystemUsersRemoved) { SystemUser systemUser = new SystemUser(); systemUser = systemUserRepository.GetUserBySystemUserGuid(item.SystemUserGuid); if (systemUser != null) { wizardMessages.AddMessage("You will remove User \"" + systemUser.LastName + "," + (systemUser.MiddleName != "" ? systemUser.MiddleName + " " : "") + systemUser.FirstName + "\".", true); } } } } if (teamChanges.ClientSubUnitsAdded != null) { if (teamChanges.ClientSubUnitsAdded.Count > 0) { foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsAdded) { ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid); if (clientSubUnit != null) { wizardMessages.AddMessage("You will add ClientSubUnit \"" + clientSubUnit.ClientSubUnitName + "\".", true); } } } } if (teamChanges.ClientSubUnitsRemoved != null) { if (teamChanges.ClientSubUnitsRemoved.Count > 0) { foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsRemoved) { ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid); if (clientSubUnit != null) { wizardMessages.AddMessage("You will remove ClientSubUnit \"" + clientSubUnit.ClientSubUnitName + "\".", true); } } } } if (teamChanges.ClientSubUnitsAltered != null) { if (teamChanges.ClientSubUnitsAltered.Count > 0) { foreach (ClientSubUnitTeam item in teamChanges.ClientSubUnitsAltered) { ClientSubUnit clientSubUnit = new ClientSubUnit(); clientSubUnit = clientSubUnitRepository.GetClientSubUnit(item.ClientSubUnitGuid); if (clientSubUnit != null) { wizardMessages.AddMessage("You will alter ClientSubUnit \"" + clientSubUnit.ClientSubUnitName + "\".", true); } } } } return(wizardMessages); }