public HttpResponseMessage updateSettingSla(int id, [FromUri] TicketSLA instance) { if (ticketService.isSLAExisted(instance)) { return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, new { msg = "This SLA was existed" })); } else { return(Request.CreateResponse(HttpStatusCode.OK, ticketService.updateSla(instance))); } }
protected void markFirstResponse() { if (!ticket.FirstResponse && ticket.PriorityId > 0 && activityConfig.FirstResponseMarked) { TicketSLA sla = dataProcessingProvider.getSLAByPriority(ticket.PriorityId); var firstResponseDate = ticket.CreatedDate.AddSeconds(sla.FirstResponsePeriod); if (firstResponseDate.CompareTo(DateTime.Now) >= 0) { ticket.FirstResponse = true; } } }
public TicketSLA updateSla(TicketSLA instance) { try { slaRepo.Update(instance); return(instance); }catch (Exception e) { Console.WriteLine(e.StackTrace); return(instance); } }
public TicketSLA addNewSla(TicketSLA instance) { try { slaRepo.Add(instance); return(instance); }catch (Exception e) { Console.WriteLine(e.StackTrace); return(instance); } }
private DateTime getDueDate(TicketSLA sla, DateTime createdDate) { return(createdDate.AddSeconds(sla.GracePeriod)); }
private void saveTicket() { TicketSLA sla = null; //SLA = mapping between ticket type and priority, Veasna-20170213 if (ticketParam.PriorityId > 0 && ticketParam.TicketTypeId > 0) { sla = dataProcessingProvider.getSLAByPriorityAndTicketType(ticketParam.PriorityId, ticketParam.TicketTypeId); } if (ticket != null) { //Prevent set requestor to none emp(0) if requestor from unknow employee if (ticket.RequestorId == -1 && ticketParam.RequestorId == 0) { ticketParam.RequestorId = -1; } //Prevent set requestor to none emp(0) if submitter is system account(K2 service ..etc) if ("GENERIC".Equals(requestor.EmpType) && ticketParam.RequestorId == 0) { ticketParam.RequestorId = ticket.RequestorId; } if (sla != null && ticket.CreatedDate != null && ticket.PriorityId != ticketParam.PriorityId && ticketParam.DueDate == null) { ticketParam.DueDate = getDueDate(sla, ticket.CreatedDate); } ticket = dataProcessingProvider.getTicket(ticketParam.TicketId); ticket.TicketTypeId = ticketParam.TicketTypeId; ticket.SiteId = ticketParam.SiteId; //No need to update //ticket.SubmitterId = ticketParam.CurrLoginUserId; ticket.RequestorId = ticketParam.RequestorId; ticket.PriorityId = ticketParam.PriorityId; ticket.UrgentcyId = ticketParam.UrgencyId; ticket.ImpactId = ticketParam.ImpactId; ticket.SourceId = ticketParam.SourceId; //Ticket status will be handle by assign ticket activity task //if (ticketParam.StatusId > 0) //{ // ticket.StatusId = ticketParam.StatusId; //} ticket.TicketItemId = getTicketItemId(); ticket.Subject = ticketParam.Subject; ticket.Description = ticketParam.Description; ticket.LastAction = getAction(); ticket.DueDate = ticketParam.DueDate; ticket.EstimatedHours = ticketParam.EstimatedHours; ticket.LastActionBy = ticketParam.CurrLoginUserId; ticket.LastActionDate = DateTime.Now; ticket.SlaId = ticketParam.SlaId; //ticket.Reference = ticketParam.Reference; //ticket.RefType = ticketParam.RefType; } else { ticket = new Ticket() { TicketNo = getNextTicketNo(), TicketTypeId = ticketParam.TicketTypeId, SiteId = ticketParam.SiteId, SubmitterId = ticketParam.CurrLoginUserId, RequestorId = ticketParam.RequestorId, PriorityId = ticketParam.PriorityId, UrgentcyId = ticketParam.UrgencyId, ImpactId = ticketParam.ImpactId, SourceId = ticketParam.SourceId, StatusId = ticketParam.StatusId == 0 ? 1 : ticketParam.StatusId, TicketItemId = getTicketItemId(), DeptId = ticketParam.DeptOwnerId, Subject = ticketParam.Subject, Description = ticketParam.Description, DueDate = ticketParam.DueDate, EstimatedHours = ticketParam.EstimatedHours, LastAction = getAction(), LastActionBy = ticketParam.CurrLoginUserId, LastActionDate = DateTime.Now, SlaId = ticketParam.SlaId, RefType = ticketParam.RefType, Reference = ticketParam.Reference }; var comment = "Post new ticket "; //Check for none regestered employee if (ticket.SourceId == 1) { comment += " via E-Mail"; } else if (ticket.SourceId == 3) { comment += " via Web Form"; } else if (ticket.SourceId == 5) { comment += " via K2 Form Integrated"; } ticketParam.ActComment = comment; if (sla != null && ticketParam.DueDate == null) { ticket.DueDate = getDueDate(sla, ticket.CreatedDate); } if (ticket.StatusId > 1) { base.markFirstResponse(); } } dataProcessingProvider.saveTicket(ticket); ticketParam.FileUploads = ticketParam.UserAttachFiles; //Remove upload file //se.ticket = ticket; //Record originator information if (ticket.RequestorId == -1 && TicketParams.INTEGRATED_TYPE.EMAIL == ticketParam.AutomationType && ticketParam.TicketNoneReqEmp != null) { var ticketNoneReqEmp = new TicketNoneReqEmp() { TicketId = ticket.Id, Originator = ticketParam.TicketNoneReqEmp.Originator, Receipient = ticketParam.TicketNoneReqEmp.Receipient, Cc = ticketParam.TicketNoneReqEmp.Cc, EmailItemId = ticketParam.TicketNoneReqEmp.EmailItemId }; dataProcessingProvider.saveTicketNoneReqEmp(ticketNoneReqEmp); this.requestor = new Domain.Entities.Employee() { Id = -1, Email = ticketNoneReqEmp.Originator, EmpNo = "Unknown", DisplayName = ticketNoneReqEmp.Originator }; } }
public Boolean isSLAExisted(TicketSLA instance) { return(slaRepo.isSlaExisted(instance)); }