Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     car_         = GetComponent <Car>();
     body_        = GetComponent <Rigidbody>();
     vision_      = GetComponent <Vision>();
     eventSender_ = GetComponent <EventSender>();
 }
Ejemplo n.º 2
0
        public void SendRequiresEvents()
        {
            var transportSender = new ObservableTransportSenderMock();
            var sender          = new EventSender(transportSender, "dummy", new EventSenderOptions());

            Assert.That(async() => await sender.SendAsync(null, new EventBatchingOptions()), Throws.ArgumentNullException);
        }
Ejemplo n.º 3
0
        public static XmlDocument SendEvent(EventSender sender, String xml)
        {
            XmlDocument simpleDoc = GetDocument(xml);

            sender.SendEvent(simpleDoc);
            return(simpleDoc);
        }
 public void SetUp()
 {
     DynaLatencySpikeMonitor.Start();
     _runtime = EPRuntimeProvider.GetDefaultRuntime();
     _senderOperationalMeasurement = _runtime.EventService.GetEventSender(typeof(OperationMeasurement).FullName);
     _senderLatencyLimit           = _runtime.EventService.GetEventSender(typeof(LatencyLimit).FullName);
 }
Ejemplo n.º 5
0
        public void TestObservationExamplePropertyExpression()
        {
            ConfigurationEventTypeXMLDOM typecfg = new ConfigurationEventTypeXMLDOM();

            typecfg.RootElementName = "Sensor";
            String schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString();

            typecfg.SchemaResource = schemaUri;

            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.EngineDefaults.ViewResourcesConfig.IsIterableUnbound = true;
            configuration.AddEventType("SensorEvent", typecfg);

            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            String stmtExampleOneText = "select ID, Observation.Command, Observation.ID,\n" +
                                        "Observation.Tag[0].ID, Observation.Tag[1].ID\n" +
                                        "from SensorEvent";
            EPStatement stmtExampleOne = _epService.EPAdministrator.CreateEPL(stmtExampleOneText);

            EPStatement stmtExampleTwo_0 = _epService.EPAdministrator.CreateEPL("insert into ObservationStream\n" +
                                                                                "select ID, Observation from SensorEvent");
            EPStatement stmtExampleTwo_1 = _epService.EPAdministrator.CreateEPL("select Observation.Command, Observation.Tag[0].ID from ObservationStream");

            EPStatement stmtExampleThree_0 = _epService.EPAdministrator.CreateEPL("insert into TagListStream\n" +
                                                                                  "select ID as sensorId, Observation.* from SensorEvent");
            EPStatement stmtExampleThree_1 = _epService.EPAdministrator.CreateEPL("select sensorId, Command, Tag[0].ID from TagListStream");

            XmlDocument doc    = SupportXML.GetDocument(XML);
            EventSender sender = _epService.EPRuntime.GetEventSender("SensorEvent");

            sender.SendEvent(doc);

            EventTypeAssertionUtil.AssertConsistency(stmtExampleOne.First());
            EventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_0.First());
            EventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_1.First());
            EventTypeAssertionUtil.AssertConsistency(stmtExampleThree_0.First());
            EventTypeAssertionUtil.AssertConsistency(stmtExampleThree_1.First());

            EPAssertionUtil.AssertProps(stmtExampleTwo_1.First(), "Observation.Command,Observation.Tag[0].ID".Split(','), new Object[] { "READ_PALLET_TAGS_ONLY", "urn:epc:1:2.24.400" });
            EPAssertionUtil.AssertProps(stmtExampleThree_1.First(), "sensorId,Command,Tag[0].ID".Split(','), new Object[] { "urn:epc:1:4.16.36", "READ_PALLET_TAGS_ONLY", "urn:epc:1:2.24.400" });

            try {
                _epService.EPAdministrator.CreateEPL("select Observation.Tag.ID from SensorEvent");
                Assert.Fail();
            } catch (EPStatementException ex) {
                Assert.AreEqual("Error starting statement: Failed to validate select-clause expression 'Observation.Tag.ID': Failed to resolve property 'Observation.Tag.ID' to a stream or nested property in a stream [select Observation.Tag.ID from SensorEvent]", ex.Message);
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Ejemplo n.º 6
0
        public void OnGUI()
        {
            eventName = EditorGUILayout.TextField("Event Name", eventName);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Event Type", GUILayout.Width(145));
            eventTypeIndex = EditorGUILayout.Popup(eventTypeIndex, MyEventType.typeList.ToArray());
            EditorGUILayout.EndHorizontal();

            DrawValueProperty(typeIndex);

            if (GUILayout.Button("Send Event"))
            {
                var    eventData = TypeUtils.ChangeType(value, MyPreferredType.Find(typeIndex));
                string eventKey  = MyEventType.typeList[eventTypeIndex];
                string eventType = MyEventType.typeDict[eventKey];

                if (string.Equals("Default", eventType))
                {
                    EventSender.SendGlobalEvent(eventName, eventData);
                }
                else
                {
                    EventSender.Dispatch(eventType, eventName, eventData);
                }
            }
        }
Ejemplo n.º 7
0
        public void ShouldSendBinary()
        {
            var    serializer = new JsonSerializer();
            Guid   eventId    = Guid.NewGuid();
            string eventName  = "Binary";

            byte[] message            = new byte[] { 1, 2, 3 };
            var    metaData           = new List <KeyValue>();
            string serializedMetaData = serializer.Serialize(metaData);
            string to   = "Bob";
            var    info = new EventInfo(eventName, to, string.Empty);

            Func <string, object, object, object, object, Guid> action = (serverAction, o1, o2, o3, o4) => {
                Assert.Equal(EventNames.SendBinaryTo, serverAction);
                Assert.Equal(eventName, o1);
                Assert.Equal(info.To, o2);
                Assert.Equal(serializedMetaData, o3);
                Assert.Equal(message, o4);
                return(eventId);
            };

            ConnectionMock connection = new ConnectionMock(action);
            EventSender    sender     = new EventSender(connection, serializer);

            Task <Guid> id = sender.Binary(info, message);

            id = sender.Binary(info, new BinaryMessage(message, metaData));
            id = sender.Binary(info, new BinaryMessage(message, metaData), serializer);

            Assert.Equal(eventId, id.GetAwaiter().GetResult());
        }
        internal static void setEnabled(Boolean enabled)
        {
            if (enabled && !isEnabled)
            {
                //Read events from storage
                eventsList = EventStorage.getEvents();

                if (eventsList.Count > 0)
                {
                    sendNextEvent();
                }

                isEnabled = true;
            }
            else if (!enabled && isEnabled)
            {
                //Stop current eventSender
                if (eventSender != null)
                {
                    eventSender.cancel();
                    eventSender = null;
                }

                //Store events to storage
                EventStorage.storeEvents(eventsList);
                eventsList = null;

                isEnabled = false;
            }
        }
        private void RunAssertionStatementNameExists(EPServiceProvider epService, string typeName, object[] events)
        {
            epService.EPAdministrator.CreateEPL("@Name('MyStatement') select * from " + typeName);

            epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " +
                                                "create schema AllObject System.Object," +
                                                "EPStatementSource -> thedata<AllObject> {" +
                                                "  statementName : 'MyStatement'," +
                                                "} " +
                                                "DefaultSupportCaptureOp(thedata) {}");

            var captureOp = new DefaultSupportCaptureOp(2, SupportContainer.Instance.LockManager());
            var options   = new EPDataFlowInstantiationOptions()
                            .OperatorProvider(new DefaultSupportGraphOpProvider(captureOp));

            EPDataFlowInstance df = epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options);

            df.Start();

            EventSender sender = epService.EPRuntime.GetEventSender(typeName);

            foreach (Object @event in events)
            {
                sender.SendEvent(@event);
            }

            captureOp.GetValue(1, TimeUnit.SECONDS);
            EPAssertionUtil.AssertEqualsExactOrder(events, captureOp.Current);

            df.Cancel();
            epService.EPAdministrator.DestroyAllStatements();
        }
Ejemplo n.º 10
0
        public override void Run(EPServiceProvider epService)
        {
            string      stmtText = "select type?,dyn[1]?,nested.nes2?,map('a')? from MyEvent";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(stmtText);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false),
                new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false),
                new EventPropertyDescriptor("nested.nes2?", typeof(XmlNode), null, false, false, false, false, false),
                new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false),
            }, stmt.EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(stmt.EventType);

            EventSender sender = epService.EPRuntime.GetEventSender("MyEvent");
            XmlDocument root   = SupportXML.SendEvent(sender, SCHEMA_XML);

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?"));
            SupportEventTypeAssertionUtil.AssertConsistency(theEvent);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Start the polling process.
        /// </summary>
        public void Start()
        {
            if (visitedFolders.Count != 0)
            {//if it gets here - a folder is opened
                if (!visitedFolders.Peek().Equals(folder.LocationURL))
                {
                    visitedFolders.Push(folder.LocationURL);

                    String message = ResourceIdentifiers.FOLDER_IDENTIFIER + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                     + folder.LocationName + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                     + folder.LocationURL + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                     + FolderMonitor.FOLDER_VIEW + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                     + DateTime.Now;

                    EventSender.GetInstance().ProcessMessage(message);
                }
            }
            else
            {//can get here once - at folder start up
                visitedFolders.Push(folder.LocationURL);

                String message = ResourceIdentifiers.FOLDER_IDENTIFIER + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                 + folder.LocationName + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                 + folder.LocationURL + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                 + FolderMonitor.FOLDER_VIEW + Constants.SPACE + Constants.SPLITTER + Constants.SPACE
                                 + DateTime.Now;


                EventSender.GetInstance().ProcessMessage(message);
            }
        }
Ejemplo n.º 12
0
 private static async void RunSender(EventSender eventSender, ConcurrentQueue <StoreEvent> sendQueue)
 {
     while (sendQueue.TryDequeue(out var message))
     {
         await eventSender.SendMessage(message);
     }
 }
Ejemplo n.º 13
0
 public StoreControllerBase(EventReceiver receiver, EventSender eventProcessor, StoreError storeError, ILogger <StoreControllerBase> logger)
 {
     _receiver       = receiver;
     _eventProcessor = eventProcessor;
     _storeError     = storeError;
     _logger         = logger;
 }
Ejemplo n.º 14
0
        public void TestSenderPONO()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddEventType("SupportBean", typeof(SupportBean));
            configuration.AddEventType("Marker", typeof(SupportMarkerInterface));

            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            // type resolved for each by the first event representation picking both up, i.e. the one with "r2" since that is the most specific URI
            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from SupportBean");

            stmt.Events += _listener.Update;

            // send right event
            EventSender sender      = _epService.EPRuntime.GetEventSender("SupportBean");
            Object      supportBean = new SupportBean();

            sender.SendEvent(supportBean);
            Assert.AreSame(supportBean, _listener.AssertOneGetNewAndReset().Underlying);

            // send wrong event
            try
            {
                sender.SendEvent(new SupportBean_G("G1"));
                Assert.Fail();
            }
            catch (EPException ex)
            {
                Assert.AreEqual(
                    "Event object of type com.espertech.esper.support.bean.SupportBean_G does not equal, extend or implement the type com.espertech.esper.support.bean.SupportBean of event type 'SupportBean'",
                    ex.Message);
            }

            // test an interface
            sender = _epService.EPRuntime.GetEventSender("Marker");
            stmt.Dispose();
            stmt         = _epService.EPAdministrator.CreateEPL("select * from Marker");
            stmt.Events += _listener.Update;
            var implA = new SupportMarkerImplA("Q2");

            sender.SendEvent(implA);
            Assert.AreSame(implA, _listener.AssertOneGetNewAndReset().Underlying);
            var implB = new SupportBean_G("Q3");

            sender.SendEvent(implB);
            Assert.AreSame(implB, _listener.AssertOneGetNewAndReset().Underlying);
            sender.SendEvent(implB);
            Assert.AreSame(implB, _listener.AssertOneGetNewAndReset().Underlying);

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Ejemplo n.º 15
0
    void SpecifiedAreaClick(GameObject btn)
    {
        if (!Core.Data.guideManger.CanClickGuideUI)
        {
            return;
        }
        //Debug.LogError("SpecifiedAreaClick");
        if (curClickType == ClickType.SpecifiedArea)
        {
            GuideData task = Core.Data.guideManger.CurTask;
            if (task != null && task.ID > 0)
            {
                task.MultiIndex = btn.name == "GuideMask" ? 0:System.Convert.ToInt32(btn.name);
                //GuideTouchEnable = false;
                EventSender.SendEvent((EventTypeDefine)task.TaskID, task);

                Core.Data.guideManger.AutoSendMsgAtLastTask();
            }
            if (task != null && task.AutoNext == 0)
            {
//				if(Core.Data.guideManger.LastTaskID == 300017)
//					Invoke("AfterAutoRun",0.5f);
//				else
                Core.Data.guideManger.AutoRUN();
            }
        }
        else
        {
            AnyAreaClick(btn);
        }
    }
Ejemplo n.º 16
0
        /// <summary>
        /// Event handler used to constantly retrieve messages from the MSMQ.
        /// </summary>
        /// <param name="sender">the sender object</param>
        /// <param name="e">the event arguments</param>
        private void queue_ReceiveCompleted(object sender, ReceiveCompletedEventArgs e)
        {
            //recieve the messages..
            Message m = queue.EndReceive(e.AsyncResult);

            m.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });

            String receivedMessage = (string)m.Body;

            String[] splittedMessage = receivedMessage.Split('|');
            if (splittedMessage[0].Equals("OUTLOOK"))
            {
                EmailMonitor.GetInstance().ProcessEmailEvent(receivedMessage);
            }
            else
            {
                MSOFFICEFileWatcher.GetInstance().FileViewed(receivedMessage);
            }

            //once get them - send to them to consuming client
            EventSender.GetInstance().ProcessMessage((string)m.Body);

            //recieve again
            StartReceivingMessages();
        }
Ejemplo n.º 17
0
        public async Task <TokenResponseModel> Authenticate([FromBody] TokenRequestModel request)
        {
            var user = await Store.PasswordVerifyAsync(request.Identifier, request.Password);

            if (user != null)
            {
                await EventSender.SendAsync(new UserAuthenticated
                {
                    UserIdentifierTopic = request.Identifier
                });

                SecurityContext.AssumeUser(user);

                return(new TokenResponseModel
                {
                    Token = JWT.CreateUserToken(user, request.ClientClaims),
                    User = user,
                    Organization = await OrganizationStore.GetOneAsync(request.Identifier)
                });
            }
            else
            {
                throw new SecurityException();
            }
        }
Ejemplo n.º 18
0
 void AnyAreaClick(GameObject btn)
 {
     if (!Core.Data.guideManger.CanClickGuideUI)
     {
         return;
     }
     //Debug.LogError("AnyAreaClick");
     if (curClickType == ClickType.AnyArea)
     {
         GuideData task = Core.Data.guideManger.CurTask;
         if (task != null && task.ID > 0)
         {
             //GuideTouchEnable = false;
             EventSender.SendEvent((EventTypeDefine)task.TaskID, task);
             Core.Data.guideManger.AutoSendMsgAtLastTask();
         }
         if (task.AutoNext == 0)
         {
             Core.Data.guideManger.AutoRUN();
         }
         else
         {
             //如果是缘引导触发
             if (task != null && task.ID == -1)
             {
                 //GuideTouchEnable = false;
                 EventSender.SendEvent((EventTypeDefine)task.TaskID, task);
                 DestoryGuide();
             }
         }
     }
 }
Ejemplo n.º 19
0
        private DeviceEvent FillingChanged(float oldValue, float newValue, EventSender sender)
        {
            if (newValue != 0.0 && newValue != 1.0)
                return null;

            var result = new DeviceEvent
            {
                DeviceId = Id,
                Time = DateTime.Now,
                Sender = sender,
                Arguments = null
            };

            if (newValue == 0.0)
            {
                result.Type = DeviceEventType.TankEmpty;
                result.Notification = EventNotification.Warning;
            }
            else if (newValue == 1.0)
            {
                result.Type = DeviceEventType.TankFull;
                result.Notification = EventNotification.Success;
            }
            return result;
        }
        internal static void setEnabled(Boolean enabled)
        {
            if (enabled && !isEnabled)
            {
                //Read events from storage
                eventsList = EventStorage.getEvents();

                if (eventsList.Count > 0)
                {
                    sendNextEvent();
                }

                isEnabled = true;
            }
            else if (!enabled && isEnabled)
            {
                //Stop current eventSender
                if (eventSender != null)
                {
                    eventSender.cancel();
                    eventSender = null;
                }

                //Store events to storage
                EventStorage.storeEvents(eventsList);
                eventsList = null;

                isEnabled = false;
            }
        }
        public static void SendSecondEventEvent(this EventSender <SpatialOSBlittableComponent> eventSender,
                                                global::Generated.Improbable.Gdk.Tests.BlittableTypes.SecondEventPayload eventData)
        {
            var translation = BlittableComponent.Translation.GetTranslation(eventSender.InternalHandleToTranslation);

            translation.EntityIdToSecondEventEvents[eventSender.EntityId].Add(eventData);
        }
        public void Initialize()
        {
            if (_isInitialized)
            {
                return;
            }

            //NOTE This call internally depend on libraries
            //will throw an error if NEsper libs not found
            EPServiceProviderManager.PurgeDefaultProvider();
            var cfg      = new Configuration();
            var evConfig = new ConfigurationEventTypeLegacy();

            evConfig.PropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE;
            cfg.AddEventType <ActivityEvent>(typeof(ActivityEvent).Name, evConfig);
            cfg.EngineDefaults.Threading.IsInternalTimerEnabled            = true;
            cfg.EngineDefaults.Threading.IsInsertIntoDispatchPreserveOrder = false;
            cfg.EngineDefaults.Threading.IsListenerDispatchPreserveOrder   = false;
            cfg.EngineDefaults.Logging.IsEnableExecutionDebug = false;
            cfg.EngineDefaults.Logging.IsEnableADO            = false;
            cfg.EngineDefaults.Logging.IsEnableQueryPlan      = false;
            cfg.EngineDefaults.Logging.IsEnableTimerDebug     = false;
            cfg.EngineDefaults.ViewResources.IsShareViews     = false;
            cfg.AddImport <StringUtil>();

            _engine = EPServiceProviderManager.GetDefaultProvider(cfg);
            _engine.StatementStateChange += OnStatementChanged;

            _activityEventSender = _engine.EPRuntime.GetEventSender(typeof(ActivityEvent).Name);
            _isInitialized       = true;
        }
Ejemplo n.º 23
0
    static int SendEvent(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        Type[] types1 = { typeof(string) };

        if (count == 1)
        {
            string arg0 = LuaScriptMgr.GetLuaString(L, 1);
            EventSender.SendEvent(arg0);
            return(0);
        }
        else if (LuaScriptMgr.CheckTypes(L, types1, 1) && LuaScriptMgr.CheckParamsType(L, typeof(object), 2, count - 1))
        {
            string   arg0  = LuaScriptMgr.GetString(L, 1);
            object[] objs1 = LuaScriptMgr.GetParamsObject(L, 2, count - 1);
            EventSender.SendEvent(arg0, objs1);
            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: EventSender.SendEvent");
        }

        return(0);
    }
Ejemplo n.º 24
0
 public SendAssertPair(
     EventSender sender,
     Asserter<object> asserter)
 {
     Sender = sender;
     Asserter = asserter;
 }
Ejemplo n.º 25
0
        public void ShouldSendString()
        {
            var    serializer         = new JsonSerializer();
            Guid   eventId            = Guid.NewGuid();
            string eventName          = "Chat";
            string message            = "Hola";
            var    metaData           = new List <KeyValue>();
            string serializedMetaData = serializer.Serialize(metaData);
            string to   = "Bob";
            var    info = new EventInfo(eventName, to, string.Empty);
            Action <object, string> onMetaSerialized = (cSharpObj, json) => {
                Assert.Equal(serializedMetaData, json);
                Assert.True(cSharpObj is List <KeyValue>);
            };
            var metaSerializer = new SerializationMock(onMetaSerialized);

            Func <string, object, object, object, object, Guid> action = (serverAction, o1, o2, o3, o4) => {
                Assert.Equal(EventNames.SendStringTo, serverAction);
                Assert.Equal(eventName, o1);
                Assert.Equal(info.To, o2);
                Assert.Equal(serializedMetaData, o3);
                Assert.Equal(message, o4);
                return(eventId);
            };

            ConnectionMock connection = new ConnectionMock(action);
            EventSender    sender     = new EventSender(connection, metaSerializer);

            Task <Guid> id = sender.String(info, message);

            id = sender.String(info, new StringMessage(message, metaData));
            id = sender.String(info, new StringMessage(message, metaData), metaSerializer);

            Assert.Equal(eventId, id.GetAwaiter().GetResult());
        }
Ejemplo n.º 26
0
        public void ChangeSystemMode(IEventMetadata eventMetadata, IEventStore eventStore,
                                     SystemModeChangeCommand cmd, long orginalEventNumber)
        {
            ValidateSystemMode(cmd.NewSystemMode);
            ValidateEventNumber(orginalEventNumber);
            ValidateCategory(eventMetadata.Category);

            var changeSystemModeCommand = new ChangeSystemMode(eventStore, cmd.ThermostatId,
                                                               cmd.ThermostatGuid, cmd.TenantId, cmd.NewSystemMode);
            var commandBus = CommandBus.Instance;

            commandBus.Execute(changeSystemModeCommand);

            ApplyEvent(new SystemModeChanged(cmd.ThermostatGuid, DateTimeOffset.UtcNow, eventMetadata,
                                             cmd.NewSystemMode), -4);

            // Send Event to Event Store
            var events = this.GetUncommittedEvents();

            try
            {
                EventSender.SendEvent(eventStore, new CompositeAggregateId(eventMetadata.TenantId, AggregateGuid, eventMetadata.Category), events);
            }
            catch (ConnectionFailure conn)
            {
                Trace.TraceError($"There was a connection error: {conn}");
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Entry method.
        /// </summary>
        /// <param name="args">arguments</param>
        public static void Main(string[] args)
        {
            COMReceiver.GetInstance().DeleteAllMessages();

            EventSender.GetInstance().StartConnection(ServerInformation.LOCAL_HOST, ServerInformation.DEFAULT_PORT);

            /* Get input from COM */
            COMReceiver.GetInstance().StartReceivingMessages();

            /* Get WebPage URL from IE */
            WebPageWatcher.GetInstance().StartMonitoring();

            /* Monitors files */
            //GeneralFileWatcher.GetInstance().Start();
            FileMonitor.GetInstance().StartMonitoring();

            /* Monitors Apps/Programs */
            ProgramWatcher.GetInstance().StartMonitoring();

            /* Monitors Folder/Directories */
            FolderMonitor.GetInstance().StartMonitoring();

            // Monitor emails
            EmailMonitor.GetInstance().StartMonitoring();

            while (active)
            {
                // runs indefinitely until terminated by user via task manager
            }
        }
Ejemplo n.º 28
0
        public static void EvanEventEntry()
        {
            EventSender   se = new EventSender();
            EventReceiver rs = new EventReceiver();

            se.evanEvent += rs.EventCount;
            se.OnevanEvent(32);
        }
Ejemplo n.º 29
0
 public static XmlDocument SendEvent(
     EventSender sender,
     string xml)
 {
     var simpleDoc = GetDocument(xml);
     sender.SendEvent(simpleDoc);
     return simpleDoc;
 }
        internal static void onEventFailed(object sender, EventSender.EventSenderArgs e)
        {
            Utils.log("onEventFailed(): " + e.theEvent.name);

            eventSender = null;

            sendNextEvent();
        }
Ejemplo n.º 31
0
 // Use this for initialization
 void Start()
 {
     car_         = GetComponent <Car>();
     body_        = GetComponent <Rigidbody>();
     eventSender_ = GetComponent <EventSender>();
     error_       = GetComponent <Error>();
     purpose_     = GetComponent <Purpose>();
 }
Ejemplo n.º 32
0
    static int Registere(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        BaseLua arg0 = LuaScriptMgr.GetNetObject <BaseLua>(L, 1);
        bool    o    = EventSender.Registere(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Ejemplo n.º 33
0
        public override DeviceEvent GenerateDeviceEvent(string changedProperty, object oldValue, object newValue, EventSender sender)
        {
            switch (changedProperty)
            {
                case nameof(MailPresent):
                    return MailPresentChanged((bool)oldValue, (bool)newValue, sender);

                default:
                    return base.GenerateDeviceEvent(changedProperty, oldValue, newValue, sender);
            }
        }
Ejemplo n.º 34
0
        public override DeviceEvent GenerateDeviceEvent(string changedProperty, object oldValue, object newValue, EventSender sender)
        {
            switch (changedProperty)
            {
                case nameof(Filling):
                    return FillingChanged((float)oldValue, (float)newValue, sender);

                default:
                    return base.GenerateDeviceEvent(changedProperty, oldValue, newValue, sender);
            }
        }
Ejemplo n.º 35
0
        private DeviceEvent MailPresentChanged(bool oldValue, bool newValue, EventSender sender)
        {
            var result = new DeviceEvent
            {
                DeviceId = Id,
                Time = DateTime.Now,
                Sender = sender,
                Arguments = null
            };

            result.Type = newValue ?
                DeviceEventType.NewMail :
                DeviceEventType.MailBoxEmpty;

            result.Notification = newValue ?
                EventNotification.Information :
                EventNotification.Hidden;

            return result;
        }
Ejemplo n.º 36
0
        private DeviceEvent TemperatureChanged(int oldValue, int newValue, EventSender sender)
        {
            var result = new DeviceEvent
            {
                DeviceId = Id,
                Time = DateTime.Now,
                Sender = sender,
                Arguments = new [] { oldValue.ToString(), newValue.ToString() }
            };

            result.Type = (newValue > oldValue) ?
                DeviceEventType.TemperatureIncreased :
                DeviceEventType.TemperatureDecreased;

            result.Notification = (sender == EventSender.System) ?
                EventNotification.Warning :
                EventNotification.Information;

            return result;
        }
        private static void sendEvent(Event e)
        {
            Utils.log("sendEvent(" + e.name + ")");

            eventSender = new EventSender(e);
            eventSender.OnEventSent += new EventHandler<EventSender.EventSenderArgs>(onEventSent);
            eventSender.OnEventFailed += new EventHandler<EventSender.EventSenderArgs>(onEventFailed);
            eventSender.start();
        }
        internal static void onEventFailed(object sender, EventSender.EventSenderArgs e)
        {
            Utils.log("onEventFailed(): " + e.theEvent.name);

            eventSender = null;

            sendNextEvent();
        }
Ejemplo n.º 39
0
 public ServerEventManager(Server server)
 {
     this.server = server;
     sender = new EventSender(this);
     listeners = new List<IServerEventListener>();
 }