Ejemplo n.º 1
0
        public void MockInsert()
        {
            for (int i = 0; i < 100000; i++)
            {
                var generate      = new GenerateTicketNo();
                var applicationNo =
                    generate.ApplicationNo(_category.GetCategoryCodeByCategoryId(1));

                var tickets = new Tickets();
                tickets.TicketId       = 0;
                tickets.CreatedDate    = DateTime.Now;
                tickets.TrackingId     = applicationNo;
                tickets.StatusAssigned = false;
                tickets.Contact        = "9999999999";
                tickets.Email          = "*****@*****.**";
                tickets.PriorityId     = 3;
                tickets.CategoryId     = 1;
                tickets.Name           = "Joejoe";
                tickets.UserId         = Convert.ToInt32(_sessionHandler.UserId);

                var message = @"<p>Lorem Ipsum&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
            Thanks & Regards,
            IT Analyst
            ";

                var ticketDetails = new TicketDetails()
                {
                    Subject         = "Lorem Ipsum is simply dummy text of the printing and typesetting indus",
                    Message         = message,
                    TicketDetailsId = 0
                };

                var ticketId = _tickets.AddTickets(Convert.ToInt64(_sessionHandler.UserId), tickets, ticketDetails, null, null);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(TicketsViewModel ticketsViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (ticketsViewModel.HiddenUserId == null)
                    {
                        ticketsViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                        ticketsViewModel.ListofPriority = _priority.GetAllPrioritySelectListItem();
                        ticketsViewModel.Message        = string.Empty;
                        ModelState.Remove("Message");
                        TempData["ErrorMessageTicket"] = "Name is AutoComplete field Don't Enter Name Choose.";
                        return(View(ticketsViewModel));
                    }

                    var file          = Request.Files;
                    var generate      = new GenerateTicketNo();
                    var applicationNo =
                        generate.ApplicationNo(_category.GetCategoryCodeByCategoryId(ticketsViewModel.CategoryId));

                    var tickets = AutoMapper.Mapper.Map <Tickets>(ticketsViewModel);
                    tickets.TicketId       = 0;
                    tickets.CreatedDate    = DateTime.Now;
                    tickets.TrackingId     = applicationNo;
                    tickets.StatusAssigned = false;
                    tickets.InternalUserId = Convert.ToInt64(_sessionHandler.UserId);

                    var message       = AppendSignature(ticketsViewModel.Message);
                    var ticketDetails = new TicketDetails()
                    {
                        Subject         = ticketsViewModel.Subject,
                        Message         = message,
                        TicketDetailsId = 0
                    };

                    var attachments       = new Attachments();
                    var attachmentdetails = new AttachmentDetails();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachments = new List <Attachments>();
                    // ReSharper disable once CollectionNeverQueried.Local
                    var listofattachmentdetails = new List <AttachmentDetails>();

                    for (int i = 0; i <= file.Count - 1; i++)
                    {
                        if (file[i] != null && file[i].ContentLength > 0)
                        {
                            string extension = Path.GetExtension(file[i].FileName);
                            attachments.UserId         = Convert.ToInt64(_sessionHandler.UserId);
                            attachments.AttachmentName = file[i].FileName;
                            attachments.AttachmentType = extension;
                            attachments.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);
                                    attachmentdetails.AttachmentBytes = fileSize;
                                }
                            }

                            listofattachments.Add(attachments);
                            listofattachmentdetails.Add(attachmentdetails);
                        }
                    }

                    var ticketId = _tickets.AddTickets(ticketsViewModel.HiddenUserId, tickets, ticketDetails, listofattachments, listofattachmentdetails);

                    if (ticketId != -1)
                    {
                        TempData["MessageTicket"] = applicationNo + ' ' + CommonMessages.TicketSuccessMessages;

                        TicketHistoryHelper ticketHistoryHelper = new TicketHistoryHelper();
                        var ticketHistory = new TicketHistory();
                        ticketHistory.UserId       = Convert.ToInt32(_sessionHandler.UserId);
                        ticketHistory.Message      = ticketHistoryHelper.CreateMessage(tickets.PriorityId, tickets.CategoryId);
                        ticketHistory.CategoryId   = tickets.CategoryId;
                        ticketHistory.PriorityId   = tickets.PriorityId;
                        ticketHistory.StatusId     = Convert.ToInt16(StatusMain.Status.Open);
                        ticketHistory.ProcessDate  = DateTime.Now;
                        ticketHistory.TicketId     = ticketId;
                        ticketHistory.ActivitiesId = Convert.ToInt16(StatusMain.Activities.Created);
                        _ticketHistory.TicketHistory(ticketHistory);
                    }
                    else
                    {
                        TempData["ErrorMessageTicket"] = CommonMessages.TicketErrorMessages;
                    }

                    return(RedirectToAction("Create", "TicketHOD"));
                }
                else
                {
                    ticketsViewModel.ListofCategory = _category.GetAllActiveSelectListItemCategory();
                    ticketsViewModel.ListofPriority = _priority.GetAllPrioritySelectListItem();
                    return(View(ticketsViewModel));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }