示例#1
0
        /// <summary>
        /// The delegate event executed by a event
        /// </summary>
        /// <param name="eventType">
        /// </param>
        /// <param name="context">
        /// EventActionContext cosa deve essere esuito
        /// </param>
        private static void delegateActionEventEmbedded(IEventType eventType, EventActionContext context)
        {
            lock (context)
            {
                try
                {
                    //If embedded mode and trigger source == embeddedtrigger then not execute the internal embedded delelegate
                    if (context.BubblingConfiguration.AssemblyClassType != typeof(GrabCaster.Framework.EmbeddedTrigger.EmbeddedTrigger))
                    {
                        setEventActionEventEmbedded(eventType, context);
                    }
                }
                catch (Exception ex)
                {
                    context.BubblingConfiguration.CorrelationOverride = null;

                    LogEngine.WriteLog(
                        Configuration.EngineName,
                        $"Error in {MethodBase.GetCurrentMethod().Name}",
                        Constant.DefconOne,
                        Constant.TaskCategoriesError,
                        ex,
                        EventLogEntryType.Error);
                }
            }
        }
示例#2
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                using (var destinationConnection = new SqlConnection(this.ConnectionString))
                {
                    destinationConnection.Open();
                    using (var bulkCopy = new SqlBulkCopy(this.ConnectionString))
                    {
                        bulkCopy.DestinationTableName = this.TableNameDestination;
                        try
                        {
                            object obj       = Serialization.ByteArrayToDataTable(this.DataContext);
                            var    dataTable = (DataTable)obj;

                            // Write from the source to the destination.
                            bulkCopy.WriteToServer(dataTable);
                        }
                        catch (Exception)
                        {
                            // ignored
                        }
                    }
                }

                setEventActionEvent(this, context);
            }
            catch
            {
                // ignored
            }
        }
示例#3
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                this.SetEventActionTrigger = setEventActionTrigger;
                this.Context = context;

                var sprovider         = this.EtwProvider;
                var rewriteProviderId = new Guid("13D5F7EF-9404-47ea-AF13-85484F09F2A7");
                //lockSlimEHQueue = new LockSlimEHQueue<byte[]>(1, 1, SetEventActionTrigger, context, this);
                using (var watcher = new EventTraceWatcher(sprovider, rewriteProviderId))
                {
                    watcher.EventArrived += delegate
                    {
                        //DataContext = Encoding.UTF8.GetBytes(e.Properties["EventData"].ToString());
                        //lockSlimEHQueue.Enqueue(DataContext);
                        setEventActionTrigger(this, context);
                    };

                    // Start listening
                    watcher.Start();

                    Thread.Sleep(Timeout.Infinite);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#4
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                this.Context = context;
                this.SetEventActionTrigger = setEventActionTrigger;

                var rfid = new RFID(); // Declare an RFID object

                // initialize our Phidgets RFID reader and hook the event handlers
                rfid.Attach += RfidAttach;
                rfid.Detach += RfidDetach;
                rfid.Error  += this.RfidError;

                rfid.Tag     += this.RfidTag;
                rfid.TagLost += RfidTagLost;
                rfid.open();

                // Wait for a Phidget RFID to be attached before doing anything with
                // the object
                rfid.waitForAttachment();

                // turn on the antenna and the led to show everything is working
                rfid.Antenna = true;
                rfid.LED     = true;
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception)
            {
                // ignored
            }
        }
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                this.Context = context;
                this.SetEventActionTrigger = setEventActionTrigger;

                using (var sourceConnection = new SqlConnection(this.ConnectionString))
                {
                    sourceConnection.Open();

                    // Get data from the source table as a SqlDataReader.
                    var commandSourceData = new SqlCommand(this.BulkSelectQuery, sourceConnection);
                    var dataTable         = new DataTable();
                    var dataAdapter       = new SqlDataAdapter(commandSourceData);
                    dataAdapter.Fill(dataTable);
                    this.DataContext = Serialization.DataTableToByteArray(dataTable);
                    setEventActionTrigger(this, context);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#6
0
        /// <summary>
        /// The event received from embedded.
        /// </summary>
        /// <param name="eventType">
        /// The event type.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>
        private static void EventReceivedFromEmbedded(IEventType eventType, EventActionContext context)
        {
            string stringValue = Encoding.UTF8.GetString(eventType.DataContext);

            Console.WriteLine("---------------EVENT RECEIVED FROM EMBEDDED LIBRARY---------------");
            Console.WriteLine(stringValue);
        }
示例#7
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                while (true)
                {
                    var reg = new Regex(this.RegexFilePattern);
                    if (Directory.GetFiles(this.InputDirectory, "*.txt").Where(path => reg.IsMatch(path)).ToList().Any())
                    {
                        var files =
                            Directory.GetFiles(this.InputDirectory, "*.txt").Where(path => reg.IsMatch(path)).ToList();
                        foreach (var file in files)
                        {
                            var data = File.ReadAllBytes(file);
                            PersistentProvider.PersistMessage(context);
                            File.Delete(Path.ChangeExtension(file, this.DoneExtensionName));
                            File.Move(file, Path.ChangeExtension(file, this.DoneExtensionName));
                            this.DataContext = data;
                            setEventActionTrigger(this, context);
                        }
                    }

                    Thread.Sleep(this.PollingTime);
                }
            }
            catch (Exception)
            {
                setEventActionTrigger(this, null);
            }
        }
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                var script = string.Empty;
                if (!string.IsNullOrEmpty(this.ScriptFileEvent))
                {
                    script = File.ReadAllText(this.ScriptFileEvent);
                }
                else
                {
                    script = this.ScriptEvent;
                }

                var powerShellScript = PowerShell.Create();
                powerShellScript.AddScript(script);

                // TODO 1020
                powerShellScript.AddParameter("DataContext", this.DataContext);
                powerShellScript.Invoke();
                var outVar = powerShellScript.Runspace.SessionStateProxy.PSVariable.GetValue("DataContext");
                if (outVar != null)
                {
                    this.DataContext = Encoding.UTF8.GetBytes(outVar.ToString());
                    setEventActionEvent(this, context);
                }

                // TODO 1030
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#9
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                this.Context             = context;
                this.SetEventActionEvent = setEventActionEvent;

                var namespaceManager = NamespaceManager.CreateFromConnectionString(this.ConnectionString);

                if (!namespaceManager.TopicExists(this.TopicPath))
                {
                    namespaceManager.CreateTopic(this.TopicPath);
                }

                var client          = TopicClient.CreateFromConnectionString(this.ConnectionString, this.TopicPath);
                var brokeredMessage = new BrokeredMessage(this.DataContext);

                var value = this.MessageContextProperties.Split('|');
                brokeredMessage.Properties[value[0]] = value[1];
                client.Send(brokeredMessage);
                setEventActionEvent(this, context);
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#10
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                this.Context = context;
                this.SetEventActionEvent = setEventActionEvent;

                var storageAccount = CloudStorageAccount.Parse(this.StorageAccount);
                var blobClient = storageAccount.CreateCloudBlobClient();

                // Retrieve a reference to a container. 
                var container = blobClient.GetContainerReference(this.BlobContainer);

                // Create the container if it doesn't already exist.
                container.CreateIfNotExists();
                container.SetPermissions(
                    new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

                var blockBlob = container.GetBlockBlobReference(this.BlobBlockReference);
                blockBlob.UploadFromByteArray(this.DataContext, 0, this.DataContext.Length);

                setEventActionEvent(this, context);
            }
            catch
            {
                // ignored
            }
        } // Execute
示例#11
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                this.Context = context;
                this.SetEventActionTrigger = setEventActionTrigger;

                // Create the connection string
                var builder = new ServiceBusConnectionStringBuilder(this.EventHubsConnectionString)
                {
                    TransportType =
                        TransportType
                        .Amqp
                };

                // Create the EH Client
                var eventHubClient = EventHubClient.CreateFromConnectionString(builder.ToString(), this.EventHubsName);

                // muli partition sample
                var namespaceManager    = NamespaceManager.CreateFromConnectionString(builder.ToString());
                var eventHubDescription = namespaceManager.GetEventHub(this.EventHubsName);

                // Use the default consumer group
                foreach (var partitionId in eventHubDescription.PartitionIds)
                {
                    var myNewThread = new Thread(() => this.ReceiveDirectFromPartition(eventHubClient, partitionId));
                    myNewThread.Start();
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#12
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                var script       = string.Empty;
                var metaProvider = new MetadataFileProvider();
                metaProvider.GetReference(context.GetType().Assembly.Location);
                var scriptEngine = new ScriptEngine(metaProvider);

                var session = scriptEngine.CreateSession(context);

                session.AddReference(
                    @"C:\Users\ninoc\Documents\Visual Studio 2015\Projects\HybridIntegrationServices\Framework\bin\Debug\Framework.exe");
                session.AddReference(
                    @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll");

                if (this.ScriptFile != null || this.ScriptFile != string.Empty)
                {
                    // TODO 1020
                    // ReSharper disable once AssignNullToNotNullAttribute
                    script = File.ReadAllText(this.ScriptFile);
                    session.ExecuteFile(script);
                }
                else
                {
                    session.Execute(this.Script);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#13
0
 public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
 {
     trigger         = this;
     InternalContext = context;
     InternalSetEventActionTrigger = setEventActionTrigger;
     InternalDataContext           = this.DataContext;
     StartHooking();
 }
示例#14
0
        public static bool PersistMessage(EventActionContext eventActionContext)
        {
            if (Configuration.EnablePersistingMessaging() == false)
            {
                return(true);
            }

            return(PersistMessage(eventActionContext.BubblingConfiguration, CommunicationDiretion.OnRamp));
        }
示例#15
0
 public LockSlimEhQueue(
     int capLimit,
     int timeLimit,
     SetEventActionTrigger setEventActionTrigger,
     EventActionContext eventActionContext,
     EtwTrigger eTwTrigger)
 {
     this.Init(capLimit, timeLimit);
     this.EtwTrigger            = eTwTrigger;
     this.SetEventActionTrigger = setEventActionTrigger;
     this.EventActionContext    = eventActionContext;
 }
示例#16
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                var namespaceManager = NamespaceManager.CreateFromConnectionString(this.ConnectionString);

                if (!namespaceManager.TopicExists(this.TopicPath))
                {
                    namespaceManager.CreateTopic(this.TopicPath);
                }

                var sqlFilter = new SqlFilter(this.MessagesFilter);

                if (!namespaceManager.SubscriptionExists(this.TopicPath, this.SubscriptionName))
                {
                    namespaceManager.CreateSubscription(this.TopicPath, this.SubscriptionName, sqlFilter);
                }

                var subscriptionClientHigh = SubscriptionClient.CreateFromConnectionString(
                    this.ConnectionString,
                    this.TopicPath,
                    this.SubscriptionName);

                // Configure the callback options
                var options = new OnMessageOptions {
                    AutoComplete = false, AutoRenewTimeout = TimeSpan.FromMinutes(1)
                };

                // Callback to handle received messages
                subscriptionClientHigh.OnMessage(
                    message =>
                {
                    try
                    {
                        // Remove message from queue
                        message.Complete();
                        this.DataContext = message.GetBody <byte[]>();
                        setEventActionTrigger(this, context);
                    }
                    catch (Exception)
                    {
                        // Indicates a problem, unlock message in queue
                        message.Abandon();
                    }
                },
                    options);
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#17
0
 public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
 {
     try
     {
         Debug.WriteLine("In MessageBoxEvent Event.");
         var message = Encoding.UTF8.GetString(this.DataContext);
         MessageBox.Show(message);
         setEventActionEvent(this, context);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("MessageBoxEvent error > " + ex.Message);
         setEventActionEvent(this, null);
     }
 }
示例#18
0
 public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
 {
     try
     {
         Debug.WriteLine("In FileEvent Event.");
         File.WriteAllBytes(this.OutputDirectory + Guid.NewGuid() + ".txt", this.DataContext == null?new byte[0]: this.DataContext);
         this.DataContext = Serialization.ObjectToByteArray(true);
         setEventActionEvent(this, context);
     }
     catch (Exception ex)
     {
         Debug.WriteLine("FileEvent error > " + ex.Message);
         setEventActionEvent(this, null);
     }
 }
示例#19
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                var content = Encoding.UTF8.GetString(this.DataContext);
                var twilio  = new TwilioRestClient(this.AccountSid, this.AuthToken);
                var text    = content.Replace("\"", string.Empty).Replace("\\", string.Empty);
                twilio.SendMessage(this.From, this.To, text);

                // SetEventActionEvent(this, context);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#20
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                if (!InternalEventUpStream.InstanceLoaded)
                {
                    InternalEventUpStream.CreateEventUpStream(this.ConnectionString, this.EventHubName);
                    InternalEventUpStream.InstanceLoaded = true;
                }

                InternalEventUpStream.SendMessage(this.DataContext);
                setEventActionEvent(this, context);
            }
            catch
            {
                // ignored
            }
        }
示例#21
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                var storageAccount = CloudStorageAccount.Parse(this.StorageAccount);
                var blobClient     = storageAccount.CreateCloudBlobClient();

                // Retrieve a reference to a container.
                var container = blobClient.GetContainerReference(this.BlobContainer);

                // Create the container if it doesn't already exist.
                container.CreateIfNotExists();
                container.SetPermissions(
                    new BlobContainerPermissions {
                    PublicAccess = BlobContainerPublicAccessType.Blob
                });

                var blockBlob = container.GetBlockBlobReference(this.BlobBlockReference);

                try
                {
                    blockBlob.FetchAttributes();
                    var fileByteLength = blockBlob.Properties.Length;
                    var blobContent    = new byte[fileByteLength];
                    for (var i = 0; i < fileByteLength; i++)
                    {
                        blobContent[i] = 0x20;
                    }

                    blockBlob.DownloadToByteArray(blobContent, 0);
                    blockBlob.Delete();
                    this.DataContext = blobContent;
                    setEventActionTrigger(this, context);
                }
                catch
                {
                    // ignored
                }
            }
            catch
            {
                // ignored
            }
        }
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                this.Context = context;
                this.SetEventActionTrigger = setEventActionTrigger;

                var myNewLog = new EventLog {
                    Log = this.EventLog
                };

                myNewLog.EntryWritten       += this.MyOnEntryWritten;
                myNewLog.EnableRaisingEvents = true;
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#23
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                var rfidtag      = Encoding.UTF8.GetString(this.DataContext);
                var dialogResult = MessageBox.Show(
                    $"Authorization for TAG code {rfidtag}.",
                    "Authorization TAG",
                    MessageBoxButtons.YesNo);
                this.DataContext = Encoding.UTF8.GetBytes(dialogResult == DialogResult.Yes ? true.ToString() : false.ToString());

                setEventActionEvent(this, context);
            }

            catch
            {
                // ignored
            }
        }
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            try
            {
                this.Context = context;
                this.SetEventActionTrigger = setEventActionTrigger;

                using (var myConnection = new SqlConnection(this.ConnectionString))
                {
                    var selectCommand = new SqlCommand(this.SqlQuery, myConnection);
                    myConnection.Open();
                    XmlReader readerResult = null;
                    try
                    {
                        readerResult = selectCommand.ExecuteXmlReader();
                        readerResult.Read();
                    }
                    catch (Exception)
                    {
                        return;
                    }

                    if (readerResult.EOF)
                    {
                        return;
                    }

                    var xdoc = new XmlDocument();
                    xdoc.Load(readerResult);
                    if (xdoc.OuterXml != string.Empty)
                    {
                        this.DataContext = Encoding.UTF8.GetBytes(xdoc.OuterXml);
                        myConnection.Close();
                        setEventActionTrigger(this, context);
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#25
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            var content  = Encoding.UTF8.GetString(this.DataContext);
            var notepads = Process.GetProcessesByName("notepad");

            if (notepads.Length == 0)
            {
                return;
            }

            if (notepads[0] != null)
            {
                EmptyClipboard();
                var child  = FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Edit", null);
                var length = SendMessageGetTextLength(child, this.WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);
                SendMessage(child, this.EM_SETSEL, length, length); // search end of file position
                content += "\r\n";
                SendMessage(child, EM_REPLACESEL, 1, content);      // append new line
            }
        }
示例#26
0
        public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
        {
            try
            {
                this.Context             = context;
                this.SetEventActionEvent = setEventActionEvent;

                var namespaceManager = NamespaceManager.CreateFromConnectionString(this.ConnectionString);

                if (!namespaceManager.QueueExists(this.QueuePath))
                {
                    namespaceManager.CreateQueue(this.QueuePath);
                }

                var client = QueueClient.CreateFromConnectionString(this.ConnectionString, this.QueuePath);
                client.Send(new BrokeredMessage(this.DataContext));
                setEventActionEvent(this, context);
            }
            catch
            {
                // ignored
            }
        }
示例#27
0
        public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
        {
            var script = string.Empty;

            script = this.ScriptFile != string.Empty ? File.ReadAllText(this.ScriptFile) : this.Script;

            var powerShellScript = PowerShell.Create();

            powerShellScript.AddScript(script);

            // foreach (var prop in MessageProperties)
            // {
            // powerShellScript.AddParameter(prop.Key, prop.Value);
            // }
            powerShellScript.AddParameter("DataContext", this.DataContext);
            powerShellScript.Invoke();
            if (powerShellScript.HadErrors)
            {
                var sb = new StringBuilder();
                foreach (var error in powerShellScript.Streams.Error)
                {
                    sb.AppendLine(error.Exception.Message);
                }

                throw new Exception(sb.ToString());
            }

            var outVar = powerShellScript.Runspace.SessionStateProxy.PSVariable.GetValue("DataContext");

            if (outVar != null && outVar.ToString() != string.Empty)
            {
                try
                {
                    var po       = (PSObject)outVar;
                    var logEntry = po.BaseObject as EventLogEntry;
                    if (logEntry != null)
                    {
                        var ev = logEntry;
                        this.DataContext = Encoding.UTF8.GetBytes(ev.Message);
                    }
                    else
                    {
                        this.DataContext = Encoding.UTF8.GetBytes(outVar.ToString());
                    }

                    if (this.DataContext.Length != 0)
                    {
                        setEventActionTrigger(this, context);
                    }
                }
                catch
                {
                    // if multiple pso
                    var results = (object[])outVar;
                    foreach (var pos in results)
                    {
                        var po       = (PSObject)pos;
                        var logEntry = po.BaseObject as EventLogEntry;
                        if (logEntry != null)
                        {
                            var ev = logEntry;
                            this.DataContext = Encoding.UTF8.GetBytes(ev.Message);
                        }
                        else
                        {
                            this.DataContext = Encoding.UTF8.GetBytes(outVar.ToString());
                        }

                        if (this.DataContext.Length != 0)
                        {
                            setEventActionTrigger(this, context);
                        }
                    }
                }
            }
        }
示例#28
0
 public void Execute(SetEventActionTrigger setEventActionTrigger, EventActionContext context)
 {
     setEventActionTrigger(this, context);
 }
示例#29
0
 public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
 {
 }
示例#30
0
 public void Execute(SetEventActionEvent setEventActionEvent, EventActionContext context)
 {
     setEventActionEvent(this, context);
 }