예제 #1
0
        public virtual PSDataset CreatePSDataset(CreatePSDatasetParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PSDataset dataset = null;
            Action createDataset = () =>
            {
                dataset =
                    new PSDataset(this.CreateOrUpdateDataset(
                        parameters.ResourceGroupName,
                        parameters.DataFactoryName,
                        parameters.Name,
                        parameters.RawJsonContent))
                    {
                        ResourceGroupName = parameters.ResourceGroupName,
                        DataFactoryName = parameters.DataFactoryName
                    };

                if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(dataset.ProvisioningState))
                {
                    string errorMessage = dataset.Properties == null
                        ? string.Empty
                        : dataset.Properties.ErrorMessage;
                    throw new ProvisioningFailedException(errorMessage);
                }
            };

            if (parameters.Force)
            {
                // If user decides to overwrite anyway, then there is no need to check if the dataset exists or not.
                createDataset();
            }
            else
            {
                bool datasetExists = this.CheckDatasetExists(parameters.ResourceGroupName, parameters.DataFactoryName,
                    parameters.Name);

                parameters.ConfirmAction(
                    !datasetExists,  // prompt only if the dataset exists
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.DatasetExists,
                        parameters.Name,
                        parameters.DataFactoryName),
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.DatasetCreating,
                        parameters.Name,
                        parameters.DataFactoryName),
                    parameters.Name,
                    createDataset);
            }

            return dataset;
        }
예제 #2
0
        public virtual PSDataset CreatePSDataset(CreatePSDatasetParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PSDataset dataset       = null;
            Action    createDataset = () =>
            {
                dataset =
                    new PSDataset(this.CreateOrUpdateDataset(
                                      parameters.ResourceGroupName,
                                      parameters.DataFactoryName,
                                      parameters.Name,
                                      parameters.RawJsonContent))
                {
                    ResourceGroupName = parameters.ResourceGroupName,
                    DataFactoryName   = parameters.DataFactoryName
                };

                if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(dataset.ProvisioningState))
                {
                    string errorMessage = dataset.Properties == null
                        ? string.Empty
                        : dataset.Properties.ErrorMessage;
                    throw new ProvisioningFailedException(errorMessage);
                }
            };

            parameters.ConfirmAction(
                parameters.Force,  // prompt only if the dataset exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DatasetExists,
                    parameters.Name,
                    parameters.DataFactoryName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DatasetCreating,
                    parameters.Name,
                    parameters.DataFactoryName),
                parameters.Name,
                createDataset,
                () => this.CheckDatasetExists(parameters.ResourceGroupName, parameters.DataFactoryName,
                                              parameters.Name));

            return(dataset);
        }
        public virtual PSDataset CreatePSDataset(CreatePSDatasetParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PSDataset dataset = null;
            Action createDataset = () =>
            {
                dataset =
                    new PSDataset(this.CreateOrUpdateDataset(
                        parameters.ResourceGroupName,
                        parameters.DataFactoryName,
                        parameters.Name,
                        parameters.RawJsonContent))
                    {
                        ResourceGroupName = parameters.ResourceGroupName,
                        DataFactoryName = parameters.DataFactoryName
                    };

                if (!DataFactoryCommonUtilities.IsSucceededProvisioningState(dataset.ProvisioningState))
                {
                    string errorMessage = dataset.Properties == null
                        ? string.Empty
                        : dataset.Properties.ErrorMessage;
                    throw new ProvisioningFailedException(errorMessage);
                }
            };

            parameters.ConfirmAction(
                parameters.Force,  // prompt only if the dataset exists
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DatasetExists,
                    parameters.Name,
                    parameters.DataFactoryName),
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.DatasetCreating,
                    parameters.Name,
                    parameters.DataFactoryName),
                parameters.Name,
                createDataset,
                () => this.CheckDatasetExists(parameters.ResourceGroupName, parameters.DataFactoryName,
                parameters.Name));

            return dataset;
        }