예제 #1
0
        public void DeleteAction(int actionID)
        {
            if (!UserSession.CurrentUser.IsSystemAdmin)
            {
                return;
            }
            TeamSupport.Data.Action action = Actions.GetAction(UserSession.LoginUser, actionID);
            if (action == null)
            {
                return;
            }
            Ticket ticket = Tickets.GetTicket(UserSession.LoginUser, action.TicketID);

            if (ticket == null)
            {
                return;
            }
            if (ticket.OrganizationID != UserSession.LoginUser.OrganizationID)
            {
                return;
            }

            action.Delete();
            action.Collection.Save();
        }
예제 #2
0
    public static int GetTicketID(int chatID)
    {
        Chat chat = Chats.GetChat(UserSession.LoginUser, chatID);

        if (chat.ActionID == null)
        {
            return(-1);
        }

        TeamSupport.Data.Action action = Actions.GetAction(UserSession.LoginUser, (int)chat.ActionID);
        if (action == null)
        {
            return(-1);
        }
        return(action.TicketID);
    }
예제 #3
0
        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));
        }
예제 #4
0
        public static string UpdateAction(RestCommand command, int actionID)
        {
            TeamSupport.Data.Action action = Actions.GetAction(command.LoginUser, actionID);
            if (action == null)
            {
                throw new RestException(HttpStatusCode.BadRequest);
            }
            Ticket ticket = Tickets.GetTicket(command.LoginUser, action.TicketID);

            if (ticket.OrganizationID != 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));
        }
예제 #5
0
        public static string CreateTicket(RestCommand command)
        {
            Tickets tickets = new Tickets(command.LoginUser);
            Ticket  ticket  = tickets.AddNewTicket();

            ticket.OrganizationID = command.Organization.OrganizationID;
            string description = string.Empty;
            int?   contactID   = null;
            int?   customerID  = null;

            ticket.FullReadFromXml(command.Data, true, ref description, ref contactID, ref customerID);
            ticket.TicketSource  = "API";
            ticket.NeedsIndexing = true;
            ticket.Collection.Save();
            ticket.UpdateCustomFieldsFromXml(command.Data);

            if (contactID != null)
            {
                ticket.Collection.AddContact((int)contactID, ticket.TicketID);
            }

            if (customerID != null)
            {
                ticket.Collection.AddOrganization((int)customerID, ticket.TicketID);
            }

            Actions actions = new Actions(command.LoginUser);

            TeamSupport.Data.Action action = actions.AddNewAction();
            action.ActionTypeID       = null;
            action.Name               = "Description";
            action.SystemActionTypeID = SystemActionType.Description;
            action.Description        = description;
            action.IsVisibleOnPortal  = ticket.IsVisibleOnPortal;
            action.IsKnowledgeBase    = ticket.IsKnowledgeBase;
            action.TicketID           = ticket.TicketID;
            actions.Save();

            UpdateFieldsOfSeparateTable(command, ticket);

            return(TicketsView.GetTicketsViewItem(command.LoginUser, ticket.TicketID).GetXml("Ticket", true));
        }
예제 #6
0
    public static int AddTicket(int chatID, int ticketID)
    {
        Chat chat = Chats.GetChat(UserSession.LoginUser, chatID);

        if (chat != null)
        {
            Actions actions = new Actions(UserSession.LoginUser);
            TeamSupport.Data.Action chatAction = actions.AddNewAction();
            chatAction.ActionTypeID       = null;
            chatAction.Name               = "Chat";
            chatAction.ActionSource       = "Chat";
            chatAction.SystemActionTypeID = SystemActionType.Chat;
            chatAction.Description        = chat.GetHtml(true, UserSession.LoginUser.OrganizationCulture);
            chatAction.IsVisibleOnPortal  = false;
            chatAction.IsKnowledgeBase    = false;
            chatAction.TicketID           = ticketID;
            actions.Save();
            chat.ActionID = chatAction.ActionID;
            chat.Collection.Save();

            (new Tickets(UserSession.LoginUser)).AddContact(chat.GetInitiatorLinkedUserID(), ticketID);
        }
        return(ticketID);
    }
        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>&nbsp;</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>&nbsp;</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");
            }
        }