Esempio n. 1
0
        public bool RoutePropertyBeforeChangeEvent(object eventData)
        {
            var    moduleEvent   = (RoutedEvent)eventData;
            var    moduleHelper  = new Automation.Scripting.ModuleHelper(homegenie, moduleEvent.Module);
            string originalValue = moduleEvent.Parameter.Value;

            for (int p = 0; p < Programs.Count; p++)
            {
                var program = Programs[p];
                if (!program.IsEnabled)
                {
                    continue;
                }
                if ((moduleEvent.Sender == null || !moduleEvent.Sender.Equals(program.Address)))
                {
                    if (program.Engine.ModuleIsChangingHandler != null)
                    {
                        bool handled = !program.Engine.ModuleIsChangingHandler(moduleHelper, moduleEvent.Parameter);
                        if (handled)
                        {
                            // stop routing event if "false" is returned
                            MigService.Log.Debug("Event propagation halted by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                            return(false);
                        }
                        else if (moduleEvent.Parameter.Value != originalValue)
                        {
                            // If manipulated, the event is not routed anymore.
                            MigService.Log.Debug("Event propagation halted - parameter manipulated by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
        public bool RoutePropertyBeforeChangeEvent(object eventData)
        {
            var moduleEvent  = (RoutedEvent)eventData;
            var moduleHelper = new Automation.Scripting.ModuleHelper(hgService, moduleEvent.Module);
            var param        = moduleEvent.Parameter.DeepClone();

            for (int p = 0; p < Programs.Count; p++)
            {
                var program = Programs[p];
                if (!program.IsEnabled)
                {
                    continue;
                }
                if ((moduleEvent.Sender == null || !moduleEvent.Sender.Equals(program.Address)))
                {
                    if (program.Engine.ModuleIsChangingHandler != null)
                    {
                        bool handled = !program.Engine.ModuleIsChangingHandler(moduleHelper, param);
                        if (handled)
                        {
                            // stop routing event if "false" is returned
                            MigService.Log.Debug("Event propagation halted by automation program '{0}' ({1}) (Name={2})", program.Name, program.Address, param.Name);
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 3
0
        public void RoutePropertyChangedEvent(object eventData)
        {
            var    moduleEvent   = (RoutedEvent)eventData;
            var    moduleHelper  = new Automation.Scripting.ModuleHelper(homegenie, moduleEvent.Module);
            string originalValue = moduleEvent.Parameter.Value;

            for (int p = 0; p < Programs.Count; p++)
            {
                var program = Programs[p];
                if (program == null || !program.IsEnabled || !isEngineEnabled)
                {
                    continue;
                }
                if ((moduleEvent.Sender == null || !moduleEvent.Sender.Equals(program)))
                {
                    try
                    {
                        program.Engine.RoutedEventAck.Set();
                        if (program.Engine.ModuleChangedHandler != null && moduleEvent.Parameter != null) // && proceed)
                        {
                            bool handled = !program.Engine.ModuleChangedHandler(moduleHelper, moduleEvent.Parameter);
                            if (handled)
                            {
                                // stop routing event if "false" is returned
                                MigService.Log.Debug("Event propagation halted by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                                break;
                            }
                            else if (moduleEvent.Parameter.Value != originalValue)
                            {
                                // If manipulated, the event is not routed anymore.
                                MigService.Log.Debug("Event propagation halted - parameter manipulated by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                                break;
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        HomeGenieService.LogError(
                            program.Domain,
                            program.Address.ToString(),
                            ex.Message,
                            "Exception.StackTrace",
                            ex.StackTrace
                            );
                    }
                }
            }
        }
Esempio n. 4
0
 public void RoutePropertyChangedEvent(object eventData)
 {
     var moduleEvent = (RoutedEvent)eventData;
     var moduleHelper = new Automation.Scripting.ModuleHelper(homegenie, moduleEvent.Module);
     string originalValue = moduleEvent.Parameter.Value;
     for (int p = 0; p < Programs.Count; p++)
     {
         var program = Programs[p];
         if (program == null || !program.IsEnabled) continue;
         if ((moduleEvent.Sender == null || !moduleEvent.Sender.Equals(program)))
         {
             try
             {
                 if (program.Engine.ModuleChangedHandler != null && moduleEvent.Parameter != null) // && proceed)
                 {
                     bool handled = !program.Engine.ModuleChangedHandler(moduleHelper, moduleEvent.Parameter);
                     if (handled)
                     {
                         // stop routing event if "false" is returned
                         MigService.Log.Debug("Event propagation halted by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                         break;
                     }
                     else if (moduleEvent.Parameter.Value != originalValue)
                     {
                         // If manipulated, the event is not routed anymore.
                         MigService.Log.Debug("Event propagation halted - parameter manipulated by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                         break;
                     }
                 }
             }
             catch (System.Exception ex)
             {
                 HomeGenieService.LogError(
                     program.Domain,
                     program.Address.ToString(),
                     ex.Message,
                     "Exception.StackTrace",
                     ex.StackTrace
                 );
             }
         }
     }
 }
Esempio n. 5
0
 public bool RoutePropertyBeforeChangeEvent(object eventData)
 {
     var moduleEvent = (RoutedEvent)eventData;
     var moduleHelper = new Automation.Scripting.ModuleHelper(homegenie, moduleEvent.Module);
     string originalValue = moduleEvent.Parameter.Value;
     for (int p = 0; p < Programs.Count; p++)
     {
         var program = Programs[p];
         if (!program.IsEnabled) continue;
         if ((moduleEvent.Sender == null || !moduleEvent.Sender.Equals(program.Address)))
         {
             program.Engine.RoutedEventAck.Set();
             if (program.Engine.ModuleIsChangingHandler != null)
             {
                 bool handled = !program.Engine.ModuleIsChangingHandler(moduleHelper, moduleEvent.Parameter);
                 if (handled)
                 {
                     // stop routing event if "false" is returned
                     MigService.Log.Debug("Event propagation halted by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                     return false;
                 }
                 else  if (moduleEvent.Parameter.Value != originalValue)
                 {
                     // If manipulated, the event is not routed anymore.
                     MigService.Log.Debug("Event propagation halted - parameter manipulated by automation program '{0}' ({1}) (Name={2}, OldValue={3}, NewValue={4})", program.Name, program.Address, moduleEvent.Parameter.Name, originalValue, moduleEvent.Parameter.Value);
                     return false;
                 }
             }
         }
     }
     return true;
 }