예제 #1
0
        /// <summary>
        /// Updates the statistics related to the task in the specified index.
        /// The stats relate to tasks that have been run on that index.
        /// </summary>
        /// <param name="index">Index to update.</param>
        public void UpdateTaskCompletedStatistics(IErrorIndex index)
        {
            if ((index != null) && (index.Status == ErrorIndexStatus.Created))
            {
                StackHashTaskStatus taskStatus = index.GetTaskStatistics(this.TaskType);

                taskStatus.TaskState = StackHashTaskState.Completed;

                taskStatus.ServiceErrorCode = StackHashException.GetServiceErrorCode(this.LastException);
                if (this.LastException != null)
                {
                    taskStatus.FailedCount++;
                    taskStatus.LastFailedRunTimeUtc = taskStatus.LastStartedTimeUtc;
                    taskStatus.LastException        = this.LastException.ToString();
                }
                else
                {
                    taskStatus.SuccessCount++;
                    taskStatus.LastSuccessfulRunTimeUtc = taskStatus.LastStartedTimeUtc;
                }

                taskStatus.LastDurationInSeconds = (int)(DateTime.Now.ToUniversalTime() - taskStatus.LastStartedTimeUtc).TotalSeconds;
                taskStatus.TaskState             = StackHashTaskState.Completed;
                index.SetTaskStatistics(taskStatus);
            }
        }
예제 #2
0
        private void copyStatistics(IErrorIndex sourceIndex, IErrorIndex destinationIndex)
        {
            Type  taskEnumType = typeof(StackHashTaskType);
            Array allValues    = Enum.GetValues(taskEnumType);

            foreach (StackHashTaskType taskType in allValues)
            {
                StackHashTaskStatus taskStatus = sourceIndex.GetTaskStatistics(taskType);

                destinationIndex.SetTaskStatistics(taskStatus);
            }
        }
예제 #3
0
 private void menuItemAbortTask_Click(object sender, RoutedEventArgs e)
 {
     if (!_worker.IsBusy)
     {
         StackHashTaskStatus selectedTask = listViewTasks.SelectedItem as StackHashTaskStatus;
         if (selectedTask != null)
         {
             this.IsEnabled = false;
             _worker.RunWorkerAsync(new WorkerArg(selectedTask.TaskType, _reselectContextId));
         }
     }
 }
예제 #4
0
        public void ErrorIndexXmlSettingsDefaultSetOneTaskDataCheckPersisted()
        {
            string settingsFileName = string.Format(CultureInfo.InvariantCulture, "{0}\\Settings.xml", m_TempPath);

            ErrorIndexXmlSettings settings = new ErrorIndexXmlSettings(settingsFileName);

            Assert.AreEqual(settingsFileName, settings.FileName);
            Assert.AreNotEqual(null, settings.LastSyncTimes);
            Assert.AreEqual(0, settings.LastSyncTimes.Count);
            StackHashTaskStatus taskStatus = settings.GetTaskStatistics(StackHashTaskType.DebugScriptTask);

            Assert.AreEqual(0, taskStatus.FailedCount);
            Assert.AreEqual(0, taskStatus.SuccessCount);
            Assert.AreEqual(0, taskStatus.LastDurationInSeconds);
            Assert.AreEqual(null, taskStatus.LastException);
            Assert.AreEqual(0, taskStatus.LastFailedRunTimeUtc.Ticks);
            Assert.AreEqual(0, taskStatus.LastStartedTimeUtc.Ticks);
            Assert.AreEqual(0, taskStatus.LastDurationInSeconds);


            taskStatus.FailedCount              = 10;
            taskStatus.LastDurationInSeconds    = 20;
            taskStatus.LastException            = "Test";
            taskStatus.LastFailedRunTimeUtc     = DateTime.Now.ToUniversalTime().AddDays(1);
            taskStatus.LastStartedTimeUtc       = DateTime.Now.ToUniversalTime().AddDays(2);
            taskStatus.LastSuccessfulRunTimeUtc = DateTime.Now.ToUniversalTime().AddDays(3);
            taskStatus.RunCount     = 30;
            taskStatus.SuccessCount = 40;
            taskStatus.TaskState    = StackHashTaskState.Running;
            taskStatus.TaskType     = StackHashTaskType.DebugScriptTask;

            settings.SetTaskStatistics(taskStatus);

            settings = new ErrorIndexXmlSettings(settingsFileName);

            Assert.AreEqual(settingsFileName, settings.FileName);
            Assert.AreNotEqual(null, settings.LastSyncTimes);
            Assert.AreEqual(0, settings.LastSyncTimes.Count);

            StackHashTaskStatus taskStatus2 = settings.GetTaskStatistics(StackHashTaskType.DebugScriptTask);

            Assert.AreEqual(taskStatus.FailedCount, taskStatus2.FailedCount);
            Assert.AreEqual(taskStatus.LastDurationInSeconds, taskStatus2.LastDurationInSeconds);
            Assert.AreEqual(taskStatus.LastException, taskStatus2.LastException);
            Assert.AreEqual(taskStatus.LastFailedRunTimeUtc, taskStatus2.LastFailedRunTimeUtc);
            Assert.AreEqual(taskStatus.LastStartedTimeUtc, taskStatus2.LastStartedTimeUtc);
            Assert.AreEqual(taskStatus.LastSuccessfulRunTimeUtc, taskStatus2.LastSuccessfulRunTimeUtc);
            Assert.AreEqual(taskStatus.RunCount, taskStatus2.RunCount);
            Assert.AreEqual(taskStatus.SuccessCount, taskStatus2.SuccessCount);
            Assert.AreEqual(taskStatus.TaskState, taskStatus2.TaskState);
            Assert.AreEqual(taskStatus.TaskType, taskStatus2.TaskType);
        }
예제 #5
0
        private void listViewTasks_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            bool canAbort = false;

            if (!_worker.IsBusy)
            {
                StackHashTaskStatus selectedTask = listViewTasks.SelectedItem as StackHashTaskStatus;
                if ((selectedTask != null) && (selectedTask.CanBeAbortedByClient) && (selectedTask.TaskState == StackHashTaskState.Running))
                {
                    canAbort = true;
                }
            }

            menuItemAbortTask.IsEnabled = canAbort;
        }
예제 #6
0
 /// <summary>
 /// Updates the statistics related to the task in the specified index.
 /// The stats relate to tasks that have been run on that index.
 /// </summary>
 /// <param name="index">Index to update.</param>
 public void UpdateTaskStartedStatistics(IErrorIndex index)
 {
     // Set the task status in the index - this will default if not found.
     // Only do this for an active context - otherwise a WinQualLogon task might trigger an update to
     // the stats before the error index is created.
     if ((index != null) && (index.Status == ErrorIndexStatus.Created))
     {
         StackHashTaskStatus taskStatus = index.GetTaskStatistics(this.TaskType);
         taskStatus.RunCount++;
         taskStatus.TaskState          = StackHashTaskState.Running;
         taskStatus.LastStartedTimeUtc = DateTime.Now.ToUniversalTime();
         taskStatus.LastException      = null;
         taskStatus.ServiceErrorCode   = StackHashServiceErrorCode.NoError;
         index.SetTaskStatistics(taskStatus);
     }
 }
예제 #7
0
        public void ErrorIndexXmlSettingsDefaultNoTaskData()
        {
            string settingsFileName = string.Format(CultureInfo.InvariantCulture, "{0}\\Settings.xml", m_TempPath);

            ErrorIndexXmlSettings settings = new ErrorIndexXmlSettings(settingsFileName);

            Assert.AreEqual(settingsFileName, settings.FileName);
            Assert.AreNotEqual(null, settings.LastSyncTimes);
            Assert.AreEqual(0, settings.LastSyncTimes.Count);
            StackHashTaskStatus taskStatus = settings.GetTaskStatistics(StackHashTaskType.AnalyzeTask);

            Assert.AreEqual(0, taskStatus.FailedCount);
            Assert.AreEqual(0, taskStatus.SuccessCount);
            Assert.AreEqual(0, taskStatus.LastDurationInSeconds);
            Assert.AreEqual(null, taskStatus.LastException);
            Assert.AreEqual(0, taskStatus.LastFailedRunTimeUtc.Ticks);
            Assert.AreEqual(0, taskStatus.LastStartedTimeUtc.Ticks);
            Assert.AreEqual(0, taskStatus.LastDurationInSeconds);
        }
예제 #8
0
        public void GetTaskControlDataDefault()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            StackHashTaskStatus controlData = m_Index.GetTaskStatistics(StackHashTaskType.DummyTask);

            Assert.AreEqual(0, controlData.FailedCount);
            Assert.AreEqual(0, controlData.LastDurationInSeconds);
            Assert.AreEqual(null, controlData.LastException);
            Assert.AreEqual(new DateTime(0), controlData.LastFailedRunTimeUtc);
            Assert.AreEqual(new DateTime(0), controlData.LastStartedTimeUtc);
            Assert.AreEqual(new DateTime(0), controlData.LastSuccessfulRunTimeUtc);
            Assert.AreEqual(0, controlData.RunCount);
            Assert.AreEqual(StackHashServiceErrorCode.NoError, controlData.ServiceErrorCode);
            Assert.AreEqual(0, controlData.SuccessCount);
            Assert.AreEqual(StackHashTaskState.NotRunning, controlData.TaskState);
            Assert.AreEqual(StackHashTaskType.DummyTask, controlData.TaskType);
        }
예제 #9
0
        public void SetTaskControlDataNullValues()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            DateTime testDate = new DateTime(0);


            StackHashTaskStatus setControlData = new StackHashTaskStatus();

            setControlData.TaskType                 = StackHashTaskType.DummyTask;
            setControlData.FailedCount              = 0;
            setControlData.LastDurationInSeconds    = 0;
            setControlData.LastFailedRunTimeUtc     = testDate;
            setControlData.LastStartedTimeUtc       = testDate;
            setControlData.LastSuccessfulRunTimeUtc = testDate;
            setControlData.LastException            = null;
            setControlData.RunCount                 = 0;
            setControlData.ServiceErrorCode         = StackHashServiceErrorCode.NoLicense;
            setControlData.SuccessCount             = 0;
            setControlData.TaskState                = StackHashTaskState.Queued;

            m_Index.SetTaskStatistics(setControlData);

            StackHashTaskStatus controlData = m_Index.GetTaskStatistics(StackHashTaskType.DummyTask);

            Assert.AreEqual(setControlData.FailedCount, controlData.FailedCount);
            Assert.AreEqual(setControlData.LastDurationInSeconds, controlData.LastDurationInSeconds);
            Assert.AreEqual(setControlData.LastException, controlData.LastException);
            Assert.AreEqual(setControlData.LastFailedRunTimeUtc, controlData.LastFailedRunTimeUtc);
            Assert.AreEqual(setControlData.LastStartedTimeUtc, controlData.LastStartedTimeUtc);
            Assert.AreEqual(setControlData.LastSuccessfulRunTimeUtc, controlData.LastSuccessfulRunTimeUtc);
            Assert.AreEqual(setControlData.RunCount, controlData.RunCount);
            Assert.AreEqual(setControlData.ServiceErrorCode, controlData.ServiceErrorCode);
            Assert.AreEqual(setControlData.SuccessCount, controlData.SuccessCount);
            Assert.AreEqual(setControlData.TaskState, controlData.TaskState);
            Assert.AreEqual(setControlData.TaskType, controlData.TaskType);
        }
예제 #10
0
        private void BuildReport(StackHashTaskStatus syncStatus, bool logonFailed, string logonExceptionText)
        {
            // logonFailed and logonExceptionText don't seem to be working - see Case 599

            if (syncStatus.ServiceErrorCode == StackHashServiceErrorCode.NoError)
            {
                // sync succeeded
                Paragraph para = new Paragraph();
                para.Inlines.Add(new Run(Properties.Resources.Synchronization + " "));

                Span successSpan = new Span();
                successSpan.FontWeight = FontWeights.Bold;
                successSpan.Foreground = Brushes.Green;
                successSpan.Inlines.Add(new Run(Properties.Resources.Succeeded));
                para.Inlines.Add(successSpan);

                DateTime successDateLocal = syncStatus.LastSuccessfulRunTimeUtc.ToLocalTime();

                para.Inlines.Add(new Run(" " + string.Format(CultureInfo.CurrentCulture,
                                                             Properties.Resources.SyncReport_AtDateTime,
                                                             successDateLocal.ToLongDateString(),
                                                             successDateLocal.ToLongTimeString())));

                richTextBoxSyncReport.Document.Blocks.Add(para);
            }
            else if (syncStatus.ServiceErrorCode == StackHashServiceErrorCode.Aborted)
            {
                DateTime startedDateLocal = syncStatus.LastStartedTimeUtc.ToLocalTime();

                AddPlainParagraph(string.Format(CultureInfo.CurrentCulture,
                                                Properties.Resources.SyncReport_Canceled,
                                                startedDateLocal.ToLongDateString(),
                                                startedDateLocal.ToLongTimeString()));
            }
            else
            {
                // sync failed
                Paragraph para = new Paragraph();
                para.Inlines.Add(new Run(Properties.Resources.Synchronization + " "));

                Span successSpan = new Span();
                successSpan.FontWeight = FontWeights.Bold;
                successSpan.Foreground = Brushes.Red;
                successSpan.Inlines.Add(new Run(Properties.Resources.Failed));
                para.Inlines.Add(successSpan);

                DateTime failDateLocal = syncStatus.LastFailedRunTimeUtc.ToLocalTime();

                para.Inlines.Add(new Run(" " + string.Format(CultureInfo.CurrentCulture,
                                                             Properties.Resources.SyncReport_AtDateTime,
                                                             failDateLocal.ToLongDateString(),
                                                             failDateLocal.ToLongTimeString())));

                richTextBoxSyncReport.Document.Blocks.Add(para);

                AddPlainParagraph(string.Format(CultureInfo.CurrentCulture,
                                                Properties.Resources.SyncReport_FailReason,
                                                syncStatus.ServiceErrorCode == StackHashServiceErrorCode.UnexpectedError ? syncStatus.LastException : StackHashMessageBox.GetServiceErrorCodeMessage(syncStatus.ServiceErrorCode)));

                DateTime successDateLocal = syncStatus.LastSuccessfulRunTimeUtc.ToLocalTime();

                AddPlainParagraph(string.Format(CultureInfo.CurrentCulture,
                                                Properties.Resources.SyncReport_LastSuccess,
                                                successDateLocal.ToLongDateString(),
                                                successDateLocal.ToLongTimeString()));
            }

            TimeSpan syncDuration = new TimeSpan(0, 0, syncStatus.LastDurationInSeconds);

            AddPlainParagraph(string.Format(CultureInfo.CurrentCulture,
                                            Properties.Resources.SyncReport_Duration,
                                            TimeSpanDisplayString(syncDuration)));
        }
예제 #11
0
        public void SetTaskControlData2Tasks()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            DateTime testDate = new DateTime(2010, 08, 10, 10, 30, 40, DateTimeKind.Utc);


            StackHashTaskStatus setControlData = new StackHashTaskStatus();

            setControlData.TaskType                 = StackHashTaskType.DummyTask;
            setControlData.FailedCount              = 1;
            setControlData.LastDurationInSeconds    = 2;
            setControlData.LastFailedRunTimeUtc     = testDate;
            setControlData.LastStartedTimeUtc       = testDate.AddDays(1);
            setControlData.LastSuccessfulRunTimeUtc = new DateTime(0, DateTimeKind.Utc);
            setControlData.LastException            = "Some exception text";
            setControlData.RunCount                 = 3;
            setControlData.ServiceErrorCode         = StackHashServiceErrorCode.NoLicense;
            setControlData.SuccessCount             = 4;
            setControlData.TaskState                = StackHashTaskState.Queued;

            m_Index.SetTaskStatistics(setControlData);

            StackHashTaskStatus setControlData2 = new StackHashTaskStatus();

            setControlData2.TaskType                 = StackHashTaskType.ErrorIndexMoveTask;
            setControlData2.FailedCount              = 2;
            setControlData2.LastDurationInSeconds    = 3;
            setControlData2.LastFailedRunTimeUtc     = testDate.AddDays(3);
            setControlData2.LastStartedTimeUtc       = testDate.AddDays(4);
            setControlData2.LastSuccessfulRunTimeUtc = testDate.AddDays(5);
            setControlData2.LastException            = "Some exception text 2";
            setControlData2.RunCount                 = 4;
            setControlData2.ServiceErrorCode         = StackHashServiceErrorCode.MoveInProgress;
            setControlData2.SuccessCount             = 5;
            setControlData2.TaskState                = StackHashTaskState.Faulted;

            m_Index.SetTaskStatistics(setControlData2);


            StackHashTaskStatus controlData = m_Index.GetTaskStatistics(setControlData.TaskType);

            Assert.AreEqual(setControlData.FailedCount, controlData.FailedCount);
            Assert.AreEqual(setControlData.LastDurationInSeconds, controlData.LastDurationInSeconds);
            Assert.AreEqual(setControlData.LastException, controlData.LastException);
            Assert.AreEqual(setControlData.LastFailedRunTimeUtc, controlData.LastFailedRunTimeUtc);
            Assert.AreEqual(setControlData.LastStartedTimeUtc, controlData.LastStartedTimeUtc);
            Assert.AreEqual(setControlData.LastSuccessfulRunTimeUtc, controlData.LastSuccessfulRunTimeUtc);
            Assert.AreEqual(setControlData.RunCount, controlData.RunCount);
            Assert.AreEqual(setControlData.ServiceErrorCode, controlData.ServiceErrorCode);
            Assert.AreEqual(setControlData.SuccessCount, controlData.SuccessCount);
            Assert.AreEqual(setControlData.TaskState, controlData.TaskState);
            Assert.AreEqual(setControlData.TaskType, controlData.TaskType);


            StackHashTaskStatus controlData2 = m_Index.GetTaskStatistics(setControlData2.TaskType);

            Assert.AreEqual(setControlData2.FailedCount, controlData2.FailedCount);
            Assert.AreEqual(setControlData2.LastDurationInSeconds, controlData2.LastDurationInSeconds);
            Assert.AreEqual(setControlData2.LastException, controlData2.LastException);
            Assert.AreEqual(setControlData2.LastFailedRunTimeUtc, controlData2.LastFailedRunTimeUtc);
            Assert.AreEqual(setControlData2.LastStartedTimeUtc, controlData2.LastStartedTimeUtc);
            Assert.AreEqual(setControlData2.LastSuccessfulRunTimeUtc, controlData2.LastSuccessfulRunTimeUtc);
            Assert.AreEqual(setControlData2.RunCount, controlData2.RunCount);
            Assert.AreEqual(setControlData2.ServiceErrorCode, controlData2.ServiceErrorCode);
            Assert.AreEqual(setControlData2.SuccessCount, controlData2.SuccessCount);
            Assert.AreEqual(setControlData2.TaskState, controlData2.TaskState);
            Assert.AreEqual(setControlData2.TaskType, controlData2.TaskType);
        }
예제 #12
0
 public void SetTaskStatistics(StackHashTaskStatus taskStatus)
 {
 }