private AddressInfo FillFromReader(SqlDataReader rdr) { var address = new AddressInfo(); address.Id = (int)rdr["Id"]; if (rdr["AddressLine1"] != DBNull.Value) { address.Address1 = (string)rdr["AddressLine1"]; } if (rdr["AddressLine2"] != DBNull.Value) { address.Address2 = (string)rdr["AddressLine2"]; } if (rdr["AddressLine3"] != DBNull.Value) { address.Address3 = (string)rdr["AddressLine3"]; } if (rdr["City"] != DBNull.Value) { address.City = (string)rdr["City"]; } if (rdr["ProvinceState"] != DBNull.Value) { address.State = (string)rdr["ProvinceState"]; } if (rdr["Country"] != DBNull.Value) { address.Country = (string)rdr["Country"]; } if (rdr["PostalZipCode"] != DBNull.Value) { address.ZipCode = (string)rdr["PostalZipCode"]; } address.Longitude = (decimal)rdr["Longitude"]; address.Latitude = (decimal)rdr["Latitude"]; return address; }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (customerObj == null) { return; } if (!ECommerceContext.IsUserAuthorizedToModifyCustomer()) { RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); } if (customerId != 0) { string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine") .NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity") .NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode") .NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result; // Check country presence if (errorMessage == "" && (ucCountrySelector.CountryID <= 0)) { errorMessage = GetString("countryselector.selectedcountryerr"); } if (errorMessage == "") { // Get object AddressInfo addressObj = AddressInfoProvider.GetAddressInfo(addressId); if (addressObj == null) { addressObj = new AddressInfo(); } addressObj.AddressIsBilling = chkAddressIsBilling.Checked; addressObj.AddressIsShipping = chkAddressIsShipping.Checked; addressObj.AddressZip = txtAddressZip.Text.Trim(); addressObj.AddressPhone = txtAddressDeliveryPhone.Text.Trim(); addressObj.AddressPersonalName = txtPersonalName.Text.Trim(); addressObj.AddressLine1 = txtAddressLine1.Text.Trim(); addressObj.AddressEnabled = chkAddressEnabled.Checked; addressObj.AddressLine2 = txtAddressLine2.Text.Trim(); addressObj.AddressCity = txtAddressCity.Text.Trim(); addressObj.AddressCountryID = ucCountrySelector.CountryID; addressObj.AddressStateID = ucCountrySelector.StateID; addressObj.AddressIsCompany = chkAddressIsCompany.Checked; addressObj.AddressName = AddressInfoProvider.GetAddressName(addressObj); addressObj.AddressCustomerID = customerId; AddressInfoProvider.SetAddressInfo(addressObj); URLHelper.Redirect("Customer_Edit_Address_Edit.aspx?customerId=" + customerId + "&addressId=" + Convert.ToString(addressObj.AddressID) + "&saved=1"); } else { lblError.Visible = true; lblError.Text = errorMessage; } } }
public CreditCardAuthorizationRequest( string firstName, string lastName, CreditCardInfo creditCardInfo, AddressInfo addressInfo) { FirstName = firstName; LastName = lastName; CreditCardInfo = creditCardInfo; AddressInfo = addressInfo; }
public ActionResult Update(AddressInfo m, string noCheck) { if (noCheck.HasValue() == false) m.ValidateAddress(ModelState); if (!ModelState.IsValid) return View("Edit", m); if (m.Error.HasValue()) { ModelState.Clear(); return View("Edit", m); } m.UpdateAddress(ModelState); return View("Saved", m); }
public virtual int AddAddress(AddressInfo address) { int id = 0; using (SqlDataReader rdr = SqlHelper.ExecuteReader(_connString, ADD_ADDRESS, address.Address1, address.Address2, address.Address3, address.City, address.State, address.Country, address.ZipCode, address.Longitude, address.Latitude)) { if (rdr.Read()) id = Convert.ToInt32(rdr.GetDecimal(0)); } address.Id = id; return id; }
public int AddAddress(AddressInfo address) { // Validate input if (address == null) { throw new ArgumentNullException("address"); } if (address.Latitude == 0 && address.Longitude == 0) { var postalCode = GeoCodePostalCode(address.ZipCode); address.Latitude = postalCode.Latitude; address.Longitude = postalCode.Longitude; } var id = _addressDal.AddAddress(address); return id; }
public static TestInfo CreateJunkData() { try { address = new AddressInfo() { AddressI="Address1",AddressII="Address II",Email="*****@*****.**",MobilePhone="12121212",Telephone="123123123",ZipOrPostalCode="123123",FK_TestInfoID=null}; office = new OfficeUse() { AC=true,AdministratorInitials="AC",DateofPayment=DateTime.Now,GT=true,IDChecked=true,ReceiptNumber="guid",Scheme="Scheme",TestDate=DateTime.Now}; student = new StudentInfo() { AddressInfo=address, ApplyingCountry = "AC", CountryNationalCode = "NC01", DateOfBirth = DateTime.Now,EducationLevel="EL01",EnglishLearningLocation="UK",EnglishLearningPeriod="5",FirstLanguageCode="01",FirstName="Madhu",Gender="Male",LastName="LNAME",OccupationLevel="01",OccupationSector="02",PermanentDisability="No",Title="Title" }; tinfo = new TestInfo() { OfficeUse=office, StudentInfo=student, TestReason = "Reason", TestModule = "Module", TestCityLocation = "UAE", Status = 0, ResultCopyTo = true, CreatedDate = DateTime.Now, ModifiedDateTime = DateTime.Now, PreferredTestDate = DateTime.Now, ReceiptNumber = "RECEIPTMENT", SecondaryTestDate = DateTime.Now }; add1 = new AddressInfo() { AddressI = "Address1", AddressII = "Address II", Email = "*****@*****.**", MobilePhone = "12121212", Telephone = "123123123", ZipOrPostalCode = "123123",TestInfo=tinfo }; add2 = new AddressInfo() { AddressI = "Address1", AddressII = "Address II", Email = "*****@*****.**", MobilePhone = "12121212", Telephone = "123123123", ZipOrPostalCode = "123123", TestInfo = tinfo }; return tinfo; } catch (Exception ex) { throw ex; } }
public void ResequenceRouteDestinations(DataObjectRoute route) { if (route.Addresses == null && route.Addresses.Length < 3) { Console.WriteLine("ResequenceRouteDestinations error {0}", "route.Addresses == null && route.Addresses.Length < 3. Number of addresses should be >= 3"); return; } // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // Switch 2 addresses after departure address: AddressesOrderInfo addressesOrderInfo = new AddressesOrderInfo(); addressesOrderInfo.RouteId = route.RouteID; addressesOrderInfo.Addresses = new AddressInfo[0]; for (int i = 0; i < route.Addresses.Length; i++) { Address address = route.Addresses[i]; AddressInfo addressInfo = new AddressInfo(); addressInfo.DestinationId = address.RouteDestinationId.Value; addressInfo.SequenceNo = i; if (i == 1) addressInfo.SequenceNo = 2; else if (i == 2) addressInfo.SequenceNo = 1; addressInfo.IsDepot = (addressInfo.SequenceNo == 0); List<AddressInfo> addressesList = new List<AddressInfo>(addressesOrderInfo.Addresses); addressesList.Add(addressInfo); addressesOrderInfo.Addresses = addressesList.ToArray(); } // Run the query string errorString1 = ""; DataObjectRoute route1 = route4Me.GetJsonObjectFromAPI<DataObjectRoute>(addressesOrderInfo, R4MEInfrastructureSettings.RouteHost, HttpMethodType.Put, out errorString1); // Output the result PrintExampleOptimizationResult("ResequenceRouteDestinations, switch 2 addresses.", route1, errorString1); Console.WriteLine(""); }
public ViewResult Address(AddressInfo model, string previous, string next) { if (previous != null) { var cacheInfo = GetUserInfo(); return View("~/Views/Wizards/CreateUser/Customer.cshtml", cacheInfo.CustomerInfo); } if (next != null) if (ModelState.IsValid) { var cacheInfo = GetUserInfo(); cacheInfo.AddressInfo = model; return View("~/Views/Wizards/CreateUser/Password.cshtml", cacheInfo.PasswordInfo); } return View("~/Views/Wizards/CreateUser/Address.cshtml"); }
public ActionResult Address(AddressInfo model, string previous, string finish) { if (previous != null) { var cacheInfo = GetUserInfo(); return View("~/Views/Wizards/EditUserInfo/Customer.cshtml", cacheInfo.CustomerInfo); } if (finish != null) if (ModelState.IsValid) { var cacheInfo = GetUserInfo(); cacheInfo.AddressInfo = model; TempData["EditedCustomer"] = cacheInfo; SessionClear(); return RedirectToAction("FinishEditPersonalInformation", "Account"); } return View("~/Views/Wizards/EditUserInfo/Address.cshtml"); }
protected void changeBtn_ServerClick(object sender, EventArgs e) { AddressInfo address = new AddressInfo(); ; address.AddressName = UserNameTextBox.Text; address.Province = ProvinceList.SelectedValue; address.City = CityList.SelectedValue; address.Telephone = TelephoneTextBox.Text; address.Post = PostTextBox.Text; address.Address = AddressTextBox.Text; if (CityList.SelectedValue == "-1") { successTxt.Text = "请选择省/市"; } else { if (Address.GetAddressByID().City == "-1") { Address.UpdateAddress(address); } else { bool sened1 = SendArea.GetSendAreaByID(int.Parse(Address.GetAddressByID().City)).IsSended; Address.UpdateAddress(address); bool sended2 = SendArea.GetSendAreaByID(int.Parse(Address.GetAddressByID().City)).IsSended; if ((sened1 == true) && sended2 == false) { Address.UpdateAddressSend(1); successTxt.Text = "修改成功"; dataBind(); } else { successTxt.Text = "修改成功"; dataBind(); } } } }
protected void LinkButton1_Click(object sender, EventArgs e) { AddressInfo address = new AddressInfo(); ; address.AddressName = userNameTxt.Text; address.Province = ProvinceList.SelectedValue; address.Telephone = telephoneTxt.Text; address.Post = postTxt.Text; address.Address = addressTxt.Text; address.City = CityList.SelectedValue; if (CityList.SelectedValue == "-1") { Label1.Text = "请选择省/市"; } else { if (Address.GetAddressByID().City == "-1") { Address.UpdateAddress(address); } else { bool sened1 = SendArea.GetSendAreaByID(int.Parse(Address.GetAddressByID().City)).IsSended; Address.UpdateAddress(address); bool sended2 = SendArea.GetSendAreaByID(int.Parse(Address.GetAddressByID().City)).IsSended; if ((sened1 == true) && sended2 == false) { Address.UpdateAddressSend(1); Address.UpdateAddressPay(2); Response.Redirect(ViewState["url"].ToString()); } else { Response.Redirect(ViewState["url"].ToString()); } } } }
public ActionResult AddressEdit(int id, string type) { var m = AddressInfo.GetAddressInfo(id, type); return(View(m)); }
public DataResult GetData(StringDictionary attributeDictionary, IDataReader reader, string catalog, RunType runType) { var customer = new Customer { SourceId = reader["CustomerID"].ToString(), CustomerID = reader["CustomerID"].ToString(), LoyaltyNumber = reader["LoyaltyNumber"] == DBNull.Value ? null : reader["LoyaltyNumber"].ToString(), MembershipID = reader["MembershipID"] == DBNull.Value ? null : reader["MembershipID"].ToString(), CreatedOn = Convert.ToDateTime(reader["CreatedOn"]).ToUniversalTime().ToString(DATE_FORMAT) }; var addressID = reader["AddressID"] == DBNull.Value ? null : reader["AddressID"].ToString(); var addrNickName = (reader["AddressNickname"] as string); var address = new AddressInfo { AddressID = addressID, AddressNickname = addrNickName, AddressIdOrNickname = (string.IsNullOrEmpty(addrNickName) ? addressID : addrNickName).LimitLength(256), AddressLine1 = (reader["AddressLine1"] as string).LimitLength(70), AddressLine2 = (reader["AddressLine2"] as string).LimitLength(70), AddressType = reader["AddressType"] == DBNull.Value ? null : (string)reader["AddressType"], City = (reader["City"] as string).LimitLength(35), Country = (reader["Country"] as string).LimitLength(40), DayPhone = (reader["DayPhone"] as string).LimitLength(40), EmailAddress = ((reader["EmailAddress"] as string) ?? string.Empty).LimitLength(150), FirstName = ((reader["FirstName"] as string) ?? string.Empty).LimitLength(64), LastName = ((reader["LastName"] as string) ?? string.Empty).LimitLength(64), MiddleInitial = ((reader["MiddleInitial"] as string) ?? string.Empty).LimitLength(40), SMSPhoneNum = ((reader["SMSPhoneNum"] as string) ?? string.Empty).LimitLength(40), EveningPhone = ((reader["EveningPhone"] as string) ?? string.Empty).LimitLength(40), PreferredShipAddress = (reader["DefaultAddress"] == DBNull.Value ? false : (bool)reader["DefaultAddress"]) ? "Y" : "N", ProvinceCode = (reader["ProvinceCode"] as string).LimitLength(35), PostalZip = (reader["PostalZip"] as string).LimitLength(35), Title = ((reader["Title"] as string) ?? string.Empty).LimitLength(10) }; customer.AddressInfo = address; if (address.AddressType?.ToUpper() == "BILLING") { customer.Consumer = new Consumer { BillingPersonInfo = address }; customer.CustomerContactList.CustomerContact = new CustomerContact { CustomerContactID = customer.CustomerID, EmailAddress = address.EmailAddress, FirstName = address.FirstName, LastName = address.LastName, MiddleInitial = address.MiddleInitial, SMSPhoneNum = address.SMSPhoneNum, PreferredShipAddress = address.PreferredShipAddress, Title = address.Title, AddressType = address.AddressType }; } else { customer.CustomerContactList.CustomerContact = new CustomerContact(address, customer.CustomerID); } return(new DataResult { ExportData = customer }); }
/// <summary> /// Updates contact's address. /// </summary> /// <param name="addressInfo">Billing address</param> private void MapContactAddress(AddressInfo addressInfo) { try { if ((addressInfo == null) || !SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOnlineMarketing")) { return; } GeneralizedInfo contactInfo = BaseAbstractInfoProvider.GetInfoById(PredefinedObjectType.CONTACT, ContactID); // Check that current contact has not yet filled in address if ((contactInfo != null) && String.IsNullOrEmpty(ValidationHelper.GetString(contactInfo.GetValue("ContactAddress1"), ""))) { Func<int, int?> getIntIfValid = i => i > 0 ? i : (int?)null; contactInfo.SetValue("ContactAddress1", addressInfo.AddressLine1); contactInfo.SetValue("ContactAddress2", addressInfo.AddressLine2); contactInfo.SetValue("ContactCity", addressInfo.AddressCity); contactInfo.SetValue("ContactZIP", addressInfo.AddressZip); contactInfo.SetValue("ContactMobilePhone", addressInfo.AddressPhone); contactInfo.SetValue("ContactCountryID", getIntIfValid(addressInfo.AddressCountryID)); contactInfo.SetValue("ContactStateID", getIntIfValid(addressInfo.AddressStateID)); contactInfo.SetObject(); } } catch (Exception ex) { // Exception could happen when max length of contact parameters is exceeded EventLogProvider.LogException("ShoppingCartOrderAddresses.MapContactAddress", "UPDATECONTACT", ex); } }
public AddressInfoSaveResult AddressInfoSave(string SPID, string CustID, AddressInfo Address, string ExtendField) { AddressInfoSaveResult Result = new AddressInfoSaveResult(); Result.Result = ErrorDefinition.BT_IError_Result_UnknowError_Code; Result.ErrorDescription = ""; Result.CustID = CustID; Result.ExtendField = ""; try { #region 数据合法性判断 if (CommonUtility.IsEmpty(SPID)) { Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code; Result.ErrorDescription = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + "(不能为空)"; return Result; } if (SPID.Length != ConstDefinition.Length_SPID) { Result.Result = ErrorDefinition.BT_IError_Result_InValidSPID_Code; Result.ErrorDescription = ErrorDefinition.BT_IError_Result_InValidSPID_Msg + "(长度有误)"; return Result; } //IP是否允许访问 Result.Result = CommonBizRules.CheckIPLimit(SPID, HttpContext.Current.Request.UserHostAddress, this.Context, out Result.ErrorDescription); if (Result.Result != 0) { return Result; } //接口访问权限判断 Result.Result = CommonBizRules.CheckInterfaceLimit(SPID, "AddressInfoLoad", this.Context, out Result.ErrorDescription); if (Result.Result != 0) { return Result; } if (CommonUtility.IsEmpty(CustID)) { Result.Result = ErrorDefinition.BT_IError_Result_InValidCustID_Code; Result.ErrorDescription = ErrorDefinition.BT_IError_Result_InValidCustID_Msg + "(不能为空)"; return Result; } if (CustID.Length > ConstDefinition.Length_CustID) { Result.Result = ErrorDefinition.BT_IError_Result_InValidCustID_Code; Result.ErrorDescription = ErrorDefinition.BT_IError_Result_InValidCustID_Msg + "(长度有误)"; } if (Address == null) { Result.Result = ErrorDefinition.BT_IError_Result_InValidParameter_Code; Result.ErrorDescription = ErrorDefinition.BT_IError_Result_InValidParameter_Msg + "(Address为空)"; return Result; } #endregion //数据库操作 Result.Result = AddressInfoBO.AddressInfoSave(SPID, CustID, Address, out Result.ErrorDescription); } catch (Exception e) { Result.Result = ErrorDefinition.IError_Result_System_UnknowError_Code; Result.ErrorDescription = ErrorDefinition.IError_Result_System_UnknowError_Msg + e.Message; } finally { try { #region 文本日志 StringBuilder msg = new StringBuilder(); msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n\r\n"); msg.Append("修改客户常用地址信息接口" + DateTime.Now.ToString("u") + "\r\n"); msg.Append(";SPID - " + SPID); msg.Append(";CustID - " + CustID); if (Address != null) { msg.Append(";AddressInfo: \r\n"); msg.Append(" :AddressID - " + Address.AddressID); msg.Append(" :AreaCode - " + Address.AreaCode); msg.Append(" :Address - " + Address.Address); msg.Append(" :Zipcode - " + Address.Zipcode); msg.Append(" :Type - " + Address.Type); msg.Append(" :OtherType - " + Address.OtherType); msg.Append(" :RelationPerson - " + Address.RelationPerson); msg.Append(" :Mobile - " + Address.Mobile); msg.Append(" :FixedPhone - " + Address.FixedPhone + "\r\n"); } msg.Append(";ExtendField - " + ExtendField + "\r\n"); msg.Append("处理结果 - " + Result.Result); msg.Append("; 错误描述 - " + Result.ErrorDescription); msg.Append("; CustID - " + Result.CustID); msg.Append("; ExtendField - " + Result.ExtendField + "\r\n"); msg.Append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r\n"); BTUCenterInterfaceLog.CenterForBizTourLog("AddressInfoLoad", msg); #endregion #region 数据库日志 StringBuilder inParam = new StringBuilder(); inParam.AppendFormat("SPID:{0},CustID:{1}", SPID, CustID); if (Address != null) { inParam.Append(",AddressInfo:"); inParam.Append("{"); inParam.AppendFormat("AddreassID:{0};AreaCode:{1},Address:{2},Zipcode:{3},Type:{4},OtherType:{5},RelationPerson:{6},Mobile:{7},FixedPhone:{8}", Address.AddressID, Address.AreaCode, Address.Address, Address.Zipcode, Address.Type, Address.OtherType, Address.RelationPerson, Address.Mobile, Address.FixedPhone); inParam.Append("}"); } inParam.Append(",ExtendField:" + ExtendField + "\r\n"); StringBuilder outParam = new StringBuilder(); outParam.AppendFormat("处理结果:{0},错误描述:{1},CustID:{2},ExtendField:{3}", Result.Result, Result.ErrorDescription, Result.CustID, Result.ExtendField); CommonBizRules.WriteCallInterfaceLog_DB(HttpContext.Current.Request.UserHostAddress, SPID, "AddressInfoSave", inParam.ToString(), outParam.ToString(), Result.Result, Result.ErrorDescription); #endregion } catch { } } return Result; }
// Profile setters // Update account info private static void SetAccountInfo(int uniqueID, AddressInfo addressInfo) { dal.SetAccountInfo(uniqueID, addressInfo); }
public ActionResult GetAddressInfo(string identifier, string companyType) { AddressInfo addressInfo = new AddressInfo(); try { var service = GeneralHelper.GetPublicOrderService(this.HttpContext.ApplicationInstance.Context); addressInfo = service.GetAddressInfoOrder(identifier, EntityType.Company, ResellerHelper.GetResellerId()); } catch (Exception ex) { OrderPageLogger.LogOrderPageException(ex); } return Json(addressInfo); }
private void BindBillingAddress(AddressInfo billingAddress) { string modulePath = this.AppRelativeTemplateSourceDirectory; hst = AppLocalized.getLocale(modulePath); StringBuilder billingAdr = new StringBuilder(); billingAdr.Append("<table><tr>"); billingAdr.Append("<td>"+getLocale("Customer Name:")+"</td>"); billingAdr.Append("<td>" + billingAddress.FirstName + " " + billingAddress.LastName + "</td></tr><tr>"); billingAdr.Append("<td>"+getLocale("Address:")+"</td>"); billingAdr.Append("<td>" + billingAddress.Address1 + "</td></tr><tr>"); if (!string.IsNullOrEmpty(billingAddress.Address2)) { billingAdr.Append("<td>"+getLocale("Address2:")+"</td>"); billingAdr.Append("<td>" + billingAddress.Address2 + "</td></tr><tr>"); } billingAdr.Append("<td>"+getLocale("Country:")+"</td>"); billingAdr.Append("<td>" + billingAddress.Country + "</td></tr><tr>"); billingAdr.Append("<td>"+getLocale("City:")+"</td>"); billingAdr.Append("<td>" + billingAddress.City + "</td></tr><tr>"); billingAdr.Append("<td>"+getLocale("State:")+"</td>"); billingAdr.Append("<td>" + billingAddress.State + "</td></tr><tr>"); billingAdr.Append("<td>"+getLocale("ZipCode:")+"</td>"); billingAdr.Append("<td>" + billingAddress.Zip + "</td></tr><tr>"); billingAdr.Append("<td>"+getLocale("Email Address:")+"</td>"); billingAdr.Append("<td>" + billingAddress.Email + "</td></tr><tr>"); billingAdr.Append("<td>"+getLocale("Phone No:")+"</td>"); billingAdr.Append("<td>" + billingAddress.Phone + "</td></tr>"); billingAdr.Append("</table>"); ltBillingAddress.Text = billingAdr.ToString(); Session["sl_frAddress"] = billingAddress; }
// Tests if the domain name can be resolved without throwing any exceptions. This gets // around the very annoying Dns.GetHostEntry(). private static bool CanResolve(Uri server) { bool result = false; SafeFreeAddrInfo root = null; try { WSAData wsaData; short wsaVersion = (2 << 8) | 2; //version 2.2, good since Windows 95 OSR2! WSAStartup(wsaVersion, out wsaData); AddressInfo hints = new AddressInfo(); int errorCode = getaddrinfo(server.Host, server.Port.ToString(), ref hints, out root); result = (errorCode == 0); //0 means success } catch { if (root != null) root.Close(); } finally { WSACleanup(); } return result; }
/// <summary> /// Gets and updates address. Called when the "Get and update address" button is pressed. /// Expects the CreateAddress method to be run first. /// </summary> private bool GetAndUpdateAddress() { // Prepare the parameters string where = "AddressName LIKE 'My New%'"; // Get the address DataSet addresses = AddressInfoProvider.GetAddresses(where, null); if (!DataHelper.DataSourceIsEmpty(addresses)) { // Create object from DataRow AddressInfo updateAddress = new AddressInfo(addresses.Tables[0].Rows[0]); // Update the properties updateAddress.AddressName = updateAddress.AddressName.ToLowerCSafe(); // Update the address AddressInfoProvider.SetAddressInfo(updateAddress); return true; } return false; }
/// <summary> /// A method to store the billing address information /// </summary> public void StoreBillingAddress(AddressInfo billingAddress) { HttpContext.Current.Session[BILLING_KEY] = billingAddress; }
/// <summary> /// A method to control the flow when picking an alternate shipping address /// </summary> public void SetAlternateShippingAddress(AddressInfo shippingAddress) { HttpContext.Current.Session[SHIPPING_KEY] = shippingAddress; }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns>Task of ApiResponse</returns> public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiAddressPostAsyncWithHttpInfo(AddressInfo body = null) { var localVarPath = "/api/Address"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiAddressPost", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), null)); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns>Task of void</returns> public async System.Threading.Tasks.Task ApiAddressPostAsync(AddressInfo body = null) { await ApiAddressPostAsyncWithHttpInfo(body); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns></returns> public void ApiAddressPost(AddressInfo body = null) { ApiAddressPostWithHttpInfo(body); }
public void TestTryAttachBuffer() { const CpuAddress CpuAddress = 0x20000; const DspAddress DspAddress = CpuAddress; // TODO: DSP LLE const ulong CpuSize = 0x1000; const int MemoryPoolStateArraySize = 0x10; const CpuAddress CpuAddressRegionEnding = CpuAddress * MemoryPoolStateArraySize; MemoryPoolState[] memoryPoolStateArray = new MemoryPoolState[MemoryPoolStateArraySize]; for (int i = 0; i < memoryPoolStateArray.Length; i++) { memoryPoolStateArray[i] = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu); memoryPoolStateArray[i].SetCpuAddress(CpuAddress + (ulong)i * CpuSize, CpuSize); } ErrorInfo errorInfo; AddressInfo addressInfo = AddressInfo.Create(); PoolMapper poolMapper = new PoolMapper(DummyProcessHandle, true); Assert.IsTrue(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, 0, 0)); Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode); Assert.AreEqual(0, errorInfo.ExtraErrorInfo); Assert.AreEqual(0, addressInfo.ForceMappedDspAddress); Assert.IsTrue(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddress, CpuSize)); Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode); Assert.AreEqual(CpuAddress, errorInfo.ExtraErrorInfo); Assert.AreEqual(DspAddress, addressInfo.ForceMappedDspAddress); poolMapper = new PoolMapper(DummyProcessHandle, false); Assert.IsFalse(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, 0, 0)); addressInfo.ForceMappedDspAddress = 0; Assert.IsFalse(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddress, CpuSize)); Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode); Assert.AreEqual(CpuAddress, errorInfo.ExtraErrorInfo); Assert.AreEqual(0, addressInfo.ForceMappedDspAddress); poolMapper = new PoolMapper(DummyProcessHandle, memoryPoolStateArray.AsMemory(), false); Assert.IsFalse(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddressRegionEnding, CpuSize)); Assert.AreEqual(ResultCode.InvalidAddressInfo, errorInfo.ErrorCode); Assert.AreEqual(CpuAddressRegionEnding, errorInfo.ExtraErrorInfo); Assert.AreEqual(0, addressInfo.ForceMappedDspAddress); Assert.IsFalse(addressInfo.HasMemoryPoolState); Assert.IsTrue(poolMapper.TryAttachBuffer(out errorInfo, ref addressInfo, CpuAddress, CpuSize)); Assert.AreEqual(ResultCode.Success, errorInfo.ErrorCode); Assert.AreEqual(0, errorInfo.ExtraErrorInfo); Assert.AreEqual(0, addressInfo.ForceMappedDspAddress); Assert.IsTrue(addressInfo.HasMemoryPoolState); }
public void Prepare(long firstByteIndex, long lastByteIndex) { int visibleByteCount = (int)(lastByteIndex - firstByteIndex + 1); if (_highlightBreakpoints) { Breakpoint[] breakpoints = BreakpointManager.Breakpoints.ToArray(); _breakpointTypes = new BreakpointTypeFlags[visibleByteCount]; for (int i = 0; i < visibleByteCount; i++) { int byteIndex = i + (int)firstByteIndex; foreach (Breakpoint bp in breakpoints) { if (bp.Enabled && bp.Matches((uint)byteIndex, _memoryType, null)) { _breakpointTypes[i] = bp.BreakOnExec ? BreakpointTypeFlags.Execute : (bp.BreakOnWrite ? BreakpointTypeFlags.Write : BreakpointTypeFlags.Read); break; } } } } else { _breakpointTypes = null; } _readStamps = DebugApi.GetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeStamps = DebugApi.GetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _execStamps = DebugApi.GetMemoryAccessStamps((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.ExecOpCode); _readCounts = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Read); _writeCounts = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.Write); _execCounts = DebugApi.GetMemoryAccessCounts((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType, MemoryOperationType.ExecOpCode); _cdlData = null; if (_highlightDataBytes || _highlightCodeBytes) { switch (_memoryType) { case SnesMemoryType.CpuMemory: case SnesMemoryType.PrgRom: _cdlData = DebugApi.GetCdlData((UInt32)firstByteIndex, (UInt32)visibleByteCount, _memoryType); break; } } _hasLabel = new bool[visibleByteCount]; if (_highlightLabelledBytes) { if (_memoryType <= SnesMemoryType.SpcMemory) { AddressInfo addr = new AddressInfo(); addr.Type = _memoryType; for (long i = 0; i < _hasLabel.Length; i++) { addr.Address = (int)(firstByteIndex + i); _hasLabel[i] = !string.IsNullOrWhiteSpace(LabelManager.GetLabel(addr)?.Label); } } else if (_memoryType == SnesMemoryType.PrgRom || _memoryType == SnesMemoryType.WorkRam || _memoryType == SnesMemoryType.SaveRam) { for (long i = 0; i < _hasLabel.Length; i++) { _hasLabel[i] = !string.IsNullOrWhiteSpace(LabelManager.GetLabel((uint)(firstByteIndex + i), _memoryType)?.Label); } } } _state = DebugApi.GetState(); }
/// <summary> /// Creates order. Called when the "Create order" button is pressed. /// Expects the CreateRegisteredCustomer, CreateAddress and CreateOrderStatus methods to be run first. /// </summary> private bool CreateOrder() { // Prepare the parameters string whereCustomer = "CustomerLastName LIKE N'My New Registered%'"; string whereAddress = "AddressName LIKE 'My New%'"; CustomerInfo customer = null; AddressInfo address = null; // Get the customer DataSet customers = CustomerInfoProvider.GetCustomers(whereCustomer, null); if (!DataHelper.DataSourceIsEmpty(customers)) { // Create object from DataRow customer = new CustomerInfo(customers.Tables[0].Rows[0]); } // Get the address DataSet addresses = AddressInfoProvider.GetAddresses(whereAddress, null); if (!DataHelper.DataSourceIsEmpty(addresses)) { // Create object from DataRow address = new AddressInfo(addresses.Tables[0].Rows[0]); } // Get the order status OrderStatusInfo orderStatus = OrderStatusInfoProvider.GetOrderStatusInfo("MyNewStatus", CMSContext.CurrentSiteName); // Get the currency CurrencyInfo currency = CurrencyInfoProvider.GetCurrencyInfo("MyNewCurrency", CMSContext.CurrentSiteName); if ((customer != null) && (address != null) && (orderStatus != null) && (currency != null)) { // Create new order object OrderInfo newOrder = new OrderInfo(); // Set the properties newOrder.OrderInvoiceNumber = "1"; newOrder.OrderBillingAddressID = address.AddressID; newOrder.OrderShippingAddressID = address.AddressID; newOrder.OrderTotalPrice = 200; newOrder.OrderTotalTax = 30; newOrder.OrderDate = DateTime.Now; newOrder.OrderStatusID = orderStatus.StatusID; newOrder.OrderCustomerID = customer.CustomerID; newOrder.OrderSiteID = CMSContext.CurrentSiteID; newOrder.OrderCurrencyID = currency.CurrencyID; // Create the order OrderInfoProvider.SetOrderInfo(newOrder); return true; } return false; }
public void ReadWrite(BitcoinStream stream) { lock (cs) { Check(); if (!stream.Serializing) { Clear(); } stream.ReadWrite(ref nVersion); stream.ReadWrite(ref nKeySize); if (!stream.Serializing && nKeySize != 32) { throw new FormatException("Incorrect keysize in addrman deserialization"); } stream.ReadWrite(ref nKey); stream.ReadWrite(ref nNew); stream.ReadWrite(ref nTried); int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30); stream.ReadWrite(ref nUBuckets); if (nVersion != 0) { nUBuckets ^= (1 << 30); } if (!stream.Serializing) { // Deserialize entries from the new table. for (int n = 0; n < nNew; n++) { AddressInfo info = new AddressInfo(); info.ReadWrite(stream); mapInfo.Add(n, info); mapAddr[info.Address.Endpoint.Address] = n; info.nRandomPos = vRandom.Count; vRandom.Add(n); if (nVersion != 1 || nUBuckets != ADDRMAN_NEW_BUCKET_COUNT) { // In case the new table data cannot be used (nVersion unknown, or bucket count wrong), // immediately try to give them a reference based on their primary source address. int nUBucket = info.GetNewBucket(nKey); int nUBucketPos = info.GetBucketPosition(nKey, true, nUBucket); if (vvNew[nUBucket, nUBucketPos] == -1) { vvNew[nUBucket, nUBucketPos] = n; info.nRefCount++; } } } nIdCount = nNew; // Deserialize entries from the tried table. int nLost = 0; for (int n = 0; n < nTried; n++) { AddressInfo info = new AddressInfo(); info.ReadWrite(stream); int nKBucket = info.GetTriedBucket(nKey); int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket); if (vvTried[nKBucket, nKBucketPos] == -1) { info.nRandomPos = vRandom.Count; info.fInTried = true; vRandom.Add(nIdCount); mapInfo[nIdCount] = info; mapAddr[info.Address.Endpoint.Address] = nIdCount; vvTried[nKBucket, nKBucketPos] = nIdCount; nIdCount++; } else { nLost++; } } nTried -= nLost; // Deserialize positions in the new table (if possible). for (int bucket = 0; bucket < nUBuckets; bucket++) { int nSize = 0; stream.ReadWrite(ref nSize); for (int n = 0; n < nSize; n++) { int nIndex = 0; stream.ReadWrite(ref nIndex); if (nIndex >= 0 && nIndex < nNew) { AddressInfo info = mapInfo[nIndex]; int nUBucketPos = info.GetBucketPosition(nKey, true, bucket); if (nVersion == 1 && nUBuckets == ADDRMAN_NEW_BUCKET_COUNT && vvNew[bucket, nUBucketPos] == -1 && info.nRefCount < ADDRMAN_NEW_BUCKETS_PER_ADDRESS) { info.nRefCount++; vvNew[bucket, nUBucketPos] = nIndex; } } } } // Prune new entries with refcount 0 (as a result of collisions). int nLostUnk = 0; foreach (var kv in mapInfo.ToList()) { if (kv.Value.fInTried == false && kv.Value.nRefCount == 0) { Delete(kv.Key); nLostUnk++; } } } else { Dictionary <int, int> mapUnkIds = new Dictionary <int, int>(); int nIds = 0; foreach (var kv in mapInfo) { mapUnkIds[kv.Key] = nIds; AddressInfo info = kv.Value; if (info.nRefCount != 0) { assert(nIds != nNew); // this means nNew was wrong, oh ow info.ReadWrite(stream); nIds++; } } nIds = 0; foreach (var kv in mapInfo) { AddressInfo info = kv.Value; if (info.fInTried) { assert(nIds != nTried); // this means nTried was wrong, oh ow info.ReadWrite(stream); nIds++; } } for (int bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) { int nSize = 0; for (int i = 0; i < ADDRMAN_BUCKET_SIZE; i++) { if (vvNew[bucket, i] != -1) { nSize++; } } stream.ReadWrite(ref nSize); for (int i = 0; i < ADDRMAN_BUCKET_SIZE; i++) { if (vvNew[bucket, i] != -1) { int nIndex = mapUnkIds[vvNew[bucket, i]]; stream.ReadWrite(ref nIndex); } } } } Check(); } }
/// <summary> /// On btnOK click, save edited or new created address. /// </summary> protected void btnOK_OnClick(object sender, EventArgs e) { if (mCustomerId != 0) { // Check field emptiness string errorMessage = new Validator().NotEmpty(txtAddressLine1.Text, "Customer_Edit_Address_Edit.rqvLine").NotEmpty(txtAddressCity.Text, "Customer_Edit_Address_Edit.rqvCity").NotEmpty(txtAddressZip.Text, "Customer_Edit_Address_Edit.rqvZipCode").NotEmpty(txtPersonalName.Text, "Customer_Edit_Address_Edit.rqvPersonalName").Result; // Check country presence if ((errorMessage == "") && (ucCountrySelector.CountryID <= 0)) { errorMessage = GetString("countryselector.selectedcountryerr"); } if (errorMessage == "") { AddressInfo ai = null; // Create new addressinfo or get the existing one if (AddressId == 0) { ai = new AddressInfo(); ai.AddressEnabled = true; ai.AddressIsBilling = true; ai.AddressIsShipping = true; ai.AddressIsCompany = true; ai.AddressCustomerID = mCustomerId; } else { ai = AddressInfoProvider.GetAddressInfo(AddressId); } if (ai != null) { ai.AddressPersonalName = txtPersonalName.Text; ai.AddressLine1 = txtAddressLine1.Text; ai.AddressLine2 = txtAddressLine2.Text; ai.AddressCity = txtAddressCity.Text; ai.AddressZip = txtAddressZip.Text; ai.AddressCountryID = ucCountrySelector.CountryID; ai.AddressStateID = ucCountrySelector.StateID; ai.AddressPhone = txtAddressDeliveryPhone.Text; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save addressinfo AddressInfoProvider.SetAddressInfo(ai); AddressId = ai.AddressID; lblInfo.Visible = true; lblAddress.Text = "> " + HTMLHelper.HTMLEncode(ai.AddressName); } } else { lblError.Visible = true; lblError.Text = errorMessage; } } }
public static List <AddressInfo> GetAdresses(bool billing, bool shipping, ShoppingCartInfo cart) { List <AddressInfo> Result = new List <AddressInfo>(); if (ECommerceContext.CurrentCustomer == null) { return(Result); } //if customer have no [AddressEnabled] int idCustomer = ECommerceContext.CurrentCustomer.CustomerID; SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString"].ConnectionString); con3.Open(); var stringQuery = "select count(AddressID) as NbAdress from COM_Address WHERE COM_Address.AddressEnabled = 'true' AND COM_Address.AddressCustomerID = " + idCustomer; SqlCommand cmd3 = new SqlCommand(stringQuery, con3); int nb = (int)cmd3.ExecuteScalar(); if (nb == 0) { Result = null; return(Result); } string where = string.Empty, orderby = string.Empty; AddressInfo ai; DataSet ds, dsoi = null; if (billing) { ai = AddressInfoProvider.GetAddressInfo(cart.ShoppingCartBillingAddressID); if (ai == null) { where = string.Format("OrderCustomerID={0}", ECommerceContext.CurrentCustomer.CustomerID.ToString()); orderby = "OrderID DESC"; dsoi = OrderInfoProvider.GetOrderList(where, orderby); if (!DataHelper.DataSourceIsEmpty(dsoi)) { foreach (DataRow drow in dsoi.Tables[0].Rows) { OrderInfo oi = new OrderInfo(drow); AddressInfo bai = AddressInfoProvider.GetAddressInfo(oi.OrderBillingAddressID); if (bai.AddressEnabled && bai.AddressIsBilling) { ai = bai; cart.ShoppingCartBillingAddressID = bai.AddressID; break; } } } } if (ai == null) { where = string.Format("AddressCustomerID={0} AND AddressIsBilling=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); orderby = "AddressID"; ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { ai = new AddressInfo(ds.Tables[0].Rows[0]); cart.ShoppingCartBillingAddressID = ai.AddressID; } } Result.Add(ai); } if (shipping) { ai = AddressInfoProvider.GetAddressInfo(cart.ShoppingCartShippingAddressID); if (ai == null) { if (DataHelper.DataSourceIsEmpty(dsoi)) { // where = string.Format("OrderCustomerID={0}", ECommerceContext.CurrentCustomer.CustomerID.ToString()); where = string.Format("OrderCustomerID={0} ", ECommerceContext.CurrentCustomer.CustomerID.ToString()); orderby = "OrderID DESC"; dsoi = OrderInfoProvider.GetOrderList(where, orderby); } if (!DataHelper.DataSourceIsEmpty(dsoi)) { foreach (DataRow drow in dsoi.Tables[0].Rows) { OrderInfo oi = new OrderInfo(drow); AddressInfo sai = AddressInfoProvider.GetAddressInfo(oi.OrderShippingAddressID); if (sai.AddressEnabled && sai.AddressIsShipping) { ai = sai; cart.ShoppingCartShippingAddressID = sai.AddressID; break; } } } } if (ai == null) { where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); orderby = "AddressID"; ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { ai = new AddressInfo(ds.Tables[0].Rows[0]); cart.ShoppingCartShippingAddressID = ai.AddressID; } else { // NO SHIPPING ADDRESS DEFINED- PICK FIRST BILLING ADDRESS AddressInfo ai_shipping = AddressInfoProvider.GetAddressInfo(cart.ShoppingCartBillingAddressID); ai_shipping.AddressIsShipping = true; AddressInfoProvider.SetAddressInfo(ai_shipping); // where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); where = string.Format("AddressCustomerID={0} AND AddressIsShipping=1", ECommerceContext.CurrentCustomer.CustomerID.ToString()); ds = AddressInfoProvider.GetAddresses(where, orderby); if (!DataHelper.DataSourceIsEmpty(ds)) { ai = new AddressInfo(ds.Tables[0].Rows[0]); cart.ShoppingCartShippingAddressID = ai.AddressID; } } } Result.Add(ai); } return(Result); }
private void ctrlHexViewer_ByteMouseHover(int address, Point position) { ctrlTooltip tooltip = BaseForm.GetPopupTooltip(this); if (address < 0 || !mnuShowLabelInfoOnMouseOver.Checked) { _lastTooltipAddress = -1; tooltip.Hide(); return; } else if (_lastTooltipAddress == address) { return; } _lastTooltipAddress = address; CodeLabel label = null; int arrayOffset = 0; switch (_memoryType) { case SnesMemoryType.CpuMemory: case SnesMemoryType.SpcMemory: AddressInfo relAddress = new AddressInfo() { Address = address, Type = _memoryType }; AddressInfo absAddress = DebugApi.GetAbsoluteAddress(relAddress); if (absAddress.Address >= 0) { label = LabelManager.GetLabel((uint)absAddress.Address, absAddress.Type); if (label != null) { arrayOffset = relAddress.Address - (int)label.Address; } } break; case SnesMemoryType.WorkRam: case SnesMemoryType.SaveRam: case SnesMemoryType.PrgRom: case SnesMemoryType.SpcRam: case SnesMemoryType.SpcRom: label = LabelManager.GetLabel((uint)address, _memoryType); if (label != null) { arrayOffset = address - (int)label.Address; } break; } if (label != null && !string.IsNullOrWhiteSpace(label.Label)) { Dictionary <string, string> values = new Dictionary <string, string>(); if (!string.IsNullOrWhiteSpace(label.Label)) { values["Label"] = label.Label; if (label.Length > 1) { values["Label"] += "+" + arrayOffset.ToString(); } } values["Address"] = "$" + (label.Address + arrayOffset).ToString("X4"); values["Type"] = ResourceHelper.GetEnumText(label.MemoryType); if (!string.IsNullOrWhiteSpace(label.Comment)) { values["Comment"] = label.Comment; } tooltip.SetTooltip(this.PointToClient(position), values); } else { tooltip.Hide(); } }
public async Task NewTenantAsync([FromBody] CompleteTenantEvictionInfo info) { TenantInfo tenantInfo = info.TenantInfo; AddressInfo addressInfo = info.AddressInfo; EvictionInfo evictionInfo = info.EvictionInfo; PreparerInfo preparerInfo = info.PreparerInfo; // Null-check for all required fields if (tenantInfo == null || addressInfo == null || evictionInfo == null) { // don't insert anything } if (tenantInfo.Name == null || tenantInfo.Email == null || addressInfo.StreetAddress == null || addressInfo.City == null || addressInfo.County == null || addressInfo.ZipCode == 0 || evictionInfo.DateOfEviction == null) { // don't insert anything } try { _dbContext.DBTenantInfo.Add(tenantInfo); await _dbContext.SaveChangesAsync(); } // the only exception we should be getting here is the duplicate insertion - on which we just swallow the exception // we take care of the nulls above // rest we assume that the data is in correct format catch (Exception) { // swallow it } try { if (addressInfo.Latitude != 0.0D && addressInfo.Longitude != 0.0D) { string key = "keygoeshere"; string address = addressInfo.StreetAddress + addressInfo.City + addressInfo.ZipCode; Uri geoReqUri = new Uri(string.Format("http://dev.virtualearth.net/REST/v1/Locations?q={0}&key={1}", address, key)); var client = new HttpClient(); var responseTask = await client.GetAsync(geoReqUri); string responseString = await responseTask.Content.ReadAsStringAsync(); var coordinates = JObject.Parse(responseString)["resourceSets"][0]["resources"][0]["point"]["coordinates"].Children().ToList(); addressInfo.Latitude = coordinates[0].ToObject <double>(); addressInfo.Longitude = coordinates[1].ToObject <double>(); } _dbContext.DBAddressInfo.Add(addressInfo); await _dbContext.SaveChangesAsync(); } catch (Exception) { } // Get TenantId and AddressId var tenantId = _dbContext.DBTenantInfo .Where(t => t.Name == tenantInfo.Name && t.Email == tenantInfo.Email) .Select(t => t.Id) .FirstOrDefault(); var addressId = _dbContext.DBAddressInfo .Where(a => a.StreetAddress == addressInfo.StreetAddress && a.ZipCode == addressInfo.ZipCode) .Select(a => a.Id) .FirstOrDefault(); evictionInfo.AddressId = addressId; evictionInfo.TenantId = tenantId; if (preparerInfo != null && preparerInfo.Name != null && preparerInfo.Organization != null) { try { _dbContext.DBPreparerInfo.Add(preparerInfo); await _dbContext.SaveChangesAsync(); var preparerId = _dbContext.DBPreparerInfo .Where(p => p.Name == preparerInfo.Name && p.Organization == preparerInfo.Organization) .Select(p => p.Id) .FirstOrDefault(); evictionInfo.PreparerId = preparerInfo.Id; } catch (Exception) { } } try { _dbContext.DBEvictionInfo.Add(evictionInfo); await _dbContext.SaveChangesAsync(); } catch (Exception) { } }
private void BindShippingAddress(AddressInfo shippingAddress) { StringBuilder shippingAdr = new StringBuilder(); shippingAdr.Append("<table><tr>"); shippingAdr.Append("<td width=\"28%\">"+getLocale("Customer Name:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.FirstName + " " + shippingAddress.LastName + "</td></tr><tr>"); shippingAdr.Append("<td>"+getLocale("Address:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.Address1 + "</td></tr><tr>"); if (!string.IsNullOrEmpty(shippingAddress.Address2)) { shippingAdr.Append("<td>"+getLocale("Address2:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.Address2 + "</td></tr><tr>"); } shippingAdr.Append("<td>"+getLocale("Country:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.Country + "</td></tr><tr>"); shippingAdr.Append("<td>"+getLocale("City:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.City + "</td></tr><tr>"); shippingAdr.Append("<td>"+getLocale("State:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.State + "</td></tr><tr>"); shippingAdr.Append("<td>"+getLocale("ZipCode:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.Zip + "</td></tr><tr>"); shippingAdr.Append("<td>"+getLocale("Email Address:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.Email + "</td></tr><tr>"); shippingAdr.Append("<td>"+getLocale("Phone No:")+"</td>"); shippingAdr.Append("<td>" + shippingAddress.Phone + "</td></tr>"); shippingAdr.Append("</table>"); ltShippingAddress.Text = shippingAdr.ToString(); Session["sl_toAddress"] = shippingAddress; }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> public void Run(AdWordsUser user) { using (AdwordsUserListService userListService = (AdwordsUserListService)user.GetService( AdWordsService.v201708.AdwordsUserListService)) { // Create a user list. CrmBasedUserList userList = new CrmBasedUserList() { name = "Customer relationship management list #" + ExampleUtilities.GetRandomString(), description = "A list of customers that originated from email addresses", // CRM Userlist has a maximum membership lifespan of 180 days. See // https://support.google.com/adwords/answer/6276125 for details. membershipLifeSpan = 180L, }; // Create operation. UserListOperation operation = new UserListOperation() { operand = userList, @operator = Operator.ADD }; try { // Add user list. UserListReturnValue result = userListService.mutate( new UserListOperation[] { operation }); Console.WriteLine("Created new user list with name = '{0}' and id = " + "'{1}'.", result.value[0].name, result.value[0].id); // Get user list ID. long userListId = result.value[0].id; // Prepare the emails for upload. List <Member> memberList = new List <Member>(); // Hash normalized email addresses based on SHA-256 hashing algorithm. String[] emailHashes = new String[EMAILS.Length]; for (int i = 0; i < EMAILS.Length; i++) { Member member = new Member(); member.hashedEmail = ToSha256String(digest, ToNormalizedEmail(EMAILS[i])); memberList.Add(member); } ; // Add a user by first and last name. AddressInfo addressInfo = new AddressInfo(); // First and last name must be normalized and hashed. addressInfo.hashedFirstName = ToSha256String(digest, FIRST_NAME); addressInfo.hashedLastName = ToSha256String(digest, LAST_NAME); // Country code and zip code are sent in plaintext. addressInfo.zipCode = ZIP_CODE; addressInfo.countryCode = COUNTRY_CODE; Member memberByAddress = new Member(); memberByAddress.addressInfo = addressInfo; memberList.Add(memberByAddress); // Create operation to add members to the user list based on email // addresses. MutateMembersOperation mutateMembersOperation = new MutateMembersOperation() { operand = new MutateMembersOperand() { userListId = userListId, membersList = memberList.ToArray() }, @operator = Operator.ADD }; // Add members to the user list based on email addresses. MutateMembersReturnValue mutateMembersResult = userListService.mutateMembers( new MutateMembersOperation[] { mutateMembersOperation }); // Display results. // Reminder: it may take several hours for the list to be populated // with members. foreach (UserList userListResult in mutateMembersResult.userLists) { Console.WriteLine("Email addresses were added to user list with " + "name '{0}' and id '{1}'.", userListResult.name, userListResult.id); } } catch (Exception e) { throw new System.ApplicationException("Failed to add user lists " + "(a.k.a. audiences) and upload email addresses.", e); } } }
public ActionResult EditAgain(AddressInfo m) { return View("Edit", m); }
private bool Add_(NetworkAddress addr, IPAddress source, TimeSpan nTimePenalty) { if (!addr.Endpoint.Address.IsRoutable(true)) { return(false); } bool fNew = false; int nId; AddressInfo pinfo = Find(addr, out nId); if (pinfo != null) { // periodically update nTime bool fCurrentlyOnline = (DateTimeOffset.UtcNow - addr.Time < TimeSpan.FromSeconds(24 * 60 * 60)); var nUpdateInterval = TimeSpan.FromSeconds(fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60); if (addr.ntime != 0 && (pinfo.Address.ntime == 0 || pinfo.Address.Time < addr.Time - nUpdateInterval - nTimePenalty)) { pinfo.Address.ntime = (uint)Math.Max(0L, (long)Utils.DateTimeToUnixTime(addr.Time - nTimePenalty)); } // add services pinfo.Address.Service |= addr.Service; // do not update if no new information is present if (addr.ntime == 0 || (pinfo.Address.ntime != 0 && addr.Time <= pinfo.Address.Time)) { return(false); } // do not update if the entry was already in the "tried" table if (pinfo.fInTried) { return(false); } // do not update if the max reference count is reached if (pinfo.nRefCount == ADDRMAN_NEW_BUCKETS_PER_ADDRESS) { return(false); } // stochastic test: previous nRefCount == N: 2^N times harder to increase it int nFactor = 1; for (int n = 0; n < pinfo.nRefCount; n++) { nFactor *= 2; } if (nFactor > 1 && (GetRandInt(nFactor) != 0)) { return(false); } } else { pinfo = Create(addr, source, out nId); pinfo.Address.ntime = (uint)Math.Max((long)0, (long)Utils.DateTimeToUnixTime(pinfo.Address.Time - nTimePenalty)); nNew++; fNew = true; } int nUBucket = pinfo.GetNewBucket(nKey, source); int nUBucketPos = pinfo.GetBucketPosition(nKey, true, nUBucket); if (vvNew[nUBucket, nUBucketPos] != nId) { bool fInsert = vvNew[nUBucket, nUBucketPos] == -1; if (!fInsert) { AddressInfo infoExisting = mapInfo[vvNew[nUBucket, nUBucketPos]]; if (infoExisting.IsTerrible || (infoExisting.nRefCount > 1 && pinfo.nRefCount == 0)) { // Overwrite the existing new table entry. fInsert = true; } } if (fInsert) { ClearNew(nUBucket, nUBucketPos); pinfo.nRefCount++; vvNew[nUBucket, nUBucketPos] = nId; } else { if (pinfo.nRefCount == 0) { Delete(nId); } } } return(fNew); }
public ActionResult ForceSave(AddressInfo m) { m.UpdateAddress(ModelState, forceSave: true); return View("Saved", m); }
private int Check_() { List <int> setTried = new List <int>(); Dictionary <int, int> mapNew = new Dictionary <int, int>(); if (vRandom.Count != nTried + nNew) { return(-7); } foreach (var kv in mapInfo) { int n = kv.Key; AddressInfo info = kv.Value; if (info.fInTried) { if (info.nLastSuccess == 0) { return(-1); } if (info.nRefCount != 0) { return(-2); } setTried.Add(n); } else { if (info.nRefCount < 0 || info.nRefCount > ADDRMAN_NEW_BUCKETS_PER_ADDRESS) { return(-3); } if (info.nRefCount == 0) { return(-4); } mapNew[n] = info.nRefCount; } #if LOCAL_TESTS if (mapAddr[info.Address.Endpoint] != n) #else if (mapAddr[info.Address.Endpoint.Address] != n) #endif { return(-5); } if (info.nRandomPos < 0 || info.nRandomPos >= vRandom.Count || vRandom[info.nRandomPos] != n) { return(-14); } if (info.nLastTry < 0) { return(-6); } if (info.nLastSuccess < 0) { return(-8); } } if (setTried.Count != nTried) { return(-9); } if (mapNew.Count != nNew) { return(-10); } for (int n = 0; n < ADDRMAN_TRIED_BUCKET_COUNT; n++) { for (int i = 0; i < ADDRMAN_BUCKET_SIZE; i++) { if (vvTried[n, i] != -1) { if (!setTried.Contains(vvTried[n, i])) { return(-11); } if (mapInfo[vvTried[n, i]].GetTriedBucket(nKey) != n) { return(-17); } if (mapInfo[vvTried[n, i]].GetBucketPosition(nKey, false, n) != i) { return(-18); } setTried.Remove(vvTried[n, i]); } } } for (int n = 0; n < ADDRMAN_NEW_BUCKET_COUNT; n++) { for (int i = 0; i < ADDRMAN_BUCKET_SIZE; i++) { if (vvNew[n, i] != -1) { if (!mapNew.ContainsKey(vvNew[n, i])) { return(-12); } if (mapInfo[vvNew[n, i]].GetBucketPosition(nKey, true, n) != i) { return(-19); } if (--mapNew[vvNew[n, i]] == 0) { mapNew.Remove(vvNew[n, i]); } } } } if (setTried.Count != 0) { return(-13); } if (mapNew.Count != 0) { return(-15); } if (nKey == null || nKey == new byte[] {}) { return(-16); } return(0); }
/// <summary> /// Load data of editing address. /// </summary> /// <param name="addressObj">Address object</param> protected void LoadData(AddressInfo addressObj) { txtAddressZip.Text = addressObj.AddressZip; txtAddressDeliveryPhone.Text = addressObj.AddressPhone; txtPersonalName.Text = addressObj.AddressPersonalName; //txtAddressName.Text = addressObj.AddressName; txtAddressLine1.Text = addressObj.AddressLine1; chkAddressEnabled.Checked = addressObj.AddressEnabled; txtAddressLine2.Text = addressObj.AddressLine2; txtAddressCity.Text = addressObj.AddressCity; //drpAddressType.SelectedValue = AddressInfoProvider.GetAddressString(addressObj.AddressType); chkAddressIsBilling.Checked = addressObj.AddressIsBilling; chkAddressIsShipping.Checked = addressObj.AddressIsShipping; chkAddressIsCompany.Checked = addressObj.AddressIsCompany; ucCountrySelector.CountryID = addressObj.AddressCountryID; ucCountrySelector.StateID = addressObj.AddressStateID; }
private void UpdateActionAvailability() { UInt32 startAddress = (UInt32)SelectionStartAddress; UInt32 endAddress = (UInt32)SelectionEndAddress; string address = "$" + startAddress.ToString("X4"); string addressRange; if (startAddress != endAddress) { addressRange = "$" + startAddress.ToString("X4") + "-$" + endAddress.ToString("X4"); } else { addressRange = address; } mnuEditLabel.Text = $"Edit Label ({address})"; mnuEditBreakpoint.Text = $"Edit Breakpoint ({addressRange})"; mnuAddToWatch.Text = $"Add to Watch ({addressRange})"; if (_memoryType == SnesMemoryType.CpuMemory || _memoryType == SnesMemoryType.SpcMemory) { AddressInfo relAddress = new AddressInfo() { Address = (int)startAddress, Type = _memoryType }; AddressInfo absAddress = DebugApi.GetAbsoluteAddress(relAddress); mnuEditLabel.Enabled = absAddress.Address != -1 && absAddress.Type.SupportsLabels(); mnuAddToWatch.Enabled = _memoryType.SupportsWatch(); } else { mnuEditLabel.Enabled = _memoryType.SupportsLabels(); mnuAddToWatch.Enabled = false; } if (_memoryType == SnesMemoryType.CpuMemory) { AddressInfo start = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = (int)startAddress, Type = _memoryType }); AddressInfo end = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = (int)endAddress, Type = _memoryType }); if (start.Address >= 0 && end.Address >= 0 && start.Address <= end.Address && start.Type == SnesMemoryType.PrgRom && end.Type == SnesMemoryType.PrgRom) { mnuMarkSelectionAs.Text = "Mark selection as... (" + addressRange + ")"; mnuMarkSelectionAs.Enabled = true; } else { mnuMarkSelectionAs.Text = "Mark selection as..."; mnuMarkSelectionAs.Enabled = false; } } else if (_memoryType == SnesMemoryType.PrgRom) { mnuMarkSelectionAs.Text = "Mark selection as... (" + addressRange + ")"; mnuMarkSelectionAs.Enabled = true; } else { mnuMarkSelectionAs.Text = "Mark selection as..."; mnuMarkSelectionAs.Enabled = false; } mnuEditBreakpoint.Enabled = true; }
/// <summary> /// Process valid values of this step. /// </summary> public override bool ProcessStep() { AddressInfo ai = null; bool newAddress = false; if (mCustomerId > 0) { // Clean the viewstate RemoveBillingTempValues(); RemoveShippingTempValues(); RemoveCompanyTempValues(); // Check country presence if (CountrySelector1.CountryID <= 0) { lblError.Visible = true; lblError.Text = GetString("countryselector.selectedcountryerr"); return false; } if (!CountrySelector1.StateSelectionIsValid) { lblError.Visible = true; lblError.Text = GetString("countryselector.selectedstateerr"); return false; } // Process billing address //------------------------ ai = AddressInfoProvider.GetAddressInfo(ValidationHelper.GetInteger(drpBillingAddr.SelectedValue, 0)); if (ai == null) { ai = new AddressInfo(); newAddress = true; } ai.AddressPersonalName = txtBillingName.Text.Trim(); ai.AddressLine1 = txtBillingAddr1.Text.Trim(); ai.AddressLine2 = txtBillingAddr2.Text.Trim(); ai.AddressCity = txtBillingCity.Text.Trim(); ai.AddressZip = txtBillingZip.Text.Trim(); ai.AddressCountryID = CountrySelector1.CountryID; ai.AddressStateID = CountrySelector1.StateID; ai.AddressPhone = txtBillingPhone.Text.Trim(); if (newAddress) { ai.AddressIsBilling = true; ai.AddressIsShipping = !chkShippingAddr.Checked; ai.AddressIsCompany = !chkCompanyAddress.Checked; ai.AddressEnabled = true; } ai.AddressCustomerID = mCustomerId; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save address and set it's ID to ShoppingCartInfoObj AddressInfoProvider.SetAddressInfo(ai); // Update current contact's address MapContactAddress(ai); ShoppingCart.ShoppingCartBillingAddress = ai; // If shopping cart does not need shipping if (!ShoppingCart.IsShippingNeeded) { ShoppingCart.ShoppingCartShippingAddress = null; } // If shipping address is different from billing address else if (chkShippingAddr.Checked) { // Check country presence if (CountrySelector2.CountryID <= 0) { lblError.Visible = true; lblError.Text = GetString("countryselector.selectedcountryerr"); return false; } if (!CountrySelector2.StateSelectionIsValid) { lblError.Visible = true; lblError.Text = GetString("countryselector.selectedstateerr"); return false; } newAddress = false; // Process shipping address //------------------------- ai = AddressInfoProvider.GetAddressInfo(Convert.ToInt32(drpShippingAddr.SelectedValue)); if (ai == null) { ai = new AddressInfo(); newAddress = true; } ai.AddressPersonalName = txtShippingName.Text.Trim(); ai.AddressLine1 = txtShippingAddr1.Text.Trim(); ai.AddressLine2 = txtShippingAddr2.Text.Trim(); ai.AddressCity = txtShippingCity.Text.Trim(); ai.AddressZip = txtShippingZip.Text.Trim(); ai.AddressCountryID = CountrySelector2.CountryID; ai.AddressStateID = CountrySelector2.StateID; ai.AddressPhone = txtShippingPhone.Text.Trim(); if (newAddress) { ai.AddressIsShipping = true; ai.AddressEnabled = true; ai.AddressIsBilling = false; ai.AddressIsCompany = false; ai.AddressEnabled = true; } ai.AddressCustomerID = mCustomerId; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save address and set it's ID to ShoppingCartInfoObj AddressInfoProvider.SetAddressInfo(ai); ShoppingCart.ShoppingCartShippingAddress = ai; } // Shipping address is the same as billing address else { ShoppingCart.ShoppingCartShippingAddress = ShoppingCart.ShoppingCartBillingAddress; } if (chkCompanyAddress.Checked) { // Check country presence if (CountrySelector3.CountryID <= 0) { lblError.Visible = true; lblError.Text = GetString("countryselector.selectedcountryerr"); return false; } if (!CountrySelector3.StateSelectionIsValid) { lblError.Visible = true; lblError.Text = GetString("countryselector.selectedstateerr"); return false; } newAddress = false; // Process company address //------------------------- ai = AddressInfoProvider.GetAddressInfo(Convert.ToInt32(drpCompanyAddress.SelectedValue)); if (ai == null) { ai = new AddressInfo(); newAddress = true; } ai.AddressPersonalName = txtCompanyName.Text.Trim(); ai.AddressLine1 = txtCompanyLine1.Text.Trim(); ai.AddressLine2 = txtCompanyLine2.Text.Trim(); ai.AddressCity = txtCompanyCity.Text.Trim(); ai.AddressZip = txtCompanyZip.Text.Trim(); ai.AddressCountryID = CountrySelector3.CountryID; ai.AddressStateID = CountrySelector3.StateID; ai.AddressPhone = txtCompanyPhone.Text.Trim(); if (newAddress) { ai.AddressIsCompany = true; ai.AddressIsBilling = false; ai.AddressIsShipping = false; ai.AddressEnabled = true; } ai.AddressCustomerID = mCustomerId; ai.AddressName = AddressInfoProvider.GetAddressName(ai); // Save address and set it's ID to ShoppingCartInfoObj AddressInfoProvider.SetAddressInfo(ai); ShoppingCart.ShoppingCartCompanyAddress = ai; } // Company address is the same as billing address else { // Save information about company address or not (according to the site settings) if (ECommerceSettings.UseExtraCompanyAddress(mCurrentSite.SiteName)) { ShoppingCart.ShoppingCartCompanyAddress = ShoppingCart.ShoppingCartBillingAddress; } else { ShoppingCart.ShoppingCartCompanyAddress = null; } } try { // Update changes in database only when on the live site if (!ShoppingCartControl.IsInternalOrder) { ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart); } return true; } catch (Exception ex) { // Show error message lblError.Visible = true; lblError.Text = ex.Message; return false; } } else { lblError.Visible = true; lblError.Text = GetString("Ecommerce.NoCustomerSelected"); return false; } }
public string GenerateUpdateJsonFromObject(Household updateFrom) { // form the json (determine the fields that need to be updated) var sb = new StringBuilder(); var sw = new StringWriter(sb); var writer = new JsonTextWriter(sw) { Formatting = Formatting.None }; writer.WriteStartObject(); writer.WritePropertyName(@"household"); writer.WriteStartObject(); if (!HouseholdName.Equals(updateFrom.HouseholdName)) { writer.WritePropertyName("name"); writer.WriteValue(updateFrom.HouseholdName); } if (!IntakeDate.Equals(updateFrom.IntakeDate)) { writer.WritePropertyName("intake_date"); writer.WriteValue(updateFrom.IntakeDate.ToString("yyyy-MM-dd")); } if (!AddressLine1.Equals(updateFrom.AddressLine1)) { writer.WritePropertyName("address_line_1"); writer.WriteValue(updateFrom.AddressLine1); } if (!AddressLine2.Equals(updateFrom.AddressLine2)) { writer.WritePropertyName("address_line_2"); writer.WriteValue(updateFrom.AddressLine2); } if (!PostalCode.Equals(updateFrom.PostalCode)) { writer.WritePropertyName("postal_code"); writer.WriteValue(updateFrom.PostalCode); } if (!DependentLocality.Equals(updateFrom.DependentLocality)) { writer.WritePropertyName("dependent_locality"); writer.WriteValue(updateFrom.DependentLocality); } if (!Locality.Equals(updateFrom.Locality)) { writer.WritePropertyName("locality"); writer.WriteValue(updateFrom.Locality); } if (!AdminvArea.Equals(updateFrom.AdminvArea)) { writer.WritePropertyName("adminv_area"); writer.WriteValue(updateFrom.AdminvArea); } if (!DependentAdminvArea.Equals(updateFrom.DependentAdminvArea)) { writer.WritePropertyName("dependent_adminv_area"); writer.WriteValue(updateFrom.DependentAdminvArea); } if (!Country.Equals(updateFrom.Country)) { writer.WritePropertyName("country"); writer.WriteValue(updateFrom.Country); } if (!AddressInfo.Equals(updateFrom.AddressInfo)) { writer.WritePropertyName("address_info"); writer.WriteValue(updateFrom.AddressInfo); } if (!GpsLatitude.Equals(updateFrom.GpsLatitude)) { writer.WritePropertyName("latitude"); writer.WriteValue(updateFrom.GpsLatitude ?? null); } if (!GpsLongitude.Equals(updateFrom.GpsLongitude)) { writer.WritePropertyName("longitude"); writer.WriteValue(updateFrom.GpsLongitude ?? null); } if (!GpsPositionAccuracy.Equals(updateFrom.GpsPositionAccuracy)) { writer.WritePropertyName("position_accuracy"); writer.WriteValue(updateFrom.GpsPositionAccuracy ?? null); } if (!GpsAltitude.Equals(updateFrom.GpsAltitude)) { writer.WritePropertyName("altitude"); writer.WriteValue(updateFrom.GpsAltitude ?? null); } if (!GpsAltitudeAccuracy.Equals(updateFrom.GpsAltitudeAccuracy)) { writer.WritePropertyName("altitude_accuracy"); writer.WriteValue(updateFrom.GpsAltitudeAccuracy ?? null); } if (!GpsHeading.Equals(updateFrom.GpsHeading)) { writer.WritePropertyName("heading"); writer.WriteValue(updateFrom.GpsHeading ?? null); } if (!GpsSpeed.Equals(updateFrom.GpsSpeed)) { writer.WritePropertyName("speed"); writer.WriteValue(updateFrom.GpsSpeed ?? null); } if (!GpsPositionTime.Equals(updateFrom.GpsPositionTime)) { writer.WritePropertyName("gps_recorded_at"); writer.WriteValue(updateFrom.GpsPositionTime ?? null); } writer.WriteEndObject(); writer.WriteEndObject(); return(sw.ToString()); }
private unsafe static SocketError TryGetAddrInfo(string name, AddressInfoHints flags, out IPHostEntry hostinfo) { // // Use SocketException here to show operation not supported // if, by some nefarious means, this method is called on an // unsupported platform. // #if FEATURE_PAL throw new SocketException(SocketError.OperationNotSupported); #else SafeFreeAddrInfo root = null; ArrayList addresses = new ArrayList(); string canonicalname = null; AddressInfo hints = new AddressInfo(); hints.ai_flags = flags; hints.ai_family = AddressFamily.Unspecified; // gets all address families // // Use try / finally so we always get a shot at freeaddrinfo // try { SocketError errorCode = (SocketError)SafeFreeAddrInfo.GetAddrInfo(name, null, ref hints, out root); if (errorCode != SocketError.Success) { // Should not throw, return mostly blank hostentry hostinfo = new IPHostEntry(); hostinfo.HostName = name; hostinfo.Aliases = new string[0]; hostinfo.AddressList = new IPAddress[0]; return errorCode; } AddressInfo* pAddressInfo = (AddressInfo*)root.DangerousGetHandle(); // // Process the results // while (pAddressInfo!=null) { SocketAddress sockaddr; // // Retrieve the canonical name for the host - only appears in the first AddressInfo // entry in the returned array. // if (canonicalname==null && pAddressInfo->ai_canonname!=null) { canonicalname = Marshal.PtrToStringUni((IntPtr)pAddressInfo->ai_canonname); } // // Only process IPv4 or IPv6 Addresses. Note that it's unlikely that we'll // ever get any other address families, but better to be safe than sorry. // We also filter based on whether IPv6 is supported on the current // platform / machine. // if ( ( pAddressInfo->ai_family == AddressFamily.InterNetwork ) || // Never filter v4 (pAddressInfo->ai_family == AddressFamily.InterNetworkV6 && Socket.OSSupportsIPv6)) { sockaddr = new SocketAddress(pAddressInfo->ai_family, pAddressInfo->ai_addrlen); // // Push address data into the socket address buffer // for (int d = 0; d < pAddressInfo->ai_addrlen; d++) { sockaddr.m_Buffer[d] = *(pAddressInfo->ai_addr + d); } // // NOTE: We need an IPAddress now, the only way to create it from a // SocketAddress is via IPEndPoint. This ought to be simpler. // if ( pAddressInfo->ai_family == AddressFamily.InterNetwork ) { addresses.Add( ((IPEndPoint)IPEndPoint.Any.Create(sockaddr)).Address ); } else { addresses.Add( ((IPEndPoint)IPEndPoint.IPv6Any.Create(sockaddr)).Address ); } } // // Next addressinfo entry // pAddressInfo = pAddressInfo->ai_next; } } finally { if (root != null) { root.Close(); } } // // Finally, put together the IPHostEntry // hostinfo = new IPHostEntry(); hostinfo.HostName = canonicalname!=null ? canonicalname : name; hostinfo.Aliases = new string[0]; hostinfo.AddressList = new IPAddress[addresses.Count]; addresses.CopyTo(hostinfo.AddressList); return SocketError.Success; #endif // FEATURE_PAL }
private void SetupSelectedAddress() { AddressInfo address = CurrentCartAddress as AddressInfo; // Set DDL value only for classic load, CurrentCartAddress in postback is not ready yet if (!RequestHelper.IsPostBack()) { int addressId = 0; // In case of PropagateChangesOnPostback don't set address id, because in this mode null address is replaced with empty one in addressForm_OnAfterDataLoad if ((address != null) && !(PropagateChangesOnPostback && (address.AddressID == 0))) { addressId = address.AddressID; } else { // Get last modified customer address ObjectQuery <AddressInfo> lastAddress = null; switch (AddressType) { case BILLING: // Get last modified billing addresses lastAddress = AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID, true, false, false, true).TopN(1).OrderByDescending("AddressLastModified"); break; case SHIPPING: lastAddress = AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID, false, true, false, true).TopN(1).OrderByDescending("AddressLastModified"); break; case COMPANY: lastAddress = AddressInfoProvider.GetAddresses(ShoppingCart.ShoppingCartCustomerID, false, false, true, true).TopN(1).OrderByDescending("AddressLastModified"); break; } // Load last used address if there is one if (!DataHelper.DataSourceIsEmpty(lastAddress)) { address = lastAddress.FirstObject; addressId = address != null ? address.AddressID : 0; } } try { drpAddresses.SelectedValue = Convert.ToString(addressId); } // Eat exception in case of setting non-existing address in selector catch { } } // Do not init UIForm for new address, or there will be still old address after selecting "new" from address DDL selector if ((address != null) && (drpAddresses.SelectedValue != "0")) { addressForm.EditedObject = address; CurrentCartAddress = address; } // Do not reload data in postback, save action is postback, and reload will erase fields with changed data before saving into CurrentCartAddress if (!RequestHelper.IsPostBack()) { addressForm.ReloadData(); } }
internal static int GetAddrInfo(string nodename, string servicename, ref AddressInfo hints, out SafeFreeAddrInfo outAddrInfo) { return UnsafeNclNativeMethods.SafeNetHandlesXPOrLater.GetAddrInfoW(nodename, servicename, ref hints, out outAddrInfo); }
/// <summary> /// /// </summary> /// <returns></returns> public bool CreateOrder() { if (_arg == null || _arg.UserCollection == null || _arg.UserCollection.Length <= 0) { Alert("请指定VIP升级会员"); return(false); } decimal amount = GetOrderAmount(_arg.DeviceModel) * _arg.UserCollection.Length; if (amount <= 0) { Alert("指定型号的设备已停止赠送"); return(false); } IUser user = GetUserById(_arg.UserId); if (user == null) { Alert("付款账号不存在"); return(false); } string order_no; BeginTransaction(); Tvip_Order daOrder = new Tvip_Order(); daOrder.ReferenceTransactionFrom(Transaction); daOrder.Amount = amount; daOrder.Order_Type = (int)_arg.OrderType; daOrder.Pay_Type = (int)_arg.PayType; daOrder.Status = 0; daOrder.User_Id = _arg.UserId; daOrder.Device_Id = _arg.DeviceModel; if (!string.IsNullOrEmpty(_arg.Org_Code)) { daOrder.Biz_Args = "{\"Org_Code\":\"" + _arg.Org_Code + "\"}"; } if (_arg.ConsigneeId.HasValue) { daOrder.Delivery_Type = 1; } if (!daOrder.Insert("VIP", out order_no)) { Rollback(); Alert("创建订单失败"); return(false); } if (_arg.ConsigneeId.HasValue) { ConsigneeProvider consignee = new ConsigneeProvider(); AddressInfo address = consignee.GetAddressById(_arg.ConsigneeId.Value); if (address == null) { Rollback(); Alert("无效的收货地址"); return(false); } Tvip_Express daExpress = new Tvip_Express(); daExpress.ReferenceTransactionFrom(Transaction); daExpress.Order_Id = daOrder.Order_Id; daExpress.Receiver = address.ConsigneeName; daExpress.Contract_Phone = address.MobileNo; daExpress.Province_Name = address.ProvinceName; daExpress.City_Name = address.CityName; daExpress.Region_Name = address.RegionName; daExpress.Full_Address = address.Address; daExpress.Status = 0; if (!daExpress.Insert()) { Rollback(); Alert("收货地址保存失败"); return(false); } } foreach (string userCode in _arg.UserCollection) { IUser vipUser = GetUserByCode(userCode); if (vipUser == null) { Rollback(); Alert(userCode + "不存在"); return(false); } //if (vipUser.Grade.Level == (int)UserLevel.DIP会员 || vipUser.Grade.Level == (int)UserLevel.VIP会员) //{ // Alert("您已经是VIP,不能重复申请"); // Rollback(); // return false; //} Tvip_Sub_Order daSub = new Tvip_Sub_Order(); daSub.ReferenceTransactionFrom(Transaction); daSub.Order_Id = daOrder.Order_Id; daSub.User_Id = vipUser.UserId; if (!daSub.Insert()) { Rollback(); Alert("创建订单失败"); return(false); } } string voucher = order_no; if (xUtils.IsCashPayment(_arg.PayType)) { var gpuRes = CreateGpuOrder(user, order_no, amount, _arg.PayType); if (!gpuRes.Success) { Rollback(); Alert(gpuRes.Message); return(false); } voucher = gpuRes.Content.Voucher; this.PayUrl = gpuRes.Content.PayUrl; } daOrder.Voucher = voucher; if (!daOrder.Update()) { Rollback(); Alert("获取支付凭证号失败"); return(false); } Commit(); this.OrderNo = order_no; this.Voucher = voucher; this.Amount = amount; return(true); }
/// <summary> /// Gets and bulk updates addresses. Called when the "Get and bulk update addresses" button is pressed. /// Expects the CreateAddress method to be run first. /// </summary> private bool GetAndBulkUpdateAddresses() { // Prepare the parameters string where = "AddressName LIKE 'My New%'"; // Get the data DataSet addresses = AddressInfoProvider.GetAddresses(where, null); if (!DataHelper.DataSourceIsEmpty(addresses)) { // Loop through the individual items foreach (DataRow addressDr in addresses.Tables[0].Rows) { // Create object from DataRow AddressInfo modifyAddress = new AddressInfo(addressDr); // Update the properties modifyAddress.AddressName = modifyAddress.AddressName.ToUpper(); // Update the address AddressInfoProvider.SetAddressInfo(modifyAddress); } return true; } return false; }
public void SetAccountInfo(int uniqueID, AddressInfo addressInfo) { var getUniqueId = new SetAccountInfo(uniqueID, addressInfo); Utility.ServiceCall(requestURL + "/setaccountinfo", JsonConvert.SerializeObject(getUniqueId)); }
/// <summary> /// Creates address. Called when the "Create address" button is pressed. /// Expects the CreateRegisteredCustomer method to be run first. /// </summary> private bool CreateAddress() { // Prepare the parameters string where = "CustomerLastName LIKE N'My New Registered%'"; CustomerInfo customer = null; // Get the customer DataSet customers = CustomerInfoProvider.GetCustomers(where, null); if (!DataHelper.DataSourceIsEmpty(customers)) { // Create object from DataRow customer = new CustomerInfo(customers.Tables[0].Rows[0]); } // Get the country CountryInfo country = CountryInfoProvider.GetCountryInfo("USA"); // Get the state StateInfo state = StateInfoProvider.GetStateInfo("Alabama"); if ((customer != null) && (country != null)) { // Create new address object AddressInfo newAddress = new AddressInfo(); // Set the properties newAddress.AddressName = "My new address"; newAddress.AddressLine1 = "Address line 1"; newAddress.AddressLine2 = "Address line 2"; newAddress.AddressCity = "Address city"; newAddress.AddressZip = "Address ZIP code"; newAddress.AddressIsBilling = true; newAddress.AddressIsShipping = false; newAddress.AddressEnabled = true; newAddress.AddressPersonalName = ""; newAddress.AddressCustomerID = customer.CustomerID; newAddress.AddressCountryID = country.CountryID; newAddress.AddressStateID = state.StateID; // Create the address AddressInfoProvider.SetAddressInfo(newAddress); return true; } return false; }
/// <summary> /// Полное удаление AddressInfo со всеми его объектами из БД /// </summary> /// <param name="film">Фильм</param> public static void FullyAddressInfoDeleting(AddressInfo addressInfo) { DeleteAddressInfoEntities <Jumper>(addressInfo); DeleteEntityFromDb <AddressInfo>(addressInfo.Id); }
/// <summary> /// Load address data into editing form. /// </summary> /// <param name="addressObj">AddressInfo object</param> protected void LoadData(AddressInfo addressObj) { lblAddress.Text = "> " + HTMLHelper.HTMLEncode(addressObj.AddressName); txtAddressZip.Text = addressObj.AddressZip; txtAddressDeliveryPhone.Text = addressObj.AddressPhone; txtPersonalName.Text = addressObj.AddressPersonalName; txtAddressLine1.Text = addressObj.AddressLine1; txtAddressLine2.Text = addressObj.AddressLine2; txtAddressCity.Text = addressObj.AddressCity; ucCountrySelector.CountryID = addressObj.AddressCountryID; ucCountrySelector.StateID = addressObj.AddressStateID; ucCountrySelector.ReloadData(true); }
/// <summary> /// Удалить все сущности AddressInfo (Наследники IAddressInfo) из БД /// </summary> /// <typeparam name="T">Тип сущностей</typeparam> /// <param name="addressInfo">AddressInfo сущностей</param> public static void DeleteAddressInfoEntities <T>(AddressInfo addressInfo) where T : IAddressInfoEntity { using var db = new LiteDatabase(DBPath); db.GetCollection <T>().DeleteMany(entity => entity.AddressInfo.Id == addressInfo.Id); }
public bool GetObjectNeedsUpate(Household checkUpdateFrom) { if (!HouseholdName.Equals(checkUpdateFrom.HouseholdName)) { return(true); } if (!IntakeDate.Equals(checkUpdateFrom.IntakeDate)) { return(true); } if (!AddressLine1.Equals(checkUpdateFrom.AddressLine1)) { return(true); } if (!AddressLine2.Equals(checkUpdateFrom.AddressLine2)) { return(true); } if (!PostalCode.Equals(checkUpdateFrom.PostalCode)) { return(true); } if (!DependentLocality.Equals(checkUpdateFrom.DependentLocality)) { return(true); } if (!Locality.Equals(checkUpdateFrom.Locality)) { return(true); } if (!AdminvArea.Equals(checkUpdateFrom.AdminvArea)) { return(true); } if (!DependentAdminvArea.Equals(checkUpdateFrom.DependentAdminvArea)) { return(true); } if (!Country.Equals(checkUpdateFrom.Country)) { return(true); } if (!AddressInfo.Equals(checkUpdateFrom.AddressInfo)) { return(true); } if (!GpsLatitude.Equals(checkUpdateFrom.GpsLatitude)) { return(true); } if (!GpsLongitude.Equals(checkUpdateFrom.GpsLongitude)) { return(true); } if (!GpsPositionAccuracy.Equals(checkUpdateFrom.GpsPositionAccuracy)) { return(true); } if (!GpsAltitude.Equals(checkUpdateFrom.GpsAltitude)) { return(true); } if (!GpsAltitudeAccuracy.Equals(checkUpdateFrom.GpsAltitudeAccuracy)) { return(true); } if (!GpsHeading.Equals(checkUpdateFrom.GpsHeading)) { return(true); } if (!GpsSpeed.Equals(checkUpdateFrom.GpsSpeed)) { return(true); } if (!GpsPositionTime.Equals(checkUpdateFrom.GpsPositionTime)) { return(true); } return(false); }
public void ShowAddress(AddressInfo address) { ShowAddress(address.Address, address.Type); }