Exemplo n.º 1
0
        public TaskItemModel AddTask(TaskItemModel taskModel)
        {
            TaskItem task = new ErucaCRM.Repository.TaskItem();

            AutoMapper.Mapper.Map(taskModel, task);
            if (taskModel.TaskId > 0)
            {
                TaskItem taskItem = taskRepository.SingleOrDefault(r => r.TaskId == taskModel.TaskId);
                taskItem.OwnerId               = taskModel.OwnerId;
                taskItem.Description           = taskModel.Description;
                taskItem.PriorityId            = taskModel.PriorityId;
                taskItem.Status                = taskModel.Status;
                taskItem.AssociatedModuleId    = taskModel.AssociatedModuleId;
                taskItem.AssociatedModuleValue = taskModel.AssociatedModuleValue;
                taskItem.Subject               = taskModel.Subject;
                taskItem.DueDate               = taskModel.DueDate;
                taskItem.ModifiedBy            = taskModel.ModifiedBy;
                taskItem.ModifiedDate          = taskModel.ModifiedDate;
                taskItem.AudioFileDuration     = taskModel.AudioFileDuration;
                taskItem.AudioFileName         = taskModel.AudioFileName;
                taskRepository.Update(taskItem);
            }
            else
            {
                taskRepository.Insert(task);
            }
            taskModel.TaskId = task.TaskId;
            return(taskModel);
        }
Exemplo n.º 2
0
        public override void HandelMessage(object sender, string message)
        {
            TaskItemModel taskModel = new TaskItemModel();

            taskModel.MergeFrom(message.DecodeBase64String());
            lock (dbContext.obj)
            {
                if (dbContext.Tasks.Any(p => p.Id.ToString() == taskModel.MajorTaskId))
                {
                    if (dbContext.TaskItems.Any(p => p.Id.ToString() == taskModel.SubTaskId) || taskModel.Position == null)
                    {
                        return;
                    }
                    dbContext.TaskItems.Add(new TaskItem()
                    {
                        Area        = 0,
                        Id          = Guid.Parse(taskModel.SubTaskId),
                        IsCrack     = false,
                        Latitude    = taskModel.Position.Latitude,
                        Longitude   = taskModel.Position.Longitude,
                        MajorTaskId = Guid.Parse(taskModel.MajorTaskId),
                        MarkedData  = ""
                    });
                    if (ZookeeperClient.ListChildren(ConstData.TodoTaskPath + "/" + taskModel.MajorTaskId).Result?.Count <= 0)
                    {
                        ZookeeperClient.DeleteNode(ConstData.TodoTaskPath + "/" + taskModel.MajorTaskId);
                        ZookeeperClient.DeleteNode(ConstData.InProgressPath + "/" + taskModel.MajorTaskId);
                    }
                    dbContext.SaveChanges();
                }
            }
        }
Exemplo n.º 3
0
 public void Save(TaskItemModel taskItem)
 {
     using (var db = new SQLiteConnection(platform, dbPath))
     {
         db.InsertOrReplace(taskItem);
     }
 }
        private void CommitTaskInEditMode()
        {
            TaskItemModel taskItem = new TaskItemModel(Name, Source, Destination, Reccurrence);

            TaskItemModel[] taskItems = { sourceTaskItem, taskItem };
            MessengerStatic.NotifyTaskWindowInEditModeClosed(taskItems);
        }
        private void MessengerStatic_TaskItemWindowOpened(object obj)
        {
            TaskItemModel  selectedItem = (TaskItemModel)obj;
            TaskItemWindow taskItemWin  = new TaskItemWindow(selectedItem);

            taskItemWin.Show();
        }
Exemplo n.º 6
0
        private async Task Executing(TaskItemModel task, CancellationToken stoppingToken)
        {
            _taskService.StartTask(task.Id);
            var rand     = new Random();
            var maxIndex = rand.Next(10, 30);
            var count    = 0;

            while (true)
            {
                if (stoppingToken.IsCancellationRequested)
                {
                    break;
                }
                count++;
                var percent = _percentCalculator.CalculatePercent(count, maxIndex);
                _taskService.UpdateTask(task.Id, percent);
                await SendLoading(task.Id); // отправим информацию о текущем состоянии задачи

                await Task.Delay(1000);

                if (count >= maxIndex)
                {
                    _taskService.CompleteTask(task.Id);
                    await SendLoading(task.Id); // отправим информацию о текущем состоянии задачи

                    break;
                }
            }
        }
 public Guid Add(TaskItemModel task)
 {
     task.Id = Guid.NewGuid();
     task.PercentComplete = 0;
     task.Status          = StatusTask.WaitingToStart;
     task.Name            = task.Name.Trim();
     _tasks.Add(task);
     return(task.Id);
 }
Exemplo n.º 8
0
        public TaskItemModel GetTask(int taskId)
        {
            TaskItemModel taskModel = new TaskItemModel();


            TaskItem task = taskRepository.GetAll(t => t.TaskId == taskId && t.RecordDeleted == false).FirstOrDefault();

            AutoMapper.Mapper.Map(task, taskModel);
            return(taskModel);
        }
        public TaskItemWindowViewModel(TaskItemModel selectedItem)
        {
            Name        = selectedItem.Name;
            Source      = selectedItem.Source;
            Destination = selectedItem.Destination;
            Reccurrence = selectedItem.Reccurrence;

            sourceTaskItem = new TaskItemModel(Name, Source, Destination, Reccurrence);

            CommitTaskItemCmd = new RelayCommand(o => { CommitTaskInEditMode(); });
        }
 public Task <int> SaveOrUpdateTaskAsync(TaskItemModel data)
 {
     if (data.Id != 0)
     {
         return(_database.UpdateAsync(data));
     }
     else
     {
         return(_database.InsertAsync(data));
     }
 }
Exemplo n.º 11
0
        async private void Save_Clicked(object sender, EventArgs e)
        {
            var taskItem = new TaskItemModel()
            {
                Heading  = Heading.Text,
                Text     = Text.Text,
                Complete = Complete.IsToggled,
            };

            await App.Database.SaveOrUpdateTaskAsync(taskItem);

            await Navigation.PopModalAsync();
        }
Exemplo n.º 12
0
        public TaskItem AddTaskItem(TaskItemModel task)
        {
            var item = new TaskItem()
            {
                Name        = task.Name,
                Description = task.Description,
                Priority    = task.Priority,
                TaskId      = task.TaskId
            };

            repository.Add(item);
            return(item);
        }
Exemplo n.º 13
0
        // GET: TaskItem
        public async Task <ActionResult> Index(string sortOrder, string searchString)
        {
            string      accessToken = Session["MicrosoftAccessToken"] as string;
            UserService userService = new UserService(accessToken);
            var         userId      = await userService.GetUserId(Session["UserId"] as string, UserDomainEnum.Microsoft);

            if (String.IsNullOrWhiteSpace(userId))
            {
                return(RedirectToAction("Login", "Account"));
            }

            TaskItemService taskItemService = new TaskItemService(accessToken);
            var             taskItems       = await taskItemService.GetTaskItems(userId);

            var groupIds = taskItems.Select(t => t.GroupId).Distinct();
            Dictionary <string, string> groups = new Dictionary <string, string>();

            foreach (var groupId in groupIds)
            {
                GroupService groupService = new GroupService(accessToken);
                string       groupName    = await groupService.GroupNameByGroupId(groupId);

                groups.Add(groupId, groupName);
            }
            var taskStatuses = await taskItemService.GetAvailableTaskStatuses();

            var tasks = new List <TaskItemModel>();

            foreach (var taskItem in taskItems)
            {
                TaskItemModel taskItemModel = GetTaskItemModel(taskItem);
                taskItemModel.GroupName = groups[taskItemModel.GroupId];
                taskItemModel.Status    = taskStatuses.Single(s => s.Id == taskItemModel.StatusId).Status;
                tasks.Add(taskItemModel);
            }
            if (!String.IsNullOrWhiteSpace(searchString))
            {
                tasks = tasks.Where(t => t.Name.Contains(searchString) || t.GroupName.Contains(searchString)).ToList();
            }

            ViewBag.TaskNameParam    = String.IsNullOrEmpty(sortOrder) ? "taskName_desc" : "";
            ViewBag.GroupNameParam   = sortOrder == "groupName" ? "groupName_desc" : "groupName";
            ViewBag.IsCompletedParam = sortOrder == "isCompleted" ? "isCompleted_desc" : "isCompleted";
            ViewBag.StatusParam      = sortOrder == "status" ? "status_desc" : "status";
            ViewBag.StartDateParam   = sortOrder == "startDate" ? "startDate_desc" : "startDate";
            ViewBag.EndDateParam     = sortOrder == "endDate" ? "endDate_desc" : "endDate";

            tasks = OrderTasks(sortOrder, tasks);

            return(View(tasks));
        }
Exemplo n.º 14
0
        private TaskItemModel GetTaskItemModel(TaskItem taskItem)
        {
            TaskItemModel taskItemModel = new TaskItemModel();

            taskItemModel.TaskItemId  = taskItem.Id;
            taskItemModel.Name        = taskItem.Name;
            taskItemModel.Description = taskItem.Description;
            taskItemModel.StartDate   = taskItem.StartDateTime.Value;
            taskItemModel.EndDate     = taskItem.EndDateTime.Value;
            taskItemModel.GroupId     = taskItem.GroupId;
            taskItemModel.IsCompleted = taskItem.IsCompleted;
            taskItemModel.StatusId    = taskItem.TaskStatusId;
            return(taskItemModel);
        }
        public TaskCompletePage(int a, int b, bool isRoutine, TaskItemModel _TaskItemModel, GRItemModel _GRItemModel)
        {
            InitializeComponent();
            firebaseFunctionsService = new FirebaseFunctionsService();

            GRItemModel    = _GRItemModel;
            TaskItemModel  = _TaskItemModel;
            this.a         = a;
            this.b         = b;
            this.isRoutine = isRoutine;
            pageModel      = new TaskCompletePageViewModel(this, a, b, isRoutine);
            BindingContext = pageModel;
            itemcount      = pageModel.count;
        }
Exemplo n.º 16
0
 public void Update(TaskItemModel item)
 {
     foreach (var task in _tasks)
     {
         if (task.Id.Equals(item.Id))
         {
             task.Name            = item.Name;
             task.PercentComplete = item.PercentComplete;
             task.Status          = item.Status;
             return;
         }
     }
     throw new ValueNotFoundException("Указанная задача не найдена");
 }
Exemplo n.º 17
0
        private TaskItem GetTaskItemFromModel(TaskItemModel taskItemModel)
        {
            TaskItem taskItem = new TaskItem();

            //taskItem.Id = Guid.NewGuid().ToString();
            taskItem.Name          = taskItemModel.Name;
            taskItem.Description   = taskItemModel.Description;
            taskItem.StartDateTime = taskItemModel.StartDate;
            taskItem.EndDateTime   = taskItemModel.EndDate;
            taskItem.GroupId       = taskItemModel.GroupId;
            taskItem.Id            = taskItemModel.TaskItemId;
            taskItem.IsCompleted   = taskItemModel.IsCompleted;
            taskItem.TaskStatusId  = taskItemModel.StatusId;
            return(taskItem);
        }
Exemplo n.º 18
0
        public StepsPage(int a, int b, bool isRoutine, TaskItemModel _taskItemModel, GRItemModel _GRItemModel)
        {
            InitializeComponent();


            this.a                     = a;
            this.b                     = b;
            taskItemModel              = _taskItemModel;
            GRItemModel                = _GRItemModel;
            this.isRoutine             = isRoutine;
            pageModel                  = new StepsPageViewModel(this, a, b, isRoutine);
            BindingContext             = pageModel;
            itemcount                  = pageModel.count;
            StepListView.HeightRequest = GetListViewHeight();
        }
Exemplo n.º 19
0
        /// <summary>
        /// Get data from session to serve for comparing
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        private TaskItemModel ReadTaskDataFromSession(int taskId)
        {
            TaskItemModel result = new TaskItemModel();
            var           data   = SessionManager.GetObject <List <TaskItemModel> >(SessionKey.TrackTask);

            if (data != null)
            {
                var item = data.FirstOrDefault(c => c.TaskId == taskId);
                if (item != null)
                {
                    result = item;
                }
            }
            return(result);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Retrieves the TaskItems in the application and gives them to a ITasksView to display.
        /// </summary>
        /// <param name="view">
        /// Displays TaskItems in the application
        /// </param>
        public void ViewTasks(ITasksView view)
        {
            var uc = taskSchedulerApplication.NewViewTasksUseCase();

            ViewTasksOutput output = uc.Execute(new ViewTasksInput());

            if (output.Success)
            {
                /*
                 * iterate through TaskItems returned by the use case, convert them to models, then
                 * add them to the view to display
                 */
                foreach (TaskItemDTO taskDTO in output.TaskItems)
                {
                    //map the current taskDTOs NotificationFrequencyType enum to a string
                    string frequencyTypeStr = frequenctTypeStrMap[taskDTO.NotificationFrequencyType];

                    //convert the taskDTO's rgb color to a Windows brush
                    SolidColorBrush colorBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, taskDTO.R, taskDTO.G, taskDTO.B));

                    //create TaskItemModel from data of TaskItemDTO
                    TaskItemModel taskItemModel = new TaskItemModel()
                    {
                        Id                    = taskDTO.Id,
                        Title                 = taskDTO.Title,
                        Description           = taskDTO.Description,
                        FrequencyType         = frequencyTypeStr,
                        NotificationFrequency = taskDTO.CustomNotificationFrequency,
                        StartTime             = taskDTO.StartTime,
                        Color                 = colorBrush
                    };

                    view.TaskItems.Add(taskItemModel);
                }

                //subscribe the view to our TaskCreated event
                TaskCreated += view.TaskCreatedCallback;

                //Subscribe to the views Closing event, so we can unsubscribe the
                //view from the TaskCreated event
                view.Closing += (s, e) => { TaskCreated -= view.TaskCreatedCallback; };
            }
            else
            {
                //TODO: handle possible failure of use-case
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Create new task
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public async Task <ResultModel <TaskItemModel> > SaveTask(TaskItemModel model)
        {
            ResultModel <TaskItemModel> result = new ResultModel <TaskItemModel>();

            TaskItem task = model.ToEntity();

            //reset navigate object
            task.Phase       = null;
            task.Project     = null;
            task.Assignee    = null;
            task.Member      = null;
            task.UpdatedDate = DateTime.Now;
            if (task.AssigneeId == 0)
            {
                task.AssigneeId = null;
            }

            if (task.Id < 1)
            {
                task.TaskCode         = string.Empty;
                task.CreatedDate      = DateTime.Now;
                task.PercentCompleted = 5;
                UnitOfWork.TaskRepository.Add(task);
            }
            else
            {
                UnitOfWork.TaskRepository.Update(task);
            }


            int iResult = await UnitOfWork.CommitAsync();

            if (iResult > 0)
            {
                if (string.IsNullOrEmpty(task.TaskCode))
                {
                    task.TaskCode = CreateCode("T", task.Id);
                    await UnitOfWork.CommitAsync();
                }

                result.Status = ActionStatus.Ok;
                result.Data   = task.ToModel();
            }
            return(result);
        }
Exemplo n.º 22
0
        public async Task <ActionResult> Delete(string taskItemId, TaskItemModel taskItemModel)
        {
            try
            {
                var taskItemService = new TaskItemService(Session["MicrosoftAccessToken"] as string);
                var taskItem        = await taskItemService.GetTaskItemById(taskItemModel.TaskItemId);

                taskItem.IsDeleted = true;

                await taskItemService.UpdateTaskItem(taskItem);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 23
0
        public ResultEntity <TaskItem> UpdateTask(TaskItemModel task)
        {
            ResultEntity <TaskItem> result = new ResultEntity <TaskItem>();
            var taskItem = repository.Get(task.Id);

            if (taskItem != null)
            {
                taskItem.Name        = task.Name;
                taskItem.Priority    = task.Priority;
                taskItem.Description = task.Description;

                repository.Update(taskItem);
            }
            else
            {
                result.AddError("Task item not found.");
            }

            return(result);
        }
Exemplo n.º 24
0
        public async Task <ActionResult> Create(TaskItemModel taskItemModel)
        {
            try
            {
                string accessToken     = Session["MicrosoftAccessToken"] as string;
                var    taskItem        = GetTaskItemFromModel(taskItemModel);
                var    taskItemService = new TaskItemService(accessToken);
                var    userService     = new UserService(accessToken);
                var    usrId           = await userService.GetUserId(Session["UserId"] as string, UserDomainEnum.Microsoft);

                taskItem.Id = Guid.NewGuid().ToString();
                await taskItemService.InsertTaskItem(taskItem, usrId);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Create TaskItemModel from ViewModel
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        private TaskItemModel CreateTaskItemModel(TaskItemViewModel viewModel)
        {
            var data = new TaskItemModel();

            data.Assignee.AccountId = viewModel.Assignee;
            data.Member.AccountId   = Context.CurrentAccount.AccountId;
            data.Phase.Id           = viewModel.PhaseId;
            data.Project.ProjectId  = viewModel.ProjectId;
            data.Priority           = viewModel.Priority.ToEnum <TaskPriority>();
            data.Status             = viewModel.Status.ToEnum <TaskItemStatus>();
            data.TaskDetail         = viewModel.TaskDetail;
            data.TaskCode           = viewModel.TaskCode;
            data.TaskId             = viewModel.TaskId;
            data.TaskTitle          = viewModel.TaskTitle;
            data.CreatedDate        = viewModel.CreatedDate;
            data.PercentCompleted   = viewModel.PercentCompleted;
            data.EstimateTime       = viewModel.EstimateTime;
            data.SpentTime          = viewModel.SpentTime;

            return(data);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Store data to session to serve for comparing
        /// </summary>
        /// <param name="taskData"></param>
        private void SetTaskDataToSession(TaskItemModel taskData)
        {
            TaskItemModel result = new TaskItemModel();
            var           data   = SessionManager.GetObject <List <TaskItemModel> >(SessionKey.TrackTask);

            if (data == null)
            {
                data = new List <TaskItemModel>();
            }
            else
            {
                var item = data.FirstOrDefault(c => c.TaskId == taskData.TaskId);
                if (item != null)
                {
                    data.Remove(item);
                }
            }

            data.Add(taskData);
            SessionManager.SetObject(SessionKey.TrackTask, data);
        }
Exemplo n.º 27
0
        public async Task <ActionResult> Edit(string taskItemId, TaskItemModel taskItemModel)
        {
            try
            {
                var taskItem        = GetTaskItemFromModel(taskItemModel);
                var taskItemService = new TaskItemService(Session["MicrosoftAccessToken"] as string);

                if (taskItem.IsCompleted ||
                    taskItem.TaskStatusId.Equals(((int)TaskStatusEnum.Completed).ToString()))
                {
                    taskItem.TaskStatusId = ((int)TaskStatusEnum.Completed).ToString();
                    taskItem.IsCompleted  = true;
                }
                await taskItemService.UpdateTaskItem(taskItem);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 28
0
        private void NewItem_AddClick(object sender, EventArgs e)
        {
            var textTitle = FindViewById <EditText>(Resource.Id.newTitleId);
            var textDesc  = FindViewById <EditText>(Resource.Id.newDescId);
            var itemToAdd = new TaskItemModel()
            {
                Title   = textTitle.Text,
                Descrip = textDesc.Text,
                IsDone  = false
            };

            try
            {
                var taskService = new TaskLocalService();
                taskService.Save(itemToAdd);
                Toast.MakeText(this, "Saved", ToastLength.Long).Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }

            base.OnBackPressed();
        }
        public Task <int> DeleteTaskAsync(TaskItemModel data)
        {
            var status = _database.DeleteAsync(data);

            return(status);
        }
Exemplo n.º 30
0
 /// <summary>
 /// Handles when the Delete context menu option is selected on a TaskItem. removes the
 /// TaskItem from the page.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TaskItemControl_DeleteClick(object sender, TaskItemModel e)
 {
     ModelToDelete = e;
     App.UserController.DeleteTask(this);
 }