Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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);
        }
Exemplo n.º 5
0
        /// <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());
        }
Exemplo n.º 6
0
 public PlatformV2C(VPlatform view)
 {
     _view = view;
 }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <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;
        }
Exemplo n.º 10
0
 public PlatformV2C(VPlatform view)
 {
     _view = view;
 }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
        /// <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));
        }
Exemplo n.º 13
0
        /// <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);
        }
Exemplo n.º 14
0
 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);
     }
 }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
 public abstract void Initialize(VPlatform platform, VLogger logger, VModuleInfo info, int secret);
Exemplo n.º 17
0
 public abstract void Initialize(VPlatform platform, VLogger logger, VModuleInfo info, int secret);