public override void Initialize(VPlatform platform, VLogger logger, VModuleInfo moduleInfo, int secret) { _contract.Initialize(PlatformAdapter.V2C(platform), LoggerAdapter.V2C(logger), ModuleInfoAdapter.V2C(moduleInfo), secret); //IPlatform iPlatform = PlatformAdapter.V2C(platform); //ILogger iLogger = LoggerAdapter.V2C(logger); //IModuleInfo iModuleInfo = ModuleInfoAdapter.V2C(moduleInfo); //_contract.Initialize(iPlatform, iLogger, iModuleInfo); }
internal static IPlatform V2C(VPlatform view) { if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) && (view.GetType().Equals(typeof(PlatformC2V)))) { return(((PlatformC2V)(view)).GetSourceContract()); } else { return(new PlatformV2C(view)); } }
public static ServiceHost CreateServiceHost(VLogger logger, VPlatform platform, IAuthenticationService instance) { string homeIdPart = string.Empty, homeId = platform.GetConfSetting("HomeId"); if (!string.IsNullOrEmpty(homeId)) homeIdPart = "/" + homeId; ServiceHost serviceHost = new ServiceHost(instance, new Uri(Constants.InfoServiceAddress + homeIdPart + "/" + authEndpoint)); var contract = ContractDescription.GetContract(typeof(IAuthenticationService)); var webBinding = new WebHttpBinding(); var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(new Uri(Constants.InfoServiceAddress + homeIdPart + "/" + authEndpoint))); webEndPoint.EndpointBehaviors.Add(new WebHttpBehavior()); serviceHost.AddServiceEndpoint(webEndPoint); return serviceHost; }
public static ServiceHost CreateServiceHost(VLogger logger, VPlatform platform, IAuthenticationService instance) { string homeIdPart = string.Empty, homeId = platform.GetConfSetting("HomeId"); if (!string.IsNullOrEmpty(homeId)) { homeIdPart = "/" + homeId; } ServiceHost serviceHost = new ServiceHost(instance, new Uri(Constants.InfoServiceAddress + homeIdPart + "/" + authEndpoint)); var contract = ContractDescription.GetContract(typeof(IAuthenticationService)); var webBinding = new WebHttpBinding(); var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(new Uri(Constants.InfoServiceAddress + homeIdPart + "/" + authEndpoint))); webEndPoint.EndpointBehaviors.Add(new WebHttpBehavior()); serviceHost.AddServiceEndpoint(webEndPoint); return(serviceHost); }
/// <summary> /// Called by the platform for initialize the module /// </summary> /// <param name="platform">A backwards pointer to the platform</param> /// <param name="logger">The default logging object</param> /// <param name="moduleInfo">ModuleInfo for the module</param> /// <param name="secret">Secret</param> public sealed override void Initialize(VPlatform platform, VLogger logger, VModuleInfo moduleInfo, int secret) { this.platform = platform; this.logger = logger; this.moduleInfo = moduleInfo; this.secret = secret; this.streamFactory = StreamFactory.Instance; this.safeToGoOnline = platform.SafeToGoOnline(); myPorts = new List <Port>(); defaultPortCapabilities = new Dictionary <Port, Capability>(); this.capabilityStore = new Dictionary <VPort, VCapability>(); InitPort(new PortInfo("ctrlport", moduleInfo)); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(LogUnhandledException); logger.Log("Initialized {0}", moduleInfo.ToString()); }
public PlatformV2C(VPlatform view) { _view = view; }
public static Tuple<bool, string> SendCloudEmail(string dst, string subject, string body, List<Attachment> attachmentList, VPlatform platform, VLogger logger) { string error = ""; logger.Log("Utils.SendCloudEmail called with " + dst + " " + subject + " " + body); string smtpServer = platform.GetPrivateConfSetting("SmtpServer"); string smtpUser = platform.GetPrivateConfSetting("SmtpUser"); string smtpPassword = platform.GetPrivateConfSetting("SmtpPassword"); Uri serviceHostUri = new Uri("https://" + platform.GetConfSetting("EmailServiceHost") + ":" + Shared.Constants.EmailServiceSecurePort + "/" + Shared.Constants.EmailServiceWcfEndPointUrlSuffix); string bodyLocal; CloudEmailer emailer = new CloudEmailer(serviceHostUri, smtpServer, smtpUser, smtpPassword, logger); if (string.IsNullOrWhiteSpace(body)) { bodyLocal = platform.GetPrivateConfSetting("NotificationEmail"); } else { bodyLocal = body; } Notification notification = BuildNotification(dst, subject, body, attachmentList); if (null == notification) { error = "Destination for the email not set"; logger.Log(error); return new Tuple<bool, string>(false, error); } return emailer.Send(notification); }
/// <summary> /// Send email from Hub. /// </summary> /// <param name="dst">to:</param> /// <param name="subject">subject</param> /// <param name="body">body of the message</param> /// <returns>A tuple with true/false success and string exception message (if any)</returns> public static Tuple<bool, string> SendHubEmail(string dst, string subject, string body, List<Attachment> attachmentList, VPlatform platform, VLogger logger) { string error = ""; logger.Log("Utils.SendHubEmail called with " + dst + " " + subject + " " + body); string smtpServer = platform.GetPrivateConfSetting("SmtpServer"); string smtpUser = platform.GetPrivateConfSetting("SmtpUser"); string smtpPassword = platform.GetPrivateConfSetting("SmtpPassword"); string bodyLocal; Emailer emailer = new Emailer(smtpServer, smtpUser, smtpPassword, logger); if (string.IsNullOrWhiteSpace(body)) { bodyLocal = platform.GetPrivateConfSetting("NotificationEmail"); } else { bodyLocal = body; } Notification notification = BuildNotification(dst, subject, body, attachmentList); if (null == notification) { error = "Destination for the email not set"; logger.Log(error); return new Tuple<bool, string>(false, error); } return emailer.Send(notification); }
/// <summary> /// Send email by trying to send from Hub first, if that fails, send using cloud relay. /// </summary> /// <param name="dst">to:</param> /// <param name="subject">subject</param> /// <param name="body">body of the message</param> /// <returns>A tuple with true/false success and string exception message (if any)</returns> public static Tuple<bool, string> SendEmail(string dst, string subject, string body, List<Attachment> attachmentList, VPlatform platform, VLogger logger) { logger.Log("Utils.SendEmail called with " + dst + " " + subject + " " + body); Tuple<bool, string> result = SendHubEmail(dst, subject, body, attachmentList, platform, logger); if (!result.Item1) { logger.Log("SendHubEmail failed with error={0}", result.Item2); result = SendCloudEmail(dst, subject, body, attachmentList, platform, logger); } return result; }
public static Tuple <bool, string> SendCloudEmail(string dst, string subject, string body, List <Attachment> attachmentList, VPlatform platform, VLogger logger) { string error = ""; logger.Log("Utils.SendCloudEmail called with " + dst + " " + subject + " " + body); string smtpServer = platform.GetPrivateConfSetting("SmtpServer"); string smtpUser = platform.GetPrivateConfSetting("SmtpUser"); string smtpPassword = platform.GetPrivateConfSetting("SmtpPassword"); Uri serviceHostUri = new Uri("https://" + platform.GetConfSetting("EmailServiceHost") + ":" + Shared.Constants.EmailServiceSecurePort + "/" + Shared.Constants.EmailServiceWcfEndPointUrlSuffix); string bodyLocal; CloudEmailer emailer = new CloudEmailer(serviceHostUri, smtpServer, smtpUser, smtpPassword, logger); if (string.IsNullOrWhiteSpace(body)) { bodyLocal = platform.GetPrivateConfSetting("NotificationEmail"); } else { bodyLocal = body; } Notification notification = BuildNotification(dst, subject, body, attachmentList); if (null == notification) { error = "Destination for the email not set"; logger.Log(error); return(new Tuple <bool, string>(false, error)); } return(emailer.Send(notification)); }
/// <summary> /// Send email from Hub. /// </summary> /// <param name="dst">to:</param> /// <param name="subject">subject</param> /// <param name="body">body of the message</param> /// <returns>A tuple with true/false success and string exception message (if any)</returns> public static Tuple <bool, string> SendHubEmail(string dst, string subject, string body, List <Attachment> attachmentList, VPlatform platform, VLogger logger) { string error = ""; logger.Log("Utils.SendHubEmail called with " + dst + " " + subject + " " + body); string smtpServer = platform.GetPrivateConfSetting("SmtpServer"); string smtpUser = platform.GetPrivateConfSetting("SmtpUser"); string smtpPassword = platform.GetPrivateConfSetting("SmtpPassword"); string bodyLocal; Emailer emailer = new Emailer(smtpServer, smtpUser, smtpPassword, logger); if (string.IsNullOrWhiteSpace(body)) { bodyLocal = platform.GetPrivateConfSetting("NotificationEmail"); } else { bodyLocal = body; } Notification notification = BuildNotification(dst, subject, body, attachmentList); if (null == notification) { error = "Destination for the email not set"; logger.Log(error); return(new Tuple <bool, string>(false, error)); } return(emailer.Send(notification)); }
/// <summary> /// Send email by trying to send from Hub first, if that fails, send using cloud relay. /// </summary> /// <param name="dst">to:</param> /// <param name="subject">subject</param> /// <param name="body">body of the message</param> /// <returns>A tuple with true/false success and string exception message (if any)</returns> public static Tuple <bool, string> SendEmail(string dst, string subject, string body, List <Attachment> attachmentList, VPlatform platform, VLogger logger) { logger.Log("Utils.SendEmail called with " + dst + " " + subject + " " + body); Tuple <bool, string> result = SendHubEmail(dst, subject, body, attachmentList, platform, logger); if (!result.Item1) { logger.Log("SendHubEmail failed with error={0}", result.Item2); result = SendCloudEmail(dst, subject, body, attachmentList, platform, logger); } return(result); }
internal static IPlatform V2C(VPlatform view) { if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(view) && (view.GetType().Equals(typeof(PlatformC2V)))) { return ((PlatformC2V)(view)).GetSourceContract(); } else { return new PlatformV2C(view); } }
public abstract void Initialize(VPlatform platform, VLogger logger, VModuleInfo info, int secret);