Esempio n. 1
0
        public void update(SearchLogItem logItem0, SqlCommand cmd0)
        {
            List <SearchLogNotWordItem> notWordItems_Update = new List <SearchLogNotWordItem>();
            List <SearchLogNotWordItem> notWordItems_Insert = new List <SearchLogNotWordItem>();
            List <SearchLogNotWordItem> notWordItems1       = getNotWordItems(logItem0, cmd0);

            foreach (var item1 in logItem0.notWordItems_Get())
            {
                if (item1.ID < 0)
                {
                    item1.searchLogID = logItem0.ID;
                    notWordItems_Insert.Add(item1);
                }
                else
                {
                    notWordItems_Update.Add(item1);
                }
                SearchLogNotWordItem item2 = notWordItems1.Find((x1) => { return(x1.ID == item1.ID); });
                if (item2 != null)
                {
                    notWordItems1.Remove(item2);
                }
            }
            //
            update_(notWordItems_Update, cmd0);
            insert(notWordItems_Insert, cmd0);
            delete_(notWordItems1, cmd0);
        }
Esempio n. 2
0
        public List <SearchLogResultItem> select(SearchLogItem logItem0, SqlCommand cmd0)
        {
            cmd0.CommandText = "SELECT * FROM " + tableName + " " + TABLE_NAME_ABBR +
                               " INNER JOIN " + DB_EpgEventInfo.TABLE_NAME + " " + DB_EpgEventInfo.TABLE_NAME_ABBR +
                               " ON (" + TABLE_NAME_ABBR + "." + COLUMN_epgEventInfoID + "=" + DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_ID + ")" +
                               " WHERE " + TABLE_NAME_ABBR + "." + COLUMN_searchLogID + "=" + logItem0.ID +
                               " ORDER BY " + DB_EpgEventInfo.TABLE_NAME_ABBR + "." + DB_EpgEventInfo.COLUMN_start_time;
            List <SearchLogResultItem> itemList1 = new List <SearchLogResultItem>();

            using (SqlDataReader reader1 = cmd0.ExecuteReader())
            {
                while (reader1.Read())
                {
                    int i1 = 0;
                    SearchLogResultItem resutItem1 = getItem(reader1, ref i1);
                    resutItem1.epgSearchKeyInfo = logItem0.epgSearchKeyInfoS;
                    resutItem1.epgEventInfoR    = _db_EpgEventInfo.getItem(reader1, ref i1);
                    if (!resutItem1.epgEventInfoR.isBroadcasted())    // 放送終了?
                    {
                        itemList1.Add(resutItem1);
                    }
                }
            }

            return(itemList1);
        }
Esempio n. 3
0
        /// <summary>
        /// update SearchResults of the SearchLogItem.
        /// Update or Insert, and Delete.
        /// </summary>
        /// <param name="logItem0"></param>
        /// <param name="cmd0"></param>
        public void update4LogItem(SearchLogItem logItem0, SqlCommand cmd0)
        {
            List <SearchLogResultItem> results_Update1 = new List <SearchLogResultItem>();
            List <SearchLogResultItem> results_Insert1 = new List <SearchLogResultItem>();
            //
            List <SearchLogResultItem> results_DB1 = select(logItem0, cmd0);

            for (int i = 0; i < logItem0.resultItems.Count; i++)
            {
                SearchLogResultItem result2 = results_DB1.Find(
                    x1 => x1.epgEventInfoR.Equals(logItem0.resultItems[i].epgEventInfoR));
                if (result2 != null)
                {
                    results_Update1.Add(logItem0.resultItems[i]);
                    results_DB1.Remove(result2);
                }
                else
                {
                    results_Insert1.Add(logItem0.resultItems[i]);
                }
            }
            updateEpg(results_Update1, cmd0);

            insert(results_Insert1, cmd0);
            delete(results_DB1, cmd0);
            _db_EpgEventInfo.delete(
                results_DB1.Select(x => x.epgEventInfoID), cmd0);
        }
Esempio n. 4
0
        public List <SearchLogNotWordItem> getNotWordItems(SearchLogItem searchLogItem0, SqlCommand cmd0)
        {
            List <SearchLogNotWordItem> notWordItems1 = new List <SearchLogNotWordItem>();

            cmd0.CommandText = "SELECT * FROM " + tableName + " WHERE " + COLUMN_searchLogID + "=" + searchLogItem0.ID + " ORDER BY " + COLUMN_word;
            using (SqlDataReader reader1 = cmd0.ExecuteReader())
            {
                while (reader1.Read())
                {
                    int i1 = 0;
                    notWordItems1.Add(
                        getItem(reader1, ref i1));
                }
            }

            return(notWordItems1);
        }
Esempio n. 5
0
        public int delete(SearchLogItem logItem0, SqlCommand cmd0)
        {
            List <long> ids1    = new List <long>();
            List <long> epgIDs1 = new List <long>();

            cmd0.CommandText = "SELECT " + COLUMN_ID + ", " + COLUMN_epgEventInfoID + " FROM " + TABLE_NAME + " WHERE " + COLUMN_searchLogID + "=" + logItem0.ID;
            using (SqlDataReader reader1 = cmd0.ExecuteReader())
            {
                while (reader1.Read())
                {
                    ids1.Add((long)reader1[0]);
                    epgIDs1.Add((long)reader1[1]);
                }
            }
            int res1 = base.delete_(ids1, cmd0);

            _db_EpgEventInfo.delete(epgIDs1, cmd0);

            return(res1);
        }
Esempio n. 6
0
    protected void BiblioSearchControl1_Search(object sender, DigitalPlatform.OPAC.Web.SearchEventArgs e)
    {
        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        string strError = "";

        string strResultSetNamePrefix = Session.SessionID + "_opac_base";  //  "opac_base";

        string strResultSetName = GetResultSetName(strResultSetNamePrefix);

        LibraryChannel channel = sessioninfo.GetChannel(true);

        // sessioninfo.Channel.
        channel.Idle += new IdleEventHandler(channel_Idle);
        try
        {
            long lRet = // sessioninfo.Channel.
                        channel.Search(
                null,
                e.QueryXml,
                strResultSetName,
                "", // strOutputStyle
                out strError);
            if (lRet == -1)
            {
                goto ERROR1;
            }
#if FILTER
            app.SetFilterTask(strResultSetName, null);
#endif

            if (app.SearchLog != null)
            {
                SearchLogItem log = new SearchLogItem();
                log.IP       = this.Request.UserHostAddress.ToString();
                log.Query    = e.QueryXml;
                log.Time     = DateTime.UtcNow;
                log.HitCount = (int)lRet;
                log.Format   = "searchcount";
                app.SearchLog.AddLogItem(log);
            }

            // not found
            if (lRet == 0)
            {
                this.BrowseSearchResultControl1.Visible = false;
#if FITLER
                this.filter.Visible = false;
#endif

                strError = "没有找到";
                goto ERROR1;
            }

            e.ErrorInfo = string.Format(
                this.BiblioSearchControl1.GetString("hit_records_number"),
                lRet.ToString());
            // e.ErrorInfo = "命中记录 " +lRet.ToString()+ " 条";
            this.BrowseSearchResultControl1.Clear();
            this.BrowseSearchResultControl1.Visible = true;
#if FILTER
            VisibleFilter(true);
#endif

            this.BrowseSearchResultControl1.ResultSetName = strResultSetName;
            this.BrowseSearchResultControl1.ResultCount   = (int)lRet;
            this.BrowseSearchResultControl1.StartIndex    = 0; // 2008/12/15

#if FILTER
            this.filter.ResultSetName = strResultSetName;
#endif
        }
        finally
        {
            //sessioninfo.Channel.
            channel.Idle -= new IdleEventHandler(channel_Idle);
            sessioninfo.ReturnChannel(channel);
        }
        return;

ERROR1:
        e.ErrorInfo = strError;
        this.BrowseSearchResultControl1.ResultSetName = "";
        this.BrowseSearchResultControl1.ResultCount   = 0;

#if FILTER
        this.filter.ResultSetName = "";
#endif
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.BiblioSearchControl1.Location = this.TitleBarControl1.SelectedLibraryCode;

        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        string strSideBarFile = Server.MapPath("./search_sidebar.xml");

        if (File.Exists(strSideBarFile) == true)
        {
            this.SideBarControl1.CfgFile = strSideBarFile;
        }
        else
        {
            this.SideBarControl1.Visible = false;
        }

        SetSideBarVisible();

        /*
         * // 是否登录?
         * if (sessioninfo.UserID == "")
         * {
         *  sessioninfo.LoginCallStack.Push(Request.RawUrl);
         *  Response.Redirect("login.aspx", true);
         *  return;
         * }
         * */

        if (this.BrowseSearchResultControl1.ResultCount > 0)
        {
            this.BrowseSearchResultControl1.Visible = true;
#if FILTER
            VisibleFilter(true);
#endif
        }

        // 是否登录?
        if (sessioninfo.UserID == "")
        {
            if (this.Page.Request["forcelogin"] == "on")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx", true);
                return;
            }
            if (this.Page.Request["forcelogin"] == "userid")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx?loginstyle=librarian", true);
                return;
            }
            sessioninfo.UserID   = "public";
            sessioninfo.IsReader = false;

            /*
             * sessioninfo.LoginCallStack.Push(Request.RawUrl);
             * Response.Redirect("login.aspx", true);
             * return;
             * */
        }

        string strError = "";
        int    nRet     = 0;

#if NO
        string strAction = this.Request["action"];
        if (strAction == "getdblist")
        {
            DoGetDbNameList();
            return;
        }
#endif

        // 如果有参数
        string strWord = this.Request["word"];
        if (String.IsNullOrEmpty(strWord) == false &&
            this.IsPostBack == false)
        {
            string strXml = "";

            // string strWord = "";
            string strDbName     = "";
            string strFrom       = "";
            string strMatchStyle = "";

            GetSearchParams(out strWord,
                            out strDbName,
                            out strFrom,
                            out strMatchStyle);

            // 根据检索参数创建XML检索式
            nRet = OpacApplication.BuildQueryXml(
                this.app,
                strDbName,     // this.Request["dbname"],
                strWord,
                strFrom,       // this.Request["from"],
                strMatchStyle, // this.Request["matchstyle"],
                null,
                null,
                app.SearchMaxResultCount,
                this.BiblioSearchControl1.SearchStyle, // strSearchStyle
                out strXml,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            string strResultSetNamePrefix = "";

            strResultSetNamePrefix = this.Request["resultsetname"];
            if (String.IsNullOrEmpty(strResultSetNamePrefix) == true)
            {
                strResultSetNamePrefix = Session.SessionID + "_opac_1";
            }
            else
            {
                strResultSetNamePrefix = Session.SessionID + "_" + strResultSetNamePrefix;
            }

            string strResultSetName = GetResultSetName(strResultSetNamePrefix);

            LibraryChannel channel = sessioninfo.GetChannel(true);
            //sessioninfo.Channel.
            channel.Idle += new IdleEventHandler(channel_Idle);
            try
            {
                long lRet = // sessioninfo.Channel.
                            channel.Search(
                    null,
                    strXml,
                    strResultSetName,
                    "", // strOutputStyle
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }
#if FILTER
                app.SetFilterTask(strResultSetName, null);
#endif

                if (app.SearchLog != null)
                {
                    SearchLogItem log = new SearchLogItem();
                    log.IP    = this.Request.UserHostAddress.ToString();
                    log.Query = SearchLog.BuildLogQueryString(
                        this.Request["dbname"],
                        strWord,
                        this.Request["from"],
                        this.Request["matchstyle"]);
                    log.Time     = DateTime.UtcNow;
                    log.HitCount = nRet;
                    log.Format   = "searchcount";
                    app.SearchLog.AddLogItem(log);
                }

                // not found
                if (lRet == 0)
                {
                    this.BrowseSearchResultControl1.Visible = false;
#if FILTER
                    this.filter.Visible = false;
#endif
                    strError = "没有找到";
                    goto ERROR1;
                }

                this.BrowseSearchResultControl1.Clear();
                this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                VisibleFilter(true);
#endif

                this.BrowseSearchResultControl1.ResultSetName = strResultSetName;
                this.BrowseSearchResultControl1.ResultCount   = (int)lRet;
                this.BrowseSearchResultControl1.StartIndex    = 0; // 2008/12/15

#if FILTER
                this.filter.ResultSetName = strResultSetName;
#endif

                string strFormat = this.Request["format"];
                if (String.IsNullOrEmpty(strFormat) == false)
                {
                    this.BrowseSearchResultControl1.FormatName = strFormat;
                }
                return;
            }
            finally
            {
                // sessioninfo.Channel.
                channel.Idle -= new IdleEventHandler(channel_Idle);
                sessioninfo.ReturnChannel(channel);
            }
        }

        // 观察特定的结果集
        if (this.IsPostBack == false)
        {
            string strResultSet     = this.Request["resultset"];
            string strBaseResultSet = this.Request["base"];
            string strTitle         = this.Request["title"];
            if (string.IsNullOrEmpty(strResultSet) == false)
            {
                string strResultsetFilename = PathUtil.MergePath(app.TempDir,   // sessioninfo.GetTempDir(), // ??
                                                                 strResultSet);
                if (File.Exists(strResultsetFilename) == true)
                {
                    long lHitCount = CacheBuilder.GetCount(app, strResultsetFilename, true);

                    this.BrowseSearchResultControl1.ResultsetFilename = strResultsetFilename;

                    this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                    VisibleFilter(true);

                    this.filter.ResultSetName = strBaseResultSet;
#endif

                    string strOffset = this.Request["offset"];
                    this.BrowseSearchResultControl1.ResultsetOffset = strOffset;

#if FILTER
                    this.filter.SelectedNodePath = MakeSelectedPath(strResultSet, strOffset);
#endif
                    if (string.IsNullOrEmpty(strOffset) == false)
                    {
                        int nStart  = 0;
                        int nLength = -1;
                        BrowseSearchResultControl.ParseOffsetString(strOffset,
                                                                    out nStart,
                                                                    out nLength);
                        if (nLength == -1)
                        {
                            nLength = (int)lHitCount - nStart;
                        }
                        this.BrowseSearchResultControl1.ResultCount = nLength;
                    }
                    else
                    {
                        this.BrowseSearchResultControl1.ResultCount = (int)lHitCount;
                    }

                    if (string.IsNullOrEmpty(strTitle) == false)
                    {
                        this.BrowseSearchResultControl1.Title = strTitle;
                    }
                }
                else
                {
                    strError = "结果集文件 '" + strResultSet + "' 不存在";
                    goto ERROR1;
                }
            }
            else if (string.IsNullOrEmpty(strBaseResultSet) == false)
            {
                // 只用了base参数
                this.BrowseSearchResultControl1.Clear();
                this.BrowseSearchResultControl1.Visible = true;
#if FILTER
                VisibleFilter(true);
#endif

                this.BrowseSearchResultControl1.ResultSetName = strBaseResultSet;
                this.BrowseSearchResultControl1.ResultCount   = (int)MyWebPage.GetServerResultCount(sessioninfo, strBaseResultSet);
                this.BrowseSearchResultControl1.StartIndex    = 0;

#if FILTER
                this.filter.ResultSetName = strBaseResultSet;
#endif
            }
        }

        //this.AdvanceSearchControl1.Channels = sessioninfo.Channels;
        //this.AdvanceSearchControl1.ServerUrl = app.WsUrl;

        // this.HeadBarControl1.CurrentColumn = HeaderColumn.Search;
        return;

ERROR1:
        Response.Write(HttpUtility.HtmlEncode(strError));
        Response.End();
    }
Esempio n. 8
0
        int PrepareBiblioRecord(
            out string strError)
        {
            strError = "";
            int  nRet = 0;
            long lRet = 0;

            // string strOutputPath = "";

            if (string.IsNullOrEmpty(this.RecPath) == true)
            {
                return(0);   // 此时无法进行初始化
            }
            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string         strBiblioXml = "";
            LibraryChannel channel      = sessioninfo.GetChannel(true);

            try
            {
                // string strBiblioState = "";

                byte[]   timestamp = null;
                string[] formats   = new string[1];
                formats[0] = "xml";

                string[] results = null;
                lRet = // sessioninfo.Channel.
                       channel.GetBiblioInfos(
                    null,
                    this.RecPath,
                    "",
                    formats,
                    out results,
                    out timestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "获得书目记录 '" + this.RecPath + "' 时出错: " + strError;
                    goto ERROR1;
                }
                if (lRet == 0)
                {
                    strError = "书目记录 '" + this.RecPath + "' 不存在";
                    goto ERROR1;
                }
                if (results == null || results.Length < 1)
                {
                    strError = "results error {A9217775-645E-42F1-8307-22B26C0E1D69}";
                    goto ERROR1;
                }

                strBiblioXml  = results[0];
                this.m_strXml = strBiblioXml;

                this.Timestamp     = ByteArray.GetHexTimeStampString(timestamp);
                this.BiblioRecPath = this.RecPath;
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            if (app.SearchLog != null)
            {
                SearchLogItem log = new SearchLogItem();
                log.IP       = this.Page.Request.UserHostAddress.ToString();
                log.Query    = "";
                log.Time     = DateTime.UtcNow;
                log.HitCount = 1;
                log.Format   = "biblio";
                log.RecPath  = this.RecPath;
                app.SearchLog.AddLogItem(log);
            }

            string strMarc = "";

            // 转换为MARC
            {
                string strOutMarcSyntax = "";

                // 将MARCXML格式的xml记录转换为marc机内格式字符串
                // parameters:
                //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
                //		strMarcSyntax	指示marc语法,如果=="",则自动识别
                //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
                nRet = MarcUtil.Xml2Marc(strBiblioXml,
                                         true,
                                         "", // this.CurMarcSyntax,
                                         out strOutMarcSyntax,
                                         out strMarc,
                                         out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.m_strMARC = strMarc;
            }

            bool bAjax = true;

            if (this.DisableAjax == true)
            {
                bAjax = false;
            }
            else
            {
                if (app != null &&
                    app.WebUiDom != null &&
                    app.WebUiDom.DocumentElement != null)
                {
                    XmlNode nodeBiblioControl = app.WebUiDom.DocumentElement.SelectSingleNode(
                        "biblioControl");
                    if (nodeBiblioControl != null)
                    {
                        DomUtil.GetBooleanParam(nodeBiblioControl,
                                                "ajax",
                                                true,
                                                out bAjax,
                                                out strError);
                    }
                }
            }

            if (bAjax == false)
            {
                string strBiblio       = "";
                string strBiblioDbName = StringUtil.GetDbName(this.RecPath);

                // 需要从内核映射过来文件
                string strLocalPath = "";
                nRet = app.MapKernelScriptFile(
                    // null,   // sessioninfo,
                    strBiblioDbName,
                    "./cfgs/opac_biblio.fltx",  // OPAC查询固定认这个角色的配置文件,作为公共查询书目格式创建的脚本。而流通前端,创建书目格式的时候,找的是loan_biblio.fltx配置文件
                    out strLocalPath,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                // 将种记录数据从XML格式转换为HTML格式
                KeyValueCollection result_params = null;

                // 2006/11/28 changed
                string strFilterFileName = strLocalPath;    // app.CfgDir + "\\biblio.fltx";
                nRet = app.ConvertBiblioXmlToHtml(
                    strFilterFileName,
                    strBiblioXml,
                    this.RecPath,
                    out strBiblio,
                    out result_params,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                // TODO: Render的时候设置,已经晚了半拍
                // 要想办法在全部Render前得到题名和进行设置
                if (this.AutoSetPageTitle == true &&
                    result_params != null && result_params.Count > 0)
                {
                    string strTitle = result_params["title"].Value;
                    if (string.IsNullOrEmpty(strTitle) == false)
                    {
                        this.Page.Title = strTitle;
                    }

                    bool bHasDC = false;
                    // 探测一下,是否有至少一个DC.开头的 key ?
                    foreach (KeyValue item in result_params)
                    {
                        if (StringUtil.HasHead(item.Key, "DC.") == true)
                        {
                            bHasDC = true;
                            break;
                        }
                    }

                    if (bHasDC == true)
                    {
                        // <header profile="http://dublincore.org/documents/2008/08/04/dc-html/">
                        this.Page.Header.Attributes.Add("profile", "http://dublincore.org/documents/2008/08/04/dc-html/");

                        // DC rel
                        //
                        HtmlLink link = new HtmlLink();
                        link.Href = "http://purl.org/dc/elements/1.1/";
                        link.Attributes.Add("rel", "schema.DC");
                        this.Page.Header.Controls.Add(link);

                        // <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" >
                        link      = new HtmlLink();
                        link.Href = "http://purl.org/dc/terms/";
                        link.Attributes.Add("rel", "schema.DCTERMS");
                        this.Page.Header.Controls.Add(link);

                        foreach (KeyValue item in result_params)
                        {
                            if (StringUtil.HasHead(item.Key, "DC.") == false &&
                                StringUtil.HasHead(item.Key, "DCTERMS.") == false)
                            {
                                continue;
                            }
                            HtmlMeta meta = new HtmlMeta();
                            meta.Name    = item.Key;
                            meta.Content = item.Value;
                            if (StringUtil.HasHead(item.Value, "urn:") == true ||
                                StringUtil.IsHttpUrl(item.Value) == true ||
                                StringUtil.HasHead(item.Value, "info:") == true
                                )
                            {
                                meta.Attributes.Add("scheme", "DCTERMS.URI");
                            }

                            this.Page.Header.Controls.Add(meta);
                        }
                    }
                }

                this.m_strOpacBiblio = strBiblio;
            }
            return(0);

ERROR1:
            return(-1);
        }
Esempio n. 9
0
 public int delete(SearchLogItem logItem0, SqlCommand cmd0)
 {
     cmd0.CommandText = "DELETE FROM " + tableName + " WHERE " + COLUMN_searchLogID + "=" + logItem0.ID;
     return((int)cmd0.ExecuteNonQuery());
 }