Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }