Beispiel #1
0
        /// <summary>
        /// Make sure that overriding classes call this!
        /// Registers the Crestron device, connects up to the base events, starts communication monitor
        /// </summary>
        public override bool CustomActivate()
        {
            Debug.Console(0, this, "Activating");
            if (!PreventRegistration)
            {
                //Debug.Console(1, this, "  Does not require registration. Skipping");

                var response = Hardware.RegisterWithLogging(Key);
                if (response != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
                    return(false);
                }

                IsRegistered.FireUpdate();
            }

            foreach (var f in Feedbacks)
            {
                f.FireUpdate();
            }

            Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
            CommunicationMonitor.Start();

            return(true);
        }
Beispiel #2
0
        public Container ShopsContainer()
        {
            if (_shopsContainer != null)
            {
                return(_shopsContainer);
            }

            _shopsContainer = new Container(new Uri(Program.ShopsServiceUri))
            {
                MergeOption = MergeOption.OverwriteChanges,
                DisableInstanceAnnotationMaterialization = true
            };

            _shopsContainer.BuildingRequest += (s, e) =>
            {
                e.Headers.Add("ShopName", Shop);
                e.Headers.Add("ShopperId", ShopperId);
                e.Headers.Add("CustomerId", CustomerId);
                e.Headers.Add("Language", Language);
                e.Headers.Add("Currency", Currency);
                e.Headers.Add("Environment", Environment);
                e.Headers.Add("PolicyKeys", PolicyKeys);
                e.Headers.Add("EffectiveDate", EffectiveDate.ToString());
                e.Headers.Add("IsRegistered", IsRegistered.ToString());
                e.Headers.Add("Authorization", Program.SitecoreToken);
            };
            return(_shopsContainer);
        }
Beispiel #3
0
        /// <summary>
        /// This disconnects events and unregisters the base hardware device.
        /// </summary>
        /// <returns></returns>
        public override bool Deactivate()
        {
            CommunicationMonitor.Stop();
            Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange;

            var success = Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;

            IsRegistered.FireUpdate();

            return(success);
        }