Example #1
0
        private void OnCheckSystemStatus(object sender, NotificationEventArgs e)
        {
            CheckDatabaseSystemState(sender, e);
            CheckInternalSystemState(sender, e);
            CheckDataPollingSystemState(sender, e);

            if (KmtConstants.IsFactoryFloor)
                CheckKeyProviderServiceSystemState(sender, e);
        }
Example #2
0
        /// <summary>
        /// create system state notification
        /// </summary>
        /// <param name="diagnosticResult"></param>
        /// <param name="errorTitle"></param>
        /// <param name="e"></param>
        private void SetSystemState(NotificationCategory notificationCategory, DiagnosticResult diagnosticResult, string errorTitle, NotificationEventArgs e)
        {
            try
            {
                NotificationCategory category = notificationCategory;
                string errorMessage = null;
                Dispatch(() =>
                {
                    if ((category != NotificationCategory.SystemError_KeyProviderServiceError && category != NotificationCategory.SystemError_DatePolling) || diagnosticResult.Exception == null)
                        errorMessage = diagnosticResult.Exception == null ? ResourcesOfR6.Notification_UnknowMessage : diagnosticResult.Exception.ToString();

                    if (diagnosticResult.DiagnosticResultType == DiagnosticResultType.Error)
                        e.Push(new Notification(category,
                            errorTitle,
                            string.IsNullOrEmpty(errorMessage) ? null : typeof(SystemStateNotificationView), null, errorTitle, errorMessage));
                    else
                        e.Pop(category);
                });

            }
            catch (Exception ex)
            {
                MessageLogger.LogSystemError(MessageLogger.GetMethodName(), ex.GetTraceText());
            }
        }
Example #3
0
 private void CheckRefulfillments(object sender, NotificationEventArgs e)
 {
     try
     {
         NotificationCategory category = NotificationCategory.ReFulfillment;
         List<FulfillmentInfo> infoes = keyProxy.GetFailedFulfillments(false);
         Dispatch(() =>
         {
             if (infoes.Count > 0)
                 e.Push(new Notification(category,
                     string.Format(MergedResources.Notification_ReFulfillmentMessage, infoes.Count),
                     typeof(ReFulfillmentNotificationView), null, infoes, keyProxy));
             else
                 e.Pop(category);
         });
     }
     catch (Exception ex)
     {
         MessageLogger.LogSystemError(MessageLogger.GetMethodName(), ex.GetTraceText());
     }
 }
Example #4
0
 /// <summary>
 /// Set error when internal web service dose not work
 /// </summary>
 /// <param name="e"></param>
 private bool IsUnknownError(NotificationCategory notificationCategory, string errorTitle, NotificationEventArgs e)
 {
     if (internalDiagnosticResult.DiagnosticResultType == DiagnosticResultType.Error)
     {
         SetSystemState(notificationCategory, new DiagnosticResult()
         {
             Exception = null,
             DiagnosticResultType = DiagnosticResultType.Error
         },
             errorTitle,
             e);
         return true;
     }
     else
     {
         return false;
     }
 }
Example #5
0
        private void CheckKeyTypeConfigurations(object sender, NotificationEventArgs e)
        {
            try
            {
                List<KeyTypeConfiguration> configs = stockProxy.GetKeyTypeConfigurations(KmtConstants.HeadQuarterId);
                Dispatch(() =>
                {
                    NotificationCategory keyTypeUnmappedCategory = NotificationCategory.KeyTypeUnmapped;
                    if (configs.Any(c => !c.KeyType.HasValue))
                        e.Push(new Notification(keyTypeUnmappedCategory,
                            ResourcesOfR6.Notification_UpmapKeyPartNumber,
                            typeof(ConfigurationView),
                            () =>
                            {
                                CheckKeyTypeConfigurations(sender, e);
                                OnRefreshKeys();
                            },
                            configProxy, ssProxy, hqProxy, userProxy, null, keyProxy, 2));
                    else
                        e.Pop(keyTypeUnmappedCategory);

                    NotificationCategory quantityOutOfRangeCategory = NotificationCategory.QuantityOutOfRange;
                    List<KeyTypeConfiguration> configsOutOfRange = configs.Where(c => c.AvailiableKeysCount < c.Minimum || c.AvailiableKeysCount > c.Maximum).ToList();
                    if (configsOutOfRange.Count > 0)
                        e.Push(new Notification(quantityOutOfRangeCategory,
                            string.Format(MergedResources.Notification_KeysStockOutOfRangeMessage, configsOutOfRange.Count),
                            typeof(KeysStockNotificationView), null, configsOutOfRange));
                    else
                        e.Pop(quantityOutOfRangeCategory);
                });
            }
            catch (Exception ex)
            {
                MessageLogger.LogSystemError(MessageLogger.GetMethodName(), ex.GetTraceText());
            }
        }
Example #6
0
 private void CheckReAcknowledgement(object sender, NotificationEventArgs e)
 {
     try
     {
         NotificationCategory category = NotificationCategory.ReAcknowledgement;
         List<Cbr> cbrs = keyProxy.GetFailedCbrs();
         Dispatch(() =>
         {
             if (cbrs.Count > 0)
                 e.Push(new Notification(category,
                     string.Format(MergedResources.Notification_ReAcknowledgeMessage, cbrs.Count),
                     typeof(ReAcknowledgementNotificationView), null, cbrs));
             else
                 e.Pop(category);
         });
     }
     catch (Exception ex)
     {
         MessageLogger.LogSystemError(MessageLogger.GetMethodName(), ex.GetTraceText());
     }
 }
Example #7
0
 /// <summary>
 /// test key provider service
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CheckKeyProviderServiceSystemState(object sender, NotificationEventArgs e)
 {
     if (!IsUnknownError(NotificationCategory.SystemError_KeyProviderServiceError, ResourcesOfR6.Notification_KeyProviderServiceErrorMessage, e))
     {
         var result = configProxy.TestKeyProviderService();
         SetSystemState(NotificationCategory.SystemError_KeyProviderServiceError, result, ResourcesOfR6.Notification_KeyProviderServiceErrorMessage, e);
     }
 }
Example #8
0
 private void CheckKeysExpired(object sender, NotificationEventArgs e)
 {
     try
     {
         NotificationCategory category = NotificationCategory.OldTimelineExceed;
         List<KeyInfo> keysExpired = keyProxy.SearchExpiredKeys(KmtConstants.OldTimeline);
         Dispatch(() =>
         {
             if (keysExpired.Count > 0)
                 e.Push(new Notification(category,
                     string.Format(MergedResources.KeyManagementViewModel_OldTimelineExceedMessage, keysExpired.Count),
                     typeof(KeysExpiredNotificationView), null, keysExpired, KmtConstants.OldTimeline));
             else
                 e.Pop(category);
         });
     }
     catch (Exception ex)
     {
         MessageLogger.LogSystemError(MessageLogger.GetMethodName(), ex.GetTraceText());
     }
 }
Example #9
0
 /// <summary>
 ///test Internal web service
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CheckInternalSystemState(object sender, NotificationEventArgs e)
 {
     string errorMessage = string.Empty;
     internalDiagnosticResult = configProxy.TestInternalConnection();
     SetSystemState(NotificationCategory.SystemError_Internal, internalDiagnosticResult, ResourcesOfR6.Notification_InternalErrorMessage, e);
 }
Example #10
0
        private void CheckDuplicatedCbr(object sender, NotificationEventArgs e)
        {
            try
            {
                NotificationCategory category = NotificationCategory.DuplicatedCbr;
                List<Cbr> cbrs = keyProxy.GetCbrsDuplicated().FindAll(cbr => cbr.CbrDuplicated != null);
                cbrs.ForEach(cbr =>
                {
                    Dispatch(() =>
                    {
                        if (cbrs.Count > 0)
                            e.Push(new Notification(category,
                                string.Format(MergedResources.ExportDuplicateCBRNotificationViewModel_DuplicateCBRsMessage, cbr.CbrKeys.Count),
                                typeof(ExportDuplicateCBRNotificationView), () => { CheckDuplicatedCbr(sender, e); }, cbr, keyProxy));
                        else
                            e.Pop(category);
                    });
                });

            }
            catch (Exception ex)
            {
                MessageLogger.LogSystemError(MessageLogger.GetMethodName(), ex.GetTraceText());
            }
        }
Example #11
0
 /// <summary>
 /// test data polling
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CheckDataPollingSystemState(object sender, NotificationEventArgs e)
 {
     if (!IsUnknownError(NotificationCategory.SystemError_DatePolling, ResourcesOfR6.Notification_DatePollingErrorMessage, e))
     {
         string errorMessage = string.Empty;
         var result = configProxy.TestDataPollingService();
         SetSystemState(NotificationCategory.SystemError_DatePolling, result, ResourcesOfR6.Notification_DatePollingErrorMessage, e);
     }
 }
Example #12
0
 /// <summary>
 /// test database
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CheckDatabaseSystemState(object sender, NotificationEventArgs e)
 {
     var result = configProxy.TestDatabaseConnection();
     SetSystemState(NotificationCategory.SystemError_DataBaseError, result, ResourcesOfR6.Notification_DataBaseErrorMessage, e);
 }
Example #13
0
        /// <summary>
        /// 
        /// </summary>
        private void OnCheckNotification(object sender, ElapsedEventArgs e)
        {
            Timer tSender = (Timer)sender;
            NotificationEventArgs ea = new NotificationEventArgs(Notifications);

            if (tSender == timer && Check != null)
                Check(this, ea);
            else if (tSender == systemCheckTimer && SystemCheck != null)
                SystemCheck(this, ea);

            tSender.Start();
        }