private void RunAdiSchedules() { List<TaskDetail> tasksList = new TasksScheduler().GetPendingSchedules(Constants.SiteName.ADIGLOBAL); for (int index = 0; index < tasksList.Count; index++) { if (tasksList[index].TaskMode == Constants.TaskMode.ADI_CRAWL) AdiSpider.CrawlProduct(tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_UPDATE) AdiSpider.UpdateProduct(tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_CLEARANCE_ZONE) AdiSpider.GetClearanzeZone(tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_HOT_DEALS) AdiSpider.GetHotDeals(tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_ONLINE_SPECIALS) AdiSpider.GetOnlineSpecials(tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_SALE_CENTER) AdiSpider.GetSaleCenter(tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_IN_STOCK) AdiSpider.GetInStockItems(tasksList[index]); else AdiSpider.ProcessProductLeastCount(); TaskheaderUpdate(tasksList[index].TaskHeaderID); } }
void TasksRefresh() { var items = listViewThreads.SelectedItems; if (!ReferenceEquals(items, null)) { foreach (ListViewItem item in items) { TaskDetail taskDetail = GetTaskFromListViewItem(item); taskDetail = new TasksScheduler().GetTaskDetailByID(taskDetail.TaskID); if (!ReferenceEquals(taskDetail, null)) { SetTaskDetailInListViewItem(taskDetail); } } } }
private void btnDeleteSchedule_Click(object sender, EventArgs e) { var items = listViewScheduleTasks.SelectedItems; if (items != null && items.Count > 0) { var result = MessageBox.Show("Do you want to delete the schedule?", "Delete Schedule", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { TaskHeader th = GetTaskSchedulerHeader(items[0]); TasksScheduler mgr = new TasksScheduler(); mgr.DeleteTaskHeader(th); LoadScheduleHeaders(true); } } }
void TasksDelete() { var items = listViewThreads.SelectedItems; if (!ReferenceEquals(items, null)) { foreach (ListViewItem item in items) { TaskDetail taskDetail = GetTaskFromListViewItem(item); taskDetail = new TasksScheduler().GetTaskDetailByID(taskDetail.TaskID); if (!ReferenceEquals(taskDetail, null)) { if (new TasksScheduler().DeleteTaskDetail(taskDetail.TaskID) > 0) item.Remove(); //SetTaskDetailInListViewItem(taskDetail); } } ReloadTaskDetails(); } }
void TaskIgnitoModeToggle(Boolean IgnitoMode) { var items = listViewThreads.SelectedItems; if (!ReferenceEquals(items, null)) { foreach (ListViewItem item in items) { TaskDetail taskDetail = GetTaskFromListViewItem(item); taskDetail = new TasksScheduler().GetTaskDetailByID(taskDetail.TaskID); if (!ReferenceEquals(taskDetail, null)) { // Ignito Mode Toggle taskDetail.IncognitoMode = IgnitoMode; // !taskDetail.IgnitoMode; new TasksScheduler().SaveTaskDetail(taskDetail); SetTaskDetailInListViewItem(taskDetail); } } ReloadTaskDetails(); } }
void TaskDownloadImagesToggle(Boolean DownloadImages) { var items = listViewThreads.SelectedItems; if (!ReferenceEquals(items, null)) { foreach (ListViewItem item in items) { TaskDetail taskDetail = GetTaskFromListViewItem(item); taskDetail = new TasksScheduler().GetTaskDetailByID(taskDetail.TaskID); if (!ReferenceEquals(taskDetail, null)) { // Download Images Toggle taskDetail.DownloadImages = DownloadImages; //!taskDetail.DownloadImages; new TasksScheduler().SaveTaskDetail(taskDetail); SetTaskDetailInListViewItem(taskDetail); } } ReloadTaskDetails(); } }
private void startWorker_DoWork(object sender, DoWorkEventArgs e) { try { //Utility.ApplicationLog("Starting to process tasks"); ChangeButtonText(btnStart, "Please wait..."); ChangeControlState(btnStart, false); ChangeControlState(cmbAdiMode, false); ChangeControlState(treeCatagory, false); ChangeControlState(chkAdiDownloadImage, false); ChangeControlState(btnTimer, false); ChangeControlState(chkAdiIncognito, false); if (btnStart.Enabled) return; List<TaskDetail> tasksList = new TasksScheduler().GetPendingTasks(); for (int index = 0; index < tasksList.Count; index++) { if (tasksList[index].TaskMode == Constants.TaskMode.ADI_CRAWL) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.CrawlProduct), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_UPDATE) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.UpdateProduct), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_CLEARANCE_ZONE) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.GetClearanzeZone), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_HOT_DEALS) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.GetHotDeals), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_ONLINE_SPECIALS) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.GetOnlineSpecials), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_SALE_CENTER) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.GetSaleCenter), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.ADI_IN_STOCK) SpiderThread.Add(new ParameterizedThreadStart(AdiSpider.GetInStockItems), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.SECLOCK_MANUFACTURER_CRAWL) SpiderThread.Add(new ParameterizedThreadStart(SecLockSpider.Crawl), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.SECLOCK_CATEGORY_CRAWL) SpiderThread.Add(new ParameterizedThreadStart(SecLockSpider.Crawl), tasksList[index]); else if (tasksList[index].TaskMode == Constants.TaskMode.SECLOCK_PRODUCT_UPDATE) SpiderThread.Add(new ParameterizedThreadStart(SecLockSpider.Update), tasksList[index]); } //Utility.ApplicationLog("Tasks Processed"); } catch (Exception ex) { Utility.ApplicationLog("Failed to process tasks"); Utility.ErrorLog(ex, null); if (Settings.GetValue("MailErrors") == true) Utility.ErrorLog(ex, null, Constants.EmailErrorFile); //treeCatagory.Enabled = true; //btnStart.Text = "Start"; //btnStart.Enabled = true; //rbtnCrawl.Enabled = rbtnUpdate.Enabled = true; //Utility.SendAlertMail("Login Failed", "Login Failed for http://adiglobal.us"); ChangeButtonText(btnStart, "Start"); ChangeControlState(btnStart, true); ChangeControlState(cmbAdiMode, true); ChangeControlState(treeCatagory, true); ChangeControlState(chkAdiDownloadImage, true); ChangeControlState(btnTimer, true); ChangeControlState(chkAdiIncognito, true); } }
private void ReloadTaskDetails(Boolean FullReload = false, Int64 SchedulerID = -1) { if (FullReload) { listViewThreads.Items.Clear(); } List<TaskDetail> dbtasks = new TasksScheduler().GetAllTasks(SchedulerID); List<TaskDetail> listTasks = new List<TaskDetail>(); foreach (ListViewItem item in listViewThreads.Items) { listTasks.Add(GetTaskFromListViewItem(item)); } foreach (TaskDetail task in dbtasks) { SetTaskDetailInListViewItem(task); } }