Exemple #1
0
        public async override Task RunCommand(object sender)
        {
            var engine     = (IAutomationEngineInstance)sender;
            var vQueueName = (string)await v_QueueName.EvaluateCode(engine);

            var vQueueItemName = (string)await v_QueueItemName.EvaluateCode(engine);

            var vSource = (string)await v_Source.EvaluateCode(engine);

            var vEvent = (string)await v_Event.EvaluateCode(engine);

            var vJsonType = (string)await v_JsonType.EvaluateCode(engine);

            int priority = (int)await v_Priority.EvaluateCode(engine);

            var vQueueItemTextValue = (string)await v_QueueItemTextValue.EvaluateCode(engine);

            var   userInfo = ServerSessionVariableMethods.GetUserInfo(engine);
            Queue queue    = QueueMethods.GetQueue(userInfo, $"Name eq '{vQueueName}'");

            if (queue == null)
            {
                throw new DataException($"Queue with name '{vQueueName}' not found");
            }

            QueueItemModel queueItem = new QueueItemModel()
            {
                Id        = Guid.NewGuid(),
                IsLocked  = false,
                QueueId   = queue.Id,
                Type      = v_QueueItemType,
                JsonType  = vJsonType,
                DataJson  = vQueueItemTextValue,
                Name      = vQueueItemName,
                IsDeleted = false,
                Priority  = priority,
                Source    = vSource,
                Event     = vEvent
            };

            QueueItemMethods.EnqueueQueueItem(userInfo, queueItem);

            if (!string.IsNullOrEmpty(v_Attachments))
            {
                var vAttachments = (List <string>) await v_Attachments.EvaluateCode(engine);

                QueueItemMethods.AttachFiles(userInfo, queueItem.Id, vAttachments);
            }
        }
        public override void RunCommand(object sender)
        {
            var engine              = (IAutomationEngineInstance)sender;
            var vQueueName          = v_QueueName.ConvertUserVariableToString(engine);
            var vQueueItemName      = v_QueueItemName.ConvertUserVariableToString(engine);
            var vSource             = v_Source.ConvertUserVariableToString(engine);
            var vEvent              = v_Event.ConvertUserVariableToString(engine);
            var vJsonType           = v_JsonType.ConvertUserVariableToString(engine);
            var vPriority           = v_Priority.ConvertUserVariableToString(engine);
            var vQueueItemTextValue = v_QueueItemTextValue.ConvertUserVariableToString(engine);
            var vAttachments        = v_Attachments.ConvertUserVariableToString(engine);

            var   client = AuthMethods.GetAuthToken();
            Queue queue  = QueueMethods.GetQueue(client, $"name eq '{vQueueName}'");

            if (queue == null)
            {
                throw new DataException($"Queue with name '{vQueueName}' not found");
            }

            int priority = 0;

            if (!string.IsNullOrEmpty(v_Priority))
            {
                priority = int.Parse(vPriority);
            }

            QueueItemModel queueItem = new QueueItemModel()
            {
                IsLocked  = false,
                QueueId   = queue.Id,
                Type      = v_QueueItemType,
                JsonType  = vJsonType,
                DataJson  = vQueueItemTextValue,
                Name      = vQueueItemName,
                IsDeleted = false,
                Priority  = priority,
                Source    = vSource,
                Event     = vEvent
            };

            QueueItemMethods.EnqueueQueueItem(client, queueItem);

            if (!string.IsNullOrEmpty(vAttachments))
            {
                QueueItemMethods.AttachFiles(client, queueItem.Id, vAttachments);
            }
        }