public void SetAsDefault(User user, HeadQuarter headQuarter) { if (user == null || headQuarter == null) throw new ArgumentException(string.Format("User {0} or HeadQuater {1} not found!", user.LoginId, headQuarter.Description)); hqRepository.UpdateUserHeadQuarter(user, headQuarter); }
public HeadQuarterEditor(HeadQuarter headQ = null) { InitializeComponent(); VM = new HeadQuarterEditorViewModel(headQ); VM.View = this; DataContext = VM; }
/// <summary> /// public constrcutor /// </summary> /// <param name="dispatcher">Dispatcher instance to send updates to DIS.Presentation.KMT. This should be passed null from automated unit tests.</param> public HeadQuarterEditorViewModel(HeadQuarter hq, IHeadQuarterProxy headQuarterProxy) { if (headQuarterProxy == null) this.headQuarterProxy = new HeadQuarterProxy(); else this.headQuarterProxy = headQuarterProxy; if (hq == null) { HeadQuarter = new HeadQuarter(); EditMode = false; Title = Resources.CreateHeadQuarterViewModel_Title_New;//later HeadContent = Resources.CreateHeadQuarterViewModel_HeadContent_Add;//later } else { HeadQuarter = hq; EditMode = true; Title = Resources.CreateHeadQuarterViewModel_Title_Edit; HeadContent = Resources.CreateHeadQuarterViewModel_HeadContent_Edit; } InitializeCollections(HeadQuarter); }
//Import Fulfilled Keys File from ULS public List<KeyOperationResult> ImportULSFulfilledKeys(string filePath, HeadQuarter currentHeadQuarter, bool isCheckFileSignature) { Constants.ImportFileType fileType = ValidateImportKeysFile(filePath); try { ExportKeyList keys = GetKeysByImpotFile(filePath, fileType); if (fileType == Constants.ImportFileType.R6_Encrypted || fileType == Constants.ImportFileType.R6_NonEncrypted) { if (keys.UserName != currentHeadQuarter.UserName) throw new DisException("ImportKey_InvalidUserName"); if (fileType == Constants.ImportFileType.R6_NonEncrypted && (!isCheckFileSignature)) { if (keys.AccessKey != currentHeadQuarter.AccessKey) throw new DisException("ImportKey_InvalidPsdOrFile"); } else { if (keys.AccessKey != GenerateHmacValue(currentHeadQuarter.AccessKey, keys.Keys)) throw new DisException("ImportKey_InvalidPsdOrFile"); } } else { if (keys.UserName != currentHeadQuarter.DisplayName) throw new DisException("ImportKey_InvalidUserName"); } return ImportFulfilledKeys(keys.Keys.ToKeyInfo()); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { ExceptionHandler.HandleException(ex); throw new DisException("Exception_ImportFileInvalid"); } }
public void UpdateHeadQuarter(HeadQuarter headQuarter) { hqRepository.UpdateHeadQuarter(headQuarter); }
public void InsertHeadQuarter(HeadQuarter headQuarter) { hqRepository.InsertHeadQuarter(headQuarter); }
public void InsertHeadQuarter(HeadQuarter headQuarter) { using (var context = GetContext()) { context.HeadQuarters.Add(headQuarter); if (Constants.IsMultipleEnabled) { var users = context.Roles.Single(r => r.RoleName == Constants.ManagerRoleName).Users.ToList(); foreach (User u in users) { context.UserHeadQuarters.Add(new UserHeadQuarter() { HeadQuarter = headQuarter, UserId = u.UserId, IsDefault = (u.UserHeadQuarters.Count() == 0) }); } } else { foreach (User u in context.Users) { context.UserHeadQuarters.Add(new UserHeadQuarter() { HeadQuarter = headQuarter, User = u, IsDefault = true }); } } context.SaveChanges(); } }
public void UpdateUserHeadQuarter(User user, HeadQuarter headQuarter) { using (var context = GetContext()) { context.UserHeadQuarters .Where(u => u.UserId == user.UserId).ToList() .ForEach(hq => hq.IsDefault = (hq.HeadQuarterId == headQuarter.HeadQuarterId)); context.SaveChanges(); } }
public void UpdateHeadQuarter(HeadQuarter headQuarter) { using (var context = GetContext()) { var hq = GetHeadQuarter(context, headQuarter.HeadQuarterId); if (hq == null) throw new ApplicationException(string.Format("Head quarter '{0}' cannot be found.", headQuarter.HeadQuarterId)); context.Entry(hq).CurrentValues.SetValues(headQuarter); context.SaveChanges(); } }
public HeadQuarterEditorViewModel(HeadQuarter ss = null) : this(ss, null) { }
private void InitializeCollections(HeadQuarter current) { try { CustomerNumber = current.CustomerNumber; AccessKey = current.AccessKey; UserName = current.Name; } catch (Exception ex) { ex.ShowDialog(); ExceptionHandler.HandleException(ex); } }
//import fulfilled keys from ULS public new List<KeyOperationResult> ImportULSFulfilledKeys(string filePath, HeadQuarter headquarter, bool IsCheckFileSignature) { return base.ImportULSFulfilledKeys(filePath, headquarter, IsCheckFileSignature); }
/// <summary> /// Initialize UI according selected HeadQuarter /// </summary> /// <param name="current"></param> private void Initialize(HeadQuarter current) { try { ULSName = current.DisplayName; UserName = current.UserName; AccessKey = current.AccessKey; Description = current.Description; IsCarbonCopy = current.IsCarbonCopy; if (!string.IsNullOrEmpty(current.ServiceHostUrl)) { Uri uri = new Uri(current.ServiceHostUrl); Host = uri.Host; Port = uri.Port.ToString(); } sourceULSName = current.DisplayName; sourceUserName = current.UserName; sourceHost = Host; sourcePort = Port; sourceDescription = current.Description; sourceAccessKey = AccessKey; sourceCarbonCopy = IsCarbonCopy; isCentralizedMode = current.IsCentralizedMode; } catch (Exception ex) { ex.ShowDialog(); ExceptionHandler.HandleException(ex); } }