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); }
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); } } }