Exemplo n.º 1
0
        /// <summary>
        /// Processes a Context event and send the result to the next block
        /// </summary>
        /// <param name="text">Event data</param>
        /// <param name="targetBlock">Next block</param>
        /// <returns></returns>
        private async Task ProcessContextEvent(string text, ITargetBlock <string> targetBlock)
        {
            var clientId = await TlHelper.GetPropertyValue(text, Logcfg.CLIENT_ID_PR);

            // If "client id" property is empty then it`s a system call, such event skipping
            if (clientId == string.Empty)
            {
                return;
            }

            var dateTime = await TlHelper.GetPropertyValue(text, Logcfg.DATETIME_PR);

            var context = await TlHelper.GetPropertyValue(text, Logcfg.CONTEXT_PR);

            var firstLineContext = await TlHelper.GetFirstLineContext(context);

            var lastLineContext = await TlHelper.GetLastLineContext(context);

            var user = await TlHelper.GetPropertyValue(text, Logcfg.USER_PR);

            var connectId = await TlHelper.GetPropertyValue(text, Logcfg.CONNECT_ID_PR);

            var data =
                Common.FS +
                dateTime +
                Common.FS +
                user +
                Common.FS +
                connectId +
                Common.FS +
                clientId +
                Common.FS +
                firstLineContext +
                Common.FS +
                lastLineContext +
                Common.RS;

            await targetBlock.SendAsync(data);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes a DBMSSQL event and send the result to the next block
        /// </summary>
        /// <param name="text">Event data</param>
        /// <param name="targetBlock">Next block</param>
        /// <returns></returns>
        private async Task ProcessDbmssqlEvent(string text, ITargetBlock <string> targetBlock)
        {
            var user = await TlHelper.GetPropertyValue(text, Logcfg.USER_PR);

            // If "usr" property is empty then skip this event
            if (user == string.Empty)
            {
                return;
            }

            var sql = await TlHelper.GetPropertyValue(text, Logcfg.SQL_PR);

            // If "sql" property is empty then skip this event
            if (sql == string.Empty)
            {
                return;
            }

            var clientId = await TlHelper.GetPropertyValue(text, Logcfg.CLIENT_ID_PR);

            // If "client id" property is empty then it`s a system call, such event skipping
            if (clientId == string.Empty)
            {
                return;
            }

            var clearedSql = await TlHelper.CleanSql(sql);

            var normalizedSql = await Common.GetNormalizedSql(clearedSql);

            var hash = await Common.GetMD5Hash(normalizedSql);

            var dateTime = await TlHelper.GetPropertyValue(text, Logcfg.DATETIME_PR);

            var context = await TlHelper.GetPropertyValue(text, Logcfg.CONTEXT_PR);

            var firstLine = await TlHelper.GetFirstLineContext(context);

            var lastLine = await TlHelper.GetLastLineContext(context);

            var connectId = await TlHelper.GetPropertyValue(text, Logcfg.CONNECT_ID_PR);

            var contextExists = firstLine.Length == 0 ? 0 : 1;

            var data =
                Common.FS +
                dateTime +
                Common.FS +
                user +
                Common.FS +
                connectId +
                Common.FS +
                clientId +
                Common.FS +
                sql +
                Common.FS +
                normalizedSql +
                Common.FS +
                firstLine +
                Common.FS +
                lastLine +
                Common.FS +
                contextExists +
                Common.FS +
                hash +
                Common.RS;

            await targetBlock.SendAsync(data);
        }