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 void TaskMailSend(Guid user_id, string order_id, string task_name, Guid task_id, string title, string body, string task_status_name, string type, string user_name_surname = "")
        {
            #region Mail Gönderiliyor

            GenelRepository gnlDB           = RepositoryManager.GetRepository <GenelRepository>();
            gnl_users       userMail        = gnlDB.GetUser(user_id);
            string          nameSurnameMail = "";

            if (userMail != null)
            {
                nameSurnameMail = userMail.name + " " + userMail.surname;
            }

            DateTime localDateTimeMail = BaseClasses.BaseFunctions.ToLocalTime(DateTime.UtcNow, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);
            string   mailBody          = "";
            if (type == "1")
            {
                mailBody = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"Templates\TaskStatusChangeTemplate.html").ReadToEnd();
            }
            else if (type == "2")
            {
                mailBody = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"Templates\TaskNewExplanationTemplate.html").ReadToEnd();
            }
            else if (type == "99")
            {
                mailBody = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"Templates\TaskExpireEndDate.html").ReadToEnd();
            }

            if (type == "99")
            {
                tsk_tasks task = new tsk_tasks();
                task = this.GetTask(task_id);
                gnl_users taskUser = gnlDB.GetUser(task.task_user_id);
                DateTime  localDateTimeMailExpireTask = BaseClasses.BaseFunctions.ToLocalTime(task.end_date, BaseDB.SessionContext.Current.ActiveUser.TimeZoneInfoUser.Id);

                mailBody = mailBody.Replace("%%task_end_date%%", localDateTimeMailExpireTask.ToString());
                mailBody = mailBody.Replace("%%task_user_name_surname%%", taskUser.name + " " + taskUser.surname);
            }
            mailBody = mailBody.Replace("%%company_name%%", Dcm.Source.GlobalHelper.GetCompanyName());
            mailBody = mailBody.Replace("%%ad%%", nameSurnameMail);
            mailBody = mailBody.Replace("%%task_no%%", "#" + order_id.PadLeft(5, '0'));

            string applicationPath = "";
            if (System.Web.HttpContext.Current.Request.ApplicationPath == "/")
            {
                applicationPath = "http://" + System.Web.HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + "/";
            }
            else
            {
                applicationPath = "http://" + System.Web.HttpContext.Current.Request.ServerVariables["HTTP_HOST"] + "/" + System.Web.HttpContext.Current.Request.ApplicationPath + "/";
            }


            mailBody = mailBody.Replace("%%path_url%%", applicationPath);
            mailBody = mailBody.Replace("%%task_name%%", task_name);
            mailBody = mailBody.Replace("%%task_date%%", localDateTimeMail.ToString());
            mailBody = mailBody.Replace("%%task_status_name%%", task_status_name);
            mailBody = mailBody.Replace("%%task_body%%", body);
            mailBody = mailBody.Replace("%%user_name_surname%%", user_name_surname);

            mailBody = mailBody.Replace("%%task_link%%", applicationPath + "Task/Tasks?RecordId=" + task_id + "&MenuId=" + Dcm.Source.GlobalHelper.Encrypt("149"));

            #region mail gönderiliyor
            if (BaseClasses.BaseFunctions.getInstance().IsEmailValid(userMail.email.Trim()))
            {
                BaseClasses.BaseFunctions.getInstance().SendSMTPMail(userMail.email.Trim(), "", title, mailBody, "", null, "", "genel");
            }
            #endregion


            #endregion
        }
Esempio n. 3
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);
        }