示例#1
0
        public bool ChangeStatus(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            DTO.StatusData dtoStatus = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.StatusData>();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    DevRequestHistory dbHistory = null;
                    DevRequest        dbRequest = context.DevRequest.FirstOrDefault(o => o.DevRequestID == id);
                    if (dbRequest != null)
                    {
                        dbHistory = new DevRequestHistory();
                        dbRequest.DevRequestHistory.Add(dbHistory);
                    }
                    else
                    {
                        notification.Message = "Dev request not found!";
                        return(false);
                    }

                    // in case status = resolved (4), check if actual hour is exist
                    if (dtoStatus.DevRequestStatusID == 4)
                    {
                        foreach (DevRequestAssignment dbAssignment in dbRequest.DevRequestAssignment)
                        {
                            if (!dbAssignment.ActualWorkingHour.HasValue)
                            {
                                throw new Exception("Please fill in the actual working hour before mark request as resolved!");
                            }
                        }
                    }

                    Support.DTO.DevRequestStatus dtoSupportStatus = supportFactory.GetDevRequestStatus().FirstOrDefault(o => o.DevRequestStatusID == dtoStatus.DevRequestStatusID);
                    if (dtoSupportStatus == null)
                    {
                        notification.Message = "Invalid status!";
                        return(false);
                    }
                    dbRequest.DevRequestStatusID        = dtoStatus.DevRequestStatusID;
                    dbHistory.Comment                   = dtoStatus.Comment;
                    dbHistory.UpdatedBy                 = userId;
                    dbHistory.UpdatedDate               = DateTime.Now;
                    dbHistory.DevRequestHistoryActionID = 4; // 4: change status
                    dbHistory.ActionDescription         = "SET STATUS TO " + dtoSupportStatus.DevRequestStatusNM;

                    if (dtoStatus.DevRequestStatusID == 7) // progress
                    {
                        dbRequest.StartDate = DateTime.Now;
                    }

                    // send notify email
                    string emailSubject = "TASK REQUEST: [STATUS] " + dbRequest.Title;
                    string emailBody    = "";
                    emailBody += "ID: " + dbRequest.DevRequestID.ToString() + "<br/>";
                    emailBody += "TITLE: " + dbRequest.Title + "<br/>";
                    emailBody += "UPDATOR: " + supportFactory.GetUsers().FirstOrDefault(o => o.UserId == userId).FullName + "<br/>";
                    emailBody += dbHistory.ActionDescription;
                    SendNotification(context, dbRequest, emailSubject, emailBody);

                    context.SaveChanges();
                    dtoItem = GetData(id, out notification).Data;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
示例#2
0
        public bool ChangeEstEndDate(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            DTO.EstEndDateData dtoEstEndDate = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.EstEndDateData>();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    DevRequestHistory dbHistory = null;
                    DevRequest        dbRequest = context.DevRequest.FirstOrDefault(o => o.DevRequestID == id);
                    if (dbRequest != null)
                    {
                        dbHistory = new DevRequestHistory();
                        dbRequest.DevRequestHistory.Add(dbHistory);
                    }
                    else
                    {
                        notification.Message = "Dev request not found!";
                        return(false);
                    }

                    DateTime tmpDate;
                    System.Globalization.CultureInfo nl = new System.Globalization.CultureInfo("nl-NL");
                    if (!string.IsNullOrEmpty(dtoEstEndDate.EstEndDate))
                    {
                        if (DateTime.TryParse(dtoEstEndDate.EstEndDate, nl, System.Globalization.DateTimeStyles.None, out tmpDate))
                        {
                            dbRequest.EstEndDate = tmpDate;
                        }
                        else
                        {
                            notification.Message = "Invalid date format!";
                            return(false);
                        }
                    }

                    dbHistory.Comment     = dtoEstEndDate.Comment;
                    dbHistory.UpdatedBy   = userId;
                    dbHistory.UpdatedDate = DateTime.Now;
                    dbHistory.DevRequestHistoryActionID = 6;  // 6 : set est end date
                    dbHistory.ActionDescription         = "SET EST END DATE TO " + dtoEstEndDate.EstEndDate;

                    // send notify email
                    string emailSubject = "TASK REQUEST: [SET EST END DATE] " + dbRequest.Title;
                    string emailBody    = "";
                    emailBody += "ID: " + dbRequest.DevRequestID.ToString() + "<br/>";
                    emailBody += "TITLE: " + dbRequest.Title + "<br/>";
                    emailBody += "UPDATOR: " + supportFactory.GetUsers().FirstOrDefault(o => o.UserId == userId).FullName + "<br/>";
                    emailBody += dbHistory.ActionDescription;
                    SendNotification(context, dbRequest, emailSubject, emailBody);

                    context.SaveChanges();
                    dtoItem = GetData(id, out notification).Data;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
示例#3
0
        public bool ChangePriority(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            DTO.PriorityData dtoPriority = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.PriorityData>();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    DevRequestHistory dbHistory = null;
                    DevRequest        dbRequest = context.DevRequest.FirstOrDefault(o => o.DevRequestID == id);
                    if (dbRequest != null)
                    {
                        dbHistory = new DevRequestHistory();
                        dbRequest.DevRequestHistory.Add(dbHistory);
                    }
                    else
                    {
                        notification.Message = "Dev request not found!";
                        return(false);
                    }

                    Support.DTO.DevRequestPriority dtoSupportPriority = supportFactory.GetDevRequestPriority().FirstOrDefault(o => o.DevRequestPriorityID == dtoPriority.Priority);
                    if (dtoSupportPriority == null)
                    {
                        notification.Message = "Invalid priority!";
                        return(false);
                    }
                    dbRequest.Priority    = dtoPriority.Priority;
                    dbHistory.Comment     = dtoPriority.Comment;
                    dbHistory.UpdatedBy   = userId;
                    dbHistory.UpdatedDate = DateTime.Now;
                    dbHistory.DevRequestHistoryActionID = 5; // 5 : change priority
                    dbHistory.ActionDescription         = "SET PRIORITY TO " + dtoSupportPriority.DevRequestPriorityNM;

                    // send notify email
                    string emailSubject = "TASK REQUEST: [PRIORITY] " + dbRequest.Title;
                    string emailBody    = "";
                    emailBody += "ID: " + dbRequest.DevRequestID.ToString() + "<br/>";
                    emailBody += "TITLE: " + dbRequest.Title + "<br/>";
                    emailBody += "PRIORITY: " + dbHistory.ActionDescription;
                    emailBody += "UPDATOR: " + supportFactory.GetUsers().FirstOrDefault(o => o.UserId == userId).FullName + "<br/>";
                    emailBody += "COMMENT: " + dbHistory.Comment + "<br/>";
                    SendNotification(context, dbRequest, emailSubject, emailBody);

                    context.SaveChanges();
                    dtoItem = GetData(id, out notification).Data;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
示例#4
0
        public bool UnAssign(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            DTO.AssignData dtoAssign = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.AssignData>();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    DevRequestHistory dbHistory = null;
                    DevRequest        dbRequest = context.DevRequest.FirstOrDefault(o => o.DevRequestID == id);
                    if (dbRequest != null)
                    {
                        dbHistory = new DevRequestHistory();
                        dbRequest.DevRequestHistory.Add(dbHistory);
                    }
                    else
                    {
                        throw new Exception("Dev request not found!");
                    }

                    DevRequestAssignment dbAssignment = dbRequest.DevRequestAssignment.FirstOrDefault(o => o.AssignedTo == dtoAssign.AssignedTo);
                    if (dbAssignment != null) // person is already added
                    {
                        dbRequest.DevRequestAssignment.Remove(dbAssignment);
                        context.DevRequestAssignment.Remove(dbAssignment);
                    }
                    else
                    {
                        throw new Exception("Person is not assigned!");
                    }

                    Support.DTO.User dtoUser = supportFactory.GetUsers().FirstOrDefault(o => o.UserId == dtoAssign.AssignedTo);
                    if (dtoUser == null) // check if user is exists in the system
                    {
                        throw new Exception("Person not found!");
                    }

                    dbHistory.Comment     = dtoAssign.Comment;
                    dbHistory.UpdatedBy   = userId;
                    dbHistory.UpdatedDate = DateTime.Now;
                    dbHistory.DevRequestHistoryActionID = 7; // 7 : un-assign
                    dbHistory.ActionDescription         = "REMOVE PERSON: " + dtoUser.FullName + " FROM TASK ASSIGNMENT";

                    // send notify email
                    string emailSubject = "TASK REQUEST: [UNASSIGN] " + dbRequest.Title;
                    string emailBody    = "";
                    emailBody += "ID: " + dbRequest.DevRequestID.ToString() + "<br/>";
                    emailBody += "TITLE: " + dbRequest.Title + "<br/>";
                    emailBody += "UPDATED BY: " + supportFactory.GetUsers().FirstOrDefault(o => o.UserId == userId).FullName + "<br/>";
                    emailBody += dbHistory.ActionDescription;
                    SendNotification(context, dbRequest, emailSubject, emailBody);

                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
示例#5
0
        public bool Assign(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            DTO.AssignData dtoAssign = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.AssignData>();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    DevRequestHistory    dbHistory = null;
                    DevRequestAssignment dbAssign  = null;
                    DevRequest           dbRequest = context.DevRequest.FirstOrDefault(o => o.DevRequestID == id);
                    if (dbRequest != null)
                    {
                        dbHistory = new DevRequestHistory();
                        dbAssign  = new DevRequestAssignment();
                        dbRequest.DevRequestHistory.Add(dbHistory);
                        dbRequest.DevRequestAssignment.Add(dbAssign);
                    }
                    else
                    {
                        notification.Message = "Dev request not found!";
                        return(false);
                    }

                    if (dbRequest.DevRequestAssignment.FirstOrDefault(o => o.AssignedTo == dtoAssign.AssignedTo) != null) // person is already added
                    {
                        notification.Message = "Person is already in the list!";
                        return(false);
                    }

                    Support.DTO.User dtoUser = supportFactory.GetUsers().FirstOrDefault(o => o.UserId == dtoAssign.AssignedTo);
                    if (dtoUser == null) // check if user is exists in the system
                    {
                        notification.Message = "Person not found!";
                        return(false);
                    }

                    dbHistory.Comment     = dtoAssign.Comment;
                    dbHistory.UpdatedBy   = userId;
                    dbHistory.UpdatedDate = DateTime.Now;
                    dbHistory.DevRequestHistoryActionID = 2; // 2 : assign
                    dbHistory.ActionDescription         = "ASSGIN TASK TO " + dtoUser.FullName + " ";
                    if (dtoAssign.IsPersonInCharge)
                    {
                        dbHistory.ActionDescription += "(PIC)";
                    }

                    dbAssign.AssignedTo = dtoAssign.AssignedTo;
                    if (dtoAssign.IsPersonInCharge)
                    {
                        dbRequest.DevRequestAssignment.ToList().ForEach(o => o.IsPersonInCharge = false);
                    }
                    dbAssign.IsPersonInCharge = dtoAssign.IsPersonInCharge;

                    // send notify email
                    string emailSubject = "TASK REQUEST: [ASSIGN] " + dbRequest.Title;
                    string emailBody    = "";
                    emailBody += "ID: " + dbRequest.DevRequestID.ToString() + "<br/>";
                    emailBody += "TITLE: " + dbRequest.Title + "<br/>";
                    emailBody += "ASSIGNED BY: " + supportFactory.GetUsers().FirstOrDefault(o => o.UserId == userId).FullName + "<br/>";
                    emailBody += dbHistory.ActionDescription;
                    SendNotification(context, dbRequest, emailSubject, emailBody);

                    context.SaveChanges();
                    dtoItem = GetData(id, out notification).Data;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
示例#6
0
        public bool AddComment(int userId, int id, ref object dtoItem, out Library.DTO.Notification notification)
        {
            DTO.DevRequestHistory dtoDevRequestHistory = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject <DTO.DevRequestHistory>();
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    DevRequestHistory dbItem    = null;
                    DevRequest        dbRequest = context.DevRequest.FirstOrDefault(o => o.DevRequestID == id);
                    if (dbRequest != null)
                    {
                        dbItem = new DevRequestHistory();
                        dbRequest.DevRequestHistory.Add(dbItem);
                    }
                    else
                    {
                        notification.Message = "Dev request not found!";
                        return(false);
                    }
                    dbItem.Comment                   = dtoDevRequestHistory.Comment;
                    dbItem.UpdatedBy                 = userId;
                    dbItem.UpdatedDate               = DateTime.Now;
                    dbItem.ActionDescription         = "ADD COMMENT";
                    dbItem.DevRequestHistoryActionID = 3; // 3 = ADD COMMENT

                    // request file
                    string TmpFile = FrameworkSetting.Setting.AbsoluteUserTempFolder + userId.ToString() + @"\";
                    foreach (DTO.DevRequestCommentAttachedFile dtoFile in dtoDevRequestHistory.DevRequestCommentAttachedFiles.Where(o => o.HasChanged == true))
                    {
                        // add file
                        DevRequestCommentAttachedFile dbFile = new DevRequestCommentAttachedFile();
                        dbItem.DevRequestCommentAttachedFile.Add(dbFile);
                        AutoMapper.Mapper.Map <DTO.DevRequestCommentAttachedFile, DevRequestCommentAttachedFile>(dtoFile, dbFile);
                        dbFile.FileUD = fwFactory.CreateNoneImageFilePointer(TmpFile, dtoFile.NewFile, dtoFile.FileUD, dtoFile.FriendlyName);
                    }

                    // send notify email
                    string emailSubject = "TASK REQUEST: [COMMENT] " + dbRequest.Title;
                    string emailBody    = "";
                    emailBody += "ID: " + dbRequest.DevRequestID.ToString() + "<br/>";
                    emailBody += "TITLE: " + dbRequest.Title + "<br/>";
                    emailBody += "UPDATOR: " + supportFactory.GetUsers().FirstOrDefault(o => o.UserId == userId).FullName + "<br/>";
                    emailBody += "COMMENT: " + dbItem.Comment + "<br/>";
                    SendNotification(context, dbRequest, emailSubject, emailBody);

                    context.SaveChanges();
                    dtoItem = GetData(id, out notification).Data;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                notification = new Library.DTO.Notification()
                {
                    Message = ex.Message, Type = Library.DTO.NotificationType.Error
                };
                return(false);
            }
        }
示例#7
0
        public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            DTO.SearchFormData data = new DTO.SearchFormData();
            data.Data = new List <DTO.DevRequestSearchResult>();
            totalRows = 0;

            //try to get data
            try
            {
                using (DevRequestMngEntities context = CreateContext())
                {
                    int?   DevRequestID        = null;
                    int?   DevRequestStatusID  = null;
                    int?   DevRequestProjectID = null;
                    int?   DevRequestTypeID    = null;
                    int?   RequesterID         = null;
                    int?   AssignedPersonID    = null;
                    int?   Priority            = null;
                    int?   SpecialCriteria     = null;
                    string Title = null;
                    if (filters.ContainsKey("DevRequestID") && filters["DevRequestID"] != null && !string.IsNullOrEmpty(filters["DevRequestID"].ToString()))
                    {
                        DevRequestID = Convert.ToInt32(filters["DevRequestID"].ToString());
                    }
                    if (filters.ContainsKey("DevRequestStatusID") && filters["DevRequestStatusID"] != null && !string.IsNullOrEmpty(filters["DevRequestStatusID"].ToString()))
                    {
                        DevRequestStatusID = Convert.ToInt32(filters["DevRequestStatusID"].ToString());
                    }
                    if (filters.ContainsKey("DevRequestProjectID") && filters["DevRequestProjectID"] != null && !string.IsNullOrEmpty(filters["DevRequestProjectID"].ToString()))
                    {
                        DevRequestProjectID = Convert.ToInt32(filters["DevRequestProjectID"].ToString());
                    }
                    if (filters.ContainsKey("DevRequestTypeID") && filters["DevRequestTypeID"] != null && !string.IsNullOrEmpty(filters["DevRequestTypeID"].ToString()))
                    {
                        DevRequestTypeID = Convert.ToInt32(filters["DevRequestTypeID"].ToString());
                    }
                    if (filters.ContainsKey("RequesterID") && filters["RequesterID"] != null && !string.IsNullOrEmpty(filters["RequesterID"].ToString()))
                    {
                        RequesterID = Convert.ToInt32(filters["RequesterID"].ToString());
                    }
                    if (filters.ContainsKey("AssignedPersonID") && filters["AssignedPersonID"] != null && !string.IsNullOrEmpty(filters["AssignedPersonID"].ToString()))
                    {
                        AssignedPersonID = Convert.ToInt32(filters["AssignedPersonID"].ToString());
                    }
                    if (filters.ContainsKey("Title") && !string.IsNullOrEmpty(filters["Title"].ToString()))
                    {
                        Title = filters["Title"].ToString().Replace("'", "''");
                    }
                    if (filters.ContainsKey("Priority") && filters["Priority"] != null && !string.IsNullOrEmpty(filters["Priority"].ToString()))
                    {
                        Priority = Convert.ToInt32(filters["Priority"].ToString());
                    }
                    if (filters.ContainsKey("SpecialCriteria") && filters["SpecialCriteria"] != null && !string.IsNullOrEmpty(filters["SpecialCriteria"].ToString()))
                    {
                        SpecialCriteria = Convert.ToInt32(filters["SpecialCriteria"].ToString());
                    }
                    totalRows = context.DevRequestMng_function_searchDevRequest(DevRequestID, DevRequestStatusID, DevRequestProjectID, DevRequestTypeID, RequesterID, Title, AssignedPersonID, Priority, SpecialCriteria, orderBy, orderDirection).Count();
                    var result = context.DevRequestMng_function_searchDevRequest(DevRequestID, DevRequestStatusID, DevRequestProjectID, DevRequestTypeID, RequesterID, Title, AssignedPersonID, Priority, SpecialCriteria, orderBy, orderDirection);
                    data.Data = converter.DB2DTO_DevRequestSearchResult(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                    // add assignment
                    var assignments = context.DevRequestMng_function_searchDevRequestAssignment(DevRequestID, DevRequestStatusID, DevRequestProjectID, DevRequestTypeID, RequesterID, Title, AssignedPersonID, Priority).ToList();
                    foreach (DTO.DevRequestSearchResult dtoItem in data.Data)
                    {
                        dtoItem.DevRequestAssignments = new List <DTO.DevRequestAssignment>();
                        dtoItem.DevRequestAssignments.AddRange(converter.DB2DTO_DevRequestAssignmentList(assignments.Where(o => o.DevRequestID == dtoItem.DevRequestID).ToList()));
                    }
                }
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }