Наследование: Microsoft.Azure.Commands.StreamAnalytics.Models.JobParametersBase
Пример #1
0
        public virtual PSJob CreatePSJob(CreatePSJobParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSJob job = null;

            parameter.ConfirmAction(
                parameter.Force,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.JobExists,
                    parameter.JobName,
                    parameter.ResourceGroupName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.JobCreating,
                    parameter.JobName,
                    parameter.ResourceGroupName),
                parameter.JobName,
                () =>
            {
                job = CreateOrUpdatePSJob(parameter.ResourceGroupName, parameter.JobName, parameter.RawJsonContent);
            },
                () => CheckJobExists(parameter.ResourceGroupName, parameter.JobName));
            return(job);
        }
        public virtual PSJob CreatePSJob(CreatePSJobParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSJob  job       = null;
            Action createJob = () =>
            {
                job = CreateOrUpdatePSJob(parameter.ResourceGroupName, parameter.JobName, parameter.RawJsonContent);
            };

            if (parameter.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not.
                createJob();
            }
            else
            {
                bool jobExists = CheckJobExists(parameter.ResourceGroupName, parameter.JobName);

                parameter.ConfirmAction(
                    !jobExists,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.JobExists,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.JobCreating,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    parameter.JobName,
                    createJob);
            }

            return(job);
        }
        protected override void ProcessRecord()
        {
            string rawJsonContent = StreamAnalyticsClient.ReadJsonFileContent(this.TryResolvePath(File));

            Name = ResolveResourceName(rawJsonContent, Name, "Job");

            if (Name != null && string.IsNullOrWhiteSpace(Name))
            {
                throw new ArgumentException(Resources.JobNameCannotBeEmpty);
            }

            CreatePSJobParameter parameter = new CreatePSJobParameter
            {
                ResourceGroupName = ResourceGroupName,
                JobName = Name,
                RawJsonContent = rawJsonContent,
                Force = Force.IsPresent,
                ConfirmAction = ConfirmAction
            };

            WriteObject(StreamAnalyticsClient.CreatePSJob(parameter));
        }
        public virtual PSJob CreatePSJob(CreatePSJobParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSJob job = null;
            parameter.ConfirmAction(
                    parameter.Force,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.JobExists,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.JobCreating,
                        parameter.JobName,
                        parameter.ResourceGroupName),
                    parameter.JobName,
                    () =>
                    {
                        job = CreateOrUpdatePSJob(parameter.ResourceGroupName, parameter.JobName, parameter.RawJsonContent);
                    },
                    () => CheckJobExists(parameter.ResourceGroupName, parameter.JobName));
            return job;
        }
        public virtual PSJob CreatePSJob(CreatePSJobParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            PSJob job = null;
            Action createJob = () =>
            {
                job = CreateOrUpdatePSJob(parameter.ResourceGroupName, parameter.JobName, parameter.RawJsonContent);
            };

            if (parameter.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the linked service exists or not.
                createJob();
            }
            else
            {
                bool jobExists = CheckJobExists(parameter.ResourceGroupName, parameter.JobName);

                parameter.ConfirmAction(
                        !jobExists,
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.JobExists,
                            parameter.JobName,
                            parameter.ResourceGroupName),
                        string.Format(
                            CultureInfo.InvariantCulture,
                            Resources.JobCreating,
                            parameter.JobName,
                            parameter.ResourceGroupName),
                        parameter.JobName,
                        createJob);
            }

            return job;
        }