Exemplo n.º 1
0
        public TaskProxy SetDueDate(int taskID, string data)
        {
            LoginUser     loginUser   = TSAuthentication.GetLoginUser();
            Task          task        = Tasks.GetTask(loginUser, taskID);
            StringBuilder description = new StringBuilder();
            TaskJsonInfo  info        = Newtonsoft.Json.JsonConvert.DeserializeObject <TaskJsonInfo>(data);
            DateTime      dueDate     = (DateTime)info.DueDate;

            if (task.DueDate == null)
            {
                description.Append(String.Format("Changed Due Date from \"{0}\" to \"{1}\".", "Unassigned", (dueDate).ToString()));
            }
            else
            {
                description.Append(String.Format("Changed Due Date from \"{0}\" to \"{1}\".", ((DateTime)task.DueDate).ToString(), (dueDate).ToString()));
            }
            task.DueDate = DataUtils.DateToUtc(loginUser, dueDate);
            task.Collection.Save();
            TaskLogs.AddTaskLog(loginUser, taskID, description.ToString());

            if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(task.GetProxy());
        }
Exemplo n.º 2
0
        public TaskLogProxy[] LoadHistory(int taskID, int start)
        {
            TaskLogs taskLogs = new TaskLogs(TSAuthentication.GetLoginUser());

            taskLogs.LoadByTaskID(taskID, start);

            return(taskLogs.GetTaskLogProxies());
        }
Exemplo n.º 3
0
 public void CreateTaskLogs(TaskLogs entity)
 {
     using (var dbScope = _dbScopeFactory.Create())
     {
         var db = dbScope.DbContexts.Get <FireProjDbContext>();
         db.TaskLogs.Add(entity);
         db.SaveChanges();
     }
 }
Exemplo n.º 4
0
        // Note that we ignore parameter 'count' because we only want to load 1 page at a time
        protected async override Task <IList <object> > LoadMoreItemsOverrideAsync(System.Threading.CancellationToken c, uint count)
        {
            int page = this.Count / APICommon.FETCH_SIZE;

            TaskLogsListAPI data = await TaskLogs.Get(page, APICommon.FETCH_SIZE);

            this.count = data.recordCount;

            return(data.data.ToArray());
        }
Exemplo n.º 5
0
        public static string GetTaskLog(RestCommand command, int taskLogID)
        {
            TaskLog taskLog = TaskLogs.GetTaskLog(command.LoginUser, taskLogID);

            if (taskLog.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            return(taskLog.GetXml("TaskLog", true));
        }
 /// <summary>
 /// 新增任务记录
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public IHttpActionResult Post([FromBody] TaskLogs entity)
 {
     if (ModelState.IsValid == false)
     {
         return(BadRequest(ModelState));
     }
     entity.CreatorId   = UserHelper.CurrUserInfo.UserId;
     entity.CreatorName = UserHelper.CurrUserInfo.NickName;
     _taskLogsSvc.CreateTaskLogs(entity);
     return(Ok());
 }
Exemplo n.º 7
0
 public override List <TaskSearchMethod> CreateTaskSearchMethods(TaskLogs logs)
 {
     return(logs.Logs
            .Where(x => (TaskSearchMethod == null ? true : TaskSearchMethod.IsMatched(x)))
            .Select(x => x.TaskName)
            .Distinct()
            .Select(x => new TaskSearchMethod()
     {
         TaskKeyword = x, SearchMethod = TaskSearchMethodType.PerfectMatch
     })
            .ToList());
 }
Exemplo n.º 8
0
        public void ClearReminderDate(int taskID)
        {
            LoginUser     loginUser   = TSAuthentication.GetLoginUser();
            Reminder      reminder    = Reminders.GetReminderByTaskID(loginUser, taskID);
            StringBuilder description = new StringBuilder();

            description.Append("Changed Reminder Date to None.");
            reminder.Delete();
            reminder.Collection.Save();
            TaskLogs.AddTaskLog(loginUser, taskID, "Reminder deleted");

            SendModifiedNotification(loginUser.UserID, taskID);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 打印任务日志
 /// </summary>
 public void PrintTaskLogs()
 {
     if (!AllowPrintTaskLog || TaskLogs == null || TaskLogs.Count == 0)
     {
         return;
     }
     TaskLogs.ForEach(log =>
     {
         if (!string.IsNullOrWhiteSpace(log))
         {
             Console.WriteLine(log);
         }
     });
 }
Exemplo n.º 10
0
        public ReminderProxy SetReminderDueDate(int taskID, string data)
        {
            LoginUser     loginUser       = TSAuthentication.GetLoginUser();
            Reminder      reminder        = Reminders.GetReminderByTaskID(loginUser, taskID);
            StringBuilder description     = new StringBuilder();
            Task          task            = Tasks.GetTask(loginUser, taskID);
            TaskJsonInfo  info            = Newtonsoft.Json.JsonConvert.DeserializeObject <TaskJsonInfo>(data);
            DateTime      reminderDueDate = (DateTime)info.Reminder;

            if (reminder != null)
            {
                if (reminder.DueDate == null)
                {
                    description.Append(String.Format("Changed Reminder from \"{0}\" to \"{1}\".", "Unassigned", (reminderDueDate).ToString()));
                }
                else
                {
                    description.Append(String.Format("Changed Reminder from \"{0}\" to \"{1}\".", ((DateTime)reminder.DueDate).ToString(), (reminderDueDate).ToString()));
                }
                reminder.DueDate      = DataUtils.DateToUtc(loginUser, reminderDueDate);
                reminder.IsDismissed  = false;
                reminder.HasEmailSent = false;
                reminder.Collection.Save();
                TaskLogs.AddTaskLog(loginUser, taskID, description.ToString());
            }
            else
            {
                if (reminder == null)
                {
                    if (task.UserID == null)
                    {
                        reminder = CreateReminder(loginUser, taskID, task.Name, DataUtils.DateToUtc(loginUser, reminderDueDate), false);
                    }
                    else
                    {
                        reminder = CreateReminder(loginUser, taskID, task.Name, DataUtils.DateToUtc(loginUser, reminderDueDate), false, (int)task.UserID);
                    }
                    task.ReminderID = reminder.ReminderID;
                    task.Collection.Save();
                }
            }

            if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(reminder.GetProxy());
        }
Exemplo n.º 11
0
        public static string GetTaskLogs(RestCommand command)
        {
            TaskLogs taskLogs = new TaskLogs(command.LoginUser);

            taskLogs.LoadByOrganizationID(command.Organization.OrganizationID);

            if (command.Format == RestFormat.XML)
            {
                return(taskLogs.GetXml("TaskLogs", "TaskLog", true, command.Filters));
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "Invalid data format");
            }
        }
Exemplo n.º 12
0
        public bool AddAssociation(int taskID, int refID, int refType)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();

            try
            {
                TaskAssociation taskAssociation = (new TaskAssociations(loginUser).AddNewTaskAssociation());
                taskAssociation.TaskID      = taskID;
                taskAssociation.RefID       = refID;
                taskAssociation.RefType     = refType;
                taskAssociation.DateCreated = DateTime.UtcNow;
                taskAssociation.CreatorID   = loginUser.UserID;
                taskAssociation.Collection.Save();
                string description = String.Format("{0} added task association to {1}.", TSAuthentication.GetUser(loginUser).FirstLastName, Enum.GetName(typeof(ReferenceType), refType));
                TaskLogs.AddTaskLog(loginUser, taskID, description);

                Task task = Tasks.GetTask(loginUser, taskID);
                if (task.UserID != null && loginUser.UserID != task.UserID)
                {
                    SendModifiedNotification(loginUser.UserID, task.TaskID);
                }

                if (refType == (int)ReferenceType.Contacts)
                {
                    TeamSupport.Data.User user = Users.GetUser(loginUser, refID);
                    taskAssociation             = (new TaskAssociations(loginUser).AddNewTaskAssociation());
                    taskAssociation.TaskID      = taskID;
                    taskAssociation.RefID       = user.OrganizationID;
                    taskAssociation.RefType     = (int)ReferenceType.Organizations;
                    taskAssociation.DateCreated = DateTime.UtcNow;
                    taskAssociation.CreatorID   = loginUser.UserID;
                    try
                    {
                        taskAssociation.Collection.Save();
                    }
                    catch (Exception e)
                    {
                        //TaskAssociation do not allow duplicates. This could happen when the company is already associated with the task.
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 13
0
        public void ClearDueDate(int taskID)
        {
            LoginUser     loginUser   = TSAuthentication.GetLoginUser();
            Task          task        = Tasks.GetTask(loginUser, taskID);
            StringBuilder description = new StringBuilder();

            description.Append("Changed Due Date to None.");
            task.DueDate = null;
            task.Collection.Save();
            TaskLogs.AddTaskLog(loginUser, taskID, description.ToString());

            if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }
        }
Exemplo n.º 14
0
        public int SetUser(int taskID, int value)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            Reminder reminder = Reminders.GetReminderByTaskID(loginUser, taskID);

            if (task.UserID != null && loginUser.UserID != task.UserID && value != task.UserID)
            {
                SendOldUserNotification(loginUser.UserID, (int)task.UserID, task.TaskID);
            }

            if (value != -1 && loginUser.UserID != value && value != task.UserID)
            {
                SendAssignedNotification(loginUser.UserID, task.TaskID);
            }

            //User is being set to unassigned
            if (value == -1)
            {
                if (reminder != null)
                {
                    reminder.Delete();
                    reminder.Collection.Save();
                    task.ReminderID = null;
                }
                task.UserID = null;
            }
            else
            {
                if (reminder != null)
                {
                    reminder.UserID = value;
                    reminder.Collection.Save();
                }
                task.UserID = value;
            }

            task.Collection.Save();

            User   u           = Users.GetUser(loginUser, value);
            string description = String.Format("{0} set task user to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, u == null ? "Unassigned" : u.FirstLastName);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            return(value);
        }
Exemplo n.º 15
0
        public TaskCompletionStatus SetTaskIsCompleted(int taskID, bool value)
        {
            TaskCompletionStatus result = new TaskCompletionStatus(false, value);

            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.IsComplete = value;

            //if a user is attempting to complete a task check for incomplete subtasks first
            if (value)
            {
                if (GetIncompleteSubtasks(taskID))
                {
                    result.IncompleteSubtasks = true;
                    result.Value = !value;
                    return(result);
                }
                task.DateCompleted   = DateTime.UtcNow;
                result.DateCompleted = task.DateCompleted;
            }
            else
            {
                result.IncompleteSubtasks = false;
                result.Value       = value;
                task.DateCompleted = null;
            }

            //We are clearing completion comments as they could or not be set in next call.
            task.CompletionComment = null;
            task.Collection.Save();
            string description = String.Format("{0} set task is complete to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, value);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            if (task.IsComplete && (loginUser.UserID != task.CreatorID || (task.UserID != null && loginUser.UserID != task.UserID)))
            {
                SendCompletedNotification(loginUser.UserID, task.TaskID);
            }
            else if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(result);
        }
Exemplo n.º 16
0
        public string SetDescription(int taskID, string value)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.Description = value;
            task.Collection.Save();
            string description = String.Format("{0} set task description to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, value);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            if (task.UserID != null && loginUser.UserID != task.UserID)
            {
                SendModifiedNotification(loginUser.UserID, task.TaskID);
            }

            return(value != "" ? value : "Empty");
        }
Exemplo n.º 17
0
        public TaskCompletionStatus AddTaskCompleteComment(int taskID, string comment)
        {
            LoginUser loginUser = TSAuthentication.GetLoginUser();
            Task      task      = Tasks.GetTask(loginUser, taskID);

            task.CompletionComment = comment;
            task.Collection.Save();

            //string description = String.Format(@"{0} added task complete note: ""{1}""", TSAuthentication.GetUser(loginUser).FirstLastName, comment);
            string description = String.Format(@"{0} added task complete note.", TSAuthentication.GetUser(loginUser).FirstLastName);

            TaskLogs.AddTaskLog(loginUser, taskID, description);

            TaskCompletionStatus result = new TaskCompletionStatus(false, true);

            result.DateCompleted     = task.DateCompleted;
            result.CompletionComment = task.CompletionComment;
            return(result);
        }
Exemplo n.º 18
0
        public void DeleteAssociation(int reminderID, int refID, ReferenceType refType)
        {
            try
            {
                LoginUser        loginUser    = TSAuthentication.GetLoginUser();
                TaskAssociations associations = new TaskAssociations(loginUser);
                associations.DeleteAssociation(reminderID, refID, refType);
                string description = String.Format("{0} deleted task association to {1} ", TSAuthentication.GetUser(loginUser).FirstLastName, Enum.GetName(typeof(ReferenceType), refType));
                TaskLogs.AddTaskLog(loginUser, reminderID, description);

                Reminder task = Reminders.GetReminder(loginUser, reminderID);
                if (task.UserID != null && loginUser.UserID != task.UserID)
                {
                    SendModifiedNotification(loginUser.UserID, task.ReminderID);
                }
            }
            catch (Exception ex)
            {
                DataUtils.LogException(UserSession.LoginUser, ex);
            }
        }
Exemplo n.º 19
0
 public abstract List <TaskSearchMethod> CreateTaskSearchMethods(TaskLogs logs);
Exemplo n.º 20
0
 public override List <TaskSearchMethod> CreateTaskSearchMethods(TaskLogs logs)
 {
     return(TargetTasks);
 }
Exemplo n.º 21
0
        public TaskProxy NewTask(string data)
        {
            TaskJsonInfo info      = Newtonsoft.Json.JsonConvert.DeserializeObject <TaskJsonInfo>(data);
            LoginUser    loginUser = TSAuthentication.GetLoginUser();

            Task newTask = (new Tasks(loginUser)).AddNewTask();

            newTask.ParentID       = info.ParentID;
            newTask.OrganizationID = TSAuthentication.OrganizationID;
            newTask.Name           = info.Name;
            newTask.Description    = info.Description;
            newTask.UserID         = info.UserID;
            newTask.IsComplete     = info.IsComplete;

            if (newTask.IsComplete)
            {
                newTask.DateCompleted = DateTime.UtcNow;
            }

            newTask.DueDate = DataUtils.DateToUtc(loginUser, info.DueDate);

            newTask.Collection.Save();

            if (info.Reminder != null)
            {
                Reminder reminder = null;
                if (newTask.UserID == null)
                {
                    reminder = CreateReminder(loginUser, newTask.TaskID, info.Name, DataUtils.DateToUtc(loginUser, (DateTime)info.Reminder), false);
                }
                else
                {
                    reminder = CreateReminder(loginUser, newTask.TaskID, info.Name, DataUtils.DateToUtc(loginUser, (DateTime)info.Reminder), false, (int)newTask.UserID);
                }

                if (reminder != null)
                {
                    Tasks taskHelper = new Tasks(loginUser);
                    taskHelper.LoadByTaskID(newTask.TaskID);

                    if (taskHelper.Any())
                    {
                        taskHelper[0].ReminderID = reminder.ReminderID;
                        taskHelper.Save();
                    }
                }
            }

            foreach (int ticketID in info.Tickets)
            {
                AddAssociation(newTask.TaskID, ticketID, (int)ReferenceType.Tickets);
            }

            foreach (int productID in info.Products)
            {
                AddAssociation(newTask.TaskID, productID, (int)ReferenceType.Products);
            }

            foreach (int CompanyID in info.Company)
            {
                AddAssociation(newTask.TaskID, CompanyID, (int)ReferenceType.Organizations);
            }

            foreach (int UserID in info.Contacts)
            {
                AddAssociation(newTask.TaskID, UserID, (int)ReferenceType.Contacts);
            }

            foreach (int groupID in info.Groups)
            {
                AddAssociation(newTask.TaskID, groupID, (int)ReferenceType.Groups);
            }

            foreach (int UserID in info.User)
            {
                AddAssociation(newTask.TaskID, UserID, (int)ReferenceType.Users);
            }

            foreach (int ActivityID in info.Activities)
            {
                Notes notes = new Notes(TSAuthentication.GetLoginUser());
                notes.LoadByNoteID(ActivityID);

                if (notes.Count > 0)
                {
                    var note = notes[0];
                    if (note.RefType == ReferenceType.Organizations)
                    {
                        AddAssociation(newTask.TaskID, ActivityID, (int)ReferenceType.CompanyActivity);
                    }
                    else if (note.RefType == ReferenceType.Users)
                    {
                        AddAssociation(newTask.TaskID, ActivityID, (int)ReferenceType.ContactActivity);
                    }
                }
            }

            string description = String.Format("{0} created task.", TSAuthentication.GetUser(loginUser).FirstLastName);

            TaskLogs.AddTaskLog(loginUser, newTask.TaskID, description);

            if (newTask.UserID != null && loginUser.UserID != newTask.UserID)
            {
                SendAssignedNotification(loginUser.UserID, newTask.TaskID);
            }

            return(newTask.GetProxy());
        }