protected void UpdatePermissionsList(User user) { if(!this.InvokeRequired) { var zones = QuicheProvider.Instance.Client.GetAll<Zone>(); var terminals = QuicheProvider.Instance.Client.GetAll<Terminal>(); this.zonesList.BeginUpdate(); this.zonesList.Items.Clear(); this.terminalsList.Items.Clear(); foreach (Zone z in zones) this.zonesList.Items.Add(z, false); foreach (Terminal u in terminals) this.terminalsList.Items.Add(u, false); this.zonesList.EndUpdate(); this.authorisedTerminalList.SuspendLayout(); this.authorisedZoneList.SuspendLayout(); this.authorisedTerminalList.Items.Clear(); this.authorisedZoneList.Items.Clear(); if (user != null && user.TerminalWhiteList!=null && user.TerminalWhiteList.Count > 0) { foreach(ushort t in user.TerminalWhiteList) { var term = terminals.Where( x => x.ReferenceId == t).SingleOrDefault(); if (term != null) this.authorisedTerminalList.Items.Add(term); } } if (user != null && user.ZoneWhiteList!=null && user.ZoneWhiteList.Count > 0) { foreach(ushort t in user.ZoneWhiteList) { var term = zones.Where( x => x.Id == t.ToString()).SingleOrDefault(); if (term != null) this.authorisedZoneList.Items.Add(term); } } this.authorisedTerminalList.ResumeLayout(); this.authorisedZoneList.ResumeLayout(); } else this.BeginInvoke(new Action<User>(this.UpdatePermissionsList), new object[]{ user }); }
void SaveUserButtonClick(object sender, EventArgs e) { User u = new User() { Name = this.nameBox.Text , LastIssued = DateTime.Now, Id = this.cardIdBox.Text}; this.issuedBox.Text = u.LastIssued.ToString(); QuicheProvider.Instance.Cache.Store(u); }
protected void SelectUser(User user) { if (user!=null) { this.nameBox.Text = user.Name; this.issuedBox.Text = user.LastIssued.ToString(); var remote = QuicheProvider.Instance.Client.Get<User>(user.Id); user.TerminalWhiteList = remote.TerminalWhiteList; user.ZoneWhiteList = remote.ZoneWhiteList; } this.UpdateLogView(); this.saveUserButton.Enabled = true; this.createReplicaButton.Enabled = true; this.readButton.Text = "Clear"; this.readButton.Enabled = true; this.UpdatePermissionsList(user); }