private static LinksToHtmlModel CreateEuroCasesHtmlModel(String docNumber, String toPar, String domain, String baseUrl, int limit, int langId, int siteLangId, out String documentTitle, out String documentLink) { documentTitle = String.Empty; documentLink = String.Empty; LinksToHtmlModel result = null; var linkInfo = Doc.GetLinkInfo(docNumber, toPar, null, langId); if (linkInfo != null) { int docLangId = Convert.ToInt32(linkInfo["doc_lang_id"]); var docType = Convert.ToInt32(linkInfo["doc_type"]); documentTitle = linkInfo["title"]; int? parId = null; bool isParsed = int.TryParse(linkInfo["doc_par_id"], out int currentParId); if (isParsed) { parId = new Nullable <int>(currentParId); } if (!string.IsNullOrEmpty(linkInfo["par_title"])) { documentTitle = AppendToPartTitleFromCelexAndToPar(documentTitle, docNumber, toPar, langId, linkInfo["par_title"]); } documentLink = new EurocasesDocumentLink(title: documentTitle, originalUrl: String.Empty, publisher: String.Empty, baseUrl: baseUrl, docLangId: docLangId, documentType: docType).GetUrl(); var eurocasesDocLinks = EurocasesDocumentLink.FromDocLinks(Doc.GetDocInLinks(docLangId, parId, domain, null, langId, limit, out int totalCount), baseUrl); var allLinksUrl = EuroCasesHelper.BuildAllUrlForDocInLinks(baseUrl: baseUrl, langId: langId, uiLangId: siteLangId, domain: domain, docNumber: docNumber, toPar: toPar); result = LinksToHtmlModel.Create(eurocasesDocLinks, totalCount, limit, allLinksUrl, "EuroCases"); } else { linkInfo = Doc.GetLinkInfo(docNumber, null, null, langId); if (linkInfo != null) { documentTitle = linkInfo["title"]; if (!string.IsNullOrEmpty(toPar)) { documentTitle = AppendToPartTitleFromCelexAndToPar(documentTitle, docNumber, toPar, langId, String.Empty); } int docLangId = Convert.ToInt32(linkInfo["doc_lang_id"]); var docType = Convert.ToInt32(linkInfo["doc_type"]); documentLink = new EurocasesDocumentLink(title: documentTitle, originalUrl: String.Empty, publisher: String.Empty, baseUrl: baseUrl, docLangId: docLangId, documentType: docType).GetUrl(); } } return(result); }
private HttpResponseMessage SearchByClassifierId(string classifierId, string domain, int langId, int siteLangId, int limitPerSource) { ChangeLangCulture(langId); List <int> l = new List <int>(); string baseUrl = HttpContext.Current.Request.Url.AbsoluteUri; baseUrl = baseUrl.Substring(0, baseUrl.IndexOf("/api")); ClassificationService.ClassificatorTreeModel ci = null; if (!String.IsNullOrEmpty(classifierId)) { ci = ClassifiersProvider.Service.GetTreeByGuid(classifierId); } StringBuilder result = new StringBuilder(); if (ci == null) // Eurovoc term is not found { string title = Resources.Resources.UI_SearchByTerm; result.Append("<html><head><title>" + title.Replace("<br/>", " ") + "</title>"); result.Append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); result.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + baseUrl + "/Content/Styles/docapi.css\"></link>"); result.Append("</head><body>"); result.Append("<div id=\"DivTopTop\"></div>"); result.Append("<div id=\"DivTopGray\"><img src=\"" + baseUrl + "/Content/Images/EUCasesLogo.jpg\" alt=\"\"/></div>"); result.Append("<div id=\"DivHeader\"><p>" + title + "<hr/>" + Resources.Resources.UI_EurovocTermNotFound + "</p></div>"); result.Append("</body></html>"); } else { string term = ci.LanguageVariantsWithHints[langId.ToString()].Title; string title = Resources.Resources.UI_SearchByTerm + " \"" + term + "\"<br/>"; string searchQuery = "classificators:(" + classifierId.Replace("-", "") + ")"; switch (domain.ToLower()) { case "natcl": title += " " + Resources.Resources.UI_inNatCL; searchQuery += " props:(dtjudgment) props:(noteudoc)"; break; case "natl": title += " " + Resources.Resources.UI_inNatL; searchQuery += " props:(dtact) props:(noteudoc)"; break; case "eucl": title += " " + Resources.Resources.UI_inEUCL; searchQuery += " props:(dtjudgment) props:(eudoc)"; break; case "eul": title += " " + Resources.Resources.UI_inEUL; searchQuery += " props:(dtact) props:(eudoc)"; break; } int[] wsRes = null; //SearchBox sb = new SearchBox(langId); //sb.SearchText = term; int[] langPref = new int[] { langId, 4 }; string searchWrapperUrl = null; if (ConfigurationManager.AppSettings["SolutionVersion"] == "product") { searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath"]; } else { searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath_cc"]; } SearchResult sr = new SearchResult(SearchSources.Search, HttpContext.Current.Application["SearchWrapper"], searchWrapperUrl, HttpContext.Current.Application["FilterDocsStruct"], HttpContext.Current.Application["FilterDocsClassifiers"], HttpContext.Current.Application["ClassifiersMap"], HttpContext.Current.Application["ResultsGroupper"], HttpRuntime.AppDomainAppPath, langId, 0, 0 ); //sr.SearchBoxFilters = sb; sr.SearchFTQuery(searchQuery, ref wsRes, langPref); // wsRes = wsRes.Take(limitPerSource).ToArray(); var linksToHtmlModels = new List <LinksToHtmlModel>(); if (!String.IsNullOrEmpty(domain) && langId == 1 && // for documents which are in bulgarian domain.IsIn(StringComparison.InvariantCultureIgnoreCase, "natl", "natcl", "all")) { // only if the document is in bulgarian language var bgTitle = String.Empty; if (ci.LanguageVariantsWithHints.ContainsKey("1")) { bgTitle = ci.LanguageVariantsWithHints["1"]?.Title; } if (!string.IsNullOrEmpty(bgTitle)) { var webApisDomain = WebApisHelper.MapNormalDomainToApisDomain(domain); try { var apisSearchResponse = WebApisRequest.SearchByText(domain: webApisDomain, text: bgTitle, limit: limitPerSource); if (apisSearchResponse != null) { // var apisSearchResponse = WebApisRequest.TestData(); var htmlModel = LinksToHtmlModel.Create(apisSearchResponse.Links, apisSearchResponse.Full_Count, limitPerSource, apisSearchResponse.All_Url, "Apis Web"); linksToHtmlModels.Add(htmlModel); } } catch { } } } var docList = EurocasesDocumentLink.FromDocLinks(Doc.GetDocListByIds(wsRes.Take(limitPerSource).ToArray(), domain), baseUrl); if (docList.Any()) { var allUrl = EuroCasesHelper.BuildAllUrlForSearchByXmlId(baseUrl: baseUrl, xmlId: ci.XmlId, domain: domain, langId: langId, uiLangId: siteLangId); var linsksToHtmlMode = LinksToHtmlModel.Create(docList, wsRes.Length, limitPerSource, allUrl, "EuroCases"); linksToHtmlModels.Insert(0, linsksToHtmlMode); } result.Append(DocLinks2Html(linksToHtmlModels, title, String.Empty, limitPerSource, baseUrl, true)); } var response = this.Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(result.ToString(), Encoding.UTF8, "text/html"); return(response); }