Example #1
0
        public override void Execute()
        {
            try
            {
                _log.Info("Begin excute post API for the websites");

                // Nếu cron job được yêu cầu dưng lại thì sẽ không sử lý nữa
                if (isPause())
                {
                    _log.Info("Run Schedule Web - Cron Job Pause.");
                    return;
                }

                var schedules = CronJobController.getScheduleProductStatus(_website, (int)CronJobStatus.Scheduled, 80);
                _log.Info(String.Format("Run Schedule - Number Schedule: {0:N}", schedules.Count));

                if (schedules.Count > 0)
                {
                    // Lock các dữ liệu chuẩn bị start
                    schedules = schedules.Select(x =>
                    {
                        x.Status = (int)CronJobStatus.Start;
                        return(x);
                    })
                                .ToList();
                    CronJobController.updateScheduleProductStatus(schedules);

                    // Chạy post API
                    RunScheduleWeb(schedules);
                }

                _log.Info("End excute post API for the websites");
            }
            catch (ThreadAbortException)
            {
                Thread.ResetAbort();
            }
        }
Example #2
0
        public void LoadData()
        {
            if (acc != null)
            {
                DateTime DateConfig = new DateTime(2018, 6, 22);

                DateTime fromDate = DateConfig;
                DateTime toDate   = DateTime.Now;

                if (!String.IsNullOrEmpty(Request.QueryString["fromdate"]))
                {
                    fromDate = Convert.ToDateTime(Request.QueryString["fromdate"]);
                }

                if (!String.IsNullOrEmpty(Request.QueryString["todate"]))
                {
                    toDate = Convert.ToDateTime(Request.QueryString["todate"]).AddDays(1).AddMinutes(-1);
                }

                rFromDate.SelectedDate = fromDate;
                rFromDate.MinDate      = DateConfig;
                rFromDate.MaxDate      = DateTime.Now;

                rToDate.SelectedDate = toDate;
                rToDate.MinDate      = DateConfig;
                rToDate.MaxDate      = DateTime.Now;

                var search       = String.Empty;
                var web          = String.Empty;
                var status       = 0;
                var category     = 0;
                var isHidden     = (Nullable <bool>)null;
                var showHomePage = String.Empty;
                var sort         = String.Empty;
                var Page         = 1;

                if (Request.QueryString["search"] != null)
                {
                    search = Request.QueryString["search"].Trim();
                }
                if (Request.QueryString["web"] != null)
                {
                    web = Request.QueryString["web"];
                }
                if (Request.QueryString["status"] != null)
                {
                    status = Request.QueryString["status"].ToInt();
                }
                if (Request.QueryString["category"] != null)
                {
                    category = Request.QueryString["category"].ToInt();
                }
                if (!String.IsNullOrEmpty(Request.QueryString["isHidden"]))
                {
                    isHidden = Request.QueryString["isHidden"].ToBool();
                }
                if (Request.QueryString["showhomepage"] != null)
                {
                    showHomePage = Request.QueryString["showhomepage"];
                }
                if (Request.QueryString["sort"] != null)
                {
                    sort = Request.QueryString["sort"];
                }
                if (Request.QueryString["Page"] != null)
                {
                    Page = Request.QueryString["Page"].ToInt();
                }

                txtSearchProduct.Text             = search;
                ddlWebAdvertisement.SelectedValue = web;
                ddlProductStatus.SelectedValue    = isHidden.HasValue ? (isHidden.Value ? "true" : "false") : "";
                ddlScheduleStatus.SelectedValue   = status.ToString();
                ddlShowHomePage.SelectedValue     = showHomePage;
                ddlCategory.SelectedValue         = category.ToString();
                ddlSort.SelectedValue             = sort;

                // Create order fileter
                var filter = new FilterModel()
                {
                    search       = search,
                    web          = web,
                    status       = status,
                    fromDate     = fromDate,
                    toDate       = toDate,
                    category     = category,
                    isHidden     = isHidden,
                    showHomePage = showHomePage,
                    sort         = sort
                };
                // Create pagination
                var page = new PaginationMetadataModel()
                {
                    currentPage = Page
                };
                var data = CronJobController.getScheduleProductStatus(filter, ref page);

                pagingall(data, page);

                ltrNumberOfSchedule.Text = page.totalCount.ToString();
            }
        }