Esempio n. 1
0
 private async void Window_Loaded(object sender, RoutedEventArgs e)
 {
     _alertNotifier        = new AlertNotifier();
     _alertNotifier.Alert += async(_, args) =>
     {
         await Dispatcher.InvokeAsync(() =>
         {
             textBlockAlertMessage.Text = $"{DateTime.Now}: {args.Data.Value}";
         });
     };
     await _alertNotifier.InitializeAsync();
 }
        public static string GetAlertsView()
        {
            List <Alert> alerts = new List <Alert>();

            using (AccessPointClient accessPoint = new AccessPointClient())
            {
                Alert[] page;
                do
                {
                    page = accessPoint.GetAlerts(new GetAlertsRequest
                    {
                        Skip = (uint)alerts.Count,
                        Take = PageSize,
                    }).Alerts;
                    alerts.AddRange(page);
                }while (page != null && page.Length == PageSize);

                long[]         jobIds = alerts.Select(a => a.JobId).ToArray();
                List <JobData> jobs   = new List <JobData>();
                JobData[]      jobPage;
                do
                {
                    jobPage = accessPoint.GetJobs(new GetJobsRequest
                    {
                        Skip = (uint)jobs.Count,
                        Take = PageSize,
                    }).Jobs;
                    jobs.AddRange(jobPage);
                }while (jobPage != null && jobPage.Length == PageSize);

                if (jobs.Count > 0)
                {
                    foreach (var alert in alerts)
                    {
                        var job = jobs.FirstOrDefault(j => j.Id == alert.JobId);
                        if (job != null)
                        {
                            alert.JobName = job.Name;
                        }
                    }
                }
            }

            System.Web.HttpRuntime.Cache.Remove(Constants.AlertsListCacheKey);
            System.Web.HttpRuntime.Cache.Add(Constants.AlertsListCacheKey, alerts, null, System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.NotRemovable, null);

            AlertNotifier alertNotifierControl = AjaxUtility.LoadControl("/UserControls/AlertNotifier.ascx") as AlertNotifier;

            alertNotifierControl.AlertCount = alerts.Count;
            return(AjaxUtility.RenderUserControl(alertNotifierControl));
        }
Esempio n. 3
0
        protected override void DeleteDomainObjects(ArrayList domainObjects)
        {
            try
            {
                this.DataProvider.BeginTransaction();

                for (int i = 0; i < domainObjects.Count; i++)
                {
                    AlertBill alert = domainObjects[i] as AlertBill;
                    if (alert != null)
                    {
                        object[] objs = _alertBillFacade.QueryAlertNotifier(alert.BillId);
                        if (objs != null)
                        {
                            foreach (object obj in objs)
                            {
                                AlertNotifier an = obj as AlertNotifier;
                                if (an != null)
                                {
                                    _alertBillFacade.DeleteAlertNotifier(an);
                                }
                            }
                        }
                    }
                    if (alert.AlertType == AlertType_Old.ResourceNG)
                    {
                        _alertBillFacade.DeleteAlertResBill((AlertResBill)alert);
                    }
                    else
                    {
                        _alertBillFacade.DeleteAlertBill(alert);
                    }
                }

                this.DataProvider.CommitTransaction();
            }
            catch (System.Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                throw ex;
            }
        }
Esempio n. 4
0
 protected override async Task OnInitializedAsync()
 {
     _alertNotifier        = new AlertNotifier();
     _alertNotifier.Alert += (_, args) => AlertText = $"{DateTime.Now}: {args.Data.Value}";
     await _alertNotifier.InitializeAsync();
 }
Esempio n. 5
0
 public void DeleteAlertNotifier(AlertNotifier alertNotifier)
 {
     this._helper.DeleteDomainObject(alertNotifier);
 }
Esempio n. 6
0
 public void UpdateAlertNotifier(AlertNotifier alertNotifier)
 {
     this._helper.UpdateDomainObject(alertNotifier);
 }
Esempio n. 7
0
 public void AddAlertNotifier(AlertNotifier alertNotifier)
 {
     this._helper.AddDomainObject(alertNotifier);
 }