示例#1
0
        public static Entity.TaskFeedback Run(Entity.Task task, IJudgeNodeCallback callback)
        {
            var freeCore = GetFreeCore();

            if (CoreStatusUpdated != null)
            {
                CoreStatusUpdated(null, null);
            }

            freeCore.CurrentTask = task;
            TaskHelper helper = new TaskHelper()
            {
                Task         = task,
                CenterServer = callback
            };

            helper.Start();
            freeCore.Status = CoreStatus.Free;

            if (CoreStatusUpdated != null)
            {
                CoreStatusUpdated(null, null);
            }
            return(helper.Feedback);
        }
示例#2
0
        /// <summary>
        /// 外发任务 物料编号 生成外发采购物料时引用
        /// </summary>
        /// <param name="_taskID"></param>
        /// <returns></returns>
        public string GetwfTaskPartNum(int _taskID)
        {
            WHPart _wfwhPart = GetwfTaskPart(_taskID);

            Entity.Task _task = _context.Tasks.Where(t => t.TaskID == _taskID).FirstOrDefault();
            var         _sObj = _context.Sequences.Where(s => s.Name == "WFPartNum").FirstOrDefault();

            if (_sObj != null)
            {
                if (_wfwhPart != null)
                {
                    return(_wfwhPart.PartNum);
                }
                else
                {
                    List <WHPart> _wfparts = GetwfWHPartByMoldNum(_task.MoldNumber).OrderBy(p => p.CreDate).ToList();
                    int           num;
                    if (_wfparts.Count > 0)
                    {
                        string _partNums    = _wfparts.Select(p => p.PartNum).Max();
                        var    _partNumArry = _partNums.Split('-');
                        num = Convert.ToInt32(_partNumArry[1].Substring(1, _partNumArry[1].Length - 1)) + 1;
                    }
                    else
                    {
                        num = 1;
                    }
                    string _fLetter  = _sObj.NameConvension.Substring(0, 1);                               //Z
                    string _ZeroList = _sObj.NameConvension.Substring(1, _sObj.NameConvension.Length - 1); //000
                    string _strNum   = string.Format("{0:" + _ZeroList + "}", num);                        //001
                    return(_task.MoldNumber + "-" + _fLetter + _strNum);                                   //xxxxxx-Z001
                }
            }
            return(null);
        }
        public void AddTask()
        {
            Entity.Task     task     = CollectTaskInformation();
            TasksRepository taskRepo = new TasksRepository("tasks.txt");

            taskRepo.Save(task);
            Console.WriteLine("Task saved successfully!!");
            Console.ReadKey(true);
        }
示例#4
0
        public void Show(Entity.Task task)
        {
            while (true)
            {
                TimeLogCommentManagerEnum choice = RenderMenuTaskOptions();

                try
                {
                    switch (choice)
                    {
                    case TimeLogCommentManagerEnum.SelectTimeLog:
                    {
                        GetAll();
                        break;
                    }

                    case TimeLogCommentManagerEnum.ViewTimeLog:
                    {
                        //View();
                        break;
                    }

                    case TimeLogCommentManagerEnum.InsertTimeLog:
                    {
                        Add(task);
                        break;
                    }

                    case TimeLogCommentManagerEnum.UpdateTimeLog:
                    {
                        // Update();
                        break;
                    }

                    case TimeLogCommentManagerEnum.DeleteTimeLog:
                    {
                        //  Delete();
                        break;
                    }

                    case TimeLogCommentManagerEnum.Exit:
                    {
                        TaskManagerView taskView = new TaskManagerView();
                        taskView.Show();
                        return;
                    }
                    }
                }
                catch (Exception ex)
                {
                    Console.Clear();
                    Console.WriteLine(ex.Message);
                    Console.ReadKey(true);
                }
            }
        }
示例#5
0
        /// <summary>
        /// 根据任务获取该任务 外发零件 PartName唯一
        /// </summary>
        /// <param name="_taskID"></param>
        /// <returns></returns>
        public WHPart GetwfTaskPart(int _taskID)
        {
            Entity.Task _task       = _context.Tasks.Where(t => t.TaskID == _taskID).FirstOrDefault();
            string      _wfPartname = _task.TaskName + "_" + _task.ProcessName + "(V" + string.Format("{0:00}", _task.Version) + ")";
            WHPart      _whpart     = _context.WHParts.Where(p => p.PartName == _wfPartname && p.Enable == true).FirstOrDefault();

            if (_whpart != null)
            {
                return(_whpart);
            }
            return(null);
        }
示例#6
0
        public void Notify(User user, Entity.Task task)
        {
            //Thread.Sleep(TimeSpan.FromSeconds(10));

            Log log = new Log();

            log.Date    = DateTime.Now;
            log.Level   = "Info";
            log.Logger  = "EMail Notifier";
            log.Message = "UserId:" + user.Id + " TaskId:" + task.Id;
            log.Thread  = string.Empty;

            LogRepository logRepo = new LogRepository();
            string        Error   = string.Empty;

            logRepo.Add(log, out Error);
        }
示例#7
0
        public void AddComment()
        {
            Console.Clear();
            Comment comment = new Comment();

            Console.Write("Enter id of the related task: ");
            int  inputRelatedTaskId = 0;
            bool isInt = int.TryParse(Console.ReadLine(), out inputRelatedTaskId);

            while (isInt == false)
            {
                Console.WriteLine("Only integers can be entered for task ID's!!");
                Console.ReadKey();
                return;
            }
            TasksRepository    taskRepo = new TasksRepository("tasks.txt");
            List <Entity.Task> tasks    = taskRepo.GetAll(Task => Task.Id == inputRelatedTaskId);

            if (tasks.Count == 0)
            {
                Console.WriteLine($"No task with id {inputRelatedTaskId} exists!! ");
                Console.ReadKey(true);
                return;
            }
            Entity.Task task = tasks[0];
            if (!(task.AssigneeId == AuthenticationService.LoggedUser.Id || task.CreatorId == AuthenticationService.LoggedUser.Id))
            {
                Console.WriteLine("You can only add comments to tasks which you created or which you are assigned to!");
                Console.ReadKey(true);
                return;
            }

            comment.RelatedTaskId = inputRelatedTaskId;
            comment.CreatorId     = AuthenticationService.LoggedUser.Id;
            Console.Write("Enter comment: ");
            comment.CommentText = Console.ReadLine();
            comment.CommentDate = DateTime.Now;
            CommentsRepository commentRepo = new CommentsRepository("comments.txt");

            commentRepo.Save(comment);
            Console.WriteLine("Comment saved successfully!");
            Console.ReadKey();
        }
示例#8
0
        private void Add(Entity.Task task)
        {
            Console.Clear();

            TimeLog timeLog = new TimeLog();

            UserRepository userRepository = new UserRepository("users.txt");
            var            all            = userRepository.GetAll();

            for (int i = 0; i < all.Count; i++)
            {
                if (i % 5 == 0 && i != 0)
                {
                    Console.Write($"\n\rId {all[i].Id} - {all[i].Username}\t");
                }
                else
                {
                    Console.Write($"Id {all[i].Id} - {all[i].Username}\t");
                }
            }
            Console.WriteLine();


            Console.WriteLine("Add new TimeLog:");

            Console.Write("User id: ");
            timeLog.UserId = Convert.ToInt32(Console.ReadLine());

            Console.Write("Hours of work: ");
            timeLog.HoursWork = Convert.ToInt32(Console.ReadLine());

            timeLog.DateOfCreation = DateTime.Now;
            timeLog.TaskId         = task.Id;

            TimeLogRepository timeLogRepository = new TimeLogRepository("timelogs.txt");

            timeLogRepository.Save(timeLog);

            Console.WriteLine("TimeLog saved successfully.");
            Console.ReadKey(true);
        }
示例#9
0
 public Guid SaveTask(TaskDto dto)
 {
     Entity.Task entity;
     if (dto.TaskId == Guid.Empty)
     {
         entity        = new Entity.Task();
         entity.TaskId = Guid.NewGuid();
         Context.Add(entity);
     }
     else
     {
         entity = Context.Task.FirstOrDefault(x => x.TaskId == dto.TaskId);
     }
     entity.Title       = dto.Title;
     entity.Description = dto.Description;
     entity.PlanTime    = dto.PlanTime;
     entity.Deadline    = dto.Deadline;
     entity.IsImportant = dto.IsImportant;
     entity.IsFinish    = dto.IsFinish;
     Context.SaveChanges();
     return(entity.TaskId);
 }
示例#10
0
        public VMAddTask(Employee selectedEmployee, Employee referenceEmployee)
        {
            SelectedActivity = new Activity();
            CurrentTask      = new Entity.Task()
            {
                Id = Guid.NewGuid(), Activity = new Activity(), ListWorkTime = new ObservableCollection <WorkTime>()
            };
            ListSoftware    = DAL.GetListSoftware();
            CurrentEmployee = selectedEmployee;
            var tempList = CurrentEmployee.Job.ListActivity.Distinct().ToList();

            foreach (Activity activity in referenceEmployee.Job.ListActivity.Where(a => a.IsAnnex == true).ToList())
            {
                if (referenceEmployee.ListTask.Where(t => t.Activity.Code == activity.Code).Any())
                {
                    tempList.Remove(activity);
                }
            }
            ListActivity     = new ObservableCollection <Activity>(tempList.Distinct().ToList());
            SelectedActivity = ListActivity.FirstOrDefault();
            SelectedSoftware = ListSoftware.FirstOrDefault();
            SelectedVersion  = SelectedSoftware.ListVersion.FirstOrDefault();
            SelectedModule   = SelectedSoftware.ListModule.FirstOrDefault();
        }
示例#11
0
 private void AddTask()
 {
     if (!SelectedActivity.IsAnnex)
     {
         CurrentTask = new TaskProd()
         {
             Id                     = CurrentTask.Id,
             ListWorkTime           = new ObservableCollection <WorkTime>(),
             Label                  = CurrentTask.Label,
             Description            = CurrentTask.Description,
             Software               = SelectedSoftware,
             Version                = SelectedVersion,
             Module                 = SelectedModule,
             PredictedTime          = float.Parse(SelectedPredictedTime),
             EstimatedRemainingTime = float.Parse(SelectedPredictedTime)
         };
     }
     CurrentTask.Activity = SelectedActivity;
     CurrentEmployee.ListTask.Add(CurrentTask);
     CurrentTask = new Entity.Task()
     {
         Id = Guid.NewGuid(), Activity = new Activity(), ListWorkTime = new ObservableCollection <WorkTime>()
     };
 }
        public Entity.Task CollectTaskInformation()
        {
            Entity.Task task = new Entity.Task();
            Console.Clear();
            Console.Write("Enter task title: ");
            task.Title = Console.ReadLine();

            Console.Write("Enter description: ");
            task.Description = Console.ReadLine();

            Console.Write("Evaluated time to complete (in hours): ");
            int  inputEvalTime = 0;
            bool isInt         = int.TryParse(Console.ReadLine(), out inputEvalTime);

            while (isInt == false)
            {
                Console.WriteLine("Only integer numbers can be entered for hours!!");
                Console.Write("Evaluated time to complete (in hours): ");
                isInt = int.TryParse(Console.ReadLine(), out inputEvalTime);
            }
            task.EvaluatedTimeToComplete = inputEvalTime;

inputAssigneeId:
            Console.Write("Enter id of the assignee: ");
            int  inputAssigneeId = 0;
            bool isInt1          = int.TryParse(Console.ReadLine(), out inputAssigneeId);

            while (isInt1 == false)
            {
                Console.WriteLine("Only integers can be entered for ID's!!");
                Console.Write("Enter id of the assignee: ");
                isInt1 = int.TryParse(Console.ReadLine(), out inputAssigneeId);
            }
            UsersRepository userRepo = new UsersRepository("users.txt");

            if (userRepo.CheckEntityExistence(User => User.Id == inputAssigneeId) == false)
            {
                Console.WriteLine($"A user with id {inputAssigneeId} doesn't exist!!");
                Console.ReadKey(true);
                goto inputAssigneeId;
            }
            task.AssigneeId   = inputAssigneeId;
            task.CreatorId    = AuthenticationService.LoggedUser.Id;
            task.CreationDate = DateTime.Now;
            task.LastEditDate = DateTime.Now;
            Console.WriteLine("Enter one of the options below: \"A\" - Awaiting Execution; \"I\" - In Execution;");
            Console.Write("Task State: ");
            string inputTaskState = Console.ReadLine();

            switch (inputTaskState.ToUpper())
            {
            case "A":
                task.TaskState = TaskState.AwaitingExecution;
                break;

            case "I":
                task.TaskState = TaskState.InExecution;
                break;

            default:
                Console.WriteLine("Invalid input!! Use one of the available options above!!");
                Console.ReadKey(true);
                break;
            }

            return(task);
        }
示例#13
0
        /// <summary>
        /// Rempli la liste passée en paramètre avec la liste de taches décrite dans le SqlDataReader
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="listTask"></param>
        private static void DataReaderToListTask(SqlDataReader reader, List <Entity.Task> listTask)
        {
            while (reader.Read())
            {
                // Si la liste des taches de l'employé courrant est vide ou si la tache est déjà dans la liste ajouter une nouvelle activité
                if (!listTask.Any() || !listTask.Where(t => t.Id == (Guid)reader["IdTache"]).Any())
                {
                    Entity.Task task;
                    if ((bool)reader["Annexe"])
                    {
                        task = new Entity.Task();
                    }
                    else
                    {
                        task = new TaskProd()
                        {
                            Number = (int)reader["Numero"],
                            EstimatedRemainingTime = (float)reader["DureeRestanteEstimee"],
                            PredictedTime          = (float)reader["DureePrevue"],
                            Module = new Module()
                            {
                                Code = (string)reader["CodeModule"]
                            },
                            Version = new Entity.Version()
                            {
                                Number = (float)reader["NumeroVersion"]
                            },
                            Software = new Software()
                            {
                                Code = (string)reader["CodeLogiciel"]
                            }
                        };
                    }

                    task.Id = (Guid)reader["IdTache"];
                    if (reader["Description"] != DBNull.Value)
                    {
                        task.Description = (string)reader["Description"];
                    }
                    task.Label = (string)reader["Libelle"];

                    task.Activity = new Activity()
                    {
                        Code    = (string)reader["CodeActiviteTache"],
                        Label   = (string)reader["LibelleActiviteTache"],
                        IsAnnex = (bool)reader["AnnexeActiviteTache"]
                    };
                    task.ListWorkTime = new ObservableCollection <WorkTime>();

                    listTask.Add(task);
                }

                // Si il n'y a pas de temps de travail à ajouter, passer à la ligne suivante
                if (reader["DateTravail"] == DBNull.Value)
                {
                    continue;
                }

                Entity.Task currentTask = listTask.Where(t => t.Id == (Guid)reader["IdTache"]).First();

                // Si la liste des temps de travail de la tache courrante est vide ou si la date du temps de travail
                // est différente de celle du temps de travail précédent, ajouter un nouveau temps de travail
                if (!currentTask.ListWorkTime.Any() ||
                    currentTask.ListWorkTime.Last().WorkingDate != (DateTime)reader["DateTravail"])
                {
                    WorkTime workTime = new WorkTime()
                    {
                        Hours        = (float)reader["Heures"],
                        Productivity = (float)reader["TauxProductivite"],
                        WorkingDate  = (DateTime)reader["DateTravail"]
                    };

                    currentTask.ListWorkTime.Add(workTime);
                }
            }
        }