Esempio n. 1
0
        public override void CalcSchedules()
        {
            Schedules.Clear();

            Schedules.Add(Device.StartTime);
            var nextTime = Device.StartTime.AddMinutes(GetFirstSpan());

            //如下一次开始时间 < endtime,且够一个周期的时间
            if (nextTime.AddMinutes(Device.Period * (int)Device.TimeType) <= Device.EndTime)
            {
                Schedules.Add(nextTime);

                while (true)
                {
                    nextTime = nextTime.AddMinutes(Device.Period * (int)Device.TimeType);
                    if (nextTime.AddMinutes(Device.Period * (int)Device.TimeType) > Device.EndTime)
                    {
                        break;
                    }
                    Schedules.Add(nextTime);
                }
            }

            LogFactory.Create().Info($"DEVICE{Device.DeviceId} CalcSchedules ==>{Schedules.Count}, first{Schedules.FirstOrDefault():yyyy-MM-dd HH:mm:ss}, last{Schedules.LastOrDefault():yyyy-MM-dd HH:mm:ss}");
        }
Esempio n. 2
0
        public void Start()
        {
            IsReady = false;

            try
            {
                _runbookNameCache.Clear();

                Runbooks.Clear();
                Credentials.Clear();
                Schedules.Clear();
                Variables.Clear();
                Modules.Clear();
                Connections.Clear();
                Tags.Clear();

                Service.Load();

                foreach (var rb in Runbooks)
                {
                    _runbookNameCache.Add((rb.Tag as RunbookModelProxy).RunbookName);
                }

                Execute.OnUIThread(() => _statusManager.SetText(""));
            }
            catch (NotSupportedException)
            {
                // Ignore for now...
            }
        }
Esempio n. 3
0
        async Task SyncSchedules()
        {
            if (!IsBusy)
            {
                Exception Error = null;

                Schedules.Clear();
                try
                {
                    IsBusy = true;
                    var Repository = new Repository();
                    var Items      = await Repository.GetSchedule();

                    foreach (var Service in Items)
                    {
                        Schedules.Add(Service);
                    }
                }
                catch (Exception ex)
                {
                    Error = ex;
                }
                finally
                {
                    IsBusy = false;
                }
                if (Error != null)
                {
                    await _pageDialogService.DisplayAlertAsync("Erro", Error.Message, "OK");
                }
                return;
            }
        }
 private void GetSchedules()
 {
     Schedules.Clear();
     foreach (var item in _dataService.GetSchedules())
     {
         Schedules.Add(item);
     }
 }
Esempio n. 5
0
 public void Reset()
 {
     BatchFiles.Clear();
     Status = " ";
     Schedules.Clear();
     fields.Clear();
     ConObj.Clear();
 }
 private void LoadSchedules(List <Schedule> medicalCenterSchedules)
 {
     Schedules.Clear();
     dialogService.ShowProgress();
     foreach (Schedule schedule in medicalCenterSchedules)
     {
         ScheduleViewModel scheduleViewModel = new ScheduleViewModel();
         ViewModelHelper.SetScheduleToScheduleViewModel(scheduleViewModel, schedule);
         Schedules.Add(scheduleViewModel);
     }
     dialogService.HideProgress();
 }
        public override async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            if (!IsRefreshing)
            {
                IsBusy = true;
            }

            try
            {
                if (!Users.Any())
                {
                    var lookups = await DataService.GetLookups(1000);

                    lookups.Users.ForEach(u => Users.Add(u));
                }

                ScheduleDateFormatted = ScheduleDate.ToShortDateString();
                OnPropertyChanged("ScheduleDateFormatted");

                Schedules.Clear();
                var items = await DataService.GetItemsAsync <Schedule>($"schedules?start={ScheduleDate.ToString("MM-dd-yyyy")}&end={ScheduleDate.ToString("MM-dd-yyyy")}{(CanManageSchedule ? "" : "&assigned=true")}");

                NoSchedules = !items.Data.Any();
                OnPropertyChanged("NoSchedules");
                this.WeekUnpublished = false;
                foreach (var item in items.Data.OrderBy(d => d.User == null ? "zzzzzz" : d.User.FirstName))
                {
                    if (item.UserId != null && !item.PublishedValue)
                    {
                        this.WeekUnpublished = true;
                    }
                    var displayItem = new DisplayItem();
                    scheduleToDisplayItem(displayItem, item);
                    Schedules.Add(displayItem);
                }
            }
            catch (Exception ex)
            {
                IsBusy       = false;
                IsRefreshing = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy       = false;
                IsRefreshing = false;
            }
        }
Esempio n. 8
0
        private async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            if (!IsRefreshing)
            {
                IsBusy = true;
            }

            try
            {
                //StartDateFormatted = StartDate.ToShortDateString();
                //OnPropertyChanged("StartDateFormatted");

                Schedules.Clear();
                var items = await DataService.GetItemsAsync <Schedule>($"schedules?start={StartDate.ToString("MM-dd-yyyy")}&end={StartDate.AddDays(6).ToString("MM-dd-yyyy")}&forUser=true");

                NoSchedules = !items.Data.Any();
                OnPropertyChanged("NoSchedules");
                foreach (var item in items.Data.OrderBy(d => d.ScheduleDate.GetValueOrDefault()).ThenBy(s => s.StartTime.GetValueOrDefault().TimeOfDay))
                {
                    Schedules.Add(new DisplayItem()
                    {
                        Line1 = $"{item.ScheduleDateValue.DayOfWeek} - {item.ScheduleDateValue.ToShortDateString()}",
                        Line2 = $"{item.StartTimeTimezonedValue.ToShortTimeString()} - {item.EndTimeTimezonedValue.ToShortTimeString()}",
                        Line3 = $"{item.Shift.ShiftName} - {item.Task.TaskName}" +
                                (item.ScheduleTrades.Any(t => t.TradeStatusValue < (int)TRADE_STATUS.APPROVED) ? " *" : ""),
                        Tag  = item,
                        Tag2 = string.IsNullOrEmpty(item.Task.TextColor) ? Color.LightGray : Color.FromHex(item.Task.TextColor),
                    });
                }
            }
            catch (Exception ex)
            {
                IsBusy       = false;
                IsRefreshing = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy       = false;
                IsRefreshing = false;
            }
        }
        private async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsRefreshing = false;
            IsBusy       = true;

            try
            {
                StartDateFormatted = StartDate.ToShortDateString();
                OnPropertyChanged("StartDateFormatted");

                var user = AuthService.UserToken.User;
                Schedules.Clear();
                var items = await DataService.GetItemsAsync <ScheduleTrade>($"scheduleTrades?start={StartDate.ToString("MM-dd-yyyy")}&end={StartDate.AddDays(6).ToString("MM-dd-yyyy")}&status=0");

                NoTrades = !items.Data.Any();
                OnPropertyChanged("NoTrades");
                foreach (var item in items.Data.Where(d => d.Schedule.UserIdValue != user.UserIdValue).OrderBy(d => d.Schedule.ScheduleDate.GetValueOrDefault()).ThenBy(s => s.Schedule.StartTime.GetValueOrDefault().TimeOfDay))
                {
                    var sched = item.Schedule;
                    Schedules.Add(new DisplayItem()
                    {
                        Line1 = $"{sched.ScheduleDateValue.DayOfWeek} - {sched.ScheduleDateValue.ToShortDateString()}",
                        Line2 = $"{sched.StartTimeTimezonedValue.ToShortTimeString()} - {sched.EndTimeTimezonedValue.ToShortTimeString()}",
                        Line3 = $"{sched.Shift.ShiftName} - {sched.Task.TaskName}",
                        Line4 = sched.User == null ? "" : sched.User.DisplayName,
                        Tag   = item,
                        Tag2  = sched.User != null
                    });
                }
            }
            catch (Exception ex)
            {
                IsBusy = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private void GetSchedultCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                }
                else
                {
                    TextReader textReader = new StringReader(e.Result);
                    var        xElement   = XElement.Load(textReader);

                    var items = (from item in xElement.Descendants("date")
                                 select new Schedule
                    {
                        Date = item.GetAttributeOrDefault("name"),
                        Halls = (from hall in item.Elements("hall")
                                 select new Hall
                        {
                            HallId = hall.GetAttributeIntOrDefault("id"),
                            Sessions = (from session in hall.Elements("item")
                                        select new Session
                            {
                                Id = session.GetAttributeIntOrDefault("id"),
                                Time = session.GetAttributeOrDefault("time"),
                                Price = session.GetAttributeIntOrDefault("price")
                            }).ToList()
                        }).ToList()
                    }).ToList();

                    Schedules.Clear();
                    foreach (var schedule in items)
                    {
                        Schedules.Add(schedule);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsRefreshing = false;
            IsBusy       = true;

            try
            {
                Schedules.Clear();
                Schedules.Add(new DisplayItem()
                {
                    Line1 = "Trade Only",
                    Line2 = ""
                });
                var items = await DataService.GetItemsAsync <Schedule>($"schedules?start={StartDate.ToString("MM-dd-yyyy")}&end={StartDate.AddDays(6).ToString("MM-dd-yyyy")}&forUser=true");

                foreach (var item in items.Data.OrderBy(d => d.ScheduleDate.GetValueOrDefault()).ThenBy(s => s.StartTime.GetValueOrDefault().TimeOfDay))
                {
                    Schedules.Add(new DisplayItem()
                    {
                        Line1 = $"{item.ScheduleDate.GetValueOrDefault().DayOfWeek} - {item.ScheduleDate.GetValueOrDefault().ToShortDateString()} {item.StartTimeTimezonedValue.ToShortTimeString()} - {item.EndTimeTimezonedValue.ToShortTimeString()}",
                        Line2 = $"{item.Shift.ShiftName} - {item.Task.TaskName}",
                        Tag   = item,
                    });
                }
            }
            catch (Exception ex)
            {
                IsBusy = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public void ShowSchedule()
        {
            Schedules.Clear();

            List <Schedule> schedules = _manager.Get();

            foreach (Schedule schedule in schedules)
            {
                if (schedule is SchedulePeriod)
                {
                    Schedules.Add(new SchedulePeriodViewModel((SchedulePeriod)schedule));
                }
                else if (schedule is ScheduleReminder)
                {
                    Schedules.Add(new ScheduleReminderViewModel((ScheduleReminder)schedule));
                }
                else
                {
                    Schedules.Add(new ScheduleViewModel(schedule));
                }
            }
        }
Esempio n. 13
0
        public void LoadConfig(string ConfigFile)
        {
            Reset();
            XmlDocument map = new XmlDocument();

            #region SetXMLReader
            try
            {
                XmlReaderSettings readerSettings = new XmlReaderSettings();
                readerSettings.IgnoreWhitespace             = true;
                readerSettings.IgnoreComments               = true;
                readerSettings.CheckCharacters              = true;
                readerSettings.CloseInput                   = true;
                readerSettings.IgnoreProcessingInstructions = false;
                readerSettings.ValidationFlags              = System.Xml.Schema.XmlSchemaValidationFlags.None;
                readerSettings.ValidationType               = ValidationType.None;
                XmlReader reader = XmlReader.Create(ConfigFile, readerSettings);

                map.Load(reader);
            }
            catch
            {
                Status = "Error Loading Config File. Please select a config file";
                return;
            }
            #endregion

            #region loadinputfile_and_counters

            XmlNodeList bl = map.SelectNodes("configuration/Source/Batch");
            foreach (XmlNode batchfile in bl)
            {
                Batch B = new Batch();
                B.BatchName  = batchfile.Attributes["Name"].Value;
                B.SourceFile = batchfile.Attributes["Path"].Value;
                B.SuccessLog = B.SourceFile.Insert(B.SourceFile.IndexOf("."), "_Success");
                B.ErrorLog   = B.SourceFile.Insert(B.SourceFile.IndexOf("."), "_Error");

                bool duplicate = BatchFiles.Any(item => item.SourceFile == B.SourceFile);
                if (duplicate)
                {
                    Status = "Duplicate Batch Files"; Reset(); return;
                }
                else
                {
                    BatchFiles.Add(B);
                }
            }

            #endregion

            #region loadDelimiter
            var delimnode = map.SelectSingleNode("configuration/Delimiter/Delimiter");
            delimiter = delimnode.Attributes["Character"].Value.ToCharArray().First();
            #endregion

            #region loadFields
            XmlNodeList fieldNodes = map.SelectNodes("configuration/FileMap/Field");
            //Loop through the nodes and create a field object
            // for each one.
            foreach (XmlNode fieldNode in fieldNodes)
            {
                Field field = new Field
                {
                    //Set the field's name
                    Name = fieldNode.Attributes["Name"].Value,

                    //Set the field's type
                    Type = fieldNode.Attributes["Type"].Value,
                };
                bool duplicate = fields.Any(item => item.Name == field.Name);
                if (duplicate)
                {
                    Status = "Duplicate Field Names"; Reset(); return;
                }
                else
                {
                    fields.Add(field);
                }
            }

            #endregion

            #region loadTimes

            Schedules.Clear();
            XmlNodeList b2 = map.SelectNodes("configuration/schedules");
            foreach (XmlNode node in b2)
            {
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    List <TimeSlot> slots = new List <TimeSlot>();

                    foreach (XmlNode gchildNode in childNode)
                    {
                        TimeSlot t = new TimeSlot();
                        t.StartTime = gchildNode.Attributes["Start"].Value;
                        t.EndTime   = gchildNode.Attributes["End"].Value;
                        if (Convert.ToInt32(t.StartTime) > Convert.ToInt32(t.EndTime))
                        {
                            Status = "Start Time cannot be greater than End Time"; BatchFiles.Clear(); Schedules.Clear(); fields.Clear();   return;
                        }
                        else
                        {
                            slots.Add(t);
                        }
                    }
                    if (Schedules.ContainsKey(childNode.Name.ToString()))
                    {
                        Schedules[childNode.Name.ToString()] = slots;
                    }
                    else
                    {
                        Schedules.Add(childNode.Name.ToString(), slots);
                    }
                }
            }
            #endregion

            #region LoadConnection
            var     connname     = map.SelectSingleNode("configuration/System/connection");
            string  connectionid = connname.Attributes["Name"].Value.ToString();
            XmlNode conn         = map.SelectSingleNode("configuration/Connections/connection[@Name='" + connectionid + "']");


            foreach (XmlNode childnode in conn.ChildNodes)
            {
                var Param    = childnode.Name;
                var ParamVal = childnode.InnerText.ToString();
                ConObj.AddProperty(Param, ParamVal);
            }

            #endregion
        }
Esempio n. 14
0
 public override void CalcSchedules()
 {
     Schedules.Clear();
     Schedules.Add(Device.StartTime);
 }
        public override async System.Threading.Tasks.Task ExecuteLoadSchedulesCommand()
        {
            await runTask(async() =>
            {
                if (!Users.Any())
                {
                    Users.Add(new User()
                    {
                        FirstName = "(All)", UserId = _allGuid
                    });
                    Users.Add(new User()
                    {
                        FirstName = "(Unassigned)", UserId = _unassignedGuid
                    });
                    Users.Add(new User()
                    {
                        FirstName = "(Assigned)", UserId = _assignedGuid
                    });
                    var lookups = await DataService.GetLookups(4);
                    lookups.Users.ForEach(u => Users.Add(u));

                    Shifts.Add(new Shift()
                    {
                        ShiftName = "(All)", ShiftId = _allGuid
                    });
                    lookups.Shifts.ForEach(s => Shifts.Add(s));

                    Tasks.Add(new Task()
                    {
                        TaskName = "(All)", TaskId = _allGuid
                    });
                    lookups.Tasks.ForEach(t => Tasks.Add(t));
                }

                Schedules.Clear();
                var items            = await DataService.GetItemsAsync <Schedule>($"schedules?start={ScheduleDate.ToString("MM-dd-yyyy")}&end={ScheduleDate.AddDays(6).ToString("MM-dd-yyyy")}");
                NoSchedules          = !items.Data.Any();
                this.WeekUnpublished = false;
                foreach (var item in items.Data.OrderBy(d => d.ScheduleDateValue).ThenBy(d => d.StartTimeValue).ThenBy(d => d.User == null ? "aaaaaaa" : d.User.FirstName))
                {
                    if (item.UserId != null && !item.PublishedValue)
                    {
                        this.WeekUnpublished = true;
                    }
                    _weekSchedules = items.Data;
                    if (SelectedUser != null && SelectedUser.UserIdValue != _allGuid)
                    {
                        if (SelectedUser.UserIdValue == _unassignedGuid && item.User != null)
                        {
                            continue;
                        }
                        if (SelectedUser.UserIdValue == _assignedGuid && item.User == null)
                        {
                            continue;
                        }
                        if (SelectedUser.UserIdValue != _assignedGuid && SelectedUser.UserIdValue != _unassignedGuid && SelectedUser.UserIdValue != item.UserIdValue)
                        {
                            continue;
                        }
                    }

                    if (SelectedShift != null && SelectedShift.ShiftIdValue != _allGuid && SelectedShift.ShiftIdValue != item.ShiftIdValue)
                    {
                        continue;
                    }

                    if (SelectedTask != null && SelectedTask.TaskIdValue != _allGuid && SelectedTask.TaskIdValue != item.TaskIdValue)
                    {
                        continue;
                    }

                    var displayItem = new DisplayItem();
                    scheduleToDisplayItem(displayItem, item);
                    Schedules.Add(displayItem);
                }
                OnPropertyChanged("WeekUnpublished");

                return(items);
            });

            OnPropertyChanged("NoSchedules");
        }