Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void loadProfile() throws Exception
        private void loadProfile()
        {
            DatabaseDBUtil.currentSession().beginTransaction();
            LocalizationProfileTable localizationProfileTable = new LocalizationProfileTable();

            localizationProfileTable.SupportsState = false;
            localizationProfileTable.ProfileName   = "Richardson Base";
            localizationProfileTable.CreateDate    = DateTime.Now;
            localizationProfileTable.LastUpdate    = DateTime.Now;
            localizationProfileTable.CreateUserId  = "richardson";
            localizationProfileTable.EditorId      = "richardson";
            localizationProfileTable.FromCountry   = "US";
            localizationProfileTable.FromState     = "US AVERAGE";
            long?long = (long?)DatabaseDBUtil.currentSession().save(localizationProfileTable);

            localizationProfileTable = (LocalizationProfileTable)DatabaseDBUtil.currentSession().load(typeof(LocalizationProfileTable), long);
            if (localizationProfileTable.Factors == null)
            {
                localizationProfileTable.Factors = new List <object>();
            }
            string            str = "SELECT * FROM CRAFT";
            PreparedStatement preparedStatement = this.con.prepareStatement(str);
            ResultSet         resultSet         = preparedStatement.executeQuery();
            sbyte             b = 0;

            while (resultSet.next())
            {
                int?   integer = Convert.ToInt32(resultSet.getInt(1));
                string str1    = resultSet.getString(2);
                string str2    = resultSet.getString(3);
                string str3    = resultSet.getString(4);
                double?double1;
                double?double2 = (double1 = Convert.ToDouble(resultSet.getDouble(5))).valueOf(resultSet.getDouble(6));
                string str4    = resultSet.getString(7);
                if (str1.Equals("0RICH0"))
                {
                    continue;
                }
                double?                 double3        = (double?)this.averagesMap[str3];
                RichardsonCity          richardsonCity = (RichardsonCity)this.citiesMap[str1];
                double                  d = (double1.Value + double2.Value) / double3.Value;
                LocalizationFactorTable localizationFactorTable = new LocalizationFactorTable();
                localizationFactorTable.AssemblyFactor      = BigDecimalMath.ONE;
                localizationFactorTable.EquipmentFactor     = BigDecimalMath.ONE;
                localizationFactorTable.Online              = true;
                localizationFactorTable.EditorId            = "richardson";
                localizationFactorTable.SubcontractorFactor = BigDecimalMath.ONE;
                localizationFactorTable.LaborFactor         = new BigDecimalFixed("" + d);
                localizationFactorTable.MaterialFactor      = BigDecimalMath.ONE;
                localizationFactorTable.ConsumableFactor    = BigDecimalMath.ONE;
                string str5 = richardsonCity.CountryCode;
                if (str5.Equals("USA"))
                {
                    str5 = "US";
                }
                else if (str5.Equals("CAN"))
                {
                    str5 = "CA";
                }
                LocationData locationData = LocationDataRetriever.Instance.retrieveForNorthAmericaData(richardsonCity.ZipCode, richardsonCity.StateCode, richardsonCity.City, str5);
                if (locationData == null)
                {
                    Console.WriteLine("NO LOCATION DATA FOUND FOR: " + richardsonCity);
                    continue;
                }
                localizationFactorTable.ToCountry                = locationData.Country;
                localizationFactorTable.ToState                  = locationData.State;
                localizationFactorTable.ToCity                   = locationData.City;
                localizationFactorTable.ToZipCode                = locationData.ZipCode;
                localizationFactorTable.GroupCodeName            = "";
                localizationFactorTable.ParentCode               = str3;
                localizationFactorTable.GeoPolygon               = locationData.GeoPolygon;
                localizationFactorTable.LocalizationProfileTable = localizationProfileTable;
                localizationProfileTable.Factors.Add(localizationFactorTable);
                Console.WriteLine("I AM SAVING: " + localizationFactorTable.ToCountry + ", " + localizationFactorTable.ToState + ", " + localizationFactorTable.ToCity + ", " + localizationFactorTable.ToZipCode);
                DatabaseDBUtil.currentSession().save(localizationFactorTable);
                if (++b % 'Ǵ' == 'dz')
                {
                    DatabaseDBUtil.currentSession().Transaction.commit();
                    DatabaseDBUtil.currentSession().beginTransaction();
                    Console.WriteLine("\n\n\n\n\n\nCommitted " + b + " factors");
                }
            }
            preparedStatement.close();
            DatabaseDBUtil.currentSession().Transaction.commit();
            DatabaseDBUtil.closeSession();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void loadCCI(java.io.File paramFile, String paramString1, String paramString2, String paramString3) throws Exception
        private void loadCCI(File paramFile, string paramString1, string paramString2, string paramString3)
        {
            StreamReader             bufferedReader           = new StreamReader(paramFile);
            LocalizationProfileTable localizationProfileTable = new LocalizationProfileTable();

            localizationProfileTable.SupportsState = false;
            localizationProfileTable.ProfileName   = paramString3;
            localizationProfileTable.CreateDate    = DateTime.Now;
            localizationProfileTable.LastUpdate    = DateTime.Now;
            localizationProfileTable.CreateUserId  = "rsmeans";
            localizationProfileTable.EditorId      = "rsmeans";
            localizationProfileTable.FromCountry   = "US";
            localizationProfileTable.FromState     = "US AVERAGE";
            long?long = (long?)DatabaseDBUtil.currentSession().save(localizationProfileTable);

            localizationProfileTable   = (LocalizationProfileTable)DatabaseDBUtil.currentSession().load(typeof(LocalizationProfileTable), long);
            this.localizationProfileId = long;
            if (localizationProfileTable.Factors == null)
            {
                localizationProfileTable.Factors = new List <object>();
            }
            sbyte b = 0;

            while (true)
            {
                string str1 = bufferedReader.ReadLine();
                if (string.ReferenceEquals(str1, null))
                {
                    break;
                }
                string str2 = str1.Substring(0, 4);
                string str3 = str1.Substring(4, 3);
                string str4 = str1.Substring(7, 2);
                string str5 = StringUtils.removeSpacesFromEnd(str1.Substring(9, 23));
                string str6 = str1.Substring(32, 3);
                string str7 = StringUtils.removeSpacesFromStart(str1.Substring(35, 12));
                string str8 = StringUtils.removeSpacesFromStart(str1.Substring(47, 12));
                string str9 = StringUtils.removeSpacesFromStart(str1.Substring(59, 12));
                LocalizationFactorTable localizationFactorTable = new LocalizationFactorTable();
                localizationFactorTable.AssemblyFactor      = BigDecimalMath.ONE;
                localizationFactorTable.EquipmentFactor     = BigDecimalMath.ONE;
                localizationFactorTable.Online              = true;
                localizationFactorTable.EditorId            = "rsmeans";
                localizationFactorTable.SubcontractorFactor = BigDecimalMath.ONE;
                localizationFactorTable.LaborFactor         = new BigDecimalFixed(str8);
                localizationFactorTable.MaterialFactor      = new BigDecimalFixed(str7);
                localizationFactorTable.ConsumableFactor    = BigDecimalMath.ONE;
                LocationData locationData = null;
                if (locationData == null)
                {
                    locationData            = new LocationData();
                    locationData.City       = str5.ToUpper();
                    locationData.State      = str4.ToUpper();
                    locationData.Country    = paramString1;
                    locationData.ZipCode    = str3;
                    locationData.GeoPolygon = "";
                    Console.WriteLine("LOADED: " + str3 + ", " + str4 + ", " + str5 + "," + paramString1);
                }
                localizationFactorTable.ToCountry                = locationData.Country;
                localizationFactorTable.ToState                  = locationData.State;
                localizationFactorTable.ToCity                   = locationData.City;
                localizationFactorTable.ToZipCode                = locationData.ZipCode;
                localizationFactorTable.GroupCodeName            = paramString2;
                localizationFactorTable.ParentCode               = str6;
                localizationFactorTable.GeoPolygon               = locationData.GeoPolygon;
                localizationFactorTable.LocalizationProfileTable = localizationProfileTable;
                localizationProfileTable.Factors.Add(localizationFactorTable);
                DatabaseDBUtil.currentSession().save(localizationFactorTable);
                if (++b % 'Ǵ' == 'dz')
                {
                    DatabaseDBUtil.currentSession().Transaction.commit();
                    DatabaseDBUtil.currentSession().beginTransaction();
                    Console.WriteLine("Committed " + b + " factors");
                }
            }
            bufferedReader.Close();
            DatabaseDBUtil.currentSession().update(localizationProfileTable);
        }