/// <summary> /// Run Procedure lynx.store_clr_dlls. /// </summary> static void ExecuteClrDll() { Console.WriteLine("Running lynx.store_clr_dlls ..."); OracleClass oc = new OracleClass(); oc.Connect(); oc.tran = oc.conn.BeginTransaction(); ProcedureInputClass pic = new ProcedureInputClass(); pic.numberOfParameters = 0; pic.procedureName = "lynx.store_clr_dlls"; oc.NonQueryProcedure(pic); oc.tran.Commit(); oc.conn.Close(); Console.WriteLine("Finished lynx.store_clr_dlls."); }
/// <summary> /// Test if the xml file is setup correctly for a database connection. /// </summary> static void TestDbConnection(string UserId, string Password, string Privilege) { Console.WriteLine("Testing Database Connection..."); try { OracleClass oc = new OracleClass(); oc.Connect(UserId, Password, Privilege); oc.conn.Close(); } catch { } }
/// <summary> /// Open 10_drop_prior_upgrade_objects.pdc and Parse and run each line. /// </summary> static void RunDropPriorUpgrade() { string dropLocation = StartLocation + "\\10_Structure\\" + CurrentEdition + "\\05_UPGRADE\\10_drop_prior_upgrade_objects.pdc"; if (File.Exists(dropLocation)) { string readLine; OracleClass oc = new OracleClass(); oc.Connect(); oc.tran = oc.conn.BeginTransaction(); using (StreamReader dpuFile = new StreamReader(dropLocation)) { while((readLine = dpuFile.ReadLine()) != null) { if (readLine != "commit;") { readLine = readLine.Replace(";", ""); oc.NonQueryText(readLine); } } } oc.tran.Commit(); oc.conn.Close(); } }
/// <summary> /// Open 40_qualify_database_and_unlock_.pdc and Parse and run each line. /// </summary> static void RunQualifyDatabaseAndUnlock() { string dropLocation = StartLocation + "\\10_Structure\\" + CurrentEdition + "\\05_UPGRADE\\40_qualify_database_and_unlock_.pdc"; if (File.Exists(dropLocation)) { string readLine; OracleClass oc = new OracleClass(); oc.Connect(); oc.tran = oc.conn.BeginTransaction(); using (StreamReader dpuFile = new StreamReader(dropLocation)) { while ((readLine = dpuFile.ReadLine()) != null) { readLine = readLine.Replace(";", ""); if (readLine.IndexOf("execute", StringComparison.OrdinalIgnoreCase) != -1) { readLine = readLine.Remove(0, 8); ProcedureInputClass pic = new ProcedureInputClass(); pic.numberOfParameters = 0; pic.procedureName = readLine; oc.NonQueryProcedure(pic); } else { oc.NonQueryText(readLine); } } } oc.tran.Commit(); oc.conn.Close(); } }
/// <summary> /// Reads the sql file and then parses and inserts it into the database. /// </summary> /// <param name="filePath"></param> public void ReadFilesToInsert(string scriptType) { Console.WriteLine("Converting " + scriptType + " files to inserts into DB..."); insertV.sectionNumber = 0; // Start the Oracle Stuff // OracleClass oc = new OracleClass(); oc.Connect(); oc.tran = oc.conn.BeginTransaction(); // Get all the schema folders // List<string> lynxFoldersAll; if (scriptType == "Structure") { oc.NonQueryText("update rt_upgrade u set u.upg_error_command_id=null, u.upg_error_ind='N', u.this_db_qualifies_ind='N' where u.upg_id='1'"); oc.NonQueryText("delete from rt_upgrade_command"); lynxFoldersAll = GetStructureLynxFolders(); } else { lynxFoldersAll = GetCodeLynxFolders(); } // Go through each schema folder // foreach (string lynxFolder in lynxFoldersAll) { // Each Folder write connect with section // insertV.sectionNumber++; if (scriptType == "Structure") WriteRunUpgrade(lynxFolder); // Go through each folder contained in the schema folder // var lynxSubFolderList = Directory.GetDirectories(lynxFolder); foreach(string lynxSubFolder in lynxSubFolderList) { // If 900 Folder then write to finalize, does execution order need to change? // insertV.finalIndication = "'N'"; int sectionNum = insertV.sectionNumber; if (lynxSubFolder.IndexOf("900") != -1) { insertV.finalIndication = "'Y'"; sectionNum = insertV.sectionNumber + lynxFoldersAll.Count; if (scriptType == "Structure") WriteRunFinalize(lynxFolder, lynxFoldersAll.Count); } // Go through each file in the sub folders // var filesInLynxSubFolder = Directory.GetFiles(lynxSubFolder); foreach (string filePath in filesInLynxSubFolder) ParseForDbInsert(ref oc, filePath, sectionNum); } } // Commit the transactions // oc.tran.Commit(); oc.conn.Dispose(); Console.WriteLine(scriptType + " files written to rt_upgrade_command."); Console.WriteLine(); }