private void RaiseFilterAddedEvent(DataFilterType dataFilterType)
 {
     if (NewFilterAdded != null)
     {
         NewFilterAdded(this, new FilterAddedEventArgs(dataFilterType));
     }
 }
예제 #2
0
 public DataFilter(string fromAddress, string toAddress, byte[] content, ContentFilterType contentFilterType, DataFilterType dataFilterType)
 {
     this.fromAddress       = fromAddress;
     this.toAddress         = toAddress;
     this.content           = content;
     this.contentFilterType = contentFilterType;
     this.dataFilterType    = dataFilterType;
 }
예제 #3
0
        public IHttpActionResult Get(string serverName, DataFilterType? filter)
        {
            if (string.IsNullOrEmpty(serverName))
                return BadRequest("Please pass serverName parameter");

            if (filter == null)
                return BadRequest("Please pass DataFilterType (PastHour or PastDay)");

            var result = CacheManager.GetPerfDataItems(serverName, filter);

            return Ok(result);
        }
예제 #4
0
        /// <summary>
        /// Filters a column based on its name and the name of the table containing it.
        /// </summary>
        /// <param name="tableName">Table name to filter.</param>
        /// <param name="columnName">Column name to filter.</param>
        /// <returns>The result of the filtering.</returns>
        public DataFilterType FilterColumn(string tableName, string columnName)
        {
            DataFilterType result = DataFilterType.Unknown;

            foreach (ColumnFilterCommand rule in columnFilter)
            {
                if (RegexSupport.CheckMatch(rule.TableNameRegex, tableName) && RegexSupport.CheckMatch(rule.ColumnNameRegex, columnName))
                {
                    result = rule.Type;
                }
            }
            return(result);
        }
예제 #5
0
        /// <summary>
        /// Filters a table based on its name.
        /// </summary>
        /// <param name="tableName">Table name to filter.</param>
        /// <returns>The result of the filtering.</returns>
        public DataFilterType FilterTable(string tableName)
        {
            DataFilterType result = DataFilterType.Unknown;

            foreach (TableFilterRule rule in tableFilter)
            {
                if (RegexSupport.CheckMatch(rule.TableNameRegex, tableName))
                {
                    result = rule.Type;
                }
            }
            return(result);
        }
예제 #6
0
        /// <summary>
        /// Installs a single table rule from its XML representation.
        /// </summary>
        /// <param name="node">Command XML node.</param>
        private bool InstallTableCommand(XmlNode node)
        {
            DataFilterType type           = GetFilterType(node);
            string         tableNameRegex = SafeGetAttributeValue(node, "tableName");

            if (type == DataFilterType.Unknown || string.IsNullOrEmpty(tableNameRegex))
            {
                return(false);
            }

            TableFilterRule rule = new TableFilterRule(type, tableNameRegex);

            tableFilter.Add(rule);
            return(true);
        }
예제 #7
0
        /// <summary>
        /// Installs a single column rule from its XML representation.
        /// </summary>
        /// <param name="node">Command XML node.</param>
        private bool InstallColumnCommand(XmlNode node)
        {
            DataFilterType type            = GetFilterType(node);
            string         tableNameRegex  = SafeGetAttributeValue(node, "tableName");
            string         columnNameRegex = SafeGetAttributeValue(node, "columnName");

            if (type == DataFilterType.Unknown || string.IsNullOrEmpty(tableNameRegex) || string.IsNullOrEmpty(columnNameRegex))
            {
                return(false);
            }

            ColumnFilterCommand rule = new ColumnFilterCommand(type, tableNameRegex, columnNameRegex);

            columnFilter.Add(rule);
            return(true);
        }
예제 #8
0
        public override string GetDataFilterString(DataFilterType type)
        {
            switch (type)
            {
            case DataFilterType.AD: return("[A-D]**");

            case DataFilterType.EH: return("[E-H]**");

            case DataFilterType.IL: return("[I-L]**");

            case DataFilterType.MP: return("[M-P]**");

            case DataFilterType.QT: return("[Q-T]**");

            case DataFilterType.UZ: return("[U-Z]**");

            case DataFilterType._All: return("*");

            default:
                return("");
            }
        }
예제 #9
0
        public override string GetDataFilterString(DataFilterType type)
        {
            switch (type)
            {
            case DataFilterType.AD: return("(A|B|C|D|a|b|c|d)**");

            case DataFilterType.EH: return("(E|F|G|H|e|f|g|h)**");

            case DataFilterType.IL: return("(I|J|K|L|i|j|k|l)**");

            case DataFilterType.MP: return("(M|N|O|P|m|n|o|p)**");

            case DataFilterType.QT: return("(Q|R|S|T|q|r|s|t)**");

            case DataFilterType.UZ: return("(U|V|W|X|Y|Z|u|v|w|x|y|z)**");

            case DataFilterType._All: return("*");

            default:
                return("");
            }
        }
예제 #10
0
        public static IEnumerable<PerfDataSummary> GetPerfDataItems(string server, DataFilterType? filter)
        {
            IEnumerable<PerfDataSummary> result = Enumerable.Empty<PerfDataSummary>();
            DateTime currentDateTime = DateTime.Now;
            switch (filter)
            {
                case DataFilterType.PastHour:
                    result = _perfDataItemList.Where(m => m.ServerName == server)
                        .Where(m => m.RecordedDateTime > currentDateTime.AddHours(-1) && m.RecordedDateTime < currentDateTime)
                        .GroupBy(m => new { ServerName = m.ServerName, RecordedDateTime = new DateTime(m.RecordedDateTime.Year, m.RecordedDateTime.Month, m.RecordedDateTime.Day, m.RecordedDateTime.Hour, m.RecordedDateTime.Minute, 0) })
                        .Select(g => new PerfDataSummary()
                        {
                            AvgCpuLoad = g.Average(p => p.CpuLoad),
                            AvgRamLoad = g.Average(p => p.RamLoad),
                            Filter = filter,
                            RecordedDateTime = g.Key.RecordedDateTime,
                            ServerName = server
                        })
                        .OrderByDescending(g => g.RecordedDateTime);
                    break;
                case DataFilterType.PastDay:
                    result = _perfDataItemList.Where(m => m.ServerName == server)
                        .Where(m => m.RecordedDateTime > currentDateTime.AddHours(-24) && m.RecordedDateTime < currentDateTime)
                        .GroupBy(m => new { ServerName = m.ServerName, RecordedDateTime = new DateTime(m.RecordedDateTime.Year, m.RecordedDateTime.Month, m.RecordedDateTime.Day, m.RecordedDateTime.Hour, 0, 0) })
                        .Select(g => new PerfDataSummary()
                        {
                            AvgCpuLoad = g.Average(p => p.CpuLoad),
                            AvgRamLoad = g.Average(p => p.RamLoad),
                            Filter = filter,
                            RecordedDateTime = g.Key.RecordedDateTime,
                            ServerName = server
                        })
                        .OrderByDescending(g => g.RecordedDateTime);
                    break;
            }

            return result;
        }
예제 #11
0
 public override string GetDataFilterString(DataFilterType type)
 {
     switch (type)
     {
         case DataFilterType.AD: return "[A-D]**";
         case DataFilterType.EH: return "[E-H]**";
         case DataFilterType.IL: return "[I-L]**";
         case DataFilterType.MP: return "[M-P]**";
         case DataFilterType.QT: return "[Q-T]**";
         case DataFilterType.UZ: return "[U-Z]**";
         case DataFilterType._All: return "*";
         default:
             return "";
     }
 }
 public void UpdateData <T>(List <T> addItems, List <T> removeItems, List <T> source, DataFilterType filterType)
 {
     foreach (T item in addItems)
     {
         if (!source.Contains(item))
         {
             source.Add(item);
         }
     }
     foreach (T item in removeItems)
     {
         if (source.Contains(item))
         {
             source.Remove(item);
         }
     }
     if (filterType != DataFilterType.Income)
     {
         expenseCollection.Filter = null;
         expenseCollection.Filter = new Predicate <object>(FilterCompatibleExpenseItems);
     }
     if (filterType != DataFilterType.Expense)
     {
         incomeCollection.Filter = null;
         incomeCollection.Filter = new Predicate <object>(FilterCompatibleIncomeItems);
     }
 }
예제 #13
0
 public override string GetDataFilterString(DataFilterType type)
 {
     switch (type)
     {
         case DataFilterType.AD: return "(A|B|C|D|a|b|c|d)**";
         case DataFilterType.EH: return "(E|F|G|H|e|f|g|h)**";
         case DataFilterType.IL: return "(I|J|K|L|i|j|k|l)**";
         case DataFilterType.MP: return "(M|N|O|P|m|n|o|p)**";
         case DataFilterType.QT: return "(Q|R|S|T|q|r|s|t)**";
         case DataFilterType.UZ: return "(U|V|W|X|Y|Z|u|v|w|x|y|z)**";
         case DataFilterType._All: return "*";
         default:
             return "";
     }
 }
예제 #14
0
 public RecordFilter(string fromAddress, string toAddress, string contentString, ContentFilterType contentFilterType, DataFilterType filterType, StringType stringType)
     : this(fromAddress, toAddress, contentString, contentFilterType, filterType, stringType, false, string.Empty, 0)
 {
 }
예제 #15
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">Type of rule.</param>
 /// <param name="tableNameRegex">Regular expression to match against table names.</param>
 public TableFilterRule(DataFilterType type, string tableNameRegex)
 {
     this.Type           = type;
     this.TableNameRegex = RegexSupport.GetRegex(tableNameRegex);
 }
예제 #16
0
파일: DataFilter.cs 프로젝트: 5342/C5SIGMA
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">Type of rule.</param>
 /// <param name="tableNameRegex">Regular expression to match against table names.</param>
 public TableFilterRule(DataFilterType type, string tableNameRegex)
 {
     this.Type = type;
     this.TableNameRegex = RegexSupport.GetRegex(tableNameRegex);
 }
예제 #17
0
파일: DataFilter.cs 프로젝트: 5342/C5SIGMA
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">Type of rule.</param>
 /// <param name="tableNameRegex">Regular expression to match against table names.</param>
 /// <param name="columnNameRegex">Regular expression to match against column names.</param>
 public ColumnFilterCommand(DataFilterType type, string tableNameRegex, string columnNameRegex)
 {
     this.Type = type;
     this.TableNameRegex = RegexSupport.GetRegex(tableNameRegex);
     this.ColumnNameRegex = RegexSupport.GetRegex(columnNameRegex);
 }
예제 #18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public abstract string GetDataFilterString(DataFilterType type);
예제 #19
0
 public RecordFilter(string fromAddress, string toAddress, string contentString, ContentFilterType contentFilterType, DataFilterType filterType, StringType stringType, bool split, string splitSymbol, int splitLength)
 {
     base.fromAddress       = fromAddress;
     base.toAddress         = toAddress;
     base.content           = null;
     base.contentFilterType = contentFilterType;
     base.dataFilterType    = filterType;
     this.contentString     = contentString;
     this.stringType        = stringType;
     this.split             = split;
     this.splitSymbol       = splitSymbol;
     this.splitLength       = splitLength;
     this.ResolveBytes();
 }
 public FilterAddedEventArgs(DataFilterType dataFilterType)
 {
     this.FilterType = dataFilterType;
 }
예제 #21
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="type">Type of rule.</param>
 /// <param name="tableNameRegex">Regular expression to match against table names.</param>
 /// <param name="columnNameRegex">Regular expression to match against column names.</param>
 public ColumnFilterCommand(DataFilterType type, string tableNameRegex, string columnNameRegex)
 {
     this.Type            = type;
     this.TableNameRegex  = RegexSupport.GetRegex(tableNameRegex);
     this.ColumnNameRegex = RegexSupport.GetRegex(columnNameRegex);
 }
예제 #22
0
 public RecordFilter(string fromAddress, string toAddress, DataFilterType filterType)
     : this(fromAddress, toAddress, null, ContentFilterType.None, filterType, StringType.Unknow, false, string.Empty, 0)
 {
 }