Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
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());
            }
        }