Пример #1
0
        public List <SchedulePlan> GetScheduledPlansByType(SchedulePlanType type)
        {
            string sql = "SELECT * FROM schedule_plan WHERE type = @type ORDER BY name";
            List <NpgsqlParameter> parameters = new List <NpgsqlParameter>();

            parameters.Add(new NpgsqlParameter("type", (int)type)
            {
                NpgsqlDbType = NpgsqlDbType.Integer
            });

            DataTable dtSchedulePlans = ExecuteQuerySqlCommand(sql, parameters);

            return(dtSchedulePlans.Rows.MapTo <SchedulePlan>());
        }
Пример #2
0
        public DateTime?FindSchedulePlanNextTriggerDate(SchedulePlan schedulePlan)
        {
            SchedulePlanType planType    = schedulePlan.Type;
            DateTime         nowDateTime = DateTime.UtcNow;    //.AddMinutes(1);
            DateTime         startingDate;

            if (schedulePlan.StartDate.HasValue)            //if day is selected then
            {
                startingDate = schedulePlan.StartDate.Value;
            }
            else
            {
                startingDate = nowDateTime;
            }
            switch (planType)
            {
            case SchedulePlanType.Interval:
            {
                return(FindIntervalSchedulePlanNextTriggerDate(schedulePlan, nowDateTime, schedulePlan.LastTriggerTime));
            }

            case SchedulePlanType.Daily:
            {
                return(FindDailySchedulePlanNextTriggerDate(schedulePlan, nowDateTime, startingDate));
            }

            case SchedulePlanType.Weekly:
            {
                return(FindWeeklySchedulePlanNextTriggerDate(schedulePlan, nowDateTime, startingDate));
            }

            case SchedulePlanType.Monthly:
            {
                return(FindMonthlySchedulePlanNextTriggerDate(schedulePlan, nowDateTime, startingDate));
            }
            }
            return(null);
        }