private int reloadIndex(RemindListModel remind) { int index; int?time = remind.Remind.Time; if (time == null) { index = 0; } else if (time == 5) { index = 1; } else if (time == 10) { index = 2; } else if (time == 20) { index = 3; } else if (time == 60) { index = 4; } else { index = 3; } SelectedRemindTextBlock.Text = App.addRemindViewModel.RemindModel.BeforeTime[index].BeforeTimeString; return(index); }
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); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); pageType = e.Parameter.ToString(); if (!pageType.Equals("add")) { editRemind = e.Parameter as RemindListModel; ReloadData(); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } else { ClearAllData(); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } }
public void ReloadList() { RemindListOC.Clear(); var DBList = DatabaseMethod.ToModel(); foreach (var item in DBList) { RemindListModel temp = new RemindListModel() { Id = item.Id, Id_system = item.Id_system, Num = item.Num, json = item.json, IsRewrite = true }; temp.JsonToModel(); temp.ClassTime(); RemindListOC.Add(temp); } }
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); } }
private async Task <RemindBackupModel> EditRemindBackup(string content, string title, string week, int indexBefore, RemindListModel remind) { var user = GetCredential.getCredential("ZSCY"); RemindBackupModel remindBackup = new RemindBackupModel(); remindBackup.Content = remind.Remind.Content = content; remindBackup.Title = remind.Remind.Title = title; remindBackup.Id = remind.Id; remindBackup.Time = remind.Remind.Time = null; if (indexBefore != 0) { remindBackup.Time = remind.Remind.Time = Convert.ToInt32(App.addRemindViewModel.RemindModel.BeforeTime[indexBefore].BeforeTime.TotalMinutes); } remindBackup.DateItems = new List <DateModel>(); remind.Remind.DateItems.Clear(); foreach (var item in App.SelCoursList) { var temp = new DateModel() { Week = week, Class = item.ClassNum.ToString(), Day = item.DayNum.ToString() }; remindBackup.DateItems.Add(temp); remind.Remind.DateItems.Add(temp); } remindBackup.StuNum = user.UserName; remindBackup.IdNum = user.Password; remind.Remind.StuNum = null; remind.Remind.IdNum = null; await RemindWebRequest.getHttpWebRequest(Api.EditRemindApi, RemindWebRequest.editRemind(remindBackup), 0, true); return(remind.Remind); }