Beispiel #1
0
        public DataSet LookupCityState(string zip5)
        {
            //
            DataSet response = null;

            try {
                response = new USPSGateway().TrackRequest(zip5);
            }
            catch (Exception ex) { throw new FaultException <EnterpriseFault>(new EnterpriseFault(ex.Message), "Service Error"); }
            return(response);
        }
Beispiel #2
0
        public DataSet VerifyAddress(string firmName, string address1, string address2, string city, string state, string zip5, string zip4)
        {
            //
            DataSet response = null;

            try {
                response = new USPSGateway().VerifyAddress(firmName, address1, address2, city, state, zip5, zip4);
            }
            catch (Exception ex) { throw new FaultException <EnterpriseFault>(new EnterpriseFault(ex.Message), "Service Error"); }
            return(response);
        }
Beispiel #3
0
        public DataSet LookupZipCode(string firmName, string address1, string address2, string city, string state)
        {
            //
            DataSet response = null;

            try {
                response = new USPSGateway().LookupZipCode(firmName, address1, address2, city, state);
            }
            catch (Exception ex) { throw new FaultException <EnterpriseFault>(new EnterpriseFault(ex.Message), "Service Error"); }
            return(response);
        }
Beispiel #4
0
        public DataSet TrackFieldRequests(string[] itemNumbers)
        {
            //
            DataSet response = null;

            try {
                response = new USPSGateway().TrackFieldRequests(itemNumbers);
            }
            catch (Exception ex) { throw new FaultException <EnterpriseFault>(new EnterpriseFault(ex.Message), "Service Error"); }
            return(response);
        }
Beispiel #5
0
    private bool verifyAddress(string firmName, string addressLine1, string addressLine2, string city, string state, string zip5, string zip4)
    {
        //Call USPS WebAPI to verify address
        bool verified = false;

        try {
            AddressValidateResponse avr = new USPSGateway().VerifyAddress(firmName, addressLine1, addressLine2, city, state, zip5, zip4);
            if (avr.Error.Rows.Count > 0)
            {
                //Bad address or syntax
                string error = (!avr.Error[0].IsNumberNull() ? avr.Error[0].Number : "") + " " + (!avr.Error[0].IsSourceNull() ? avr.Error[0].Source : "") + "\r\n" + (!avr.Error[0].IsDescriptionNull() ? avr.Error[0].Description : "");
                Master.ShowMessageBox(error);
            }
            else if (avr.Address.Rows.Count > 0)
            {
                ////Does it match the request?
                string srcAddress  = addressLine2.Trim().ToLower() + addressLine1.Trim().ToLower();
                string uspsAddress = (!avr.Address[0].IsAddress1Null() ? avr.Address[0].Address1.Trim().ToLower() : "") + (!avr.Address[0].IsAddress2Null() ? avr.Address[0].Address2.Trim().ToLower() : "");
                bool   match       = (srcAddress == uspsAddress) &&
                                     (city.Trim().ToLower() == (!avr.Address[0].IsCityNull() ? avr.Address[0].City.Trim().ToLower() : "")) &&
                                     (state.Trim().ToLower() == (!avr.Address[0].IsStateNull() ? avr.Address[0].State.Trim().ToLower() : "")) &&
                                     (zip5.Trim().ToLower() == (!avr.Address[0].IsZip5Null() ? avr.Address[0].Zip5.Trim().ToLower() : ""));
                if (match && avr.Address[0].IsReturnTextNull())
                {
                    //Use scrubbed USPS address
                    this.txtName.Text         = firmName;
                    this.txtAddressLine1.Text = !avr.Address[0].IsAddress2Null() ? avr.Address[0].Address2 : "";
                    this.txtAddressLine2.Text = !avr.Address[0].IsAddress1Null() ? avr.Address[0].Address1 : "";
                    this.txtCity.Text         = !avr.Address[0].IsCityNull() ? avr.Address[0].City : "";
                    this.txtState.Text        = !avr.Address[0].IsStateNull() ? avr.Address[0].State : "";
                    this.txtZip5.Text         = !avr.Address[0].IsZip5Null() ? avr.Address[0].Zip5 : "";
                    this.txtZip4.Text         = !avr.Address[0].IsZip4Null() ? avr.Address[0].Zip4 : "";
                    verified = true;
                }
                else
                {
                    //Let user choose
                    this.txtSrcName.Text         = firmName;
                    this.txtSrcAddressLine1.Text = addressLine1;
                    this.txtSrcAddressLine2.Text = addressLine2;
                    this.txtSrcCity.Text         = city;
                    this.txtSrcState.Text        = state;
                    this.txtSrcZip5.Text         = zip5;
                    this.txtSrcZip4.Text         = zip4;

                    this.lblMessage.Text          = !avr.Address[0].IsReturnTextNull() ? avr.Address[0].ReturnText : "";
                    this.txtUSPSName.Text         = firmName;
                    this.txtUSPSAddressLine1.Text = !avr.Address[0].IsAddress2Null() ? avr.Address[0].Address2 : "";
                    this.txtUSPSAddressLine2.Text = !avr.Address[0].IsAddress1Null() ? avr.Address[0].Address1 : "";
                    this.txtUSPSCity.Text         = !avr.Address[0].IsCityNull() ? avr.Address[0].City : "";
                    this.txtUSPSState.Text        = !avr.Address[0].IsStateNull() ? avr.Address[0].State : "";
                    this.txtUSPSZip5.Text         = !avr.Address[0].IsZip5Null() ? avr.Address[0].Zip5 : "";
                    this.txtUSPSZip4.Text         = !avr.Address[0].IsZip4Null() ? avr.Address[0].Zip4 : "";

                    this.mvwPage.ActiveViewIndex = 1;
                }
            }
            else
            {
                //Not verified
                Master.ShowMessageBox("The adddress could not be verified by the US Postal Service.");
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
        return(verified);
    }