Exemplo n.º 1
0
 private void _cmsi_ServerTag_Delete_Click(object sender, EventArgs e)
 {
     if (_grid_TagServers.ActiveRow != null && _grid_TagServers.ActiveRow.IsDataRow)
     {
         int tagId    = (int)_grid_Tags.ActiveRow.Cells[colHeaderHiddenTagID].Value;
         int serverId = (int)_grid_TagServers.ActiveRow.Cells[colHeaderHiddenServerId].Value;
         TagWorker.RemoveServerFromTag(tagId, serverId);
         ShowRefresh();
     }
 }
Exemplo n.º 2
0
        private bool LoadTagServers(IEnumerable <int> tagIds, bool bUpdate)
        {
            bool hasRows = false;

            try
            {
                foreach (int tagId in tagIds)
                {
                    var tag = TagWorker.GetTagById(tagId);
                    if (tag == null)
                    {
                        return(false);            //tag was removed
                    }
                    foreach (var server in tag.TaggedServers)
                    {
                        if (!_dt_Servers.Rows.Contains(server.Name))
                        {
                            DataRow newRow = _dt_Servers.NewRow();
                            newRow[colHeaderServerName]     = server.Name;
                            newRow[colHeaderHiddenServerId] = server.Id;
                            _dt_Servers.Rows.Add(newRow);
                            _dt_Servers.Rows.Find(server.Name)[colHeaderTagName] = tag.Name;
                            hasRows = true;
                        }
                        else
                        {
                            var currentTag = _dt_Servers.Rows.Find(server.Name)[colHeaderTagName];
                            _dt_Servers.Rows.Find(server.Name)[colHeaderTagName] = string.Format("{0}, {1}", currentTag, tag.Name);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logX.loggerX.Error(@"Error - Unable to retrieve Servers", ex);
                MsgBox.ShowError(ErrorMsgs.CantGetLoginsCaption, ex);
            }

            _grid_TagServers.BeginUpdate();
            _grid_TagServers.DataSource = _dt_Servers;
            _grid_TagServers.DataMember = "";
            if (bUpdate)
            {
                _grid_TagServers.EndUpdate();
            }


            _label_NoServers.Visible = !hasRows;
            _grid_TagServers.Visible = hasRows;

            return(hasRows);
        }
Exemplo n.º 3
0
        private static void AddServerToTags(int serverId)
        {
            try
            {
                List <string> tagsIds = new List <string>();

                TagWorker.AssignServerToTags(serverId, tagsIds);
            }
            catch (Exception ex)
            {
                logX.loggerX.Error(ex.Message);
                throw;
            }
        }
Exemplo n.º 4
0
 private void DeleteTag(object sender, EventArgs e)
 {
     if (_grid_Tags.ActiveRow != null && _grid_Tags.ActiveRow.IsDataRow)
     {
         try
         {
             int tagId = (int)_grid_Tags.ActiveRow.Cells[colHeaderHiddenTagID].Value;
             TagWorker.DeleteTag(tagId);
             ShowRefresh();
         }
         catch (Exception ex)
         {
             MsgBox.ShowError(ErrorMsgs.ManageTags, ex.Message);
         }
     }
 }
Exemplo n.º 5
0
        private void LoadTags(bool bUpdate)
        {
            _dt_Tags.Clear();
            try
            {
                // Retrieve policy information.
                var tags = TagWorker.GetTags();

                foreach (Tag p in tags)
                {
                    DataRow newRow = _dt_Tags.NewRow();

                    newRow[colHeaderTagName]     = p.Name;
                    newRow[colHeaderDesc]        = p.Description;
                    newRow[colHeaderHiddenTagID] = p.Id;
                    _dt_Tags.Rows.Add(newRow);
                }
            }
            catch (Exception ex)
            {
                logX.loggerX.Error(@"Error - Unable to retrieve tags", ex);
                MsgBox.ShowError(ErrorMsgs.CantGetLoginsCaption, ex);
            }
            if (_dt_Tags.Rows.Count != 0)
            {
                _grid_Tags.BeginUpdate();
                _grid_Tags.DataSource = _dt_Tags;
                if (_grid_Tags.Selected.Rows.Count == 0)
                {
                    _grid_Tags.Selected.Rows.Add(_grid_Tags.Rows[0]);
                    _grid_Tags.ActiveRow = _grid_Tags.Rows[0];
                }


                _grid_Tags.DataMember = "";
                if (bUpdate)
                {
                    _grid_Tags.EndUpdate();
                }
            }

            _label_Policies.Text = string.Format(TagHeaderDisplay, _grid_Tags.Rows.Count);
            LoadSelectedTagServers();
        }
Exemplo n.º 6
0
 private void EditTag(int tagId)
 {
     if (tagId > 0)
     {
         try
         {
             var t = TagWorker.GetTagById(tagId);
             if (t != null)
             {
                 Form_CreateTag.Process(t);
             }
             LoadSelectedTagServers();
         }
         catch (Exception ex)
         {
             MsgBox.ShowError(ErrorMsgs.ManageTags, ex.Message);
         }
     }
 }
Exemplo n.º 7
0
        public static int Process(Tag tag)
        {
            // Create the form.

            try
            {
                Form_CreateTag form = new Form_CreateTag(tag);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    TagWorker.UpdateCreateTag(form.ServerTag);
                    return(TagWorker.GetTagByName(form.ServerTag.Name).Id);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error during tag edit\\create", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(-1);
        }
Exemplo n.º 8
0
        private void AddServersToTag(object sender, EventArgs e)
        {
            if (_grid_Tags.ActiveRow != null && _grid_Tags.ActiveRow.IsDataRow)
            {
                Form_SelectServer serverListForm = new Form_SelectServer(true);
                if (serverListForm.LoadServers(true))
                {
                    if (serverListForm.ShowDialog() == DialogResult.OK)
                    {
                        var servers = serverListForm.SelectedServers;

                        int tagId = (int)_grid_Tags.ActiveRow.Cells[colHeaderHiddenTagID].Value;
                        if (tagId > 0)
                        {
                            TagWorker.AssignServerToTag(tagId, servers);
                        }
                    }
                }
            }
            ShowRefresh();
        }
Exemplo n.º 9
0
        private void _button_OK_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            string tagName = _textBox_TagName.Text.Trim();

            if (string.IsNullOrEmpty(tagName))
            {
                MsgBox.ShowError(ErrorTitle, ErrorMessageTitle);
                DialogResult = DialogResult.None;

                Cursor = Cursors.Default;
                return;
            }
            var tag = TagWorker.GetTagByName(tagName);

            if (tag != null && !_isEdit)
            {
                MsgBox.ShowError(ErrorTitle, ErrorMessageExists);
                DialogResult = DialogResult.None;

                Cursor = Cursors.Default;
            }
        }