public SmsMessageChannel( IOrchardServices orchardServices, IShapeFactory shapeFactory, IShapeDisplay shapeDisplay) { _shapeFactory = shapeFactory; _shapeDisplay = shapeDisplay; _smsSettings = orchardServices.WorkContext.CurrentSite.As <SmsSettingsPart>(); _smsClientField = new Lazy <TwilioRestClient>(CreateSmsClient); }
private SmsServiceReference.SmsWebServiceSoapClient CreateSmsService(SmsSettingsPart smsSettings) { //Specify the binding to be used for the client. EndpointAddress address = new EndpointAddress(smsSettings.SmsServiceEndPoint); BasicHttpBinding binding = new BasicHttpBinding(); if (address.Uri.Scheme.ToLower().StartsWith("https")) { binding.Security.Mode = BasicHttpSecurityMode.Transport; } return(new SmsWebServiceSoapClient(binding, address)); }
void LazyLoadHandlers(LoadContentContext context, SmsSettingsPart part) { //part.PasswordField.Getter(() => { // try { // var encryptedPassword = part.Retrieve(x => x.Password); // return String.IsNullOrWhiteSpace(encryptedPassword) ? String.Empty : Encoding.UTF8.GetString(_encryptionService.Decode(Convert.FromBase64String(encryptedPassword))); // } // catch { // Logger.Error("The email password could not be decrypted. It might be corrupted, try to reset it."); // return null; // } //}); //part.PasswordField.Setter(value => { // var encryptedPassword = String.IsNullOrWhiteSpace(value) ? String.Empty : Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(value))); // part.Store(x => x.Password, encryptedPassword); //}); //part.AddressPlaceholderField.Loader(value => (string)((dynamic)ConfigurationManager.GetSection("system.net/mailSettings/smtp")).From); part.TwilioNumberPlaceholderField.Loader(value => "YYY-YYY-YYYY"); }