public async Task DataModelCreate(DataModelParameters dmParameters)
        {
            ConnectParameters connector = await Common.GetConnectParameters(azureConnectionString, dmParameters.DataConnector);

            if (dmParameters.ModelOption == "PPDM Model")
            {
                await CreatePPDMModel(dmParameters, connector);
            }
            else if (dmParameters.ModelOption == "DSM Model")
            {
                await CreateDMSModel(dmParameters, connector);
            }
            else if (dmParameters.ModelOption == "DSM Rules")
            {
                await CreateDSMRules(connector);
            }
            else if (dmParameters.ModelOption == "Stored Procedures")
            {
                await CreateStoredProcedures(connector);
                await CreateFunctions(connector);
            }
            else if (dmParameters.ModelOption == "PPDM Modifications")
            {
                await CreatePpdmModifications(connector);
            }
            else
            {
            }
        }
        private async Task CreatePPDMModel(DataModelParameters dmParameters, ConnectParameters connector)
        {
            try
            {
                string sql = await _fileStorage.ReadFile(dmParameters.FileShare, dmParameters.FileName);

                if (string.IsNullOrEmpty(sql))
                {
                    Exception error = new Exception($"Empty data from {dmParameters.FileName}");
                    throw error;
                }
                else
                {
                    DbUtilities dbConn = new DbUtilities();
                    dbConn.OpenConnection(connector);
                    dbConn.SQLExecute(sql);
                    dbConn.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                Exception error = new Exception("Create PPDM Model Error: ", ex);
                throw error;
            }
        }
Esempio n. 3
0
        public static async Task <IActionResult> ModelCreate(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("DataModelCreate: Starting");
            try
            {
                string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
                DataModelParameters dmParameters = JsonConvert.DeserializeObject <DataModelParameters>(requestBody);
                if (dmParameters == null)
                {
                    log.LogError("DataModelCreate: error missing data model parameters");
                    return(new BadRequestObjectResult("Error missing data model parameters"));
                }
                string storageAccount  = Common.Helpers.Common.GetStorageKey(req);
                DataModelManagement dm = new DataModelManagement(storageAccount, null);
                await dm.DataModelCreate(dmParameters);
            }
            catch (Exception ex)
            {
                log.LogError($"DataModelCreate: {ex}");
                return(new BadRequestObjectResult($"Error creating data model: {ex}"));
            }

            log.LogInformation("DataModelCreate: Complete");
            return(new OkObjectResult("OK"));
        }
 private void CreatePPDMModel(DataModelParameters dmParameters, ConnectParameters connector)
 {
     try
     {
         CloudStorageAccount account    = CloudStorageAccount.Parse(connectionString);
         CloudFileClient     fileClient = account.CreateCloudFileClient();
         CloudFileShare      share      = fileClient.GetShareReference(dmParameters.FileShare);
         if (share.Exists())
         {
             CloudFileDirectory rootDir = share.GetRootDirectoryReference();
             CloudFile          file    = rootDir.GetFileReference(dmParameters.FileName);
             if (file.Exists())
             {
                 string      sql    = file.DownloadTextAsync().Result;
                 DbUtilities dbConn = new DbUtilities();
                 dbConn.OpenConnection(connector);
                 dbConn.SQLExecute(sql);
                 dbConn.CloseConnection();
             }
         }
     }
     catch (Exception ex)
     {
         Exception error = new Exception("Create PPDM Model Error: ", ex);
         throw error;
     }
 }
        public async Task Create(DataModelParameters modelParameters)
        {
            var response = await httpService.Post(modelUrl, modelParameters);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
        }
        private async Task CreateDMSModel(DataModelParameters dmParameters, ConnectParameters connector)
        {
            try
            {
                string sql = await ReadDatabaseFile("DataScienceManagement.sql");

                string sqlFunctions = await ReadDatabaseFile("InternalRuleFunctions.sql");

                DbUtilities dbConn = new DbUtilities();
                dbConn.OpenConnection(connector);
                dbConn.SQLExecute(sql);
                dbConn.SQLExecute(sqlFunctions);
                //CreateSqlSources(dbConn);
                dbConn.CloseConnection();

                string fileName = "WellBore.json";
                string taxonomy = await ReadDatabaseFile(fileName);

                await _fileStorage.SaveFile(dmParameters.FileShare, fileName, taxonomy);

                fileName = "PPDMDataAccess.json";
                string definition = await ReadDatabaseFile(fileName);

                await _fileStorage.SaveFile("connectdefinition", fileName, definition);

                fileName   = "LASDataAccess.json";
                definition = await ReadDatabaseFile(fileName);

                await _fileStorage.SaveFile("connectdefinition", fileName, definition);

                fileName   = "CSVDataAccess.json";
                definition = await ReadDatabaseFile(fileName);

                await _fileStorage.SaveFile("connectdefinition", fileName, definition);

                fileName   = "PPDMReferenceTables.json";
                definition = await ReadDatabaseFile(fileName);

                await _fileStorage.SaveFile("connectdefinition", fileName, definition);
            }
            catch (Exception ex)
            {
                Exception error = new Exception("Create DMS Model Error: ", ex);
                throw error;
            }
        }
        public async Task Create(DataModelParameters modelParameters)
        {
            if (string.IsNullOrEmpty(baseUrl))
            {
                url = "api/datamodel";
            }
            else
            {
                url = baseUrl.BuildFunctionUrl("DataModelCreate", $"", apiKey);
            }
            Console.WriteLine($"Create model: {url}");
            var response = await httpService.Post(url, modelParameters);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
        }
 public async Task <ActionResult <string> > DataModelCreate(DataModelParameters dmParameters)
 {
     logger.LogInformation("Starting data model create");
     if (dmParameters == null)
     {
         return(BadRequest());
     }
     try
     {
         string storageAccount   = DatabaseManager.Common.Helpers.Common.GetStorageKey(Request);
         DataModelManagement dmm = new DataModelManagement(storageAccount, _contentRootPath);
         await dmm.DataModelCreate(dmParameters);
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
     logger.LogInformation("Data model create Complete");
     return(Ok($"OK"));
 }
        public async Task <ActionResult <string> > DataModelCreate(DataModelParameters dmParameters)
        {
            if (dmParameters == null)
            {
                return(BadRequest());
            }

            try
            {
                ConnectParameters connector = Common.GetConnectParameters(connectionString, container, dmParameters.DataConnector);
                if (connector == null)
                {
                    return(BadRequest());
                }
                if (dmParameters.ModelOption == "PPDM Model")
                {
                    CreatePPDMModel(dmParameters, connector);
                }
                else if (dmParameters.ModelOption == "DMS Model")
                {
                    CreateDMSModel(connector);
                }
                else if (dmParameters.ModelOption == "Stored Procedures")
                {
                    CreateStoredProcedures(connector);
                }
                else if (dmParameters.ModelOption == "PPDM Modifications")
                {
                    CreatePpdmModifications(connector);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.ToString()));
            }

            return(Ok($"OK"));
        }