Exemple #1
0
        public TicketCreateResponse GenerateTicketCreateRequest(TicketCredencials ticketCredencials, TicketBodyCreateRequest ticket, List <AttachmentRequest> attachment)
        {
            string   TARGETURL = ticketCredencials.WebBaseUrl;
            DateTime now       = DateTime.Now;

            TicketBodyCreateRequest ticketRequest = new TicketBodyCreateRequest();

            ticketRequest.Year              = now.ToString("yyyy");
            ticketRequest.Month             = now.ToString("MM");
            ticketRequest.Day               = now.ToString("dd");
            ticketRequest.Hour              = now.ToString("HH");
            ticketRequest.Minute            = now.ToString("mm");
            ticketRequest.UserLogin         = ticketCredencials.UserLogin;
            ticketRequest.CustomerUserLogin = ticketCredencials.CustomerUserLogin;
            ticketRequest.Password          = ticketCredencials.Password;
            ticketRequest.Ticket            = ticket.Ticket;
            ticketRequest.Article           = ticket.Article;
            if (attachment.Count() > 0)
            {
                ticketRequest.Attachment = attachment;
            }
            var response = JsonCreateTicketOtrs(TARGETURL, ticketRequest);

            return(response);
        }
Exemple #2
0
        public TicketUpdateResponse UpdateTicketOtrs(TicketCredencials ticketCredencials, TicketIncidenceCreate ticket)
        {
            TicketBodyUpdateRequest ticketRequest = new TicketBodyUpdateRequest {
                Article = new ArticleRequest()
                {
                    Subject     = _OTRSOptions.TicketArticleSubjectUpdate,
                    Body        = ticket.Description,
                    ContentType = "text/plain; charset=utf8",
                    SenderType  = "customer",
                    TimeUnit    = "0"
                }
            };
            List <AttachmentRequest> attachments = new List <AttachmentRequest>();

            foreach (TicketAttachments file in ticket.Attachments)
            {
                attachments.Add(new AttachmentRequest {
                    Content = file.Base64, ContentType = file.ContentType, Filename = file.FileName
                });
            }

            var result = _OTRSClientRest.GenerateTicketUpdateRequest(ticket.TicketId, ticketCredencials, ticketRequest, attachments);

            return(result);
        }
Exemple #3
0
        public TicketUpdateResponse GenerateTicketUpdateRequest(long ticketId, TicketCredencials ticketCredencials, TicketBodyUpdateRequest ticket, List <AttachmentRequest> attachment)
        {
            string TARGETURL = ticketCredencials.WebBaseUrl + "/" + ticketId;

            TicketBodyUpdateRequest ticketRequest = new TicketBodyUpdateRequest();

            ticketRequest.UserLogin         = ticketCredencials.UserLogin;
            ticketRequest.CustomerUserLogin = ticketCredencials.CustomerUserLogin;
            ticketRequest.Password          = ticketCredencials.Password;
            ticketRequest.Article           = ticket.Article;
            if (attachment.Count() > 0)
            {
                ticketRequest.Attachment = attachment;
            }
            var response = JsonUpdateTicketOtrs(TARGETURL, ticketRequest);

            return(response);
        }
Exemple #4
0
        public TicketCreateResponse AddTicketIncidenceOtrs(TicketCredencials ticketCredencials, TicketIncidenceCreate ticket)
        {
            var service = _OTRSContext.VwService.Find(ticket.OtrsServiceId);

            TicketBodyCreateRequest ticketRequest = new TicketBodyCreateRequest {
                Ticket = new TicketParametersCreateRequest()
                {
                    Title        = service.Name + ": " + ticket.Asset.Name,
                    CustomerUser = ticket.UserCip,
                    Queue        = _OTRSOptions.TicketIncidenceQueueName,
                    Priority     = _OTRSOptions.TicketPriorityLow,
                    State        = _OTRSOptions.TicketStateNew,
                    TypeID       = int.Parse(service.TypeService),
                    ServiceID    = service.Id
                },
                Article = new ArticleRequest()
                {
                    Subject     = service.TypeServiceName,
                    Body        = ticket.Description,
                    ContentType = "text/plain; charset=utf8",
                    SenderType  = "customer",
                    TimeUnit    = "0"
                }
            };
            List <AttachmentRequest> attachments = new List <AttachmentRequest>();

            foreach (TicketAttachments file in ticket.Attachments)
            {
                attachments.Add(new AttachmentRequest {
                    Content = file.Base64, ContentType = file.ContentType, Filename = file.FileName
                });
            }

            TicketCreateResponse response = null;

            try {
                response = _OTRSClientRest.GenerateTicketCreateRequest(ticketCredencials, ticketRequest, attachments);
            } catch (System.Exception) {
                throw;
            }


            return(response);
        }
Exemple #5
0
        public TicketCreateResponse AddStolenAlert(TicketCredencials ticketCredencials, StolenAlert stolenAlert)
        {
            var service = _OTRSContext.VwService.Find(stolenAlert.OtrsServiceId);

            TicketBodyCreateRequest ticketRequest = new TicketBodyCreateRequest();

            ticketRequest.Ticket = new TicketParametersCreateRequest()
            {
                Title        = _OTRSOptions.StolenAlertTicketTitle + " " + stolenAlert.Asset.Name,
                CustomerUser = stolenAlert.UserCip,
                Queue        = _OTRSOptions.StolenAlertQueueName,
                Priority     = _OTRSOptions.TicketPriorityLow,
                State        = _OTRSOptions.TicketStateNew,
                TypeID       = int.Parse(service.TypeService),
                ServiceID    = service.Id
            };
            ticketRequest.Article = new ArticleRequest()
            {
                Subject     = service.TypeServiceName,
                Body        = $"Robo del siguiente activo: Código: {stolenAlert.Asset.Id}, Modelo: {stolenAlert.Asset.Name}, Serie: {stolenAlert.Asset.SerieNro}",
                ContentType = "text/plain; charset=utf8",
                SenderType  = "customer",
                TimeUnit    = "0"
            };

            List <AttachmentRequest> attachments = new List <AttachmentRequest>
            {
                new AttachmentRequest {
                    Content = stolenAlert.PoliceReport.Base64, ContentType = stolenAlert.PoliceReport.ContentType, Filename = stolenAlert.PoliceReport.FileName
                },
                new AttachmentRequest {
                    Content = stolenAlert.Affidavit.Base64, ContentType = stolenAlert.Affidavit.ContentType, Filename = stolenAlert.Affidavit.FileName
                }
            };

            var result = _OTRSClientRest.GenerateTicketCreateRequest(ticketCredencials, ticketRequest, attachments);

            return(result);
        }