예제 #1
0
        /// <summary>
        /// Call to start the process of upload to integration account
        /// </summary>
        /// <param name="schemasToBeUploaded"></param>
        /// <param name="schemaDetailsList"></param>
        /// <param name="outputDir"></param>
        /// <param name="overrideExistingSchemasFlag"></param>
        /// <param name="aadInstance"></param>
        /// <param name="resource"></param>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="subscriptionId"></param>
        /// <param name="resourceGroupName"></param>
        /// <param name="iaName"></param>
        public void UploadToIntegrationAccount(List <SchemaDetails> schemasToBeUploaded, ref List <SchemaDetails> schemaDetailsList, string outputDir, bool overrideExistingSchemasFlag, string subscriptionId, string resourceGroupName, string iaName, AuthenticationResult authResult)
        {
            if (schemasToBeUploaded.Count > 0)
            {
                IntegrationAccountContextForSchemas iacontext = new IntegrationAccountContextForSchemas();
                try
                {
                    IntegrationAccountDetails iaDetails = new IntegrationAccountDetails
                    {
                        SubscriptionId         = subscriptionId,
                        ResourceGroupName      = resourceGroupName,
                        IntegrationAccountName = iaName
                    };
                    iacontext.SchemaUploadFromFolder(outputDir, schemasToBeUploaded, overrideExistingSchemasFlag, iaDetails, authResult, ref schemaDetailsList);
                }

                catch (Exception e)
                {
                    string message = $"ERROR! Something went wrong while doing a schema upload from local folder ${outputDir}. \nErrorMessage:{e.Message}";
                    TraceProvider.WriteLine($"{message} \nStackTrace:{e.StackTrace}");
                    //Console.WriteLine($"{message} \nStackTrace:{e.StackTrace}");

                    throw e;
                }
            }
        }
        /// <summary>
        /// Retuns true if the schema artifact already exists, false if it does not.
        /// </summary>
        /// <param name="url"></param>
        /// <param name="iaDetails"></param>
        /// <returns></returns>
        public bool CheckIfArtifactExists(string url, AuthenticationResult authResult)
        {
            IntegrationAccountContextForSchemas sclient = new IntegrationAccountContextForSchemas();
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                response = sclient.SendGetRequestToIA(url, authResult);
                if (!response.IsSuccessStatusCode)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }