コード例 #1
0
        public void TicketHistory(TicketReplyModel ticketReplyModel, string replied)
        {
            try
            {
                string message = string.Empty;

                TicketHistoryHelper ticketHistoryHelper = new TicketHistoryHelper();
                var ticketHistory = new TicketHistory();
                if (!string.IsNullOrEmpty(replied))
                {
                    message = ticketHistoryHelper.ReplyMessage(Convert.ToInt16(StatusMain.Status.Replied));
                    ticketHistory.StatusId = Convert.ToInt16(StatusMain.Status.Replied);
                }

                TempData["TicketReplyMessage"] = CommonMessages.TicketSuccessReplyMessages;

                ticketHistory.UserId       = Convert.ToInt32(_sessionHandler.UserId);
                ticketHistory.Message      = message;
                ticketHistory.ProcessDate  = DateTime.Now;
                ticketHistory.TicketId     = ticketReplyModel.TicketId;
                ticketHistory.ActivitiesId = Convert.ToInt16(StatusMain.Activities.Replied);
                _ticketHistory.TicketHistory(ticketHistory);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public ActionResult Details(TicketReplyModel ticketReplyModel, string resolved, string inprogress, string onHold, string replied)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var file     = Request.Files;
                    var statusId = 0;

                    if (!string.IsNullOrEmpty(resolved))
                    {
                        statusId = (int)StatusMain.Status.Resolved;
                    }
                    else if (!string.IsNullOrEmpty(inprogress))
                    {
                        statusId = (int)StatusMain.Status.InProgress;
                    }
                    else if (!string.IsNullOrEmpty(onHold))
                    {
                        statusId = (int)StatusMain.Status.OnHold;
                    }
                    else if (!string.IsNullOrEmpty(replied))
                    {
                        statusId = (int)StatusMain.Status.Replied;
                    }

                    ReplyAttachment        replyAttachment        = new ReplyAttachment();
                    ReplyAttachmentDetails replyAttachmentDetails = new ReplyAttachmentDetails();

                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachments = new List <ReplyAttachment>();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachmentdetails = new List <ReplyAttachmentDetails>();

                    for (int i = 0; i <= file.Count - 1; i++)
                    {
                        if (file[i] != null && file[i].ContentLength > 0)
                        {
                            string extension = Path.GetExtension(file[i].FileName);
                            replyAttachment.SystemUser     = Convert.ToInt64(_sessionHandler.UserId);
                            replyAttachment.AttachmentName = file[i].FileName;
                            replyAttachment.AttachmentType = extension;
                            replyAttachment.CreatedDate    = DateTime.Now;
                            var inputStream = file[i].InputStream;
                            if (inputStream != null)
                            {
                                using (var binaryReader = new BinaryReader(inputStream))
                                {
                                    byte[] fileSize = binaryReader.ReadBytes(count: file[i].ContentLength);
                                    replyAttachmentDetails.AttachmentBytes = fileSize;
                                }
                            }

                            listofattachments.Add(replyAttachment);
                            listofattachmentdetails.Add(replyAttachmentDetails);
                        }
                    }


                    var userId = Convert.ToInt64(_sessionHandler.UserId);

                    var message = AppendString(ticketReplyModel.Message);
                    ticketReplyModel.Message = message;

                    _ticketsReply.ReplyTicket(ticketReplyModel, listofattachments, listofattachmentdetails, null, userId, statusId);

                    var ticket = _displayTickets.TicketsDetailsbyticketId(ticketReplyModel.TrackingId);
                    ticket.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    ticket.ListofStatus   = _status.GetAllStatusWithoutOverdueandEscalationSelectListItem();
                    ticket.TicketReply    = new TicketReplyModel()
                    {
                        Message    = string.Empty,
                        TicketId   = ticket.TicketId,
                        TrackingId = ticket.TrackingId
                    };

                    var listofTicketreply = _ticketsReply.ListofHistoryTicketReplies(ticketReplyModel.TrackingId);

                    if (listofTicketreply != null)
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId);
                        ticket.ViewMainModel     = new ViewTicketReplyMainModel()
                        {
                            ListofReplyAttachment = _attachments.GetListReplyAttachmentsByAttachmentId(ticketReplyModel.TicketId)
                        };
                    }
                    else
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId) ??
                                                   new List <Attachments>();

                        ticket.ViewMainModel = new ViewTicketReplyMainModel()
                        {
                            ListofTicketreply     = new List <ViewTicketReplyHistoryModel>(),
                            ListofReplyAttachment = new List <ReplyAttachment>()
                        };
                    }

                    TicketHistory(ticketReplyModel, resolved, inprogress, onHold, replied);
                    TempData["TicketReplyMessage"] = CommonMessages.TicketSuccessReplyMessages;

                    return(RedirectToAction("Details", "TicketDetailsAdmin", new { trackingId = ticket.TrackingId }));
                }
                else
                {
                    var ticket = _displayTickets.TicketsDetailsbyticketId(ticketReplyModel.TrackingId);
                    ticket.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    ticket.ListofStatus   = _status.GetAllStatusWithoutOverdueandEscalationSelectListItem();
                    ticket.EscalatedUser  = _userMaster.GetTicketEscalatedToUserNames(ticket.TicketId);
                    ticket.ListofCategory = _category.GetAllActiveSelectListItemCategory();

                    ticket.TicketReply = new TicketReplyModel()
                    {
                        Message    = string.Empty,
                        TicketId   = ticket.TicketId,
                        TrackingId = ticket.TrackingId
                    };
                    var listofTicketreply = _ticketsReply.ListofHistoryTicketReplies(ticketReplyModel.TrackingId);

                    if (listofTicketreply.Count > 0)
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId) ??
                                                   new List <Attachments>();

                        ticket.ViewMainModel = new ViewTicketReplyMainModel()
                        {
                            ListofReplyAttachment = _attachments.GetListReplyAttachmentsByAttachmentId(ticketReplyModel.TicketId),
                            ListofTicketreply     = listofTicketreply
                        };
                    }
                    else
                    {
                        ticket.ListofAttachments = _attachments.GetListAttachmentsByAttachmentId(ticketReplyModel.TicketId) ??
                                                   new List <Attachments>();

                        ticket.ViewMainModel = new ViewTicketReplyMainModel()
                        {
                            ListofTicketreply     = new List <ViewTicketReplyHistoryModel>(),
                            ListofReplyAttachment = new List <ReplyAttachment>()
                        };
                    }

                    TempData["TicketReplyMessage"] = CommonMessages.TicketErrorReplyMessages;
                    return(View(ticket));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public void ReplyTicket(TicketReplyModel ticketReplyModel, List <ReplyAttachment> replyAttachment, List <ReplyAttachmentDetails> replyAttachmentDetails,
                                long?fromuser, long?systemuser, int?status)
        {
            using (SqlConnection con =
                       new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString))
            {
                con.Open();
                SqlTransaction transaction = con.BeginTransaction();
                try
                {
                    var paramTicketReply = new DynamicParameters();
                    paramTicketReply.Add("@CreatedDateDisplay", DateTime.Now.ToString(CultureInfo.InvariantCulture));
                    paramTicketReply.Add("@CreatedDate", DateTime.Now);
                    paramTicketReply.Add("@TicketUser", fromuser);
                    paramTicketReply.Add("@SystemUser", systemuser);
                    paramTicketReply.Add("@TicketId", ticketReplyModel.TicketId);
                    paramTicketReply.Add("@DeleteStatus", 0);
                    paramTicketReply.Add("@TicketReplyId", dbType: DbType.Int64, direction: ParameterDirection.Output);
                    var resultticketReply = con.Execute("Usp_Insert_TicketReply", paramTicketReply, transaction, 0,
                                                        CommandType.StoredProcedure);
                    long ticketReplyId = paramTicketReply.Get <Int64>("@TicketReplyId");


                    if (status != null)
                    {
                        var paramstatus = new DynamicParameters();
                        paramstatus.Add("@StatusId", status);
                        paramstatus.Add("@TicketId", ticketReplyModel.TicketId);
                        var resultstatus = con.Execute("Usp_UpdateTicketStatusbyTicketId", paramstatus, transaction, 0,
                                                       CommandType.StoredProcedure);
                    }

                    var paramTicketReplyDetails = new DynamicParameters();
                    paramTicketReplyDetails.Add("@TicketReplyId", ticketReplyId);
                    paramTicketReplyDetails.Add("@Message", ticketReplyModel.Message);
                    paramTicketReplyDetails.Add("@Note", ticketReplyModel.Note);
                    var resultTicketReplyDetails = con.Execute("Usp_Insert_TicketReplyDetails", paramTicketReplyDetails,
                                                               transaction, 0, CommandType.StoredProcedure);

                    if (replyAttachment.Count > 0)
                    {
                        for (var i = 0; i < replyAttachment.Count; i++)
                        {
                            var objattachments        = replyAttachment[i];
                            var objattachmentsdetails = replyAttachmentDetails[i];

                            var paramReplyAttachment = new DynamicParameters();
                            paramReplyAttachment.Add("@AttachmentName", objattachments.AttachmentName);
                            paramReplyAttachment.Add("@AttachmentType", objattachments.AttachmentType);
                            paramReplyAttachment.Add("@TicketUser", fromuser);
                            paramReplyAttachment.Add("@SystemUser", systemuser);
                            paramReplyAttachment.Add("@TicketReplyId", ticketReplyId);
                            paramReplyAttachment.Add("@TicketId", ticketReplyModel.TicketId);
                            paramReplyAttachment.Add("@AttachmentBytes", objattachmentsdetails.AttachmentBytes);
                            var resultAttachment = con.Execute("Usp_Insert_ReplyAttachment", paramReplyAttachment,
                                                               transaction, 0, CommandType.StoredProcedure);
                        }
                    }

                    transaction.Commit();
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }