protected override void ProcessRecord()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            DataSliceFilterOptions filterOptions = new DataSliceFilterOptions()
            {
                ResourceGroupName = ResourceGroupName,
                DataFactoryName = DataFactoryName,
                DatasetName = this.DatasetName,
                DataSliceRangeStartTime = StartDateTime,
                DataSliceRangeEndTime = EndDateTime
            };

            int totalDataSlices = 0;
            do
            {
                var dataSlices = DataFactoryClient.ListDataSlices(filterOptions);
                totalDataSlices += dataSlices.Count;
                WriteObject(dataSlices, true);    
            } while (filterOptions.NextLink.IsNextPageLink());

            if (totalDataSlices == 0)
            {
                WriteWarning(string.Format(CultureInfo.InvariantCulture, Resources.NoDataSliceFound));
            }
        }
Example #2
0
        public virtual List <PSDataSlice> ListDataSlices(DataSliceFilterOptions filterOptions)
        {
            List <PSDataSlice> dataSlices = new List <PSDataSlice>();

            DataSliceListResponse response;

            if (filterOptions.NextLink.IsNextPageLink())
            {
                response = DataPipelineManagementClient.DataSlices.ListNext(filterOptions.NextLink);
            }
            else
            {
                response = DataPipelineManagementClient.DataSlices.List(
                    filterOptions.ResourceGroupName,
                    filterOptions.DataFactoryName,
                    filterOptions.DatasetName,
                    new DataSliceListParameters()
                {
                    DataSliceRangeStartTime = filterOptions.DataSliceRangeStartTime.ConvertToISO8601DateTimeString(),
                    DataSliceRangeEndTime   = filterOptions.DataSliceRangeEndTime.ConvertToISO8601DateTimeString()
                });
            }
            filterOptions.NextLink = response != null ? response.NextLink : null;

            if (response != null && response.DataSlices != null)
            {
                foreach (var dataSlice in response.DataSlices)
                {
                    dataSlices.Add(
                        new PSDataSlice(dataSlice)
                    {
                        ResourceGroupName = filterOptions.ResourceGroupName,
                        DataFactoryName   = filterOptions.DataFactoryName,
                        DatasetName       = filterOptions.DatasetName
                    });
                }
            }

            return(dataSlices);
        }
        public virtual List<PSDataSlice> ListDataSlices(DataSliceFilterOptions filterOptions)
        {
            List<PSDataSlice> dataSlices = new List<PSDataSlice>();

            DataSliceListResponse response;
            if (filterOptions.NextLink.IsNextPageLink())
            {
                response = DataPipelineManagementClient.DataSlices.ListNext(filterOptions.NextLink);
            }
            else
            {
                response = DataPipelineManagementClient.DataSlices.List(
                    filterOptions.ResourceGroupName,
                    filterOptions.DataFactoryName,
                    filterOptions.TableName,
                    new DataSliceListParameters()
                    {
                        DataSliceRangeStartTime = filterOptions.DataSliceRangeStartTime.ConvertToISO8601DateTimeString(),
                        DataSliceRangeEndTime = filterOptions.DataSliceRangeEndTime.ConvertToISO8601DateTimeString()
                    });
            }
            filterOptions.NextLink = response != null ? response.NextLink : null;
            
            if (response != null && response.DataSlices != null)
            {
                foreach (var dataSlice in response.DataSlices)
                {
                    dataSlices.Add(
                        new PSDataSlice(dataSlice)
                        {
                            ResourceGroupName = filterOptions.ResourceGroupName,
                            DataFactoryName = filterOptions.DataFactoryName,
                            TableName = filterOptions.TableName
                        });
                }
            }

            return dataSlices;
        }
        protected override void ProcessRecord()
        {
            if (ParameterSetName == ByFactoryObject)
            {
                if (DataFactory == null)
                {
                    throw new PSArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.DataFactoryArgumentInvalid));
                }

                DataFactoryName   = DataFactory.DataFactoryName;
                ResourceGroupName = DataFactory.ResourceGroupName;
            }

            DataSliceFilterOptions filterOptions = new DataSliceFilterOptions()
            {
                ResourceGroupName       = ResourceGroupName,
                DataFactoryName         = DataFactoryName,
                DatasetName             = this.DatasetName,
                DataSliceRangeStartTime = StartDateTime,
                DataSliceRangeEndTime   = EndDateTime
            };

            int totalDataSlices = 0;

            do
            {
                var dataSlices = DataFactoryClient.ListDataSlices(filterOptions);
                totalDataSlices += dataSlices.Count;
                WriteObject(dataSlices, true);
            } while (filterOptions.NextLink.IsNextPageLink());

            if (totalDataSlices == 0)
            {
                WriteWarning(string.Format(CultureInfo.InvariantCulture, Resources.NoDataSliceFound));
            }
        }