public static List <ItemCalendar> Convert(List <WorkPlan> wPlan) { var result = new List <ItemCalendar>(); foreach (var item in wPlan) { var temp = new ItemCalendar(); temp.Title = item.Title; temp.IsReminded = !string.IsNullOrEmpty(item.ViewTO); temp.Body = item.Title + " " + item.ViewTO; temp.StartDateTime = item.StartTO.AddHours(8); temp.EndDateTime = item.EndTO.AddHours(15); temp.ReminderDay = Other.DayOfWeek(item.StartTO, new SettingsContext().Settings.DayRemineder); result.Add(temp); } return(result); }
public static List <ItemCalendar> ConvertAndGroup(List <WorkPlan> wPlan) { var result = new List <ItemCalendar>(); var groupList = wPlan.GroupBy(startDate => startDate.StartTO); foreach (var itemGroup in groupList) { var temp = new ItemCalendar(); foreach (var item in itemGroup) { temp.Title = "Работа"; temp.Body += item.Title + " " + item.ViewTO + ";\n"; temp.StartDateTime = item.StartTO.AddHours(8).AddMinutes(2).AddSeconds(17); temp.EndDateTime = item.EndTO.AddHours(8).AddMinutes(3).AddSeconds(17); temp.ReminderDay = Other.DayOfWeek(item.StartTO, Const.DayReminder); } result.Add(temp); } return(result); }
//Intial creation public static void Calendar(Grid grid, int px, int py, int sx, int sy, JArray data) { Microsoft.AppCenter.Analytics.Analytics.TrackEvent("Create Calendar Widget"); CrossLogger.Current.Info("Calendar", "Widget Processing Started"); try { List <Models.Sitemap.Widget3> items = data.ToObject <List <Models.Sitemap.Widget3> >(); foreach (Models.Sitemap.Widget3 item in items) { //Master Grid for Widget Grid Widget_Grid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, }, RowSpacing = 0, ColumnSpacing = 0, BackgroundColor = App.Config.CellColor, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.StartAndExpand, }; grid.Children.Add(Widget_Grid, px, px + sx, py, py + sy); ItemCalendar.Add(new Models.CalItems { Label = item.Label, State = item.Item.State, Name = item.Item.Name, Grid = Widget_Grid, }); } lock (ItemCalendar) { Create_Calendar(); } // Check if we've crossed midnight as first entry is now yesterday Device.StartTimer(TimeSpan.FromSeconds(60), () => { if ((SortedList != null) && (SortedList.Count > 0) && (DateTime.Today.Date != SortedList[0].Start.Date)) { CrossLogger.Current.Debug("Calendar", "Update Calendar as we've crossed midnight"); lock (ItemCalendar) { Create_Calendar(); } } return(true); }); } catch (Exception ex) { CrossLogger.Current.Error("Calendar", "Crashed: " + ex.ToString()); } }