Example #1
0
        public async void EditRemind(string content, string title, RemindListModel remind)
        {
            string[] tag = remind.Id_system.Split(',');
            RemindSystemUtil.DeleteRemind(tag);
            List <RemindSystemModel> remindSystemList = new List <RemindSystemModel>();
            string weekString = GetSelWeek(content, title, remindSystemList);//设置本地通知的时间转换

            try
            {
                int    indexBefore = App.indexBefore;
                string json        = "";
                remind.Remind = await EditRemindBackup(content, title, weekString, indexBefore, remind);

                json = JsonConvert.SerializeObject(remind.Remind);
                var    beforeTime = RemindModel.BeforeTime[indexBefore].BeforeTime;
                string localId    = "";
                if (indexBefore != 0)
                {
                    localId = await RemindSystemUtil.AddAllRemind(remindSystemList, beforeTime);
                }
                DatabaseMethod.EditItem(remind.Num, remind.Id, json, localId);
                //DatabaseMethod.ToDatabase(remind.Id.ToString(), json, localId);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
Example #2
0
        public async void AddRemind(string content, string title)
        {
            List <RemindSystemModel> remindSystemList = new List <RemindSystemModel>();
            string weekString = "";

            //List<RemindBackupModel> remindBackupList = new List<RemindBackupModel>();
            weekString = GetSelWeek(content, title, remindSystemList);
            try
            {
                int    indexBefore = App.indexBefore;
                string json        = "";
                var    temp        = await AddRemindBakcup(content, title, weekString, indexBefore);

                AddRemindBackModel backInfo = new AddRemindBackModel();
                if (!temp.Item1.Equals(""))
                {
                    backInfo = JsonConvert.DeserializeObject <AddRemindBackModel>(temp.Item1);
                }
                json = temp.Item2;
                var    beforeTime = RemindModel.BeforeTime[indexBefore].BeforeTime;
                string localId    = "";
                if (indexBefore != 0)
                {
                    localId = await RemindSystemUtil.AddAllRemind(remindSystemList, beforeTime);
                }

                DatabaseMethod.ToDatabase(backInfo.Id.ToString(), json, localId);
            }
            catch (Exception n)
            {
                Debug.WriteLine(n);
            }
        }
Example #3
0
        public async void RefreshList(bool e = false)
        {
            bool isRewrite;

            if (e)
            {
                isRewrite = e;
            }
            else
            {
                isRewrite = RemindListOC.Count > 0 ? RemindListOC[0].IsRewrite : false;
            }
            RemindListOC.Clear();
            var remindList = await RemindSystemUtil.SyncRemindList();

            DatabaseMethod.ClearDatabase();
            int num = 1;

            foreach (var item in remindList)
            {
                RemindListModel temp = new RemindListModel();
                temp.Remind    = item;
                temp.Num       = num++;
                temp.IsRewrite = isRewrite;
                temp.Id        = item.Id;
                temp.json      = JsonConvert.SerializeObject(item);
                temp.ClassTime();
                if (item.Time != null)
                {
                    int hour, min;
                    hour = (int)item.Time / 60;
                    min  = (int)item.Time % 60;
                    TimeSpan beforeTime = new TimeSpan(hour, min, 0);
                    temp.Id_system = await RemindSystemUtil.AddAllRemind(OnceRemind(temp.Remind), beforeTime);
                }
                RemindListOC.Add(temp);
                DatabaseMethod.ToDatabase(temp.Id, temp.json, temp.Id_system);
            }
        }