示例#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);
            }
        }
示例#2
0
        public static void EnqueueQueueItem(string token, string serverUrl, string organizationId, SDKQueueItem queueItem, string apiVersion)
        {
            var apiInstance = GetQueueItemApiInstance(token, serverUrl);

            try
            {
                var queueItemString = JsonConvert.SerializeObject(queueItem);
                var queueItemSDK    = JsonConvert.DeserializeObject <SDKQueueItem>(queueItemString);
                apiInstance.ApiVapiVersionQueueItemsEnqueuePostAsyncWithHttpInfo(apiVersion, organizationId, queueItemSDK).Wait();
            }
            catch (Exception ex)
            {
                if (ex.Message != "One or more errors occurred.")
                {
                    throw new InvalidOperationException("Exception when calling QueueItemsApi.EnqueueQueueItem: " + ex.Message);
                }
                else
                {
                    throw new InvalidOperationException(ex.InnerException.Message);
                }
            }
        }