示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnRefresh.OnClientClick = $"refreshJobsList{ApplicationName}();return false;";
                lblLastRefresh.Text      = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
            }

            var selectedStatuses = GetSelectedStatuses().ToArray();

            using (AccessPointClient accessPoint = new AccessPointClient())
            {
                List <JobData> jobs = new List <JobData>();
                JobData[]      page;
                do
                {
                    if (!string.IsNullOrWhiteSpace(ApplicationName))
                    {
                        page = accessPoint.GetJobs(new GetJobsRequest
                        {
                            Skip         = (uint)jobs.Count,
                            Take         = PageSize,
                            Applications = new string[] { ApplicationName },
                        }).Jobs;
                        jobs.AddRange(page);
                    }
                    else
                    {
                        page = accessPoint.GetJobs(new GetJobsRequest
                        {
                            Skip = (uint)jobs.Count,
                            Take = PageSize,
                        }).Jobs;
                        jobs.AddRange(page.Where(j => string.IsNullOrWhiteSpace(j.Application)));
                    }
                }while (page != null && page.Length == PageSize);

                foreach (string groupName in jobs.Select(j => j.Group ?? "").Distinct().OrderBy(gn => gn))
                {
                    var control = (JobsGroup)Page.LoadControl("~/UserControls/JobsGroup.ascx");
                    control.ID = "JobsGroup_" + ApplicationName + "_" + groupName;
                    control.ApplicationName = ApplicationName;
                    control.GroupName       = groupName;
                    control.PageSize        = PageSize;
                    control.ShownStatuses   = selectedStatuses.ToList();
                    JobGridsContainer.Controls.Add(control);
                }
            }
        }
        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));
        }
        public void ShowJobs()
        {
            using (AccessPointClient accessPoint = new AccessPointClient())
            {
                List <JobData> jobs = new List <JobData>();
                JobData[]      page;
                do
                {
                    if (!string.IsNullOrWhiteSpace(ApplicationName))
                    {
                        page = accessPoint.GetJobs(new GetJobsRequest
                        {
                            Skip         = (uint)jobs.Count,
                            Take         = PageSize,
                            Applications = new string[] { ApplicationName },
                            JobStatuses  = ShownStatuses.ToArray(),
                        }).Jobs;
                        jobs.AddRange(page);
                    }
                    else
                    {
                        page = accessPoint.GetJobs(new GetJobsRequest
                        {
                            Skip        = (uint)jobs.Count,
                            Take        = PageSize,
                            JobStatuses = ShownStatuses.ToArray(),
                        }).Jobs;
                        jobs.AddRange(page.Where(j => string.IsNullOrWhiteSpace(j.Application)));
                    }
                }while (page != null && page.Length == PageSize);

                jobs = jobs.Where(j => string.IsNullOrWhiteSpace(GroupName) ? j.Group == null || j.Group == "" : j.Group == GroupName).ToList();

                JobsList.DataSource = jobs;
                JobsList.DataBind();
                JobsListPager.Visible = jobs.Count > JobsListPager.MaximumRows;
            }
        }
        private static JobData GetJob(long jobId)
        {
            JobData job = null;

            using (AccessPointClient accessPoint = new AccessPointClient())
            {
                job = accessPoint.GetJobs(new GetJobsRequest
                {
                    Skip   = 0,
                    Take   = 1,
                    JobIds = new long[] { jobId },
                }).Jobs.FirstOrDefault();
            }
            return(job);
        }
示例#5
0
        private void ShowJobs()
        {
            using (AccessPointClient accessPoint = new AccessPointClient())
            {
                JobData[] jobs = accessPoint.GetJobs(new GetJobsRequest
                {
                    Skip = 0,
                    Take = int.MaxValue,
                }).Jobs;

                JobsList.DataSource = jobs;
                JobsList.DataBind();
                JobsListPager.Visible = jobs.Length > JobsListPager.MaximumRows;
            }
        }
示例#6
0
        protected void JobsList_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            long jobId;

            if (long.TryParse((string)e.CommandArgument, out jobId))
            {
                switch (e.CommandName.ToUpper())
                {
                case "RUN":
                    using (AccessPointClient accessPoint = new AccessPointClient())
                    {
                        JobData job = accessPoint.GetJobs(new GetJobsRequest
                        {
                            Skip   = 0,
                            Take   = 1,
                            JobIds = new long[] { jobId },
                        }).Jobs.FirstOrDefault();

                        if (job != null)
                        {
                            if (job.CalendarSchedule == null)
                            {
                                job.Status = JobStatus.Ready;
                                accessPoint.UpdateJob(new UpdateJobRequest {
                                    JobData = job
                                });
                            }
                            else
                            {
                                accessPoint.RunScheduledJob(new RunScheduledJobRequest {
                                    JobId = jobId
                                });
                            }
                        }
                    }
                    break;

                case "DELETE":
                    using (AccessPointClient accessPoint = new AccessPointClient())
                    {
                        accessPoint.DeleteJob(new DeleteJobRequest {
                            JobId = jobId
                        });
                    }
                    break;
                }
            }
        }
示例#7
0
 private void ShowJobs()
 {
     using (AccessPointClient accessPoint = new AccessPointClient())
     {
         List <JobData> jobs = new List <JobData>();
         JobData[]      page;
         do
         {
             page = accessPoint.GetJobs(new GetJobsRequest
             {
                 Skip = (uint)jobs.Count,
                 Take = PageSize,
             }).Jobs;
             jobs.AddRange(page);
         }while (page != null && page.Length == PageSize);
         JobsList.DataSource = jobs;
         JobsList.DataBind();
         JobsListPager.Visible = jobs.Count > JobsListPager.MaximumRows;
     }
     lblLastRefresh.Text = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
 }
        protected void Page_Load(object sender, EventArgs e)

        {
            List <string> jobs = new List <string>();

            using (AccessPointClient accessPoint = new AccessPointClient())
            {
                var page = accessPoint.GetJobs(new GetJobsRequest
                {
                    Skip = 0,
                    Take = int.MaxValue,
                });

                jobs.AddRange(page.Jobs.Select(x => x.Application));
            }

            foreach (string applicationName in jobs.Distinct().OrderBy(an => an))
            {
                if (string.IsNullOrWhiteSpace(applicationName))
                {
                    continue;
                }
                var tab = new HtmlGenericControl("li");
                tab.Controls.Add(new HtmlAnchor()
                {
                    HRef = "#" + applicationName, InnerText = applicationName, ID = "tab" + applicationName
                });

                mainMenuDiv.FindControl("mainMenuUl").Controls.Add(tab);

                var div = new HtmlGenericControl("div");
                div.Attributes.Add("id", applicationName);

                mainMenuDiv.Controls.Add(div);
                var control = (WebUI.UserControls.Jobs)Page.LoadControl("~/UserControls/Jobs.ascx");
                control.ID = "Jobs_" + applicationName;
                control.ApplicationName = applicationName;
                div.Controls.Add(control);
            }
        }