//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void extractDBFile(java.io.File paramFile) throws Exception private void extractDBFile(File paramFile) { this.projectFolder = makeProjectFolder(this.o_projectFolderName); this.projectFolder.mkdirs(); ZipUtil.unpackArchive(paramFile, this.projectFolder); File file = new File(installDir + "project" + File.separator + this.o_projectFolderName + File.separator + "projectDB.details"); if (!paramFile.Name.equalsIgnoreCase("populatedExpenses") && file.exists()) { Console.WriteLine("Migrating from file to database..." + paramFile); this.o_properties = new ProjectDBProperties(this, file.AbsoluteFile.ToString()); file.delete(); if (file.exists()) { throw new Exception("fatal error when upgrading project, could not delete previous details file"); } } else if (file.exists()) { file.delete(); if (file.exists()) { throw new Exception("fatal error when upgrading project, could not delete previous details file"); } loadDB(); } else { loadDB(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void makeNewDB() throws Exception private void makeNewDB() { File file = makeProjectFolder(this.o_projectFolderName); file.mkdirs(); this.o_properties = new ProjectDBProperties(this, false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void loadDB() throws Exception public override void loadDB() { if (DBLoaded) { return; } if (syncToEventDispatch && !SwingUtilities.EventDispatchThread) { this.o_retException = null; SwingUtilities.invokeAndWait(new RunnableAnonymousInnerClass(this)); if (this.o_retException != null) { throw this.o_retException; } return; } if (this.o_properties != null && !string.ReferenceEquals(this.o_properties.PreviousVersion, null)) { if (this.o_properties.isOlderVersionFrom(this.o_properties.PreviousVersion, "4.0.1")) { Console.WriteLine("Deleting indexes prior to 4.0.1 from version " + this.o_properties.PreviousVersion); try { Console.WriteLine("deleting: " + new File(installDir + "project/" + this.o_projectFolderName + "/indexBase")); deleteDirectory(new File(installDir + "project/" + this.o_projectFolderName + "/indexBase")); } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } } if (this.o_properties.isOlderVersionFrom(this.o_properties.PreviousVersion, "4.2.7")) { Properties properties = new Properties(); properties.setProperty("user", "SA"); properties.setProperty("password", ""); properties.setProperty("shutdown", "true"); initDriver(HSQL_DBMS); Connection connection = DriverManager.getConnection("jdbc:hsqldb:" + installDir + "project/" + this.o_projectFolderName + "/projectDB", properties); if (!connection.AutoCommit) { connection.commit(); } Statement statement = connection.createStatement(); try { Console.WriteLine("Renaming the Condition Table to CNDON..."); statement.execute("DROP TABLE IF EXISTS CNDON"); statement.execute("ALTER TABLE CONDITION RENAME TO CNDON"); Console.WriteLine("OK!"); } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); Console.WriteLine("TABLE WITH NAME CONDITION NOT FOUND!"); } statement.close(); connection.close(); } if (this.o_properties.isOlderVersionFrom(this.o_properties.PreviousVersion, "4.6.0")) { Properties properties = new Properties(); properties.setProperty("user", "SA"); properties.setProperty("password", ""); properties.setProperty("shutdown", "true"); initDriver(HSQL_DBMS); Connection connection = DriverManager.getConnection("jdbc:hsqldb:" + installDir + "project/" + this.o_projectFolderName + "/projectDB", properties); if (!connection.AutoCommit) { connection.commit(); } Statement statement = connection.createStatement(); try { Console.WriteLine("Updating data integrity..."); statement.execute("ALTER TABLE BOQITEM ALTER COLUMN DESCRIPTION LONGVARCHAR"); statement.execute("ALTER TABLE BOQITEM ALTER COLUMN NOTES LONGVARCHAR"); statement.execute("ALTER TABLE EQUIPMENT ALTER COLUMN DESCRIPTION LONGVARCHAR"); statement.execute("ALTER TABLE EQUIPMENT ALTER COLUMN NOTES LONGVARCHAR"); statement.execute("ALTER TABLE ASSEMBLY ALTER COLUMN DESCRIPTION LONGVARCHAR"); statement.execute("ALTER TABLE ASSEMBLY ALTER COLUMN NOTES LONGVARCHAR"); statement.execute("ALTER TABLE MATERIAL ALTER COLUMN DESCRIPTION LONGVARCHAR"); statement.execute("ALTER TABLE MATERIAL ALTER COLUMN NOTES LONGVARCHAR"); statement.execute("ALTER TABLE SUBCONTRACTOR ALTER COLUMN DESCRIPTION LONGVARCHAR"); statement.execute("ALTER TABLE SUBCONTRACTOR ALTER COLUMN NOTES LONGVARCHAR"); statement.execute("ALTER TABLE QUOTEITEM ALTER COLUMN TITLE LONGVARCHAR"); Console.WriteLine("OK!"); } catch (Exception) { } statement.close(); connection.close(); } } closeSession(); this.o_configuration = new Configuration(); this.o_configuration.configure(configXML); ISet <object> set = this.o_configuration.Properties.Keys; string[] arrayOfString = (string[])set.toArray(new string[set.Count]); foreach (string str in arrayOfString) { if (str.IndexOf("search.default", StringComparison.Ordinal) != -1) { this.o_configuration.Properties.remove(str); } } this.o_configuration.setProperty("hibernate.connection.isolation", "1"); this.o_configuration.setProperty("hibernate.cache.jdbc.batch_size", "50"); this.o_configuration.setProperty("hibernate.cache.use_second_level_cache", "false"); this.o_configuration.setProperty("hibernate.cache.use_query_cache", "false"); this.o_configuration.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider"); this.o_configuration.setProperty("hibernate.search.indexing_strategy", "manual"); this.o_configuration.setProperty("hibernate.search.autoregister_listeners", "false"); this.o_configuration.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false"); this.o_configuration.registerTypeOverride(new CostOSString256Type(), new string[] { "costos_string" }); this.o_configuration.registerTypeOverride(new CostOSTextType()); this.o_configuration.registerTypeOverride(new UnitAliasType(ProjectGroupCodesProvider, "unit_alias")); for (sbyte b = 1; b <= 9; b++) { this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)10, b, "eps_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-1, b, "wbs1_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-2, b, "wbs2_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-3, b, "location_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-4, b, "paramitem_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)10, b, "eps_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-1, b, "wbs1_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-2, b, "wbs2_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-3, b, "location_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-4, b, "paramitem_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-1, b, "wbs1_level" + b + "_item_code", (short)5)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-2, b, "wbs2_level" + b + "_item_code", (short)5)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-1, b, "wbs1_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-2, b, "wbs2_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-1, b, "wbs1_level" + b + "_qty", (short)6)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)-2, b, "wbs2_level" + b + "_qty", (short)6)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)1, b, "groupcode1_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)2, b, "groupcode2_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)3, b, "groupcode3_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)4, b, "groupcode4_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)5, b, "groupcode5_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)6, b, "groupcode6_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)7, b, "groupcode7_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)8, b, "groupcode8_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)9, b, "groupcode9_level" + b + "_code", (short)2)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)1, b, "groupcode1_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)2, b, "groupcode2_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)3, b, "groupcode3_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)4, b, "groupcode4_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)5, b, "groupcode5_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)6, b, "groupcode6_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)7, b, "groupcode7_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)8, b, "groupcode8_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)9, b, "groupcode9_level" + b + "_title", (short)0)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)1, b, "groupcode1_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)2, b, "groupcode2_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)3, b, "groupcode3_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)4, b, "groupcode4_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)5, b, "groupcode5_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)6, b, "groupcode6_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)7, b, "groupcode7_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)8, b, "groupcode8_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)9, b, "groupcode9_level" + b + "_description", (short)1)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)1, b, "groupcode1_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)2, b, "groupcode2_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)3, b, "groupcode3_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)4, b, "groupcode4_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)5, b, "groupcode5_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)6, b, "groupcode6_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)7, b, "groupcode7_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)8, b, "groupcode8_level" + b + "_unit", (short)4)); this.o_configuration.registerTypeOverride(new GroupCodeType(ProjectGroupCodesProvider, (short)9, b, "groupcode9_level" + b + "_unit", (short)4)); } this.o_configuration.setListener("post-update", null); this.o_configuration.setListener("post-insert", null); this.o_configuration.setListener("post-delete", null); this.o_configuration.setProperty("hibernate.connection.url", "jdbc:hsqldb:" + installDir + "project/" + this.o_projectFolderName + "/projectDB;hsqldb.write_delay=false"); this.o_sessionFactory = this.o_configuration.buildSessionFactory(); Session session = currentSession(); if (ProjectSchemaUpdateUtil.checkRequiresProjectIdUpdates(this)) { ProjectSchemaUpdateUtil.processProjectIdUpdates(this); } closeSession(); ProjectDBUtil projectDBUtil; (projectDBUtil = ProjectDBUtil.currentProjectDBUtil()).CurrentProjectDBUtil = this; File file = new File(installDir + "project" + File.separator + this.o_projectFolderName + File.separator + "projectDB.details"); if (!file.exists()) { this.b_isDBLoaded = true; if (this.o_properties == null) { this.o_properties = new ProjectDBProperties(this, true); } else { this.o_properties.reloadProperties(); } if (!string.ReferenceEquals(this.o_properties.PreviousVersion, null)) { updateNewerDatabase(); } ProjectGroupCodesProvider.initializeProjectCaches(); } ProjectDBUtil.CurrentProjectDBUtil = projectDBUtil; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void loadDB() throws Exception public override void loadDB() { if (DBLoaded) { return; } if (syncToEventDispatch && !SwingUtilities.EventDispatchThread) { this.o_retException = null; loadDB(); SwingUtilities.invokeAndWait(new RunnableAnonymousInnerClass(this)); if (this.o_retException != null) { throw this.o_retException; } return; } closeSession(); this.dbmsType = this.o_urlTable.Dbms.Value; if (this.requiresAlters) { this.o_configuration = ProjectSessionFactoryBuilder.Instance.createConfigurationFromUrl(configXML, this.o_urlTable, ProjectGroupCodesProvider, this.requiresAlters, this.o_urlTable.TablePrefix); long l = DateTimeHelper.CurrentUnixTimeMillis(); Console.WriteLine(" BUILDING SESSION FACTORY..."); this.o_sessionFactory = this.o_configuration.buildSessionFactory(); Console.WriteLine("DONE IN: " + ((DateTimeHelper.CurrentUnixTimeMillis() - l) / 1000L)); } else { if (ProjectSessionFactory.GroupCodesProvider == null) { ProjectSessionFactory.UpGroupCodesProvider = s_providerFactory.createSharedFactory(); } this.sharedGroupCodesProvider = (ProjectGroupCodesProvider)ProjectSessionFactory.GroupCodesProvider; long l = DateTimeHelper.CurrentUnixTimeMillis(); Console.WriteLine(" GETTING SESSION FACTORY..."); this.o_configuration = ProjectSessionFactory.getConfiguration(this.dbmsType); this.o_sessionFactory = ProjectSessionFactory.getSessionFactory(this.dbmsType); Console.WriteLine("DONE IN: " + ((DateTimeHelper.CurrentUnixTimeMillis() - l) / 1000L)); } currentSession(); closeSession(); this.b_isDBLoaded = true; ProjectDBUtil projectDBUtil; (projectDBUtil = ProjectDBUtil.currentProjectDBUtil()).CurrentProjectDBUtil = this; if (this.o_properties == null) { this.o_properties = new ProjectDBProperties(this, true); } else { this.o_properties.reloadProperties(); } if (!string.ReferenceEquals(this.o_properties.PreviousVersion, null) && this.requiresAlters && !(s_providerFactory is nomitech.ces.utils.DummyProjectGroupCodesProviderFactory)) { updateNewerDatabase(); } if (this.sharedGroupCodesProvider == null) { ProjectGroupCodesProvider.initializeProjectCaches(); } else { ((WBSCache)Wbs1Cache).initCache(); ((WBS2Cache)Wbs2Cache).initCache(); try { ((ParamItemCache)ParamItemCache).initializeCache(); } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } } ProjectVariableCache.initCache(); ProjectDBUtil.CurrentProjectDBUtil = projectDBUtil; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private Desktop.common.nomitech.common.db.local.ProjectUrlTable makeNewDB(String paramString1, String paramString2, String paramString3, String paramString4, int paramInt, String paramString5, String paramString6, String paramString7, java.util.Properties paramProperties, System.Nullable<bool> paramBoolean) throws Exception private ProjectUrlTable makeNewDB(string paramString1, string paramString2, string paramString3, string paramString4, int paramInt, string paramString5, string paramString6, string paramString7, Properties paramProperties, bool?paramBoolean) { initDriver(paramInt); this.dbmsType = paramInt; string str1 = CryptUtil.Instance.decryptHexString(paramString6); string str2 = AddOnUtil.Instance.decryptHexString(paramString7); if (!StringUtils.isNullOrBlank(paramString5) && (paramBoolean == null || paramBoolean.Value == true)) { string str3 = null; string str4 = null; if (paramInt == ProjectDBUtil.MYSQL_DBMS) { str3 = "CREATE DATABASE " + paramString3; str4 = "mysql"; } else if (paramInt == ProjectDBUtil.SQLSERVER_DBMS) { paramInt = ProjectDBUtil.SQLSERVER_DBMS; str3 = "CREATE DATABASE " + paramString3; str4 = "master"; } else if (paramInt == ProjectDBUtil.ORACLE_DBMS) { paramInt = ProjectDBUtil.ORACLE_DBMS; str3 = "CREATE DATABASE " + paramString3; str4 = "sys"; } string str5 = createJdbcUrl(paramString1, str4, paramString2, paramInt); Connection connection = null; Statement statement = null; try { connection = DriverManager.getConnection(str5, str1, str2); statement = connection.createStatement(); } catch (Exception) { str5 = ProjectDBUtil.createJdbcUrl(paramString1, "CostOS", paramString2, paramInt); connection = DriverManager.getConnection(str5, str1, str2); statement = connection.createStatement(); } try { statement.executeUpdate(str3); } catch (Exception exception) { if (exception.Message.IndexOf("exists") == -1) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); statement.close(); connection.close(); throw exception; } } statement.close(); connection.close(); } else { Connection connection = DriverManager.getConnection(paramString4, str1, str2); if (!connection.AutoCommit) { connection.commit(); } connection.close(); } this.o_properties = new ProjectDBProperties(this, false); if (paramProperties != null) { this.o_properties.Properties = paramProperties; } this.o_urlTable = new ProjectUrlTable(); this.o_urlTable.Hostname = paramString1; this.o_urlTable.Port = paramString2; this.o_urlTable.Dbms = Convert.ToInt32(paramInt); this.o_urlTable.Username = paramString6; this.o_urlTable.Password = paramString7; this.o_urlTable.DbmsName = paramString5; this.o_urlTable.Url = paramString4; this.o_urlTable.DatabaseName = paramString3; this.o_urlTable.CreateDate = DateTime.Now; this.o_urlTable.CreateUserId = DatabaseDBUtil.Properties.UserId; this.o_urlTable.LastUpdate = this.o_urlTable.CreateDate; this.o_urlTable.CreateUserId = this.o_urlTable.CreateUserId; this.o_urlTable.Frozen = false; this.o_urlTable.CreatesNewDatabases = paramBoolean; return(this.o_urlTable); }