public static void UpdateSchedule(Schedule objSchedule, List <string> WeekDays, List <string> Months, string Dates)
        {
            DateTime currentDate      = DateTime.Now;
            DateTime tmpNextStartDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, objSchedule.StartHour, objSchedule.StartMin, 0);

            try
            {
                Scheduler.RemoveFromScheduleQueue(objSchedule);
                SchedulerDataProvider.ScheduleRepeatOptionDelete(objSchedule.ScheduleID);
                if (WeekDays.Count > 0)
                {
                    AddNewScheduleWeeks(objSchedule.ScheduleID, WeekDays);
                }
                if (Months.Count > 0)
                {
                    AddNewScheduleMonths(objSchedule.ScheduleID, Months);
                }
                if (!string.IsNullOrEmpty(Dates) && Dates.Trim().Length > 0)
                {
                    AddNewScheduleDate(objSchedule.ScheduleID, Dates);
                }

                objSchedule.NextStart = UpdateTaskHistoryNextStartDate(objSchedule.ScheduleID);
                SchedulerDataProvider.UpdateSchedule(objSchedule);

                RunScheduleItemNow(objSchedule);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public static void AddNewScheduleWeeks(int ScheduleID, List <string> Weeks)
 {
     try
     {
         SchedulerDataProvider.AddNewScheduleWeek(ScheduleID, Weeks);
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// Add scheduler exception
        /// </summary>
        /// <param name="LogTypeID">Log type ID.</param>
        /// <param name="Severity">Severity</param>
        /// <param name="Message">Message</param>
        /// <param name="Exception">Exception</param>
        /// <param name="ClientIPAddress">Client IP address.</param>
        /// <param name="PageURL">Page URL.</param>
        /// <param name="IsActive">True if active.</param>
        /// <param name="PortalID">PortalID</param>
        /// <param name="AddedBy">User name.</param>

        public static void AddSchedulerException(int LogTypeID, int Severity, string Message, string Exception, string ClientIPAddress, string PageURL, bool IsActive,
                                                 int PortalID, string AddedBy)
        {
            try
            {
                SchedulerDataProvider.AddSchedulerException(LogTypeID, Severity, Message, Exception, ClientIPAddress, PageURL, IsActive, PortalID, AddedBy);
            }
            catch (Exception)
            {
            }
        }
 public static List <SchedularView> GetAllActiveTasks(int offset, int limit)
 {
     try
     {
         return(SchedulerDataProvider.GetAllActiveTasks(offset, limit));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static List <ScheduleDate> GetScheduleDates(int ScheduleID)
 {
     try
     {
         return(SchedulerDataProvider.GetScheduleDates(ScheduleID));
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static void DeleteTaskHistory(int ScheduleHistoryID)
 {
     try
     {
         SchedulerDataProvider.DeleteTaskHistory(ScheduleHistoryID);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static void UpdateScheduleEnableStatus(int scheduleId, bool isEnable)
 {
     try
     {
         SchedulerDataProvider.UpdateScheduleStatus(scheduleId, isEnable);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static List <Schedule> GetTasks()
 {
     try
     {
         return(SchedulerDataProvider.GetTasks());
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static void AddNewScheduleDate(int ScheduleID, string Dates)
 {
     try
     {
         SchedulerDataProvider.AddNewScheduleDate(ScheduleID, Dates);
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "AddNewScheduleDate");
         // throw;
     }
 }
 public static void AddNewScheduleMonths(int ScheduleID, List <string> Months)
 {
     try
     {
         SchedulerDataProvider.AddNewScheduleMonth(ScheduleID, Months);
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "AddNewScheduleMonths");
         // throw;
     }
 }
 public static void AddNewScheduleDays(int ScheduleID, List <string> WeekDays)
 {
     try
     {
         SchedulerDataProvider.AddNewScheduleDay(ScheduleID, WeekDays);
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "AddNewScheduleDays");
         // throw;
     }
 }
 public static Schedule GetSchedule(int ScheduleID)
 {
     try
     {
         return(SchedulerDataProvider.GetSchedule(ScheduleID));
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "GetSchedule");
     }
     return(null);
 }
 public static ScheduleHistory GetScheduleHistory(int ScheduleHistoryID)
 {
     try
     {
         return(SchedulerDataProvider.GetScheduleHistory(ScheduleHistoryID));
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "GetScheduleHistory");
         return(null);
     }
 }
 public static void UpdateTaskHistory(ScheduleHistory scheduleHistory)
 {
     try
     {
         SchedulerDataProvider.UpdateTaskHistory(scheduleHistory);
     }
     catch (Exception e)
     {
         ErrorLogger.log(scheduleHistory, e, "UpdateTaskHistory");
         throw;
     }
 }
 public static int GetMaxScheduleHistoryID(int ScheduleID)
 {
     try
     {
         return(SchedulerDataProvider.GetMaxScheduleHistoryID(ScheduleID));
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "GetMaxScheduleHistoryID");
         // throw;
         return(0);
     }
 }
 public static string UpdateTaskHistoryNextStartDate(int ScheduleID)
 {
     try
     {
         return(SchedulerDataProvider.UpdateTaskHistoryNextStartDate(ScheduleID));
     }
     catch (Exception e)
     {
         ErrorLogger.log(e, "UpdateTaskHistoryNextStartDate");
         return(null);
         // throw;
     }
 }
        public static int AddTaskHistory(ScheduleHistory scheduleHistory)
        {
            int Id = 0;

            try
            {
                Id = SchedulerDataProvider.AddTaskHistory(scheduleHistory);
            }
            catch (Exception)
            {
                throw;
            }
            return(Id);
        }
 public static void DeleteTask(int ScheduleID, string physicalPath)
 {
     try
     {
         SchedulerDataProvider.DeleteTask(ScheduleID);
         Scheduler.RemoveFromScheduleQueueByID(ScheduleID);
         //Scheduler.ReloadSchedule();
         DeleteFile(physicalPath);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public static List <ScheduleHistoryView> GetAllScheduleHistory(int ScheduleID, int offset, int limit)
        {
            List <ScheduleHistoryView> scheduleHistoryList = null;

            try
            {
                scheduleHistoryList = SchedulerDataProvider.GetAllScheduleHistory(ScheduleID, offset, limit);
            }
            catch (Exception)
            {
                throw;
            }

            return(scheduleHistoryList);
        }
        /// <summary>
        /// Add new schedule.
        /// </summary>
        /// <param name="objSchedule"></param>
        /// <returns></returns>
        public static Schedule AddNewSchedule(Schedule objSchedule)
        {
            try
            {
                objSchedule.ScheduleID = SchedulerDataProvider.AddNewSchedule(objSchedule);

                //  RunScheduleItemNow(objSchedule);
            }
            catch (Exception e)
            {
                ErrorLogger.log(objSchedule, e, "AddNewSchedule");
                string fileName = objSchedule.AssemblyFileName;
                string filepath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "bin\\" + fileName);
                DeleteFile(filepath);
                throw;
            }

            return(objSchedule);
        }
 public static int GetNextScheduleWeekDay(int ScheduleID, int weekday)
 {
     return(SchedulerDataProvider.GetNextScheduleWeekDay(ScheduleID, weekday));
 }
 public static DateTime?GetNextScheduleDate(int ScheduleID, string CurrentStartDate)
 {
     return(SchedulerDataProvider.GetNextScheduleDate(ScheduleID, CurrentStartDate));
 }
 public static int ScheduleDateGetNextMonth(int ScheduleID, int month)
 {
     return(SchedulerDataProvider.ScheduleDateGetNextMonth(ScheduleID, month));
 }