Exemplo n.º 1
0
        private List <RemindSystemModel> OnceRemind(RemindBackupModel remind)
        {
            DateTime oneWeekTime = WeekNumClass.OneWeek();
            List <RemindSystemModel> remindList = new List <RemindSystemModel>();

            foreach (var item in remind.DateItems)
            {
                string[] weekNum = item.Week.Split(',');
                for (int i = 0; i < weekNum.Length; i++)
                {
                    int            num        = int.Parse(weekNum[i]);
                    SelCourseModel selCourse  = new SelCourseModel(int.Parse(item.Day), int.Parse(item.Class));
                    DateTime       remindTime = oneWeekTime.AddDays((num - 1) * 7).Add(selCourse.NowTime());
                    if (remindTime < DateTime.Now)
                    {
                        continue;
                    }
                    else
                    {
                        RemindSystemModel remindSystem = new RemindSystemModel()
                        {
                            Content    = remind.Content,
                            Title      = remind.Title,
                            RemindTime = remindTime
                        };
                        remindList.Add(remindSystem);
                    }
                }
            }
            return(remindList);
        }
Exemplo n.º 2
0
        private static ScheduledToastNotification GenerateAlarmNotification(RemindSystemModel remind, TimeSpan beforeTime)
        {
            ToastContent content = new ToastContent()
            {
                Scenario = ToastScenario.Alarm,

                Visual = new ToastVisual()
                {
                    BindingGeneric = new ToastBindingGeneric()
                    {
                        Children =
                        {
                            new AdaptiveText()
                            {
                                Text = $"提醒: {remind.Title}"
                            },

                            new AdaptiveText()
                            {
                                Text = remind.Content
                            }
                        }
                    }
                },
                Actions = new ToastActionsSnoozeAndDismiss()  //自动创建一个自动本地化的有延迟提醒时间间隔,贪睡和取消的按钮,贪睡时间由系统自动处理
            };

            return(new ScheduledToastNotification(content.GetXml(), remind.RemindTime - beforeTime)
            {
                Tag = GetTag(remind)
            });
        }
Exemplo n.º 3
0
        public static string GetTag(RemindSystemModel remind)
        {
            string temp = remind.Id.GetHashCode().ToString();

            id += temp + ",";
            // Tag needs to be 16 chars or less, so hash the Id
            return(temp);
        }
Exemplo n.º 4
0
 private static async Task AddRemind(RemindSystemModel remind, TimeSpan beforeTime)
 {
     remind.Id = Guid.NewGuid();
     await Task.Run(delegate
     {
         addNotification(remind, beforeTime);
     });
 }
Exemplo n.º 5
0
        private static void GetSelClassTime(string content, string title, List <RemindSystemModel> remindSystemList, int week)
        {
            DateTime oneWeekTime = WeekNumClass.OneWeek();

            foreach (var item in App.SelCoursList)
            {
                DateTime remindTime = oneWeekTime.Add(item.NowTime()).AddDays(week * 7);
                if (remindTime < DateTime.Now)
                {
                    continue;
                }
                else
                {
                    RemindSystemModel remindSystem = new RemindSystemModel()
                    {
                        Content    = content,
                        Title      = title,
                        RemindTime = remindTime
                    };
                    remindSystemList.Add(remindSystem);
                }
            }
        }
Exemplo n.º 6
0
        private static void addNotification(RemindSystemModel remind, TimeSpan beforeTime)
        {
            ScheduledToastNotification scheduledNotifi = GenerateAlarmNotification(remind, beforeTime);

            ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduledNotifi);
        }
Exemplo n.º 7
0
        public static async Task <string> SyncAllRemind(RemindSystemModel remind)
        {
            id = "";

            return(id);
        }