Пример #1
0
        public void CreatePdf(int catalogueId, string searchPhrase, System.IO.Stream memoryStream)
        {
            Catalogue catalogue = _uow.Catalogues.Get(b => b.Id == catalogueId, null, b => b.SousSerie.Serie).FirstOrDefault();

            var searchTerms = _wordSearchParser.Parse(searchPhrase);

            var pdfManager = _pdfManager.Create(memoryStream);

            pdfManager.AddNewPage();
            if (searchTerms.Any())
            {
                pdfManager.WriteText(String.Format("[Mot recherche : {0}]", String.Join(", ", searchTerms.Select(b => b.SearchVal))), null, null, null, true);
            }

            var serie     = catalogue.SousSerie.Serie;
            var serieName = String.Format("Série {0} - {1}", serie.Code, serie.Nom);

            pdfManager.WriteTitle(serieName, 0, true);
            if (!String.IsNullOrWhiteSpace(catalogue.SousSerie.Nom))
            {
                pdfManager.WriteTitle(catalogue.SousSerie.Nom, 1, true, true, false, true);
            }

            pdfManager.WriteCatalogue(catalogue.Titre, catalogue.Cote, searchTerms.Select(b => new KeyValuePair <string, bool>(b.Val, b.WordBoundary)).ToList());
            pdfManager.Close();
        }
Пример #2
0
        private void initModel(RechercheCatalogueViewModel model)
        {
            model.Series = _unitOfWork.Series.Get(includeProperties: b => b.SousSeries);

            if (model.SousSerieId.HasValue)
            {
                model.SousSerie = model.Series.SelectMany(s => s.SousSeries).SingleOrDefault(ss => ss.Id == model.SousSerieId.Value);

                if (model.SousSerie == null)
                {
                    model.SousSerieId = null;
                }
            }

            model.MarkableElement = _wordSearchparser.Parse(model.Titre).ToList();
        }
Пример #3
0
        public PaginationResult <IList <FondMedium> > GetFondMedium(int fondId, string searchTerms, IEnumerable <int> index, List <Tuple <int, string, TypeColonneFond> > informationsFilters,
                                                                    PaginationRequest paginationRequest)
        {
            ResultAndCountModel result;

            try
            {
                if (Context.Database.Connection.State != ConnectionState.Open)
                {
                    Context.Database.Connection.Open();
                }

                var cmd = Context.Database.Connection.CreateCommand();

                // CREATION PARAMETRES
                DataTable dtIndex = new DataTable();
                dtIndex.Columns.Add("Id", typeof(int));
                index.ToList().ForEach(b => dtIndex.Rows.Add(b));

                DataTable dtFondInformationValue = new DataTable();
                dtFondInformationValue.Columns.Add("Id", typeof(int));
                dtFondInformationValue.Columns.Add("Value", typeof(string));
                informationsFilters.ToList().ForEach(b => dtFondInformationValue.Rows.Add(b.Item1, GetValue(b.Item2, b.Item3)));

                DataTable dtWordSearch = new DataTable();
                dtWordSearch.Columns.Add("Libelle", typeof(string));
                dtWordSearch.Columns.Add("WordBoundary", typeof(bool));
                _wordSearchParser.Parse(searchTerms).ToList().ForEach(b => dtWordSearch.Rows.Add(b.Val, b.WordBoundary));

                SqlParameter searchTermsParams = new SqlParameter("@searchTerm", SqlDbType.Structured)
                {
                    Value = dtWordSearch
                };
                SqlParameter fondIdParams = new SqlParameter("@fondId", SqlDbType.Int)
                {
                    Value = fondId
                };
                SqlParameter indexPraram = new SqlParameter("@index", SqlDbType.Structured)
                {
                    Value = dtIndex
                };
                SqlParameter fondInformationValueParam = new SqlParameter("@FondInformationValues", SqlDbType.Structured)
                {
                    Value = dtFondInformationValue
                };
                SqlParameter pageNumberParams = new SqlParameter("@pageNumber", SqlDbType.Int)
                {
                    Value = paginationRequest.PageNumber
                };
                SqlParameter pageSizeParams = new SqlParameter("@pageSize", SqlDbType.Int)
                {
                    Value = paginationRequest.PageSize
                };


                cmd.CommandText = "dbo.GetMediaFond";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(searchTermsParams);
                cmd.Parameters.Add(fondIdParams);
                cmd.Parameters.Add(indexPraram);
                cmd.Parameters.Add(fondInformationValueParam);
                cmd.Parameters.Add(pageNumberParams);
                cmd.Parameters.Add(pageSizeParams);

                result = SqlDataReaderHelper.ExecuteCommand(cmd);
            }
            finally
            {
                if (Context.Database.Connection.State == ConnectionState.Open)
                {
                    Context.Database.Connection.Close();
                }
            }


            var fondMediums = this.Get(b => result.Ids.Contains(b.Id),
                                       b => b.OrderByDescending(o => o.Titre.Contains(searchTerms)), b => b.ColonneFondMedium,
                                       b => b.Fond.InformationAffichageFonds,
                                       b => b.ColonneFondMedium.Select(col => col.InformationFond),
                                       b => b.Tags.Select(t => t.Tag));

            return(new PaginationResult <IList <FondMedium> >(result.Count, fondMediums));
        }
Пример #4
0
        public string BuildContainsPredicate(string inputSearch)
        {
            var predicate = String.Join(" AND ", _wordSearchParser.Parse(inputSearch).Select(b => BuildPredicate(b)));

            return(String.IsNullOrWhiteSpace(predicate) ? null : String.Format("({0})", predicate));
        }