Example #1
0
        private void LoadRates(XmlNode inputNode, GridDescriptor gridDescriptor, Dictionary <int, TreatmentZone> treatmentZones, RasterGridPrescription prescription)
        {
            prescription.LossOfGpsRate  = LoadRateFromTreatmentZones(inputNode.GetXmlNodeValue("@I"), treatmentZones).FirstOrDefault();
            prescription.OutOfFieldRate = LoadRateFromTreatmentZones(inputNode.GetXmlNodeValue("@J"), treatmentZones).FirstOrDefault();

            if (gridDescriptor.TreatmentZones != null)
            {
                var treatmentZone = treatmentZones.FindById(gridDescriptor.TreatmentZones.First());
                if (treatmentZone == null)
                {
                    return;
                }

                LoadProducts(treatmentZone, prescription);
                LoadRateUnits(treatmentZone, prescription);
                prescription.Rates = LoadRatesFromTreatmentZones(gridDescriptor, treatmentZones, prescription.ProductIds, prescription);
            }
            else if (gridDescriptor.ProductRates != null)
            {
                var treatmentZoneTemplate = treatmentZones.FindById(gridDescriptor.ProductRateTemplateId);
                if (treatmentZoneTemplate == null)
                {
                    return;
                }

                LoadProducts(treatmentZoneTemplate, prescription);
                LoadRateUnits(treatmentZoneTemplate, prescription);
                prescription.Rates = LoadRatesFromProducts(gridDescriptor, prescription.ProductIds, prescription);
            }
        }
Example #2
0
        private List <RxCellLookup> ImportRatesFromProducts(GridDescriptor gridDescriptor, List <int> productIds, RasterGridPrescription prescription)
        {
            var  rates = new List <RxCellLookup>();
            bool binaryDataMatchesDefinition = true;

            foreach (var productRates in gridDescriptor.ProductRates)
            {
                var lookup = new RxCellLookup {
                    RxRates = new List <RxRate>()
                };
                for (int productIndex = 0; productIndex < productRates.Count; productIndex++)
                {
                    int adaptProductId = 0;
                    if (productIds.Count > productIndex)
                    {
                        adaptProductId = productIds[productIndex];
                    }
                    else if (productIds.Count > 0)
                    {
                        binaryDataMatchesDefinition = false;
                    }
                    lookup.RxRates.Add(PrescriptionMapper.ImportRate(adaptProductId, productRates[productIndex], prescription));
                }
                rates.Add(lookup);
            }
            if (!binaryDataMatchesDefinition)
            {
                TaskDataMapper.AddError($"Binary Grid Data for Type-2 Grid {TaskDataMapper.InstanceIDMap.GetISOID(prescription.Id.ReferenceId)} does not match its definition.  Product data will be omitted.");
            }
            return(rates);
        }
Example #3
0
        public BaseSearchModel GetResultsFullTextSearch(SearchFilters filters, GridDescriptor request, IMaterialsContextUow context)
        {
            BaseSearchModel model = new BaseSearchModel();
            IQueryable <SampleMaterialModel> resultMat = null;

            int    cnt;
            var    commandText       = "SELECT ID FROM [fn_FullTextSearch] ({0},{1});";
            string cleanSearchString = RemoveCharacters(filters.filter);
            string searchStringWS    = RemoveCharactersWS(filters.filter);


            var         parameters = new object[] { searchStringWS, cleanSearchString };
            IList <int> results    = context.FullTextSearch.SqlQuery <int>(commandText, parameters).ToList();


            resultMat = context.FullTextSearch.GetMaterialsByFullTextSearch(false, filters.filter).Select(m => new SampleMaterialModel()
            {
                Id = m.Id, Name = m.material_designation, TypeName = m.material_type, TypeId = m.type_ID, GroupName = m.material_group, GroupId = m.group_ID, ClassName = m.material_class, ClassId = m.class_ID, SubClassName = m.material_subClass, SubClassId = m.subClass_ID, UNS = m.UNS, CAS_RN = m.CAS_RN
            }).AsQueryable();

            HttpContext.Current.Session["ClassificationRecordsCount"] = results;
            cnt = results.Count;
            model.ListOfMaterials = PagerSearch <SampleMaterialModel>(request.Pager, resultMat, cnt).ToList();


            model.Descriptor      = request;
            model.Filter          = new SearchResultsCondition();
            model.Filter.FullText = filters.filter;

            return(model);
        }
Example #4
0
        private List <RxCellLookup> ImportRatesFromTreatmentZones(GridDescriptor gridDescriptor, IEnumerable <ISOTreatmentZone> treatmentZones, List <int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List <RxCellLookup>();

            foreach (var treatmentZoneCode in gridDescriptor.TreatmentZoneCodes)
            {
                ISOTreatmentZone treatmentZone = treatmentZones.FirstOrDefault(t => t.TreatmentZoneCode == treatmentZoneCode);
                if (treatmentZone == null)
                {
                    return(null);
                }

                var lookup = new RxCellLookup {
                    RxRates = new List <RxRate>()
                };
                foreach (ISOProcessDataVariable pdv in treatmentZone.ProcessDataVariables)
                {
                    if (!string.IsNullOrEmpty(pdv.ProductIdRef))
                    {
                        int?productID = TaskDataMapper.InstanceIDMap.GetADAPTID(pdv.ProductIdRef);
                        if (productID.HasValue)
                        {
                            lookup.RxRates.Add(PrescriptionMapper.ImportAndConvertRate(productID.Value, pdv, prescription));
                        }
                    }
                }

                rates.Add(lookup);
            }

            return(rates);
        }
Example #5
0
        public RasterGridPrescription Import(ISOTask task, WorkItem workItem)
        {
            RasterGridPrescription rasterPrescription = new RasterGridPrescription();

            _prescriptionMapper.ImportSharedPrescriptionProperties(task, workItem, rasterPrescription);

            GridDescriptor gridDescriptor = LoadGridDescriptor(task, TaskDataPath);

            if (gridDescriptor != null)
            {
                rasterPrescription.BoundingBox      = new BoundingBox();
                rasterPrescription.BoundingBox.MinY = new NumericRepresentationValue(RepresentationInstanceList.vrLatitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), gridDescriptor.Origin.Y));
                rasterPrescription.BoundingBox.MinX = new NumericRepresentationValue(RepresentationInstanceList.vrLongitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), gridDescriptor.Origin.X));
                var maxYValue = rasterPrescription.BoundingBox.MinY.Value.Value + gridDescriptor.CellHeight.Value.Value * gridDescriptor.RowCount;
                var maxXValue = rasterPrescription.BoundingBox.MinX.Value.Value + gridDescriptor.CellWidth.Value.Value * gridDescriptor.ColumnCount;
                rasterPrescription.BoundingBox.MaxY = new NumericRepresentationValue(RepresentationInstanceList.vrLatitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), maxYValue));
                rasterPrescription.BoundingBox.MaxX = new NumericRepresentationValue(RepresentationInstanceList.vrLongitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), maxXValue));
                rasterPrescription.Origin           = gridDescriptor.Origin;
                rasterPrescription.CellHeight       = gridDescriptor.CellHeight;
                rasterPrescription.CellWidth        = gridDescriptor.CellWidth;
                rasterPrescription.ColumnCount      = gridDescriptor.ColumnCount;
                rasterPrescription.RowCount         = gridDescriptor.RowCount;

                ImportRates(task, gridDescriptor, rasterPrescription);
            }
            return(rasterPrescription);
        }
Example #6
0
        private GridDescriptor LoadGridDescriptor(ISOTask task, string dataPath)
        {
            if (task.Grid == null)
            {
                return(null);
            }

            GridDescriptor descriptor = new GridDescriptor();

            if (!descriptor.LoadGridDefinition(task.Grid))
            {
                return(null);
            }

            ISOTreatmentZone treatmentZone = null;

            if (task.Grid.GridType == 2)
            {
                treatmentZone = task.TreatmentZones.SingleOrDefault(tz => tz.TreatmentZoneCode == task.Grid.TreatmentZoneCode);
                if (treatmentZone == null)
                {
                    return(null);
                }
            }
            if (!descriptor.LoadRates(dataPath, task.Grid, treatmentZone))
            {
                return(null);
            }

            return(descriptor);
        }
Example #7
0
        private void ImportRates(ISOTask task, GridDescriptor gridDescriptor, RasterGridPrescription prescription)
        {
            if (task.PositionLostTreatmentZone != null)
            {
                prescription.LossOfGpsRate = ImportTreatmentZoneAsNumericRepValue(task.PositionLostTreatmentZone);
            }
            if (task.OutOfFieldTreatmentZone != null)
            {
                prescription.OutOfFieldRate = ImportTreatmentZoneAsNumericRepValue(task.OutOfFieldTreatmentZone);
            }

            if (gridDescriptor.TreatmentZoneCodes != null)
            {
                //Grid Type 1
                ISOTreatmentZone treatmentZone = task.TreatmentZones.FirstOrDefault();
                if (treatmentZone == null)
                {
                    return;
                }

                prescription.Rates = ImportRatesFromTreatmentZones(gridDescriptor, task.TreatmentZones, prescription.ProductIds, prescription);
            }
            else if (gridDescriptor.ProductRates != null)
            {
                //Grid Type 2
                var treatmentZoneTemplate = task.DefaultTreatmentZone;
                if (treatmentZoneTemplate == null)
                {
                    return;
                }

                prescription.Rates = ImportRatesFromProducts(gridDescriptor, prescription.ProductIds, prescription);
            }
        }
        public JsonResult SearchResultsApplyInputFilter()
        {
            GridDescriptor request = new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "Name", Order = SortOrder.Ascending
            });

            BaseSearchModel model   = new BaseSearchModel();
            SearchFilters   filters = new SearchFilters();
            IDictionary <string, object> allFilters = BreadcrumbNavigationGetSet(filters, null);

            filters = (SearchFilters)(allFilters["filters"]);
            if (allFilters.ContainsKey("advFilters"))
            {
                model = SearchResults(filters, "", (AdvSearchFiltersAll)allFilters["advFilters"], request);
            }
            else
            {
                model = SearchResults(filters, "", null, request);
            }
            SearchResultsCondition filterModel = GetFiltersModel(filters);

            model.Filter = filterModel;
            return(Json(ResponseStatus.Success, RenderPartialViewToString("ResultsContainer", model), JsonRequestBehavior.AllowGet));
        }
Example #9
0
        private static List <RxRates> LoadRatesFromTreatmentZones(GridDescriptor gridDescriptor, Dictionary <int, TreatmentZone> treatmentZones, List <int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List <RxRates>();

            foreach (var treatmentZoneId in gridDescriptor.TreatmentZones)
            {
                var treatmentZone = treatmentZones.FindById(treatmentZoneId);
                if (treatmentZone == null)
                {
                    return(null);
                }

                var rate = new RxRates {
                    RxRate = new List <RxRate>()
                };

                for (int i = 0; i < treatmentZone.Variables.Count; i++)
                {
                    var dataVariable = treatmentZone.Variables[i];
                    AddRate(productIds[i], dataVariable.Value, rate, prescription, treatmentZone.Variables[i].IsoUnit.ToAdaptUnit());
                }

                rates.Add(rate);
            }

            return(rates);
        }
        public JsonResult GetSampleMaterials(string filter, int clId, int clTypeId, GridDescriptor request)
        {
            SearchFilters filters = new SearchFilters()
            {
                filter = filter, ClasificationId = clId, ClasificationTypeId = clTypeId
            };
            BaseSearchModel model = _searchResultsBinder.GetResults(filters, request, materialContextUow, "", null);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("ResultsContainer", model)));
        }
        public ActionResult AdvStructureSearch(string query, string exactsearch, string stereo, GridDescriptor request)
        {
            System.Web.HttpContext.Current.Session["AdvancedSearchFilter"] = null;
            var tmp = BreadcrumbNavigationGetSet();
            AdvSearchFiltersAll filters = new AdvSearchFiltersAll();

            if (filters.StructureSearch == null)
            {
                filters.StructureSearch = new AdvStructureSearch();
            }
            filters.StructureSearch.Query       = query;
            filters.StructureSearch.Exactsearch = exactsearch;
            filters.StructureSearch.Stereo      = stereo;
            filters = BreadcrumbNavigationGetSet(filters);

            StringBuilder sb = new StringBuilder(524288);

            byte[] bytesData = Encoding.ASCII.GetBytes("query=" + query + ";exactsearch=" + exactsearch + ";stereo=" + stereo + "\0");
            int    result    = StructureSearch(bytesData, sb, sb.Capacity);


            string recordIds = sb.Replace(";", ",").ToString().Trim().TrimEnd(',');

            ViewBag.ErrorMsg = "result: " + result + "sb: " + sb;
            BaseSearchModel model = new BaseSearchModel();

            model.IsStructureSearch = true;
            if (request.Pager == null)
            {
                request = new GridDescriptor(new SortDescriptor()
                {
                    PropertyName = "Name", Order = SortOrder.Ascending
                });
            }
            model.Descriptor = request;

            //kada proradi raskomentarisati
            if (!string.IsNullOrEmpty(recordIds) && result > 0)
            {
                model.ListOfMaterials = _searchResultsBinder.GetResultsStructureAdvSearch(recordIds, request, materialContextUow);
            }

            SearchResultsCondition filterModel = new SearchResultsCondition();

            filterModel.FullText = "";
            filterModel.ShowPropertiesFilters = false;
            filterModel.FromBrowse            = false;
            filterModel.FromAdvanced          = true;
            model.Filter = filterModel;


            ModelState.Clear();
            return(View("AdvSearchResults", model));
        }
Example #12
0
        public static ApplicationList FilterApplications(DASEntities db, GridDescriptor desc, ApplicationListFilterModel filters)
        {
            ApplicationList model = new ApplicationList()
            {
                Descriptor = desc, ListOfApplication = new List <DAS.Backoffice.Models.Application.ApplicationForm>()
            };
            IQueryable <DAS.Domain.Model.ApplicationForm> applications = db.ApplicationForms.AsQueryable();
            int languageId = (int)HttpContext.Current.Session["lngId"];

            if (filters == null)
            {
                filters = new ApplicationListFilterModel();
            }


            string filApplication = "";


            if (!string.IsNullOrWhiteSpace(filters.Name))
            {
                filApplication = filters.Name.Replace(":", "").Replace("/", "").Replace("-", "").Replace("–", "").Replace("\"", "").Replace(".", "");
                applications   = applications.Where(m => m.CompanyName.Contains(filApplication));
            }

            IList <DAS.Domain.Model.ApplicationForm> listA = applications.Slice(desc).ToList();

            DAS.Backoffice.Models.Application.ApplicationForm applicationModel;
            foreach (var item in listA)
            {
                applicationModel = new DAS.Backoffice.Models.Application.ApplicationForm()
                {
                    ApplicationId                  = item.ApllicationId, CompanyName = item.CompanyName, Adress = item.Adress, Place = item.Place, Telephone = item.Telephone, Email = item.Email, Applicant = item.Applicant,
                    ISO14001                       = (bool)item.ISO14001, ISO22301 = (bool)item.ISO22301, ISO27001 = (bool)item.ISO27001, ISO9001 = (bool)item.ISO9001, OtherIso = (bool)item.OtherIso, Other = item.Other,
                    CompanyWebsite                 = item.CompanyWebsite, PrimaryContactForAuditPurposes = item.PrimaryContactForAuditPurposes, PrimaryContactTelephone = item.PrimaryContactTelephone,
                    NatureOfBusiness               = item.NatureOfBusiness, NumberOfYearsAtThisSite = item.NumberOfYearsAtThisSite, PrincipleServicesOrProducts = item.PrincipleServicesOrProducts,
                    ActivitiesOnClientsSites       = item.ActivitiesOnClientsSites, NameOfPresentCertificationBody = item.NameOfPresentCertificationBody, CertificateExpiryDate = item.CertificateExpiryDate,
                    TotalNumberOfEmployees         = item.TotalNumberOfEmployees, TotalNumberOfCompanyDirectors = item.TotalNumberOfCompanyDirectors, NumberOfLocations = item.NumberOfLocations,
                    AllSitesMainActivites          = item.AllSitesMainActivites, SalesTotalPermanent = item.SalesTotalPermanent, SalesTotalTemporary = item.SalesTotalTemporary, MarketingTotalPermanent = item.MarketingTotalPermanent,
                    MarketingTotalTemporary        = item.MarketingTotalTemporary, AdministrationTotalPermanent = item.AdministrationTotalPermanent, AdministrationTotalTemporary = item.AdministrationTotalTemporary,
                    DesignTotalPermanent           = item.DesignTotalPermanent, DesignTotalTemporary = item.DesignTotalTemporary, ManufacturingTotalPermanent = item.ManufacturingTotalPermanent, ManufacturingTotalTemporary = item.ManufacturingTotalTemporary,
                    OtherTotalPermanent            = item.OtherTotalPermanent, OtherTotalTemporary = item.OtherTotalTemporary, TotalPermanent = item.TotalPermanent, TotalTemporary = item.TotalTemporary, Extension = item.Extension, ManagementRepresentativeName = item.ManagementRepresentativeName,
                    JobTitle                       = item.JobTitle, NameOfConsultant = item.NameOfConsultant, ConsultantTelephone = item.ConsultantTelephone, ISO14001_2 = (bool)item.ISO14001_2, ISO9001_2 = (bool)item.ISO9001_2,
                    ISO22301_2                     = (bool)item.ISO22301_2, ISO27001_2 = (bool)item.ISO27001_2, BSOHSAS18001_2 = (bool)item.BSOHSAS18001_2, StandardTransferred = item.StandardTransferred,
                    DateNextCertificationBodyVisit = item.DateNextCertificationBodyVisit, Other_2 = item.Other_2, OtherIso_2 = (bool)item.OtherIso_2, date_created = (DateTime)item.DateCreated
                };

                model.ListOfApplication.Add(applicationModel);
            }

            return(model);
        }
        public ActionResult ApplySubgroupFilters(GridDescriptor request, SearchSubgroupsFilters filters)
        {
            if (request.Pager == null)
            {
                request = new GridDescriptor(new SortDescriptor()
                {
                    PropertyName = "SourceId", Order = SortOrder.Ascending
                });
            }
            filters = _subgroupBinder.BreadcrumbNavigationGetSet(filters);
            SubgroupsModel model = _subgroupBinder.GetSubgroupsModel(request, filters, materialContextUow);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("EquivalentMaterials", model), JsonRequestBehavior.AllowGet));
        }
        public JsonResult ApplyAdvSearchFilters(AdvSearchFiltersAll filters, GridDescriptor request)
        {
            // Check for null valuse in conditionFilters
            foreach (AdvSearchFilters f in filters.AllFilters)
            {
                if (f.PropertyConditions == null)
                {
                    f.PropertyConditions = new List <PropertyConditionModel>();
                }
            }


            filters = BreadcrumbNavigationGetSet(filters);

            return(Json(ResponseStatus.Success, new { url = Url.Action("AdvSearchResults", "AdvSearch") }, JsonRequestBehavior.AllowGet));
        }
Example #15
0
        public static ApplicationsModel BuildApplications(DASEntities db)
        {
            ApplicationsModel model = new ApplicationsModel();
            int languageId          = (int)HttpContext.Current.Session["lngId"];

            GridDescriptor desc = new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "DateCreated", Order = SortOrder.Descending
            })
            {
                Pager = new PagerDescriptor(1, 20, db.Labels.Where(l => l.ViewId == "Clients" && l.ElementId == "lblPageSize" && l.LanguageId == languageId).Select(l => l.Text).FirstOrDefault(), 5)
            };
            IQueryable <DAS.Domain.Model.ApplicationForm> applications = db.ApplicationForms.AsQueryable();
            IList <DAS.Domain.Model.ApplicationForm>      listA        = applications.Slice(desc).ToList();

            model.Filters = new ApplicationListFilterModel();

            model.Applications = new ApplicationList()
            {
                Descriptor = desc, ListOfApplication = new List <DAS.Backoffice.Models.Application.ApplicationForm>()
            };
            DAS.Backoffice.Models.Application.ApplicationForm applicationModel;
            foreach (var item in listA)
            {
                applicationModel = new DAS.Backoffice.Models.Application.ApplicationForm()
                {
                    ApplicationId                  = item.ApllicationId, CompanyName = item.CompanyName, Adress = item.Adress, Place = item.Place, Telephone = item.Telephone, Email = item.Email, Applicant = item.Applicant,
                    ISO14001                       = (bool)item.ISO14001, ISO22301 = (bool)item.ISO22301, ISO27001 = (bool)item.ISO27001, ISO9001 = (bool)item.ISO9001, OtherIso = (bool)item.OtherIso, Other = item.Other,
                    CompanyWebsite                 = item.CompanyWebsite, PrimaryContactForAuditPurposes = item.PrimaryContactForAuditPurposes, PrimaryContactTelephone = item.PrimaryContactTelephone,
                    NatureOfBusiness               = item.NatureOfBusiness, NumberOfYearsAtThisSite = item.NumberOfYearsAtThisSite, PrincipleServicesOrProducts = item.PrincipleServicesOrProducts,
                    ActivitiesOnClientsSites       = item.ActivitiesOnClientsSites, NameOfPresentCertificationBody = item.NameOfPresentCertificationBody, CertificateExpiryDate = item.CertificateExpiryDate,
                    TotalNumberOfEmployees         = item.TotalNumberOfEmployees, TotalNumberOfCompanyDirectors = item.TotalNumberOfCompanyDirectors, NumberOfLocations = item.NumberOfLocations,
                    AllSitesMainActivites          = item.AllSitesMainActivites, SalesTotalPermanent = item.SalesTotalPermanent, SalesTotalTemporary = item.SalesTotalTemporary, MarketingTotalPermanent = item.MarketingTotalPermanent, ManufacturingTotalTemporary = item.ManufacturingTotalTemporary,
                    MarketingTotalTemporary        = item.MarketingTotalTemporary, AdministrationTotalPermanent = item.AdministrationTotalPermanent, AdministrationTotalTemporary = item.AdministrationTotalTemporary,
                    DesignTotalPermanent           = item.DesignTotalPermanent, DesignTotalTemporary = item.DesignTotalTemporary, ManufacturingTotalPermanent = item.ManufacturingTotalPermanent,
                    OtherTotalPermanent            = item.OtherTotalPermanent, OtherTotalTemporary = item.OtherTotalTemporary, TotalPermanent = item.TotalPermanent, TotalTemporary = item.TotalTemporary, Extension = item.Extension, ManagementRepresentativeName = item.ManagementRepresentativeName,
                    JobTitle                       = item.JobTitle, NameOfConsultant = item.NameOfConsultant, ConsultantTelephone = item.ConsultantTelephone, ISO14001_2 = (bool)item.ISO14001_2, ISO9001_2 = (bool)item.ISO9001_2,
                    ISO22301_2                     = (bool)item.ISO22301_2, ISO27001_2 = (bool)item.ISO27001_2, BSOHSAS18001_2 = (bool)item.BSOHSAS18001_2, StandardTransferred = item.StandardTransferred,
                    DateNextCertificationBodyVisit = item.DateNextCertificationBodyVisit, Other_2 = item.Other_2, OtherIso_2 = (bool)item.OtherIso_2, date_created = (DateTime)item.DateCreated
                };

                model.Applications.ListOfApplication.Add(applicationModel);
            }

            return(model);
        }
Example #16
0
        private static void LoadDefinition(GridDescriptor gridDescriptor, RasterGridPrescription prescription)
        {
            prescription.BoundingBox      = new BoundingBox();
            prescription.BoundingBox.MinY = new NumericRepresentationValue(RepresentationInstanceList.vrLatitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), gridDescriptor.Origin.Y));
            prescription.BoundingBox.MinX = new NumericRepresentationValue(RepresentationInstanceList.vrLongitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), gridDescriptor.Origin.X));
            var maxYValue = prescription.BoundingBox.MinY.Value.Value + gridDescriptor.CellHeight.Value.Value * gridDescriptor.RowCount;
            var maxXValue = prescription.BoundingBox.MinX.Value.Value + gridDescriptor.CellWidth.Value.Value * gridDescriptor.ColumnCount;

            prescription.BoundingBox.MaxY = new NumericRepresentationValue(RepresentationInstanceList.vrLatitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), maxYValue));
            prescription.BoundingBox.MaxX = new NumericRepresentationValue(RepresentationInstanceList.vrLongitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), maxXValue));

            prescription.Origin     = gridDescriptor.Origin;
            prescription.CellHeight = gridDescriptor.CellHeight;
            prescription.CellWidth  = gridDescriptor.CellWidth;

            prescription.ColumnCount = gridDescriptor.ColumnCount;
            prescription.RowCount    = gridDescriptor.RowCount;
        }
Example #17
0
        private List <RxCellLookup> ImportRatesFromProducts(GridDescriptor gridDescriptor, List <int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List <RxCellLookup>();

            foreach (var productRates in gridDescriptor.ProductRates)
            {
                var lookup = new RxCellLookup {
                    RxRates = new List <RxRate>()
                };
                for (int productIndex = 0; productIndex < productRates.Count; productIndex++)
                {
                    int adaptProductId = productIds[productIndex];
                    lookup.RxRates.Add(PrescriptionMapper.ImportRate(adaptProductId, productRates[productIndex], prescription));
                }
                rates.Add(lookup);
            }

            return(rates);
        }
        public ActionResult ApplySubgroupTableFilters(GridDescriptor request, SearchSubgroupsFilters filters)
        {
            filters = _subgroupBinder.BreadcrumbNavigationGetSet(filters);
            SubgroupsModel model = null;

            if (request == null || (request != null && request.Pager == null) || (request != null && request.Sort != null && request.Sort.PropertyName == null))
            {
                model = _subgroupBinder.GetSubgroupsModel(new GridDescriptor(new SortDescriptor()
                {
                    PropertyName = "SourceText", Order = SortOrder.Ascending
                }), filters, materialContextUow);
            }
            else
            {
                model = _subgroupBinder.GetSubgroupsModel(request, filters, materialContextUow);
            }

            return(Json(ResponseStatus.Success, RenderPartialViewToString("SubgroupResults", model), JsonRequestBehavior.AllowGet));
        }
Example #19
0
        private List <RxRates> LoadRatesFromProducts(GridDescriptor gridDescriptor, List <int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List <RxRates>();

            foreach (var productRates in gridDescriptor.ProductRates)
            {
                var rate = new RxRates {
                    RxRate = new List <RxRate>()
                };

                for (int productIndex = 0; productIndex < productRates.Count; productIndex++)
                {
                    var           adaptProductId = productIds[productIndex];
                    UnitOfMeasure uom            = null;
                    AddRate(adaptProductId, productRates[productIndex], rate, prescription, uom);
                }

                rates.Add(rate);
            }

            return(rates);
        }
Example #20
0
        public GridDescriptor Build(Domain.QueryView view, List <Schema.Domain.Entity> entities, List <Schema.Domain.Attribute> attributes)
        {
            var            gridBuilder = new GridBuilder(view);
            GridDescriptor grid        = gridBuilder.Grid;
            int            i           = 0;

            foreach (var cell in grid.Rows[0].Cells)
            {
                if (cell.Label.IsEmpty())
                {
                    if (cell.EntityName.IsCaseInsensitiveEqual(view.EntityName))//主实体
                    {
                        var attr = attributes.Find(x => x.Name.IsCaseInsensitiveEqual(cell.Name) && x.EntityName.IsCaseInsensitiveEqual(view.EntityName));
                        if (attr != null)
                        {
                            grid.Rows[0].Cells[i].Label = attr.LocalizedName;
                        }
                    }
                    else //关联实体
                    {
                        //当列为关联实体字段时,列名加上关联实体名
                        var temp = cell.Name.SplitSafe(".");
                        if (temp.Length > 1)
                        {
                            var attr = attributes.Find(x => x.Name.IsCaseInsensitiveEqual(temp[1]) && x.EntityName.IsCaseInsensitiveEqual(cell.EntityName));
                            if (attr != null)
                            {
                                grid.Rows[0].Cells[i].Label = attr.LocalizedName + "(" + attr.EntityLocalizedName + ")";
                            }
                        }
                    }
                }
                i++;
            }

            return(grid);
        }
Example #21
0
        private static void LoadDefinition(GridDescriptor gridDescriptor, RasterGridPrescription prescription)
        {
            prescription.BoundingBox = new BoundingBox();
            prescription.BoundingBox.MinY = new NumericRepresentationValue(RepresentationInstanceList.vrLatitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), gridDescriptor.Origin.Y));
            prescription.BoundingBox.MinX = new NumericRepresentationValue(RepresentationInstanceList.vrLongitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), gridDescriptor.Origin.X));
            var maxYValue = prescription.BoundingBox.MinY.Value.Value + gridDescriptor.CellHeight.Value.Value * gridDescriptor.RowCount;
            var maxXValue = prescription.BoundingBox.MinX.Value.Value + gridDescriptor.CellWidth.Value.Value * gridDescriptor.ColumnCount;
            prescription.BoundingBox.MaxY = new NumericRepresentationValue(RepresentationInstanceList.vrLatitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), maxYValue));
            prescription.BoundingBox.MaxX = new NumericRepresentationValue(RepresentationInstanceList.vrLongitude.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("arcdeg"), maxXValue));

            prescription.Origin = gridDescriptor.Origin;
            prescription.CellHeight = gridDescriptor.CellHeight;
            prescription.CellWidth = gridDescriptor.CellWidth;

            prescription.ColumnCount = gridDescriptor.ColumnCount;
            prescription.RowCount = gridDescriptor.RowCount;
        }
Example #22
0
        public JsonResult FindApplication(ApplicationListFilterModel filters, GridDescriptor request)
        {
            ApplicationList model = HomeBuilder.FilterApplications(Db, request, filters);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("ApplicationList", model)));
        }
Example #23
0
        public static IHtmlString DescriptorToJson(this HtmlHelper helper, GridDescriptor descriptor)
        {
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(descriptor);

            return(MvcHtmlString.Create(json));
        }
Example #24
0
        public SubgroupsModel GetSubgroupsModel(GridDescriptor request, SearchSubgroupsFilters filters, IMaterialsContextUow context)
        {
            SubgroupsModel model = new SubgroupsModel();

            model.Descriptor = request;
            ICollection <Material> materials = GetAllEquivalentMaterialsEn(filters.MaterialId, context);

            model.MaterialInfo = materials.FirstOrDefault();
            var standardList = materials.Select(m => new PropertyGroupModel {
                PropertyGroupModelName = m.Standard
            }).Distinct(new PropertyGroupComparer()).OrderBy(m => m.PropertyGroupModelName).ToList();

            var sourcesInitial = materials.Select(m => string.Concat(m.SourceId, "#", m.DatabookId)).Distinct();



            int databookId = 0;

            if (filters.SourceId > 0)
            {
                bool isInt = int.TryParse(filters.Source.Split('#')[1], out databookId);
                databookId = isInt ? databookId : 0;

                materials = materials.Where(m => m.SourceId == filters.SourceId && m.DatabookId == databookId).ToList();
            }

            if (filters.StandardId != null && filters.StandardId != "" && filters.StandardId != "0")
            {
                materials = materials.Where(m => m.Standard == filters.StandardId).ToList();
            }

            if (filters.Specification != "" && filters.Specification != null)
            {
                materials = materials.Where(m => m.Specification.ToLower().Contains(filters.Specification.ToLower())).ToList();
            }

            IEnumerable <Material> materialsEnum = materials.AsEnumerable();

            SearchFilterColumnsAll columnFilters = (SearchFilterColumnsAll)System.Web.HttpContext.Current.Session["SubgroupListResults"];

            if (columnFilters != null)
            {
                foreach (SearchFilterColumns f in columnFilters.AllFilters.Where(c => c.Filter != null && c.Filter.Trim() != ""))
                {
                    string oneFilter = f.Filter.Trim().ToUpper();
                    if (f.Name == "Reference")
                    {
                        materialsEnum = materialsEnum.Where(m => m.SourceText != null && m.SourceText.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Supplier")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Manufacturer != null && m.Manufacturer.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Std. Org. / Country")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Standard != null && m.Standard.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Specification")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Specification != null && m.Specification.ToUpper().Contains(oneFilter));
                    }
                    else if (f.Name == "Filler")
                    {
                        materialsEnum = materialsEnum.Where(m => m.Filler != null && m.Filler.ToUpper().Contains(oneFilter));
                    }
                }
            }

            model.Materials = materialsEnum.ToList();
            model.Descriptor.Pager.TotalRecordCount = model.Materials.Count;
            model.Descriptor = request;
            if (model.Materials.Count > 0)
            {
                model.Name = model.Materials[0].Name;
            }
            else
            {
                model.Name = "";
            }


            SearchSubgroupCondition filterModel = new SearchSubgroupCondition();

            filterModel.SourceId              = filters.SourceId;
            filterModel.StandardId            = filters.StandardId;
            filterModel.Specification         = filters.Specification;
            filterModel.FullText              = filters.filter;
            filterModel.ShowPropertiesFilters = false;
            //IEnumerable<string> subSources = sourcesInitial.Select(m => string.Concat(m.SourceId, "#", m.DatabookId)).Distinct();
            filterModel.Sources = context.Sources.AllAsNoTracking.Where(s =>
                                                                        s.Id == 0 || /* for All */
                                                                        sourcesInitial.Contains(string.Concat(s.Id, "#", s.Databook_id))
                                                                        ).ToList();
            filterModel.PropertyGroups        = standardList;
            filterModel.MaterialId            = filters.MaterialId;
            filterModel.ShowPropertiesFilters = false;
            filterModel.FromBrowse            = filters.FromBrowse;
            filterModel.FromAdvanced          = filters.FromAdvanced;
            filterModel.SelectedSource        = filters.Source;

            model.Filters = filterModel;
            return(model);
        }
Example #25
0
        public IList <Material> GetEquivalentMaterials(int id, GridDescriptor request, IMaterialsContextUow context)
        {
            IList <Material> tmp = GetAllEquivalentMaterials(id, context);

            return(tmp.Page(request.Pager).ToList());
        }
Example #26
0
        public static ClientList FilterClients(DASEntities db, GridDescriptor desc, FilterModel filters)
        {
            ClientList model = new ClientList()
            {
                Descriptor = desc, ListOfClients = new List <ClientModel>()
            };
            IQueryable <Client> clients = db.Clients.AsQueryable();
            IQueryable <vw_ClientsBackoffice> clientsF = db.vw_ClientsBackoffice.AsQueryable();
            string filStandard = "";

            if (filters == null)
            {
                filters = new FilterModel();
            }


            if (!string.IsNullOrWhiteSpace(filters.Name))
            {
                filStandard = filters.Name.Replace(":", "").Replace("/", "").Replace("-", "").Replace("–", "").Replace("\"", "").Replace(".", "");
                clientsF    = clientsF.Where(m => m.Name.Contains(filStandard));
            }


            if (filters.SelectedStatusId != 0)
            {
                if (!string.IsNullOrWhiteSpace(filters.Standard))
                {
                    clientsF = clientsF.Where(b => b.StatusId == filters.SelectedStatusId && b.Standard.Contains(filters.Standard));
                }
                else
                {
                    clientsF = clientsF.Where(m => m.StatusId == filters.SelectedStatusId);
                }
            }
            else if (!string.IsNullOrWhiteSpace(filters.Standard))
            {
                clientsF = clientsF.Where(m => m.Standard.Contains(filters.Standard));
            }

            IList <int> clientIds = clientsF.Select(k => k.ClientId).Distinct().ToList();


            IList <Client> listC = clients.Where(h => clientIds.Contains(h.ClientId)).Slice(desc).ToList();
            ClientModel    clientM;
            CertModel      certM;

            foreach (var item in listC)
            {
                clientM = new ClientModel()
                {
                    ClientId = item.ClientId, Address = item.Address, ClientName = item.Name, Description = item.Description, Certificates = new List <CertModel>()
                };
                foreach (var itemC in item.Certificates)
                {
                    if ((string.IsNullOrWhiteSpace(filters.Standard) || itemC.Standard.Contains(filters.Standard.ToUpper())) && (filters.SelectedStatusId == 0 || filters.SelectedStatusId == itemC.StatusId))
                    {
                        certM = new CertModel()
                        {
                            CertId = itemC.CertificateId, CertName = itemC.CertificateName, Standard = itemC.Standard
                        };
                        certM.Status = GetStatusName(db, itemC.StatusId);
                        clientM.Certificates.Add(certM);
                    }
                }
                model.ListOfClients.Add(clientM);
            }
            return(model);
        }
        public JsonResult ApplyAdvSearchSource(AdvSearchFiltersAll filters, GridDescriptor request)
        {
            filters = BreadcrumbNavigationGetSet(filters);

            return(Json(ResponseStatus.Success, new { url = Url.Action("AdvSearchResults", "AdvSearch") }, JsonRequestBehavior.AllowGet));
        }
Example #28
0
        private void LoadRates(XmlNode inputNode, GridDescriptor gridDescriptor, Dictionary<int, TreatmentZone> treatmentZones, RasterGridPrescription prescription)
        {
            prescription.LossOfGpsRate = LoadRateFromTreatmentZones(inputNode.GetXmlNodeValue("@I"), treatmentZones).FirstOrDefault();
            prescription.OutOfFieldRate = LoadRateFromTreatmentZones(inputNode.GetXmlNodeValue("@J"), treatmentZones).FirstOrDefault();

            if (gridDescriptor.TreatmentZones != null)
            {
                var treatmentZone = treatmentZones.FindById(gridDescriptor.TreatmentZones.First());
                if (treatmentZone == null)
                    return;

                LoadProducts(treatmentZone, prescription);
                LoadRateUnits(treatmentZone, prescription);
                prescription.Rates = LoadRatesFromTreatmentZones(gridDescriptor, treatmentZones, prescription.ProductIds, prescription);
            }
            else if (gridDescriptor.ProductRates != null)
            {
                var treatmentZoneTemplate = treatmentZones.FindById(gridDescriptor.ProductRateTemplateId);
                if (treatmentZoneTemplate == null)
                    return;

                LoadProducts(treatmentZoneTemplate, prescription);
                LoadRateUnits(treatmentZoneTemplate, prescription);
                prescription.Rates = LoadRatesFromProducts(gridDescriptor, prescription.ProductIds, prescription);
            }
        }
Example #29
0
 private GridLoader(string baseFolder, Dictionary<int, TreatmentZone> treatmentZones)
 {
     _descriptor = new GridDescriptor();
     _baseFolder = baseFolder;
     _treatmentZones = treatmentZones;
 }
Example #30
0
        private static List<RxRates> LoadRatesFromTreatmentZones(GridDescriptor gridDescriptor, Dictionary<int, TreatmentZone> treatmentZones, List<int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List<RxRates>();
            foreach (var treatmentZoneId in gridDescriptor.TreatmentZones)
            {
                var treatmentZone = treatmentZones.FindById(treatmentZoneId);
                if (treatmentZone == null)
                    return null;

                var rate = new RxRates { RxRate = new List<RxRate>() };

                for (int i = 0; i < treatmentZone.Variables.Count; i++)
                {
                    var dataVariable = treatmentZone.Variables[i];
                    AddRate(productIds[i], dataVariable.Value, rate, prescription, treatmentZone.Variables[i].IsoUnit.ToAdaptUnit());
                }

                rates.Add(rate);
            }

            return rates;
        }
        public JsonResult ApplyPager(GridDescriptor request)
        {
            BreadcrumbNavigation nav = (BreadcrumbNavigation)System.Web.HttpContext.Current.Session["Navigation"];

            if (nav == null)
            {
                nav = new BreadcrumbNavigation();
            }
            AdvSearchFiltersAll filters = new AdvSearchFiltersAll();

            AdvancedSearchResults res = nav.GetOrderedItems().Where(n => n.NavigableID == "AdvancedSearchResults").FirstOrDefault() as AdvancedSearchResults;

            if (res != null)
            {
                filters = res.PageData as AdvSearchFiltersAll;
            }
            nav.LastNavigable = "AdvancedSearchResults";
            System.Web.HttpContext.Current.Session["Navigation"] = nav;

            BaseSearchModel model = new BaseSearchModel();

            if (request.Pager == null)
            {
                request = new GridDescriptor(new SortDescriptor()
                {
                    PropertyName = "Name", Order = SortOrder.Ascending
                });
            }
            model.Descriptor = request;
            if (filters.StructureSearch != null)
            {
                StringBuilder sb = new StringBuilder(65536);

                byte[] bytesData = Encoding.ASCII.GetBytes("query=" + filters.StructureSearch.Query + ";exactsearch=" + filters.StructureSearch.Exactsearch + ";stereo=" + filters.StructureSearch.Stereo + "\0");

                var    result    = StructureSearch(bytesData, sb, sb.Capacity);
                string recordIds = sb.Replace(";", ",").ToString().Trim().TrimEnd(',');

                if (!string.IsNullOrEmpty(recordIds))
                {
                    model.ListOfMaterials = _searchResultsBinder.GetResultsStructureAdvSearch(recordIds, request, materialContextUow);
                }
                model.IsStructureSearch = true;
            }
            else
            {
                model.ListOfMaterials = _searchResultsBinder.GetResultsAdvSearch(filters, request, materialContextUow);
            }
            SearchResultsCondition filterModel = new SearchResultsCondition();

            //filterModel.ClasificationId = filters.ClasificationId;
            //filterModel.ClasificationTypeId = filters.ClasificationTypeId;
            filterModel.FullText = "";
            filterModel.ShowPropertiesFilters = false;
            filterModel.FromBrowse            = false;
            filterModel.FromAdvanced          = true;
            // add Sources to model
            filterModel.Sources        = materialContextUow.Sources.AllAsNoTracking.OrderBy(m => m.Id).ThenBy(n => n.Name).ToList();
            filterModel.SelectedSource = filters.SelectedSource;
            model.Filter = filterModel;
            //BreadcrumbNavigationGetSet(filters);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("AdvResultsContainer", model), JsonRequestBehavior.AllowGet));
        }
Example #32
0
        private List<RxRates> LoadRatesFromProducts(GridDescriptor gridDescriptor, List<int> productIds, RasterGridPrescription prescription)
        {
            var rates = new List<RxRates>();
            foreach (var productRates in gridDescriptor.ProductRates)
            {
                var rate = new RxRates { RxRate = new List<RxRate>() };

                for (int productIndex = 0; productIndex < productRates.Count; productIndex++)
                {
                    var adaptProductId = productIds[productIndex];
                    UnitOfMeasure uom = null;
                    AddRate(adaptProductId, productRates[productIndex], rate, prescription, uom);
                }

                rates.Add(rate);
            }

            return rates;
        }
Example #33
0
        /// <summary>
        /// 生成默认视图
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public (Domain.QueryView DefaultView, List <Dependency.Domain.Dependency> Dependents) Get(Schema.Domain.Entity entity, List <Schema.Domain.Attribute> attributes)
        {
            Domain.QueryView view = new Domain.QueryView
            {
                Name        = entity.LocalizedName,
                EntityId    = entity.EntityId,
                EntityName  = entity.Name,
                IsDefault   = true,
                StateCode   = Core.RecordState.Enabled,
                IsPrivate   = false,
                QueryViewId = Guid.NewGuid(),
                CreatedBy   = entity.CreatedBy
            };
            //fetch
            QueryExpression _queryExpression = new QueryExpression(entity.Name, _appContext.GetFeature <ICurrentUser>().UserSettings.LanguageId);

            _queryExpression.Distinct = false;
            _queryExpression.NoLock   = true;
            _queryExpression.AddOrder("createdon", OrderType.Descending);
            var primaryField = attributes.Find(n => n.IsPrimaryField);

            _queryExpression.ColumnSet = new ColumnSet(primaryField.Name.ToLower(), "createdon");
            if (entity.EntityMask == EntityMaskEnum.User)
            {
                _queryExpression.ColumnSet.AddColumn("ownerid");
            }
            view.FetchConfig = _queryExpression.SerializeToJson();
            //layout
            GridDescriptor grid = new GridDescriptor();
            RowDescriptor  row  = new RowDescriptor();

            row.AddCell(new CellDescriptor()
            {
                Name = primaryField.Name.ToLower(), EntityName = entity.Name, IsHidden = false, IsSortable = true, Width = 150
            });
            row.AddCell(new CellDescriptor()
            {
                Name = "createdon", EntityName = entity.Name, IsHidden = false, IsSortable = true, Width = 150
            });
            if (entity.EntityMask == EntityMaskEnum.User)
            {
                row.AddCell(new CellDescriptor()
                {
                    Name = "ownerid", EntityName = entity.Name, IsHidden = false, IsSortable = true, Width = 150
                });
            }
            grid.AddRow(row);
            grid.AddSort(new QueryColumnSortInfo("createdon", false));
            view.LayoutConfig = grid.SerializeToJson(false);

            var dependents = new List <Dependency.Domain.Dependency>();

            foreach (var item in attributes.Where(x => x.Name.IsCaseInsensitiveEqual(primaryField.Name) || x.Name.IsCaseInsensitiveEqual("createdon") || x.Name.IsCaseInsensitiveEqual("ownerid")))
            {
                var dp = new Dependency.Domain.Dependency();
                //dp.DependentComponentType = DependencyComponentTypes.Get(QueryViewDefaults.ModuleName);
                dp.DependentObjectId = view.QueryViewId;
                //dp.RequiredComponentType = DependencyComponentTypes.Get(AttributeDefaults.ModuleName);
                dp.RequiredObjectId = item.AttributeId;
                dependents.Add(dp);
            }
            return(view, dependents);
        }
Example #34
0
        public JsonResult FindClients(FilterModel filters, GridDescriptor request)
        {
            ClientList model = HomeBuilder.FilterClients(Db, request, filters);

            return(Json(ResponseStatus.Success, RenderPartialViewToString("ClientList", model)));
        }
Example #35
0
        public static ClientsModel BuildClients(DASEntities db)
        {
            ClientsModel model      = new ClientsModel();
            int          languageId = (int)HttpContext.Current.Session["lngId"];

            model.Filters = new FilterModel();

            model.Filters.Statuses = BuildStatuses(db);
            /*todo; dodati labelu Svi u labels*/

            string stat = "...";

            stat = db.Labels.Where(s => s.ViewId == "Clients" && s.ElementId == "lblSearchStat" && s.LanguageId == languageId).Select(ps => ps.Text).FirstOrDefault();

            model.Filters.Statuses.Add(new StatusModel()
            {
                StatusId = 0, StatusName = stat
            });
            /*in backoffice selected status is All*/
            model.Filters.SelectedStatusId = 0;
            model.Filters.Statuses         = model.Filters.Statuses.OrderBy(m => m.StatusId).ToList();

            GridDescriptor desc = new GridDescriptor(new SortDescriptor()
            {
                PropertyName = "DateChange", Order = SortOrder.Descending
            })
            {
                Pager = new PagerDescriptor(1, 20, db.Labels.Where(l => l.ViewId == "Clients" && l.ElementId == "lblPageSize" && l.LanguageId == languageId).Select(l => l.Text).FirstOrDefault(), 5)
            };

            IQueryable <Client> clients = db.Clients.AsQueryable();

            /*initial filter will be only with active status*/
            //clients = clients.Where(m => m.Certificates.Any(l => l.StatusId == 1));
            IList <Client> listC = clients.Slice(desc).ToList();

            model.Clients = new ClientList()
            {
                Descriptor = desc, ListOfClients = new List <ClientModel>()
            };
            ClientModel clientM;
            CertModel   certM;

            foreach (var item in listC)
            {
                clientM = new ClientModel()
                {
                    ClientId = item.ClientId, Address = item.Address, ClientName = item.Name, Description = item.Description, Certificates = new List <CertModel>()
                };
                foreach (var itemC in item.Certificates)
                {
                    //if (itemC.StatusId==1)
                    //{
                    certM = new CertModel()
                    {
                        CertId = itemC.CertificateId, CertName = itemC.CertificateName, Standard = itemC.Standard
                    };
                    certM.Status = GetStatusName(db, itemC.StatusId);
                    clientM.Certificates.Add(certM);
                    //}
                }
                model.Clients.ListOfClients.Add(clientM);
            }
            return(model);
        }