public static string GetTicketAutomationAction(RestCommand command, int ticketActionID) { TicketAutomationAction ticketAutomationAction = TicketAutomationActions.GetTicketAutomationAction(command.LoginUser, ticketActionID); if (ticketAutomationAction.OrganizationID != command.Organization.OrganizationID) { throw new RestException(HttpStatusCode.Unauthorized); } return(ticketAutomationAction.GetXml("TicketAutomationAction", true)); }
public TicketAutomationTriggerProxy SaveTrigger(string value) { SaveTriggerData data = Newtonsoft.Json.JsonConvert.DeserializeObject <SaveTriggerData>(value); HttpContext.Current.Request.InputStream.Position = 0; TicketAutomationTrigger trigger = null; if (data.TriggerID > -1) { trigger = TicketAutomationTriggers.GetTicketAutomationTrigger(UserSession.LoginUser, data.TriggerID); if (trigger.OrganizationID != UserSession.LoginUser.OrganizationID || !UserSession.CurrentUser.IsSystemAdmin) { return(null); } } else { trigger = (new TicketAutomationTriggers(UserSession.LoginUser)).AddNewTicketAutomationTrigger(); trigger.OrganizationID = UserSession.LoginUser.OrganizationID; } trigger.Active = data.IsActive; trigger.Name = data.Name; trigger.Position = trigger.Collection.GetMaxPosition(UserSession.LoginUser.OrganizationID) + 1; trigger.Collection.Save(); TicketAutomationTriggerLogic logic = new TicketAutomationTriggerLogic(UserSession.LoginUser); logic.LoadByTrigger(data.TriggerID); foreach (TicketAutomationTriggerLogicItem logicItem in logic) { logicItem.Delete(); } logic.Save(); TicketAutomationActions actions = new TicketAutomationActions(UserSession.LoginUser); actions.LoadByTrigger(data.TriggerID); foreach (TicketAutomationAction action in actions) { action.Delete(); } actions.Save(); actions = new TicketAutomationActions(UserSession.LoginUser); foreach (TicketAutomationActionProxy actionProxy in data.Actions) { TicketAutomationAction action = actions.AddNewTicketAutomationAction(); action.TriggerID = trigger.TriggerID; action.ActionValue = actionProxy.ActionValue; action.ActionValue2 = actionProxy.ActionValue2; action.ActionID = actionProxy.ActionID; } actions.Save(); logic = new TicketAutomationTriggerLogic(UserSession.LoginUser); foreach (LogicItem logicItemProxy in data.LogicItems) { TicketAutomationTriggerLogicItem logicItem = logic.AddNewTicketAutomationTriggerLogicItem(); logicItem.TriggerID = trigger.TriggerID; logicItem.TableID = logicItemProxy.IsCustom ? -1 : logicItemProxy.TableID; logicItem.FieldID = logicItemProxy.FieldID; logicItem.TestValue = logicItemProxy.TestValue; logicItem.Measure = logicItemProxy.Measure; logicItem.MatchAll = logicItemProxy.MatchAll; logicItem.OtherTrigger = logicItemProxy.OtherTrigger; } logic.Save(); return(trigger.GetProxy()); }