public async Task <ActionResult> PostResolutionForTicket(int ticketId, TicketResolutionCommentDto ticketResolution)
        {
            if (string.IsNullOrEmpty(ticketResolution.ResolutionComment))
            {
                return(BadRequest("Comment is required for resolving the ticket!"));
            }

            var ticketFromDb = await _unitOfWork.Tickets.GetById(ticketId);

            if (ticketFromDb == null)
            {
                return(BadRequest("Invalid ticket Id!"));
            }
            if (ticketFromDb.TicketResolution != null)
            {
                return(BadRequest("Ticket is already resolved! Resoluiton Id : " + ticketFromDb.TicketResolution.Id + "!"));
            }

            var currentUser = await _userManager.GetUserAsync(HttpContext.User);

            var resolution = new TicketResolution
            {
                CreatedBy         = currentUser.UserName,
                CreatedByUserId   = currentUser.Id,
                DateCreated       = DateTime.Now,
                ResolutionComment = ticketResolution.ResolutionComment,
                TicketId          = ticketId
            };

            ticketFromDb.TicketStatusId = ticketResolution.TicketStatusId;

            _unitOfWork.TicketResolutions.Add(resolution);

            if (await _unitOfWork.Complete() >= 1)
            {
                return(Ok("Created new ticket resolution!"));
            }
            else
            {
                return(BadRequest("An erron happened while saving new ticket resolution!"));
            }
        }
Ejemplo n.º 2
0
        // GET: MyTechnicalRequest
        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            if (Session["userid"] == null)
            {
                return(View("LoginRedirect"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(View("LoginRedirect"));
                }

                ViewBag.CurrentSort    = sortOrder;
                ViewBag.DateSortParm   = String.IsNullOrEmpty(sortOrder) ? "DateDesc" : "";
                ViewBag.TitleSortParm  = sortOrder == "Title" ? "TitleDesc" : "Title";
                ViewBag.StatusSortParm = sortOrder == "Status" ? "StatusDesc" : "Status";

                if (searchString != null)
                {
                    page = 1;
                }
                else
                {
                    searchString = currentFilter;
                }

                ViewBag.CurrentFilter = searchString;

                var tickets = _ticketBs.GetQueryableByUserConected(int.Parse(Session["userid"].ToString()));
                //Search MyTR
                if (!String.IsNullOrEmpty(searchString))
                {
                    int userlogin = int.Parse(Session["userid"].ToString());
                    if ("waiting your feedback".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                (ticket.Status == 2 && userlogin.Equals(ticket.NextCommenter) && (userlogin.Equals(ticket.Responder) || userlogin.Equals(ticket.Submiter))) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("pra".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                (ticket.Status == 2 && !userlogin.Equals(ticket.NextCommenter) && ticket.NextCommenter.Equals(ticket.Responder)) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("psa".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                (ticket.Status == 2 && !userlogin.Equals(ticket.NextCommenter) && ticket.NextCommenter.Equals(ticket.Submiter)) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("draft".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                ticket.Status.Equals(1) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("solved".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                ticket.Status.Equals(6) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else if ("closed".Contains(searchString.ToLower()))
                    {
                        tickets = tickets.Where(ticket =>
                                                ticket.Title.Contains(searchString) ||
                                                ticket.TicketNo.Contains(searchString) ||
                                                ticket.SerialNumber.Contains(searchString) ||
                                                ticket.Status.Equals(3) ||
                                                ticket.Description.Contains(searchString) ||
                                                ticket.EmailCC.Contains(searchString));
                    }
                    else
                    {
                        int[] UserParticipant = _ticketParticipantBusinessService.GetTicketIdBySearchUserId(searchString).ToArray();
                        int[] User            = _userBusinessService.GetListSearchUser(searchString).ToArray();
                        int[] tagTicket       = _articleTagBs.searchTagTicket(searchString).ToArray();
                        if (tagTicket.Length > 0)
                        {
                            tickets = tickets.Where(ticket =>
                                                    ticket.Title.Contains(searchString) ||
                                                    ticket.TicketNo.Contains(searchString) ||
                                                    ticket.SerialNumber.Contains(searchString) ||
                                                    ticket.DPPMno.Contains(searchString) ||
                                                    ticket.Description.Contains(searchString) ||
                                                    ticket.EmailCC.Contains(searchString) || (tagTicket.Contains(ticket.TicketId) && ticket.Status != 1) || ((User.Contains(ticket.Responder) || User.Contains(ticket.Submiter) || UserParticipant.Contains(ticket.TicketId)) && ticket.Status != 1));
                        }
                        else
                        {
                            tickets = tickets.Where(ticket =>
                                                    ticket.Title.Contains(searchString) ||
                                                    ticket.TicketNo.Contains(searchString) ||
                                                    ticket.SerialNumber.Contains(searchString) ||
                                                    ticket.DPPMno.Contains(searchString) ||
                                                    ticket.Description.Contains(searchString) ||
                                                    ticket.EmailCC.Contains(searchString) || ((User.Contains(ticket.Responder) || User.Contains(ticket.Submiter) || UserParticipant.Contains(ticket.TicketId)) && ticket.Status != 1));
                        }
                    }
                }
                List <Ticket> recent = new List <Ticket>();
                if (tickets != null)
                {
                    foreach (var item in tickets)
                    {
                        Ticket recentDate = new Ticket()
                        {
                            TicketId  = item.TicketId,
                            CreatedAt = new[] { item.CreatedAt, item.LastReply, item.UpdatedAt, item.LastStatusDate }.Max()
                        };
                        recent.Add(recentDate);
                    }
                    ViewBag.RecentDate = recent;
                }
                else
                {
                    ViewBag.RecentDate = null;
                }
                switch (sortOrder)
                {
                case "DateDesc":
                    tickets = tickets.OrderBy(t => new[] { t.CreatedAt, t.LastReply, t.UpdatedAt, t.LastStatusDate }.Max());
                    break;

                case "Title":
                    tickets = tickets.OrderBy(t => t.Title);
                    break;

                case "TitleDesc":
                    tickets = tickets.OrderByDescending(t => t.Title);
                    break;

                case "Status":
                    tickets = tickets.OrderBy(t => t.Status);
                    break;

                case "StatusDesc":
                    tickets = tickets.OrderByDescending(t => t.Status);
                    break;

                default:
                    tickets = tickets.OrderByDescending(t => new[] { t.CreatedAt, t.LastReply, t.UpdatedAt, t.LastStatusDate }.Max());
                    break;
                }

                ViewBag.Recent = TechnicalRequest.GetRecentTR(Convert.ToInt32(Session["userid"]));
                var ticketPreview = _ticketPreviewBusinessService.MakeFrom(tickets, Convert.ToInt32(Session["userid"]));

                List <InvolvedUser>     submitter     = new List <InvolvedUser>();
                List <InvolvedUser>     responders    = new List <InvolvedUser>();
                List <InvolvedUser>     involvedUsers = new List <InvolvedUser>();
                List <TicketResolution> Resolutions   = new List <TicketResolution>();
                if (ticketPreview != null)
                {
                    foreach (var ticket in ticketPreview)
                    {
                        User submitterData = _userBusinessService.GetDetail(ticket.Submiter);
                        ticket.IsEscalated = _ticketBs.IsEscalated(ticket.TicketId, Convert.ToInt32(Session["userid"]));
                        TicketResolution resolution = _ticketResolutionBs.GetByTicket(ticket.TicketId);
                        if (resolution != null)
                        {
                            TicketResolution resolutionObj = new TicketResolution()
                            {
                                TicketId    = ticket.TicketId,
                                Description = resolution.Description,
                                CreatedAt   = resolution.CreatedAt
                            };
                            Resolutions.Add(resolutionObj);
                        }
                        else
                        {
                            TicketResolution resolutionObj = new TicketResolution()
                            {
                                TicketId    = ticket.TicketId,
                                Description = null,
                                CreatedAt   = null
                            };
                            Resolutions.Add(resolutionObj);
                        }
                        if (submitterData != null)
                        {
                            InvolvedUser submitterUser = new InvolvedUser()
                            {
                                TicketNo    = ticket.TicketNo,
                                EmployeName = _userBusinessService.GetDetail(ticket.Submiter).Name
                            };

                            submitter.Add(submitterUser);
                        }
                        else
                        {
                            InvolvedUser submitterUser = new InvolvedUser()
                            {
                                TicketNo    = ticket.TicketNo,
                                EmployeName = ""
                            };

                            submitter.Add(submitterUser);
                        }

                        if (ticket.Responder != 0)
                        {
                            User responderData = _userBusinessService.GetDetail(ticket.Responder);
                            if (responderData != null)
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = _userBusinessService.GetDetail(ticket.Responder).Name
                                };
                                responders.Add(responder);
                            }
                            else
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = ""
                                };
                                responders.Add(responder);
                            }
                        }
                        else
                        {
                            if (ticket.Status != 1)
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = "TREND Admin"
                                };
                                responders.Add(responder);
                            }
                            else
                            {
                                InvolvedUser responder = new InvolvedUser()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    EmployeName = ""
                                };
                                responders.Add(responder);
                            }
                        }

                        var participants = _ticketParticipantBusinessService.GetByTicket(ticket.TicketId);
                        if (participants != null)
                        {
                            foreach (var participantItem in participants)
                            {
                                var useCek = _userBusinessService.GetDetail(participantItem.UserId);

                                if (useCek != null)
                                {
                                    InvolvedUser participant = new InvolvedUser()
                                    {
                                        TicketNo    = ticket.TicketNo,
                                        EmployeName = useCek.Name,
                                        UserId      = useCek.UserId
                                    };
                                    involvedUsers.Add(participant);
                                }
                            }
                        }
                    }
                }
                ViewBag.Resolutions   = Resolutions;
                ViewBag.Submiters     = submitter;
                ViewBag.Responders    = responders;
                ViewBag.InvolvedUsers = involvedUsers;

                int pageSize   = 10;
                int pageNumber = (page ?? 1);
                return(View("Index", ticketPreview.ToPagedList(pageNumber, pageSize)));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }
            ViewBag.DebugMode = DebugMode;


            if (DebugMode == false)
            {
                var                  ticketPreview     = _ticketBusinessService.GetQueryableSummary();
                List <User>          submiters         = new List <User>();
                List <TicketPreview> submitersRating   = new List <TicketPreview>();
                List <TicketPreview> responderRating   = new List <TicketPreview>();
                List <User>          responders        = new List <User>();
                List <TicketPreview> solvedDate        = new List <TicketPreview>();
                List <User>          EscalateData1     = new List <User>();
                List <User>          EscalateData2     = new List <User>();
                List <User>          EscalateData3     = new List <User>();
                List <TicketNote>    SubmiterNote      = new List <TicketNote>();
                List <TicketNote>    ResponderNote     = new List <TicketNote>();
                List <TicketNote>    EscalatedFromNote = new List <TicketNote>();
                List <TicketNote>    Escalated1Note    = new List <TicketNote>();
                List <TicketNote>    Escalated2Note    = new List <TicketNote>();
                List <TicketNote>    Escalated3Note    = new List <TicketNote>();
                if (ticketPreview != null)
                {
                    foreach (var ticket in ticketPreview)
                    {
                        User       submiterData       = _userBusinessService.GetDetail(ticket.Submiter);
                        Rating     ratingDataSubmiter = _ratingBusinessService.GetRatingFromSubmiter(ticket.TicketId, ticket.Submiter);
                        TicketNote noteSubmiter       = _ticketNoteBusinessService.GetDatebyTicketandUserId(ticket.TicketId, ticket.Submiter);

                        TicketNote notesubmiter = new TicketNote()
                        {
                            TicketNoteId = ticket.TicketId,
                            RespondTime  = noteSubmiter == null ? null : /*noteSubmiter.RespondTime*/ new string[] { noteSubmiter == null ? null : noteSubmiter.RespondTime, ratingDataSubmiter == null ? null : ratingDataSubmiter.RespondTime, }.Max()
                        };
                        SubmiterNote.Add(notesubmiter);

                        TicketNote noteResponder       = _ticketNoteBusinessService.GetDatebyTicketandUserId(ticket.TicketId, ticket.Responder);
                        Rating     ratingDataResponder = _ratingBusinessService.GetRatingFromResponder(ticket.TicketId, ticket.Responder);
                        TicketNote noteresponder       = new TicketNote()
                        {
                            TicketNoteId = ticket.TicketId,
                            RespondTime  = new string[] { noteResponder == null ? null : noteResponder.RespondTime, ratingDataResponder == null ? null : ratingDataResponder.RespondTime, }.Max()
                        };
                        ResponderNote.Add(noteresponder);

                        if (ratingDataSubmiter != null)
                        {
                            TicketPreview ratingdata = new TicketPreview()
                            {
                                TicketId   = ticket.TicketId,
                                ClosedDate = ratingDataSubmiter.CreatedAt,
                                Rate       = ratingDataSubmiter.Rate
                            };
                            submitersRating.Add(ratingdata);
                        }
                        else
                        {
                            TicketPreview ratingdata = new TicketPreview()
                            {
                                TicketId   = ticket.TicketId,
                                ClosedDate = null,
                                Rate       = 0
                            };
                            submitersRating.Add(ratingdata);
                        }
                        if (submiterData != null)
                        {
                            User submiter = new User()
                            {
                                UserId   = ticket.TicketId,
                                Name     = submiterData.Name,
                                AreaName = submiterData.AreaName,
                                POH_Name = _mstEmployeeBService.GetDetailbyUserName(submiterData.Username) == null ? null : _mstEmployeeBService.GetDetailbyUserName(submiterData.Username).Business_Area
                            };
                            submiters.Add(submiter);
                        }
                        else
                        {
                            User submiter = new User()
                            {
                                UserId   = ticket.TicketId,
                                Name     = "",
                                AreaName = "",
                                POH_Name = ""
                            };
                            submiters.Add(submiter);
                        }

                        if (ticket.Responder != 0)
                        {
                            User             responderData   = _userBusinessService.GetDetail(ticket.Responder);
                            TicketResolution SolvedDateData  = _ticketResolutionBusinessService.GetByTicket(ticket.TicketId);
                            Rating           ratingresponder = _ratingBusinessService.GetRatingFromSubmiter(ticket.TicketId, ticket.Submiter);

                            int[] escalateId = new int[4] {
                                0, 0, 0, 0
                            };
                            int i = 0;
                            foreach (var item in _ticketBusinessService.getlistIdEscalatedbyTicket(ticket.TicketId))
                            {
                                escalateId[i] = item;
                            }
                            EscalateLog escalateData  = escalateId[0] == 0 ? null : _ticketBusinessService.getEscalatedDetail(escalateId[0]);
                            EscalateLog escalateData2 = escalateId[1] == 0 ? null : _ticketBusinessService.getEscalatedDetail(escalateId[1]);
                            EscalateLog escalateData3 = escalateId[2] == 0 ? null : _ticketBusinessService.getEscalatedDetail(escalateId[2]);
                            if (responderData != null)
                            {
                                User responder = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = responderData.Name,
                                    AreaName = responderData.AreaName,
                                    POH_Name = responderData.EmployeeId == 0 ? null : _mstEmployeeBService.GetDetail(responderData.EmployeeId).Business_Area,
                                };

                                responders.Add(responder);
                            }
                            else
                            {
                                User responder = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = "",
                                    AreaName = "",
                                    POH_Name = ""
                                };

                                responders.Add(responder);
                            }

                            if (SolvedDateData != null)
                            {
                                TicketPreview solveddate = new TicketPreview()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    Description = SolvedDateData.Description,
                                    SolvedDate  = SolvedDateData.CreatedAt
                                };
                                solvedDate.Add(solveddate);
                            }
                            else
                            {
                                TicketPreview solveddate = new TicketPreview()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    Description = null,
                                    SolvedDate  = null
                                };
                                solvedDate.Add(solveddate);
                            }

                            if (ratingresponder != null)
                            {
                                TicketPreview rateResponder = new TicketPreview()
                                {
                                    TicketId    = ticket.TicketId,
                                    Rate        = ratingresponder.Rate,
                                    Description = ratingresponder.Description
                                };
                                responderRating.Add(rateResponder);
                            }
                            else
                            {
                                TicketPreview rateResponder = new TicketPreview()
                                {
                                    TicketId    = ticket.TicketId,
                                    Rate        = 0,
                                    Description = null
                                };
                                responderRating.Add(rateResponder);
                            }

                            if (escalateData != null)
                            {
                                User userEscalate1 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = _userBusinessService.GetDetail(escalateData.EscalateTo).Name,
                                    AreaName = _userBusinessService.GetDetail(escalateData.EscalateTo).AreaName == null ? "HEAD OFFICE" : _userBusinessService.GetDetail(escalateData.EscalateTo).AreaName,

                                    Position = _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData.EscalateTo).EmployeeId) == null ? null : _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData.EscalateTo).EmployeeId).Business_Area,

                                    Username   = _userBusinessService.GetDetail(escalateData.EscalateFrom).Name,
                                    BranchName = _userBusinessService.GetDetail(escalateData.EscalateFrom).AreaName == null ? "HEAD OFFICE" : _userBusinessService.GetDetail(escalateData.EscalateFrom).AreaName,
                                    POH_Name   = _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData.EscalateFrom).EmployeeId) == null ? null : _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData.EscalateFrom).EmployeeId).Business_Area,
                                };
                                EscalateData1.Add(userEscalate1);

                                TicketDiscussion replyEsFrom      = _ticketDiscussionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData.EscalateFrom);
                                TicketResolution ResolutionEsFrom = _ticketResolutionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData.EscalateFrom);
                                TicketNote       noteEsFrom       = _ticketNoteBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData.EscalateFrom);
                                TicketNote       noteesFrom       = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = noteEsFrom == null ? null : noteEsFrom.RespondTime /* new double[] { noteResponder == null ? 0 : noteResponder.RespondTime, replySubmiter == null ? 0 : replySubmiter.RespondTime, ResolutionResponder == null ? 0 : ResolutionResponder.RespondTime }.Max()*/
                                };
                                EscalatedFromNote.Add(noteesFrom);

                                TicketDiscussion replyEs1      = _ticketDiscussionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData.EscalateTo);
                                TicketResolution ResolutionEs1 = _ticketResolutionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData.EscalateTo);
                                TicketNote       noteEs1       = _ticketNoteBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData.EscalateTo);
                                TicketNote       notees1       = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = noteEs1 == null ? null : noteEs1.RespondTime /*new double[] { noteResponder == null ? 0 : noteResponder.RespondTime, replySubmiter == null ? 0 : replySubmiter.RespondTime, ResolutionResponder == null ? 0 : ResolutionResponder.RespondTime }.Max()*/
                                };
                                Escalated1Note.Add(notees1);
                            }
                            else
                            {
                                User userEscalate1 = new User()
                                {
                                    UserId     = ticket.TicketId,
                                    Name       = null,
                                    AreaName   = null,
                                    Username   = null,
                                    POH_Name   = null,
                                    BranchName = null,
                                    Position   = null
                                };
                                EscalateData1.Add(userEscalate1);
                                TicketNote noteesFrom = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = null
                                };
                                EscalatedFromNote.Add(noteesFrom);
                                TicketNote notees1 = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = null
                                };
                                Escalated1Note.Add(notees1);
                            }
                            if (escalateData2 != null)
                            {
                                User userEscalate2 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = _userBusinessService.GetDetail(escalateData2.EscalateTo).Name,
                                    AreaName = _userBusinessService.GetDetail(escalateData2.EscalateTo).AreaName == null ? "HEAD OFFICE" : _userBusinessService.GetDetail(escalateData2.EscalateTo).AreaName,
                                    POH_Name = _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData2.EscalateTo).EmployeeId) == null ? null : _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData2.EscalateTo).EmployeeId).Business_Area,
                                };
                                EscalateData2.Add(userEscalate2);
                                TicketDiscussion replyEs2      = _ticketDiscussionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData2.EscalateTo);
                                TicketResolution ResolutionEs2 = _ticketResolutionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData2.EscalateTo);
                                TicketNote       noteEs2       = _ticketNoteBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData2.EscalateTo);
                                TicketNote       notees2       = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = noteEs2 == null ? null : noteEs2.RespondTime/* new double[] { noteResponder == null ? 0 : noteResponder.RespondTime, replySubmiter == null ? 0 : replySubmiter.RespondTime, ResolutionResponder == null ? 0 : ResolutionResponder.RespondTime }.Max()*/
                                };
                                Escalated2Note.Add(notees2);
                            }
                            else
                            {
                                User userEscalate2 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = null,
                                    AreaName = null,
                                    POH_Name = null
                                };
                                EscalateData2.Add(userEscalate2);
                                TicketNote notees2 = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = null
                                };
                                Escalated2Note.Add(notees2);
                            }
                            if (escalateData3 != null)
                            {
                                User userEscalate3 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = _userBusinessService.GetDetail(escalateData3.EscalateTo).Name,
                                    AreaName = _userBusinessService.GetDetail(escalateData3.EscalateTo).AreaName == null ? "HEAD OFFICE" : _userBusinessService.GetDetail(escalateData3.EscalateTo).AreaName,
                                    POH_Name = _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData3.EscalateTo).EmployeeId) == null ? null : _mstEmployeeBService.GetDetail(_userBusinessService.GetDetail(escalateData3.EscalateTo).EmployeeId).Business_Area,
                                };
                                EscalateData3.Add(userEscalate3);
                                TicketDiscussion replyEs3      = _ticketDiscussionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData3.EscalateTo);
                                TicketResolution ResolutionEs3 = _ticketResolutionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData3.EscalateTo);
                                TicketNote       noteEs3       = _ticketNoteBusinessService.GetDatebyTicketandUserId(ticket.TicketId, escalateData3.EscalateTo);
                                TicketNote       notees3       = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = noteEs3 == null ? null : noteEs3.RespondTime/*new double[] { noteResponder == null ? 0 : noteResponder.RespondTime, replySubmiter == null ? 0 : replySubmiter.RespondTime, ResolutionResponder == null ? 0 : ResolutionResponder.RespondTime }.Max()*/
                                };
                                Escalated3Note.Add(notees3);
                            }
                            else
                            {
                                User userEscalate3 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = null,
                                    AreaName = null,
                                    POH_Name = null
                                };
                                EscalateData3.Add(userEscalate3);
                                TicketNote notees3 = new TicketNote()
                                {
                                    TicketNoteId = ticket.TicketId,
                                    RespondTime  = null
                                };
                                Escalated3Note.Add(notees3);
                            }
                        }
                        else
                        {
                            TicketNote noteres = new TicketNote()
                            {
                                TicketNoteId = ticket.TicketId,
                                RespondTime  = null
                            };
                            ResponderNote.Add(noteres);
                            TicketNote noteesFrom = new TicketNote()
                            {
                                TicketNoteId = ticket.TicketId,
                                RespondTime  = null
                            };
                            EscalatedFromNote.Add(noteesFrom);
                            TicketNote notees1 = new TicketNote()
                            {
                                TicketNoteId = ticket.TicketId,
                                RespondTime  = null
                            };
                            Escalated1Note.Add(notees1);
                            TicketNote notees2 = new TicketNote()
                            {
                                TicketNoteId = ticket.TicketId,
                                RespondTime  = null
                            };
                            Escalated2Note.Add(notees2);
                            TicketNote notees3 = new TicketNote()
                            {
                                TicketNoteId = ticket.TicketId,
                                RespondTime  = null
                            };
                            Escalated3Note.Add(notees3);

                            EscalatedFromNote.Add(noteesFrom);
                            if (ticket.Status != 1)
                            {
                                User responder = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = "TREND Admin",
                                    AreaName = "-",
                                    POH_Name = "-"
                                };
                                TicketPreview solveddate = new TicketPreview()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    Description = null,
                                    SolvedDate  = null
                                };
                                TicketPreview rateResponder = new TicketPreview()
                                {
                                    TicketId    = ticket.TicketId,
                                    Rate        = 0,
                                    Description = null
                                };
                                User userEscalate1 = new User()
                                {
                                    UserId     = ticket.TicketId,
                                    Name       = null,
                                    AreaName   = null,
                                    Username   = null,
                                    BranchName = null,
                                    POH_Name   = null,
                                    Position   = null
                                };
                                User userEscalate2 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = null,
                                    AreaName = null
                                };
                                User userEscalate3 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = null,
                                    AreaName = null
                                };
                                EscalateData1.Add(userEscalate1);
                                EscalateData2.Add(userEscalate2);
                                EscalateData3.Add(userEscalate3);
                                responderRating.Add(rateResponder);
                                solvedDate.Add(solveddate);
                                responders.Add(responder);
                            }
                            else
                            {
                                User responder = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = "",
                                    AreaName = "",
                                    POH_Name = ""
                                };
                                TicketPreview solveddate = new TicketPreview()
                                {
                                    TicketNo    = ticket.TicketNo,
                                    Description = null,
                                    SolvedDate  = null
                                };
                                TicketPreview rateResponder = new TicketPreview()
                                {
                                    TicketId    = ticket.TicketId,
                                    Rate        = 0,
                                    Description = null
                                };
                                User userEscalate1 = new User()
                                {
                                    UserId     = ticket.TicketId,
                                    Name       = null,
                                    AreaName   = null,
                                    Username   = null,
                                    POH_Name   = null,
                                    BranchName = null,
                                    Position   = null
                                };
                                User userEscalate2 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = null,
                                    AreaName = null,
                                    POH_Name = null
                                };
                                User userEscalate3 = new User()
                                {
                                    UserId   = ticket.TicketId,
                                    Name     = null,
                                    AreaName = null,
                                    POH_Name = null
                                };
                                EscalateData1.Add(userEscalate1);
                                EscalateData2.Add(userEscalate2);
                                EscalateData3.Add(userEscalate3);
                                responderRating.Add(rateResponder);
                                solvedDate.Add(solveddate);
                                responders.Add(responder);
                            }
                        }
                    }
                }
                ViewBag.RespondEsFrom    = EscalatedFromNote;
                ViewBag.RespondEs1       = Escalated1Note;
                ViewBag.RespondEs2       = Escalated2Note;
                ViewBag.RespondEs3       = Escalated3Note;
                ViewBag.NoteSubmiter     = SubmiterNote;
                ViewBag.NoteResponder    = ResponderNote;
                ViewBag.EscalatedLog1    = EscalateData1;
                ViewBag.EscalatedLog2    = EscalateData2;
                ViewBag.EscalatedLog3    = EscalateData3;
                ViewBag.RatingSubmiters  = submitersRating;
                ViewBag.RatingResponders = responderRating;
                ViewBag.SolvedDate       = solvedDate;
                ViewBag.Submiters        = submiters;
                ViewBag.Responders       = responders;

                return(View(ticketPreview.ToList()));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
 public void Save(TicketResolution resolution)
 {
     base.Save(resolution);
 }
 public TicketResolution Add(TicketResolution ticketResolution)
 {
     _dBtsics.TicketResolution.Add(ticketResolution);
     _dBtsics.SaveChanges();
     return(ticketResolution);
 }
Ejemplo n.º 6
0
        // GET: Admin/HelpDesk/Detail/5
        public ActionResult Detail(int?id)
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }
            if (id == null)
            {
                return(RedirectToAction("Index", "HelpDesk"));
            }

            Ticket ticket = _ticketBusinessService.GetDetail(int.Parse(id.ToString()));

            if (ticket == null)
            {
                return(HttpNotFound());
            }

            #region Involved Users

            List <int> involvedIdList = new List <int> {
                ticket.Submiter
            };
            if (ticket.Responder != 0)
            {
                involvedIdList.Add(ticket.Responder);
            }

            var participants = _ticketParcipantBusinessService.GetByTicket(ticket.TicketId);
            if (participants != null)
            {
                foreach (var participantItem in participants)
                {
                    involvedIdList.Add(participantItem.UserId);
                }
            }

            ViewBag.Participants = _ticketParcipantBusinessService.GetParticipantWithName(participants);
            ViewBag.IsInvolved   = false;

            if (involvedIdList.Contains(Convert.ToInt32(Session["useridbackend"])))
            {
                ViewBag.IsInvolved = true;
            }
            #endregion



            if (ticket.Status.Equals(6) || ticket.Status.Equals(3))
            {
                TicketResolution ticketResolution = _ticketResolutionBusinessService.GetByTicket(int.Parse(id.ToString()));

                DateTime createdAt   = DateTime.Parse(ticketResolution.CreatedAt.ToString());
                string   commenterAs = null;

                if (ticketResolution.UserId.Equals(ticket.Submiter))
                {
                    commenterAs = "Submiter";
                }
                else if (ticketResolution.UserId.Equals(ticket.Responder))
                {
                    commenterAs = "Responder";
                }

                var commenterName = _userBusinessService.GetDetail(ticketResolution.UserId).Name;

                JsonResolution resolution = new JsonResolution()
                {
                    Day           = createdAt.ToString("dddd, dd MMMM yy"),
                    Time          = createdAt.ToString("hh:mm tt"),
                    CommenterName = commenterName,
                    CommenterAs   = commenterAs,
                    Description   = ticketResolution.Description
                };

                ViewBag.Resolution     = resolution;
                ViewBag.ResolutionData = ticketResolution;
                var submiterRatingBack = _ratingBusinessService.GetRatingFromSubmiter(ticket.TicketId, ticket.Submiter);

                ViewBag.IsRatedBySubmiter = false;

                if (submiterRatingBack != null)
                {
                    ViewBag.IsRatedBySubmiter = true;
                }
            }

            #region Attachments


            var attachments = _ticketAttachmentBusinessService.GetFullByTicketId(ticket.TicketId);
            List <TicketAttachmentsAPI> listAttachment = new List <TicketAttachmentsAPI>();
            string attachmentsPath = System.Web.HttpContext.Current.Server.MapPath("~/Upload/TechnicalRequestAttachments/");
            if (attachments != null)
            {
                string[] imgExt = { ".jpg", ".png", ".jpeg", ".gif", ".bmp", ".tif", ".tiff" };
                foreach (var attachment in attachments)
                {
                    if (imgExt.Contains(Path.GetExtension(attachment.Name)))
                    {
                        listAttachment.Add(new TicketAttachmentsAPI
                        {
                            Id                = attachment.TicketAttachmentId,
                            Name              = Common.ImageToBase64(attachmentsPath + attachment.Name),
                            Level             = attachment.LevelUser,
                            Type              = Path.GetExtension(attachment.Name),
                            NameWithOutBase64 = attachment.Name,
                            Uri               = Common.GetDomainSecure() + "/Upload/TechnicalRequestAttachments/" + attachment.Name
                        });
                    }
                    else
                    {
                        listAttachment.Add(new TicketAttachmentsAPI
                        {
                            Id                = attachment.TicketAttachmentId,
                            Name              = attachment.Name,
                            Level             = attachment.LevelUser,
                            Type              = Path.GetExtension(attachment.Name),
                            NameWithOutBase64 = attachment.Name,
                            Uri               = Common.GetDomainSecure() + "/Upload/TechnicalRequestAttachments/" + attachment.Name
                        });
                    }
                }
            }
            ViewBag.Attachments = listAttachment;
            #endregion

            ViewBag.CategoryName = _ticketCategoryBusinessService.GetDetail(ticket.TicketCategoryId).Name;

            var userData = _userBusinessService.GetDetail(ticket.Submiter);
            ViewBag.Submiter       = userData;
            ViewBag.SubmiterUserId = ticket.Submiter;
            ViewBag.Responder      = ticket.Responder == 0 ? null : _userBusinessService.GetDetail(ticket.Responder);
            ViewBag.Tags           = _articleTagBusinessService.GetTagsByTicket(ticket.TicketId);
            ViewBag.Ticket         = ticket;
            ViewBag.Area           = userData.AreaName;
            ViewBag.Branch         = userData.BranchName;
            ViewBag.RoleId         = userData.RoleId;
            ViewBag.RoleName       = userData.RoleId == 0 ? "-" : _userRoleBusinessService.GetDetail(userData.RoleId).Name;
            ViewBag.UserLevelName  = userData.RoleId == 0 ? "-" : _userRoleBusinessService.GetDetail(userData.RoleId).Description;
            ViewBag.Stars          = _ratingBusinessService.GetRatingFromResponder(ticket.TicketId, ticket.Responder);
            ViewBag.StarsResponder = _ratingBusinessService.GetRatingFromSubmiter(ticket.TicketId, ticket.Submiter);
            return(View(ticket));
        }
Ejemplo n.º 7
0
        // GET: Admin/HelpDesk
        public ActionResult Index(int?page, String currentFilter, string sortOrder = "", String searchString = "")
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }

            ViewBag.CurrentSort    = sortOrder;
            ViewBag.DateSortParm   = String.IsNullOrEmpty(sortOrder) ? "DateDesc" : "";
            ViewBag.TitleSortParm  = sortOrder == "Title" ? "TitleDesc" : "Title";
            ViewBag.StatusSortParm = sortOrder == "Status" ? "StatusDesc" : "Status";

            var tickets = _ticketBusinessService.GetHelpDeskList();

            switch (sortOrder)
            {
            case "DateDesc":
                tickets = tickets.OrderBy(s => s.CreatedAt);
                break;

            case "Title":
                tickets = tickets.OrderBy(t => t.Title);
                break;

            case "TitleDesc":
                tickets = tickets.OrderByDescending(t => t.Title);
                break;

            case "Status":
                tickets = tickets.OrderBy(t => t.Status);
                break;

            case "StatusDesc":
                tickets = tickets.OrderByDescending(t => t.Status);
                break;

            default:
                tickets = tickets.OrderByDescending(t => t.CreatedAt);
                break;
            }

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            tickets = tickets.Where(ticket =>
                                    ticket.Title.Contains(searchString) ||
                                    ticket.TicketNo.Contains(searchString)
                                    );

            var ticketPreview = _ticketPreviewBusinessService.MakeFrom(tickets, 0);

            List <InvolvedUser>     submiters         = new List <InvolvedUser>();
            List <User>             responders        = new List <User>();
            List <TicketResolution> ticketresolutions = new List <TicketResolution>();
            List <TicketPreview>    ratings           = new List <TicketPreview>();
            List <TicketPreview>    ratingresponders  = new List <TicketPreview>();
            List <User>             userData          = new List <User>();
            List <TicketPreview>    userRoles         = new List <TicketPreview>();
            List <TicketNote>       SubmiterNote      = new List <TicketNote>();
            List <TicketNote>       ResponderNote     = new List <TicketNote>();

            if (ticketPreview != null)
            {
                foreach (var ticket in ticketPreview)
                {
                    User             submiterData   = _userBusinessService.GetDetail(ticket.Submiter);
                    TicketResolution resolutionData = _ticketResolutionBusinessService.GetByTicket(ticket.TicketId);
                    Rating           ratingData     = _ratingBusinessService.GetRatingFromSubmiter(ticket.TicketId, ticket.Submiter);
                    TicketNote       noteSubmiter   = _TicketNote.GetDatebyTicketandUserId(ticket.TicketId, ticket.Submiter);
                    TicketDiscussion replySubmiter  = _ticketDiscussionBs.GetDatebyTicketandUserId(ticket.TicketId, ticket.Submiter) == null ? null : _ticketDiscussionBs.GetDatebyTicketandUserId(ticket.TicketId, ticket.Submiter);

                    TicketNote notesubmiter = new TicketNote()
                    {
                        TicketNoteId = ticket.TicketId,
                        RespondTime  = noteSubmiter == null ? null: noteSubmiter.RespondTime
                    };
                    SubmiterNote.Add(notesubmiter);

                    if (ratingData != null)
                    {
                        TicketPreview ratingdata = new TicketPreview()
                        {
                            TicketId   = ticket.TicketId,
                            ClosedDate = ratingData.CreatedAt,
                            Rate       = ratingData.Rate
                        };
                        ratings.Add(ratingdata);
                    }
                    else
                    {
                        TicketPreview ratingdata = new TicketPreview()
                        {
                            TicketId   = ticket.TicketId,
                            ClosedDate = null,
                            Rate       = 0
                        };
                        ratings.Add(ratingdata);
                    }
                    if (resolutionData != null)
                    {
                        TicketResolution resolutiondata = new TicketResolution()
                        {
                            TicketId  = ticket.TicketId,
                            CreatedAt = resolutionData.CreatedAt
                        };
                        ticketresolutions.Add(resolutiondata);
                    }
                    else
                    {
                        TicketResolution resolutiondata = new TicketResolution()
                        {
                            TicketId  = ticket.TicketId,
                            CreatedAt = null
                        };
                        ticketresolutions.Add(resolutiondata);
                    }
                    if (submiterData != null)
                    {
                        if (submiterData.RoleId == 0)
                        {
                            TicketPreview userrole = new TicketPreview()
                            {
                                TicketNo = ticket.TicketNo,
                                RoleName = "-"
                            };
                            userRoles.Add(userrole);
                        }
                        else
                        {
                            TicketPreview userrole = new TicketPreview()
                            {
                                TicketNo = ticket.TicketNo,
                                RoleName = _userRoleBusinessService.GetDetail(submiterData.RoleId).Name
                            };
                            userRoles.Add(userrole);
                        }
                        InvolvedUser submiter = new InvolvedUser()
                        {
                            TicketNo    = ticket.TicketNo,
                            EmployeName = _userBusinessService.GetDetail(ticket.Submiter).Name,
                        };
                        User userdata = new User()
                        {
                            Username   = ticket.TicketNo,
                            BranchName = submiterData.BranchName,
                            AreaName   = submiterData.AreaName,
                            POH_Name   = _EmployeeMasterBusinessService.GetDetail(submiterData.EmployeeId) == null ?"N/A" : _EmployeeMasterBusinessService.GetDetail(submiterData.EmployeeId).Business_Area
                        };


                        userData.Add(userdata);
                        submiters.Add(submiter);
                    }
                    else
                    {
                        TicketPreview userrole = new TicketPreview()
                        {
                            TicketNo = ticket.TicketNo,
                            RoleName = ""
                        };
                        InvolvedUser submiter = new InvolvedUser()
                        {
                            TicketNo    = ticket.TicketNo,
                            EmployeName = ""
                        };
                        User userdata = new User()
                        {
                            Username   = ticket.TicketNo,
                            BranchName = "",
                            AreaName   = ""
                        };
                        userData.Add(userdata);
                        userRoles.Add(userrole);
                        submiters.Add(submiter);
                    }
                    if (ticket.Responder != 0)
                    {
                        User             responderData       = _userBusinessService.GetDetail(ticket.Responder);
                        Rating           ratingDataResponder = _ratingBusinessService.GetRatingFromResponder(ticket.TicketId, ticket.Responder);
                        TicketNote       noteResponder       = _TicketNote.GetDatebyTicketandUserId(ticket.TicketId, ticket.Responder);
                        TicketDiscussion replyResponder      = _ticketDiscussionBs.GetDatebyTicketandUserId(ticket.TicketId, ticket.Responder);
                        TicketResolution ResolutionResponder = _ticketResolutionBusinessService.GetDatebyTicketandUserId(ticket.TicketId, ticket.Submiter);

                        TicketNote noteresponder = new TicketNote()
                        {
                            TicketNoteId = ticket.TicketId,
                            RespondTime  = noteResponder == null ? null : noteResponder.RespondTime /* new double[] { noteSubmiter == null ? 0 : noteSubmiter.RespondTime, replySubmiter == null ? 0 : replySubmiter.RespondTime, ResolutionResponder == null ? 0 : ResolutionResponder.RespondTime }.Max()*/
                        };
                        ResponderNote.Add(noteresponder);


                        if (responderData != null)
                        {
                            User responderdata = new User()
                            {
                                Username = ticket.TicketNo,
                                Name     = responderData.Name
                            };

                            responders.Add(responderdata);
                        }
                        else
                        {
                            User responderdata = new User()
                            {
                                Username = ticket.TicketNo,
                                Name     = null
                            };

                            responders.Add(responderdata);
                        }
                        if (ratingDataResponder != null)
                        {
                            TicketPreview ratingdataresponder = new TicketPreview()
                            {
                                TicketId   = ticket.TicketId,
                                ClosedDate = ratingDataResponder.CreatedAt,
                                Rate       = ratingDataResponder.Rate
                            };
                            ratingresponders.Add(ratingdataresponder);
                        }
                        else
                        {
                            TicketPreview ratingdataresponder = new TicketPreview()
                            {
                                TicketId   = ticket.TicketId,
                                ClosedDate = null,
                                Rate       = 0
                            };
                            ratingresponders.Add(ratingdataresponder);
                        }
                    }
                    else
                    {
                        TicketNote noteresponder = new TicketNote()
                        {
                            TicketNoteId = ticket.TicketId,
                            RespondTime  = null
                        };
                        ResponderNote.Add(noteresponder);
                        TicketPreview ratingdataresponder = new TicketPreview()
                        {
                            TicketId   = ticket.TicketId,
                            ClosedDate = null,
                            Rate       = 0
                        };
                        User responderdata = new User()
                        {
                            Username = ticket.TicketNo,
                            Name     = null
                        };

                        responders.Add(responderdata);
                        ratingresponders.Add(ratingdataresponder);
                    }
                }
            }
            ViewBag.NoteSubmiter     = SubmiterNote;
            ViewBag.NoteResponder    = ResponderNote;
            ViewBag.Responders       = responders;
            ViewBag.RatingResponders = ratingresponders;
            ViewBag.Rating           = ratings;
            ViewBag.Resolution       = ticketresolutions;
            ViewBag.UserData         = userData;
            ViewBag.User             = userRoles;
            ViewBag.Submiters        = submiters;
            int pageSize   = 999999999;
            int pageNumber = (page ?? 1);

            return(View(tickets.ToPagedList(pageNumber, pageSize)));
        }