private void UpdateUI() { ObservableDeviceViewModels = new ObservableCollection <ELLDeviceBaseViewModel>(_deviceViewModels.Values.OrderBy(i => i.FullDeviceName)); SelectedViewModel = ObservableDeviceViewModels.FirstOrDefault(); UsedAddress = _deviceViewModels.Keys.OrderBy(ch => ch).ToList(); FreeAddress = ValidAddress.Where(ch => !UsedAddress.Contains(ch)).OrderBy(ch => ch).ToList(); CanReaddress = UsedAddress.Any() && FreeAddress.Any(); if (CanReaddress) { NewAddress = FreeAddress.First(); OldAddress = UsedAddress.First(); } else { NewAddress = '\0'; OldAddress = '\0'; } UpdateSequence(); }
private void LoadAddress(int index) { ValidAddress validAddress = _validateResult.Addresses[index]; //##################################################### //### LOAD SELECTED ADDRESS DATA FROM RESULT OBJECT ### //##################################################### lblAddressType.Text = validAddress.AddressType; lblLine1.Text = validAddress.Line1; lblLine2.Text = validAddress.Line2; lblLine3.Text = validAddress.Line3; lblLine4.Text = validAddress.Line4; lblCity.Text = validAddress.City; lblRegion.Text = validAddress.Region; lblPostalCode.Text = validAddress.PostalCode; lblCounty.Text = validAddress.County; lblCountry.Text = validAddress.Country; lblCarrierRoute.Text = validAddress.CarrierRoute; lblPOSTNet.Text = validAddress.PostNet; lblFIPSCode.Text = validAddress.FipsCode; }
protected void UseValidAddressButton_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } if (!UpdateAddress(false)) { return; } if (ValidAddresses != null) { Address address = AbleContext.Current.User.PrimaryAddress; int id = AlwaysConvert.ToInt(ValidAddressesList.SelectedValue); if (id == 0) { address.Validated = true; address.Save(); } else { ValidAddress validAddress = (from va in ValidAddresses where va.Id == id select va).SingleOrDefault(); if (validAddress != null) { address.Address1 = validAddress.Address1; address.Address2 = validAddress.Address2; address.City = validAddress.City; address.Province = validAddress.Province; address.PostalCode = validAddress.PostalCode; address.CountryCode = Country.SelectedValue; address.Validated = true; address.Save(); } } } ValidAddresses = null; GoToNextPage(); }
public void createValidAddress() { //Create the authentication header, initialize with credentials, and //create the service proxy. For details, see the API Developer's //Guide and the Reference Library CHM. Authentication_class var_auth = new Authentication_class(); AuthenticationHeader ah = var_auth.getAuthentication_header(); AsmRepository.SetServiceLocationUrl("http://mncsvasm.mskydev1.local/asm/all/servicelocation.svc"); var customersConfiguration = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersConfigurationService>(ah); //Instanstiate and initialize a ValidAddress object. //For a description of each property, see the API Reference Library CHM. ValidAddress validAddressParams = new ValidAddress(); validAddressParams.Active = true; validAddressParams.BigCity = "zzzzzzzz"; validAddressParams.CountryId = 1; validAddressParams.CreateDateTime = System.DateTime.Now; //To populate a CustomField, instantiate a collection, and... validAddressParams.CustomFields = new CustomFieldValueCollection(); //...note that you must use the string value of the custom field's name //to add an instance to the collection. //validAddressParams.CustomFields.Add(new CustomFieldValue ("Number of Active Outlets", "12")); validAddressParams.ExternalAddressId = 2929134; validAddressParams.SmallCity = "qqqqqqqq"; validAddressParams.ProvinceId = 2; //validAddressParams.ExternalReference = "MOR"; //validAddressParams.HouseNumberNumeric = 2982; validAddressParams.ManuallyAdded = false; validAddressParams.PostalCode = "666666"; validAddressParams.Street = "wwwwwww"; validAddressParams.UniqueAddress = false; //Call the method and display the results. ValidAddress validAddress = customersConfiguration.CreateValidAddress(validAddressParams); Console.WriteLine("Valid address created. ID = {0}", validAddress.Id); Console.ReadLine(); }
public HttpResponseMessage GetValidAddressById(int id, String username_ad, String password_ad) { Authentication_class var_auth = new Authentication_class(); AuthenticationHeader authHeader = var_auth.getAuthHeader(username_ad, password_ad); AsmRepository.SetServiceLocationUrl(var_auth.var_service_location_url); var customersConfiguration = AsmRepository.GetServiceProxyCachedOrDefault <ICustomersConfigurationService>(authHeader); int val_addr_id = id; ValidAddress var_valid_addr = customersConfiguration.GetValidAddress(val_addr_id); if (var_valid_addr != null) { return(Request.CreateResponse(HttpStatusCode.OK, var_valid_addr)); } else { var message = string.Format("error"); HttpError err = new HttpError(message); return(Request.CreateResponse(HttpStatusCode.OK, message)); } }
protected void EditSaveButton_Click(object sender, EventArgs e) { string buttonId = ((Button)sender).ID; string provinceName; if (ValidateProvince(out provinceName)) { if (Page.IsValid) { Address address = this.Address; string address1 = StringHelper.StripHtml(Address1.Text.Trim()); string address2 = StringHelper.StripHtml(Address2.Text.Trim()); string city = StringHelper.StripHtml(City.Text.Trim()); string postalCode = StringHelper.StripHtml(PostalCode.Text.Trim()); if (address.Address1 != address1 || address.Address2 != address2 || address.City != city || address.Province != provinceName || address.PostalCode != postalCode) { address.Validated = false; } if (buttonId == "UseValidAddressButton") { int id = AlwaysConvert.ToInt(ValidAddressesList.SelectedValue); address.Validated = true; if (id > 0) { if (ValidAddresses != null && buttonId == "UseValidAddressButton") { ValidAddress validAddress = (from va in ValidAddresses where va.Id == id select va).SingleOrDefault(); if (validAddress != null) { address1 = validAddress.Address1; address2 = validAddress.Address2; city = validAddress.City; provinceName = validAddress.Province; postalCode = validAddress.PostalCode; } } } ValidAddresses = null; } address.FirstName = StringHelper.StripHtml(FirstName.Text); address.LastName = StringHelper.StripHtml(LastName.Text); address.Address1 = address1; address.Address2 = address2; address.Company = StringHelper.StripHtml(Company.Text); address.City = city; address.Province = provinceName; address.PostalCode = postalCode; address.CountryCode = Country.SelectedValue; address.Phone = StringHelper.StripHtml(Phone.Text); address.Fax = StringHelper.StripHtml(Fax.Text); address.Residence = (Residence.SelectedIndex == 0); AbleContext.Current.User.Addresses.Add(address); address.Save(); this.AddressId = address.Id; if (!address.Validated && _addressValidator != null) { AddressValidationResponse avr = _addressValidator.ValidateAddress(address); if (avr != null) { if (!avr.IsValid.HasValue || !avr.IsValid.Value) { ValidAddresses = avr.Addresses; if (ValidAddresses != null) { int index = 0; foreach (ValidAddress validAddress in ValidAddresses) { validAddress.Id = ++index; } ValidAddressesList.DataSource = ValidAddresses; ValidAddressesList.DataBind(); ValidAddressesPanel.Visible = true; ValidAddressesList.Items.Add(new ListItem("Use the address exactly as I entered it", "0")); ValidAddressesList.Items[0].Selected = true; if (ValidAddressesList.Items.Count > 1) { PHAddressFound.Visible = true; PHNoAddress.Visible = false; } else { PHAddressFound.Visible = false; PHNoAddress.Visible = true; } return; } } } } ShowAddressBook(); } } else { Province2Invalid.IsValid = false; UpdateCountry(); } }
public string ValidateAddress(Customer customer, Address inputAddress, out Address ResultAddress) { //If coming from address.aspx do not include Avalara-specific string resources bool stringResourceInResult = inputAddress == null ? true : false; ResultAddress = new Address(); if (!Enabled) { throw new InvalidOperationException("AvalaraInactiveException"); } if (!customer.HasAtLeastOneAddress()) { return(AppLogic.GetString("Avalara.AddressValidate.AtLeastOneAddress", customer.LocaleSetting)); } var addrSvc = new AddressSvc(); addrSvc.Configuration.Url = ServiceURL; addrSvc.Configuration.Security.Account = Account; addrSvc.Configuration.Security.License = License; //set address to validate and ensure ResultAddress returns non-blank address var addrReq = new ValidateRequest(); if (inputAddress == null) { addrReq.Address = LoadAvalaraAddress(customer.PrimaryShippingAddressID); ResultAddress.LoadFromDB(customer.PrimaryShippingAddressID); } else { addrReq.Address = LoadAvalaraAddress(inputAddress.AddressID); ResultAddress = inputAddress; } try { //http://developer.avalara.com/api-docs/api-reference/address-validation ValidateResult addressResult = addrSvc.Validate(addrReq); if (addressResult.Messages.Count > 0) { var errorMessages = new StringBuilder(); foreach (Message message in addressResult.Messages) { if (message.Severity == SeverityLevel.Error) { if (stringResourceInResult) { errorMessages.Append(String.Format(AppLogic.GetString("Avalara.AddressValidate.ValidationFailed", customer.LocaleSetting), message.Details)); } errorMessages.Append(message.Details); } } return(errorMessages.ToString()); } else { if (addressResult.ResultCode == SeverityLevel.Success && addressResult.Addresses.Count == 1) { ValidAddress normalizedAddress = addressResult.Addresses[0]; ResultAddress.Address1 = normalizedAddress.Line1; ResultAddress.Address2 = normalizedAddress.Line2; ResultAddress.City = normalizedAddress.City; ResultAddress.State = normalizedAddress.Region; ResultAddress.Zip = normalizedAddress.PostalCode; ResultAddress.Country = AppLogic.GetCountryNameFromTwoLetterISOCode(normalizedAddress.Country); } return(String.Empty); } } catch (Exception ex) { return(String.Format(AppLogic.GetString("Avalara.AddressValidate.Exception", customer.LocaleSetting), ex.Message)); } }
public void Craw(string url, int curentLevel, int maxLevel) { this.visitedUrls.Add(url); //Download HTML string html = string.Empty; using (var client = new WebClient()) { html = client.DownloadString(url); } //Get all image tags (and their source URL) List<string> imgUrls = this.Parser.ParseImageTags(html); //Download all images from parsed tags Parallel.ForEach(imgUrls, (imgUrl, loopState) => { using (var client = new WebClient()) { var imageName = new GetImageName(imgUrl); var address = new ValidAddress(url, imgUrl); if (!this.downloadedImages.Contains(address.GetAddress)) { try { client.DownloadFile(address.GetAddress, "../../img/" + this.id + "" + imageName.Name); id++; this.downloadedImages.Add(address.GetAddress); } catch (WebException wex) { Console.WriteLine(wex.Message); } } } }); if (curentLevel <= maxLevel) { //Get all anchor tag (and their source URL) List<string> anchorUrls = this.Parser.ParseAnchorTag(html); try { foreach (var anchorUrl in anchorUrls) { //Recursion var checkTag = new ValidAddress(url, anchorUrl); curentLevel++; if (!this.visitedUrls.Contains(checkTag.GetAddress)) ; { this.Craw(checkTag.GetAddress, curentLevel, maxLevel); } } } catch (WebException wex) { Console.WriteLine(wex.Message); } } }
public void Craw(string url, int curentLevel, int maxLevel) { this.visitedUrls.Add(url); //Download HTML string html = string.Empty; using (var client = new WebClient()) { html = client.DownloadString(url); } //Get all image tags (and their source URL) List <string> imgUrls = this.Parser.ParseImageTags(html); //Download all images from parsed tags Parallel.ForEach(imgUrls, (imgUrl, loopState) => { using (var client = new WebClient()) { var imageName = new GetImageName(imgUrl); var address = new ValidAddress(url, imgUrl); if (!this.downloadedImages.Contains(address.GetAddress)) { try { client.DownloadFile(address.GetAddress, "../../img/" + this.id + "" + imageName.Name); id++; this.downloadedImages.Add(address.GetAddress); } catch (WebException wex) { Console.WriteLine(wex.Message); } } } }); if (curentLevel <= maxLevel) { //Get all anchor tag (and their source URL) List <string> anchorUrls = this.Parser.ParseAnchorTag(html); try { foreach (var anchorUrl in anchorUrls) { //Recursion var checkTag = new ValidAddress(url, anchorUrl); curentLevel++; if (!this.visitedUrls.Contains(checkTag.GetAddress)) { ; } { this.Craw(checkTag.GetAddress, curentLevel, maxLevel); } } } catch (WebException wex) { Console.WriteLine(wex.Message); } } }