예제 #1
0
        public static string CreateCustomerTicket(RestCommand command)
        {
            Tickets tickets = new Tickets(command.LoginUser);
            Ticket  ticket  = tickets.AddNewTicket();

            ticket.OrganizationID = (int)command.Organization.ParentID;
            ticket.TicketSource   = "API";
            ticket.NeedsIndexing  = true;
            string description = string.Empty;
            int?   contactID   = null;
            int?   customerID  = null;

            ticket.FullReadFromXml(command.Data, true, ref description, ref contactID, ref customerID);
            ticket.Collection.Save();
            ticket.UpdateCustomFieldsFromXml(command.Data);

            Actions actions = new Actions(command.LoginUser);

            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();

            tickets.AddOrganization(command.Organization.OrganizationID, ticket.TicketID);
            UpdateFieldsOfSeparateTable(command, ticket, true);
            return(TicketsView.GetTicketsViewItem(command.LoginUser, ticket.TicketID).GetXml("Ticket", true));
        }
예제 #2
0
        /**
         *
         */
        public void UpdateAgentsRelations(Data.Action paction)
        {
            foreach (CharacterAgent agent in Agents)
            {
                ProcessedRelations.AddRange(agent.UpdateRelation(paction));
            }

            ProcessedRelations.Clear();
        }
예제 #3
0
        public static void AddFileNames(Actions actions, List <string> fileNames, Data.Action action, Logs log)
        {
            Attachments attachments = action.GetAttachments();

            foreach (Data.Attachment attachment in attachments)
            {
                fileNames.Add(attachment.Path);
                log.WriteEventFormat("Adding Attachment   AttachmentID:{0}, ActionID:{1}, Path:{2}", attachment.AttachmentID.ToString(), actions[0].ActionID.ToString(), attachment.Path);
            }
        }
예제 #4
0
        /// <summary>
        /// Sends the hooks for the specified hook event, of the specified schema
        /// </summary>
        /// <param name="id">Id of job to send hooks for</param>
        /// <param name="hookEvent">The hook event to send for</param>
        /// <param name="doForSchema">The hook schame to send for</param>
        public void SendJobHooks(int id, WebHookEvent hookEvent, string doForSchema)
        {
            var action = new Data.Action
            {
                Name         = "sendhook",
                AssociatedId = hookEvent.ToString()
            };

            var resource   = string.Format("Jobs/{0}/Action", id);
            var callParams = string.Format("sendhook_schema={0}", doForSchema);

            CallWithRetry(resource, "POST", false, action, callParams);
        }
예제 #5
0
        private void PerformAction(string resourceName, string loadId, Data.Action action)
        {
            if (action == null)
            {
                throw new ArgumentException("Action cannot be null");
            }
            if (string.IsNullOrEmpty(action.Name))
            {
                throw new ArgumentException("Action.Name must be populated");
            }

            var resource = string.Format("{0}/{1}/Action", resourceName, loadId);

            CallWithRetry(resource, "POST", true, action);
        }
예제 #6
0
        public int[] UpdateRelation(Data.Action paction)
        {
            List <int> processedRelation = new List <int>();

            // Update relation with action influence
            foreach (int id in paction.CharactersId)
            {
                if (id == CharacterData.Id)
                {
                    continue;
                }

                // Check if relation exists
                Simulation.Relation r;
                bool find = relations.TryGetValue(id, out r);

                if (!find)
                {
                    // Create relation
                    r = new Simulation.Relation();
                    relations.Add(id, r);
                }

                // Check if relation is already processed for this step
                if (Simulation.SimulationManager.environment.ProcessedRelations.Contains(r.Id))
                {
                    continue;
                }

                // If not process it
                r.Update(paction.Influence);

                // Add this relation to processed
                processedRelation.Add(r.Id);
            }

            return(processedRelation.ToArray());
        }
예제 #7
0
        public static string UpdloadAttachments(LoginUser _loginUser, CRMLinkErrors _crmErrors, TeamSupport.ServiceLibrary.Log _log, Data.Action action, string encodedCredentials, string result, string appId, string hostName)
        {
            Attachments attachments = new Attachments(_loginUser);

            attachments.LoadForIntegration(action.ActionID, IntegrationType.ServiceNow);

            foreach (Attachment attachment in attachments)
            {
                UploadAttachment(_loginUser, _crmErrors, _log, appId, encodedCredentials, ref result, attachment, hostName);
            }

            return(result);
        }
예제 #8
0
 private void PerformJobAction(string loadId, Data.Action action)
 {
     PerformAction("Jobs", loadId, action);
 }
예제 #9
0
 private void PerformJobAction(int id, Data.Action action)
 {
     PerformAction("Jobs", id, action);
 }
예제 #10
0
        /**
         * Method that runs in simulation Thread.
         * Runs multiagents system to calculate physical behaviors
         * based on interactions extract from episode's script.
         */
        public static void SimulationWorker()
        {
            float elapsedTimeProcessing = 0f;
            float elapsedTimeSimulation = 0f;

            Data.Action currentAction = SimulationManager.CurrentEpisode.Actions[SimulationManager.CurrentActionIndex];
            SimulationManager.CurrentActionIndex++;

            Console.WriteLine("Simulation thread start");

            while (SimulationManager.SimulationShouldRun)
            {
                /** Check if simulation is in pause state */
                if (SimulationManager.SimulationShouldPause)
                {
                    SimulationManager.PauseEvent.WaitOne();
                }

                /** Process simulation for next line */
                if (elapsedTimeProcessing >= ProcessingTimeStep)
                {
                    elapsedTimeProcessing = 0f;

                    /** Set next action as current action */
                    currentAction = SimulationManager.CurrentEpisode.Actions[SimulationManager.CurrentActionIndex];
                    SimulationManager.CurrentActionIndex++;

                    /** Update relations */
                    Console.WriteLine("Process RELATIONS !!!!");
                    SimulationManager.environment.UpdateAgentsRelations(currentAction);
                }

                /** Process physic simulation for current line */
                if (elapsedTimeSimulation >= SimulationTimeStep)
                {
                    Console.WriteLine("SIM TIME: " + elapsedTimeSimulation);

                    if (SimulationManager.SimulationShouldRun)
                    {
                        /** Do physics calculations */
                        SimulationManager.environment.UpdateAgents();

                        /** Launch communication task */
                        var t = Task.Run(async() => await SendData());
                        t.Wait();

                        Console.WriteLine("End task wait !!!!");

                        elapsedTimeSimulation = 0f;
                    }
                }

                /** Update elapsed times */
                TimeManager.Instance.Update();
                float elapsedTime = TimeManager.Instance.DeltaTime;
                elapsedTimeProcessing += elapsedTime;
                elapsedTimeSimulation += elapsedTime;
            }

            Console.WriteLine("Simulation thread stop");
        }
예제 #11
0
        /// <summary>
        /// Sends the hooks for the specified hook event, of the specified schema
        /// </summary>
        /// <param name="id">Id of job to send hooks for</param>
        /// <param name="hookEvent">The hook event to send for</param>
        /// <param name="doForSchema">The hook schame to send for</param>
        public void SendJobHooks(int id, WebHookEvent hookEvent, string doForSchema)
        {
            var action = new Data.Action
            {
                Name = "sendhook",
                AssociatedId = hookEvent.ToString()
            };

            var resource = string.Format("Jobs/{0}/Action", id);
            var callParams = string.Format("sendhook_schema={0}", doForSchema);
            CallWithRetry(resource, "POST", false, action, callParams);
        }
예제 #12
0
 public void Update(Data.Action entity, int LoggedInUserId, int LoggedInOrganizationId)
 {
     base.Update(entity);
     _unitOfWork.Save();
 }
예제 #13
0
 public void Add(Data.Action entity, int LoggedInUserId, int LoggedInOrganizationId)
 {
     entity.OrganizationID = LoggedInOrganizationId;
     base.Insert(entity);
 }