Represents the jQuery DataTables request that is sent for server side processing.

http://datatables.net/usage/server-side

        public JsonResult CategoriesSearch(JQueryDataTablesModel jQueryDataTablesModel, string identifier)
        {
            int totalRecordCount;
            int searchRecordCount;

            //Get Connection string
            var entityConnectionString = HydroServerToolsUtils.BuildConnectionStringForUserName(HttpContext.User.Identity.Name);
            //var entityConnectionString = HydroServerToolsUtils.GetDBEntityConnectionStringByName(connectionName);

            if (String.IsNullOrEmpty(entityConnectionString))
            {
                ModelState.AddModelError(String.Empty, Ressources.HYDROSERVER_USERLOOKUP_FAILED);

            }

            var repository = new CategoriesRepository();
            var items = repository.GetCategories(entityConnectionString, startIndex: jQueryDataTablesModel.iDisplayStart,
                pageSize: jQueryDataTablesModel.iDisplayLength, sortedColumns: jQueryDataTablesModel.GetSortedColumns(),
                totalRecordCount: out totalRecordCount, searchRecordCount: out searchRecordCount, searchString: jQueryDataTablesModel.sSearch);

            var result = from c in items
                         select new[] {
                            c.VariableCode,
                            c.DataValue,
                            c.CategoryDescription
                };

            return this.DataTablesJson(items: result,
                totalRecords: totalRecordCount,
                totalDisplayRecords: searchRecordCount,
                sEcho: jQueryDataTablesModel.sEcho);
        }
Пример #2
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            if (bindingContext == null)
            {
                throw new ArgumentNullException("bindingContext");
            }
            _bindingContext = bindingContext;

            //Bind Model
            var dataTablesRequest = new JQueryDataTablesModel();

            dataTablesRequest.sEcho = GetA <int>(sEchoKey);
            if (dataTablesRequest.sEcho <= 0)
            {
                throw new InvalidOperationException("Expected the request to have a sEcho value greater than 0");
            }

            dataTablesRequest.iColumns       = GetA <int>(iColumnsKey);
            dataTablesRequest.bRegex         = GetA <bool>(bEscapeRegexKey);
            dataTablesRequest.bRegex_        = GetAList <bool>(bEscapeRegex_Key);
            dataTablesRequest.bSearchable_   = GetAList <bool>(bSearchable_Key);
            dataTablesRequest.bSortable_     = GetAList <bool>(bSortable_Key);
            dataTablesRequest.iDisplayLength = GetA <int>(iDisplayLengthKey);
            dataTablesRequest.iDisplayStart  = GetA <int>(iDisplayStartKey);
            dataTablesRequest.iSortingCols   = GetANullableValue <int>(iSortingColsKey);

            if (dataTablesRequest.iSortingCols.HasValue)
            {
                dataTablesRequest.iSortCol_ = GetAList <int>(iSortCol_Key);
                dataTablesRequest.sSortDir_ = GetStringList(sSortDir_Key);

                if (dataTablesRequest.iSortingCols.Value
                    != dataTablesRequest.iSortCol_.Count)
                {
                    throw new InvalidOperationException(string.Format("Amount of items contained in iSortCol_ {0} do not match the amount specified in iSortingCols which is {1}",
                                                                      dataTablesRequest.iSortCol_.Count, dataTablesRequest.iSortingCols.Value));
                }

                if (dataTablesRequest.iSortingCols.Value
                    != dataTablesRequest.sSortDir_.Count)
                {
                    throw new InvalidOperationException(string.Format("Amount of items contained in sSortDir_ {0} do not match the amount specified in iSortingCols which is {1}",
                                                                      dataTablesRequest.sSortDir_.Count, dataTablesRequest.iSortingCols.Value));
                }
            }
            dataTablesRequest.sSearch    = GetString(sSearchKey);
            dataTablesRequest.sSearch_   = GetStringList(sSearch_Key);
            dataTablesRequest.mDataProp_ = GetStringList(mDataProp_Key);

            return(dataTablesRequest);
        }
        public JsonResult DatavaluesSearch(JQueryDataTablesModel jQueryDataTablesModel, string identifier)
        {
            int totalRecordCount;
            int searchRecordCount;

            //Get Connection string
               var entityConnectionString = HydroServerToolsUtils.BuildConnectionStringForUserName(HttpContext.User.Identity.Name);
            //var entityConnectionString = HydroServerToolsUtils.GetDBEntityConnectionStringByName(connectionName);

            if (String.IsNullOrEmpty(entityConnectionString))
            {
                ModelState.AddModelError(String.Empty, Ressources.HYDROSERVER_USERLOOKUP_FAILED);

            }

            var repository = new DataValuesRepository();
            var items = repository.GetDatavalues(entityConnectionString, startIndex: jQueryDataTablesModel.iDisplayStart,
                pageSize: jQueryDataTablesModel.iDisplayLength, sortedColumns: jQueryDataTablesModel.GetSortedColumns(),
                totalRecordCount: out totalRecordCount, searchRecordCount: out searchRecordCount, searchString: jQueryDataTablesModel.sSearch);

            var result = from c in items
                         select new[] {
                            c.ValueID,
                            c.DataValue,
                            c.ValueAccuracy,
                            c.LocalDateTime,
                            c.UTCOffset,
                            c.DateTimeUTC,
                            c.SiteCode,
                            c.VariableCode,
                            c.OffsetValue,
                            c.OffsetTypeID,
                            c.CensorCode,
                            c.QualifierID,
                            c.MethodCode,
                            c.SourceCode,
                            c.LabSampleCode,
                            c.DerivedFromID,
                            c.QualityControlLevelCode
                };

            return this.DataTablesJson(items: result,
                totalRecords: totalRecordCount,
                totalDisplayRecords: searchRecordCount,
                sEcho: jQueryDataTablesModel.sEcho);
        }
        public JsonResult SourcesSearch(JQueryDataTablesModel jQueryDataTablesModel, string identifier)
        {
            int totalRecordCount;
            int searchRecordCount;

            //Get Connection string
            var entityConnectionString = HydroServerToolsUtils.BuildConnectionStringForUserName(HttpContext.User.Identity.Name);
            //var entityConnectionString = HydroServerToolsUtils.GetDBEntityConnectionStringByName(connectionName);

            if (String.IsNullOrEmpty(entityConnectionString))
            {
                ModelState.AddModelError(String.Empty, Ressources.HYDROSERVER_USERLOOKUP_FAILED);

            }

            var repository = new SourcesRepository();
            var items = repository.GetSources(entityConnectionString, startIndex: jQueryDataTablesModel.iDisplayStart,
                pageSize: jQueryDataTablesModel.iDisplayLength, sortedColumns: jQueryDataTablesModel.GetSortedColumns(),
                totalRecordCount: out totalRecordCount, searchRecordCount: out searchRecordCount, searchString: jQueryDataTablesModel.sSearch);

            var result = from c in items
                         select new[] {
                            c.SourceCode,
                            c.Organization,
                            c.SourceDescription,
                            c.SourceLink,
                            c.ContactName,
                            c.Phone,
                            c.Email,
                            c.Address,
                            c.City,
                            c.State,
                            c.ZipCode,
                            c.Citation,
                            c.TopicCategory,
                            c.Title,
                            c.Abstract,
                            c.ProfileVersion,
                            c.MetadataLink
                };

            return this.DataTablesJson(items: result,
                totalRecords: totalRecordCount,
                totalDisplayRecords: searchRecordCount,
                sEcho: jQueryDataTablesModel.sEcho);
        }
        public JsonResult SeriesCatalogSearch(JQueryDataTablesModel jQueryDataTablesModel, string identifier)
        {
            int totalRecordCount;
            int searchRecordCount;

            //Get Connection string
            var entityConnectionString = HydroServerToolsUtils.BuildConnectionStringForUserName(HttpContext.User.Identity.Name);
            //var entityConnectionString = HydroServerToolsUtils.GetDBEntityConnectionStringByName(connectionName);

            if (String.IsNullOrEmpty(entityConnectionString))
            {
                ModelState.AddModelError(String.Empty, Ressources.HYDROSERVER_USERLOOKUP_FAILED);

            }

            var repository = new SeriesCatalogRepository();
            var items = repository.GetSeriesCatalog(entityConnectionString, startIndex: jQueryDataTablesModel.iDisplayStart,
                pageSize: jQueryDataTablesModel.iDisplayLength, sortedColumns: jQueryDataTablesModel.GetSortedColumns(),
                totalRecordCount: out totalRecordCount, searchRecordCount: out searchRecordCount, searchString: jQueryDataTablesModel.sSearch);

            var result = from c in items
                         select new[] {
                            //c.SeriesID,
                            //c.SiteID,
                            c.SiteCode,
                            c.SiteName,
                            c.SiteType,
                            //c.VariableID,
                            c.VariableCode,
                            c.VariableName,
                            c.Speciation,
                            //c.VariableUnitsID,
                            c.VariableUnitsName,
                            c.SampleMedium,
                            c.ValueType,
                            c.TimeSupport,
                            //c.TimeUnitsID,
                            c.TimeUnitsName,
                            c.DataType,
                            c.GeneralCategory,
                            //c.MethodID,
                            c.MethodDescription,
                            //c.SourceID,
                            c.Organization,
                            c.SourceDescription,
                            c.Citation,
                            //c.QualityControlLevelID,
                            c.QualityControlLevelCode,
                            c.BeginDateTime,
                            c.EndDateTime,
                            //c.BeginDateTimeUTC,
                            //c.EndDateTimeUTC,
                            c.ValueCount
                };

            return this.DataTablesJson(items: result,
                totalRecords: totalRecordCount,
                totalDisplayRecords: searchRecordCount,
                sEcho: jQueryDataTablesModel.sEcho);
        }
        public JsonResult Search(JQueryDataTablesModel jQueryDataTablesModel, string identifier)
        {
            int totalRecordCount;
            int searchRecordCount;

            //Get Connection string
            var entityConnectionString = HydroServerToolsUtils.BuildConnectionStringForUserName(HttpContext.User.Identity.Name);
            //var entityConnectionString = HydroServerToolsUtils.GetDBEntityConnectionStringByName(connectionName);

            if (String.IsNullOrEmpty(entityConnectionString))
            {
                ModelState.AddModelError(String.Empty, Ressources.HYDROSERVER_USERLOOKUP_FAILED);

            }

            var sitesRepository = new SitesRepository();
            var items = sitesRepository.GetSites(entityConnectionString, startIndex: jQueryDataTablesModel.iDisplayStart,
                pageSize: jQueryDataTablesModel.iDisplayLength, sortedColumns: jQueryDataTablesModel.GetSortedColumns(),
                totalRecordCount: out totalRecordCount, searchRecordCount: out searchRecordCount, searchString: jQueryDataTablesModel.sSearch);

            var result = from c in items
                         select new[] {
                    c.SiteCode,
                    c.SiteName,
                    c.Latitude,
                    c.Longitude,
                    c.LatLongDatumSRSName,
                    c.Elevation_m,
                    c.VerticalDatum,
                    c.LocalX,
                    c.LocalY,
                    c.LocalProjectionSRSName,
                    c.PosAccuracy_m,
                    c.State,
                    c.County,
                    c.Comments,
                    c.SiteType
                };

            return this.DataTablesJson(items: result,
                totalRecords: totalRecordCount,
                totalDisplayRecords: searchRecordCount,
                sEcho: jQueryDataTablesModel.sEcho);
        }