public static void DownloadSchedule(string filePath, Toc toc = Toc.All, ScheduleType schedule = ScheduleType.Full, DayOfWeek? day = null)
 {
     Uri requestUri = new Uri(string.Format("{0}?type={1}&day={2}", (object)ConfigurationManager.AppSettings["ScheduleUri"], (object)string.Format("CIF_{0}_{1}_DAILY", (object)TocHelper.TocToString(toc), (object)TocHelper.ScheduleTypeToString(schedule)), (object)TocHelper.ScheduleTypeToDay(schedule, day)));
     Trace.TraceInformation("Downloading file: {0} to {1}", requestUri, filePath);
     byte[] buffer = new byte[4096];
     WebRequest webRequest = WebRequest.Create(requestUri);
     webRequest.Timeout = (int)TimeSpan.FromMinutes((double)int.Parse(ConfigurationManager.AppSettings["ScheduleTimeoutMins"])).TotalMilliseconds;
     string str = Convert.ToBase64String(Encoding.ASCII.GetBytes(ConfigurationManager.AppSettings["Username"] + ":" + ConfigurationManager.AppSettings["Password"]));
     webRequest.Headers[HttpRequestHeader.Authorization] = "Basic " + str;
     using (WebResponse response = webRequest.GetResponse())
     {
         using (Stream responseStream = response.GetResponseStream())
         {
             using (MemoryStream memoryStream = new MemoryStream())
             {
                 int count;
                 int counter = 0;
                 do
                 {
                     Console.WriteLine("Downloading bytes {0}", counter * 4096);
                     count = responseStream.Read(buffer, 0, buffer.Length);
                     memoryStream.Write(buffer, 0, count);
                     counter++;
                 }
                 while (count != 0);
                 byte[] bytes = memoryStream.ToArray();
                 System.IO.File.WriteAllBytes(filePath, bytes);
             }
         }
     }
 }
Esempio n. 2
0
        public void Open(string outputDir, ScheduleType scheduleType)
        {
            if (outputDir == null)
            {
                throw new ArgumentNullException(nameof(outputDir));
            }
            if (!_fileSystem.DirectoryExists(outputDir))
            {
                _fileSystem.CreateDirectory(outputDir);
            }

            IEnumerable <CifRecordBase> recordDefs = _recordDefFactory.GetRecordDefs(scheduleType);

            _writers = new Dictionary <string, RecordWriter>();

            foreach (CifRecordBase cifRecord in recordDefs)
            {
                string recordIdentifier = cifRecord.RecordIdentifier;

                string outputFilepath = Path.Combine(outputDir, recordIdentifier + ".csv");
                _writers.Add(recordIdentifier,
                             new RecordWriter
                {
                    Writer = new StreamWriter(_fileSystem.FileOpen(outputFilepath, FileMode.Create)),
                    Fields = cifRecord.Fields
                });
            }
        }
Esempio n. 3
0
        private Reminder.Schedule CreateSchedule(string msg, DateTime when, ScheduleType type = ScheduleType.Once, bool withAck = true)
        {
            switch (type)
            {
            case ScheduleType.Once:
                return(new Reminder.Schedule(
                           taskId: msg + "-task",
                           recipient: TestActor.Path,
                           message: msg,
                           triggerDateUtc: when,
                           ack: withAck ? msg + "-ack" : null));

            case ScheduleType.Repeat:
                return(new Reminder.ScheduleRepeatedly(
                           taskId: msg + "-task",
                           recipient: TestActor.Path,
                           message: msg,
                           triggerDateUtc: when,
                           repeatInterval: TimeSpan.FromSeconds(1),
                           ack: withAck ? msg + "-ack" : null));

            case ScheduleType.Cron:
                return(new Reminder.ScheduleCron(
                           taskId: msg + "-task",
                           recipient: TestActor.Path,
                           message: msg,
                           triggerDateUtc: when,
                           cronExpression: "0 12 * * *",
                           ack: withAck ? msg + "-ack" : null));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
 private void SwitchUIByFrequency(ScheduleType frq)
 {
     this.DayOfWeekSelector.Visibility = Visibility.Collapsed;
     this.Frequency_EveryMonth_Day_Value.Visibility = Visibility.Collapsed;
     if (frq == ScheduleType.EveryDay)
     {
         this.frequency.Frequency = ScheduleType.EveryDay;
     }
     else if (frq == ScheduleType.EveryWeek)
     {
         this.DayOfWeekSelector.Visibility = Visibility.Visible;
         this.frequency.Frequency = ScheduleType.EveryWeek;
     }
     else if (frq == ScheduleType.EveryMonth)
     {
         this.Frequency_EveryMonth_Day_Value.Visibility = Visibility.Visible;
         this.frequency.Frequency = ScheduleType.EveryMonth;
     }
     else if (frq == ScheduleType.Workday)
     {
         this.frequency.Frequency = ScheduleType.Workday;
     }
     else if (frq == ScheduleType.Weekend)
     {
         this.frequency.Frequency = ScheduleType.Weekend;
     }
     else if (frq == ScheduleType.SpecificDate)
     {
         this.frequency.Frequency = ScheduleType.SpecificDate;
     }
 }
        //
        // Load ConfigXml into controls
        //
        private void ScheduleDialog_Load(object sender, EventArgs e)
        {
            if (ConfigXml.ChildNodes.Count > 0)
            {
                ScheduleType scheduleType = Schedule.IfExistsExtractScheduleType(ConfigXml);
                dateStart.Value = Schedule.IfExistsExtractDate(ConfigXml, "/schedule/startdate", DateTime.Now);
                timeStart.Value = Schedule.IfExistsExtractTime(ConfigXml, "/schedule/starttime", DateTime.Now);

                switch (scheduleType)
                {
                case ScheduleType.Daily:
                    LoadDailySchedule();
                    break;

                case ScheduleType.Weekly:
                    LoadWeeklySchedule();
                    break;

                case ScheduleType.Monthly:
                    LoadMonthlySchedule();
                    break;

                case ScheduleType.Timely:
                    LoadTimelySchedule();
                    break;

                default:
                    ConfigXml = new XmlDocument();
                    break;
                }
            }
        }
Esempio n. 6
0
 ///<summary>If a particular day already has some non-default schedule items, then this does nothing and returns false.  But if the day is all default, then it converts each default entry into an actual schedule entry and returns true.  The user would not notice this change, but now they can edit or add.</summary>
 public static bool ConvertFromDefault(DateTime forDate, ScheduleType schedType, int provNum)
 {
     Schedule[] List        = RefreshDay(forDate);
     Schedule[] ListForType = GetForType(List, schedType, provNum);
     if (ListForType.Length > 0)
     {
         return(false);               //do nothing, since it has already been converted from default.
         //it is also possible there will be no default entries to convert, but that's ok.
     }
     SchedDefault[] ListDefaults = SchedDefaults.GetForType(schedType, provNum);
     for (int i = 0; i < ListDefaults.Length; i++)
     {
         if (ListDefaults[i].DayOfWeek != (int)forDate.DayOfWeek)
         {
             continue;                    //if day of week doesn't match, then skip
         }
         Schedule SchedCur = new Schedule();
         SchedCur.Status       = SchedStatus.Open;
         SchedCur.SchedDate    = forDate;
         SchedCur.StartTime    = ListDefaults[i].StartTime;
         SchedCur.StopTime     = ListDefaults[i].StopTime;
         SchedCur.SchedType    = schedType;
         SchedCur.ProvNum      = provNum;
         SchedCur.Op           = ListDefaults[i].Op;
         SchedCur.BlockoutType = ListDefaults[i].BlockoutType;
         InsertOrUpdate(SchedCur, true);
     }
     return(true);
 }
        private string GetHtmlMessageBody(User user, string unsubscribeToken, List <Article> articles,
                                          ScheduleType scheduleType, Template articlesEmailTemplate)
        {
            unsubscribeToken = WebUtility.UrlEncode(unsubscribeToken);

            var model = new ArticlesModel
            {
                UserName       = user.Name,
                UserEmail      = user.Email,
                Period         = GetPeriod(scheduleType),
                UnsubscribeUrl = $"{_webUiBasePath}/unsubscribe/{unsubscribeToken}",
                ViewOnSiteUrl  = $"{_webUiBasePath}/articles/sent",
                Articles       = articles.Select(a => new ArticleModel
                {
                    Title        = a.Title,
                    Description  = a.Description,
                    Url          = $"{_webUiBasePath}/articles/{a.Id}/user/{user.Id}",
                    PublicatedAt = GetDate(a.PublicatedAt),
                    ReadTime     = a.ReadTime,
                    PdfUrl       = $"{_webUiBasePath}/articles/{a.Id}",
                    AuthorEmail  = a.AuthorEmail,
                    AuthorName   = a.AuthorName,
                    AuthorPhoto  = a.AuthorPhoto
                }).ToList()
            };

            return(articlesEmailTemplate.Render(new { Model = model }));
        }
Esempio n. 8
0
 // Constructor
 public Schedule(string name, DateTime startTime, ScheduleType type)
 {
     StartTime  = startTime;
     m_nextTime = startTime;
     m_type     = type;
     m_name     = name;
 }
Esempio n. 9
0
        /// <summary>
        /// Returns the start date for the report based on the type of email schedule
        /// </summary>
        /// <param name="scheduleType">Schedule type for the report</param>
        /// <returns>Start and End date of the report</returns>
        private static Tuple <DateTime, DateTime> GetMerchantReportDate(ScheduleType scheduleType)
        {
            DateTime fromDateTime = new DateTime();
            DateTime toDateTime   = new DateTime();

            switch (scheduleType)
            {
            case ScheduleType.Daily:
                fromDateTime = DateTime.UtcNow.AddDays(-1);
                toDateTime   = DateTime.UtcNow.AddDays(-1);
                break;

            case ScheduleType.Monthly:
                DateTime previousMonth = DateTime.UtcNow.AddMonths(-1);
                fromDateTime = new DateTime(previousMonth.Year, previousMonth.Month, 01);
                toDateTime   = new DateTime(previousMonth.Year, previousMonth.Month, DateTime.DaysInMonth(previousMonth.Year, previousMonth.Month));
                break;

            case ScheduleType.Weekly:
                fromDateTime = DateTime.UtcNow.AddDays(-7);
                toDateTime   = DateTime.UtcNow.AddDays(-1);
                break;
            }

            fromDateTime = new DateTime(fromDateTime.Year, fromDateTime.Month, fromDateTime.Day, 0, 0, 1);
            toDateTime   = new DateTime(toDateTime.Year, toDateTime.Month, toDateTime.Day, 23, 59, 59);

            return(new Tuple <DateTime, DateTime>(fromDateTime, toDateTime));
        }
 protected ScheduleType(ScheduleType a, ScheduleType b)
 {
     foreach (var kvp in a.innerValue.Union(b.innerValue))
     {
         innerValue[kvp.Key] = kvp.Value;
     }
 }
Esempio n. 11
0
        ///<summary>Used in the schedule setup window</summary>
        public static Schedule[] RefreshMonth(DateTime CurDate, ScheduleType schedType, int provNum)
        {
            string command =
                //"SELECT * FROM schedule WHERE SchedDate > '"+POut.PDate(startDate.AddDays(-1))+"' "
                //+"AND SchedDate < '"+POut.PDate(stopDate.AddDays(1))+"' "

                /*"SELECT * FROM schedule WHERE MONTH(SchedDate)='"+CurDate.Month.ToString()
                 +"' AND YEAR(SchedDate)='"+CurDate.Year.ToString()+"' "
                 +"AND SchedType="+POut.PInt((int)schedType)
                 +" AND ProvNum="+POut.PInt(provNum)
                 +" ORDER BY starttime";*/
                "SELECT * FROM schedule WHERE ";

            if (FormChooseDatabase.DBtype == DatabaseType.Oracle)
            {
                command += "TO_CHAR(SchedDate,'MM')='" + CurDate.Month.ToString() + "' AND TO_CHAR(SchedDate,'YYYY')";
            }
            else              //Assume MySQL
            {
                command += "MONTH(SchedDate)='" + CurDate.Month.ToString() + "' AND YEAR(SchedDate)";
            }
            command += "='" + CurDate.Year.ToString() + "'"
                       + " AND SchedType=" + POut.PInt((int)schedType)
                       + " AND ProvNum=" + POut.PInt(provNum)
                       + " ORDER BY starttime";
            return(RefreshAndFill(command).ToArray());
        }
Esempio n. 12
0
        /// <summary>
        /// 取得Queue內的推波訊息
        /// </summary>
        /// <param name="pushMessage"></param>
        /// <returns></returns>
        internal static ScheduleTask GetNextScheduleTask(ScheduleType pushMessage)
        {
            ScheduleTask task      = null;
            string       queueName = $"MQ{DateTime.Now.ToString("yyyyMMdd")}.TaskQueue";

            try
            {
                //***************OptionIII 讀取單線程那版的架構方法()***********
                IMQConsumerFacade <string> adapter = new MQConsumerFacade <string>(queueName, 60, 10, false, null, 2, 10);
                //adapter.Init();
                adapter.Connect();
                task = JsonConvert.DeserializeObject <ScheduleTask>(adapter.StartDequeue());
                adapter.Disconnect();

                if (task != null)
                {
                    NLogService.Instance.Info($"{DateTime.Now} Info: GetNextScheduleTask()取得訊息。Queue: {queueName}。Task= {task.ScheduleData}");
                }
            }
            catch (Exception ex)
            {
                NLogService.Instance.Error($"{DateTime.Now} Error: GetNextScheduleTask()錯誤。Message: {ex.Message}。StackTrace= {ex.StackTrace}");
                task = null;
            }

            return(task);
        }
Esempio n. 13
0
        /// <summary>
        /// Формирование запроса для отправки серверу
        /// </summary>
        /// <param name="uri">адрес страницы</param>
        /// <param name="scheduleType">тип расписания</param>
        public void LoadData(string uri, ScheduleType scheduleType)
        {
            var request = (HttpWebRequest)WebRequest.Create(uri);

            //Add these, as we're doing a POST
            request.ContentType = "application/x-www-form-urlencoded";
            request.Method      = "POST";

            switch (scheduleType)
            {
            case ScheduleType.Subjects:
                request.BeginGetRequestStream(GetRequestStreamSubjectsCallback, request);
                break;

            case ScheduleType.Exams:
                request.BeginGetRequestStream(GetRequestStreamExamsCallback, request);
                break;
            }


            // Keep the main thread from continuing while the asynchronous
            // operation completes. A real world application
            // could do something useful such as updating its user interface.

            //allDone.WaitOne();
        }
Esempio n. 14
0
        public IEnumerable <CifRecordBase> GetRecordDefs(ScheduleType scheduleType)
        {
            if (scheduleType == ScheduleType.Association)
            {
                return(new List <CifRecordBase> {
                    new AaRecord()
                });
            }

            else if (scheduleType == ScheduleType.Journey)
            {
                return(new List <CifRecordBase> {
                    new HdRecord(),
                    new BsRecord(),
                    new BxRecord(),
                    new LoRecord(),
                    new LiRecord(),
                    new CrRecord(),
                    new LtRecord(),
                    new ZzRecord()
                });
            }

            return(new List <CifRecordBase> {
                new AaRecord(),
                new HdRecord(),
                new BsRecord(),
                new BxRecord(),
                new LoRecord(),
                new LiRecord(),
                new CrRecord(),
                new LtRecord(),
                new ZzRecord()
            });
        }
Esempio n. 15
0
        public static void GetIconAndToolTip(ScheduleType scheduleType, UpcomingCancellationReason cancellationReason,
                                             bool isPartOfSeries, UpcomingOrActiveProgramsList upcomingRecordings, UpcomingRecording upcomingRecording,
                                             out Icon icon, out string toolTip)
        {
            toolTip = null;
            bool isCancelled = (cancellationReason != UpcomingCancellationReason.None);

            switch (scheduleType)
            {
            case ScheduleType.Recording:
                GetRecordingIconAndToolTip(upcomingRecordings, cancellationReason, isPartOfSeries, upcomingRecording,
                                           out icon, out toolTip);
                break;

            case ScheduleType.Alert:
                icon = isCancelled ? (isPartOfSeries ? Properties.Resources.AlertSeriesCancelledIcon : Properties.Resources.AlertCancelledIcon)
                        : GetIcon(ScheduleType.Alert, isPartOfSeries);
                break;

            case ScheduleType.Suggestion:
                icon = isCancelled ? (isPartOfSeries ? Properties.Resources.SuggestionSeriesCancelledIcon : Properties.Resources.SuggestionCancelledIcon)
                        : GetIcon(ScheduleType.Suggestion, isPartOfSeries);
                break;

            default:
                icon = Properties.Resources.TransparentIcon;
                break;
            }
        }
Esempio n. 16
0
        public override ISchedule CreateSchedule(ScheduleType scheduleType, string name, IDictionary<string, object> parameters)
        {
            switch (scheduleType)
            {
                case ScheduleType.Periodic:
                    var triggerSettings = new PeriodicScheduleParameters(parameters);
                    var trigger = new SimpleTriggerImpl
                    {
                        Name = name,
                        RepeatCount = triggerSettings.RepeatCount, 
                        StartTimeUtc = triggerSettings.Start, 
                        RepeatInterval = triggerSettings.Interval
                    };
                    return new TriggerWrapper(trigger, scheduleType);
                
                case ScheduleType.CronBased:
                    var triggerSettingsCron = new CronScheduleParameters(parameters);
                    var triggerCron = new CronTriggerImpl
                    {
                        Name = name,
                        CronExpressionString = triggerSettingsCron.CronString
                    };
                    return new TriggerWrapper(triggerCron, scheduleType);

                default:
                    throw new Exception("Unsupported schedule type " + scheduleType.ToString());
            }
        }
Esempio n. 17
0
 public Schedule(string name, DateTime startTime, ScheduleType type)
 {
     StartTime = startTime;
     m_nextTime = startTime;
     m_type = type;
     m_name = name;
 }
Esempio n. 18
0
        public static void GetIconAndToolTip(ScheduleType scheduleType, UpcomingCancellationReason cancellationReason,
            bool isPartOfSeries, UpcomingOrActiveProgramsList upcomingRecordings, UpcomingRecording upcomingRecording,
            out Icon icon, out string toolTip)
        {
            toolTip = null;
            bool isCancelled = (cancellationReason != UpcomingCancellationReason.None);
            switch (scheduleType)
            {
                case ScheduleType.Recording:
                    GetRecordingIconAndToolTip(upcomingRecordings, cancellationReason, isPartOfSeries, upcomingRecording,
                        out icon, out toolTip);
                    break;

                case ScheduleType.Alert:
                    icon = isCancelled ? (isPartOfSeries ? Properties.Resources.AlertSeriesCancelledIcon : Properties.Resources.AlertCancelledIcon)
                        : GetIcon(ScheduleType.Alert, isPartOfSeries);
                    break;

                case ScheduleType.Suggestion:
                    icon = isCancelled ? (isPartOfSeries ? Properties.Resources.SuggestionSeriesCancelledIcon : Properties.Resources.SuggestionCancelledIcon)
                        : GetIcon(ScheduleType.Suggestion, isPartOfSeries);
                    break;

                default:
                    icon = Properties.Resources.TransparentIcon;
                    break;
            }
        }
        /// <summary>
        /// Updates the first schedule of specified type with a new value and name.
        /// </summary>
        private void _UpdateSchedule(ScheduleType scheduleTypeToUpdate, Schedule newValue, string newName)
        {
            // get all schedules
            Project project = App.Current.Project;
            IDataObjectCollection <Schedule> schedules = project.Schedules.Search(newValue.PlannedDate.Value, false);

            // and try to find schedule of specified type.
            Schedule oldSchedule = null;

            foreach (Schedule schedule in schedules)
            {
                if (schedule.Type == scheduleTypeToUpdate)
                {
                    oldSchedule = schedule;
                    break;
                }
            }

            // delete old schedule if present
            if (oldSchedule != null)
            {
                project.Schedules.Remove(oldSchedule);
            }

            // create new schedule and add it to the project
            Schedule updatedSchedule = (Schedule)newValue.Clone();

            updatedSchedule.Type = scheduleTypeToUpdate;
            updatedSchedule.Name = newName;

            project.Schedules.Add(updatedSchedule);
        }
Esempio n. 20
0
 private void AddAllUpcomingProgramsForType(ScheduleType type, UpcomingGuideProgram[] upcomingGuidePrograms)
 {
     foreach (UpcomingGuideProgram upcomingGuideProgram in upcomingGuidePrograms)
     {
         this[upcomingGuideProgram.GetUniqueUpcomingProgramId()] = new GuideUpcomingProgram(type, upcomingGuideProgram);
     }
 }
Esempio n. 21
0
        public JobInstance CreateJobInstance(string queueName, ScheduleType scheduleType)
        {
            JobInstance job = new JobInstance(Context);

            job.Name = GenerateJobID();
            // TODO: delete if works job.JobDefinitionReference.Name = GetFullyQualifiedName();
            job.JobDefinition        = this;
            job.ParentReference.Name = queueName;
            job.WorkflowTypeName     = this.workflowTypeName;
            job.JobExecutionStatus   = Jhu.Graywulf.Registry.JobExecutionState.Scheduled;
            job.ScheduleType         = scheduleType;

            // Create workflow parameters
            var rh = JobReflectionHelper.CreateInstance(this.workflowTypeName);

            foreach (JobDefinitionParameter par in rh.GetParameters().Values)
            {
                job.Parameters.Add(par.Name, new JobInstanceParameter()
                {
                    Name      = par.Name,
                    Direction = par.Direction,
                });
            }

            return(job);
        }
        /// <summary>
        /// Creates a new task schedule instance.
        /// </summary>
        /// <param name="task">The task.</param>
        /// <param name="type">The schedule type.</param>
        /// <param name="startTime">The start time.</param>
        public CrawlerSchedule(CrawlerTask task, ScheduleType type, DateTime startTime)
        {
            // The identifier.
            this.Id = Guid.NewGuid();

            // The task.
            this.task = task;

            // The schedule type.
            this.type = type;

            // The start time.
            this.startTime = startTime;
            this.useUniversalStartTime = false;

            // Task enabled.
            this.enabled = true;

            // Settings.
            this.delayEnabled = false;
            this.delayMaximumInterval = TimeSpan.FromHours(1.0);
            this.repeatEnabled = false;
            this.repeatInterval = TimeSpan.FromHours(1.0);
            this.repeatDuration = TimeSpan.FromDays(1.0);
            this.stopAfterRepeatEnabled = false;
            this.stopEnabled = false;
            this.stopInterval = TimeSpan.FromDays(3.0);
            this.expiresEnabled = false;
            this.expiresTime = startTime.AddYears(1);

            // Create the triggers.
        }
Esempio n. 23
0
        /// <summary>
        /// This coroutine will wait for amountToWait before finishing
        /// </summary>
        /// <param name="scheduleType"></param>
        /// <param name="amountToWait"></param>
        /// <returns></returns>
        private static IEnumerator WaiterCoroutine(ScheduleType scheduleType, int amountToWait)
        {
            switch (scheduleType)
            {
            case ScheduleType.WaitForSeconds:
                int count = 0;
                while (amountToWait >= count)
                {
                    if (AppDomain.CurrentDomain == null)
                    {
                        break;
                    }

                    yield return(new WaitForSecondsRealtime(1));

                    count++;
                }

                break;

            case ScheduleType.WaitForFrames:
                count = 0;
                while (amountToWait >= count)
                {
                    yield return(new WaitForEndOfFrame());

                    count++;
                }
                break;
            }
        }
 protected ScheduleType(ScheduleType a, ScheduleType b)
 {
     foreach (var kvp in a.Types.Union(b.Types))
     {
         Types[kvp.Key] = kvp.Value;
     }
 }
Esempio n. 25
0
 public SchedulerJob(ISchedulerJob job, DateTime next, ScheduleType type, bool async)
 {
     Job             = job;
     NextExecuteDate = next;
     Async           = async;
     ScheduleType    = type;
 }
Esempio n. 26
0
 public async Task <ScheduleRun> GetSchedule(ScheduleType scheduleType)
 {
     using (var request = new HttpRequestMessage(HttpMethod.Get, $"/api/v1/schedule/runnow?scheduleType={(int)scheduleType}"))
     {
         return(await GetAsync <ScheduleRun>(request));
     }
 }
Esempio n. 27
0
        public void ScheduleChunkUpdate(ChunkCoordinates position, ScheduleType type, bool prioritize = false)
        {
            if (Chunks.TryGetValue(position, out IChunkColumn chunk))
            {
                var currentSchedule = chunk.Scheduled;
                if (prioritize)
                {
                    chunk.Scheduled = type;

                    if (!Enqueued.Contains(position) && Enqueued.TryAdd(position))
                    {
                        HighestPriority.Enqueue(position);
                    }

                    return;
                }


                if (currentSchedule != ScheduleType.Unscheduled)
                {
                    return;
                }

                if (!_workItems.ContainsKey(position) &&
                    !Enqueued.Contains(position) && Enqueued.TryAdd(position))
                {
                    chunk.Scheduled = type;

                    Interlocked.Increment(ref _chunkUpdates);
                }
            }
        }
Esempio n. 28
0
 private void DailyInitOnce(ref Time?occursOnce, ref ScheduleType type,
                            Time?occursOnceAt, bool enabled, string description)
 {
     Init(enabled, description);
     occursOnce = occursOnceAt;
     type       = ScheduleType.Once;
 }
            public void ThreeComponentLambda(ScheduleType scheduleType)
            {
                switch (scheduleType)
                {
                case ScheduleType.Run:
                    Entities.ForEach((Entity entity, ref EcsTestFloatData d1, ref EcsTestFloatData2 d2, ref EcsTestFloatData3 d3) =>
                    {
                        d1.Value++;
                        d2.Value0++;
                        d3.Value0++;
                    }).Run();
                    break;

                case ScheduleType.Schedule:
                    Entities.ForEach((Entity entity, ref EcsTestFloatData d1, ref EcsTestFloatData2 d2, ref EcsTestFloatData3 d3) =>
                    {
                        d1.Value++;
                        d2.Value0++;
                        d3.Value0++;
                    }).Schedule();
                    CompleteDependency();
                    break;

                case ScheduleType.ScheduleParallel:
                    Entities.ForEach((Entity entity, ref EcsTestFloatData d1, ref EcsTestFloatData2 d2, ref EcsTestFloatData3 d3) =>
                    {
                        d1.Value++;
                        d2.Value0++;
                        d3.Value0++;
                    }).ScheduleParallel();
                    CompleteDependency();
                    break;
                }
            }
Esempio n. 30
0
        private void DailyInitRecurring(ref int schInterval, ref DailyIntervalUnit schIntervalUnit, ref Time?schStartAt,
                                        ref Time?schEndAt, ref ScheduleType schType, ref TimeSpan spanStart, ref TimeSpan spanEnd,
                                        DailyIntervalUnit intervalUnit, int interval, Time?startAt, Time?endAt,
                                        bool enabled, string description)
        {
            if (startAt.HasValue && endAt.HasValue)
            {
                if (startAt.Value >= endAt.Value)
                {
                    throw new ArgumentException("Argument endAt must be greater than argument startAt.");
                }
            }

            if (interval <= 0)
            {
                throw new ArgumentException("Argument interval must be greater than 0.");
            }

            Init(enabled, description);

            schInterval     = interval;
            schIntervalUnit = intervalUnit;
            schStartAt      = startAt;
            schEndAt        = endAt;
            schType         = ScheduleType.Recurring;

            spanStart = GetTimeSpan(startAt, 0, 0, 0);
            spanEnd   = GetTimeSpan(endAt, 23, 59, 59);
        }
            public void SetComponent_SetsValue(Entity entity, ScheduleType scheduleType)
            {
                switch (scheduleType)
                {
                case ScheduleType.Run:
                    Entities.ForEach((ref EcsTestDataEntity tde) => { SetComponent(entity, new EcsTestData()
                        {
                            value = 2
                        }); }).Run();
                    break;

                case ScheduleType.Schedule:
                    Entities.ForEach((ref EcsTestDataEntity tde) => { SetComponent(entity, new EcsTestData()
                        {
                            value = 2
                        }); }).Schedule();
                    break;

                case ScheduleType.ScheduleParallel:
                    Entities.ForEach((ref EcsTestDataEntity tde) => { SetComponent(entity, new EcsTestData()
                        {
                            value = 2
                        }); }).ScheduleParallel();
                    break;
                }

                Dependency.Complete();
            }
Esempio n. 32
0
        public void ScheduleChunkUpdate(ChunkCoordinates position, ScheduleType type, bool prioritize = false)
        {
            var queue = UpdateQueue;

            if (Chunks.TryGetValue(position, out var cc))
            {
                if ((type & ScheduleType.Lighting) != 0)
                {
                    //cc.SkyLightDirty = true;
                }

                if ((type & ScheduleType.Border) != 0)
                {
                    queue = UpdateBorderQueue;
                }

                if (prioritize)
                {
                    queue = FastUpdateQueue;
                }

                if (queue.Contains(position))
                {
                    return;
                }

                cc.ScheduleBorder();

                //Scheduled.Add(position);
                queue.Enqueue(position);
            }
        }
Esempio n. 33
0
        public async Task <ActionResult <ScheduleType> > PostType(ScheduleType scheduleType)
        {
            _context.ScheduleType.Add(scheduleType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetType", new { id = scheduleType.ScheduleTypeID }, scheduleType));
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is OrderFulfillmentPickupDetails other &&
                   ((Recipient == null && other.Recipient == null) || (Recipient?.Equals(other.Recipient) == true)) &&
                   ((ExpiresAt == null && other.ExpiresAt == null) || (ExpiresAt?.Equals(other.ExpiresAt) == true)) &&
                   ((AutoCompleteDuration == null && other.AutoCompleteDuration == null) || (AutoCompleteDuration?.Equals(other.AutoCompleteDuration) == true)) &&
                   ((ScheduleType == null && other.ScheduleType == null) || (ScheduleType?.Equals(other.ScheduleType) == true)) &&
                   ((PickupAt == null && other.PickupAt == null) || (PickupAt?.Equals(other.PickupAt) == true)) &&
                   ((PickupWindowDuration == null && other.PickupWindowDuration == null) || (PickupWindowDuration?.Equals(other.PickupWindowDuration) == true)) &&
                   ((PrepTimeDuration == null && other.PrepTimeDuration == null) || (PrepTimeDuration?.Equals(other.PrepTimeDuration) == true)) &&
                   ((Note == null && other.Note == null) || (Note?.Equals(other.Note) == true)) &&
                   ((PlacedAt == null && other.PlacedAt == null) || (PlacedAt?.Equals(other.PlacedAt) == true)) &&
                   ((AcceptedAt == null && other.AcceptedAt == null) || (AcceptedAt?.Equals(other.AcceptedAt) == true)) &&
                   ((RejectedAt == null && other.RejectedAt == null) || (RejectedAt?.Equals(other.RejectedAt) == true)) &&
                   ((ReadyAt == null && other.ReadyAt == null) || (ReadyAt?.Equals(other.ReadyAt) == true)) &&
                   ((ExpiredAt == null && other.ExpiredAt == null) || (ExpiredAt?.Equals(other.ExpiredAt) == true)) &&
                   ((PickedUpAt == null && other.PickedUpAt == null) || (PickedUpAt?.Equals(other.PickedUpAt) == true)) &&
                   ((CanceledAt == null && other.CanceledAt == null) || (CanceledAt?.Equals(other.CanceledAt) == true)) &&
                   ((CancelReason == null && other.CancelReason == null) || (CancelReason?.Equals(other.CancelReason) == true)) &&
                   ((IsCurbsidePickup == null && other.IsCurbsidePickup == null) || (IsCurbsidePickup?.Equals(other.IsCurbsidePickup) == true)) &&
                   ((CurbsidePickupDetails == null && other.CurbsidePickupDetails == null) || (CurbsidePickupDetails?.Equals(other.CurbsidePickupDetails) == true)));
        }
Esempio n. 35
0
        public async Task <IActionResult> PutType(int id, ScheduleType scheduleType)
        {
            if (id != scheduleType.ScheduleTypeID)
            {
                return(BadRequest());
            }

            _context.Entry(scheduleType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ScheduleTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 36
0
 public ScheduleInfo(int lastResult, string stopTaskIfRunsXHoursAndXMinutes, ScheduleType scheduleType, string modifier, int interval,
                     TimeSpan startTime, DateTime startDate, TimeSpan endTime, DateTime endDate, DayOfWeek[] daysOfWeek, int[] days, Month[] months, string repeatEvery,
                     string repeatUntilTime, string repeatUntilDuration, string repeatStopIfStillRunning, bool stopAtEnd, TimeSpan delay, int idleTime, string eventChannelName)
 {
     LastResult = lastResult;
     StopTaskIfRunsXHoursandXMins = stopTaskIfRunsXHoursAndXMinutes;
     ScheduleType             = scheduleType;
     Modifier                 = modifier;
     Interval                 = interval;
     StartTime                = startTime;
     StartDate                = startDate;
     EndTime                  = endTime;
     EndDate                  = endDate;
     DaysOfWeek               = daysOfWeek;
     Days                     = days;
     Months                   = months;
     RepeatEvery              = repeatEvery;
     RepeatUntilTime          = repeatUntilTime;
     RepeatUntilDuration      = repeatUntilDuration;
     RepeatStopIfStillRunning = repeatStopIfStillRunning;
     StopAtEnd                = stopAtEnd;
     Delay                    = delay;
     IdleTime                 = idleTime;
     EventChannelName         = eventChannelName;
 }
Esempio n. 37
0
 public SchedulesPanel(ScheduleType scheduleType)
 {
     InitializeComponent();
     _iconColumn.ValuesAreIcons = true;
     _scheduleType = scheduleType;
     _schedulesDataGridView.ColumnHeadersHeight = (int)(23 * _heightFactor);
     WinFormsUtility.ResizeDataGridViewColumns(_schedulesDataGridView, _widthFactor);
 }
 public static string GetSummary(ScheduleType frequency, int day, System.DayOfWeek dayOfWeek, string weekName = "")
 {
     string str = LocalizedObjectHelper.GetLocalizedStringFrom(frequency.ToString());
     if (((frequency == ScheduleType.EveryDay) || (frequency == ScheduleType.Weekend)) || (frequency == ScheduleType.Workday))
     {
         return str;
     }
     return string.Format("{0} {1}", str, (frequency == ScheduleType.EveryMonth) ? string.Format(LocalizedObjectHelper.GetLocalizedStringFrom("FrequencyDayOfMonthFormatter"), day) : weekName);
 }
Esempio n. 39
0
 public Schedule(string schid, DateTime startTime, ScheduleType type, int duationMin, ScheduleJob[] jobs, bool IsPrimary)
 {
     StartTime = startTime;
     m_nextTime = startTime;
     m_type = type;
     m_schid = schid;
     m_durationMin = duationMin;
     this.jobs = jobs;
     this.IsPrimary = IsPrimary;
 }
        public async Task<IHttpActionResult> PostScheduleType(ScheduleType ScheduleType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            await repository.AddAsync(ScheduleType);

            return CreatedAtRoute("DefaultApi", new { id = ScheduleType.ScheduleTypeID }, ScheduleType);
        }
Esempio n. 41
0
 // Constructor
 public Schedule(string schid, DateTime startTime, ScheduleType type, ScheduleJob[] jobs, bool IsPrimary)
 {
     StartTime = startTime;
     m_nextTime = startTime;
     m_type = type;
     m_schid = schid;
     m_durationMin = 0;
     this.jobs = jobs;
     this.IsPrimary = IsPrimary;
     foreach (ScheduleJob job in jobs)
         job.setSchedule(this);
 }
Esempio n. 42
0
 private void GetScheduleNames(SchedulerServiceAgent tvSchedulerAgent, ScheduleType type)
 {
     ScheduleSummary[] schedules = tvSchedulerAgent.GetAllSchedules(ChannelType.Television, type, false);
     foreach (ScheduleSummary schedule in schedules)
     {
         _scheduleNames.Add(schedule.ScheduleId, schedule.Name);
     }
     schedules = tvSchedulerAgent.GetAllSchedules(ChannelType.Radio, type, false);
     foreach (ScheduleSummary schedule in schedules)
     {
         _scheduleNames.Add(schedule.ScheduleId, schedule.Name);
     }
 }
Esempio n. 43
0
 public static string GetLogoForSchedule(ScheduleType scheduleType, bool isOneTime, bool isActive)
 {
     string suffix = String.Empty;
     if (!isOneTime)
     {
         suffix += "Series";
     }
     if (!isActive)
     {
         suffix += "Cancelled";
     }
     return GUIGraphicsContext.Skin + @"\Media\ARGUS_" + scheduleType.ToString() + suffix + ".png";
 }
Esempio n. 44
0
        public static Icon GetIcon(ScheduleType scheduleType, bool isPartOfSeries)
        {
            switch (scheduleType)
            {
                case ScheduleType.Recording:
                    return isPartOfSeries ? Properties.Resources.RecordSeriesIcon : Properties.Resources.RecordIcon;

                case ScheduleType.Alert:
                    return isPartOfSeries ? Properties.Resources.AlertSeriesIcon : Properties.Resources.AlertIcon;

                case ScheduleType.Suggestion:
                    return isPartOfSeries ? Properties.Resources.SuggestionSeriesIcon : Properties.Resources.SuggestionIcon;
            }
            return Properties.Resources.TransparentIcon;
        }
        // PUT api/ScheduleTypes/5
        public async Task<IHttpActionResult> PutScheduleType(int id, ScheduleType ScheduleType)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != ScheduleType.ScheduleTypeID)
            {
                return BadRequest();
            }

            await repository.UpdateAsync(ScheduleType, ScheduleType.ScheduleTypeID);

            return StatusCode(HttpStatusCode.NoContent);
        }
 private async Task AddUpcomingProgramsAsync(ScheduleType scheduleType)
 {
     var schedules = await Proxies.SchedulerService.GetAllSchedules(ChannelType.Television, scheduleType);
     // EpisodeDisplayname must have S01E01 format
     var episodeDataValidRegEx = new System.Text.RegularExpressions.Regex(@"S\d\dE\d\d");
     //
     foreach (var scheduleSummary in schedules)
     {
         if (!scheduleSummary.IsActive) continue;
         //
         var schedule = await Proxies.SchedulerService.GetScheduleById(scheduleSummary.ScheduleId);
         // remove schedule filters
         var filtersToRemove = new List<ScheduleRuleType>
                 {
                     { ScheduleRuleType.EpisodeNumberEquals },
                     { ScheduleRuleType.EpisodeNumberContains },
                     { ScheduleRuleType.EpisodeNumberDoesNotContain },
                     { ScheduleRuleType.EpisodeNumberStartsWith },
                     { ScheduleRuleType.NewEpisodesOnly },
                     { ScheduleRuleType.NewTitlesOnly },
                     { ScheduleRuleType.SkipRepeats }
                  };
         schedule.Rules.RemoveAll(x => filtersToRemove.Contains(x.Type));
         //
         foreach (var program in await Proxies.SchedulerService.GetUpcomingPrograms(schedule, true))
         {
             var guideProgram = new GuideEnricherProgram(await Proxies.GuideService.GetProgramById(program.GuideProgramId.Value));
             // skip already enriched entries
             if (episodeDataValidRegEx.IsMatch(guideProgram.EpisodeNumberDisplay)) continue;
             //
             if (!this.seriesToEnrich.ContainsKey(guideProgram.Title))
             {
                 this.seriesToEnrich.Add(guideProgram.Title, new GuideEnricherSeries(guideProgram.Title, config.UpdateMatchedEpisodes, config.UpdateSubtitlesParameter, config.UpdateDescription));
             }
             this.seriesToEnrich[guideProgram.Title].AddProgram(guideProgram);
         }
     }
 }
Esempio n. 47
0
            public ScheduledEvent(string __EventID, Action __Target, DateTime __FireOn, TimeSpan __Interval, bool AutoStart = true)
            {
                this.EventID = __EventID;
                this._Target = __Target;
                this._Start = __FireOn;
                this._Interval = __Interval;
                this._Type = ScheduleType.Interval;

                if (AutoStart)
                    this.Go();
                else
                    this._Enabled = false;
            }
        private void Onrecord(ScheduleType scheduleType)
        {
            Schedule schedule = null;
            if (_upcomingProgram != null)
            {
                schedule = SchedulerAgent.GetScheduleById(_upcomingProgram.ScheduleId);
            }
            if (_upcomingProgram != null && schedule != null
                && schedule.ScheduleType == scheduleType)//delete schedule
            {
                if (_upcomingProgram.IsCancelled)
                {
                    SchedulerAgent.UncancelUpcomingProgram(_upcomingProgram.ScheduleId, _upcomingProgram.GuideProgramId, _upcomingProgram.Channel.ChannelId, _upcomingProgram.StartTime);
                    try
                    {
                        //refresh _upcomingProgram
                        _upcomingProgram = SchedulerAgent.GetUpcomingPrograms(schedule, true)[0];
                    }
                    catch { }
                }
                else
                {
                    if (_upcomingProgram.IsPartOfSeries)
                    {
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DeleteEntireSchedule));
                            dlgYesNo.SetLine(1, "\"" + schedule.Name + "\"");
                            dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure));
                            dlgYesNo.SetLine(3, String.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
                            if (dlgYesNo.IsConfirmed)
                            {
                                SchedulerAgent.DeleteSchedule(schedule.ScheduleId);
                                _upcomingProgram = null;
                            }
                        }
                    }
                    else
                    {
                        SchedulerAgent.DeleteSchedule(_upcomingProgram.ScheduleId);
                        _upcomingProgram = null;
                    }
                }
            }
            else//create new schedule
            {
                TimeSpan duration = new TimeSpan(Int32.Parse(_spinHoursDuration.GetLabel()), Int32.Parse(_spinMinutesDuration.GetLabel()), 0);
                DateTime startTime = new DateTime(Int32.Parse(_spinStartYear.GetLabel()), Int32.Parse(_spinStartMonth.GetLabel()), Int32.Parse(_spinStartDay.GetLabel()), Int32.Parse(_spinStartHour.GetLabel()), Int32.Parse(_spinStartMinute.GetLabel()), 0);
                ScheduleDaysOfWeek daysOfWeek = new ScheduleDaysOfWeek();

                //TODO: What if we have multiple channels with the same name
                Channel channel = SchedulerAgent.GetChannelByDisplayName(_channelType, _spinChannel.GetLabel());

                Schedule newSchedule = null;
                newSchedule = SchedulerAgent.CreateNewSchedule(_channelType, scheduleType);
                newSchedule.Rules.Add(ScheduleRuleType.Channels, channel.ChannelId);
                newSchedule.Rules.Add(ScheduleRuleType.ManualSchedule, startTime, new ScheduleTime(duration));
                if (!_recordOnce)
                {
                    string days = " ";
                    if (_mondayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Mondays;
                        days += Utility.GetLocalizedText(TextId.Mon) + ",";
                    }
                    if (_tuesdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Tuesdays;
                        days += Utility.GetLocalizedText(TextId.Tue) + ",";
                    }
                    if (_wednesdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Wednesdays;
                        days += Utility.GetLocalizedText(TextId.Wed) + ",";
                    }
                    if (_thursdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Thursdays;
                        days += Utility.GetLocalizedText(TextId.Thu) + ",";
                    }
                    if (_fridayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Fridays;
                        days += Utility.GetLocalizedText(TextId.Fri) + ",";
                    }
                    if (_saturdayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Saturdays;
                        days += Utility.GetLocalizedText(TextId.Sat) + ",";
                    }
                    if (_sundayButton.Selected)
                    {
                        daysOfWeek = daysOfWeek | ScheduleDaysOfWeek.Sundays;
                        days += Utility.GetLocalizedText(TextId.Sun) + ",";
                    }
                    days = days.Remove(days.Length - 1);
                    newSchedule.Rules.Add(ScheduleRuleType.DaysOfWeek, daysOfWeek);
                    newSchedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1} {2:t}-{3:t}", channel.DisplayName, days, startTime, startTime.Add(duration));
                }
                else
                {
                    newSchedule.Name = String.Format(CultureInfo.CurrentCulture, "{0} {1:g}-{2:t}", channel.DisplayName, startTime, startTime.Add(duration));
                }

                //TODO: try to prevent dublicate manual schedules
                //and find a better way to get the newly created "_schedule" and  "_upcomingProgram"
                if (newSchedule != null)
                {
                    newSchedule.ScheduleType = scheduleType;
                    SchedulerAgent.SaveSchedule(newSchedule);

                    bool found = false;
                    UpcomingProgram[] _programs = SchedulerAgent.GetAllUpcomingPrograms(scheduleType, true);
                    foreach (UpcomingProgram _prog in _programs)
                    {
                        if (_prog.Channel.ChannelId == channel.ChannelId
                        && _prog.Duration == duration
                        && !found)
                        {
                            Schedule _schedule = SchedulerAgent.GetScheduleById(_prog.ScheduleId);
                            if (_schedule.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule) != null)
                            {
                                if (_schedule.Name == newSchedule.Name)
                                {
                                    if (_recordOnce
                                        && _prog.StartTime == startTime)
                                    {
                                        _upcomingProgram = _prog;
                                        found = true;
                                    }
                                    else if (!_recordOnce && _schedule.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek) != null
                                        && _schedule.Rules.FindRuleByType(ScheduleRuleType.DaysOfWeek).Arguments[0].ToString() == daysOfWeek.ToString()
                                        && Convert.ToDateTime(_schedule.Rules.FindRuleByType(ScheduleRuleType.ManualSchedule).Arguments[0]) == startTime)
                                    {
                                        _upcomingProgram = _prog;
                                        found = true;
                                    }
                                    Update(_schedule);
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                    {
                        GUIWindowManager.ShowPreviousWindow();
                    }
                }
            }
        }
Esempio n. 49
0
            public ScheduledEvent(Action __Target, TimeSpan __Interval, bool AutoStart = true)
            {
                this._Target = __Target;
                this._Start = GameClient.DateTimeNow + __Interval;
                this._Interval = __Interval;
                this._Type = ScheduleType.Interval;

                if (AutoStart)
                    this.Go();
                else
                    this._Enabled = false;
            }
Esempio n. 50
0
 private Schedule(ScheduleType type)
 {
     this.Type = type;
 }
Esempio n. 51
0
        public JobInstance CreateJobInstance(string queueName, ScheduleType scheduleType)
        {
            JobInstance job = new JobInstance(Context);

            job.Name = GenerateJobID();
            job.JobDefinitionReference.Name = GetFullyQualifiedName();
            job.ParentReference.Name = queueName;
            job.WorkflowTypeName = this.workflowTypeName;
            job.JobExecutionStatus = Jhu.Graywulf.Registry.JobExecutionState.Scheduled;
            job.ScheduleType = scheduleType;

            // Create workflow parameters
            var rh = JobReflectionHelper.CreateInstance(this.workflowTypeName);
            foreach (var par in rh.GetParameters().Values)
            {
                job.Parameters.Add(par.Name, new JobParameter(par));
            }

            return job;
        }
Esempio n. 52
0
        private ISchedule GetSchedule(ScheduleType type)
        {
            for(int i = 0; i < scheduleList.Count; i++) {
                if(scheduleList[i].Type == type) {
                    return scheduleList[i];
                }
            }

            return null;
        }
Esempio n. 53
0
        private IMBotMessage DoShowUpcomingCommand(IMBotConversation conversation, ScheduleType type)
        {
            if (type == ScheduleType.Recording)
            {
                using (ControlServiceAgent tvControlAgent = new ControlServiceAgent())
                {
                    UpcomingRecording[] upcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.Recordings, false);

                    StringBuilder replyText = new StringBuilder();

                    if (upcomingRecordings.Length > 0)
                    {
                        int index = 0;
                        foreach (UpcomingRecording upcomingRecording in upcomingRecordings)
                        {
                            if (replyText.Length > 0)
                            {
                                replyText.AppendLine();
                            }

                            PluginService pluginService = null;
                            if (upcomingRecording.CardChannelAllocation != null)
                            {
                                pluginService =
                                    RecorderTunersCache.GetRecorderTunerById(upcomingRecording.CardChannelAllocation.RecorderTunerId);
                            }

                            replyText.AppendFormat("{0,3}» ", ++index);
                            Utility.AppendProgramDetails(replyText, upcomingRecording.Program.Channel, upcomingRecording.Program);
                            replyText.AppendFormat(" [{0}]", pluginService == null ? "-" : pluginService.Name);
                        }

                        conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingRecordings);

                        return new IMBotMessage(replyText.ToString(), true)
                        {
                            Footer = "Use 'cancel', 'uncancel' or 'delete schedule' with <number>."
                        };
                    }
                }
            }
            else
            {
                using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                {
                    UpcomingProgram[] upcomingPrograms = tvSchedulerAgent.GetAllUpcomingPrograms(type, false);

                    StringBuilder replyText = new StringBuilder();

                    if (upcomingPrograms.Length > 0)
                    {
                        int index = 0;
                        foreach (UpcomingProgram upcomingProgram in upcomingPrograms)
                        {
                            if (replyText.Length > 0)
                            {
                                replyText.AppendLine();
                            }
                            replyText.AppendFormat("{0,3}» ", ++index);
                            Utility.AppendProgramDetails(replyText, upcomingProgram.Channel, upcomingProgram);
                        }

                        conversation.Session[SessionKey.Programs] = new Session.Programs(upcomingPrograms);

                        return new IMBotMessage(replyText.ToString(), true)
                        {
                            Footer = "Use 'record', 'cancel', 'uncancel' or 'delete schedule' with <number>."
                        };
                    }
                }
            }
            return new IMBotMessage("There are no upcoming " + type.ToString().ToLowerInvariant() + "s.");
        }
Esempio n. 54
0
        /// <summary>
        /// Initializes member variables to their initial values.
        /// </summary>
        /// <remarks>
        /// This function is called by the contructors.
        /// </remarks>
        private void InitializeMembers()
        {
            base.EntityType = EntityType.JobInstance;
            base.EntityGroup = EntityGroup.Jobs;

            this.workflowTypeName = string.Empty;
            this.dateStarted = DateTime.MinValue;
            this.dateFinished = DateTime.MinValue;
            this.jobExecutionStatus = JobExecutionState.Unknown;
            this.suspendTimeout = DateTime.MinValue;
            this.scheduleType = ScheduleType.Unknown;
            this.scheduleTime = DateTime.MinValue;
            this.recurringPeriod = RecurringPeriod.Unknown;
            this.recurringInterval = 0;
            this.recurringMask = 0;
            this.workflowInstanceId = Guid.Empty;
            this.adminRequestTime = DateTime.MinValue;
            this.adminRequestData = null;
            this.adminRequestResult = -1;
            this.exceptionMessage = null;

            this.parameters = new Dictionary<string, JobParameter>();
            this.checkpoints = new List<JobCheckpoint>();
        }
Esempio n. 55
0
        public FrmAppointment(SchedulerControl control, Appointment apt, bool openRecurrenceForm, ScheduleType schedType, List<CTBookingSchedule> listMeetingSchedules)
        {
            this.openRecurrenceForm = openRecurrenceForm;
            this.controller = new BVAppointmentFormController(control, apt);
            this.appointmentForm = apt;
            this.control = control;
            this.BookingType = schedType;
            this.ListMeetingSchedules = listMeetingSchedules;
            SuspendUpdate();
            InitializeComponent();
            this.KeyPreview = true;
            btnRecurrence.Enabled = false;
            if (this.controller.IsNewAppointment) {
                btnDelete.Enabled = false;
            } else {
                bool isReadonly = false;
                if (this.control.Tag != null && this.control.Tag.ToString() == "ReadOnly")
                    isReadonly = true;
                //if in editing mode, do this for sales consultant only
                //don't allow delete or edit if webinar and seminar. allow for meeting only

                if (controller.ScheduleType == 2 || controller.ScheduleType == 1) {
                    DisableControls();
                } else if (controller.ScheduleType == 3) {
                    if (ListMeetingSchedules != null) {
                        schedule dbApt = (schedule)apt.GetSourceObject(control.Storage);
                        if (dbApt != null) {
                            var meeting = listMeetingSchedules.FirstOrDefault(x => x.id == dbApt.id);
                            if (meeting == null || isReadonly) {
                                DisableControls();
                            }
                        }
                    }
                }
            }
            ResumeUpdate();
            UpdateForm();
        }
Esempio n. 56
0
        /// <summary>
        /// Creates a deep copy of the passed object.
        /// </summary>
        /// <param name="old">A <b>Database Definition</b> object to create the deep copy from.</param>
        private void CopyMembers(JobInstance old)
        {
            this.workflowTypeName = old.workflowTypeName;
            this.dateStarted = old.dateStarted;
            this.dateFinished = old.dateFinished;
            this.jobExecutionStatus = old.jobExecutionStatus;
            this.suspendTimeout = old.suspendTimeout;
            this.scheduleType = old.scheduleType;
            this.scheduleTime = old.scheduleTime;
            this.recurringPeriod = old.recurringPeriod;
            this.recurringInterval = old.recurringInterval;
            this.recurringMask = old.recurringMask;
            this.workflowInstanceId = old.workflowInstanceId;
            this.adminRequestTime = old.adminRequestTime;
            this.adminRequestData = old.adminRequestData == null ? null : new JobAdminRequestData(old.adminRequestData);
            this.adminRequestResult = old.adminRequestResult;
            this.exceptionMessage = old.exceptionMessage;

            // TODO: do deep copy here?
            this.parameters = new Dictionary<string, JobParameter>(old.parameters);
            this.checkpoints = new List<JobCheckpoint>(old.checkpoints);
        }
Esempio n. 57
0
 private SerializableDictionary<Guid, GuideUpcomingProgram> BuildUpcomingProgramsDictionary(ScheduleType scheduleType)
 {
     SerializableDictionary<Guid, GuideUpcomingProgram> result = new SerializableDictionary<Guid, GuideUpcomingProgram>();
     foreach (GuideUpcomingProgram upcomingProgram in _model.UpcomingProgramsByType[scheduleType])
     {
         if (!result.ContainsKey(upcomingProgram.UpcomingProgramId))
         {
             result.Add(upcomingProgram.UpcomingProgramId, upcomingProgram);
         }
     }
     return result;
 }
Esempio n. 58
0
 private List<GuideUpcomingProgram> GetGuideUpcomingPrograms(ScheduleType type)
 {
     var upcomingPrograms = Proxies.SchedulerService.GetUpcomingGuidePrograms(type, true).Result;
     List<GuideUpcomingProgram> result = new List<GuideUpcomingProgram>();
     foreach (UpcomingGuideProgram upcomingProgram in upcomingPrograms)
     {
         result.Add(new GuideUpcomingProgram(type, upcomingProgram));
     }
     return result;
 }
Esempio n. 59
0
 /// <summary>
 /// "Record" via REC button
 /// </summary>
 private void OnRecordOrAlert(ScheduleType scheduleType)
 {
     Channel channel = _currentChannel;
     if (_singleChannelView)
     {
         channel = _channelList[_singleChannelNumber].channel;
     }
     if (channel != null
         && _currentProgram != null)
     {
         if (TvProgramInfo.RecordProgram(channel, _currentProgram, scheduleType, true))
         {
             LoadSchedules(true);
             UpdateCurrentProgram(true);
             UnFocus();
             Update(false);
             SetFocus();
         }
     }
 }
Esempio n. 60
0
 private void SetTaskSchedule(ScheduleType type)
 {
     switch(type) {
         case ScheduleType.OneTime: {
             _task.Schedule = GetSchedule(ScheduleType.OneTime);
             OneTimeScheduleEditor editor = new OneTimeScheduleEditor();
             editor.Schedule = (OneTimeSchedule)_task.Schedule;
             HostScheduleControl(editor);
             break;
         }
         case ScheduleType.Daily: {
             _task.Schedule = GetSchedule(ScheduleType.Daily);
             DailyScheduleEditor editor = new DailyScheduleEditor();
             editor.Schedule = (DailySchedule)_task.Schedule;
             HostScheduleControl(editor);
             break;
         }
         case ScheduleType.Weekly: {
             _task.Schedule = GetSchedule(ScheduleType.Weekly);
             WeeklyScheduleEditor editor = new WeeklyScheduleEditor();
             editor.Schedule = (WeeklySchedule)_task.Schedule;
             HostScheduleControl(editor);
             break;
         }
         case ScheduleType.Monthly: {
             _task.Schedule = GetSchedule(ScheduleType.Monthly);
             MonthlyScheduleEditor editor = new MonthlyScheduleEditor();
             editor.Schedule = (MonthlySchedule)_task.Schedule;
             HostScheduleControl(editor);
             break;
         }
     }
 }