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); }
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(); } } }
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(); }
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); }
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)); } }
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(); }
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); }
// 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)); }
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; }
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("Указанная задача не найдена"); }
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); }
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(); }
/// <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); }
/// <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 } }
/// <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); }
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()); } }
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); }
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()); } }
/// <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); }
/// <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); }
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()); } }
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); }
/// <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); }