Ejemplo n.º 1
0
        /// <summary>
        /// Get job action.
        /// </summary>
        /// <param name="updateJobActionParams">Job action properties specified via PowerShell.</param>
        /// <param name="existingJobAction">Job action properties from existing job.</param>
        /// <returns>JobAction object.</returns>
        private JobAction GetExistingJobAction(PSJobActionParams updateJobActionParams, JobAction existingJobAction)
        {
            if (updateJobActionParams != null)
            {
                if (existingJobAction != null &&
                    (existingJobAction.Type == updateJobActionParams.JobActionType ||
                     ((existingJobAction.Type == JobActionType.Http || existingJobAction.Type == JobActionType.Https) &&
                      (updateJobActionParams.JobActionType == JobActionType.Http || updateJobActionParams.JobActionType == JobActionType.Https))))
                {
                    switch (updateJobActionParams.JobActionType)
                    {
                    case JobActionType.Http:
                    case JobActionType.Https:
                        PSHttpJobActionParams httpJobAction        = updateJobActionParams.HttpJobAction;
                        HttpRequest           existinghHttpRequest = existingJobAction.Request;
                        if (httpJobAction.Uri != null)
                        {
                            existinghHttpRequest.Uri = httpJobAction.Uri.OriginalString;
                            existingJobAction.Type   = updateJobActionParams.JobActionType;
                        }

                        existinghHttpRequest.Method  = httpJobAction.RequestMethod.GetValueOrDefault(defaultValue: existinghHttpRequest.Method);
                        existinghHttpRequest.Body    = httpJobAction.RequestBody.GetValueOrDefault(defaultValue: existinghHttpRequest.Body);
                        existinghHttpRequest.Headers = httpJobAction.RequestHeaders != null?httpJobAction.RequestHeaders.ToDictionary() : existinghHttpRequest.Headers;

                        existinghHttpRequest.Authentication = this.GetExistingAuthentication(httpJobAction.RequestAuthentication, existinghHttpRequest.Authentication);
                        break;

                    case JobActionType.StorageQueue:
                        PSStorageJobActionParams storageJobAction     = updateJobActionParams.StorageJobAction;
                        StorageQueueMessage      existingStorageQueue = existingJobAction.QueueMessage;
                        storageJobAction.StorageAccount      = storageJobAction.StorageAccount.GetValueOrDefault(defaultValue: existingStorageQueue.StorageAccount);
                        storageJobAction.StorageQueueMessage = storageJobAction.StorageQueueMessage.GetValueOrDefault(defaultValue: existingStorageQueue.Message);
                        storageJobAction.StorageQueueName    = storageJobAction.StorageQueueName.GetValueOrDefault(defaultValue: existingStorageQueue.QueueName);
                        storageJobAction.StorageSasToken     = storageJobAction.StorageSasToken.GetValueOrDefault(defaultValue: existingStorageQueue.SasToken);
                        break;

                    case JobActionType.ServiceBusQueue:
                        PSServiceBusParams     serviceBusQueueParams          = updateJobActionParams.ServiceBusAction;
                        ServiceBusQueueMessage existingServiceBusQueueMessage = existingJobAction.ServiceBusQueueMessage;
                        this.UpdateServiceBus(serviceBusQueueParams, existingServiceBusQueueMessage);
                        existingServiceBusQueueMessage.QueueName = serviceBusQueueParams.QueueName.GetValueOrDefault(defaultValue: existingServiceBusQueueMessage.QueueName);
                        break;

                    case JobActionType.ServiceBusTopic:
                        PSServiceBusParams     serviceBusTopicParams          = updateJobActionParams.ServiceBusAction;
                        ServiceBusTopicMessage existingServiceBusTopicMessage = existingJobAction.ServiceBusTopicMessage;
                        this.UpdateServiceBus(serviceBusTopicParams, existingServiceBusTopicMessage);
                        existingServiceBusTopicMessage.TopicPath = serviceBusTopicParams.TopicPath.GetValueOrDefault(defaultValue: existingServiceBusTopicMessage.TopicPath);
                        break;
                    }
                }
                else
                {
                    this.PopulateJobAction(updateJobActionParams, ref existingJobAction);
                }
            }

            return(existingJobAction);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get Service bus topic.
        /// </summary>
        /// <param name="serviceBusQueueActionParams">Servie bus properities specified via PowerShell.</param>
        /// <returns>ServiceBusTopicMessage object.</returns>
        private ServiceBusTopicMessage GetServiceBusTopic(PSServiceBusParams serviceBusQueueActionParams)
        {
            if (string.IsNullOrWhiteSpace(serviceBusQueueActionParams.TopicPath))
            {
                throw new PSManagement.PSArgumentException(Resources.SchedulerInvalidServiceBusTopicPath);
            }

            var serviceBusTopicMessage = new ServiceBusTopicMessage()
            {
                TopicPath = serviceBusQueueActionParams.TopicPath
            };

            this.PopulateServiceBusMessage(serviceBusQueueActionParams, serviceBusTopicMessage);

            return(serviceBusTopicMessage);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets service bus topic job action details.
        /// </summary>
        /// <param name="jobActionType">Job action type.</param>
        /// <param name="storageQueue">Stervice bus topic message.</param>
        /// <returns>PSServiceBusJobActionDetails.</returns>
        internal static PSServiceBusJobActionDetails GetSchedulerServiceBusTopicJobActionDetails(JobActionType jobActionType, ServiceBusTopicMessage serviceBusTopicMessage)
        {
            var psServiceBusjobActionDetails = Converter.GetServiceBusJobActionDetails(jobActionType, serviceBusTopicMessage);
            psServiceBusjobActionDetails.ServiceBusTopicPath = serviceBusTopicMessage.TopicPath;

            return psServiceBusjobActionDetails;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets service bus topic job action details.
        /// </summary>
        /// <param name="jobActionType">Job action type.</param>
        /// <param name="storageQueue">Stervice bus topic message.</param>
        /// <returns>PSServiceBusJobActionDetails.</returns>
        internal static PSServiceBusJobActionDetails GetSchedulerServiceBusTopicJobActionDetails(JobActionType jobActionType, ServiceBusTopicMessage serviceBusTopicMessage)
        {
            var psServiceBusjobActionDetails = Converter.GetServiceBusJobActionDetails(jobActionType, serviceBusTopicMessage);

            psServiceBusjobActionDetails.ServiceBusTopicPath = serviceBusTopicMessage.TopicPath;

            return(psServiceBusjobActionDetails);
        }
        /// <summary>
        /// Get Service bus topic.
        /// </summary>
        /// <param name="serviceBusQueueActionParams">Servie bus properities specified via PowerShell.</param>
        /// <returns>ServiceBusTopicMessage object.</returns>
        private ServiceBusTopicMessage GetServiceBusTopic(PSServiceBusParams serviceBusQueueActionParams)
        {
            if (string.IsNullOrWhiteSpace(serviceBusQueueActionParams.TopicPath))
            {
                throw new PSManagement.PSArgumentException(Resources.SchedulerInvalidServiceBusTopicPath);
            }

            var serviceBusTopicMessage = new ServiceBusTopicMessage()
            {
                TopicPath = serviceBusQueueActionParams.TopicPath
            };

            this.PopulateServiceBusMessage(serviceBusQueueActionParams, serviceBusTopicMessage);

            return serviceBusTopicMessage;
        }