Example #1
0
 public Todo(int id, string task, DateTime dueDate, TaskStatusEnum status)
 {
     Id      = id;
     Task    = task;
     DueDate = dueDate;
     Status  = status;
 }
        public async System.Threading.Tasks.Task <IEnumerable <Task> > GetTasksByUserRoleAsync(IEnumerable <string> roles)
        {
            TaskStatusEnum accessLevel = ToStatus(roles);
            var            tasks       = await Find(task => (task.Status & accessLevel) == task.Status);

            return(tasks);
        }
Example #3
0
        public static TaskStatusEnum Parse(this TaskStatusEnum enumeration, string input)
        {
            if (input == "Active" || int.Parse(input) == (int)TaskStatusEnum.Active)
            {
                return(TaskStatusEnum.Active);
            }
            if (input == "Started" || int.Parse(input) == (int)TaskStatusEnum.Started)
            {
                return(TaskStatusEnum.Started);
            }
            if (input == "Resolved" || int.Parse(input) == (int)TaskStatusEnum.Resolved)
            {
                return(TaskStatusEnum.Resolved);
            }
            if (input == "Closed" || int.Parse(input) == (int)TaskStatusEnum.Closed)
            {
                return(TaskStatusEnum.Closed);
            }
            if (input == "Removed" || int.Parse(input) == (int)TaskStatusEnum.Removed)
            {
                return(TaskStatusEnum.Removed);
            }

            throw new ArgumentException("TaskStatusEnum.Parse input argument invalid!");
        }
Example #4
0
        public void SetStatus(TaskStatusEnum status)
        {
            this.Status = status;

            this.Validate();

            this.Project.UpdateTask(this);
        }
Example #5
0
 public bool Equals(TaskStatusEnum obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value));
 }
Example #6
0
 public Todo(SqlDataReader reader)
 {
     Id      = reader.GetInt32(reader.GetOrdinal("Id"));
     Task    = reader.GetString(reader.GetOrdinal("Task"));
     DueDate = Convert.ToDateTime(reader.GetDateTime(reader.GetOrdinal("DueDate")));
     TaskStatusEnum.TryParse(reader.GetString(reader.GetOrdinal("Status")), out _status);
     Status = _status;
 }
Example #7
0
        public TaskItem ChangeStatus(int TaskId, TaskStatusEnum status)
        {
            TaskItem task = _taskRepository.FirstOrDefault(TaskId);

            if (task == null)
            {
                return(null);
            }
            task.Status = status;
            _taskRepository.Update(task);
            return(task);
        }
Example #8
0
 public Task(Guid id, string description, string longDescription, DateTime createdDate, DateTime deadLine, User assignee, User reporter, Project project, TaskStatusEnum status)
 {
     Id              = id;
     Description     = description;
     LongDescription = longDescription;
     CreatedDate     = createdDate;
     DeadLine        = deadLine;
     Assignee        = assignee;
     Reporter        = reporter;
     Status          = status;
     Project         = project;
     State           = DomainState.FROM_DB;
 }
Example #9
0
        private async Task CreateImportLogMessage(IDal <ImportLog, ImportLogModel> dalImportLog, int logId, UserToken userToken,
                                                  string message, TaskStatusEnum status)
        {
            var logItem = dalImportLog.GetById(logId, userToken);

            logItem.Status = status;
            if (status == TaskStatusEnum.Failed || status == TaskStatusEnum.Cancelled || status == TaskStatusEnum.Completed)
            {
                logItem.Completed = DateTime.UtcNow;
            }
            logItem.Messages.Add(new ImportLogMessageModel()
            {
                Message = message
            });
            await dalImportLog.Update(logItem, userToken);
        }
Example #10
0
        public static void AddUnreads(long taskNum, long curUserNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), taskNum, curUserNum);
                return;
            }
            //if the task is done, don't add unreads
            string         command      = "SELECT TaskStatus,UserNum FROM task WHERE TaskNum = " + POut.Long(taskNum);
            DataTable      table        = Db.GetTable(command);
            TaskStatusEnum taskStatus   = (TaskStatusEnum)PIn.Int(table.Rows[0]["TaskStatus"].ToString());
            long           userNumOwner = PIn.Long(table.Rows[0]["UserNum"].ToString());

            if (taskStatus == TaskStatusEnum.Done)           //
            {
                return;
            }
            //Set it unread for the original owner of the task.
            if (userNumOwner != curUserNum)           //but only if it's some other user
            {
                SetUnread(userNumOwner, taskNum);
            }
            //Then, for anyone subscribed
            long userNum;

            //task subscriptions are not cached yet, so we use a query.
            //Get a list of all subscribers to this task
            command = "SELECT tasksubscription.UserNum "
                      + "FROM tasksubscription,taskancestor,tasklist "
                      + "WHERE taskancestor.TaskListNum=tasklist.TaskListNum "
                      + "AND taskancestor.TaskNum = " + POut.Long(taskNum) + " "
                      + "AND tasksubscription.TaskListNum=tasklist.TaskListNum";
            table = Db.GetTable(command);          //Crud.TaskSubscriptionCrud.SelectMany(
            for (int i = 0; i < table.Rows.Count; i++)
            {
                userNum = PIn.Long(table.Rows[i]["UserNum"].ToString());
                if (userNum == userNumOwner)
                {
                    continue;                    //already set
                }
                if (userNum == curUserNum)       //If the current user is subscribed to this task.
                {
                    continue;                    //User has obviously already read it.
                }
                SetUnread(userNum, taskNum);     //This no longer results in duplicates like it used to
            }
        }
        public string GetTaskStatusName(TaskStatusEnum item)
        {
            List <string> result = new List <string>();

            foreach (var value in Enum.GetValues <TaskStatusEnum>())
            {
                if ((item & value) == value)
                {
                    result.Add(value.GetType()
                               .GetMember(value.ToString())
                               .First()
                               .GetCustomAttribute <DisplayAttribute>()
                               ?.GetName());
                }
            }
            return(String.Join(", ", result));
        }
Example #12
0
        public static ITaskProfile GetTaskProfile(TaskStatusEnum taskStatus)
        {
            switch (taskStatus)
            {
            case TaskStatusEnum.Completed:
                return(new CompletedTaskProfile());

            case TaskStatusEnum.Obsolete:
                return(new ObsoleteTaskProfile());

            case TaskStatusEnum.OnHold:
                return(new OnHoldTaskProfile());

            case TaskStatusEnum.InProgress:
                return(new InProgressTaskProfile());

            default:
                return(new DefaultTaskProfile());
            }
        }
        private TaskStatusEnum ToStatus(IEnumerable <string> roles)
        {
            TaskStatusEnum status = 0;

            foreach (var role in roles)
            {
                status |= role switch
                {
                    RoleEnum.Assembler => TaskStatusEnum.Montage,
                    RoleEnum.Collector => TaskStatusEnum.Assembly,
                    RoleEnum.OrderPicker => TaskStatusEnum.Equipment,
                    RoleEnum.Shipper => TaskStatusEnum.Warehouse,
                    RoleEnum.Tuner => TaskStatusEnum.Customization,
                    RoleEnum.Validating => TaskStatusEnum.Validate,
                    RoleEnum.Admin => (TaskStatusEnum)int.MaxValue,
                    _ => 0
                };
            }
            return(status);
        }
Example #14
0
        ///<summary>Creates a TaskSubscription, dateTimeEntry will be DateTime.Now if not specified.</summary>
        public static Task CreateTask(long taskListNum          = 0, long keyNum = 0, string descript = "",
                                      TaskStatusEnum taskStatus = TaskStatusEnum.New, bool isRepeating        = false, TaskDateType dateType = TaskDateType.None, long fromNum       = 0,
                                      TaskObjectType objectType = TaskObjectType.None, DateTime dateTimeEntry = new DateTime(), long userNum = 0, bool isUnread                      = false, string parentDesc = "", string patientName = "",
                                      long priorityDefNum       = 0, string reminderGroupId = "", TaskReminderType reminderType = TaskReminderType.NoReminder, int reminderFrequency = 0)
        {
            if (dateTimeEntry == DateTime.MinValue)
            {
                dateTimeEntry = DateTime.Now;
            }
            Task task = new Task
            {
                TaskListNum       = taskListNum,
                DateTask          = DateTime.MinValue,
                KeyNum            = keyNum,
                Descript          = descript,
                TaskStatus        = taskStatus,
                IsRepeating       = isRepeating,
                DateType          = dateType,
                FromNum           = fromNum,
                ObjectType        = objectType,
                DateTimeEntry     = dateTimeEntry,
                UserNum           = userNum,
                DateTimeFinished  = DateTime.MinValue,
                IsUnread          = isUnread,
                ParentDesc        = parentDesc,
                PatientName       = patientName,
                PriorityDefNum    = priorityDefNum,
                ReminderGroupId   = reminderGroupId,
                ReminderType      = reminderType,
                ReminderFrequency = reminderFrequency,
                DateTimeOriginal  = DateTime.Now
            };

            Tasks.Insert(task);
            task = Tasks.GetOne(task.TaskNum);          //Make sure task matches Db. Avoids problems with DateTime columns.
            return(task);
        }
Example #15
0
        private void DownloadFiles()
        {
            //determina i task da eseguire
            TaskStatusEnum filter = TaskStatusEnum.Queued;

#if LOCALTEST
#warning LOCALTEST - TaskStatusEnum.Done
            filter = TaskStatusEnum.DoneWithErrors;
#endif
            //scarica files
            IEnumerable <TaskHeader> tasks = FacadeFactory.Instance.TaskHeaderFacade.GetByTypeAndStatus((TaskTypeEnum)100, filter).ToList();
            foreach (TaskHeader task in tasks)
            {
                try
                {
                    FileLogger.Debug(this.Name, String.Format("{0} {1} {2} {3}", this.importer, task, this.Parameters, this.Parameters.DropFolder));
                    this.importer.DownloadFile(task, this.Parameters.DropFolder);
                }
                catch (Exception ex)
                {
                    FileLogger.Error(this.Name, String.Format("Errore in DownloadFiles: Task.Id:{0} - Message: {1} - StackTrace: {2}", task.Id, ex.Message, ex.StackTrace));
                }
            }
        }
Example #16
0
		public ToClientStatusParam(TaskStatusEnum Status)
			: this(null, Status)
		{
		}
Example #17
0
        public static void AddUnreads(long taskNum, long curUserNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), taskNum, curUserNum);
                return;
            }
            //if the task is done, don't add unreads
            string command = "SELECT TaskStatus,UserNum,ReminderGroupId,DateTimeEntry," + DbHelper.Now() + " DbTime "
                             + "FROM task WHERE TaskNum = " + POut.Long(taskNum);
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;                //only happens when a task was deleted by one user but left open on another user's computer.
            }
            TaskStatusEnum taskStatus   = (TaskStatusEnum)PIn.Int(table.Rows[0]["TaskStatus"].ToString());
            long           userNumOwner = PIn.Long(table.Rows[0]["UserNum"].ToString());

            if (taskStatus == TaskStatusEnum.Done)           //
            {
                return;
            }
            //Set it unread for the original owner of the task.
            if (userNumOwner != curUserNum)           //but only if it's some other user
            {
                SetUnread(userNumOwner, taskNum);
            }
            //Set it for this user if a future repeating task, so it will be new when "due".  Doing this here so we don't check every row below.
            //Only for future dates because we don't want to mark as new if it was already "due" and you added a note or something.
            if ((PIn.String(table.Rows[0]["ReminderGroupId"].ToString()) != "") &&      //Is a reminder
                (PIn.DateT(table.Rows[0]["DateTimeEntry"].ToString()) > PIn.DateT(table.Rows[0]["DbTime"].ToString()))) //Is "due" in the future by DbTime
            {
                SetUnread(curUserNum, taskNum);                                                                         //Set unread for current user only, other users dealt with below.
            }
            //Then, for anyone subscribed
            long userNum;
            bool isUnread;

            //task subscriptions are not cached yet, so we use a query.
            //Get a list of all subscribers to this task
            command  = @"SELECT 
									tasksubscription.UserNum,
									(CASE WHEN taskunread.UserNum IS NULL THEN 0 ELSE 1 END) IsUnread
								FROM tasksubscription
								INNER JOIN tasklist ON tasksubscription.TaskListNum = tasklist.TaskListNum 
								INNER JOIN taskancestor ON taskancestor.TaskListNum = tasklist.TaskListNum 
									AND taskancestor.TaskNum = "                                     + POut.Long(taskNum) + " ";
            command += "LEFT JOIN taskunread ON taskunread.UserNum = tasksubscription.UserNum AND taskunread.TaskNum=taskancestor.TaskNum";
            table    = Db.GetTable(command);
            List <long> listUserNums = new List <long>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                userNum  = PIn.Long(table.Rows[i]["UserNum"].ToString());
                isUnread = PIn.Bool(table.Rows[i]["IsUnread"].ToString());
                if (userNum == userNumOwner ||          //already set
                    userNum == curUserNum ||                  //If the current user is subscribed to this task. User has obviously already read it.
                    listUserNums.Contains(userNum) ||
                    isUnread)                        //Unread currently exists
                {
                    continue;
                }
                listUserNums.Add(userNum);
            }
            SetUnreadMany(listUserNums, taskNum);           //This no longer results in duplicates like it used to
        }
Example #18
0
 protected void ChangeTaskStatus(TaskDto task, TaskStatusEnum status)
 {
     task.Status = status;
     dataAccessor.update(task);
 }
Example #19
0
 public TaskItemDTO ChangeTaskStatus(int TaskId, TaskStatusEnum newstatus)
 {
     return(_objectMapper.Map <TaskItemDTO>(_taskManager.ChangeStatus(TaskId, newstatus)));
 }
Example #20
0
		public ToClientStatusParam(
			object[] DescriptionPrefix,
			TaskStatusEnum Status = TaskStatusEnum.None)
			:
			base(DescriptionPrefix)
		{
			this.Status = Status;
		}
Example #21
0
		public ToClientStatusParam(
			object DescriptionPrefix,
			TaskStatusEnum Status = TaskStatusEnum.None)
			:
			this(new object[] { DescriptionPrefix }, Status)
		{
		}
Example #22
0
 public TaskStatus(TaskStatusEnum taskStatus)
 {
     Id   = (int)taskStatus;
     Name = taskStatus.ToString();
 }
        /// <summary>
        /// Begins the task process
        /// <para>A task process will loop until the underlying function completes or fails.</para>
        /// <para>A process can be paused and resumed while it is in base class's body.  Once control passes to the underlying function
        /// , it is up to the task's designer to implement properly;  the framework does provide sample tasks however.</para>
        /// <para>A task designer has the option to implement a task to run continuously or repeatedly after stopping.</para>
        /// </summary>
        public void Start()
        {
            using (LoggingContext lc = new LoggingContext(string.Format("ThreadPool: {0}; TaskProcess QueueCode: {1}"
                                                                        , _threadPoolLabel, _taskQueueCode)))
            {
                try
                {
                    // loop continuously until process has not completed
                    while (_processStatus == ProcessStatusEnum.Ready ||
                           _processStatus == ProcessStatusEnum.Working)
                    {
                        // handle paused (and resume) and stop events
                        if (_processStatus == ProcessStatusEnum.Paused)
                        {
                            WaitHandle[] waithandles = new WaitHandle[3];
                            waithandles[0] = _stopEvent;
                            waithandles[1] = _resumeEvent;
                            int waitResult = WaitHandle.WaitAny(waithandles);
                            if (waitResult == 0)
                            {
                                _stopEvent.Reset();
                            }
                            if (waitResult == 1)
                            {
                                _resumeEvent.Reset();
                            }
                        }

                        // make call to task's function body in seperate assembly.
                        // pass in the parameters
                        TaskStatusEnum taskStatus = TaskFunctionBody(_parameters);
                        // if task has completed or failed, then this process is over
                        // otherwise continue working and calling function again
                        if (taskStatus == TaskStatusEnum.Completed ||
                            taskStatus == TaskStatusEnum.Failed)
                        {
                            if (taskStatus == TaskStatusEnum.Completed)
                            {
                                _processStatus = ProcessStatusEnum.Completed;
                            }
                            if (taskStatus == TaskStatusEnum.Failed)
                            {
                                _processStatus = ProcessStatusEnum.Failed;
                            }
                        }

                        _daMgr.loggingMgr.Trace("Working", enumTraceLevel.Level5);
                    }
                }
                catch
                {
                    // If there are any unhandled exceptions, then the task is considered failed
                    // and the process will terminate.
                    _processStatus = ProcessStatusEnum.Failed;
                }
                finally
                {
                    // whether it had succeeded or failed, we let delegate know
                    // that task completed and pass in the status
                    _taskCompletedHandler(_taskQueueCode, _processStatus);
                }
                _daMgr.loggingMgr.Trace("Finished", enumTraceLevel.Level5);
            }
        }