//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ public static void LoadAttributesList(DataGridView dg, DSources oDSrc, DataGridView dgo, string RowForRefresh) { int row = SearchRowByLink(dgo, RowForRefresh); if (row < 0) { for (int i = 0; i < dgo.Rows.Count; i++) { if (RowForRefresh == dgo[0, i].Value.ToString()) { row = i; } } } Dictionary <string, Dictionary <string, string> > dV; foreach (KeyValuePair <string, IDataSource> ds in oDSrc.DS) { if (row >= 0 && dgo[dgo.Columns[ds.Key].Index, row].Value != null) { dV = ds.Value.FindAllAttributes(dgo[dgo.Columns[ds.Key].Index, row].Value.ToString()); GridHelper.FillAtribRows(dg, dV, ds.Key); } else { CleanAtribRows(dg, ds.Key); } } }
//_________________________________________________________________________________________________________ // Unused by the moment. //_________________________________________________________________________________________________________ public static void CleanAttributesList(DataGridView dg, DSources oDSrc, DataGridView dgo, string RowForRefresh) { foreach (KeyValuePair <string, IDataSource> ds in oDSrc.DS) { GridHelper.CleanAtribRows(dg, ds.Key); } }
//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ public static void DeleteRow(DataGridView dg, DSources oDSrc, DataGridView dgo, string Column) { string cn = ""; foreach (KeyValuePair <string, IDataSource> ds in oDSrc.DS) { if (dgo[dgo.Columns[ds.Key].Index, dgo.CurrentRow.Index].Value != null && (Column == "" || Column == ds.Key)) { cn = dgo[dgo.Columns[ds.Key].Index, dgo.CurrentRow.Index].Value.ToString(); ds.Value.DeleteEntry(cn); } } }
//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ public static void LoadObjectsList(List <string> lLinks, DataGridView dg, DSources oDSrc, int max = 0, string sFilter = "") { Dictionary <string, Dictionary <string, string> > dV; string sSelectedRow = GridHelper.GetCurrentRow(dg); GridHelper.ResetRows(dg); LogHelper.Prg(oDSrc.DS.Count, 0); foreach (KeyValuePair <string, IDataSource> ds in oDSrc.DS) { LogHelper.Msg("Loading Data from " + ds.Value.Name); dV = ds.Value.FindAllEntries(max, "", sFilter); GridHelper.FillObjRows(lLinks, dg, dV, ds.Key); LogHelper.Prg(0); } GridHelper.SetCurrentRow(dg, sSelectedRow); LogHelper.Prg(); LogHelper.Msg(); }
//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ public static void UpdateAttributeValue(DataGridView dg, DSources oDSrc, int Row, int Col) { string newValue = dg[Col, Row].Value != null ? dg[Col, Row].Value.ToString() : ""; if (dg[Col, Row].Tag == null) { dg[Col, Row].Value = ""; return; } // If Tag == null there does not exist a register for that data source so, it cannot be edited if (newValue == dg[Col, Row].Tag.ToString()) { return; // si no cambia el valor, termina } // First two columns cannot be edited if (Col < 2 && dg[Col, Row].Value.ToString() != dg[Col, Row].Tag.ToString()) { dg[Col, Row].Value = dg[Col, Row].Tag.ToString(); return; } string sColumn = dg.Columns[Col].Name; // Column name identify tue data source string sID = dg.Columns[Col].Tag.ToString(); // Column tag contains ID (if it is a AD data source it contains DN value) string value = oDSrc.DS[sColumn].UpdateAttributeValue(sID, sColumn, dg[0, Row].Value.ToString(), newValue, dg[Col, Row].Tag.ToString()); dg[Col, Row].Value = value; // Update value in screen dg[Col, Row].Tag = value; // Tag value contains the same value showed in cell to allow undo operations }
//_________________________________________________________________________________________________________ //_________________________________________________________________________________________________________ private bool LoadConfig() { if (Initialized && Control.ModifierKeys != Keys.Shift) { return(true); // If it is already initialized and Keys.Shift is not pressed, return } if (!File.Exists(XlxConfig)) { return(false); //!File.Exists(XlxConfig) && !File.Exists(@"F:\" + XlxConfig) } Config.InitConfig(XlxConfig, DatasourcesSheet); //File.Exists(XlxConfig) ? XlxConfig : @"F:\" + XlxConfig GridHelper.InitializeDataGridView(dgObjs); GridHelper.InitializeDataGridView(dgAux); GridHelper.InitializeDataGridView(dgValues, true); GridHelper.InitializeDataGridView(oDetails.dgv); // Scrollbars dgObjs.ScrollBars = ScrollBars.Vertical; dgAux.ScrollBars = ScrollBars.None; LogHelper.Msg("Connecting Data Sources"); this.Refresh(); oDSrc = new DSources(Config.tFDatos, Config.tAttributes); GridHelper.InitGrid(dgObjs, Config.lObjCols); GridHelper.InitGrid(dgAux, Config.lAuxCols, null, 1); GridHelper.InitGrid(dgValues, Config.lValuesCols, Config.dAtribs); GridHelper.MarkRows(dgValues, SelectedRows); cObjClass.Items.Clear(); cObjClass.Items.AddRange(ExtensionHelper.GetNewObjectClasses()); if (cObjClass.Items.Count > 0) { cObjClass.SelectedIndex = 0; } cBU.Items.Clear(); cBU.Items.AddRange(Config.dConfig["ADSource Alias"].Split(';')); if (cBU.Items.Count > 0) { cBU.SelectedIndex = 0; } mProfilesOptions.Items.Clear(); mProfilesOptions.Items.AddRange(Config.dConfig["Profile Options"].Split(';')); if (mProfilesOptions.Items.Count > 0) { mProfilesOptions.SelectedIndex = 0; } // Optional: Change with of dropdownlist with a functionality of available in MacroHelper MacroHelper.ChangeListBoxWidth(cObjClass); MacroHelper.ChangeListBoxWidth(cBU); MacroHelper.ChangeListBoxWidth(mProfilesOptions); // Profiles config dWorkers = new Dictionary <string, cWorker>(); dWorkers.Add("1", new cWorker(null, null, lbPfStatus1, null)); dWorkers.Add("2", new cWorker(null, null, lbPfStatus2, null)); dWorkers.Add("3", new cWorker(null, null, lbPfStatus3, null)); dWorkers.Add("4", new cWorker(null, null, lbPfStatus4, null)); dWorkers.Add("5", new cWorker(null, null, lbPfStatus5, null)); dWorkers.Add("6", new cWorker(null, null, lbPfStatus6, null)); // Load servers info FIMServers.LoadServers(dWorkers); Initialized = true; return(true); }