Class for dispatching changes to Kentico via REST.
상속: IDispatcher, IDisposable
예제 #1
0
        protected override void OnStart(string[] args)
        {
            mErrorsInARow = 0;

            // Deserialize configuration from XML
            try
            {
                var serializer = new XmlSerializer(typeof(ServiceConfiguration));

                using (var reader = new StreamReader(Environment.ExpandEnvironmentVariables(CONFIGURATION_PATH)))
                {
                    Configuration = (ServiceConfiguration)serializer.Deserialize(reader);
                }

                Sender            = new RestSender(Configuration.Rest, Logger);
                Sender.OnError   += Stop;
                Sender.OnSuccess += () => { mErrorsInARow = 0; };

                Dispatcher          = new ChangesDispatcher(Sender, Configuration.UserAttributesBindings, Configuration.GroupAttributesBindings, Logger);
                Dispatcher.OnError += OnListenerError;
            }
            catch (Exception ex)
            {
                Logger.LogError("Exception occured during configuration parsing.", ex);
            }

            StartListening();

            Logger.LogMessage("Listener Service has been successfully started.");
        }
예제 #2
0
        /// <summary>
        /// Basic constructor for change notifications listener.
        /// </summary>
        /// <param name="dispatcher">Changes dispatcher</param>
        /// <param name="configuration">Listener configuration</param>
        /// <param name="logger">Logger</param>
        public ChangeNotificationsListener(ChangesDispatcher dispatcher, ListenerConfiguration configuration, Logger logger)
        {
            Configuration = configuration;
            Logger        = logger;

            Dispatcher = dispatcher;
            Dispatcher.DispatchAllowed = true;

            if (Configuration.UseSsl)
            {
                if (!File.Exists(Configuration.SslCertificateLocation))
                {
                    throw new ArgumentException("Provided path to certificate doesn't exist.");
                }

                // Load certificate
                Certificate = X509Certificate.CreateFromCertFile(Configuration.SslCertificateLocation);
            }
        }
        protected override void OnStart(string[] args)
        {
            mErrorsInARow = 0;

            // Deserialize configuration from XML
            try
            {
                var serializer = new XmlSerializer(typeof(ServiceConfiguration));

                using (var reader = new StreamReader(Environment.ExpandEnvironmentVariables(CONFIGURATION_PATH)))
                {
                    Configuration = (ServiceConfiguration)serializer.Deserialize(reader);
                }

                Sender = new RestSender(Configuration.Rest, Logger);
                Sender.OnError += Stop;
                Sender.OnSuccess += () => { mErrorsInARow = 0; };

                Dispatcher = new ChangesDispatcher(Sender, Configuration.UserAttributesBindings, Configuration.GroupAttributesBindings, Logger);
                Dispatcher.OnError += OnListenerError;
            }
            catch (Exception ex)
            {
                Logger.LogError("Exception occured during configuration parsing.", ex);
            }

            StartListening();

            Logger.LogMessage("Listener Service has been successfully started.");
        }
        /// <summary>
        /// Basic constructor for change notifications listener.
        /// </summary>
        /// <param name="dispatcher">Changes dispatcher</param>
        /// <param name="configuration">Listener configuration</param>
        /// <param name="logger">Logger</param>
        public ChangeNotificationsListener(ChangesDispatcher dispatcher, ListenerConfiguration configuration, Logger logger)
        {
            Configuration = configuration;
            Logger = logger;

            Dispatcher = dispatcher;
            Dispatcher.DispatchAllowed = true;

            if (Configuration.UseSsl)
            {
                if (!File.Exists(Configuration.SslCertificateLocation))
                {
                    throw new ArgumentException("Provided path to certificate doesn't exist.");
                }

                // Load certificate
                Certificate = X509Certificate.CreateFromCertFile(Configuration.SslCertificateLocation);
            }
        }