public DataSet TrackFieldRequests(string[] itemNumbers) {
     //
     DataSet response = null;
     try {
         response = new USPSGateway().TrackFieldRequests(itemNumbers);
     }
     catch(Exception ex) { throw new FaultException<USPSFault>(new USPSFault(ex.Message), "Service Error"); }
     return response;
 }
 public DataSet LookupZipCode(string firmName,string address1,string address2,string city,string state) {
     //
     DataSet response = new DataSet();
     try {
         DataSet ds = new USPSGateway().LookupZipCode(firmName,address1,address2,city,state);
         if (ds != null) response.Merge(ds);
     }
     catch (Exception ex) { throw new FaultException<USPSFault>(new USPSFault(ex.Message),"Service Error"); }
     return response;
 }
 public DataSet LookupCityState(string zip5) {
     //
     DataSet response = new DataSet();
     try {
         DataSet ds = new USPSGateway().LookupCityState(zip5);
         if (ds != null) response.Merge(ds);
     }
     catch(Exception ex) { throw new FaultException<USPSFault>(new USPSFault(ex.Message), "Service Error"); }
     return response;
 }
예제 #4
0
 protected void OnZipChanged(object sender,EventArgs e) {
     //Event handler for change in zip
     try {
         //Validate the zip is servicable; display city/state if it is; notify and log unsupported zips if not
         string zip5 = this.txtZip5.Text;
         if (zip5.Trim().Length == 5) {
             CityStateLookupResponse response = new VS13.USPS.USPSGateway().LookupCityState(zip5);
             if (response == null) {
                 this.txtZip5.Text = "";
                 this.txtZip5.Focus();
                 throw new ApplicationException(zip5 + " is currently not supported.");
             }
             else {
                 this.txtCity.Text = response.ZipCode[0].City.Trim();
                 this.txtState.Text = response.ZipCode[0].State.Trim();
                 this.txtName.Focus();
             }
         }
     }
     catch (Exception ex) { reportError(ex,3); }
 }
예제 #5
0
 private bool trackRequest(string itemNumber) {
     //Call USPS WebAPI to track item
     bool tracked = false;
     try {
         TrackResponse response = new USPSGateway().TrackRequest(itemNumber);
         if (response.Error.Rows.Count > 0) {
             //Bad item or syntax
             string error = (!response.Error[0].IsNumberNull() ? response.Error[0].Number : "") + " " + (!response.Error[0].IsSourceNull() ? response.Error[0].Source : "") + "\r\n" + (!response.Error[0].IsDescriptionNull() ? response.Error[0].Description : "");
             showMessageBox(error);
         }
         else if (response.TrackInfo.Rows.Count > 0) {
             //Item found
             this.txtSummary.Text = response.TrackInfo[0].TrackSummary;
             //TODO: Detail
             tracked = true;
         }
         else {
             //Not verified
             showMessageBox("The item could not be tracked by the US Postal Service.");
         }
     }
     catch (Exception ex) { reportError(ex,4); }
     return tracked;
 }
예제 #6
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 : "");
                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].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
                showMessageBox("The adddress could not be verified by the US Postal Service.");
            }
        }
        catch (Exception ex) { reportError(ex,4); }
        return verified;
    }