public string ToCnArcherJSON() { var singleLineAddress = Address.Replace("\n", ","); // TODO: Proper serialization instead of hand writing string output = ""; output = $"{{ " + $" \"type\":\"cnArcherWO\"," + $" \"product\": \"canopy\"," + $" \"id\": \"{EIP}\"," + $" \"name\": \"{Name}\"," + $" \"address\": \"{singleLineAddress}\"," + $" \"phone\": \"{Phones.Split(',')[0]}\"," + $" \"mode\": \"automated\"," + $" \"sm_name\": \"{Name} ({EIP})\"," + $" \"security\": \"aaa\"," + $" \"aaa_user_type\": \"mac_hyphen\"," + $" \"aaa_pass\": \"\"," + $" \"aaa_phase1\": \"eapMSChapv2\"," + $" \"aaa_phase2\": \"mschapv2\"," + $" \"aaa_identity\": \"anonymous\"," + $" \"aaa_realm\": \"canopy.net\"," + $" \"nat\": false," + $" \"ip_setting\": \"dhcp\"," + $" \"comments\": \"Install {Date} by {Tech}\", " + $" \"firmware\": \"{Firmware}\"" + $"}}"; return(output); }
public void PatchModel(Organization target) { target.OuterId = OuterId; target.Name = OrganizationName; target.Emails = string.IsNullOrEmpty(Emails) ? null : Emails.Split(',').Select(email => email.Trim()).ToList(); target.Phones = string.IsNullOrEmpty(Phones) ? null : Phones.Split(',').Select(phone => phone.Trim()).ToList(); target.BusinessCategory = BusinessCategory; target.Description = Description; target.DynamicProperties = DynamicProperties; target.Addresses ??= new List <Address>(); var isAddressSpecified = new[] { AddressCountry, AddressCountryCode, AddressRegion, AddressCity, AddressLine1, AddressLine2, AddressZipCode }.Any(addressField => !string.IsNullOrEmpty(addressField)); if (isAddressSpecified) { target.Addresses.Add(new Address { AddressType = !string.IsNullOrEmpty(AddressType) ? Enum.Parse <AddressType>(AddressType) : CoreModule.Core.Common.AddressType.BillingAndShipping, FirstName = AddressFirstName, LastName = AddressLastName, CountryName = AddressCountry, CountryCode = AddressCountryCode, RegionName = AddressRegion, City = AddressCity, Line1 = AddressLine1, Line2 = AddressLine2, PostalCode = AddressZipCode, Email = AddressEmail, Phone = AddressPhone, }); } }
public void PatchModel(Contact target) { target.OuterId = OuterId; target.FirstName = ContactFirstName; target.LastName = ContactLastName; target.FullName = ContactFullName; target.Status = ContactStatus; target.BirthDate = Birthday; target.TimeZone = TimeZone; target.Emails = string.IsNullOrEmpty(Emails) ? null : Emails.Split(',').Select(email => email.Trim()).ToList(); target.Phones = string.IsNullOrEmpty(Phones) ? null : Phones.Split(',').Select(phone => phone.Trim()).ToList(); target.Salutation = Salutation; target.DefaultLanguage = DefaultLanguage; target.TaxPayerId = TaxPayerId; target.PreferredCommunication = PreferredCommunication; target.PreferredDelivery = PreferredDelivery; target.DynamicProperties = DynamicProperties; target.Addresses ??= new List <Address>(); var isAddressSpecified = new[] { AddressCountry, AddressCountryCode, AddressRegion, AddressCity, AddressLine1, AddressLine2, AddressZipCode }.Any(addressField => !string.IsNullOrEmpty(addressField)); if (isAddressSpecified) { target.Addresses.Add(new Address { AddressType = EnumUtility.SafeParse(AddressType, CoreModule.Core.Common.AddressType.BillingAndShipping), FirstName = AddressFirstName, LastName = AddressLastName, CountryName = AddressCountry, CountryCode = AddressCountryCode, RegionName = AddressRegion, City = AddressCity, Line1 = AddressLine1, Line2 = AddressLine2, PostalCode = AddressZipCode, Email = AddressEmail, Phone = AddressPhone, }); } target.SecurityAccounts = new List <ApplicationUser>(); var accountSpecified = new[] { AccountLogin, AccountEmail }.Any(accountField => !string.IsNullOrEmpty(accountField)); if (accountSpecified) { target.SecurityAccounts.Add( new ApplicationUser { StoreId = StoreId, UserName = AccountLogin, Email = AccountEmail, UserType = AccountType, Status = AccountStatus, EmailConfirmed = EmailVerified ?? false, Password = Password, PasswordExpired = true, } ); } }
private void SendSms(string text) { var phones = Phones.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); if (phones.Length == 0) { return; } var httpWebRequest = (HttpWebRequest)WebRequest.Create(GatewayUrl); var postData = string.Format("user={0}&pass={1}&action=post_sms&message={2}&target={3}", GatewayUser, GatewayPassword, HttpUtility.UrlEncode(text), string.Join(",", phones)); //postData = HttpUtility.UrlEncode(postData); var data = encodingSms.GetBytes(postData); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; httpWebRequest.ContentLength = data.Length; httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; try { var newStream = httpWebRequest.GetRequestStream(); newStream.Write(data, 0, data.Length); newStream.Close(); var response = (HttpWebResponse)httpWebRequest.GetResponse(); var status = response.StatusDescription; Logger.InfoFormat("SMS отправлено: \"{0}\". Статус: {1}", text, status); var respData = response.GetResponseStream(); using (var sr = new StreamReader(respData, Encoding.UTF8)) { var respStr = sr.ReadToEnd(); Logger.InfoFormat(respStr); } } catch (Exception ex) { Logger.Error(string.Format("Ошибка при отправке SMS"), ex); } }
public IEnumerable <string> GetPhones() { return(Phones.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)); }