Exemple #1
0
 /// <summary>
 /// 创建默认userProfile
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public static UserProfile CreateDefaultUserProfile(String userId)
 {
     UserProfile profile = new UserProfile();
     profile.Id = Constants.EntityIdentifie.DEFAULT_USER_PROFILE_ID;
     profile.UserId = userId;
     profile.IsShowTodayList = 1;
     profile.IsShow7DaysList = 0;
     profile.DefaultReminderTime = "-1";
     //profile.DailyReminderTime = DateUtils.removeDailyReminderTimeZone("09:00");
     profile.MeridiemType = Constants.MeridiemType.TYPE_24_HOUR;//==========此处处理日期留坑
     //DateFormat.is24HourFormat(TickTickApplicationBase.StaticApplication) ?
     //    Constants.MeridiemType.TYPE_24_HOUR
     //    :
     //    Constants.MeridiemType.TYPE_AM_PM;
     //profile.StartDayWeek = new DateTimeFormatInfo().FirstDayOfWeek;
     profile.Status = ModelStatusEnum.SYNC_NEW;
     profile.IsShowCompletedList = ModelStatusEnum.NO;
     profile.IsShowTagsList = false;
     profile.IsShowScheduledList = true;
     profile.IsShowTrashList = false;
     //profile.SortTypeOfAllProject = SortType.DUE_DATE;
     //profile.SortTypeOfInbox = SortType.USER_ORDER;
     return profile;
 }
 /// <summary>
 /// 获取用户的设置信息
 /// </summary>
 /// <returns></returns>
 public async Task GetUserProfile()
 {
     var userId = App.SignUserInfo.Sid;
     UserProfile = await UserProfileBll.GetLastOneUserProfileInfoByUserId(userId) ??
                   UserProfile.CreateDefaultUserProfile(userId);
 }
        /// <summary>
        /// 初始化智能清单列表
        /// </summary>
        /// <returns></returns>
        public async Task<List<Projects>> InitialIntelligentProjects()
        {
            var intelligentProjects = new List<Projects>();
            if (UserProfile == null)
            {
                UserProfile = UserProfile.CreateDefaultUserProfile(App.SignUserInfo.Sid);
            }
            if (UserProfile.IsShowAllList)
            {
                var allTasks = await TaskBll.GetAllTasks();
                intelligentProjects.Add(new Projects
                {
                    Name = "所有",
                    IsIntelligentProjects = true,
                    IntelligentProjectsTypeEnum = IntelligentProjectsTypeEnum.IsShowAllList,
                    TasksCount = allTasks.Count(t => !t.IsCompleted)
                });
            }
            if (UserProfile.IsShowTodayList == ModelStatusEnum.YES)
            {
                var todayTasks = await TaskBll.GetTodayTasks();
                intelligentProjects.Add(new Projects
                {
                    Name = "今天",
                    IsIntelligentProjects = true,
                    IntelligentProjectsTypeEnum = IntelligentProjectsTypeEnum.IsShowTodayList,
                    TasksCount = todayTasks.Count(t => !t.IsCompleted)
                });
            }
            if (UserProfile.IsShow7DaysList == ModelStatusEnum.YES)
            {
                var sevenDaysTasks = await TaskBll.GetSevenTasks();
                intelligentProjects.Add(new Projects
                {
                    Name = "最近7天",
                    IsIntelligentProjects = true,
                    IntelligentProjectsTypeEnum = IntelligentProjectsTypeEnum.IsShow7DaysList,
                    TasksCount = sevenDaysTasks.Count(t => !t.IsCompleted)
                });
            }
            if (UserProfile.IsShowCompletedList == ModelStatusEnum.YES)
            {
                var completedTasks = await TaskBll.GetCompletedTasks();
                intelligentProjects.Add(new Projects
                {
                    Name = "已完成",
                    IsIntelligentProjects = true,
                    IntelligentProjectsTypeEnum = IntelligentProjectsTypeEnum.IsShowCompletedList,
                    TasksCount = completedTasks.Count(t => !t.IsCompleted)
                });
            }

            //if (UserProfile.IsShowScheduledList)
            //{
            //    IntelligentProjects.Add(new Projects { Name = "所有", IsIntelligentProjects = true });
            //}
            var inboxTasks = await TaskBll.GetInboxTasks();
            intelligentProjects.Add(new Projects
            {
                Name = "收集箱",
                IsIntelligentProjects = true,
                IntelligentProjectsTypeEnum = IntelligentProjectsTypeEnum.IsInboxList,
                TasksCount = inboxTasks.Count(t => !t.IsCompleted)
            });
            return intelligentProjects;
        }
 public SettingDetailPageViewModel()
 {
     this.SettingItem = new SettingItem();
     _userProfile = new UserProfile();
 }