public static void WriteTicketsViewItemXml(RestCommand command, XmlWriter writer, string ticketID, CustomFields customFields) { int id = int.Parse(ticketID); TicketsViewItem ticket = TicketsView.GetTicketsViewItem(command.LoginUser, id); WriteTicketsViewItemXml(command, writer, ticket, customFields); }
protected void Page_Load(object sender, EventArgs e) { if (Request["TicketID"] == null) { EndResponse("Invalid Ticket"); } int ticketID = int.Parse(Request["TicketID"]); TicketsViewItem ticket = TicketsView.GetTicketsViewItem(TSAuthentication.GetLoginUser(), ticketID); CultureInfo us = new CultureInfo(TSAuthentication.GetLoginUser().CultureInfo.ToString()); if (ticket == null) { EndResponse("Invalid Ticket"); } if (ticket.SlaViolationTime < 0) { tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-bad"); } else if (ticket.SlaWarningTime < 0) { tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-warning"); } else { tipSla.Attributes.Add("class", "ts-icon ts-icon-sla-good"); } tipNumber.InnerText = "Ticket #" + ticket.TicketNumber.ToString(); tipNumber.Attributes.Add("onclick", "top.Ts.MainPage.openTicket(" + ticket.TicketNumber + "); return false;"); tipName.InnerHtml = ticket.Name; StringBuilder props = new StringBuilder(); AddStringProperty(props, "Assigned To", ticket.UserName, true, "", "openUser", ticket.UserID); AddStringProperty(props, "Group", ticket.GroupName, true, null, null, null); AddStringProperty(props, "Type", ticket.TicketTypeName, false, null, null, null); AddStringProperty(props, "Status", ticket.Status, false, null, null, null); AddStringProperty(props, "Severity", ticket.Severity, false, null, null, null); AddStringProperty(props, "Customers", GetCustomerLinks(ticketID), false, null, null, null); AddStringProperty(props, "Tags", GetTagLinks(ticketID), false, null, null, null); if (ticket.DueDate != null) { DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc((DateTime)ticket.DueDateUtc, TSAuthentication.GetLoginUser().TimeZoneInfo); if (ticket.DueDateUtc < DateTime.UtcNow) { AddStringProperty(props, "Due Date", cstTime.ToString(us.DateTimeFormat.ShortDatePattern + " HH:mm"), false, null, null, null, true); } else { AddStringProperty(props, "Due Date", cstTime.ToString(us.DateTimeFormat.ShortDatePattern + " HH:mm"), false, null, null, null); } } tipProps.InnerHtml = props.ToString(); }
public static string GetTicketsViewItem(RestCommand command, int ticketID) { TicketsViewItem ticketsViewItem = TicketsView.GetTicketsViewItem(command.LoginUser, ticketID); if (ticketsViewItem.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(ticketsViewItem.GetXml("TicketsViewItem", true)); }
public string GetData() { TicketsViewItem ticket = TicketsView.GetTicketsViewItem(_command.LoginUser, _ticketID); CustomFields customFields = new CustomFields(_command.LoginUser); customFields.LoadByTicketTypeID(_command.Organization.OrganizationID, ticket.TicketTypeID); RestXmlWriter writer = new RestXmlWriter("Ticket"); WriteTicketsViewItemXml(_command, writer.XmlWriter, ticket, customFields); return(writer.GetXml()); }
public static string GetCustomerAction(RestCommand command, int actionID) { ActionsViewItem action = ActionsView.GetActionsViewItem(command.LoginUser, actionID); TicketsViewItem ticket = action.GetTicket(); if (ticket.OrganizationID != command.Organization.ParentID || !ticket.GetIsCustomer(command.Organization.OrganizationID)) { throw new RestException(HttpStatusCode.Unauthorized); } return(action.GetXml("Action", true)); }
public static string UnSubscribeFromTicket(RestCommand command, int ticketIDOrNumber, int userId) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Subscriptions.RemoveSubscription(command.LoginUser, userId, ReferenceType.Tickets, ticket.TicketID); return(ticket.GetXml("Ticket", true)); }
public static string GetCustomerActions(RestCommand command, int ticketID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumberForCustomer(command.LoginUser, (int)command.Organization.ParentID, ticketID); if (ticket.OrganizationID != command.Organization.ParentID || !ticket.GetIsCustomer(command.Organization.OrganizationID)) { throw new RestException(HttpStatusCode.Unauthorized); } ActionsView actions = new ActionsView(command.LoginUser); actions.LoadByTicketID(ticket.TicketID); return(actions.GetXml("Actions", "Action", true, command.Filters)); }
public static string DeleteTicket(RestCommand command, int ticketIDOrNumber) { TicketsViewItem ticketViewItem = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); Ticket ticket = Tickets.GetTicket(command.LoginUser, ticketViewItem.TicketID); string result = ticketViewItem.GetXml("Ticket", true); if (ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } ticket.Delete(); ticket.Collection.Save(); return(result); }
public void RequestTicketUpdate(int ticketID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItem(UserSession.LoginUser, ticketID); if (ticket == null) { return; } EmailPosts.SendTicketUpdateRequest(UserSession.LoginUser, ticketID); string description = String.Format("{0} requested an update from {1} for {2}", UserSession.CurrentUser.FirstLastName, ticket.UserName, Tickets.GetTicketLink(UserSession.LoginUser, ticketID)); ActionLogs.AddActionLog(UserSession.LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, description); }
// Customer Only Methods public static string GetCustomerTicket(RestCommand command, int ticketID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumberForCustomer(command.LoginUser, (int)command.Organization.ParentID, ticketID); if (ticket.OrganizationID != command.Organization.ParentID || !ticket.GetIsCustomer(command.Organization.OrganizationID)) { throw new RestException(HttpStatusCode.Unauthorized); } Tags tags = new Tags(command.LoginUser); tags.LoadByReference(ReferenceType.Tickets, ticket.TicketID, command.Organization.ParentID); return(ticket.GetXml("Ticket", true, tags)); }
public static string CreateAttachment(RestCommand command, int ticketIDOrNumber, int actionID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } string path = AttachmentPath.GetPath(command.LoginUser, command.Organization.OrganizationID, AttachmentPath.Folder.Actions, 3); path = Path.Combine(path, actionID.ToString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } HttpFileCollection files = command.Context.Request.Files; if (files.Count > 0) { if (files[0].ContentLength > 0) { string fileName = RemoveSpecialCharacters(DataUtils.VerifyUniqueUrlFileName(path, Path.GetFileName(files[0].FileName))); files[0].SaveAs(Path.Combine(path, fileName)); Attachment attachment = (new Attachments(command.LoginUser)).AddNewAttachment(); attachment.RefType = AttachmentProxy.References.Actions; attachment.RefID = (int)actionID; attachment.OrganizationID = command.Organization.OrganizationID; attachment.FileName = fileName; attachment.Path = Path.Combine(path, fileName); attachment.FileType = files[0].ContentType; attachment.FileSize = files[0].ContentLength; attachment.FilePathID = 3; attachment.Collection.Save(); return(attachment.Collection.GetXml("Attachments", "Attachment", true, command.Filters)); } else { throw new RestException(HttpStatusCode.BadRequest, "The file to attach is empty."); } } else { throw new RestException(HttpStatusCode.BadRequest, "No file to attach."); } }
public static string GetActions(RestCommand command, int ticketIDOrNumber, int?limitNumber = null) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } ActionsView actions = new ActionsView(command.LoginUser); actions.LoadByTicketID(ticket.TicketID, limitNumber); actions.Select(p => { p.Description = RemoveInvalidXmlChars(p.Description); return(p); }).ToList(); return(actions.GetXml("Actions", "Action", true, command.Filters)); }
public static string CreateAction(RestCommand command, int ticketIDOrNumber) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Actions actions = new Actions(command.LoginUser); TeamSupport.Data.Action action = actions.AddNewAction(); action.TicketID = ticket.TicketID; action.ReadFromXml(command.Data, true); action.Collection.Save(); action.UpdateCustomFieldsFromXml(command.Data); return(ActionsView.GetActionsViewItem(command.LoginUser, action.ActionID).GetXml("Action", true)); }
public static string UpdateTicket(RestCommand command, int ticketIDOrNumber) { TicketsViewItem ticketViewItem = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); Ticket ticket = Tickets.GetTicket(command.LoginUser, ticketViewItem.TicketID); if (ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } ticket.ReadFromXml(command.Data, false); ticket.Collection.Save(); ticket.UpdateCustomFieldsFromXml(command.Data); ticket = Tickets.GetTicket(command.LoginUser, ticket.TicketID); UpdateFieldsOfSeparateTable(command, ticket); return(TicketsView.GetTicketsViewItem(command.LoginUser, ticket.TicketID).GetXml("Ticket", true)); }
public static string UpdateCustomerAction(RestCommand command, int actionID) { TeamSupport.Data.Action action = Actions.GetAction(command.LoginUser, actionID); if (action == null) { throw new RestException(HttpStatusCode.BadRequest); } TicketsViewItem ticket = TicketsView.GetTicketsViewItem(command.LoginUser, action.TicketID); if (ticket.OrganizationID != command.Organization.ParentID || !ticket.GetIsCustomer(command.Organization.OrganizationID)) { throw new RestException(HttpStatusCode.Unauthorized); } action.ReadFromXml(command.Data, false); action.Collection.Save(); action.UpdateCustomFieldsFromXml(command.Data); return(ActionsView.GetActionsViewItem(command.LoginUser, action.ActionID).GetXml("Action", true)); }
public static string RemoveTicketOrganization(RestCommand command, int ticketIDOrNumber, int organizationID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Organization organization = Organizations.GetOrganization(command.LoginUser, organizationID); if (organization == null || organization.ParentID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Tickets tickets = new Tickets(command.LoginUser); tickets.RemoveOrganization(organizationID, ticket.TicketID); return(OrganizationsView.GetOrganizationsViewItem(command.LoginUser, organizationID).GetXml("Customer", true)); }
public static string GetTicketOrganizations(RestCommand command, int ticketIDOrNumber, bool orderByDateCreated = false) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } OrganizationsView organizations = new OrganizationsView(command.LoginUser); if (orderByDateCreated) { organizations.LoadByTicketID(ticket.TicketID, "ot.DateCreated DESC"); } else { organizations.LoadByTicketID(ticket.TicketID); } return(organizations.GetXml("Customers", "Customer", true, command.Filters)); }
public static string RemoveTicketContact(RestCommand command, int ticketIDOrNumber, int contactID) { TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber); if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } User user = Users.GetUser(command.LoginUser, contactID); Organization organization = Organizations.GetOrganization(command.LoginUser, user.OrganizationID); if (organization == null || organization.ParentID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } Tickets tickets = new Tickets(command.LoginUser); tickets.RemoveContact(user.UserID, ticket.TicketID); return(ContactsView.GetContactsViewItem(command.LoginUser, user.UserID).GetXml("Contact", true)); }
override protected void GetNextRecord() { TicketsViewItem ticket = TicketsView.GetTicketsViewItem(_loginUser, _itemIDList[_rowIndex]); _lastItemID = ticket.TicketID; UpdatedItems.Add((int)_lastItemID); StringBuilder actionsBuilder = new StringBuilder(); Actions actions = new Actions(_loginUser); actions.LoadByTicketID(ticket.TicketID); foreach (TeamSupport.Data.Action action in actions) { string actionText = action.Description; if (!action.IsClean) { try { actionText = HtmlUtility.Sanitize(actionText); SqlCommand command = new SqlCommand(); command.CommandText = "UPDATE Actions SET Description = @Description, IsClean=1 WHERE ActionID=@ActionID"; command.Parameters.AddWithValue("ActionID", action.ActionID); command.Parameters.AddWithValue("Description", actionText); SqlExecutor.ExecuteNonQuery(_loginUser, command); } catch (Exception) { _logs.WriteEvent("Unable to sanitize action: " + action.ActionID); } } try { //actionText = HtmlToText.ConvertHtml(actionText); actionsBuilder.AppendLine(actionText); } catch (Exception ex) { _logs.WriteEvent("Unable to convert action html: " + action.ActionID); _logs.WriteException(ex); } } DocText = actionsBuilder.ToString(); _docFields.Clear(); foreach (DataColumn column in ticket.Collection.Table.Columns) { object value = ticket.Row[column]; string s = value == null || value == DBNull.Value ? "" : value.ToString(); AddDocField(column.ColumnName, s); } CustomValues customValues = new CustomValues(_loginUser); customValues.LoadByReferenceType(_organizationID, ReferenceType.Tickets, ticket.TicketTypeID, ticket.TicketID); foreach (CustomValue value in customValues) { object o = value.Row["CustomValue"]; string s = o == null || o == DBNull.Value ? "" : o.ToString(); AddDocField(value.Row["Name"].ToString(), s); } DocFields = _docFields.ToString(); DocIsFile = false; DocName = ticket.TicketID.ToString(); DocDisplayName = string.Format("{0}: {1}", ticket.TicketNumber.ToString(), ticket.Name); DocCreatedDate = (DateTime)ticket.Row["DateCreated"]; DocModifiedDate = (DateTime)ticket.Row["DateModified"]; }
private void ProcessReminder(Reminder reminder) { Logs.WriteLine(); Logs.WriteEvent("***********************************************************************************"); Logs.WriteEvent("Processing Reminder ReminderID: " + reminder.ReminderID.ToString()); Logs.WriteData(reminder.Row); Logs.WriteLine(); Logs.WriteEvent("***********************************************************************************"); MailMessage message; UsersViewItem user = UsersView.GetUsersViewItem(LoginUser, (int)reminder.UserID); if (user == null) { return; } string description = ""; switch (reminder.RefType) { case ReferenceType.Organizations: OrganizationsViewItem org = OrganizationsView.GetOrganizationsViewItem(LoginUser, reminder.RefID); if (org == null) { return; } message = EmailTemplates.GetReminderCustomerEmail(LoginUser, reminder, user, org); description = String.Format("Reminder sent to {0} for Organization {1}", message.To.ToString(), org.Name); Logs.WriteEvent(description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, reminder.RefType, reminder.RefID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Organizations, org.OrganizationID, description); break; case ReferenceType.Tickets: TicketsViewItem ticket = TicketsView.GetTicketsViewItem(LoginUser, reminder.RefID); if (ticket == null) { return; } message = EmailTemplates.GetReminderTicketEmail(LoginUser, reminder, user, ticket); EmailTemplates.ReplaceEmailRecipientParameters(LoginUser, message, Tickets.GetTicket(LoginUser, ticket.TicketID), reminder.UserID); //vv TeamSupport.Data.Action action = (new Actions(LoginUser)).AddNewAction(); action.ActionTypeID = null; action.Name = "Reminder"; action.ActionSource = "Reminder"; action.SystemActionTypeID = SystemActionType.Reminder; action.Description = String.Format("<p>The following is a reminder for {0} {1}:</p><p> </p><p>{2}</p>", user.FirstName, user.LastName, reminder.Description); action.IsVisibleOnPortal = false; action.IsKnowledgeBase = false; action.TicketID = ticket.TicketID; action.Collection.Save(); description = String.Format("Reminder sent to {0} for Ticket {1}", message.To.ToString(), ticket.TicketNumber.ToString()); Logs.WriteEvent(description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, reminder.RefType, reminder.RefID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tickets, ticket.TicketID, description); break; case ReferenceType.Contacts: ContactsViewItem contact = ContactsView.GetContactsViewItem(LoginUser, reminder.RefID); if (contact == null) { return; } message = EmailTemplates.GetReminderContactEmail(LoginUser, reminder, user, contact); description = String.Format("Reminder sent to {0} for Contact {1}", message.To.ToString(), contact.FirstName + " " + contact.LastName); Logs.WriteEvent(description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, reminder.RefType, reminder.RefID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, contact.UserID, description); break; case ReferenceType.Tasks: TasksViewItem task = TasksView.GetTasksViewItem(LoginUser, reminder.RefID); if (task == null || task.IsComplete) { reminder.IsDismissed = true; reminder.Collection.Save(); return; } message = EmailTemplates.GetReminderTaskEmail(LoginUser, reminder, user, task); description = String.Format("Reminder sent to {0} for Task {1}", message.To.ToString(), task.Name); Logs.WriteEvent("ver. 05162017: " + description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Tasks, task.TaskID, description); ActionLogs.AddActionLog(LoginUser, ActionLogType.Insert, ReferenceType.Users, (int)reminder.UserID, description); TaskAssociations taskAssociations = new TaskAssociations(LoginUser); taskAssociations.LoadByTaskIDOnly(task.TaskID); foreach (TaskAssociation taskAssociation in taskAssociations) { if (taskAssociation.RefType == (int)ReferenceType.Tickets) { TeamSupport.Data.Action taskAction = (new Actions(LoginUser)).AddNewAction(); taskAction.ActionTypeID = null; taskAction.Name = "Reminder"; taskAction.ActionSource = "Reminder"; taskAction.SystemActionTypeID = SystemActionType.Reminder; taskAction.Description = String.Format("<p>The following is a reminder for {0} {1}:</p><p> </p><p>{2}</p>", user.FirstName, user.LastName, reminder.Description); taskAction.IsVisibleOnPortal = false; taskAction.IsKnowledgeBase = false; taskAction.TicketID = taskAssociation.RefID; try { taskAction.Collection.Save(); } catch (Exception ex) { Logs.WriteEvent("Ex Reminder Action.Save: " + ex.StackTrace); } } } break; default: message = null; break; } if (message == null) { return; } reminder.HasEmailSent = true; reminder.Collection.Save(); if (Emails.IsEmailDisabled(LoginUser, user.UserID, "Reminders")) { Logs.WriteEvent("Message skipped due to disabled user setting."); } else { MailAddress address = new MailAddress(user.Email, user.FirstName + " " + user.LastName); Logs.WriteEvent("Mail Address: " + address.ToString()); message.To.Add(address); EmailTemplates.ReplaceMailAddressParameters(message); Emails.AddEmail(LoginUser, reminder.OrganizationID, null, message.Subject, message); Logs.WriteEvent("Message queued"); } }
private void NotifyViolation(int ticketID, bool useUser, bool useGroup, bool isWarning, SlaViolationType slaViolationType, SlaNotification notification, int?triggerId) { Users users = new Users(LoginUser); User user = null; Logs.WriteLine(); Logs.WriteEvent("***** Processing TicketID: " + ticketID.ToString()); TicketsViewItem ticket = TicketsView.GetTicketsViewItem(LoginUser, ticketID); if (ticket == null) { Logs.WriteEvent("Ticket is NULL, exiting"); return; } //Since we are already re-loading the Ticket information we will check again if the SLAs still apply at this point string violationType = ""; bool slaNotApplyAnymore = false; switch (slaViolationType) { case SlaViolationType.InitialResponse: violationType = "Initial Response"; slaNotApplyAnymore = ticket.SlaWarningInitialResponse == null; break; case SlaViolationType.LastAction: violationType = "Last Action"; slaNotApplyAnymore = ticket.SlaViolationLastAction == null; break; case SlaViolationType.TimeClosed: violationType = "Time to Close"; slaNotApplyAnymore = ticket.SlaViolationTimeClosed == null; break; default: break; } if (slaNotApplyAnymore) { Logs.WriteEvent($"The {((isWarning) ? "warning" : "violation")} for {violationType} does not apply anymore because the Ticket has been updated to satisfy this SLA while it was in process for the notification."); } else { if (!isWarning) { SlaViolationHistoryItem history = (new SlaViolationHistory(LoginUser)).AddNewSlaViolationHistoryItem(); history.DateViolated = DateTime.UtcNow; history.GroupID = ticket.GroupID; history.UserID = ticket.UserID; history.ViolationType = slaViolationType; history.TicketID = ticket.TicketID; history.SlaTriggerId = triggerId; history.Collection.Save(); } Actions actions = new Actions(LoginUser); actions.LoadLatestByTicket(ticket.TicketID, false); ActionLogs.AddActionLog(LoginUser, ActionLogType.Update, ReferenceType.Tickets, ticket.TicketID, violationType + " SLA " + (isWarning ? "warning" : "violation") + " occurred"); MailMessage message = EmailTemplates.GetSlaEmail(LoginUser, ticket, violationType, isWarning); if (ticket.GroupID != null && useGroup) { users.LoadByGroupID((int)ticket.GroupID); } if (ticket.UserID != null && useUser && users.FindByUserID((int)ticket.UserID) == null) { user = Users.GetUser(LoginUser, (int)ticket.UserID); } foreach (User item in users) { if (Emails.IsEmailDisabled(LoginUser, item.UserID, "SLA")) { continue; } message.To.Add(new MailAddress(item.Email, item.FirstLastName)); } if (user != null) { if (!Emails.IsEmailDisabled(LoginUser, user.UserID, "SLA")) { message.To.Add(new MailAddress(user.Email, user.FirstLastName)); Logs.WriteEvent(string.Format("Adding Main User, Name:{0} Email:{1} UserID:{2}", user.FirstLastName, user.Email, user.UserID.ToString())); } } if (message.To.Count > 0) { Email email = Emails.AddEmail(LoginUser, ticket.OrganizationID, null, "Sla Message", message); Logs.WriteEvent("Email Added (EmailID: " + email.EmailID.ToString() + ")", true); } try { TimeZoneInfo tz = null; Organization org = Organizations.GetOrganization(LoginUser, ticket.OrganizationID); if (org.TimeZoneID != null) { tz = System.TimeZoneInfo.FindSystemTimeZoneById(org.TimeZoneID); } if (tz == null) { Logs.WriteEvent("Timezone is null, using system's"); tz = System.TimeZoneInfo.Local; } Logs.WriteEvent(tz.DisplayName); Logs.WriteEvent("Supports DLS: " + tz.SupportsDaylightSavingTime.ToString()); Logs.WriteEvent("Is DLS: " + tz.IsDaylightSavingTime(DateTime.UtcNow).ToString()); Logs.WriteEvent("UTC: " + DateTime.UtcNow.ToString()); Logs.WriteEvent(string.Format("NOTIFYING TicketID:{0} TicketNumber:{1} OrganizationID:{2} ", ticket.TicketID.ToString(), ticket.TicketNumber.ToString(), ticket.OrganizationID.ToString())); Logs.WriteEvent(string.Format("User:{1} Group:{2} IsWarning:{3} NoficationType:{4}", ticketID.ToString(), useUser.ToString(), useGroup.ToString(), isWarning.ToString(), slaViolationType)); Logs.WriteEvent("Ticket Data:"); Logs.WriteData(ticket.Row); Logs.WriteEvent("Notification Data:"); Logs.WriteData(notification.Row); Logs.WriteEvent("Organization Data:"); Logs.WriteData(org.Row); Organizations customers = new Organizations(LoginUser); customers.LoadByTicketID(ticket.TicketID); foreach (Organization customer in customers) { Logs.WriteEvent("-- Customer: " + customer.Name); if (customer.SlaLevelID != null) { SlaLevel level = SlaLevels.GetSlaLevel(LoginUser, (int)customer.SlaLevelID); Logs.WriteEvent("SLA Level: " + level.Name); SlaTriggers triggers = new SlaTriggers(LoginUser); triggers.LoadByTicketTypeAndSeverity(level.SlaLevelID, ticket.TicketTypeID, ticket.TicketSeverityID); foreach (SlaTrigger trigger in triggers) { Logs.WriteData(trigger.Row); } } else { Logs.WriteEvent("No SLA Level Assigned to " + customer.Name); } } if (org.InternalSlaLevelID != null) { Logs.WriteEvent("Internal SLA:"); SlaTriggers triggers = new SlaTriggers(LoginUser); triggers.LoadByTicketTypeAndSeverity((int)org.InternalSlaLevelID, ticket.TicketTypeID, ticket.TicketSeverityID); foreach (SlaTrigger trigger in triggers) { Logs.WriteData(trigger.Row); } } else { Logs.WriteEvent("No Internal SLA"); } } catch (Exception ex) { Logs.WriteEvent("Logging Exception:"); Logs.WriteException(ex); } } }
public static void WriteTicketsViewItemXml(RestCommand command, XmlWriter writer, TicketsViewItem ticket, CustomFields customFields) { if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.BadRequest, "Invalid TicketID"); } writer.WriteElementString("TicketID", ticket.TicketID.ToString()); writer.WriteElementString("TicketNumber", ticket.TicketNumber.ToString()); writer.WriteElementString("TicketType", ticket.TicketTypeName.ToString()); writer.WriteElementString("Name", ticket.Name.ToString()); writer.WriteElementString("IsClosed", ticket.IsClosed.ToString()); if (customFields != null) { foreach (CustomField field in customFields) { CustomValue value = CustomValues.GetValue(command.LoginUser, field.CustomFieldID, ticket.TicketID); writer.WriteElementString(field.ApiFieldName, value.Value); } } }
public static void WriteTicketsViewItemXml(RestCommand command, XmlWriter writer, int ticketID, CustomFields customFields) { TicketsViewItem ticket = TicketsView.GetTicketsViewItem(command.LoginUser, ticketID); WriteTicketsViewItemXml(command, writer, ticket, customFields); }