Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 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";
 }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
 public LoginDialog(CCOWApplication application)
 {
     InitializeComponent();
     _CCOWApplication = application;
 }
Exemplo n.º 9
0
 private void UpdateItem(ListViewItem item, CCOWApplication app)
 {
     item.Checked    = app.Allowed.Value;
     item.ImageIndex = !string.IsNullOrEmpty(app.Passcode) ? 0 : -1;
     item.Text       = app.Name;
 }