private void buttonEdit_Click(object sender, EventArgs e) { Monitor.Enter(CcowServer.LockObject); try { using (Database db = Leadtools.Ccow.Server.Utils.GetDatabase()) { Guid appId = (Guid)listViewApplications.SelectedItems[0].Tag; CCOWApplication app = db.CCOWApplication.First(a => a.Id == appId); ApplicationDialog addDialog = new ApplicationDialog(app); if (addDialog.ShowDialog(this) == DialogResult.OK) { try { db.SubmitChanges(); UpdateItem(listViewApplications.SelectedItems[0], app); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } finally { Monitor.Exit(CcowServer.LockObject); } }
private void buttonDelete_Click(object sender, EventArgs e) { Monitor.Enter(CcowServer.LockObject); try { using (Database db = Leadtools.Ccow.Server.Utils.GetDatabase()) { Guid appId = (Guid)listViewApplications.SelectedItems[0].Tag; CCOWApplication app = db.CCOWApplication.First(a => a.Id == appId); try { db.CCOWApplication.DeleteOnSubmit(app); db.SubmitChanges(); listViewApplications.Items.Remove(listViewApplications.SelectedItems[0]); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } finally { Monitor.Exit(CcowServer.LockObject); } }
private void AddApplication(CCOWApplication app) { ListViewItem item = listViewApplications.Items.Add(app.Name); item.Checked = app.Allowed.Value; item.ImageIndex = !string.IsNullOrEmpty(app.Passcode) ? 0 : -1; item.Tag = app.Id; }
public ApplicationDialog(CCOWApplication application) : this() { _App = application; AppName.Text = _App.Name; Passcode.Text = _App.Passcode; Active.Checked = _App.Allowed.Value; Suffix.Text = _App.Suffix; Text = "Edit Application"; }
private void ApplicationListDialog_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { foreach (ListViewItem item in listViewApplications.SelectedItems) { CCOWApplication app = item.Tag as CCOWApplication; _AllowedApps.Add(app); } } }
private void AddApplicationDialog_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { if (_App == null) { _App = new CCOWApplication(); _App.Id = Guid.NewGuid(); } _App.Name = AppName.Text; _App.Passcode = Passcode.Text; _App.Allowed = Active.Checked; _App.Suffix = Suffix.Text; } }
private void listViewApplications_ItemChecked(object sender, ItemCheckedEventArgs e) { if (e.Item.Tag == null) { return; } Monitor.Enter(CcowServer.LockObject); try { using (Database db = Leadtools.Ccow.Server.Utils.GetDatabase()) { Guid appId = (Guid)e.Item.Tag; CCOWApplication app = db.CCOWApplication.First(a => a.Id == appId); app.Allowed = e.Item.Checked; db.SubmitChanges(); } } finally { Monitor.Exit(CcowServer.LockObject); } }
public LoginDialog(CCOWApplication application) { InitializeComponent(); _CCOWApplication = application; }
private void UpdateItem(ListViewItem item, CCOWApplication app) { item.Checked = app.Allowed.Value; item.ImageIndex = !string.IsNullOrEmpty(app.Passcode) ? 0 : -1; item.Text = app.Name; }