// Create dependencies between pipelines so
        // the concurrency limit for smaller Salesforce
        // instances is not broken
        private JObject CreatePipelineDependency(string pipelineType, DeserializedADFPayload obj, JObject armTemplate, int index)
        {
            var currentDataset = pipelineType + "_" + obj.fields[index + 1].Item1 + "_Output";
            var dataset        = pipelineType + "_" + obj.fields[index].Item1 + "_Output";
            var dependency     = JToken.Parse(string.Concat("{ \"name\": \"", dataset, "\"}"));

            if (currentDataset != "PreDeployment_Opportunity_Output")
            {
                (armTemplate
                 .SelectToken("resources")[0]
                 .SelectToken("properties")
                 .SelectToken("activities")[0]
                 .SelectToken("inputs") as JArray).
                Add(dependency);
            }

            return(armTemplate);
        }
        // Reorder the objects so the scheduled pipelines
        // (Opportunity, Lead, OpportunityLineItem) are
        // dependent on the scheduled ones
        private DeserializedADFPayload ReorderObjects(DeserializedADFPayload obj)
        {
            var opportunity = obj.fields.Where(o => o.Item1 == "Opportunity").FirstOrDefault();
            var leads       = obj.fields.Where(o => o.Item1 == "Lead").FirstOrDefault();
            var items       = obj.fields.Where(o => o.Item1 == "OpportunityLineItem").FirstOrDefault();

            var objects = obj.fields.ToList();

            objects.Remove(opportunity);
            objects.Remove(leads);
            objects.Remove(items);

            objects.Add(opportunity);
            objects.Add(leads);
            objects.Add(items);

            obj.fields = objects.ToArray();

            return(obj);
        }