public static IDictionary <string, string> Execute(object job, string configuration, Action <string> logAction)
        {
            ActivityConfiguration activityConfiguration = Utils.GetActivityConfiguration(configuration);

            IDotNetActivity activityImplementation = job as IDotNetActivity;

            Ensure.IsNotNull(job, "job",
                             string.Format(
                                 CultureInfo.InvariantCulture,
                                 "The type {0} in does not implement IDotNetActivity. Check the configuration and try again.",
                                 job == null ? "<null>" : job.GetType().FullName));

            ActivityLogger logger = new ActivityLogger(logAction);

            Collection <LinkedService> linkedServices = new Collection <LinkedService>();
            Collection <Table>         tables         = new Collection <Table>();

            PopulateCollections(activityConfiguration.Inputs, linkedServices, tables);
            PopulateCollections(activityConfiguration.Outputs, linkedServices, tables);

            Activity activity = null;

            if (activityConfiguration.Pipeline != null &&
                activityConfiguration.Pipeline.Properties != null &&
                activityConfiguration.Pipeline.Properties.Activities != null)
            {
                activity = activityConfiguration.Pipeline.Properties.Activities.FirstOrDefault();
            }

            return(activityImplementation.Execute(
                       linkedServices,
                       tables,
                       activity,
                       logger));
        }
        private void TestLinkedServiceJsonSample(JsonSampleInfo sampleInfo)
        {
            Core.Models.LinkedService linkedServiceIn =
                Core.DataFactoryManagementClient.DeserializeInternalLinkedServiceJson(sampleInfo.Json);

            Core.Models.LinkedService linkedServiceOut =
                Core.DataFactoryManagementClient.DeserializeInternalLinkedServiceJson(sampleInfo.Json);

            var expectedActivityConfiguration = new ActivityConfiguration()
            {
                Inputs = new Collection<ResolvedTable>()
                {
                    new ResolvedTable()
                    {
                        LinkedService = this.linkedServiceConverter.ToWrapperType(linkedServiceIn),
                    },
                },
                Outputs = new Collection<ResolvedTable>()
                {
                    new ResolvedTable()
                    {
                        LinkedService = this.linkedServiceConverter.ToWrapperType(linkedServiceOut),
                    },
                },
            };

            this.TestJsonSample(string.Concat("{ \"inputs\" : [{ \"linkedService\":", sampleInfo.Json, "}], \"outputs\" : [{ \"linkedService\":", sampleInfo.Json, "}]}"), expectedActivityConfiguration);
        }
Exemplo n.º 3
0
        public static ActivityConfiguration GetActivityConfiguration(string configuration)
        {
            JsonSerializerSettings settings = ConversionCommon.DefaultSerializerSettings;

            settings.MissingMemberHandling = MissingMemberHandling.Ignore;

            foreach (JsonConverter jsonConverter in Utils.GetConverters(true, true, true))
            {
                settings.Converters.Add(jsonConverter);
            }

            ActivityConfiguration activityConfiguration = JsonConvert.DeserializeObject <ActivityConfiguration>(configuration, settings);

            return(activityConfiguration);
        }
Exemplo n.º 4
0
        public static IDictionary <string, string> Execute(object job, string configuration, Action <string> logAction)
        {
            ActivityConfiguration activityConfiguration = Utils.GetActivityConfiguration(configuration);

            IDotNetActivity activityImplementation = job as IDotNetActivity;

            Ensure.IsNotNull(job, "job",
                             string.Format(
                                 CultureInfo.InvariantCulture,
                                 "The type {0} in does not implement IDotNetActivity. Check the configuration and try again.",
                                 job == null ? "<null>" : job.GetType().FullName));

            ActivityLogger logger = new ActivityLogger(logAction);

            return(activityImplementation.Execute(
                       activityConfiguration.InputDataSets,
                       activityConfiguration.OutputDataSets,
                       activityConfiguration.ExtendedProperties,
                       logger));
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Collection<ResolvedTable> inputs = new Collection<ResolvedTable>();
            Collection<ResolvedTable> outputs = new Collection<ResolvedTable>();

            ActivityConfiguration activityConfiguration = new ActivityConfiguration();

            JObject jObject = JObject.Load(reader);
            JToken inputsJToken;
            JToken outputsJToken;
            JToken pipelineJToken;

            if (jObject.TryGetValue(InputsToken, StringComparison.OrdinalIgnoreCase, out inputsJToken))
            {
                activityConfiguration.Inputs = inputs;
                foreach (JObject resolvedTable in inputsJToken.Children<JObject>())
                {
                    inputs.Add(GetResolvedTable(resolvedTable));
                }
            }

            if (jObject.TryGetValue(OutputsToken, StringComparison.OrdinalIgnoreCase, out outputsJToken))
            {
                activityConfiguration.Outputs = outputs;
                foreach (JObject resolvedTable in outputsJToken.Children<JObject>())
                {
                    outputs.Add(GetResolvedTable(resolvedTable));
                }
            }

            if (jObject.TryGetValue(PipelineToken, StringComparison.OrdinalIgnoreCase, out pipelineJToken))
            {
                activityConfiguration.Pipeline = GetPipeline(pipelineJToken);
            }

            return activityConfiguration;
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Collection <ResolvedTable> inputs  = new Collection <ResolvedTable>();
            Collection <ResolvedTable> outputs = new Collection <ResolvedTable>();

            ActivityConfiguration activityConfiguration = new ActivityConfiguration();

            JObject jObject = JObject.Load(reader);
            JToken  inputsJToken;
            JToken  outputsJToken;
            JToken  pipelineJToken;

            if (jObject.TryGetValue(InputsToken, StringComparison.OrdinalIgnoreCase, out inputsJToken))
            {
                activityConfiguration.Inputs = inputs;
                foreach (JObject resolvedTable in inputsJToken.Children <JObject>())
                {
                    inputs.Add(GetResolvedTable(resolvedTable));
                }
            }

            if (jObject.TryGetValue(OutputsToken, StringComparison.OrdinalIgnoreCase, out outputsJToken))
            {
                activityConfiguration.Outputs = outputs;
                foreach (JObject resolvedTable in outputsJToken.Children <JObject>())
                {
                    outputs.Add(GetResolvedTable(resolvedTable));
                }
            }

            if (jObject.TryGetValue(PipelineToken, StringComparison.OrdinalIgnoreCase, out pipelineJToken))
            {
                activityConfiguration.Pipeline = GetPipeline(pipelineJToken);
            }

            return(activityConfiguration);
        }
 private void TestJsonSample(string token, ActivityConfiguration expectedActivityConfiguration)
 {
     ActivityConfiguration actualActivityConfiguration =
         JsonConvert.DeserializeObject<ActivityConfiguration>(token);
     Common.ValidateAreSame(expectedActivityConfiguration, actualActivityConfiguration);
 }
        private void TestPipelineJsonSample(JsonSampleInfo sampleInfo)
        {
            Core.Models.Pipeline pipeline =
                Core.DataFactoryManagementClient.DeserializeInternalPipelineJson(sampleInfo.Json);

            var expectedActivityConfiguration = new ActivityConfiguration()
            {
                Pipeline = this.pipelineConverter.ToWrapperType(pipeline)
            };

            this.TestJsonSample(string.Concat("{ \"pipeline\" : ", sampleInfo.Json, "}"), expectedActivityConfiguration);
        }