Exemple #1
0
        public static CourtAct GetCourtAct(
            int id,
            int uiLangId,
            int userId,
            DocHighlightSearchParams highlightParams,
            int productId,
            bool showFreeDocuments = true)
        {
            CourtAct  courtAct = null;
            DataTable dt       = DB.GetDocument(id, userId, productId);

            if (dt.Rows.Count == 1)
            {
                DataRow row = dt.Rows[0];

                courtAct           = new CourtAct();
                courtAct.DocLangId = Convert.ToInt32(row["doc_lang_id"]);
                courtAct.DocType   = Convert.ToInt32(row["doc_type"]);
                courtAct.LangId    = Convert.ToInt32(row["lang_id"]);
                courtAct.Title     = row["title"].ToString();


                // refactor
                courtAct =
                    new CourtAct(
                        GetDocText(id, courtAct.DocType, productId, showFreeDocuments),
                        courtAct.LangId,
                        courtAct.DocLangId,
                        uiLangId,
                        highlightParams);

                courtAct.DocLangId     = Convert.ToInt32(row["doc_lang_id"]);
                courtAct.DocType       = Convert.ToInt32(row["doc_type"]);
                courtAct.DocNumber     = row["doc_number"].ToString();
                courtAct.LangId        = Convert.ToInt32(row["lang_id"]);
                courtAct.HasInLinks    = Convert.ToBoolean(row["has_in_links"]);
                courtAct.Title         = row["title"].ToString();
                courtAct.UserDocId     = row["user_doc_id"].ToString();
                courtAct.ProductIds    = (int[])row["products"];
                courtAct.Country       = row["country"].ToString();
                courtAct.BaseDocLangId = int.Parse(row["base_act_id"].ToString());
                courtAct.ExactMatch    = highlightParams.ExactMatch;
            }

            return(courtAct);
        }
Exemple #2
0
        private string GetDocHTML(int docId, bool isPdf)
        {
            CourtAct courtAct = CourtActBL.GetCourtAct(
                docId,
                this.Language.Id,
                UserData.UserId,
                new DocHighlightSearchParams(null, null, false, null, null),
                ProductId,
                this.UserData.ShowFreeDocuments);

            var content = GetViewString("~/Views/Doc/Act.cshtml", courtAct, true);

            StringBuilder html = new StringBuilder();

            html.Append("<html><head><meta charset=\"UTF-8\">");

            if (isPdf == true)
            {
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/doc.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/eurocases.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/layout.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/doc-list.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/doc-top-bar.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/search.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/spritecrops.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/xslt/styleActGeneral.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/xslt/styleActEuroLexJudgment.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/xslt/styleGeneral.css\">");
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/xslt/styleJudgmentGeneral.css\">");
            }
            else
            {
                html.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"../../Content/Styles/export-rtf.css\">");
            }

            html.Append("</head><body>");
            content = content.Replace("section", "div");
            content = content.Replace("header", "div");
            html.Append(content);
            html.Append("</body></html>");

            html = html.Replace("/DocImages", ConfigurationManager.AppSettings["BaseDocImagesPath"]);

            return(html.ToString());
        }
Exemple #3
0
        public ActionResult CourtAct(int id, int?siteSearchId)
        {
            CourtAct courtAct = null;

            if (this.CheckRights)
            {
                int[]             productIds = Doc.GetDocProducts(id);
                IEnumerable <int> prod       = this.UserData.Products.Select(p => p.ProductId).ToArray().Intersect(productIds);
                if (prod.Count() == 0)
                {
                    string[] products = ((List <Product>) this.Session["ProductsList"]).Where(p => productIds.Contains(p.ProductId) == true).Select(p => p.ProductName).ToArray();
                    string   errorMsg = "To open this document you need valid license for '" + String.Join("' or '", products) + "'";

                    this.ViewBag.DocError = errorMsg;
                    return(this.View(new CourtAct()));
                }
            }

            bool showFreeDocs = this.UserData.ShowFreeDocuments;

            #region Search and stats creatings
            if (siteSearchId.HasValue)
            {
                ViewBag.SiteSearchId = siteSearchId.Value;
                //int searchId = int.Parse(siteSearchId.Substring(siteSearchId.LastIndexOf('-') + 1));

                SearchResult sr = SearchResult.FindSearchResult(siteSearchId.Value, this.Session["SearchResults"]);

                if (sr != null)
                {
                    // if text is searched - add to statistic
                    if (sr.StatSearchId.HasValue)
                    {
                        Stat.SetStatSearchDoc(sr.StatSearchId.Value, id);
                    }

                    if (sr.SearchSource == SearchSources.Search)
                    {
                        if (this.Session["local-search-" + id + "-" + siteSearchId] != null && this.Session["local-search-" + id + "-" + siteSearchId].ToString() != "")
                        {
                            var highLightParams = new DocHighlightSearchParams(
                                this.Session["local-search-" + id + "-" + siteSearchId].ToString(),
                                null,
                                Convert.ToBoolean(this.Session["local-search-exactmatch-" + id + "-" + siteSearchId]),
                                null,
                                null);

                            courtAct = CourtActBL.GetCourtAct(
                                id,
                                this.Language.Id,
                                this.UserData.UserId,
                                highLightParams,
                                this.ProductId,
                                showFreeDocs);
                        }
                        else
                        {
                            var complexSearchText = sr.SearchBoxFilters.SearchText;
                            if (sr.SearchBoxFilters.Cases != null && !String.IsNullOrEmpty(sr.SearchBoxFilters.Cases.MultiDict.Text))
                            {
                                if (!String.IsNullOrEmpty(sr.SearchBoxFilters.SearchText))
                                {
                                    complexSearchText = complexSearchText + " AND (";
                                }
                                else
                                {
                                    complexSearchText = "(";
                                }

                                complexSearchText = complexSearchText + sr.SearchBoxFilters.Cases.MultiDict.Text;    // combining search text with multilingial dictionary if present
                                complexSearchText = complexSearchText.Replace("OR", "[OR]").Replace("AND", "[AND]"); // trimming logical operators
                                complexSearchText = complexSearchText + ")";
                            }
                            else if (sr.SearchBoxFilters.Law != null && !String.IsNullOrEmpty(sr.SearchBoxFilters.Law.MultiDict.Text))
                            {
                                if (!String.IsNullOrEmpty(sr.SearchBoxFilters.SearchText))
                                {
                                    complexSearchText = complexSearchText + " AND (";
                                }
                                else
                                {
                                    complexSearchText = "(";
                                }

                                complexSearchText = complexSearchText + sr.SearchBoxFilters.Law.MultiDict.Text;      // combining search text with multilingial dictionary if present
                                complexSearchText = complexSearchText.Replace("OR", "[OR]").Replace("AND", "[AND]"); // trimming logical operators
                                complexSearchText = complexSearchText + ")";
                            }
                            else if (sr.SearchBoxFilters.MultiDict != null && !String.IsNullOrEmpty(sr.SearchBoxFilters.MultiDict.Text))
                            {
                                if (!String.IsNullOrEmpty(sr.SearchBoxFilters.SearchText))
                                {
                                    complexSearchText = complexSearchText + " AND (";
                                }
                                else
                                {
                                    complexSearchText = "(";
                                }

                                complexSearchText = complexSearchText + sr.SearchBoxFilters.MultiDict.Text;          // combining search text with multilingial dictionary if present
                                complexSearchText = complexSearchText.Replace("OR", "[OR]").Replace("AND", "[AND]"); // trimming logical operators
                                complexSearchText = complexSearchText + ")";
                            }

                            var highLightParams = new DocHighlightSearchParams();

                            if (!String.IsNullOrEmpty(sr.SearchBoxFilters.SearchTextMultiLingual))
                            {
                                highLightParams.SearchText = complexSearchText;
                                highLightParams.MultilingualSearchedText = sr.SearchBoxFilters.SearchTextMultiLingual;
                                highLightParams.ExactMatch = sr.SearchBoxFilters.ExactMatch;

                                if (sr.SearchBoxFilters.Cases != null && !String.IsNullOrEmpty(sr.SearchBoxFilters.Cases.NatID_ECLI))
                                {
                                    highLightParams.SearchedCelex = sr.SearchBoxFilters.Cases.NatID_ECLI;
                                }
                                else
                                {
                                    courtAct = CourtActBL.GetCourtAct(
                                        id,
                                        this.Language.Id,
                                        this.UserData.UserId,
                                        highLightParams,
                                        this.ProductId,
                                        showFreeDocs);
                                }
                            }
                            else
                            {
                                highLightParams.SearchText = complexSearchText;
                                highLightParams.ExactMatch = sr.SearchBoxFilters.ExactMatch;

                                if (sr.SearchBoxFilters.Cases != null)
                                {
                                    if (!String.IsNullOrEmpty(sr.SearchBoxFilters.Cases.EnactmentCelex))
                                    {
                                        highLightParams.SearchedCelex = sr.SearchBoxFilters.Cases.EnactmentCelex;
                                    }

                                    if (!String.IsNullOrEmpty(sr.SearchBoxFilters.Cases.ProvisionParOriginal))
                                    {
                                        var searchedPars = new List <string>();
                                        searchedPars.Add(sr.SearchBoxFilters.Cases.ProvisionParOriginal);
                                        highLightParams.SearchedPars = searchedPars;
                                    }
                                }

                                courtAct = CourtActBL.GetCourtAct(
                                    id,
                                    this.Language.Id,
                                    this.UserData.UserId,
                                    highLightParams,
                                    this.ProductId,
                                    showFreeDocs);
                            }
                        }
                    }
                    else if (sr.SearchSource == SearchSources.InLinks)
                    {
                        var highlightParams = new DocHighlightSearchParams();
                        if (!String.IsNullOrEmpty(sr.SearchBoxFilters.DocInLinks.ToDocNumber))
                        {
                            highlightParams.SearchedCelex = sr.SearchBoxFilters.DocInLinks.ToDocNumber;
                        }

                        if (sr.SearchBoxFilters.DocInLinks.ToPars != null && sr.SearchBoxFilters.DocInLinks.ToPars.Count > 0)
                        {
                            highlightParams.SearchedPars = sr.SearchBoxFilters.DocInLinks.ToPars;
                        }

                        /* Highlight for inlinks should go here */

                        courtAct = CourtActBL.GetCourtAct(
                            id,
                            this.Language.Id,
                            this.UserData.UserId,
                            highlightParams,
                            this.ProductId,
                            showFreeDocs);
                    }
                }
            }
            else if (this.Session["local-search-" + id + "-" + siteSearchId] != null && this.Session["local-search-" + id + "-" + siteSearchId].ToString() != "")
            {
                var highLightParams = new DocHighlightSearchParams();
                highLightParams.SearchText = this.Session["local-search-" + id + "-" + siteSearchId].ToString();
                highLightParams.ExactMatch = Convert.ToBoolean(this.Session["local-search-exactmatch-" + id + "-" + siteSearchId]);

                courtAct = CourtActBL.GetCourtAct(
                    id,
                    this.Language.Id,
                    this.UserData.UserId,
                    highLightParams,
                    this.ProductId,
                    showFreeDocs);
            }
            else if (this.Session["local-search-" + id] != null && this.Session["local-search-exactmatch-" + id] != null)
            {
                var highLightParams = new DocHighlightSearchParams();
                highLightParams.SearchText = this.Session["local-search-" + id].ToString();
                highLightParams.ExactMatch = Convert.ToBoolean(this.Session["local-search-exactmatch-" + id + "-" + siteSearchId]);

                courtAct = CourtActBL.GetCourtAct(
                    id,
                    this.Language.Id,
                    this.UserData.UserId,
                    highLightParams,
                    this.ProductId,
                    showFreeDocs);
            }

            if (courtAct == null)
            {
                var highLightParams = new DocHighlightSearchParams(null, null, false, null, null);

                courtAct = CourtActBL.GetCourtAct(
                    id,
                    this.Language.Id,
                    this.UserData.UserId,
                    highLightParams,
                    this.ProductId,
                    showFreeDocs);
            }

            #endregion

            if (courtAct != null)
            {
                // Rewriting inline links before visualization
                var linkRewriter = new DocLinksRewriter(courtAct.LangId, WebAppHelper.AppRootFolder, this.UserData.OpenDocumentsInNewTab, this.NationalLegislationMapPath);
                courtAct.RewriteInLineLinks(linkRewriter);

                this.ViewBag.Title = courtAct.HtmlModel.Title.Value.ToString();
                //only limited number of docs are avaiable in sysdemo
                //List<string> avaiableDocsCelexes = ConfigurationManager.AppSettings["SysDemoDocumentsCelex"].ToString().Split(',').ToList();
                //if (this.UserData.Username.ToLower() == "sysdemo")
                //{
                //    Regex reglamentsAndDirectivesRegex = new Regex("3.{4}[RrLl](.*)");

                //    if (!((courtAct.DocType == 2 && !courtAct.DocNumber.StartsWith("7")) ||
                //        avaiableDocsCelexes.Any(c => c == courtAct.DocNumber) ||
                //        (courtAct.DocType == 1 && courtAct.DocNumber.Substring(0, 1) == "6" && courtAct.Country.ToLower() == "eu") ||
                //        reglamentsAndDirectivesRegex.IsMatch(courtAct.DocNumber) ||
                //        Doc.IsInternationalStandartDoc(courtAct.DocLangId) ||
                //        Doc.IsDemoDoc(courtAct.DocLangId)))
                //    {
                //        if (Common.CheckRequestOriginIsBotSoft(this.Request.UserAgent) || this.DemoBonusDocumentsCheck(courtAct.DocNumber) == false)
                //        {
                //            var productFeaturesInfo = new ProductFeaturesInfo(FunctionalityTypes.DocumentOpen, courtAct);
                //            string viewName = this.ProductId == 1 ? "~/Views/Shared/_ProductFeaturesInfo_Wrapper.cshtml" : "~/Views/Shared/_ProductFeaturesInfo_Finances.cshtml";
                //            this.ViewBag.UseLayout = true;
                //            return this.View(viewName, productFeaturesInfo);
                //        }
                //        else
                //        {
                //            // refresh bonus docs cookie
                //            var currentBonusDocsCookie = this.Request.Cookies["dmbnsdcs"];
                //            var newCookie = this.ComputeDemoBonusDocsCookie(currentBonusDocsCookie, courtAct.DocNumber);
                //            this.Response.Cookies.Set(newCookie);
                //        }
                //    }
                //}

                // add ro recent documents
                int maxCount     = Convert.ToInt32(ConfigurationManager.AppSettings["RecentDocumentsCount"]);
                int curProductId = 1;
                if (this.Session["SelectedProductId"] != null)
                {
                    curProductId = int.Parse(this.Session["SelectedProductId"].ToString());
                }

                if (this.UserData.Username.ToLower() != "sysdemo" ||
                    (this.UserData.Username.ToLower() == "sysdemo" && !Common.CheckRequestOriginIsBotSoft(this.Request.UserAgent)))
                {
                    Doc.AddRecentDoc(this.UserData.UserId, id, maxCount, curProductId); // add to recent documents
                    Doc.AddOpenedDoc(this.UserData.UserId, id, curProductId);           // add to stat
                }

                if (courtAct.BloblInfo.IsBlob)
                {
                    var contentType = MimeMapping.GetMimeMapping(courtAct.BloblInfo.Path);

                    return(this.File(fileName: courtAct.BloblInfo.Path, contentType: contentType));
                }
                else
                {
                    return(this.View(courtAct));
                }
            }
            else
            {
                return(this.RedirectToAction("Index", "Home"));
            }
        }