private void ShowExceptionLogList( LoggingViewDataSet loggingViewData, LogIDPairEntity logIDPair, DateTimeCompare timeEntity, string userName, string severity, string machineName, string logContent, string instanceID) { using (AsyncWorkerByTrunk<IExceptionLogView> worker = new AsyncWorkerByTrunk<IExceptionLogView>(_presenter, this.GridViewExceptionLog, new Control[] { ButtonClear }, true)) { worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork) { eDoWork.Result = _presenter.GetExceptionLog( logIDPair, timeEntity, userName, severity, machineName, logContent, instanceID); Thread.Sleep(300); // default 300 }; worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted) { if (WorkItem.SmartParts[ViewId] == null || !IsAsyncWorking) { this.ButtonSearch.Text = "&Search"; return; } // ExceptionViewData exceptionViewData = eCompleted.Result as ExceptionViewData; LoggingViewDataSet LoggingViewData = eCompleted.Result as LoggingViewDataSet; if (LoggingViewData == null) LoggingViewData = new LoggingViewDataSet(); loggingViewData.Merge(LoggingViewData); GridViewExceptionLog.DataSource = loggingViewData; this.totalCount.Text = GridViewExceptionLog.Rows.Count.ToString(); string[] logIDPairArray = LoggingViewData.ExtendedProperties["LogIDPair"].ToString().Split(','); Int64 minLogID = Convert.ToInt64(logIDPairArray[0]); Int64 maxLogID = Convert.ToInt64(logIDPairArray[1]); double remain = maxLogID - minLogID; double total = totalMaxLogID - minLogID; double remains = (1 - remain / total) * 97 + 3; if (remains > 0 && remains <= 100) { this._ultraProgressBarForSearch.Value = Convert.ToInt32(remains); } if (minLogID <= maxLogID) { ShowExceptionLogList( loggingViewData, new LogIDPairEntity(minLogID, maxLogID), timeEntity, TextBoxUseName.Text, ComboxSeverity.Value.ToString(), TextBoxMachineName.Text, TextBoxLogContent.Text, TextBoxInstanceID.Text.Trim()); } else { IsAsyncWorking = false; this.ButtonSearch.Text = "&Search"; _presenter.OnUpdateProgressBar(ProgressBarStatus.OnEnd); ProgressCounter--; this._ultraProgressBarForSearch.Value = 100; AsyncWaiting(500); } }; worker.Run(); } }
public LoggingViewDataSet RetrieveExceptionLog(LogIDPairEntity logIDPair, DateTimeCompare timeEntity, string userName, string category, string severity, string machineName, string logContent, string instanceID) { const int MaxErrorLogNumber = 1000; if (!string.IsNullOrEmpty(instanceID)) { LoggingViewDataSet logDs = new LoggingViewDataSet(); DbCommand command; command = Helper.BuildDbCommand("dbo.P_IC_LOGGING_EXCEPTION_LOG_S_BY_ID"); Helper.AssignParameterValues(command, instanceID); Helper.Fill(logDs.T_IC_LOGGING_LOG, command); return logDs; } else { long minLogID = logIDPair.MinLogID; long maxLogID = logIDPair.MaxLogID; long currentMinLogID = maxLogID - MaxErrorLogNumber; LoggingViewDataSet logDs; LoggingViewDataSet logDsByFilter = new LoggingViewDataSet(); DbCommand command; int recordCount = 0; int computeCount = 0; string temporaryUserNameInput = TranslateWildcardForExceptionLog(userName); string temporaryMachineameInput = TranslateWildcardForExceptionLog(machineName); while (recordCount == 0 && minLogID <= maxLogID && computeCount < MaxNullFounds) { command = Helper.BuildDbCommand("dbo.P_IC_LOGGING_EXCEPTION_LOG_S"); command.CommandTimeout = 0; if (currentMinLogID < minLogID) { currentMinLogID = minLogID; } logDs = new LoggingViewDataSet(); Helper.AssignParameterValues(command, currentMinLogID, maxLogID, temporaryUserNameInput, temporaryMachineameInput); Helper.Fill(logDs.T_IC_LOGGING_LOG, command); var list = (from n in logDs.T_IC_LOGGING_LOG // ReSharper disable ConditionIsAlwaysTrueOrFalse where (string.IsNullOrEmpty(severity) || ConvertToString(n.SEVERITY).Equals(severity)) && (!string.IsNullOrEmpty(userName) ? SearchHelper.IsRegexMatch(ConvertToString(n.USER_NAME), userName, @"[\w|\W]*") : true) && (string.IsNullOrEmpty(category) || ConvertToString(n.CATEGORY_NAME).Equals(category)) && (!string.IsNullOrEmpty(machineName) ? SearchHelper.IsRegexMatch(ConvertToString(n.MACHINE_NAME), machineName, @"[\w|\W]*") : true) && (!string.IsNullOrEmpty(logContent) ? SearchHelper.IsRegexMatch(ConvertToString(n.FORMATTED_MESSAGE), logContent, @"[\w|\W]*") : true) && (string.IsNullOrEmpty(instanceID) || ConvertToString(n.INSTANCE_ID).Equals(instanceID)) && (timeEntity == null ? true : n.LOG_TIME <= timeEntity.EndTime) && (timeEntity == null ? true : n.LOG_TIME >= timeEntity.StartTime) // ReSharper restore ConditionIsAlwaysTrueOrFalse select n); maxLogID = currentMinLogID - 1; currentMinLogID = maxLogID - MaxErrorLogNumber; recordCount += list.Count(); computeCount += 1; foreach (var row in list) { logDsByFilter.T_IC_LOGGING_LOG.ImportRow(row); } logDs.Dispose(); } logDsByFilter.ExtendedProperties.Add("LogIDPair", minLogID.ToString() + "," + maxLogID.ToString()); logDsByFilter.AcceptChanges(); return logDsByFilter; } }
public LoggingViewDataSet RetrieveInstrumentation(LogIDPairEntity logIDPair, DateTimeCompare timeEntity,string userName, string ipAddress, string moduleId, string functionId, string componentName, string category, string pcName) { long minLogID = logIDPair.MinLogID; long maxLogID = logIDPair.MaxLogID; long currentMinLogID = maxLogID - MaxRecords; LoggingViewDataSet logDs; LoggingViewDataSet logDsByFilter = new LoggingViewDataSet(); DbCommand command; int recordCount = 0; int computeCount = 0; while (recordCount == 0 && minLogID <= maxLogID && computeCount < MaxNullFounds) { command = Helper.BuildDbCommand("dbo.P_IC_LOGGING_INSTRUMENTATION_S"); command.CommandTimeout = 0; if (currentMinLogID < minLogID) { currentMinLogID = minLogID; } logDs = new LoggingViewDataSet(); Helper.AssignParameterValues(command, currentMinLogID, maxLogID); Helper.Fill(logDs.T_IC_LOGGING_LOG, command); var list = (from n in logDs.T_IC_LOGGING_LOG // ReSharper disable ConditionIsAlwaysTrueOrFalse where (string.IsNullOrEmpty(category) || n.CATEGORY_NAME.Equals(category)) && (string.IsNullOrEmpty(componentName) || n.COMPONENT.Equals(ConvertToString(componentName))) && (!string.IsNullOrEmpty(userName) ? SearchHelper.IsRegexMatch(ConvertToString(n.USER_NAME), userName, @"[\w|\W]*") : true) && (!string.IsNullOrEmpty(ipAddress) ? SearchHelper.IsRegexMatch(ConvertToString(n.IP_ADDRESS), ipAddress, @"[\w|\W]*") : true) && (!string.IsNullOrEmpty(moduleId) ? SearchHelper.IsRegexMatch(ConvertToString(n.MODULE_ID), moduleId, @"[\w|\W]*") : true) && (!string.IsNullOrEmpty(functionId) ? SearchHelper.IsRegexMatch(ConvertToString(n.FUNCTION_ID), functionId, @"[\w|\W]*") : true) && (!string.IsNullOrEmpty(pcName) ? SearchHelper.IsRegexMatch(ConvertToString(n.MACHINE_NAME), pcName, @"[\w|\W]*") : true) // ReSharper restore ConditionIsAlwaysTrueOrFalse && (timeEntity == null ? true : n.LOG_TIME <= timeEntity.EndTime) && (timeEntity == null ? true : n.LOG_TIME >= timeEntity.StartTime) select n); maxLogID = currentMinLogID - 1; currentMinLogID = maxLogID - MaxRecords; recordCount += list.Count(); computeCount += 1; foreach (var row in list) { logDsByFilter.T_IC_LOGGING_LOG.ImportRow(row); } logDs.Dispose(); } logDsByFilter.ExtendedProperties.Add("LogIDPair", minLogID.ToString() + "," + maxLogID.ToString()); logDsByFilter.AcceptChanges(); return logDsByFilter; }
private void ShowInstrumentationLogList( LoggingViewDataSet loggingViewData, LogIDPairEntity logIDPair,DateTimeCompare timeEntity, InstrumentationSearchCondition condition) { using (AsyncWorkerByTrunk<IInstrumentationView> worker = new AsyncWorkerByTrunk<IInstrumentationView>(_presenter, this.GridViewInstrumentation, new Control[] { ButtonClear }, true)) { worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork) { eDoWork.Result = _presenter.GetInstrumentationData( logIDPair,timeEntity, condition); Thread.Sleep(300); // default 300 }; worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted) { if (WorkItem.SmartParts[ViewId] == null || !IsAsyncWorking) { this.ButtonSearch.Text = "&Search"; return; } // ExceptionViewData exceptionViewData = eCompleted.Result as ExceptionViewData; LoggingViewDataSet tempLoggingViewData = eCompleted.Result as LoggingViewDataSet; if (tempLoggingViewData == null) tempLoggingViewData = new LoggingViewDataSet(); loggingViewData.Merge(tempLoggingViewData); GridViewInstrumentation.DataSource = loggingViewData; this.totalCount.Text = GridViewInstrumentation.Rows.Count.ToString(); string[] logIDPairArray = tempLoggingViewData.ExtendedProperties["LogIDPair"].ToString().Split(','); Int64 minLogID = Convert.ToInt64(logIDPairArray[0]); Int64 maxLogID = Convert.ToInt64(logIDPairArray[1]); if (minLogID <= maxLogID) { ShowInstrumentationLogList( loggingViewData, new LogIDPairEntity(minLogID, maxLogID),timeEntity, condition); } else { IsAsyncWorking = false; this.ButtonSearch.Text = "&Search"; _presenter.OnUpdateProgressBar(ProgressBarStatus.OnEnd); ProgressCounter--; AsyncWaiting(500); } }; worker.Run(); } }