Esempio n. 1
0
        public Task UpdateExplanation(Task model, Guid recordId)
        {
            tsk_tasks task = new tsk_tasks();

            task = this.GetTask(recordId);

            DateTime lclDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

            if (model.new_explanation != null && model.new_explanation.Trim() != "")
            {
                task.explanations = "~~~~ " + SessionContext.Current.ActiveUser.Name + " " + SessionContext.Current.ActiveUser.Surname + "  " + lclDateTime + " ~~~~\n" + model.new_explanation + "\n\r" + task.explanations;
            }

            this.Kaydet();

            GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>();

            #region Notification Ekleniyor

            string title = Resources.GlobalResource.task_explanation_added;

            DateTime localDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

            string body = string.Format(Resources.GlobalResource.task_explanation_added_body, task.task_name, localDateTime);

            gnlDB.AddNotification(recordId, task.assigned_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
            gnlDB.Kaydet();

            gnlDB.AddNotification(recordId, task.task_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
            gnlDB.Kaydet();

            if (task.assigned_user_id != task.task_user_id)
            {
                TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Explanation Added", model.new_explanation, "", "2", SessionContext.Current.ActiveUser.Name + " " + SessionContext.Current.ActiveUser.Surname);
                TaskMailSend(task.task_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Explanation Added", model.new_explanation, "", "2", SessionContext.Current.ActiveUser.Name + " " + SessionContext.Current.ActiveUser.Surname);
            }
            else
            {
                TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Explanation Added", model.new_explanation, "", "2", SessionContext.Current.ActiveUser.Name + " " + SessionContext.Current.ActiveUser.Surname);
            }


            #endregion

            return(model);
        }
Esempio n. 2
0
        public Task UpdateTaskStatus(Task model, Guid recordId, int statusId, bool active = true)
        {
            tsk_tasks task = new tsk_tasks();

            task = this.GetTask(recordId);

            bool statusChanged = false;

            if (statusId != task.task_status_id)
            {
                statusChanged = true;
            }

            task.task_status_id = statusId;
            task.is_task_sent   = true;
            task.is_active      = active;

            task.updated_at = DateTime.UtcNow;
            task.updated_by = SessionContext.Current.ActiveUser.UserUid;

            this.Kaydet();


            if (statusChanged)
            {
                this.AddTaskHistory(task);

                GenelRepository gnlDB = RepositoryManager.GetRepository <GenelRepository>();

                #region Notification Ekleniyor

                if (statusId == (int)Enums.TaskStatus.Gonderildi)
                {
                    #region Notification Statu Gönderildi
                    string title = Resources.GlobalResource.new_task_notification;

                    gnl_users user        = gnlDB.GetUser(task.task_user_id);
                    string    nameSurname = "";

                    if (user != null)
                    {
                        nameSurname = user.name + " " + user.surname;
                    }

                    DateTime localDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

                    string body = string.Format(Resources.GlobalResource.new_task_notification_body, task.task_name, localDateTime, nameSurname);

                    gnlDB.AddNotification(recordId, task.assigned_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                    gnlDB.Kaydet();

                    TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Sent", "1");
                    #endregion
                }
                else if (Convert.ToInt32(model.task_status_id) == (int)Enums.TaskStatus.Gonderildi)
                {
                    #region Notification Statu Gönderildi
                    string title = Resources.GlobalResource.new_task_notification;

                    gnl_users user        = gnlDB.GetUser(task.task_user_id);
                    string    nameSurname = "";

                    if (user != null)
                    {
                        nameSurname = user.name + " " + user.surname;
                    }

                    DateTime localDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

                    string body = string.Format(Resources.GlobalResource.new_task_notification_body, task.task_name, localDateTime, nameSurname);

                    gnlDB.AddNotification(recordId, task.assigned_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                    gnlDB.Kaydet();

                    TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Sent", "1");
                    #endregion
                }
                else
                {
                    #region Notification Statu Değişikliği

                    if (Convert.ToInt32(model.task_status_id) == (int)Enums.TaskStatus.Calismaya_Baslandi)
                    {
                        string   title         = Resources.GlobalResource.task_status_notification;
                        DateTime localDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);
                        string   body          = string.Format(Resources.GlobalResource.task_gonderildi_status_notification_body, task.task_name, Resources.GlobalResource.task_status_calismaya_baslandi, localDateTime);

                        gnlDB.AddNotification(recordId, task.assigned_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                        gnlDB.Kaydet();

                        gnlDB.AddNotification(recordId, task.task_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                        gnlDB.Kaydet();

                        if (task.assigned_user_id != task.task_user_id)
                        {
                            TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Work Started", "1");
                            TaskMailSend(task.task_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Work Started", "1");
                        }
                        else
                        {
                            TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Work Started", "1");
                        }
                    }
                    else if (Convert.ToInt32(model.task_status_id) == (int)Enums.TaskStatus.Tamamlandi)
                    {
                        string title = Resources.GlobalResource.task_status_notification;

                        DateTime localDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

                        string body = string.Format(Resources.GlobalResource.task_gonderildi_status_notification_body, task.task_name, Resources.GlobalResource.task_status_tamamlandi, localDateTime);

                        task.task_completed_by   = SessionContext.Current.ActiveUser.UserUid;
                        task.task_completed_date = DateTime.UtcNow;
                        this.Kaydet();

                        gnlDB.AddNotification(recordId, task.assigned_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                        gnlDB.Kaydet();

                        gnlDB.AddNotification(recordId, task.task_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                        gnlDB.Kaydet();

                        if (task.assigned_user_id != task.task_user_id)
                        {
                            TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Finished", "1");
                            TaskMailSend(task.task_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Finished", "1");
                        }
                        else
                        {
                            TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Finished", "1");
                        }
                    }
                    else if (Convert.ToInt32(model.task_status_id) == (int)Enums.TaskStatus.Reddedildi)
                    {
                        string title = Resources.GlobalResource.task_status_notification;

                        DateTime localDateTime = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

                        string body = string.Format(Resources.GlobalResource.task_gonderildi_status_notification_body, task.task_name, Resources.GlobalResource.task_status_reddedildi, localDateTime);

                        gnlDB.AddNotification(recordId, task.assigned_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                        gnlDB.Kaydet();

                        gnlDB.AddNotification(recordId, task.task_user_id, (int)Enums.NotificationType.Normal, (int)Enums.NotificationModuleType.Task, title, body);
                        gnlDB.Kaydet();

                        if (task.assigned_user_id != task.task_user_id)
                        {
                            TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Rejected", "1");
                            TaskMailSend(task.task_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Rejected", "1");
                        }
                        else
                        {
                            TaskMailSend(task.assigned_user_id, task.order_id.ToString(), task.task_name, task.task_id, "Task Status Change", "", "Rejected", "1");
                        }
                    }


                    #endregion
                }
                #endregion
            }


            return(model);
        }