Пример #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();
            }
        }
Пример #2
0
        private void PrepareShowExceptionList(DateTimeCompare timepair, string userName, string machineName)
        {
            string instanceID = TextBoxInstanceID.Text.Trim();

            if (!string.IsNullOrEmpty(instanceID))
            {
                using (AsyncWorkerByTrunk<IExceptionLogView> worker = new AsyncWorkerByTrunk<IExceptionLogView>(_presenter, this.GridViewExceptionLog, new Control[] { ButtonSearch, ButtonClear }, true))
                {
                    worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork)
                    {
                        eDoWork.Result = _presenter.GetExceptionLog(
                                new LogIDPairEntity(),
                                null,
                                null,
                                null,
                                null,
                                null,
                                instanceID);
                    };
                    worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted)
                    {
                        LoggingViewDataSet loggingViewData = eCompleted.Result as LoggingViewDataSet;
                        GridViewExceptionLog.DataSource = loggingViewData;
                        this.totalCount.Text = GridViewExceptionLog.Rows.Count.ToString();
                    };
                    worker.Run();
                }
            }
            else
            {
                using (AsyncWorkerByTrunk<IExceptionLogView> worker = new AsyncWorkerByTrunk<IExceptionLogView>(_presenter, this.GridViewExceptionLog, new Control[] { ButtonSearch, ButtonClear }, true))
                {
                    worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork)
                    {
                        eDoWork.Result = _presenter.GetLogIDRangeByLogTime(timepair, userName, machineName);
                    };
                    worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted)
                    {
                        LogIDPairEntity logIDPairEntity = eCompleted.Result as LogIDPairEntity;

                        GridViewExceptionLog.DataSource = new LoggingViewDataSet();
                        this.totalCount.Text = GridViewExceptionLog.Rows.Count.ToString();

                        if (logIDPairEntity != null && logIDPairEntity.MinLogID > 0)
                        {
                            // Step 1. Return Min LOG_ID and Max LOG_ID

                            totalMaxLogID = logIDPairEntity.MaxLogID;
                            this._ultraProgressBarForSearch.Value = 3;  // only prepare for loading data, initial progress is 3%

                            _presenter.OnUpdateProgressBar(ProgressBarStatus.OnProcess);
                            ProgressCounter++;
                            this.ButtonSearch.Text = "&Stop";
                            IsAsyncWorking = true;

                            // Step 2. Recursive loading data according to LOG_ID and LOG_ID
                            ShowExceptionLogList(
                                new LoggingViewDataSet(),
                                logIDPairEntity,
                                timepair,
                                TextBoxUseName.Text,
                                ComboxSeverity.Value.ToString(),
                                TextBoxMachineName.Text,
                                TextBoxLogContent.Text,
                                TextBoxInstanceID.Text.Trim());
                        }
                        else
                        {
                            this._ultraProgressBarForSearch.Visible = false;
                        }
                    };
                    worker.Run();
                }
            }
        }
Пример #3
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();
            }
        }
Пример #4
0
        private void PrepareShowInstrumentationList(DateTimeCompare timepair)
        {
            using (AsyncWorkerByTrunk<IInstrumentationView> worker = new AsyncWorkerByTrunk<IInstrumentationView>(_presenter, this.GridViewInstrumentation, new Control[] { ButtonSearch, ButtonClear }, true))
            {
                worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork)
                {
                    eDoWork.Result = _presenter.GetLogIDRangeByLogTime(timepair);
                };
                worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted)
                {
                    LogIDPairEntity logIDPairEntity = eCompleted.Result as LogIDPairEntity;

                    GridViewInstrumentation.DataSource = new LoggingViewDataSet();
                    this.totalCount.Text = GridViewInstrumentation.Rows.Count.ToString();

                    if (logIDPairEntity != null && logIDPairEntity.MinLogID > 0)
                    {
                        // Step 1. Return Min LOG_ID and Max LOG_ID

                        _presenter.OnUpdateProgressBar(ProgressBarStatus.OnProcess);
                        ProgressCounter++;
                        this.ButtonSearch.Text = "&Stop";
                        IsAsyncWorking = true;

                        // Step 2. Recursive loading data according to LOG_ID and LOG_ID
                        InstrumentationSearchCondition condition = new InstrumentationSearchCondition();
                        condition.UserName = TextBoxUserName.Text;
                        condition.IpAddress = TextBoxIpAddress.Text;
                        condition.ModuleId = TextBoxModuleId.Text;
                        condition.FunctionId = TextBoxFunctionId.Text;
                        condition.ComponentName = ComboxComponentName.Value.ToString();
                        condition.PCName = PCName.Text;
                        ShowInstrumentationLogList(
                            new LoggingViewDataSet(),
                            logIDPairEntity,timepair,
                            condition);
                    }
                };
                worker.Run();
            }
        }
        private void ButtonSearch_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (this.ValidateChildren())
                {
                    // Initialize data grid
                    LoggingViewData = new LoggingViewDataSet();
                    GridViewPerformance.DataSource = LoggingViewData.T_IC_PERFORMANCE_LOG;
                    this.totalCount.Text = GridViewPerformance.Rows.Count.ToString();
                    this.GridViewPerformance.Focus();

                    DateTimeCompare timeEntity = new DateTimeCompare(DateTimeStartDate.DateTime,
                        DateTimeEndDate.DateTime);
                    var argus = new object[] { timeEntity,
                        TextBoxFunctionId.Text,
                        ComboxComponentName.Value.ToString(),
                        this.TextBoxUserName.Text };

                    using (AsyncWorkerByTrunk<IPerformanceMonitoringView> worker = new AsyncWorkerByTrunk<IPerformanceMonitoringView>(_presenter, this.GridViewPerformance, new Control[] { ButtonSearch, ButtonClear }))
                    {
                        #region worker definition
                        worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork)
                        {
                            var tempArgus = eDoWork.Argument as object[];
                            if (tempArgus==null || tempArgus.Length<=3)
                            {
                                return;
                            }
                            eDoWork.Result = _presenter.GetPerformanceData(
                                tempArgus[0] as DateTimeCompare,
                                tempArgus[1] as string,
                                tempArgus[2] as string, tempArgus[3] as string);
                        };
                        worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted)
                        {
                            LoggingViewData = eCompleted.Result as LoggingViewDataSet;
                            if (null==LoggingViewData)
                            {
                                LoggingViewData = new LoggingViewDataSet();
                            }
                            GridViewPerformance.DataSource = LoggingViewData.T_IC_PERFORMANCE_LOG;
                            this.totalCount.Text = GridViewPerformance.Rows.Count.ToString();
                        };
                        #endregion
                        worker.Run(argus);
                    }
                }
            }
            catch (Exception ex)
            {
                if (ExceptionManager.Handle(ex)) throw;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Пример #6
0
        public void ProcessRetrieve(AuditTrailSearchCriteria criteria)
        {
            using (AsyncWorkerByTrunk<IAuditLogView> worker = new AsyncWorkerByTrunk<IAuditLogView>(_presenter, this.GridViewAuditLog, new Control[] { ButtonClear }, false))
            {
                worker.BackgroundWorker.WorkerSupportsCancellation = true;
                worker.DoWork += delegate(object oDoWork, DoWorkEventArgs eDoWork)
                {
                    eDoWork.Result = _presenter.BatchGetSummary(criteria);
                    Thread.Sleep(100);
                };
                worker.RunWorkerCompleted += delegate(object oCompleted, RunWorkerCompletedEventArgs eCompleted)
                {
                    AuditLogViewDataSet ds = eCompleted.Result as AuditLogViewDataSet;

                    if (null != BatchProcessCompleted && null!=ds)
                    {
                        BatchProcessCompleted(this, new BatchProcessEventArgs(ds, criteria));
                        worker.BackgroundWorker.CancelAsync();
                    }
                    else
                    {
                        //try to stop
                        _presenter.GetSummary(false);
                    }
                };
                worker.Run();
            }
        }