コード例 #1
0
        public void LoadTasks()
        {
            TasksList.Clear();
            using (SqlCommand cmd = new SqlCommand("get_tasks_by_date", Conn))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@dt", ChosenDate);
                Conn.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var task = new TaskModel();
                        task.Id      = Convert.ToInt32(reader["id"]);
                        task.Content = reader["content"].ToString();
                        task.IsDone  = Convert.ToBoolean(reader["is_done"]);
                        task.Date    = Convert.ToDateTime(reader["dt"]).Date;
                        TasksList.Add(task);
                    }
                }
                reader.Close();
                Conn.Close();
            }
            Change_TasksState();
        }
コード例 #2
0
 private void ReloadTasks(List <Models.Task> tasks)
 {
     tasks = tasks.Where(t => t.StateId != Constant.Finalizar).ToList();
     TasksList.Clear();
     foreach (var task in tasks)
     {
         TasksList.Add(task.Cast <TaskItemViewModel>());
     }
 }
コード例 #3
0
        /// <summary>
        /// Gets the solution name and saves the tasks related to that solution
        /// Data is saved to %AppData%/VsToDoList/{solutionname}.tasks
        /// </summary>
        private void SaveTasks()
        {
            var solutionName = GetSolutionName();

            if (solutionName == null)
            {
                return;
            }

            _taskService.SaveTasks(solutionName, TasksList.ToList());
            TasksList.Clear();
        }
コード例 #4
0
        public async Task Init()
        {
            try
            {
                Model.Search.Task req;
                if (SelectedSearchOption == SearchOptions.TeamActive)
                {
                    req = new Model.Search.Task
                    {
                        Executed          = false,
                        FunctionalFieldId = APIService.LoggedUser.FunctionalFieldId,
                        LocalCommitteeId  = APIService.LoggedUser.LocalCommitteeId
                    };
                    if (APIService.LoggedUser.FunctionalFieldId == 1)
                    {
                        req.FunctionalFieldId = 0;
                    }
                }
                else if (SelectedSearchOption == SearchOptions.AllActive)
                {
                    req = new Model.Search.Task
                    {
                        Executed = false
                    };
                }
                else if (SelectedSearchOption == SearchOptions.AllTeam)
                {
                    req = new Model.Search.Task
                    {
                        FunctionalFieldId = APIService.LoggedUser.FunctionalFieldId,
                        LocalCommitteeId  = APIService.LoggedUser.LocalCommitteeId
                    };
                    if (APIService.LoggedUser.FunctionalFieldId == 1)
                    {
                        req.FunctionalFieldId = 0;
                    }
                }
                else
                {
                    req = null;
                }
                var list = await _tasksService.Get <IEnumerable <Model.Response.TaskDetails> >(req);

                TasksList.Clear();
                foreach (var task in list)
                {
                    TasksList.Add(task);
                }
            }catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Task", "There was an error.", "OK");
            }
        }
コード例 #5
0
        public async Task <bool> LoadTasks()
        {
            IsRefreshing = true;
            try
            {
                var modelMain = MainViewModel.GetInstance();
                modelMain.ProjectSelected = this.selectedProject;
                TasksList.Clear();
                var response = await apiService.Get <Models.Task>(modelMain.urlBase, "/api", string.Format("/TareaAPI/GetTareasProyecto/{0}/{1}/1/{2}/{3}", modelMain.CurrentUser.UserId, this.selectedProject, Constant.Prioridad, Constant.EstadoTarea));

                if (response.IsSuccess)
                {
                    ReloadTasks((List <Models.Task>)response.Result);
                    GetSuspendMessages();
                }
            }
            catch (Exception ex)
            {
                dialogService.ShortToast("Error al obtener los datos.");
                await navigationService.Clear();
            }
            IsRefreshing = false;
            return(true);
        }
コード例 #6
0
 private void DeleteList()
 {
     TasksList.Clear();
     TasksViewModel.WriteToTaskList(TasksList);
     ReadList();
 }
コード例 #7
0
        /// <summary>
        /// Обработка события выбора элемента в Picker для фильтрации списка текущих задач.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnCategoryChanged(object sender, EventArgs e)
        {
            if (IsPickerEventExecuted)
            {
                IsCheckBoxEventExecuted = false;
                IsPickerEventExecuted   = false;
                TasksList.Clear();
                List <Task> newTasks = new List <Task>();
                switch (CategoryPicker.SelectedIndex)
                {
                //Дефолтное значение
                case -1:
                    newTasks = User.Tasks.OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Все
                case 0:
                    newTasks = User.Tasks.OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Дедлайны
                case 1:
                    newTasks = User.Tasks.Where(task => task.IsDeadLine).OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Выполненные
                case 2:
                    newTasks = User.Tasks.Where(task => task.IsCompleted).OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Невыполненные
                case 3:
                    newTasks = User.Tasks.Where(task => !task.IsCompleted).OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Просроченные
                case 4:
                    newTasks = User.Tasks.Where(task => task.EndDate < DateTime.Now && !task.IsCompleted).OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Вчера
                case 5:
                    DateTime yesterday = new DateTime(DateTime.Now.Ticks - Utils.oneDay);
                    newTasks = User.Tasks.
                               Where(task => Utils.Date(task.BeginDate) <= Utils.Date(yesterday) && Utils.Date(yesterday) <= Utils.Date(task.EndDate) ||
                                     (task.IsDeadLine && Utils.Date(new DateTime(yesterday.Ticks + Utils.oneDay)).ToString("dd.MM HH:mm") == task.EndDateText)).
                               OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Сегодня
                case 6:
                    DateTime now = DateTime.Now;
                    newTasks = User.Tasks.
                               Where(task => Utils.Date(task.BeginDate) <= Utils.Date(now) && Utils.Date(now) <= Utils.Date(task.EndDate) ||
                                     (task.IsDeadLine && Utils.Date(new DateTime(now.Ticks + Utils.oneDay)).ToString("dd.MM HH:mm") == task.EndDateText)).
                               OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;

                //Завтра
                case 7:
                    DateTime tomorrow = new DateTime(DateTime.Now.Ticks + Utils.oneDay);
                    newTasks = User.Tasks.
                               Where(task => Utils.Date(task.BeginDate) <= Utils.Date(tomorrow) && Utils.Date(tomorrow) <= Utils.Date(task.EndDate) ||
                                     (task.IsDeadLine && Utils.Date(new DateTime(tomorrow.Ticks + Utils.oneDay)).ToString("dd.MM HH:mm") == task.EndDateText)).
                               OrderBy(task => task.BeginDate).Select(task => task).ToList();
                    break;
                }
                newTasks.ForEach(task => TasksList.Add(task));
                IsCheckBoxEventExecuted = true;
                IsPickerEventExecuted   = true;
            }
        }