Пример #1
0
        public static BaseEvent GetEvent(RawEvent raw)
        {
            if (raw.Type != EventType.Sql)
            {
                throw new ArgumentException("Sql event expected");
            }

            var ev = new SqlEvent(raw);

            string pool = raw.Header.Values[ValueKeys.Index];

            ev.ConnectionIndex = string.IsNullOrEmpty(pool) ? -1 : Convert.ToInt32(pool);
            ev.IsNew           = raw.Header.Values[ValueKeys.IsNew];

            // TODO: f*****g edocs... Body is sometimes missing...
            SqlQueryEvent query = new SqlQueryEvent();

            foreach (var bodyLine in raw.Body)
            {
                if (bodyLine.RuleType == typeof(SqlBodyRule) || bodyLine.RuleType == typeof(SqlBodyNotifyRule))
                {
                    query      = new SqlQueryEvent();
                    query.Time = bodyLine.Values[ValueKeys.Time];
                    ev.Queries.Add(query);
                    //TODO: line index
                }

                /*else if(bodyLine.RuleType == typeof(SqlStatementRequiredRule.AutoCommitLineRule) {
                 *  query.AutoCommit = bodyLine.Content; // TODO: On or Off only
                 * }*/
                else if (bodyLine.RuleType == typeof(SqlStatementRequiredRule.StatementLineRule))
                {
                    query.Command = bodyLine.Content;
                }
                else if (bodyLine.RuleType == typeof(SqlBodyTimerReadItemRule))
                {
                    query.DurationReadItem = bodyLine.Values[ValueKeys.Duration];
                }
                else if (bodyLine.RuleType == typeof(SqlBodyTimerIssueCommandRule))
                {
                    query.DurationIssueCommand = bodyLine.Values[ValueKeys.Duration];
                }
            }
            return(ev);
        }
Пример #2
0
        public static BaseEvent GetEvent(RawEvent raw)
        {
            if(raw.Type != EventType.Sql)
                throw new ArgumentException("Sql event expected");

            var ev = new SqlEvent(raw);

            string pool = raw.Header.Values[ValueKeys.Index];
            ev.ConnectionIndex = string.IsNullOrEmpty(pool) ? -1 : Convert.ToInt32(pool);
            ev.IsNew = raw.Header.Values[ValueKeys.IsNew];

            // TODO: f*****g edocs... Body is sometimes missing...
            SqlQueryEvent query = new SqlQueryEvent();
            foreach(var bodyLine in raw.Body) {
                if(bodyLine.RuleType == typeof(SqlBodyRule) || bodyLine.RuleType == typeof(SqlBodyNotifyRule)) {
                    query = new SqlQueryEvent();
                    query.Time = bodyLine.Values[ValueKeys.Time];
                    ev.Queries.Add(query);
                    //TODO: line index
                }
                /*else if(bodyLine.RuleType == typeof(SqlStatementRequiredRule.AutoCommitLineRule) {
                    query.AutoCommit = bodyLine.Content; // TODO: On or Off only
                }*/
                else if(bodyLine.RuleType == typeof(SqlStatementRequiredRule.StatementLineRule))
                    query.Command = bodyLine.Content;
                else if(bodyLine.RuleType == typeof(SqlBodyTimerReadItemRule))
                    query.DurationReadItem = bodyLine.Values[ValueKeys.Duration];
                else if(bodyLine.RuleType == typeof(SqlBodyTimerIssueCommandRule))
                    query.DurationIssueCommand = bodyLine.Values[ValueKeys.Duration];
            }
            return ev;
        }