public APIResponse.APIResponse AddTask(ManageTask model)
 {
     try
     {
         long       id   = model.Id;
         ManageTask data = _context.ManageTask.FirstOrDefault(t => t.Id == id);
         if (data == null)
         {
             _context.ManageTask.Add(model);
             _context.SaveChanges();
             if (model.Id > 0)
             {
                 response.StatusCode = StaticResource.StaticResource.successStatusCode;
                 response.data.currentCreatedTaskId = model.Id.ToString();
             }
             else
             {
                 response.StatusCode = StaticResource.StaticResource.failStatusCode;
             }
         }
         else
         {
             response.StatusCode = StaticResource.StaticResource.successStatusCode;
             response.Message    = StaticResource.StaticResource.SomethingWrong;
         }
     }
     catch (Exception ex)
     {
         response.StatusCode = StaticResource.StaticResource.failStatusCode;
         response.Message    = StaticResource.StaticResource.SomethingWrong;
     }
     return(response);
 }
 public APIResponse.APIResponse DeleteTask(long id)
 {
     try
     {
         ManageTask data = _context.ManageTask.FirstOrDefault(t => t.Id == id);
         if (data != null)
         {
             _context.ManageTask.Remove(data);
             _context.SaveChanges();
             response.StatusCode = StaticResource.StaticResource.successStatusCode;
         }
         else
         {
             response.StatusCode = StaticResource.StaticResource.failStatusCode;
             response.Message    = StaticResource.StaticResource.SomethingWrong;
         }
     }
     catch (Exception ex)
     {
         response.StatusCode = StaticResource.StaticResource.failStatusCode;
         response.Message    = StaticResource.StaticResource.SomethingWrong;
         throw;
     }
     return(response);
 }
        public async Task VerifyGetTaskFunction()
        {
            var taskObj = new ManageTask(_taskRepository.Object);

            await _manageTask.GetTask(114);

            _taskRepository.Verify(r => r.GetTask(114), Times.Once);
        }
        public async Task TestGetTaskAsync_VerifyGetAsyncCalledOnce()
        {
            var mockRepository = new Mock <ITaskRepository>();
            var manageTask     = new ManageTask(mockRepository.Object, fixture.Logger);

            var result = await manageTask.GetTaskAsync(10);

            mockRepository.Verify(r => r.GetAsync(10), Times.Once);
        }
        public async Task TestEditTaskAsync_VerifyUpdateAsyncCalledOnce()
        {
            var mockRepository = new Mock <ITaskRepository>();
            var manageTask     = new ManageTask(mockRepository.Object, fixture.Logger);
            var taskDetail     = new TaskDetail();
            var result         = await manageTask.EditTaskAsync(10, taskDetail);

            mockRepository.Verify(r => r.UpdateAsync(10, taskDetail), Times.Once);
        }
Example #6
0
 public IActionResult Update([FromBody] ManageTask model)
 {
     if (model == null)
     {
         return(BadRequest());
     }
     try
     {
         response = _IManageTask.UpdateTask(model);
         var json = JsonConvert.SerializeObject(response, _serializerSettings);
         return(new OkObjectResult(json));
     }
     catch { throw; }
 }
 public APIResponse.APIResponse UpdateTask(ManageTask model)
 {
     try
     {
         _context.ManageTask.Update(model);
         _context.SaveChanges();
         response.StatusCode = StaticResource.StaticResource.successStatusCode;
         response.data.currentCreatedTaskId = model.Id.ToString();
     }
     catch (Exception ex)
     {
         response.StatusCode = StaticResource.StaticResource.failStatusCode;
         response.Message    = StaticResource.StaticResource.SomethingWrong;
         throw;
     }
     return(response);
 }
        public void TestIsTaskValidToClose_ReturnTrueWhenTaskContainsChildTaskWhichIsNOtActive()
        {
            var mockRepository = new Mock <ITaskRepository>();
            var manageTask     = new ManageTask(mockRepository.Object, fixture.Logger);
            var taskDetail     = new TaskDetail()
            {
                Id = 1, Name = "Task 1", Priority = 20
            };

            var taskDetailsList = new List <TaskDetail>()
            {
                taskDetail,
                new TaskDetail()
                {
                    Id = 2, Name = "Task 2 ", Priority = 20, ParentId = 1, EndTask = true
                },
            };

            mockRepository.Setup(r => r.GetAllAsync()).Returns(Task.FromResult <IEnumerable <TaskDetail> >(taskDetailsList));

            var result = manageTask.IsTaskValidToClose(taskDetail);

            Assert.True(result);
        }
Example #9
0
        public void QueryTask(string taskType, string taskStatus)
        {
            currtaskType   = taskType;
            currtaskStatus = taskStatus;
            List <View_ManageModel> taskList = bllViewManage.GetModelList(taskType, taskStatus);

            ViewDataManager.TASKLISTDATA.TaskListData.Clear();
            if (taskList == null)
            {
                return;
            }
            foreach (View_ManageModel manage in taskList)
            {
                ManageTask task = new ManageTask();
                task.操作员 = manage.Manage_Operater;
                //task.结束时间 = manage.Manage_End_Time.ToString("yyyyy-MM-dd HH:mm:ss");
                //if(manage.Manage_Begin_Time!= null)
                //{
                //    task.开始时间 = ((DateTime)manage.Manage_Begin_Time).ToString("yyyyy-MM-dd HH:mm:ss");
                //}

                View_CellModel viewStartCell = bllViewCell.GetModelByChildCellID(manage.Mange_Start_Cell_ID);

                if (viewStartCell == null)
                {
                    this.View.ShowMessage("信息提示", "任务起始工位数据为空:工位号," + manage.Mange_Start_Cell_ID + ",系统错误请联系管理员!");
                    return;
                }
                if (manage.Manage_Type_Name == EnumManageTaskType.空托盘上架.ToString() ||
                    manage.Manage_Type_Name == EnumManageTaskType.架.ToString())
                {
                    task.起始位置 = viewStartCell.Cell_Name;
                }
                else if (manage.Manage_Type_Name == EnumManageTaskType.拣选下架.ToString() ||
                         manage.Manage_Type_Name == EnumManageTaskType.盘点下架.ToString() ||
                         manage.Manage_Type_Name == EnumManageTaskType.架.ToString())
                {
                    task.起始位置 = viewStartCell.WareHouse_Name + ":" + viewStartCell.Cell_Name + ":" + viewStartCell.Cell_Chlid_Position;
                }
                View_CellModel viewEndCell = bllViewCell.GetModelByChildCellID(manage.Mange_End_Cell_ID);
                if (viewEndCell == null)
                {
                    this.View.ShowMessage("信息提示", "任务终止工位数据为空:工位号," + manage.Mange_End_Cell_ID + ",系统错误请联系管理员!");
                    return;
                }
                if (manage.Manage_Type_Name == EnumManageTaskType.空托盘上架.ToString() ||
                    manage.Manage_Type_Name == EnumManageTaskType.架.ToString())
                {
                    task.终止位置 = viewEndCell.WareHouse_Name + ":" + viewEndCell.Cell_Name + ":" + viewEndCell.Cell_Chlid_Position;
                }
                else if (manage.Manage_Type_Name == EnumManageTaskType.拣选下架.ToString() ||
                         manage.Manage_Type_Name == EnumManageTaskType.盘点下架.ToString() ||
                         manage.Manage_Type_Name == EnumManageTaskType.架.ToString())
                {
                    WH_Station_LogicModel station = bllStationLogic.GetStationByIDAndType(viewEndCell.Cell_Chlid_ID, EnumCellType.架工位.ToString());
                    if (station != null)
                    {
                        task.终止位置 = station.WH_Station_Logic_Name;
                    }
                }

                task.任务类型 = manage.Manage_Type_Name;
                task.任务状态 = manage.Mange_Status;
                task.托盘条码 = manage.Mange_Stock_Barcode;
                //if(manage.Manage_Begin_Time!= null)
                //{
                //    task.开始时间 = manage.Manage_Begin_Time.ToString();
                //}
                if (manage.Mange_CreateTime != null)
                {
                    task.创建时间 = manage.Mange_CreateTime.ToString();
                }

                if (manage.Manage_End_Time != null)
                {
                    task.完成时间 = manage.Manage_End_Time.ToString();
                }

                ViewDataManager.TASKLISTDATA.TaskListData.Add(task);
            }
        }