public HttpResponseMessage ParHint(int langId, int siteLangId, int uniqueId, int dbIndex, String toPar = "") { var content = WebApisRequest.Hint(uniqueId: uniqueId, dbIndex: dbIndex, toPar: toPar); var response = this.Request.CreateResponse(HttpStatusCode.OK); response.Headers.Add("Access-Control-Allow-Origin", "*"); response.Headers.Add("Access-Control-Allow-Methods", "GET"); response.Headers.Add("Access-Control-Allow-Headers", "*"); response.Content = new StringContent(content, Encoding.UTF8, "text/html"); return(response); }
public HttpResponseMessage Cite(int langId, string docNumber, CiteType citeType, String domain = "") { var response = this.Request.CreateResponse(HttpStatusCode.OK); ChangeLangCulture(langId); var data = new CiteData { DocType = 1, Text = Resources.Resources.ApiDocCiteNotFound }; if (domain.IsIn(StringComparison.InvariantCultureIgnoreCase, "bgcite")) { var parts = docNumber.Split('_'); data.Text = WebApisRequest.Cite(code: parts[1], @base: parts[0], citeType: citeType); } else { Document doc = Doc.GetDocByDocNumber(docNumber, langId, null); if (doc != null) { string docXml = Doc.GetDocText(doc.DocLangId, doc.DocType, 1, true); // this is temporary if (citeType == CiteType.LongCite) { data.Text = AkomaNtosoPreProcessor.GetLongCitation(docXml); } else { data.Text = AkomaNtosoPreProcessor.GetShortCitation(docXml); } } } response.Headers.Remove("Access-Control-Allow-Origin"); response.Headers.Remove("Access-Control-Allow-Methods"); response.Headers.Remove("Access-Control-Allow-Headers"); response.Headers.Add("Access-Control-Allow-Origin", "*"); response.Headers.Add("Access-Control-Allow-Methods", "GET"); response.Headers.Add("Access-Control-Allow-Headers", "*"); response.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(data), Encoding.UTF8, "text/html"); return(response); }
private static LinksToHtmlModel CreateApisEuHtmlMode(String docNumber, String toPar, String domain, int limit) { LinksToHtmlModel result = null; var apisDomain = WebApisHelper.MapNormalDomainToApisForEuAct(domain); var apisResponse = WebApisRequest.GetEuDocLinks(domain: apisDomain, limit: limit, celex: docNumber, toPar: toPar); if (apisResponse != null) { result = LinksToHtmlModel.Create( links: apisResponse.Links, totalCount: apisResponse.Full_Count, limit: limit, allLinksUrl: apisResponse.All_Url, sourceName: "Apis Web"); } return(result); }
private static LinksToHtmlModel CreateApisNationalHtmlModel(String docNumber, String toPar, String domain, int limit, out String documentTitle, out String documentLink) { documentTitle = String.Empty; documentLink = String.Empty; // request web.apis.bg for links related to bg legislation or case law LinksToHtmlModel result = null; var parts = docNumber.Split('_'); if (parts.Length == 2) // only when the base and the code are provider (by convention they are splited with '_') { var apisResponse = WebApisRequest.GetDocLinks(domain: domain, limit: limit, code: parts[1], @base: parts[0], toPar: toPar); // var apisResponse = WebApisRequest.TestData(); if (apisResponse != null) { documentTitle = apisResponse.Caption; if (!String.IsNullOrEmpty(toPar)) { documentTitle = AppendToPartTitleFromCelexAndToPar(documentTitle, "fake number", toPar, 1, String.Empty); } documentLink = WebApisDocumentLink.CreateApisUrl(code: parts[1], @base: parts[0]); result = LinksToHtmlModel.Create( links: apisResponse.Links, totalCount: apisResponse.Full_Count, limit: limit, allLinksUrl: apisResponse.All_Url, sourceName: "Apis Web"); } } 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); }
public HttpResponseMessage ParHint(int langId, int siteLangId, string docNumber, string toPar = "", string domain = "") { var baseUrl = HttpContext.Current.Request.Url.AbsoluteUri; baseUrl = baseUrl.Substring(0, baseUrl.IndexOf("/api")); var response = this.Request.CreateResponse(HttpStatusCode.OK); var content = String.Empty; if (domain.IsIn(StringComparison.InvariantCultureIgnoreCase, "bgtooltip")) { ChangeLangCulture(langId); var parts = docNumber.Split('_'); content = WebApisRequest.Hint(code: parts[1], @base: parts[0], toPar: toPar); if (String.IsNullOrEmpty(content)) { content = WebApisDocumentLink.CreateApisUrl(code: parts[1], @base: parts[0]); } } else { var actualLanguageId = GetAvailableLanguageIdForDocument(docNumber, langId); ChangeLangCulture(actualLanguageId); var d = Doc.GetParText( "celex", docNumber, toPar, actualLanguageId, null, actualLanguageId, false, false, true, true); content = d.Text; content = RedirectCelexAnchorsToEurocases(content, baseUrl, actualLanguageId); if (!String.IsNullOrEmpty(content)) { content = $"<div class='eurocases-hint-wrapper'><p class='hint-header'>InterLex</p>{content}</div>"; } if (String.IsNullOrEmpty(content)) { content = Doc.CreateEurLexLink(docNumber, actualLanguageId); } } response.Headers.Add("Access-Control-Allow-Origin", "*"); response.Headers.Add("Access-Control-Allow-Methods", "GET"); response.Headers.Add("Access-Control-Allow-Headers", "*"); response.Content = new StringContent(content, Encoding.UTF8, "text/html"); return(response); }