Example #1
0
        public AddressWebService()
        {
            var conf       = SecurityAccessor.Instance.EncryptConfig;
            var addressEsb = conf.GetAddressESBService();

            client      = new AddressService.addressServicePortClient(conf.DecryptValue(addressEsb.EndPointName), conf.DecryptValue(addressEsb.Uri));
            reply       = null;
            request     = null;
            addrReply   = null;
            addrRequest = null;
        }
Example #2
0
        public AddressData LookupCityState(string zipcode, string zipplus)
        {
            var custAddrData = new AddressData();

            if (!string.IsNullOrEmpty(zipcode))
            {
                var conf       = SecurityAccessor.Instance.EncryptConfig;
                var addressEsb = conf.GetAddressESBService();
                request = new AddressService.cityStateLookupRequestType
                {
                    serviceInformation = new AddressService.serviceInformationType
                    {
                        domain        = conf.DecryptValue(addressEsb.Domain),
                        shopNumber    = ShopNumber,
                        terminalID    = TerminalID,
                        userID        = UserID,
                        transactionID = TransactionID,
                        timeStamp     = CurrentDateTime
                    },
                    serviceData =
                        new AddressService.cityStateLookupRequestTypeServiceData
                    {
                        postalCode = new AddressService.postalCodeType {
                            zipCode = zipcode
                        }
                    }
                };
                if (zipplus != null && zipplus.Trim().Length != 0)
                {
                    request.serviceData.postalCode.zipPlus = zipplus;
                }

                reply = client.lookupCityState(request);
                if (reply.serviceInformation != null)
                {
                    if (reply.serviceData != null && reply.serviceData.Item != null)
                    {
                        if (reply.serviceData.Item.GetType() != typeof(businessExceptionType))
                        {
                            var returnedAddress = (addressType)reply.serviceData.Item;

                            custAddrData.City  = returnedAddress.city;
                            custAddrData.State = returnedAddress.state;
                        }
                        else
                        {
                            if (reply.serviceInformation.status.exceptionCode != null)
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this, string.Format("Address web service came back with errors {0}", reply.serviceInformation.status.exceptionCode));
                            }
                            else
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Address web service came back with errors ");
                            }
                        }
                    }
                    else
                    //No data came back from the web service call...log it
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Address web service came back with errors ");
                    }
                }
            }

            request = null;
            reply   = null;
            client.Close();
            return(custAddrData);
        }
Example #3
0
        public bool validateAddress(string strAddress1, string strAddress2, string strCity, string strState)
        {
            bool addrCheck = false;

            try
            {
                var conf       = SecurityAccessor.Instance.EncryptConfig;
                var addressEsb = conf.GetAddressESBService();
                addrRequest = new AddressService.addressValidationRequestType();
                addrRequest.serviceInformation           = new AddressService.serviceInformationType();
                addrRequest.serviceInformation.domain    = conf.DecryptValue(addressEsb.Domain);
                request.serviceInformation.shopNumber    = ShopNumber;
                request.serviceInformation.terminalID    = TerminalID;
                request.serviceInformation.userID        = UserID;
                request.serviceInformation.transactionID = TransactionID;
                request.serviceInformation.timeStamp     = CurrentDateTime;
                addrRequest.serviceData = new AddressService.addressValidationRequestTypeServiceData();
                string[] strStreet;
                if (strAddress2.Trim().Length > 0)
                {
                    strStreet    = new string[2];
                    strStreet[0] = strAddress1;
                    strStreet[1] = strAddress2;
                }
                else
                {
                    strStreet    = new string[1];
                    strStreet[0] = strAddress1;
                }

                addrRequest.serviceData.address = new AddressService.addressType
                {
                    street = strStreet,
                    city   = strCity,
                    state  = strState,
                    type   = AddressService.addressTypeType.PHYSICAL
                };

                client.Open();
                addrReply = client.validateAddress(addrRequest);
                client.Close();
                var returnedAddress = (AddressService.addressType)reply.serviceData.Item;
                if (returnedAddress.postalCode.zipCode != null)
                {
                    addrCheck = true;
                }
                else
                {
                    addrCheck = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                client  = null;
                request = null;
                reply   = null;
            }
            return(addrCheck);
        }