internal static BackupDbccViewFilterOperands PopulateGapFilterOperands(List <KeyValuePair <string, string> > queryParams)
        {
            var filterOperands = new BackupDbccViewFilterOperands();

            System.Enum.TryParse <FilterOperand>(queryParams.FirstOrDefault(k => k.Key == "sOperand_5").Value, out filterOperands.GapSize);
            return(filterOperands);
        }
        /// <summary>
        /// Retrieves data for the Backup/DBCC History View
        /// </summary>
        /// <param name="gridConditions"></param>
        /// <param name="filterConditions"></param>
        /// <returns></returns>
        public DataTableCollection GetBackupDbccHistoryDetails(GridConditions gridConditions, BackupDbccViewFilterConditions filterConditions, BackupDbccViewFilterOperands filterOperands)
        {
            using (var conn = (SqlConnection)this.connectionFactory.GetEddsPerformanceConnection())
            {
                using (var command = new SqlCommand())
                {
                    var parameters = new SqlParameter[] {
                        //Grid conditions
                        new SqlParameter {
                            ParameterName = "@SortColumn", DbType = DbType.String, Value = gridConditions.SortColumn
                        },
                        new SqlParameter {
                            ParameterName = "@SortDirection", DbType = DbType.String, Value = gridConditions.SortDirection
                        },
                        new SqlParameter {
                            ParameterName = "@TimezoneOffset", DbType = DbType.Int32, Value = gridConditions.TimezoneOffset
                        },
                        new SqlParameter {
                            ParameterName = "@StartRow", DbType = DbType.Int32, Value = gridConditions.StartRow
                        },
                        new SqlParameter {
                            ParameterName = "@EndRow", DbType = DbType.Int32, Value = gridConditions.EndRow
                        },
                        //Filter conditions
                        new SqlParameter {
                            ParameterName = "@Server", DbType = DbType.String, Value = filterConditions.Server
                        },
                        new SqlParameter {
                            ParameterName = "@Database", DbType = DbType.String, Value = filterConditions.Database
                        },
                        new SqlParameter {
                            ParameterName = "@LastActivityDate", DbType = DbType.DateTime, Value = filterConditions.LastActivityDate
                        },
                        new SqlParameter {
                            ParameterName = "@ActivityType", DbType = DbType.Boolean, Value = filterConditions.IsBackup
                        },
                        new SqlParameter {
                            ParameterName = "@ResolutionDate", DbType = DbType.DateTime, Value = filterConditions.ResolutionDate
                        },
                        new SqlParameter {
                            ParameterName = "@GapSize", DbType = DbType.Int32, Value = filterConditions.GapSize
                        },
                        //Filter operands
                        new SqlParameter {
                            ParameterName = "@GapSizeOperand", DbType = DbType.String, Value = filterOperands.GapSize.GetSqlOperation()
                        },
                        //Page-level filters
                        new SqlParameter {
                            ParameterName = "@StartHour", DbType = DbType.DateTime, Value = gridConditions.StartDate
                        },
                        new SqlParameter {
                            ParameterName = "@EndHour", DbType = DbType.DateTime, Value = gridConditions.EndDate
                        }
                    };

                    var data = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, "eddsdbo.QoS_BackupDBCCReport", parameters);
                    return(data.Tables);
                }
            }
        }
		public BackupDbccViewModel()
		{
			GridConditions = new GridConditions();
			FilterConditions = new BackupDbccViewFilterConditions();
			FilterOperands = new BackupDbccViewFilterOperands();
		}
        // Report methods //
        public virtual BackupDbccViewGrid BackupDbccHistory(GridConditions gridConditions, BackupDbccViewFilterConditions filterConditions, BackupDbccViewFilterOperands filterOperands)
        {
            var grid = new BackupDbccViewGrid();
            var dt   = this.reportRepository.GetBackupDbccHistoryDetails(gridConditions, filterConditions, filterOperands);

            if (dt.Count > 1)
            {
                var searchUsers = dt[0];
                grid.Data = (from DataRow d in searchUsers.Rows
                             select new BackupDbccGapInfo
                {
                    Index = d.Field <int>("RowNumber"),
                    ServerId = d.Field <int>("ServerArtifactID"),
                    Server = d.Field <string>("ServerName"),
                    Database = d.Field <string>("DatabaseName"),
                    Workspace = d.Field <string>("WorkspaceName"),
                    IsBackup = d.Field <bool?>("IsBackup").GetValueOrDefault(false),
                    LastActivityDate = d.Field <DateTime?>("LastActivityDate"),
                    GapResolutionDate = d.Field <DateTime?>("ResolutionDate"),
                    GapSize = d.Field <int?>("GapSize").GetValueOrDefault(0)
                }).AsQueryable();

                var resultInfo = dt[1];
                grid.Count = resultInfo.Rows.Count > 0 ? resultInfo.Rows[0].Field <int?>("FilteredCount").GetValueOrDefault(0) : 0;
            }

            return(grid);
        }