public virtual StandardizedAddress StandardizeAddress(string street, string city, string state, string zipCode)
        {
            string endpointUri         = "";
            StandardizedAddress result = new StandardizedAddress {
                Street = street, City = city, State = state, ZipCode = zipCode, MelissaAddressWashSucceeded = false, ErrorOccurred = "true"
            };

            try
            {
                endpointUri = BuildStandarizedAddressEndpointUri(street, city, state, zipCode);
                XElement xml = GetXml(endpointUri);
                result = xml.ToStandardizedAddress(endpointUri);
                if (String.IsNullOrWhiteSpace(result.CountyName))
                {
                    result.CountyID = LookupCountyID(zipCodeNumber: zipCode);
                }
                else
                {
                    result.CountyID = LookupCountyID(countyName: result.CountyName);
                }
            }
            catch (Exception ex)
            {
                using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
                {
                    ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                    services.ErrorReporting.Report(StandardizedAddressErrorMessage("AddressServiceProxy::StandardizeAddress", endpointUri, ex), ex);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private void SummaryDeltaButton_Click(object sender, RoutedEventArgs e)
        {
            ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(DataRepository);

            try
            {
                int fsid = 0;
                fsid = Convert.ToInt32(SDFsidTB.Text);
                XElement submittalDeltaElement = services.SubmittalDelta.DeltaFS(fsid);
                this.OutputTB.Text = submittalDeltaElement.ToString();
            }
            catch (Exception ex)
            {
                this.OutputTB.Text = "Error: " + ex.Message;
            }
        }
Exemplo n.º 3
0
        private void InventorySummaryButton_Click(object sender, RoutedEventArgs e)
        {
            ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(DataRepository);

            try
            {
                int fsid = 0;
                fsid = Convert.ToInt32(ISFsidTB.Text);

                services.BusinessLogic.SubmittalElements.HazardousMaterialsInventory.InventorySummary.Summary(Convert.ToInt32(fsid));

                // all this was done in Summary but we need the information to get the output
                FacilitySubmittal        fs  = (from fsRec in DataRepository.DataModel.FacilitySubmittals where fsRec.ID == fsid select fsRec).FirstOrDefault();
                FacilitySubmittalElement fse =
                    (from fseRec in DataRepository.DataModel.FacilitySubmittalElements
                     where fseRec.FacilitySubmittal.ID == fs.ID && fseRec.Voided == false &&
                     fseRec.SubmittalElementID == (int)SubmittalElementType.HazardousMaterialsInventory
                     select fseRec).FirstOrDefault();
                FacilitySubmittalElementResource fser =
                    (from fserRec in DataRepository.DataModel.FacilitySubmittalElementResources
                     where fserRec.FacilitySubmittalElementID == fse.ID &&
                     fserRec.Voided == false && fserRec.ResourceTypeID == (int)ResourceType.HazardousMaterialInventory
                     select fserRec).FirstOrDefault();

                InventorySummary inventory = DataRepository.InventorySummaries.GetByFSERID(fser.ID);
                StringBuilder    results   = new StringBuilder();
                results.Append("Inventory Summary  FSE: " + fse.ID + " CERSID: " + fse.CERSID + "\n");

                results.Append("   Solid Material Count: " + inventory.SolidMaterialCount + " EHS Count: " +
                               inventory.SolidEHSCount + " Maximum Daily Value: " + inventory.SolidMaximumDailyValue + " pounds\n");
                results.Append("   Liquid Material Count: " + inventory.LiquidMaterialCount + " EHS Count: " +
                               inventory.LiquidEHSCount + " Maximum Daily Value: " + inventory.LiquidMaximumDailyValue + " gallons\n");
                results.Append("   Gas Material Count: " + inventory.GasMaterialCount + " EHS Count: " +
                               inventory.GasEHSCount + " Maximum Daily Value: " + inventory.GasMaximumDailyValue + " cubic feet\n");
                results.Append("   Unique Location Count: " + inventory.UniqueLocationCount + "\n");

                this.OutputTB.Text = results.ToString();
            }
            catch (Exception ex)
            {
                this.OutputTB.Text = "Error: " + ex.Message;
            }
        }
        public ParsedAddress ParseAddress(string street)
        {
            string        endpointUri = "";
            ParsedAddress result      = new ParsedAddress();

            try
            {
                endpointUri = BuildParseAddressEndpointUri(street);
                XElement xml = GetXml(endpointUri);
                result = xml.ToParsedAddress(endpointUri);
            }
            catch (Exception ex)
            {
                using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
                {
                    ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                    services.ErrorReporting.Report(StandardizedAddressErrorMessage("AddressServiceProxy::ParseAddress", endpointUri, ex), ex);
                }
            }
            return(result);
        }
        public virtual StandardizedBusinessName StandardizeBusinessName(string businessName)
        {
            string endpointUri = "";
            StandardizedBusinessName result = new StandardizedBusinessName {
                BusinessName = businessName, EndPointUri = "", Message = ""
            };

            try
            {
                endpointUri = BuildStandardizedBusinessNameEndpointUri(businessName);
                XElement xml = GetXml(endpointUri);
                result = xml.ToStandardizedBusinessName(endpointUri);
            }
            catch (Exception ex)
            {
                using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
                {
                    ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                    services.ErrorReporting.Report(StandardizedAddressErrorMessage("AddressServiceProxy::StandardizedBusinessName", endpointUri, ex), ex);
                }
            }
            return(result);
        }
        public virtual CityZipValidationResult VerifyCityByZip(string city, string state, string zip)
        {
            string endpointUri             = "";
            CityZipValidationResult result = new CityZipValidationResult {
                CityFound = false, ErrorsOccurred = true, ZipCodeFound = false
            };

            try
            {
                endpointUri = BuildVerifyCityByZipEndpointUri(city, state, zip);
                XElement xml = GetXml(endpointUri);
                result = xml.ToCityZipValidationResult(endpointUri);
            }
            catch (Exception ex)
            {
                using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
                {
                    ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                    services.ErrorReporting.Report(StandardizedAddressErrorMessage("AddressServiceProxy::VerifyCityByZip", endpointUri, ex), ex);
                }
            }
            return(result);
        }
Exemplo n.º 7
0
        private static void Main(string[] args)
        {
            Console.WriteLine("CERS2 Address Washing Utility, v0.01");
            Console.WriteLine("Initializing Data Registry...");
            DataRegistry.Initialize();
            int successCount              = 0;
            int failureCount              = 0;
            int lengthViolationsCount     = 0;
            int skippedDueToMissingStreet = 0;

            bool lengthViolation = false;

            using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
            {
                ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                Console.WriteLine("Gathering Facilities...");

                //DateTime washDate = DateTime.Now.Date.AddDays( -3 );
                //DateTime washDate = Convert.ToDateTime( "12/31/2013" );
                DateTime washDate = Convert.ToDateTime("6/30/2014");

                //var facilities = repo.Facilities.Search(washDate: washDate).ToList();

                var facilities = (from fac in repo.DataModel.Facilities where !fac.Voided && !fac.IsAddressWashed && fac.WashDate > washDate select fac).ToList();

                //var facilities = ( from facil in repo.DataModel.Facilities where facil.Voided == false select facil ).ToList();

                Console.WriteLine("Found " + facilities.Count() + " Facilities...");
                foreach (var facility in facilities)
                {
                    lengthViolation = false;
                    Console.WriteLine("CERSID: " + facility.CERSID);
                    Console.WriteLine("Facility Name: " + facility.Name);
                    Console.Write("\tSource Address: ");
                    Console.WriteLine(GetSourceAddress(facility));
                    if (!string.IsNullOrWhiteSpace(facility.Street))
                    {
                        Console.Write("\tWashed Address:");
                        AddressInformation result = services.Geo.GetAddressInformation(facility.Street, facility.City, facility.ZipCode, facility.State);
                        if (result != null)
                        {
                            CheckLength("WashedStreet", result.Street, 100, ref lengthViolation);
                            CheckLength("WashedCity", result.City, 100, ref lengthViolation);
                            CheckLength("WashedState", result.State, 2, ref lengthViolation);
                            CheckLength("WashedZipCode", result.ZipCode, 10, ref lengthViolation);

                            if (!lengthViolation)
                            {
                                int washConfidence;
                                if (int.TryParse(result.MelissaAddressWashConfidence, out washConfidence) == false)
                                {
                                    washConfidence = 0;
                                }

                                if (result.MelissaAddressWashSucceeded && Convert.ToInt32(washConfidence) > 0)
                                {
                                    facility.IsAddressWashed           = true;
                                    facility.WashDate                  = DateTime.Now;
                                    facility.WashedStreet              = result.Street;
                                    facility.WashedStreetWithoutSuite  = result.StreetWithoutSuiteNumber;
                                    facility.WashedSuite               = result.Suite;
                                    facility.WashedCity                = result.City;
                                    facility.WashedState               = result.State;
                                    facility.WashedZipCode             = result.ZipCode;
                                    facility.WashedStreetName          = result.StreetName;
                                    facility.WashedStreetPostDirection = result.PostDirection;
                                    facility.WashedStreetPreDirection  = result.PreDirection;
                                    facility.WashedStreetRange         = result.Range;
                                    facility.WashedStreetSuffix        = result.Suffix;
                                    facility.WashConfidence            = washConfidence;
                                    facility.WashSourceID              = (int)WashSource.Melissa;
                                    if (facility.CountyID == null)
                                    {
                                        facility.CountyID = result.CountyID;
                                    }

                                    CERSFacilityGeoPoint geoPoint = facility.CERSFacilityGeoPoint;

                                    if (geoPoint == null)
                                    {
                                        geoPoint = new CERSFacilityGeoPoint();
                                    }

                                    //make sure the result coordinates are in range before saving them
                                    if ((result.Latitude >= 32 && result.Latitude < 43) && (result.Longitude >= -114 && result.Longitude < 125))
                                    {
                                        geoPoint.CERSID                       = facility.CERSID;
                                        geoPoint.LatitudeMeasure              = result.Latitude;
                                        geoPoint.LongitudeMeasure             = result.Longitude;
                                        geoPoint.HorizontalAccuracyMeasure    = result.HorizontalAccuracyMeasure;
                                        geoPoint.HorizontalCollectionMethodID = result.HorizontalCollectionMethodID;
                                        geoPoint.HorizontalReferenceDatumID   = result.HorizontalReferenceDatumID;
                                        geoPoint.GeographicReferencePointID   = result.GeographicReferencePointID;
                                        geoPoint.SetCommonFields();
                                        repo.CERSFacilityGeoPoints.Save(geoPoint);
                                    }
                                }
                                else if (result.MelissaAddressWashSucceeded)
                                {
                                    //Use the parsed street values to get a standardized address

                                    facility.IsAddressWashed           = false;
                                    facility.WashDate                  = DateTime.Now;
                                    facility.WashSourceID              = (int)WashSource.Melissa;
                                    facility.WashedStreet              = result.Street;
                                    facility.WashedStreetWithoutSuite  = result.StreetWithoutSuiteNumber;
                                    facility.WashedSuite               = result.Suite;
                                    facility.WashedCity                = result.City;
                                    facility.WashedState               = result.State;
                                    facility.WashedZipCode             = result.ZipCode;
                                    facility.WashedStreetName          = result.StreetName;
                                    facility.WashedStreetPostDirection = null;
                                    facility.WashedStreetPreDirection  = null;
                                    facility.WashedStreetRange         = result.Range;
                                    facility.WashedStreetSuffix        = result.Suffix;
                                }

                                Console.WriteLine(GetWashedAddress(result));
                                Console.WriteLine("\tUpdating Facility...");
                                repo.Facilities.Save(facility);
                                Console.WriteLine("\tFacility Updated");
                                successCount++;
                            }
                            else
                            {
                                Console.WriteLine("\tFacility NOT Updated");
                                lengthViolationsCount++;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Unable to obtain washed address.");
                            failureCount++;
                        }
                    }
                    else
                    {
                        skippedDueToMissingStreet++;
                        Console.WriteLine("\tSkipped Due to Missing Street!");
                    }
                }

                Console.WriteLine("Process Completed.");
                Console.WriteLine("Successfully Washed: " + successCount);
                Console.WriteLine("Failed To Wash: " + failureCount);
                Console.WriteLine("Length Violations (NOT Washed): " + lengthViolationsCount);
                Console.WriteLine("Skipped Due to Missing Street: " + skippedDueToMissingStreet);
            }
            Console.Write("Press enter to quit.");
            Console.ReadLine();
        }