Exemple #1
0
        public ActionResult Update(string id)
        {
            if (Session["userid"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                if (WebConfigure.GetLoginPortal() == "true" && Common.GetUserXupj().ToLower() != Session["username"].ToString().ToLower())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                ViewBag.Domain = WebConfigure.GetDomain() + "/Upload/TechnicalRequestAttachments/";
                if (id != null)
                {
                    string ticketCategory = _ticketBs.GetCategoryName(id);

                    var ticket             = _ticketBs.GetByTicketNumber(id);
                    var ticketParticipants = _ticketParticipantBusinessService.GetByTicket(ticket.TicketId);
                    if (!((ticket.Status.Equals(2) && Convert.ToInt32(Session["userid"]) == ticket.Responder) || (ticket.Status.Equals(1) && Convert.ToInt32(Session["userid"]) == ticket.Submiter)))
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('You are Not Included with This Technical Request'); location.href = '" + WebConfigure.GetDomain() + "/MyTechnicalRequest';</script>"));
                    }
                    if (Convert.ToInt32(Session["DelegateStatus"]) == 1)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Cant Update Technical Request During Delegation Period'); location.href = '" + WebConfigure.GetDomain() + "/MyTechnicalRequest';</script>"));
                    }
                    if (ticket.Status == 1 && ticket.Submiter != Convert.ToInt32(Session["userid"]))
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('The Technical Request is Not Found'); location.href = '" + WebConfigure.GetDomain() + "/TechnicalRequest';</script>"));
                    }
                    var responder   = _userBusinessService.GetDetail(ticket.Responder);
                    var attachments = _ticketAttachmentBs.GetFullByTicketId(ticket.TicketId);
                    List <TicketAttachmentsAPI> listAttachment = new List <TicketAttachmentsAPI>();
                    string attachmentsPath = System.Web.HttpContext.Current.Server.MapPath("~/Upload/TechnicalRequestAttachments/");
                    if (attachments != null)
                    {
                        foreach (var attachment in attachments)
                        {
                            string[] imgExt = { ".jpg", ".png", ".jpeg", ".gif", ".bmp", ".tif", ".tiff" };

                            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
                                });
                            }
                            else
                            {
                                listAttachment.Add(new TicketAttachmentsAPI
                                {
                                    Id                = attachment.TicketAttachmentId,
                                    Name              = attachment.Name,
                                    Level             = attachment.LevelUser,
                                    Type              = Path.GetExtension(attachment.Name),
                                    NameWithOutBase64 = attachment.Name
                                });
                            }
                        }
                    }

                    var tags = _articleTagBs.GetTagsByTicket(ticket.TicketId);
                    WarrantyTypeBusinessService warrantyTypeBusinessService = Factory.Create <WarrantyTypeBusinessService>("WarrantyType", ClassType.clsTypeBusinessService);
                    ViewBag.warrantyType = warrantyTypeBusinessService.Get();
                    ViewBag.Ticket       = ticket;
                    ViewBag.Attachments  = listAttachment;
                    ViewBag.Tags         = tags;
                    ViewBag.Responder    = responder;

                    if (ticketParticipants != null)
                    {
                        ViewBag.Participants = _ticketParticipantBusinessService.GetParticipantWithName(ticketParticipants);
                    }
                    ViewBag.Recent = TechnicalRequest.GetRecentTR(Convert.ToInt32(Session["userid"]));

                    SetListDropdown(int.Parse(Session["userid"].ToString()));

                    return(View("../TechnicalRequest/Update" + ticketCategory));
                }

                return(RedirectToAction("Index", "MyTechnicalRequest"));
            }
        }
Exemple #2
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));
        }