private static string[] GetValueFromKey(string key, DataViewerParameters dataViewerParameters) { foreach (KeyValuePair <string, string[]> column in dataViewerParameters.Columns) { if (column.Key == key) { return(column.Value); } } return(null); }
private void DoLoadData(DataViewerParameters dataViewerParameters, DataRow selectedRow, int selectedIndex) { _sqlFile = dataViewerParameters.SqlFile; _page = dataViewerParameters.Page; _itemsPerPage = dataViewerParameters.ItemsPerPage; _sortingColumn = dataViewerParameters.SortingColumn; _sortingColumnDirection = dataViewerParameters.SortingColumnDirection; _searchTerm = dataViewerParameters.SearchTerm; _searchColumn = dataViewerParameters.SearchColumn; _visibleColumns = dataViewerParameters.Columns; _whereActive = dataViewerParameters.WhereActive; _numberOfSortingColumns = dataViewerParameters.NumberOfSortingColumns; Dictionary <string, string> iconDictionary = dataViewerParameters.IconDictionary; Dictionary <string, Icon> iconList = dataViewerParameters.IconList; _dataViewerHandler = new DataViewerHandler(dataGridView, GetPagerPanel(), _sortingColumn, _sortingColumnDirection, GetSearcherPanel(), _visibleColumns, _itemsPerPage, _isDataModifiedText, _isDataModifiedCaptionText, _outOfText, _totalText, _numberOfSortingColumns, iconDictionary, iconList, dataViewerParameters.FirstSortColumnDirection); _dataViewerHandler.RequestDataSourceUpdateEvent += DataViewerHandler_RequestDataSourceUpdateEvent; _dataViewerHandler.RequestDataSourceAllPagesEvent += DataViewerHandler_RequestDataSourceAllPagesEvent; _dataViewerHandler.ShowOutputEvent += DataViewerHandler_ShowOutputEvent; string where = ""; if (selectedRow != null) { if (selectedRow[dataViewerParameters.WhereSingleColumn] == DBNull.Value) { where = string.Format(dataViewerParameters.WhereSingle, "null"); } else { where = string.Format(dataViewerParameters.WhereSingle, selectedRow[dataViewerParameters.WhereSingleColumn].ToString().Replace("'", "''")); } } _previousSelectedRowIndex = -1; _dataViewerHandler.SetSelectedRow(selectedIndex); FireUpdateDataSourceEvent(_page, _itemsPerPage, _sortingColumn, _sortingColumnDirection, _searchTerm, _searchColumn, where, _whereActive); dataGridView.MouseClick += DataGridView_MouseClick; dataGridView.SelectionChanged += DataGridView_SelectionChanged; dataGridView.CellMouseDoubleClick += DataGridView_CellMouseDoubleClick; dataGridView.KeyDown += DataGridView_KeyDown; dataGridView.KeyUp += DataGridView_KeyUp; dataGridView.ColumnWidthChanged += DataGridView_ColumnWidthChanged; dataGridView.MouseDown += DataGridView_MouseDown; dataGridView.CellFormatting += DataGridView_CellFormatting; InitializeToolTip(searchTermTextBox, _searchBoxToolTipText); _isInitialized = true; }
public static void Export(DataTable dataTable, string fileName, DataViewerParameters dataViewerParameters) { bool success = DoExport(dataTable, fileName, dataViewerParameters); if (success) { string text = "Export successful."; if (ConfigHandler.UseTranslation) { text = Translator.GetText("ExportSuccessful"); } OutputHandler.Show(text, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private static int GetColumnIndexFromKey(string key, DataViewerParameters dataViewerParameters) { int i = 0; foreach (KeyValuePair <string, string[]> column in dataViewerParameters.Columns) { if (column.Key == key) { return(i); } i++; } return(-1); }
private static bool ShouldExportColumn(DataViewerParameters dataViewerParameters, string columnName) { foreach (KeyValuePair <string, string[]> column in dataViewerParameters.Columns) { if (column.Key == columnName) { if (column.Value[4] == "SearchableShow" || column.Value[4] == "NonSearchableShow") { return(true); } break; } } return(false); }
private void InitializeDataViewer(bool inititalizeUserInterface, bool useConnectToSessionTimeAsImportTime, string sortingColumn, ListSortDirection sortingColumnDirection) { if (inititalizeUserInterface) { _dataViewerParametersDataViewer1 = DalTranslator.GetTraceData(); ColumnPropertiesHandler.LoadColumnWidthAndOrder(_dataViewerParametersDataViewer1, "DataViewer_TraceData"); ToggleShowHiddenColumns(); if (useConnectToSessionTimeAsImportTime) { ConfigHandler.ImportStartTime = DateTime.Now; } SetUserInterface(); if (useConnectToSessionTimeAsImportTime) { ConfigHandler.ImportEndTime = DateTime.Now; } } _dataViewerParametersDataViewer1.SortingColumn = sortingColumn; _dataViewerParametersDataViewer1.SortingColumnDirection = sortingColumnDirection; dataViewer1.UpdateDataSourceEvent += _databaseOperation.UpdateDataSource; dataViewer1.RequestDataSourceAllPagesEvent += _databaseOperation.RequestDataSourceAllPages; dataViewer1.SelectionChangedEvent += DataViewer1_SelectionChangedEvent; dataViewer1.DoubleClickEvent += DataViewer1_DoubleClickEvent; dataViewer1.RightClickEvent += DataViewer1_RightClickEvent; dataViewer1.ColumnWidthChangedEvent += DataViewer1_ColumnWidthChangedEvent; dataViewer1.ColumnDisplayIndexChangedEvent += DataViewer1_ColumnDisplayIndexChangedEvent; dataViewer1.ShowOutputEvent += DataViewer1_ShowOutputEvent; dataViewer1.SetDateFormatShow(ConfigHandler.DateTimeLongFormat); dataViewer1.SetDateFormatSearch(ConfigHandler.DateFormatSearch); dataViewer1.SetUseDateSelector(ConfigHandler.UseDateSelectorInQuickSearch); dataViewer1.LoadData(_dataViewerParametersDataViewer1); Visible = true; }
private static bool DoExport(DataTable dataTable, string fileName, DataViewerParameters dataViewerParameters) { bool success = true; try { StreamWriter sw = new StreamWriter(fileName, false, System.Text.Encoding.GetEncoding(1252)); int iColCount = dataTable.Columns.Count; foreach (DataRow dr in dataTable.Rows) { for (int i = 0; i < iColCount; i++) { if (ShouldExportColumn(dataViewerParameters, dataTable.Columns[i].ToString())) { if (!Convert.IsDBNull(dr[i])) { string data = dr[i].ToString(); sw.Write(data); } } } sw.Write(sw.NewLine); sw.Write("go"); sw.Write(sw.NewLine); sw.Write(sw.NewLine); } sw.Close(); } catch (Exception ex) { OutputHandler.Show(ex.Message, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); success = false; } return(success); }
public static void SaveColumnWidthAndOrder(DataViewerParameters dataViewerParameters, string registryName) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><columns>"); foreach (KeyValuePair <string, string[]> column in dataViewerParameters.Columns) { string key = column.Key; string type = column.Value[4]; string width = column.Value[3]; stringBuilder.Append(string.Format("<column key=\"{0}\" type=\"{1}\" width=\"{2}\" />", System.Security.SecurityElement.Escape(key), type, width)); } stringBuilder.Append("</columns>"); if (ConfigHandler.RegistryModifyAccess) { RegistryHandler.SaveToRegistry(registryName, stringBuilder.ToString()); } }
public void Initialize(DatabaseOperation databaseOperation) { InitializeDictionary(); _databaseOperation = databaseOperation; _dataViewerParametersDataViewer1 = DalTranslator.GetTraceData(); ColumnPropertiesHandler.LoadColumnWidthAndOrder(_dataViewerParametersDataViewer1, "DataViewer_TraceData"); _searchForm = new SearchTextForm(); _searchForm.Initialize(); if (ConfigHandler.UseTranslation) { _searchForm.SetTitle(Translator.GetText("searchInTextData")); } else { _searchForm.SetTitle("Search in TextData"); } filter1UserControl.ApplyEvent += Filter1UserControl_ApplyEvent; filter1UserControl.ResetEvent += Filter1UserControl_ResetEvent; filter2UserControl.ApplyEvent += Filter2UserControl_ApplyEvent; filter2UserControl.ResetEvent += Filter2UserControl_ResetEvent; textDataTextBox.SetHighlighting("SQL"); textDataTextBox.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("SQL"); textDataTextBox.TextEditorProperties.Font = new Font(ConfigHandler.TextDataFontFamily, float.Parse(ConfigHandler.TextDataFontSize)); textDataTextBox.Font = new Font(ConfigHandler.TextDataFontFamily, float.Parse(ConfigHandler.TextDataFontSize)); textDataTextBox.ActiveTextAreaControl.Caret.PositionChanged += Caret_PositionChanged; _searchForm.SearchEvent += SearchForm_SearchEvent; ConfigHandler.ActiveFilters = new List <Filter>(); }
public void Initialize(DatabaseOperation databaseOperation, DataViewer dataViewer, DataViewerParameters dataViewerParameters) { InitializeDictionary(); _dataViewer = dataViewer; _databaseOperation = databaseOperation; _dataViewerParameters = dataViewerParameters; }
public void LoadData(DataViewerParameters dataViewerParameters, int selectedIndex) { DoLoadData(dataViewerParameters, null, selectedIndex); }
public void LoadData(DataViewerParameters dataViewerParameters, DataRow selectedRow, int selectedIndex) { DoLoadData(dataViewerParameters, selectedRow, selectedIndex); }
public void LoadData(DataViewerParameters dataViewerParameters, DataRow selectedRow) { DoLoadData(dataViewerParameters, selectedRow, 1); }
public void LoadData(DataViewerParameters dataViewerParameters) { DoLoadData(dataViewerParameters, null, 1); }
public void Initialize(DatabaseOperation databaseOperation, List <string> groupBys, bool filter1Applied, bool filter2Applied, bool unattended, int totalRows) { InitializeDictionary(); Text = GenericHelper.ApplicationName; SetSize(); _toolTip = new ToolTip(); _totalRows = totalRows; _groupBys = groupBys; _databaseOperation = databaseOperation; string where = GetWhere(); _dataViewerParametersDataViewer1 = DalTranslator.GetStatisticsData(); if (!unattended) { ColumnPropertiesHandler.LoadColumnWidthAndOrder(_dataViewerParametersDataViewer1, "DataViewer_StatisticsData"); } else { List <KeyValuePair <string, string[]> > columnsToReorder = new List <KeyValuePair <string, string[]> >(); foreach (KeyValuePair <string, string[]> visibleColumn in _dataViewerParametersDataViewer1.Columns) { if (groupBys.Contains(visibleColumn.Key)) { columnsToReorder.Add(visibleColumn); } } for (int i = 0; i < groupBys.Count; i++) { foreach (KeyValuePair <string, string[]> column in columnsToReorder) { if (column.Key == groupBys[i]) { Dictionary <string, string[]> newColumns = ColumnPropertiesHandler.ChangeColumnOrder(_dataViewerParametersDataViewer1, column.Key, i - 1); _dataViewerParametersDataViewer1.Columns = newColumns; } } } } DataViewerParameters dataViewerParameters = DalTranslator.GetTraceData(); foreach (KeyValuePair <string, string[]> column in dataViewerParameters.Columns) { if (ConfigHandler.GroupByColumns.Contains(column.Key)) { _dataViewerParametersDataViewer1.Columns[column.Key].SetValue("SearchableShow", 4); } else { _dataViewerParametersDataViewer1.Columns[column.Key].SetValue("NonSearchableHide", 4); } } _dataViewerParametersDataViewer1.WhereActive = where; if (!unattended) { ColumnPropertiesHandler.SaveColumnWidthAndOrder(_dataViewerParametersDataViewer1, "DataViewer_StatisticsData"); } InitializeDataViewer(); DataSet dataSet = dataViewer1.GetDataSource(); if (dataSet.Tables[1].Rows[0]["MinStartTime"] != DBNull.Value) { _minStartTime = Convert.ToDateTime(dataSet.Tables[1].Rows[0]["MinStartTime"]); } if (dataSet.Tables[1].Rows[0]["MaxStartTime"] != DBNull.Value) { _maxStartTime = Convert.ToDateTime(dataSet.Tables[1].Rows[0]["MaxStartTime"]); } SetFilterLabel(filter1Applied, filter2Applied); InitializeShowCheckBoxes(); MinimumSize = new Size(900, 680); // error in .NET }