Ejemplo n.º 1
0
 private void LoadOrUpdateHours()
 {
     for (int i = 0; i < 24; i++)
     {
         if (Hours.Count <= i)
         {
             var ClockItem = new ClockModelItem()
             {
                 Value       = i,
                 DisplayName = i.ToString(),
                 IsEnabled   = IsHourValidated(i),
                 IsChecked   = i == SelectedTime.Hour,
             };
             Hours.Add(ClockItem);
         }
         else
         {
             var ClockItem = Hours[i];
             ClockItem.Value       = i;
             ClockItem.DisplayName = i.ToString();
             ClockItem.IsEnabled   = IsHourValidated(i);
             ClockItem.IsChecked   = i == SelectedTime.Hour;
         }
     }
 }
Ejemplo n.º 2
0
        async Task SyncHours()
        {
            if (!IsBusy)
            {
                Exception Error = null;

                Hours.Clear();
                try
                {
                    IsBusy = true;
                    var Repository = new Repository();
                    var Items      = await Repository.GetHours();

                    foreach (var Hour in Items)
                    {
                        Hours.Add(Hour.Hour);
                        HoursAvaliable.Add(Hour);
                    }
                }
                catch (Exception ex)
                {
                    Error = ex;
                }
                finally
                {
                    IsBusy = false;
                }
                if (Error != null)
                {
                    await _pageDialogService.DisplayAlertAsync("Erro", Error.Message, "OK");
                }
                return;
            }
        }
Ejemplo n.º 3
0
 public Store(DWStore apiStore) : this()
 {
     Id = apiStore.Id;
     string[] dayOfWeekArray = { "Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat." };
     Address.Address1 = (apiStore.Address1 ?? string.Empty).Trim();
     Address.Address2 = (apiStore.Address2 ?? string.Empty).Trim();
     Address.City     = apiStore.City;
     Address.State    = apiStore.State;
     Address.Zip      = apiStore.Zip;
     Address.Phone    = apiStore.Phone;
     Latitude         = (double)apiStore.Latitude;
     Longitude        = (double)apiStore.Longitude;
     Distance         = (double)Math.Round(apiStore.Distance, 2);
     if (apiStore.Hours != null)
     {
         apiStore.Hours = apiStore.Hours.ToUpper();
         var matches = APIHelper.HoursRegex.Matches(apiStore.Hours);
         if (matches.Count > 0)
         {
             for (int i = 0; i < matches.Count; i++)
             {
                 var storehours = GetHoursAndMsg(matches[i]);
                 Hours.Add(new StoreHours(storehours.Item1, storehours.Item2, dayOfWeekArray[i]));
             }
         }
     }
 }
Ejemplo n.º 4
0
        public TimeItemCollection()
        {
            DateTime date   = DateTime.Now;
            int      month  = date.Month;
            int      day    = date.Day;
            int      hour   = date.Hour;
            int      min    = date.Minute;
            int      second = date.Second;

            for (int i = 1; i <= 12; i++)
            {
                Months.Add(new TimeItem()
                {
                    Content = $"{i.ToString().PadLeft(2, '0')}月",
                    Value   = i,
                    Angle   = 30 * (i - month - 1)
                });
            }
            for (int i = 1; i <= 31; i++)
            {
                Days.Add(new TimeItem()
                {
                    Content = $"{i.ToString().PadLeft(2, '0')}天",
                    Value   = i,
                    Angle   = 360.0 / 31.0 * (i - day - 1)
                });
            }
            for (int i = 0; i < 24; i++)
            {
                Hours.Add(new TimeItem()
                {
                    Content = $"{i.ToString().PadLeft(2, '0')}点",
                    Value   = i,
                    Angle   = 15 * (i - hour - 1)
                });
            }
            for (int i = 0; i < 60; i++)
            {
                Mins.Add(new TimeItem()
                {
                    Content = $"{i.ToString().PadLeft(2, '0')}分",
                    Value   = i,
                    Angle   = 6 * (i - min - 1)
                });
            }
            for (int i = 0; i < 60; i++)
            {
                Seconds.Add(new TimeItem()
                {
                    Content = $"{i.ToString().PadLeft(2, '0')}秒",
                    Value   = i,
                    Angle   = 6 * (i - second - 1)
                });
            }
        }
Ejemplo n.º 5
0
        public Day(DateTimeOffset date, DailyEventManager manager, int startH = 0, int endH = 23)
        {
            this.Date         = date;
            this.EventManager = manager;
            this.Culture      = new CultureInfo(GlobalizationPreferences.Languages[0]);

            this.Hours = new List <Hour>();
            for (var h = startH; h <= endH; h++)
            {
                Hours.Add(new Hour(date.Date.AddHours(h)));
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 初始化日期
 /// 初始化时间
 /// 初始化分钟
 /// </summary>
 public SearchParamsDateTime()
 {
     Date = new DateTime().ToString();
     for (int i = 0; i <= 59; i++)
     {
         if (i >= 1 && i <= 24)
         {
             Hours.Add(i + ":00");
         }
         Minutes.Add(i);
     }
 }
Ejemplo n.º 7
0
        public TimePicker()
        {
            InitializeComponent();

            for (var i = 0; i < 24; i++)
            {
                Hours.Add(i);
            }

            for (var i = 0; i < 60; i++)
            {
                Minutes.Add(i);
                Seconds.Add(i);
            }
        }
Ejemplo n.º 8
0
        public AssignmentViewModel()
        {
            AvailableStatuses = new AssignmentStatus []
            {
                AssignmentStatus.Hold,
                AssignmentStatus.Active,
                AssignmentStatus.Complete,
            };

            service = ServiceContainer.Resolve <IAssignmentService> ();

            timer = new Timer(1000);

#if !NETFX_CORE
            //This causes our timer to fire it's events on the UI thread
            timer.SynchronizingObject = ServiceContainer.Resolve <ISynchronizeInvoke> ();
#endif
            timer.Elapsed += (sender, e) => {
                Hours = Hours.Add(TimeSpan.FromSeconds(1));
                SaveAssignmentAsync(ActiveAssignment);
            };
        }
Ejemplo n.º 9
0
        public CronPattern Parse(string cron, JalaliCalendar startDate, JalaliCalendar endDate)
        {
            //CronTabScheduler cronTabScheduler = new NCronTab.CronTabScheduler();
            var persianCalendarPart = new JalaliCalendar();

            var parts = cron.Split(' ');


            #region [Days]
            int dayStep          = 0;
            int currentDayOfYear = 0;
            if (parts[2] == "*")
            {
                for (int i = startDate.DaysInYears; i <= endDate.DaysInYears; i++)
                {
                    Days.Add(i);
                }
            }
            else
            {
                var dayParts = parts[2].Split('/');
                if (dayParts.Count() == 1)
                {
                    Days.Add(int.Parse(dayParts[0]));
                }
                else if (dayParts.Count() == 2)
                {
                    var days = dayParts[1].Split(',');
                    dayStep          = int.Parse(days[0]);
                    currentDayOfYear = startDate.DayOfYear;
                    for (int i = startDate.DaysInYears; i <= endDate.DaysInYears; i = i + dayStep)
                    {
                        Days.Add(i);
                    }
                }
            }

            //else
            //{
            //    if (parts[2].Contains("-"))
            //    {
            //        Days.Clear();
            //        var dayParts = parts[2].Split('-');
            //        var firstOfWeek = int.Parse(dayParts[0]);
            //        var endOfWeek = int.Parse(dayParts[1]);
            //        currentDayOfYear = startDate.DayOfYear;

            //        for (int i = startDate.DaysInYears; i <= endDate.DaysInYears; i++)
            //        {
            //            var dayOfMonth = persianCalendarPart.DayOfYearToDayOfMonth(i);
            //            var dayNum = persianCalendarPart.DayOfYearToDayNum(i);

            //            if (WeekDays.Contains(dayNum) && dayOfMonth >= firstOfWeek && dayOfMonth < endOfWeek)
            //                Days.Add(i);
            //        }
            //        Months = null;
            //        return this;
            //    }
            //    else
            //    {
            //        var dayParts = parts[2].Split('/');
            //        if (dayParts.Count() == 1)
            //        {
            //            Days.Add(int.Parse(dayParts[0]));
            //        }
            //        else if (dayParts.Count() == 2)
            //        {
            //            var days = dayParts[1].Split(',');
            //            dayStep = int.Parse(days[0]);
            //            currentDayOfYear = startDate.DayOfYear;
            //            for (int i = startDate.DayOfYear; i <= endDate.DayOfYear; i = i + dayStep)
            //            {
            //                Days.Add(i);
            //            }
            //        }
            //    }
            //}
            #endregion



            //for (int i = startDate.Year; i <= endDate.Year; i++)
            //{
            //    Years.Add(i);
            //}



            #region [WeekDays]
            if (parts[4] != "*")
            {
                Days = new List <int>();
                var        yearParts   = parts[4].Split(',');
                List <int> daysForWeek = new List <int>();
                for (int i = startDate.DaysInYears; i <= endDate.DaysInYears; i++)
                {
                    daysForWeek.Add(i);
                }
                foreach (var item in yearParts)
                {
                    var dayNum = persianCalendarPart.WeekMapping.FirstOrDefault(q => q.Key == item);
                    WeekDays.Add(dayNum.Value);
                }
                foreach (var dayForWeek in daysForWeek)
                {
                    var dayNum = persianCalendarPart.DaysInYearsToDayNum(dayForWeek);
                    if (WeekDays.Contains(dayNum))
                    {
                        Days.Add(dayForWeek);
                    }
                }
            }
            #endregion


            #region [Minutes]
            if (parts[0] == "*")
            {
                for (int i = 0; i < 60; i++)
                {
                    Minutes.Add(i);
                }
            }
            else
            {
                var minuteParts = parts[0].Split('/');
                if (minuteParts.Count() == 1)
                {
                    Minutes.Add(int.Parse(minuteParts[0]));
                }
                else if (minuteParts.Count() == 2)
                {
                    int minPart = 0;
                    if (minuteParts[0] == "*" && int.TryParse(minuteParts[1].ToString(), out minPart))
                    {
                        for (int i = startDate.MinuteOfYear; i < endDate.MinuteOfYear; i = i + minPart)
                        {
                            Minutes.Add(i);
                        }
                    }
                    return(this);
                }
            }

            #endregion



            #region [Hours]
            if (parts[1] == "*")
            {
                for (int i = 0; i < 24; i++)
                {
                    Hours.Add(i);
                }
            }
            else
            {
                var hourParts = parts[1].Split('/');
                if (hourParts.Count() == 1)
                {
                    Hours.Add(int.Parse(hourParts[0]));
                }
                else if (hourParts.Count() == 2)
                {
                    int minPart = 0;
                    if (hourParts[0] == "*" && int.TryParse(hourParts[1].ToString(), out minPart))
                    {
                        for (int i = startDate.Hour; i < endDate.Hour; i = i + minPart)
                        {
                            Hours.Add(i);
                        }
                    }
                }
            }
            #endregion

            #region [Months]
            bool       monthly      = false;
            List <int> monthStep    = new List <int>();
            int        currentMonth = 0;
            if (parts[3] == "*")
            {
                Months.Add(1);
            }
            else
            {
                var monthParts = parts[3].Split('/');
                if (monthParts.Count() == 1)
                {
                    monthly = false;
                    monthStep.Add(int.Parse(monthParts[0]));
                }
                else if (monthParts.Count() == 2)
                {
                    monthly = true;
                    foreach (var item in monthParts[1].Split(','))
                    {
                        monthStep.Add(int.Parse(item));
                    }
                }

                var daysInMonthPart = new List <int>();
                var days            = new List <int>();
                days.AddRange(Days);
                Days.Clear();
                for (int i = startDate.DaysInYears; i <= endDate.DaysInYears; i++)
                {
                    int yearr;
                    int month;
                    int day;
                    persianCalendarPart.DaysInYearsToDateParts(i, out yearr, out month, out day);
                    if (monthly && (monthStep.Any(q => q == month)) && days.Contains(day))
                    {
                        Days.Add(i);
                    }
                    else
                    if ((month == monthStep[0]) && days.Contains(day))
                    {
                        Days.Add(i);
                    }
                }
            }
            #endregion
            return(this);
        }
Ejemplo n.º 10
0
        public void InitDummyData()
        {
            Database.SetInitializer <WHTDbContext>(new DropCreateDatabaseAlways <WHTDbContext>());

            EmployeeModel tempEmp = new EmployeeModel {
                FirstName = "Adam", LastName = "Oforek"
            };

            Employees.Add(tempEmp);

            tempEmp = new EmployeeModel {
                FirstName = "Marek", LastName = "Janek"
            };
            Employees.Add(tempEmp);

            tempEmp = new EmployeeModel {
                FirstName = "Aneta", LastName = "Polak"
            };
            Employees.Add(tempEmp);

            tempEmp = new EmployeeModel {
                FirstName = "Cesarz", LastName = "Juliusz"
            };
            Employees.Add(tempEmp);


            DateTime now = new DateTime();

            now = DateTime.Now.Date;
            HoursModel tempHours = new HoursModel
            {
                WorkingDate = now,
                From        = new TimeSpan(8, 30, 0),
                To          = new TimeSpan(17, 0, 0),
                EmployeeId  = 1
            };

            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now.AddDays(-1),
                From        = new TimeSpan(7, 00, 0),
                To          = new TimeSpan(17, 0, 0),
                EmployeeId  = 1
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now,
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 2
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now.AddDays(-14),
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 1
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now,
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 3
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now,
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 4
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now.AddDays(-3),
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 1
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now.AddDays(-3),
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 2
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now.AddDays(-3),
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 3
            };
            Hours.Add(tempHours);

            tempHours = new HoursModel
            {
                WorkingDate = now.AddDays(-3),
                From        = new TimeSpan(6, 30, 0),
                To          = new TimeSpan(10, 0, 0),
                EmployeeId  = 4
            };
            Hours.Add(tempHours);

            HashSet <int> weekends = new HashSet <int>();

            weekends.Add(1);
            weekends.Add(3);
            weekends.Add(4);
            weekends.Add(5);
            weekends.Add(11);
            weekends.Add(12);
            weekends.Add(18);
            weekends.Add(19);
            weekends.Add(25);
            weekends.Add(26);
            YearMonthModel yearMonth = new YearMonthModel {
                Year = 2019, Month = 5, MonthsWorkingHours = 168, MonthsWeekendDays = new HashSet <int>(weekends)
            };

            YearMonths.Add(yearMonth);

            YearMonths.Add(yearMonth);

            yearMonth = new YearMonthModel
            {
                Year  = 2019,
                Month = 6,
                MonthsWorkingHours = 160,
                MonthsWeekendDays  = new HashSet <int>(weekends)
            };
            YearMonths.Add(yearMonth);

            yearMonth = new YearMonthModel
            {
                Year  = 2019,
                Month = 7,
                MonthsWorkingHours = 200,
                MonthsWeekendDays  = new HashSet <int>(weekends)
            };
            YearMonths.Add(yearMonth);

            VacationModel vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(7),
                Type       = Models.Enums.VacationTypes.PŁATNY,
                EmployeeId = 1
            };

            Vacations.Add(vacation);

            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.ZWOLNIENIE_LEKARSKIE,
                EmployeeId = 2
            };
            Vacations.Add(vacation);

            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.OKOLICZNOŚCIOWY,
                EmployeeId = 3
            };
            Vacations.Add(vacation);

            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.RODZICIELSKI,
                EmployeeId = 1
            };
            Vacations.Add(vacation);

            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.WYPOCZYNKOWY,
                EmployeeId = 4
            };
            Vacations.Add(vacation);
            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.ZWOLNIENIE_LEKARSKIE,
                EmployeeId = 2
            };
            Vacations.Add(vacation);
            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.RODZICIELSKI,
                EmployeeId = 3
            };
            Vacations.Add(vacation);
            vacation = new VacationModel
            {
                From       = DateTime.Now,
                To         = DateTime.Now.AddDays(3),
                Type       = Models.Enums.VacationTypes.ZWOLNIENIE_LEKARSKIE,
                EmployeeId = 4
            };
            Vacations.Add(vacation);
            this.SaveChanges();
        }