Exemple #1
0
        // 装载MARC记录,根据记录路径
        // parameters:
        //      strPath 路径。例如 "图书总库/1@本地服务器"
        //      bReload 是否确保从数据库装载
        public int LoadDp2Record(dp2SearchForm dp2_searchform,
            string strPath,
            string strDirection,
            bool bLoadResObject,
            bool bReload = false)
        {
            string strError = "";

            if (dp2_searchform == null)
            {
                strError = "dp2_searchform参数不能为空";
                goto ERROR1;
            }

            if (dp2_searchform.CurrentProtocol != "dp2library")
            {
                strError = "所提供的检索窗不是 dp2library 协议";
                goto ERROR1;
            }

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[] baTimestamp = null;
            string strOutStyle = "";

            string strSavePath = "";
            string strMARC;

            long lVersion = 0;
            LoginInfo logininfo = null; 
            string strXmlFragment = "";

            int nRet = dp2_searchform.GetOneRecord(
                //true,
                "marc",
                //strPath,
                //strDirection,
                0,  // test
                "path:" + strPath + ",direction:" + strDirection,
                bReload == true ? "reload" : "",
                out strSavePath,
                out strMARC,
                out strXmlFragment,
                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            nRet = this.LoadXmlFragment(strXmlFragment,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.CurrentTimestamp = baTimestamp;
            // this.SavePath = dp2_searchform.CurrentProtocol + ":" + strOutputPath;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;


            /*
            // 接着装入对象资源
            if (bLoadResObject == true)
            {
                this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                nRet = this.binaryResControl1.LoadObject(strLocalPath,
                    strRecordXml,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return -1;
                }
            }*/
            // 装入MARC编辑器
            this.MarcEditor.Marc = strMARC;


            this.m_nDisableInitialAssembly++; 
            this.CurrentRecord = record;
            this.m_nDisableInitialAssembly--; 

            if (this.m_currentRecord != null)
            {
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    this.m_currentRecord.m_baRecord);

                // 装入ISO2709文本
                nRet = this.Set2709OriginText(this.m_currentRecord.m_baRecord,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }

                // 数据库名
                this.textBox_originDatabaseName.Text = this.m_currentRecord.m_strDBName;

                // Marc syntax OID
                this.textBox_originMarcSyntaxOID.Text = this.m_currentRecord.m_strSyntaxOID;

                // 2014/5/18
                if (this.UseAutoDetectedMarcSyntaxOID == true)
                {
                    this.AutoDetectedMarcSyntaxOID = this.m_currentRecord.AutoDetectedSyntaxOID;
                    if (string.IsNullOrEmpty(this.AutoDetectedMarcSyntaxOID) == false)
                        this.textBox_originMarcSyntaxOID.Text = this.AutoDetectedMarcSyntaxOID;
                }

#if NO
                // 让确定的OID起作用 2008/3/25
                if (String.IsNullOrEmpty(this.m_currentRecord.m_strSyntaxOID) == false)
                    this.AutoDetectedMarcSyntaxOID = "";
#endif
            }
            else
            {
                byte[] baMARC = this.CurrentEncoding.GetBytes(strMARC);
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    baMARC);

                // 装入ISO2709文本
                nRet = this.Set2709OriginText(baMARC,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }
            }

            DisplayHtml(strMARC, this.textBox_originMarcSyntaxOID.Text);

            // 构造路径
            /*
            string strPath = searchform.CurrentProtocol + ":"
                + searchform.CurrentResultsetPath
                + "/" + (index + 1).ToString();

            this.textBox_tempRecPath.Text = strPath;
             * */
            if (strDirection != "current")  // 2013/9/18
                this.textBox_tempRecPath.Text = "";


            this.MarcEditor.MarcDefDom = null; // 强制刷新字段名提示
            this.MarcEditor.RefreshNameCaption();

            this.BiblioChanged = false;

            if (this.MarcEditor.FocusedFieldIndex == -1)
                this.MarcEditor.FocusedFieldIndex = 0;

            this.MarcEditor.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemple #2
0
        // 装载XML记录,根据记录路径
        // parameters:
        //      strPath 路径。例如 "图书总库/1@本地服务器"
        public int LoadDp2Record(dp2SearchForm dp2_searchform,
            string strPath,
            string strDirection,
            bool bLoadResObject)
        {
            string strError = "";
            string strRecordXml = "";

            if (dp2_searchform == null)
            {
                strError = "dp2_searchform参数不能为空";
                goto ERROR1;
            }

            if (dp2_searchform.CurrentProtocol != "dp2library")
            {
                strError = "所提供的检索窗不是dp2library协议";
                goto ERROR1;
            }

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[] baTimestamp = null;
            string strOutStyle = "";

            string strSavePath = "";

            long lVersion = 0;
            LoginInfo logininfo = null;
            string strXmlFragment = "";

            int nRet = dp2_searchform.GetOneRecord(
                // true,
                "xml",
                // strPath,
                // strDirection,
                0,   // test
                "path:" + strPath + ",direction:" + strDirection,
                "",
                out strSavePath,
                out strRecordXml,
                out strXmlFragment,

                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.CurrentTimestamp = baTimestamp;
            // this.SavePath = dp2_searchform.CurrentProtocol + ":" + strOutputPath;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;

            string strServerName = "";
            string strLocalPath = "";

            strPath = strSavePath;

            // 解析记录路径。
            // 记录路径为如下形态 "中文图书/1 @服务器"
            dp2SearchForm.ParseRecPath(strPath,
                out strServerName,
                out strLocalPath);

            string strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);

            // 获得cfgs\dcdef
            string strCfgFileName = "dcdef";

            string strCfgPath = strBiblioDbName + "/cfgs/" + strCfgFileName + "@" + strServerName;

            // 和以前的不同,才有必要重新载入
            if (this.DcCfgFilename != strCfgPath)
            {
                string strCode = "";
                byte[] baCfgOutputTimestamp = null;
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = dp2_searchform.GetCfgFile(strCfgPath,
                    out strCode,
                    out baCfgOutputTimestamp,
                    out strError);
                if (nRet == -1 || nRet == 0)
                    goto ERROR1;

                nRet = this.DcEditor.LoadCfgCode(strCode,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.DcCfgFilename = strCfgPath;
            }

            // 接着装入对象资源
            if (bLoadResObject == true)
            {
                // this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                nRet = this.binaryResControl1.LoadObject(
                    dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName)),
                    strLocalPath,
                    strRecordXml,
                    "0",  // TODO
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return -1;
                }
            }




            // TODO: 再次装入的时候有问题
            // 装入DC编辑器
            this.DcEditor.Xml = strRecordXml;


            this.CurrentRecord = record;

            this.BiblioChanged = false;

            this.DcEditor.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }