public void CreateMenu(object sender, GenerateDataEventArgs e)
    {
        ScriptActionCollection actions = new ScriptActionCollection();

        if (sender is MarcEditor || sender == null)
        {
        }

        if (sender is BinaryResControl || sender is MarcEditor)
        {
            // 856字段
            actions.NewItem("创建维护856字段", "创建维护856字段", "Manage856", false);
        }

        if (sender is EntityEditForm || sender is EntityControl || sender is BindingForm)
        {
            // 创建索取号
            actions.NewItem("创建索取号", "为册记录创建索取号", "CreateCallNumber", false);

            // 管理索取号
            actions.NewItem("管理索取号", "为册记录管理索取号", "ManageCallNumber", false);
        }

        this.ScriptActions = actions;

    }
    public void CreateMenu(object sender, GenerateDataEventArgs e)
    {
        ScriptActionCollection actions = new ScriptActionCollection();

        if (sender is MarcEditor || sender == null)
        {
            // 规整ISBN为13
            actions.NewItem("规整ISBN-13", "对020$a中ISBN进行规整", "HyphenISBN_13", false);

            // 规整ISBN为10
            actions.NewItem("规整ISBN-10", "对020$a中ISBN进行规整", "HyphenISBN_10", false);

            //245$c<-- 100$a
            actions.NewItem("245$c<-- 100$a", "将100$a内容拷贝入245字段$c", "Copy100aTo245c", false);

            //7xx$a<-- 245$c
            actions.NewItem("7xx$a<-- 245$c", "将245$c内容拷贝入7xx字段$a", "Copy245cTo7xxa", false);

            // 出版地
            actions.NewItem("260$a$b <-- 020$a", "根据020$a中ISBN出版社代码, 自动创建出版社子字段260$a$b", "AddPublisher", false);

            // 维护 260 出版地 出版社
            actions.NewItem("维护260对照表", "ISBN出版社代码 和 260字段$a出版地$b出版社名 的对照表", "Manage260", false);
            
            // 分割行
            actions.NewSeperator();

            actions.NewItem("加入封面图片 URL", "将来自亚马逊的封面图片 URL 加入 856 字段", "AddCoverImageUrl", false);

            // 分割行
            actions.NewSeperator();
        }

        if (sender is BinaryResControl || sender is MarcEditor)
        {
            // 856字段
            actions.NewItem("创建维护856字段", "创建维护856字段", "Manage856", false);
        }

        if (sender is EntityEditForm || sender is EntityControl)
        {
            // 创建索取号
            actions.NewItem("创建索取号", "为册记录创建索取号", "CreateCallNumber", false);

            // 管理索取号
            actions.NewItem("管理索取号", "为册记录管理索取号", "ManageCallNumber", false);
        }

        this.ScriptActions = actions;

    }
Esempio n. 3
0
 private void toolStripButton_verifyData_Click(object sender, EventArgs e)
 {
     GenerateDataEventArgs e1 = new GenerateDataEventArgs();
     e1.FocusedControl = this.m_marcEditor;
     this.VerifyData(this, e1, false);
 }
Esempio n. 4
0
        // 自动加工数据
        // parameters:
        //      sender    从何处启动? MarcEditor EntityEditForm BindingForm
        public void AutoGenerate(object sender,
            GenerateDataEventArgs e,
            string strBiblioRecPath,
            bool bOnlyFillMenu = false)
        {
            int nRet = 0;
            string strError = "";
            bool bAssemblyReloaded = false;

            // 防止重入
            if (bOnlyFillMenu == true && this.m_nInFillMenu > 0)
                return;

            this.m_nInFillMenu++;
            try
            {
                // 初始化 dp2circulation_marc_autogen.cs 的 Assembly,并new DetailHost对象
                // return:
                //      -1  error
                //      0   没有重新初始化Assembly,而是直接用以前Cache的Assembly
                //      1   重新(或者首次)初始化了Assembly
                nRet = InitialAutogenAssembly(strBiblioRecPath, // null,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
                if (nRet == 0)
                {
                    if (this.m_detailHostObj == null)
                        return; // 库名不具备,无法初始化
                }
                if (nRet == 1)
                    bAssemblyReloaded = true;

                Debug.Assert(this.m_detailHostObj != null, "");

                if (this.AutoGenNewStyle == true)
                {
                    bool bDisplayWindow = this.MainForm.PanelFixedVisible == false ? true : false;
                    if (bDisplayWindow == true)
                    {
                        if (String.IsNullOrEmpty(e.ScriptEntry) != true
                            && e.ScriptEntry != "Main")
                            bDisplayWindow = false;
                    }

                    if (sender is EntityEditForm
                        && (String.IsNullOrEmpty(e.ScriptEntry) == true
                            || e.ScriptEntry == "Main"))
                    {
                        bDisplayWindow = true;
                    }
                    else if (sender is BindingForm
    && (String.IsNullOrEmpty(e.ScriptEntry) == true
        || e.ScriptEntry == "Main"))
                    {
                        bDisplayWindow = true;
                    }

                    DisplayAutoGenMenuWindow(bDisplayWindow);   // 可能会改变 .ActionTable以及 .Count
                    if (bOnlyFillMenu == false)
                    {
                        if (this.MainForm.PanelFixedVisible == true
                            && e.Parameter == null) // 2015/6/5
                            MainForm.ActivateGenerateDataPage();
                    }

                    if (this.m_genDataViewer != null)
                    {
                        this.m_genDataViewer.sender = sender;
                        this.m_genDataViewer.e = e;
                    }

                    // 清除残留菜单事项
                    if (m_autogenSender != sender
                        || bAssemblyReloaded == true)
                    {
                        if (this.m_genDataViewer != null
                            && this.m_genDataViewer.Count > 0)
                            this.m_genDataViewer.Clear();
                    }
                }
                else // 旧的风格
                {
#if NO
                    if (this.m_genDataViewer != null)
                    {
                        this.m_genDataViewer.Close();
                        this.m_genDataViewer = null;
                    }
#endif
                    CloseGenDataViewer();

                    if (this._myForm.Focused == true 
                        // || this.m_marcEditor.Focused TODO: 这里要研究一下如何实现
                        )
                        this.MainForm.CurrentGenerateDataControl = null;

                    // 如果意图仅仅为填充菜单
                    if (bOnlyFillMenu == true)
                        return;
                }

                try
                {
                    // 旧的风格
                    if (this.AutoGenNewStyle == false)
                    {
                        this.m_detailHostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry,
    sender,
    e);
                        // this.SetSaveAllButtonState(true); TODO: 应该没有必要。MARC 编辑器内容修改自然会引起保存按钮状态变化
                        return;
                    }

                    // 初始化菜单
                    try
                    {
                        if (this.m_genDataViewer != null)
                        {
                            // 出现菜单界面
                            if (this.m_genDataViewer.Count == 0)
                            {
                                dynamic o = this.m_detailHostObj;
                                o.CreateMenu(sender, e);

                                this.m_genDataViewer.Actions = this.m_detailHostObj.ScriptActions;
                            }

                            // 根据当前插入符位置刷新加亮事项
                            this.m_genDataViewer.RefreshState();
                        }

                        if (String.IsNullOrEmpty(e.ScriptEntry) == false)
                        {
                            this.m_detailHostObj.Invoke(e.ScriptEntry,
                                sender,
                                e);
                        }
                        else
                        {
                            if (this.MainForm.PanelFixedVisible == true
                                && bOnlyFillMenu == false
                                && this.MainForm.CurrentGenerateDataControl != null)
                            {
                                TableLayoutPanel table = (TableLayoutPanel)this.MainForm.CurrentGenerateDataControl;
                                for (int i = 0; i < table.Controls.Count; i++)
                                {
                                    Control control = table.Controls[i];
                                    if (control is DpTable)
                                    {
                                        control.Focus();
                                        break;
                                    }
                                }

                            }
                        }
                    }
                    catch (Exception /*ex*/)
                    {
                        /*
                        // 被迫改用旧的风格
                        this.m_detailHostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry,
        sender,
        e);
                        this.SetSaveAllButtonState(true);
                        return;
                         * */
                        throw;
                    }
                }
                catch (Exception ex)
                {
                    strError = "执行脚本文件 '" + m_strAutogenDataCfgFilename + "' 过程中发生异常: \r\n" + ExceptionUtil.GetDebugText(ex);
                    goto ERROR1;
                }

                this.m_autogenSender = sender;  // 记忆最近一次的调用发起者

                if (bOnlyFillMenu == false
                    && this.m_genDataViewer != null)
                    this.m_genDataViewer.TryAutoRun();
                return;
            ERROR1:
                // TODO: 报错是否要直接显示在 dpTable 中?
                // MessageBox.Show(this._myForm, strError);
                DisplayAutoGenMenuWindow(false);
                if (this.m_genDataViewer != null)
                    this.m_genDataViewer.DisplayError(strError);
            }
            finally
            {
                this.m_nInFillMenu--;
            }
        }
Esempio n. 5
0
 // 获得索取号
 void button_getAccessNo_Click(object sender, EventArgs e)
 {
     if (this.GenerateData != null)
     {
         GenerateDataEventArgs e1 = new GenerateDataEventArgs();
         if (Control.ModifierKeys == Keys.Control)
             e1.ScriptEntry = "ManageCallNumber";
         else
             e1.ScriptEntry = "CreateCallNumber";
         e1.FocusedControl = sender; // sender为最原始的子控件
         this.GenerateData(this, e1);
     }
 }
Esempio n. 6
0
        // MARC格式校验
        // parameters:
        //      sender    从何处启动? MarcEditor EntityEditForm BindingForm
        /// <summary>
        /// MARC格式校验
        /// </summary>
        /// <param name="sender">从何处启动?</param>
        /// <param name="e">GenerateDataEventArgs对象,表示动作参数</param>
        /// <param name="bAutoVerify">是否自动校验。自动校验的时候,如果没有发现错误,则不出现最后的对话框</param>
        /// <returns>0: 没有发现校验错误; 1: 发现校验警告; 2: 发现校验错误</returns>
        public int VerifyData(object sender,
            GenerateDataEventArgs e,
            bool bAutoVerify)
        {
            string strError = "";
            this._processing++;
            try
            {
                if (this.IsDisposed == true)
                {
                    strError = "VerifyData() 失败。因 EntityForm 窗口已经释放";
                    goto ERROR1;
                }

                // test
                //Thread.Sleep(10 * 1000);

                // 库名部分路径
                string strBiblioDbName = Global.GetDbName(this.BiblioRecPath);

                string strCode = "";
                string strRef = "";
                string strOutputFilename = "";

                // Debug.Assert(false, "");
                this.m_strVerifyResult = "正在校验...";
                // 自动校验的时候,如果没有发现错误,则不出现最后的对话框
                if (bAutoVerify == false)
                {
                    // 如果固定面板隐藏,就打开窗口
                    DoViewVerifyResult(this.MainForm.PanelFixedVisible == false ? true : false);

                    // 2011/8/17
                    if (this.MainForm.PanelFixedVisible == true)
                        MainForm.ActivateVerifyResultPage();
                }

                VerifyHost host = new VerifyHost();
                host.DetailForm = this;

                string strCfgFileName = "dp2circulation_marc_verify.fltx";

                byte[] baCfgOutputTimestamp = null;
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                int nRet = GetCfgFile(strBiblioDbName,
                    strCfgFileName,
                    out strOutputFilename,
                    out baCfgOutputTimestamp,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                // test
                //Thread.Sleep(10 * 1000);

                if (nRet == 0)
                {
                    // .cs 和 .cs.ref
                    strCfgFileName = "dp2circulation_marc_verify.cs";
                    nRet = GetCfgFileContent(strBiblioDbName,
        strCfgFileName,
        out strCode,
        out baCfgOutputTimestamp,
        out strError);
                    if (nRet == 0)
                    {
                        strError = "服务器上没有定义路径为 '" + strBiblioDbName + "/" + strCfgFileName + "' 的配置文件(或.fltx配置文件),数据校验无法进行";
                        goto ERROR1;
                    }
                    if (nRet == -1 || nRet == 0)
                        goto ERROR1;
                    strCfgFileName = "dp2circulation_marc_verify.cs.ref";
                    nRet = GetCfgFileContent(strBiblioDbName,
                        strCfgFileName,
                        out strRef,
                        out baCfgOutputTimestamp,
                        out strError);
                    if (nRet == 0)
                    {
                        strError = "服务器上没有定义路径为 '" + strBiblioDbName + "/" + strCfgFileName + "' 的配置文件,虽然定义了.cs配置文件。数据校验无法进行";
                        goto ERROR1;
                    }
                    if (nRet == -1 || nRet == 0)
                        goto ERROR1;

                    try
                    {
                        // 执行代码
                        nRet = RunVerifyCsScript(
                            sender,
                            e,
                            strCode,
                            strRef,
                            out host,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;
                    }
                    catch (Exception ex)
                    {
                        strError = "执行脚本代码过程中发生异常: \r\n" + ExceptionUtil.GetDebugText(ex);
                        goto ERROR1;
                    }
                }
                else
                {
                    VerifyFilterDocument filter = null;

                    nRet = this.PrepareMarcFilter(
                        host,
                        strOutputFilename,
                        out filter,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "编译文件 '" + strCfgFileName + "' 的过程中出错:\r\n" + strError;
                        goto ERROR1;
                    }

                    try
                    {
                        nRet = filter.DoRecord(null,
                            this.GetMarc(),    //  this.m_marcEditor.Marc,
                            0,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;
                    }
                    catch (Exception ex)
                    {
                        strError = "filter.DoRecord error: " + ExceptionUtil.GetDebugText(ex);
                        goto ERROR1;
                    }
                }

                bool bVerifyFail = false;
                if (string.IsNullOrEmpty(host.ResultString) == true)
                {
                    if (this.m_verifyViewer != null)
                    {
                        this.m_verifyViewer.ResultString = "经过校验没有发现任何错误。";
                    }
                }
                else
                {
                    if (bAutoVerify == true)
                    {
                        // 延迟打开窗口
                        DoViewVerifyResult(this.MainForm.PanelFixedVisible == false ? true : false);
                    }
                    this.m_verifyViewer.ResultString = host.ResultString;
                    this.MainForm.ActivateVerifyResultPage();   // 2014/7/3
                    bVerifyFail = true;
                }

                this.SetSaveAllButtonState(true);   // 2009/3/29 
                return bVerifyFail == true ? 2 : 0;
            }
            finally
            {
                this._processing--;
            }
        ERROR1:
            MessageBox.Show(this, strError);
            if (this.m_verifyViewer != null)
                this.m_verifyViewer.ResultString = strError;
            return 0;
        }
Esempio n. 7
0
        // 自动加工数据
        // parameters:
        //      sender    从何处启动? MarcEditor EntityEditForm
        public void AutoGenerate(object sender, GenerateDataEventArgs e)
        {
            // 库名部分路径
            string strBiblioDbName = Global.GetDbName(this.BiblioRecPath);

            string strError = "";
            string strCode = "";
            string strRef = "";

            // Debug.Assert(false, "");

            string strCfgFileName = "dp2circulation_marc_autogen.cs";   // 原来叫dp2_autogen.cs 2007/12/10修改为dp2circulation_marc_autogen.cs

            byte[] baCfgOutputTimestamp = null;
            // return:
            //      -1  error
            //      0   not found
            //      1   found
            int nRet = GetCfgFileContent(strBiblioDbName,
                strCfgFileName,
                out strCode,
                out baCfgOutputTimestamp,
                out strError);
            if (nRet == -1 || nRet == 0)
                goto ERROR1;

            strCfgFileName = "dp2circulation_marc_autogen.cs.ref";
            nRet = GetCfgFileContent(strBiblioDbName,
                strCfgFileName,
                out strRef,
                out baCfgOutputTimestamp,
                out strError);
            if (nRet == -1 || nRet == 0)
                goto ERROR1;

            try
            {
                // 执行代码
                nRet = RunCsScript(
                    sender,
                    e,
                    strCode,
                    strRef,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
            }
            catch (Exception ex)
            {
                strError = "执行脚本代码过程中发生异常: \r\n" + ExceptionUtil.GetDebugText(ex);
                goto ERROR1;
            }

            this.SetSaveAllButtonState(true);   // 2009/3/29 
            return;
       ERROR1:
            MessageBox.Show(this, strError);
        }
Esempio n. 8
0
        // 提交所有保存请求
        // parameters:
        //      strStyle    风格。displaysuccess 显示最后的成功消息在框架窗口的状态条 verifydata 发送校验记录的消息(注意是否校验还要取决于配置状态)
        //                  searchdup 虽然对本函数没有作用,但是可以传递到下级函数SaveBiblioToDatabase()
        // return:
        //      -1  有错。此时不排除有些信息保存成功。
        //      0   成功。
        /// <summary>
        /// 全部保存
        /// </summary>
        /// <param name="strStyle">保存方式。由 displaysuccess / verifydata / searchdup 之一或者逗号间隔组合而成。displaysuccess 显示最后的成功消息在框架窗口的状态条; verifydata 保存成功后发送校验记录的消息(注意是否校验还要取决于配置状态); searchdup 保存成功后发送查重消息</param>
        /// <returns>-1: 有错。此时不排除有些信息保存成功。0: 成功。</returns>
        public int DoSaveAll(string strStyle = "displaysuccess,verifydata,searchdup")
        {
            bool bBiblioSaved = false;
            int nRet = 0;
            string strText = "";
            int nErrorCount = 0;

            bool bDisplaySuccess = StringUtil.IsInList("displaysuccess", strStyle);
            bool bVerifyData = StringUtil.IsInList("verifydata", strStyle);
            // bool bForceVerifyData = StringUtil.IsInList("forceverifydata", strStyle);

            bool bVerified = false;

            if (this.m_verifyViewer != null)
                this.m_verifyViewer.Clear();

            string strHtml = "";

            LibraryChannel channel = this.GetChannel();
            channel.Timeout = new TimeSpan(0, 5, 0);    // 保存大量册记录时可能会耗时长一点

            Progress.OnStop += new StopEventHandler(this.DoStop);
            Progress.Initial("正在保存记录 ...");
            Progress.BeginLoop();

            this.ShowMessage("正在保存记录 ...");
            try
            {
                if (this.BiblioChanged == true
                    || Global.IsAppendRecPath(this.BiblioRecPath) == true
                    || this.m_bDeletedMode == true /* 2011/11/8 */)
                {
                    // 2014/7/3
                    if (bVerifyData == true
    && this.ForceVerifyData == true)
                    {
                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = this.m_marcEditor;

                        // 0: 没有发现校验错误; 1: 发现校验警告; 2: 发现校验错误
                        nRet = this.VerifyData(this, e1, true);
                        if (nRet == 2)
                        {
                            MessageBox.Show(this, "MARC 记录经校验发现有错,被拒绝保存。请修改 MARC 记录后重新保存");
                            return -1;
                        }

                        bVerified = true;
                    }

                    // 保存书目记录到数据库
                    // return:
                    //      -1  出错
                    //      0   没有保存
                    //      1   已经保存
                    nRet = SaveBiblioToDatabase(
                        channel,
                        true,
                        out strHtml,
                        strStyle);
                    if (nRet == 1)
                    {
                        bBiblioSaved = true;
                        strText += "书目信息";
                    }
                    if (nRet == -1)
                    {
                        nErrorCount++;
                    }
                }

                bool bOrdersSaved = false;
                // 提交订购保存请求
                // return:
                //      -1  出错
                //      0   没有必要保存
                //      1   保存成功
                nRet = this.orderControl1.DoSaveItems(channel);
                if (nRet == 1)
                {
                    bOrdersSaved = true;
                    if (strText != "")
                        strText += " ";
                    strText += "采购信息";
                }
                if (nRet == -1)
                {
                    nErrorCount++;

                    // 2013/1/18
                    // 如果订购信息保存不成功,则不要继续保存后面的其他信息。这主要是为了订购验收环节考虑,避免在订购信息保存失败的情况下继续保存验收所创建的新的册信息
                    return -1;
                }

                bool bIssuesSaved = false;
                bool bIssueError = false;
                // 提交期保存请求
                // return:
                //      -1  出错
                //      0   没有必要保存
                //      1   保存成功
                nRet = this.issueControl1.DoSaveItems(channel);
                if (nRet == 1)
                {
                    bIssuesSaved = true;
                    if (strText != "")
                        strText += " ";
                    strText += "期信息";
                }
                if (nRet == -1)
                {
                    nErrorCount++;
                    bIssueError = true;

                    // 2013/1/18
                    // 如果期信息保存不成功,则不要继续保存后面的其他信息。这主要是为了期刊验收环节考虑,避免在期信息保存失败的情况下继续保存验收所创建的新的册信息
                    return -1;
                }

                bool bEntitiesSaved = false;

                // 注:在期刊记到后,如果期信息保存不成功,则不保存册信息。以免发生不一致
                if (bIssueError == false)
                {
                    // 提交实体保存请求
                    // return:
                    //      -1  出错
                    //      0   没有必要保存
                    //      1   保存成功
                    nRet = this.entityControl1.DoSaveItems(channel);
                    if (nRet == 1)
                    {
                        bEntitiesSaved = true;
                        if (strText != "")
                            strText += " ";
                        strText += "册信息";
                    }
                    if (nRet == -1)
                    {
                        nErrorCount++;
                    }
                }

                bool bCommentsSaved = false;
                // 提交评注保存请求
                // return:
                //      -1  出错
                //      0   没有必要保存
                //      1   保存成功
                nRet = this.commentControl1.DoSaveItems(channel);
                if (nRet == 1)
                {
                    bCommentsSaved = true;
                    if (strText != "")
                        strText += " ";
                    strText += "评注信息";
                }
                if (nRet == -1)
                {
                    nErrorCount++;
                }

                bool bObjectSaved = false;
                string strError = "";

                // 当允许编目功能的时候才能允许保存对象资源。否则会把书目记录摧毁为空记录
                if (this.Cataloging == true)
                {
                    // 提交对象保存请求
                    // return:
                    //		-1	error
                    //		>=0 实际上载的资源对象数
                    nRet = this.binaryResControl1.Save(
                        channel,
                        this.MainForm.ServerVersion,
                        out strError);
                    if (nRet == -1)
                    {
                        MessageBox.Show(this, "保存对象信息时出错: " + strError);
                        nErrorCount++;
                    }

                    if (nRet >= 1)
                    {
                        bObjectSaved = true;
                        if (strText != "")
                            strText += " ";
                        strText += "对象信息";

                        /*
                        string strSavedBiblioRecPath = this.BiblioRecPath;

                        // 刷新书目记录的时间戳
                        string strOutputBiblioRecPath = "";
                        string strXml = "";
                        nRet = LoadBiblioRecord(this.BiblioRecPath,
                            "",
                            false,
                            out strOutputBiblioRecPath,
                            out strXml,
                            out strError);
                        if (nRet == -1)
                        {
                            // 如果提取记录失败,并且原有书目记录路径被摧毁,需要恢复
                            if (String.IsNullOrEmpty(this.BiblioRecPath) == true)
                            {
                                this.BiblioRecPath = strSavedBiblioRecPath;
                            }

                            MessageBox.Show(this, strError + "\r\n\r\n注意:当前窗口内的书目记录时间戳可能没有正确刷新,这将导致后继的保存书目记录操作出现时间戳不匹配报错");
                            nErrorCount++;
                        }
                        */
                    }
                }

                if (string.IsNullOrEmpty(strHtml) == false)
                {
                    this.m_webExternalHost_biblio.SetHtmlString(strHtml,
    "entityform_biblio");
                }

                if (bDisplaySuccess == true)
                {
                    if (bEntitiesSaved == true
                        || bBiblioSaved == true
                        || bIssuesSaved == true
                        || bOrdersSaved == true
                        || bObjectSaved == true
                        || bCommentsSaved == true)
                        this.MainForm.StatusBarMessage = strText + " 保存 成功";
                }

                if (nErrorCount > 0)
                {
                    return -1;
                }

                // 保存成功后再校验 MARC 记录
                if (bVerifyData == true
                    && this.AutoVerifyData == true
                    && bVerified == false)
                {
                    // TODO: 注意中途关闭 EntityForm 会发生什么
                    API.PostMessage(this.Handle, WM_VERIFY_DATA, 0, 0);
                }

                return 0;
            }
            finally
            {
                if (nErrorCount == 0)
                    this.ShowMessage("记录保存成功", "green", true);
                else
                    this.ShowMessage("记录保存失败", "red", true);

                Progress.EndLoop();
                Progress.OnStop -= new StopEventHandler(this.DoStop);
                Progress.Initial("");

                this.ReturnChannel(channel);
            }
        }
Esempio n. 9
0
        private void flowLayoutPanel1_Enter(object sender, EventArgs e)
        {
#if NO
            // 找到拥有输入焦点的那个 EntityEditControl
            foreach(Control control in this.flowLayoutPanel1.Controls)
            {
                if (control.ContainsFocus == true
                    && control is EntityEditControl)
                {
                    if (this._genData != null
                        && this.MainForm.PanelFixedVisible == true
                        && this._biblio != null)
                    {
                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = control;
                        this._genData.AutoGenerate(_biblio, // control,
                            e1,
                            this._biblio.BiblioRecPath,
                            true);
                    }
                    return;

                }
            }
#endif
            if (_biblio != null)
            {
                EntityEditControl edit = _biblio.GetFocusedEditControl();
                if (edit != null)
                {
                    if (this._genData != null
        && this.MainForm.PanelFixedVisible == true)
                    {
                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = edit;
                        this._genData.AutoGenerate(_biblio, // control,
                            e1,
                            this._biblio.BiblioRecPath,
                            true);
                    }
                }
            }
        }
Esempio n. 10
0
 void MarcEditor_GenerateData(object sender, GenerateDataEventArgs e)
 {
     this.AutoGenerate();
 }
Esempio n. 11
0
    public void CreateMenu(object sender, GenerateDataEventArgs e)
    {
        ScriptActionCollection actions = new ScriptActionCollection();

        this.ScriptActions = actions;
    }
Esempio n. 12
0
 public void VerifyData()
 {
     GenerateDataEventArgs e1 = new GenerateDataEventArgs();
     e1.FocusedControl = this.MarcEditor;
     this.VerifyData(this, e1, null, false);
 }
Esempio n. 13
0
        // MARC格式校验
        // parameters:
        //      sender    从何处启动? MarcEditor EntityEditForm
        /// <summary>
        /// MARC格式校验
        /// </summary>
        /// <param name="sender">从何处启动?</param>
        /// <param name="e">GenerateDataEventArgs对象,表示动作参数</param>
        /// <param name="bAutoVerify">是否自动校验。自动校验的时候,如果没有发现错误,则不出现最后的对话框</param>
        /// <returns>0: 没有发现校验错误; 1: 发现校验警告; 2: 发现校验错误</returns>
        public int VerifyData(object sender,
            GenerateDataEventArgs e,
            string strSavePath,
            bool bAutoVerify)
        {
            string strError = "";
            string strCode = "";
            string strRef = "";


            if (string.IsNullOrEmpty(strSavePath) == true)
                strSavePath = this.SavePath;

            if (String.IsNullOrEmpty(strSavePath) == true)
            {
                strError = "缺乏保存路径";
                goto ERROR1;
            }

            string strProtocol = "";
            string strPath = "";
            int nRet = Global.ParsePath(strSavePath,
                out strProtocol,
                out strPath,
                out strError);
            if (nRet == -1)
                goto ERROR1;


            // dtlp协议的自动创建数据
            if (strProtocol.ToLower() == "dtlp")
            {
                strError = "暂不支持来自DTLP协议的数据自动创建功能";
                goto ERROR1;
            }

            // Debug.Assert(false, "");
            this.m_strVerifyResult = "正在校验...";
            // 自动校验的时候,如果没有发现错误,则不出现最后的对话框
            if (bAutoVerify == false)
            {
                // 如果固定面板隐藏,就打开窗口
                DoViewVerifyResult(this.MainForm.PanelFixedVisible == false ? true : false);
            }

            VerifyHost host = new VerifyHost();
            host.DetailForm = this;

            // dp2library协议的自动创建数据
            if (strProtocol.ToLower() == "dp2library")
            {
                dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

                if (dp2_searchform == null)
                {
                    strError = "没有连接的或者打开的dp2检索窗,无法进行数据创建";
                    goto ERROR1;
                }

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

                string strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);

                string strCfgFileName = "dp2catalog_marc_verify.fltx";

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

                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)
                    goto ERROR1;
                if (nRet == 0)
                {
                    strCfgFileName = "dp2catalog_marc_verify.cs";

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

                    baCfgOutputTimestamp = null;
                    nRet = dp2_searchform.GetCfgFile(strCfgPath,
                        out strCode,
                        out baCfgOutputTimestamp,
                        out strError);
                    if (nRet == 0)
                    {
                        strError = "服务器上没有定义路径为 '" + strCfgPath + "' 的配置文件(或.fltx配置文件),数据校验无法进行";
                        goto ERROR1;
                    } 
                    if (nRet == -1)
                        goto ERROR1;

                    strCfgFileName = "dp2catalog_marc_verify.cs.ref";

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

                    nRet = dp2_searchform.GetCfgFile(strCfgPath,
                        out strRef,
                        out baCfgOutputTimestamp,
                        out strError);
                    if (nRet == 0)
                    {
                        strError = "服务器上没有定义路径为 '" + strCfgPath + "' 的配置文件,虽然定义了.cs配置文件。数据校验无法进行";
                        goto ERROR1;
                    }
                    if (nRet == -1)
                        goto ERROR1;

                    try
                    {
                        // 执行代码
                        nRet = RunVerifyCsScript(
                            sender,
                            e,
                            strCode,
                            strRef,
                            out host,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;
                    }
                    catch (Exception ex)
                    {
                        strError = "执行脚本代码过程中发生异常: \r\n" + ExceptionUtil.GetDebugText(ex);
                        goto ERROR1;
                    }
                }
                else
                {
                    VerifyFilterDocument filter = null;

                    nRet = this.PrepareVerifyMarcFilter(
                        host,
                        strCode,
                        out filter,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "编译文件 '" + strCfgFileName + "' 的过程中出错:\r\n" + strError;
                        goto ERROR1;
                    }

                    try
                    {

                        nRet = filter.DoRecord(null,
                            this.MarcEditor.Marc,
                            0,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;

                    }
                    catch (Exception ex)
                    {
                        strError = "filter.DoRecord error: " + ExceptionUtil.GetDebugText(ex);
                        goto ERROR1;
                    }
                }
            }

            bool bVerifyFail = false;
            if (string.IsNullOrEmpty(host.ResultString) == true)
            {
                if (this.m_verifyViewer != null)
                    this.m_verifyViewer.ResultString = "经过校验没有发现任何错误。";
            }
            else
            {
                if (bAutoVerify == true)
                {
                    // 延迟打开窗口
                    DoViewVerifyResult(this.MainForm.PanelFixedVisible == false ? true : false);
                }
                this.m_verifyViewer.ResultString = host.ResultString;
                this.MainForm.ActivateVerifyResultPage();   // 2014/7/13
                bVerifyFail = true;
            }

            return bVerifyFail == true ? 2 : 0;
        ERROR1:
            MessageBox.Show(this, strError);
            if (this.m_verifyViewer != null)
                this.m_verifyViewer.ResultString = strError;
            return 0;
        }
Esempio n. 14
0
        // 自动加工数据
        // parameters:
        //      sender    从何处启动? MarcEditor EntityEditForm
        public void AutoGenerate(object sender,
            GenerateDataEventArgs e,
            bool bOnlyFillMenu = false)
        {
            int nRet = 0;

            string strError = "";
            bool bAssemblyReloaded = false;

            // 初始化 dp2catalog_marc_autogen.cs 的 Assembly,并new MarcDetailHost对象
            // return:
            //      -2  清除了Assembly
            //      -1  error
            //      0   没有重新初始化Assembly,而是直接用以前Cache的Assembly
            //      1   重新(或者首次)初始化了Assembly
            nRet = InitialAutogenAssembly(out strError);
            if (nRet == -2)
            {
                if (bOnlyFillMenu == true)
                    return;
            }
            if (nRet == -1)
                goto ERROR1;
            if (nRet == 0)
            {
                if (this.m_detailHostObj == null)
                    return; // 库名不具备,无法初始化
            }
            if (nRet == 1)
                bAssemblyReloaded = true;

            Debug.Assert(this.m_detailHostObj != null, "");




            if (this.AutoGenNewStyle == true)
            {
                DisplayAutoGenMenuWindow(this.MainForm.PanelFixedVisible == false ? true : false);
                if (bOnlyFillMenu == false)
                {
                    if (this.MainForm.PanelFixedVisible == true)
                        MainForm.ActivateGenerateDataPage();
                }

                if (this.m_genDataViewer != null)
                {
                    this.m_genDataViewer.sender = sender;
                    this.m_genDataViewer.e = e;
                }

                // 清除残留菜单事项
                if (m_autogenSender != sender
                    || bAssemblyReloaded == true)
                {
                    if (this.m_genDataViewer != null
                        && this.m_genDataViewer.Count > 0)
                        this.m_genDataViewer.Clear();
                }
            }
            else // 旧的风格
            {
                if (this.m_genDataViewer != null)
                {
                    this.m_genDataViewer.Close();
                    this.m_genDataViewer = null;
                }

                if (this.Focused == true || this.MarcEditor.Focused)
                    this.MainForm.CurrentGenerateDataControl = null;

                // 如果意图仅仅为填充菜单
                if (bOnlyFillMenu == true)
                    return;
            }

            try
            {
                // 旧的风格
                if (this.AutoGenNewStyle == false)
                {
                    this.m_detailHostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry,
sender,
e);
                    // this.SetSaveAllButtonState(true);
                    return;
                }

                // 初始化菜单
                try
                {
                    if (this.m_genDataViewer != null)
                    {
                        if (this.m_genDataViewer.Count == 0)
                        {
                            dynamic o = this.m_detailHostObj;
                            o.CreateMenu(sender, e);

                            this.m_genDataViewer.Actions = this.m_detailHostObj.ScriptActions;
                        }

                        // 根据当前插入符位置刷新加亮事项
                        this.m_genDataViewer.RefreshState();
                    }

                    if (String.IsNullOrEmpty(e.ScriptEntry) == false)
                    {
                        this.m_detailHostObj.Invoke(e.ScriptEntry,
                            sender,
                            e);
                    }
                    else
                    {
                        if (this.MainForm.PanelFixedVisible == true
                            && bOnlyFillMenu == false
                            && this.MainForm.CurrentGenerateDataControl != null)
                        {
                            TableLayoutPanel table = (TableLayoutPanel)this.MainForm.CurrentGenerateDataControl;
                            for (int i = 0; i < table.Controls.Count; i++)
                            {
                                Control control = table.Controls[i];
                                if (control is DpTable)
                                {
                                    control.Focus();
                                    break;
                                }
                            }

                        }
                    }
                }
                catch (Exception ex)
                {
                    /*
                    // 被迫改用旧的风格
                    this.m_detailHostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry,
    sender,
    e);
                    this.SetSaveAllButtonState(true);
                    return;
                     * */
                    throw;
                }
            }
            catch (Exception ex)
            {
                strError = "执行脚本文件 '" + m_strAutogenDataCfgFilename + "' 过程中发生异常: \r\n" + ExceptionUtil.GetDebugText(ex);
                goto ERROR1;
            }

            this.m_autogenSender = sender;  // 记忆最近一次的调用发起者

            if (bOnlyFillMenu == false
                && this.m_genDataViewer != null)
                this.m_genDataViewer.TryAutoRun();

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Esempio n. 15
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_FILL_MARCEDITOR_SCRIPT_MENU:
                    // 显示Ctrl+A菜单
                    if (this.MainForm.PanelFixedVisible == true)
                        this.AutoGenerate(this.MarcEditor,
                            new GenerateDataEventArgs(),
                            true);
                    return;
                case WM_LOADSIZE:
                    LoadSize();
                    return;
                case WM_VERIFY_DATA:
                    {
                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = this.MarcEditor;

                        this.VerifyData(this, e1, null, true);
                        return;
                    }
            }
            base.DefWndProc(ref m);
        }
Esempio n. 16
0
        // 保存记录
        // parameters:
        //      strStyle    "saveas"另存  其他为普通保存
        public int SaveRecord(string strStyle = "save")
        {
            string strError = "";
            int nRet = 0;

            string strLastSavePath = MainForm.LastSavePath;
            if (String.IsNullOrEmpty(strLastSavePath) == false)
            {
                string strOutputPath = "";
                nRet = ChangePathToAppendStyle(strLastSavePath,
                    out strOutputPath,
                    out strError);
                if (nRet == -1)
                {
                    MainForm.LastSavePath = ""; // 避免下次继续出错 2011/3/4
                    goto ERROR1;
                }
                strLastSavePath = strOutputPath;
            }

            string strCurrentUserName = "";
            string strSavePath = this.SavePath == "" ? strLastSavePath : this.SavePath;

            if (strStyle == "save"
                && string.IsNullOrEmpty(this.SavePath) == false
                && (Control.ModifierKeys & Keys.Control) == 0)
            {
                // 2011/8/8
                // 保存时如果已经有了路径,就不用打开对话框了
            }
            else
            {
                SaveRecordDlg dlg = new SaveRecordDlg();
                GuiUtil.SetControlFont(dlg, this.Font);

                dlg.MainForm = this.MainForm;
                dlg.GetDtlpSearchParam += new GetDtlpSearchParamEventHandle(dlg_GetDtlpSearchParam);
                dlg.GetDp2SearchParam += new GetDp2SearchParamEventHandle(dlg_GetDp2SearchParam);
                if (strStyle == "save")
                    dlg.RecPath = this.SavePath == "" ? strLastSavePath : this.SavePath;
                else
                {
                    dlg.RecPath = strLastSavePath;  // 2011/6/19
                    dlg.Text = "另存记录";
                }

                // dlg.StartPosition = FormStartPosition.CenterScreen;
                this.MainForm.AppInfo.LinkFormState(dlg, "SaveRecordDlg_state");
                dlg.UiState = this.MainForm.AppInfo.GetString("MarcDetailForm", "SaveRecordDlg_uiState", "");
                dlg.ShowDialog(this);
                this.MainForm.AppInfo.SetString("MarcDetailForm", "SaveRecordDlg_uiState", dlg.UiState);

                if (dlg.DialogResult != DialogResult.OK)
                    return 0;

                MainForm.LastSavePath = dlg.RecPath;

                strSavePath = dlg.RecPath;
                strCurrentUserName = dlg.CurrentUserName;
            }


            /*
            if (String.IsNullOrEmpty(this.SavePath) == true)
            {
                strError = "缺乏保存路径";
                goto ERROR1;
            }
             * */

            string strProtocol = "";
            string strPath = "";
            nRet = Global.ParsePath(strSavePath,
                out strProtocol,
                out strPath,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.stop.BeginLoop();

            this.EnableControls(false);
            try
            {
                // dtlp协议的记录保存
                if (strProtocol.ToLower() == "dtlp")
                {
                    DtlpSearchForm dtlp_searchform = this.GetDtlpSearchForm();

                    if (dtlp_searchform == null)
                    {
                        strError = "没有连接的或者打开的DTLP检索窗,无法保存记录";
                        goto ERROR1;
                    }

                    /*
                    string strOutPath = "";
                    nRet = DtlpChannel.CanonicalizeWritePath(strPath,
                        out strOutPath,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    strPath = strOutPath;
                     * */


                    string strOutputPath = "";
                    byte[] baOutputTimestamp = null;
                    nRet = dtlp_searchform.SaveMarcRecord(
                        strPath,
                        this.MarcEditor.Marc,
                        this.CurrentTimestamp,
                        out strOutputPath,
                        out baOutputTimestamp,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    // TODO: 时间戳冲突?

                    this.SavePath = strProtocol + ":" + strOutputPath;
                    this.CurrentTimestamp = baOutputTimestamp;

                    this.BiblioChanged = false;

                    // 是否刷新MARC记录?
                    //AutoCloseMessageBox.Show(this, "保存成功");
                    // MessageBox.Show(this, "保存成功");
                    return 0;
                }
                else if (strProtocol.ToLower() == "dp2library")
                {
                    dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

                    if (dp2_searchform == null)
                    {
                        strError = "没有连接的或者打开的dp2检索窗,无法保存记录";
                        goto ERROR1;
                    }

#if NO
                    // 迫使登录一次
                    if (string.IsNullOrEmpty(strCurrentUserName) == true
                        && string.IsNullOrEmpty(this.CurrentUserName) == true)
                    {
                        string strServerName = "";
                        string strLocalPath = "";

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

                        string strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);
                        string strSyntax = "";
                        nRet = dp2_searchform.GetDbSyntax(
    null,
    strServerName,
    strBiblioDbName,
    out strSyntax,
    out strError);
                    }
#endif

                    // 保存前的准备工作
                    {
                        // 初始化 dp2catalog_marc_autogen.cs 的 Assembly,并new MarcDetailHost对象
                        // return:
                        //      -2  清除了Assembly
                        //      -1  error
                        //      0   没有重新初始化Assembly,而是直接用以前Cache的Assembly (可能本来就是空)
                        //      1   重新(或者首次)初始化了Assembly
                        nRet = InitialAutogenAssembly(out strError);
                        if (nRet == -1)
                            goto ERROR1;
                        if (this.m_detailHostObj != null)
                        {
                            // 模拟出this.SavePath 2011/11/22
                            string strOldSavePath = this.textBox_savePath.Text;
                            this.textBox_savePath.Text = strSavePath;
                            try
                            {
                                BeforeSaveRecordEventArgs e = new BeforeSaveRecordEventArgs();
                                e.CurrentUserName = strCurrentUserName;
                                this.m_detailHostObj.BeforeSaveRecord(this.MarcEditor, e);
                                if (string.IsNullOrEmpty(e.ErrorInfo) == false)
                                {
                                    MessageBox.Show(this, "保存前的准备工作失败: " + e.ErrorInfo + "\r\n\r\n但保存操作仍将继续");
                                }
                            }
                            finally
                            {
                                // 恢复this.SavePath
                                this.textBox_savePath.Text = strOldSavePath;
                            }
                        }
                    }

                    byte[] baTimestamp = this.CurrentTimestamp;
                    string strMARC = this.MarcEditor.Marc;
                    string strFragment = "";
                    if (this.domXmlFragment != null
                        && this.domXmlFragment.DocumentElement != null)
                        strFragment = this.domXmlFragment.DocumentElement.InnerXml;

                    // 2014/5/12
                    string strMarcSyntax = "";
                    if (this.CurrentRecord != null)
                        strMarcSyntax = GetMarcSyntax(this.CurrentRecord.m_strSyntaxOID);

                    // 2014/5/18
                    if (string.IsNullOrEmpty(this.AutoDetectedMarcSyntaxOID) == false)
                        strMarcSyntax = GetMarcSyntax(this.AutoDetectedMarcSyntaxOID);

                    string strComment = "";
                    bool bOverwrite = false;

                    if (string.IsNullOrEmpty(this.SavePath) == false)
                    {
                        string strTempProtocol = "";
                        string strTempPath = "";
                        nRet = Global.ParsePath(this.SavePath,
                            out strTempProtocol,
                            out strTempPath,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;

                        string strServerName = "";
                        string strPurePath = "";

                        dp2SearchForm.ParseRecPath(strTempPath,
out strServerName,
out strPurePath);

                        if (dp2SearchForm.IsAppendRecPath(strPurePath) == false)
                        {
                            string strServerUrl = dp2_searchform.GetServerUrl(strServerName);
                            strComment = "copy from " + strPurePath + "@" + strServerUrl;
                        }
                    }
                    else if (string.IsNullOrEmpty(this.textBox_tempRecPath.Text) == false)
                    {
                        strComment = "copy from " + this.textBox_tempRecPath.Text;
                    }

                    string strRights = "";
                    // 判断是否追加
                    {
                        string strServerName = "";
                        string strPurePath = "";

                        dp2SearchForm.ParseRecPath(strPath,
out strServerName,
out strPurePath);
                        if (dp2SearchForm.IsAppendRecPath(strPurePath) == false)
                            bOverwrite = true;

                        nRet = dp2_searchform.GetChannelRights(
                                strServerName,
                                out strRights,
                                out strError);
                        if (nRet == -1)
                            goto ERROR1;

                    }

                    bool bForceWverifyData = StringUtil.IsInList("client_forceverifydata", strRights);

                    bool bVerifyed = false;
                    if (bForceWverifyData == true)
                    {
                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = this.MarcEditor;

                        // 0: 没有发现校验错误; 1: 发现校验警告; 2: 发现校验错误
                        nRet = this.VerifyData(this, e1, strSavePath, true);
                        if (nRet == 2)
                        {
                            strError = "MARC 记录经校验发现有错,被拒绝保存。请修改 MARC 记录后重新保存";
                            goto ERROR1;
                        }
                        bVerifyed = true;
                    }

                REDO_SAVE_DP2:
                    string strOutputPath = "";
                    byte[] baOutputTimestamp = null;
                    // return:
                    //      -2  timestamp mismatch
                    //      -1  error
                    //      0   succeed
                    nRet = dp2_searchform.SaveMarcRecord(
                        true,
                        strPath,
                        strMARC,
                        strMarcSyntax,
                        baTimestamp,
                        strFragment,
                        strComment,
                        out strOutputPath,
                        out baOutputTimestamp,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    if (nRet == -2)
                    {
                        // 时间戳冲突了

                        // 装载目标记录
                        DigitalPlatform.Z3950.Record record = null;
                        Encoding currentEncoding = null;
                        byte[] baTargetTimestamp = null;
                        string strOutStyle = "";
                        string strTargetMARC = "";
                        string strError1 = "";

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

                        nRet = dp2_searchform.GetOneRecord(
                            // true,
                            "marc",
                            //strPath,    // 不能有问号?
                            //"", // strDirection,
                            0,
                            "path:" + strPath,
                            "",
                            out strOutputSavePath,
                            out strTargetMARC,
                            out strXmlFragment,
                            out strOutStyle,
                            out baTargetTimestamp,
                            out lVersion,
                            out record,
                            out currentEncoding,
                            out logininfo,
                            out strError1);
                        if (nRet == -1)
                        {
                            strError = "保存记录时发生错误: " + strError + ",在重装入目标记录的时候又发生错误: " + strError1;
                            goto ERROR1;
                        }

                        nRet = this.LoadXmlFragment(strXmlFragment,
out strError1);
                        if (nRet == -1)
                        {
                            strError1 = "保存记录时发生错误: " + strError + ",在重装入目标记录的时候又发生错误: " + strError1;
                            goto ERROR1;
                        }

                        // TODO: 检查源和目标的MARC格式是否一致?是否前面检查过了?
                        TwoBiblioDialog two_biblio_dlg = new TwoBiblioDialog();
                        GuiUtil.SetControlFont(two_biblio_dlg, this.Font);

                        two_biblio_dlg.Text = "覆盖书目记录";
                        two_biblio_dlg.MessageText = "即将被覆盖的目标记录和源内容不同。\r\n\r\n请问是否确定要用源内容覆盖目标记录?";
                        two_biblio_dlg.LabelSourceText = "源";
                        two_biblio_dlg.LabelTargetText = "目标 " + strPath;
                        two_biblio_dlg.MarcSource = strMARC;
                        two_biblio_dlg.MarcTarget = strTargetMARC;
                        two_biblio_dlg.ReadOnlyTarget = true;   // 初始时目标MARC编辑器不让进行修改

                        this.MainForm.AppInfo.LinkFormState(two_biblio_dlg, "TwoBiblioDialog_state");
                        two_biblio_dlg.ShowDialog(this);
                        this.MainForm.AppInfo.UnlinkFormState(two_biblio_dlg);

                        if (two_biblio_dlg.DialogResult == DialogResult.Cancel)
                        {
                            strError = "放弃保存";
                            goto ERROR1;
                            // return 0;   // 全部放弃
                        }

                        if (two_biblio_dlg.DialogResult == DialogResult.No)
                        {
                            strError = "放弃保存";
                            goto ERROR1;
                        }

                        if (two_biblio_dlg.EditTarget == false)
                            strMARC = two_biblio_dlg.MarcSource;
                        else
                            strMARC = two_biblio_dlg.MarcTarget;

                        baTimestamp = baTargetTimestamp;
                        goto REDO_SAVE_DP2;
                    }

                    this.SavePath = dp2_searchform.CurrentProtocol + ":" + strOutputPath;
                    this.CurrentTimestamp = baOutputTimestamp;

                    this.BiblioChanged = false;

                    this.MarcEditor.ClearMarcDefDom();
                    this.MarcEditor.RefreshNameCaption();


                    // 是否刷新MARC记录?
                    // MessageBox.Show(this, "保存成功");

                    if (bOverwrite == true
                        && this.LinkedSearchForm != null)
                    {
                        // return:
                        //      -2  不支持
                        //      -1  error
                        //      0   相关窗口已经销毁,没有必要刷新
                        //      1   已经刷新
                        //      2   在结果集中没有找到要刷新的记录
                        nRet = RefreshCachedRecord("refresh",
                            out strError);
                        if (nRet == -1)
                            MessageBox.Show(this, "记录保存已经成功,但刷新相关结果集内记录时出错: " + strError);
                    }

                    if (this.AutoVerifyData == true
                        && bVerifyed == false)
                    {
                        // API.PostMessage(this.Handle, WM_VERIFY_DATA, 0, 0);

                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = this.MarcEditor;

                        // 0: 没有发现校验错误; 1: 发现校验警告; 2: 发现校验错误
                        nRet = this.VerifyData(this, e1, strSavePath, true);
                        if (nRet == 2)
                        {
                            strError = "MARC 记录经校验发现有错。记录已经保存。请修改 MARC 记录后重新保存";
                            MessageBox.Show(this, strError);
                        }
                    }

                    return 0;
                }
                else if (strProtocol.ToLower() == "unioncatalog")
                {
                    string strServerName = "";
                    string strPurePath = "";
                    dp2SearchForm.ParseRecPath(strPath,
                        out strServerName,
                        out strPurePath);
                    if (String.IsNullOrEmpty(strServerName) == true)
                    {
                        strError = "路径不合法: 缺乏服务器名部分";
                        goto ERROR1;
                    }
                    if (String.IsNullOrEmpty(strPurePath) == true)
                    {
                        strError = "路径不合法:缺乏纯路径部分";
                        goto ERROR1;
                    }

                    byte[] baTimestamp = this.CurrentTimestamp;
                    string strMARC = this.MarcEditor.Marc;
                    string strMarcSyntax = "";

                    string strMarcSyntaxOID = this.GetCurrentMarcSyntaxOID(out strError);
                    if (String.IsNullOrEmpty(strMarcSyntaxOID) == true)
                    {
                        strError = "当前MARC syntax OID为空,无法判断MARC具体格式";
                        goto ERROR1;
                    }

                    if (strMarcSyntaxOID == "1.2.840.10003.5.1")
                        strMarcSyntax = "unimarc";
                    if (strMarcSyntaxOID == "1.2.840.10003.5.10")
                        strMarcSyntax = "usmarc";

                    string strXml = "";

                    nRet = MarcUtil.Marc2Xml(
                        strMARC,
                        strMarcSyntax,
                        out strXml,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    string strXml1 = "";
                    // 将机内使用的marcxml格式转化为marcxchange格式
                    nRet = MarcUtil.MarcXmlToXChange(strXml,
                        null,
                        out strXml1,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    // TODO: 是否可以直接使用Z39.50属性对话框中的用户名和密码? 登录失败后才出现登录对话框
                    if (this.LoginInfo == null)
                        this.LoginInfo = new dp2Catalog.LoginInfo();

                    bool bRedo = false;
                    REDO_LOGIN:
                    if (string.IsNullOrEmpty(this.LoginInfo.UserName) == true
                        || bRedo == true)
                    {
                        LoginDlg login_dlg = new LoginDlg();
                        GuiUtil.SetControlFont(login_dlg, this.Font);

                        if (bRedo == true)
                            login_dlg.Comment = strError + "\r\n\r\n请重新登录";
                        else
                            login_dlg.Comment = "请指定用户名和密码";
                        login_dlg.UserName = this.LoginInfo.UserName;
                        login_dlg.Password = this.LoginInfo.Password;
                        login_dlg.SavePassword = true;
                        login_dlg.ServerUrl = strServerName;
                        login_dlg.StartPosition = FormStartPosition.CenterScreen;
                        login_dlg.ShowDialog(this);

                        if (login_dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                        {
                            strError = "放弃保存";
                            goto ERROR1;
                        }

                        this.LoginInfo.UserName = login_dlg.UserName;
                        this.LoginInfo.Password = login_dlg.Password;
                        strServerName = login_dlg.ServerUrl;
                    }

                    if (this.LoginInfo.UserName.IndexOf("/") != -1)
                    {
                        strError = "用户名中不能出现字符 '/'";
                        goto ERROR1;
                    }

                    string strOutputTimestamp = "";
                    string strOutputRecPath = "";
                    // parameters:
                    //      strAction   动作。为"new" "change" "delete" "onlydeletebiblio"之一。"delete"在删除书目记录的同时,会自动删除下属的实体记录。不过要求实体均未被借出才能删除。
                    // return:
                    //      -2  登录不成功
                    //      -1  出错
                    //      0   成功
                    nRet = UnionCatalog.UpdateRecord(
                        null,
                        strServerName,
                        this.LoginInfo.UserName + "/" + this.LoginInfo.Password,
                        dp2SearchForm.IsAppendRecPath(strPurePath) == true ? "new": "change",
                        strPurePath,
                        "marcxchange",
                        strXml1,
                        ByteArray.GetHexTimeStampString(baTimestamp),
                        out strOutputRecPath,
                        out strOutputTimestamp,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    if (nRet == -2)
                    {
                        bRedo = true;
                        goto REDO_LOGIN;
                    }

                    this.CurrentTimestamp = ByteArray.GetTimeStampByteArray(strOutputTimestamp);
                    this.SavePath = strProtocol + ":" + strOutputRecPath + "@" + strServerName;

                    this.BiblioChanged = false;

                    this.MarcEditor.ClearMarcDefDom();
                    this.MarcEditor.RefreshNameCaption();


                    // 是否刷新MARC记录?
                    // MessageBox.Show(this, "保存成功");

                    if (dp2SearchForm.IsAppendRecPath(strPurePath) == false
                        && this.LinkedSearchForm != null
                        && this.LinkedSearchForm is ZSearchForm)
                    {
                        nRet = RefreshCachedRecord("refresh",
                            out strError);
                        if (nRet == -1)
                            MessageBox.Show(this, "记录保存已经成功,但刷新相关结果集内记录时出错: " + strError);
                    }

                    return 0;
                }
                else if (strProtocol.ToLower() == "z3950")
                {
                    strError = "目前暂不支持 Z39.50 协议的保存操作";
                    goto ERROR1;
                }
                else if (strProtocol.ToLower() == "amazon")
                {
                    strError = "目前暂不支持 amazon 协议的保存操作";
                    goto ERROR1;
                }
                else
                {
                    strError = "无法识别的协议名 '" + strProtocol + "'";
                    goto ERROR1;
                }

            }
            finally
            {
                this.stop.EndLoop();

                this.EnableControls(true);
            }

            // return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Esempio n. 17
0
 private void binaryResControl1_Enter(object sender, EventArgs e)
 {
     // 显示Ctrl+A菜单
     if (this.MainForm.PanelFixedVisible == true)
     {
         GenerateDataEventArgs e1 = new GenerateDataEventArgs();
         e1.FocusedControl = this.binaryResControl1.ListView;
         e1.ScriptEntry = "";    // 启动Ctrl+A菜单
         this._genData.AutoGenerate(this.binaryResControl1,
             e1,
             GetBiblioRecPathOrSyntax(),
             true);
     }
 }
Esempio n. 18
0
        // 工具条按钮: 保存记录到数据库
        private void toolStripButton_marcEditor_save_Click(object sender, EventArgs e)
        {
            this.toolStrip_marcEditor.Enabled = false;
            try
            {
                // 2014/7/3
                bool bVerifyed = false;

                if (this.m_verifyViewer != null)
                    this.m_verifyViewer.Clear();

                if (this.ForceVerifyData == true)
                {
                    GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                    e1.FocusedControl = this.m_marcEditor;

                    // 0: 没有发现校验错误; 1: 发现校验警告; 2: 发现校验错误
                    int nRet = this.VerifyData(this, e1, true);
                    if (nRet == 2)
                    {
                        MessageBox.Show(this, "MARC 记录经校验发现有错,被拒绝保存。请修改 MARC 记录后重新保存");
                        return;
                    }
                    bVerifyed = true;
                }

                string strHtml = "";
                SaveBiblioToDatabase(null, true, out strHtml);
                this.m_webExternalHost_biblio.SetHtmlString(strHtml,
    "entityform_biblio");

                if (this.AutoVerifyData == true
                    && bVerifyed == false)
                    API.PostMessage(this.Handle, WM_VERIFY_DATA, 0, 0);
            }
            finally
            {
                this.toolStrip_marcEditor.Enabled = true;
            }
        }
Esempio n. 19
0
 void entityControl1_GenerateData(object sender, GenerateDataEventArgs e)
 {
     this._genData.AutoGenerate(sender,
         e,
         GetBiblioRecPathOrSyntax());
 }
Esempio n. 20
0
 private void MarcEditor_VerifyData(object sender, GenerateDataEventArgs e)
 {
     // this.VerifyData(sender, e);
     this.VerifyData(sender, e, false);
 }
Esempio n. 21
0
        /// <summary>
        /// 缺省窗口过程
        /// </summary>
        /// <param name="m">消息</param>
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case WM_SEARCH_DUP:
                    this.SearchDup();
                    return;
                case WM_FILL_MARCEDITOR_SCRIPT_MENU:
                    // 显示Ctrl+A菜单
                    if (this.MainForm.PanelFixedVisible == true)
                        this._genData.AutoGenerate(this.m_marcEditor,
                            new GenerateDataEventArgs(),
                            GetBiblioRecPathOrSyntax(),
                            true);
                    return;
                case WM_VERIFY_DATA:
                    {
                        GenerateDataEventArgs e1 = new GenerateDataEventArgs();
                        e1.FocusedControl = this.m_marcEditor;

                        this.VerifyData(this, e1, true);
                        return;
                    }
                case WM_SWITCH_FOCUS:
                    {
                        if ((int)m.WParam == BIBLIO_SEARCHTEXT)
                        {
                            this.textBox_queryWord.SelectAll();
                            this.textBox_queryWord.Focus();
                        }

                        else if ((int)m.WParam == ITEM_BARCODE)
                        {
                            this.textBox_itemBarcode.SelectAll();
                            this.textBox_itemBarcode.Focus();
                        }
                        else if ((int)m.WParam == ITEM_LIST)
                        {
                            bool bFound = this.ActivateItemsPage();
                            if (bFound == true)
                                this.entityControl1.Focus();
                        }
                        else if ((int)m.WParam == ORDER_LIST)
                        {
                            bool bFound = this.ActivateOrdersPage();
                            if (bFound == true)
                                this.orderControl1.Focus();
                        }
                        else if ((int)m.WParam == COMMENT_LIST)
                        {
                            bool bFound = this.ActivateCommentsPage();
                            if (bFound == true)
                                this.commentControl1.Focus();
                        }
                        else if ((int)m.WParam == ISSUE_LIST)
                        {
                            bool bFound = this.ActivateIssuesPage();
                            if (bFound == true)
                                this.issueControl1.Focus();
                        }
                        else if ((int)m.WParam == MARC_EDITOR)
                        {
                            if (this.m_marcEditor.FocusedFieldIndex == -1)
                                this.m_marcEditor.FocusedFieldIndex = 0;

                            if (this.m_marcEditor.Focused == false)
                                this.m_marcEditor.Focus();
                        }

                        return;
                    }
                // break;

            }
            base.DefWndProc(ref m);
        }
Esempio n. 22
0
 void _biblio_GenerateData(object sender, GenerateDataEventArgs e)
 {
     this._genData.AutoGenerate(sender, e, this.BiblioRecPath);
 }
Esempio n. 23
0
 private void MarcEditor_GenerateData(object sender, GenerateDataEventArgs e)
 {
     this._genData.AutoGenerate(sender,
         e,
         GetBiblioRecPathOrSyntax());
 }
Esempio n. 24
0
 public override void CreateCallNumber(object sender,
 GenerateDataEventArgs e)
 {
     base.CreateCallNumber(sender, e);
 }
Esempio n. 25
0
 // MARC格式校验
 // parameters:
 //      sender    从何处启动? MarcEditor EntityEditForm BindingForm
 /// <summary>
 /// MARC格式校验
 /// </summary>
 /// <param name="sender">从何处启动?</param>
 /// <param name="e">GenerateDataEventArgs对象,表示动作参数</param>
 public void VerifyData(object sender, 
     GenerateDataEventArgs e)
 {
     VerifyData(sender, e, false);
 }
Esempio n. 26
0
    public void CreateMenu(object sender, GenerateDataEventArgs e)
    {
        ScriptActionCollection actions = new ScriptActionCollection();

        if (sender is MarcEditor || sender == null)
        {
            // 加拼音
            actions.NewItem("加拼音", "给全部定义的子字段加拼音", "AddPinyin", false, 'P');

            // 删除拼音
            actions.NewItem("删除拼音", "删除全部拼音子字段", "RemovePinyin", false);

            // 清除拼音缓存
            actions.NewItem("清除拼音缓存", "清除存储的以前选择过的汉字和拼音对照关系", "ClearPinyinCache", false);

            // 分割行
            actions.NewSeperator();

            // 规整ISBN为13
            actions.NewItem("规整为ISBN-13", "对010$a中ISBN进行规整", "HyphenISBN_13", false);

            // 规整ISBN为10
            actions.NewItem("规整为ISBN-10", "对010$a中ISBN进行规整", "HyphenISBN_10", false);

            // 分割行
            actions.NewSeperator();


            // 102国家代码 地区代码
            actions.NewItem("102$a$b <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建102字段$a国家代码$b地区代码", "Add102", false);

            // 410 <-- 225
            actions.NewItem("410 <-- 225", "将225$a内容加入410  $1200  $a", "Copy225To410", false);

            // 7*1$a <-- 200$f
            actions.NewItem("7*1$a <-- 200$f", "将200$f内容加入701/711字段$a", "Copy200fTo7x1a", false);

            // 7*2$a <-- 200$g
            actions.NewItem("7*2$a <-- 200$g", "将200$g内容加入702/712字段$a", "Copy200gTo7x2a", false);


            // 905$d <-- 690$a
            actions.NewItem("905$d <-- 690$a", "将690$a内容加入905字段$d", "Copy690aTo905d", false);


            // 加入GCA著者号
            actions.NewItem("加入GCAT著者号", "根据701/711/702/712$a内容, 创建905$e", "AddGcatAuthorNumber", false);

            // 加入四角号码著者号
            actions.NewItem("加入四角号码著者号", "根据701/711/702/712$a内容, 创建905$e", "AddSjhmAuthorNumber", false);

            // 加入种次号
            actions.NewItem("加入种次号", "根据905$d内容, 创建905$e", "AddZhongcihao", false);

            //  维护种次号
            actions.NewItem("维护种次号", "根据905$d内容中的类号, 出现维护种次号的界面", "ManageZhongcihao", false);

            // 出版地
            actions.NewItem("210$a$c <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建出版社子字段210$a$c", "AddPublisher", false);

            // 分割行
            actions.NewSeperator();

            // 维护 102 国家代码 地区代码
            actions.NewItem("维护102对照表", "ISBN出版社代码 和 102字段$a国家代码$b地区代码 的对照表", "Manage102", false);

            // 维护 210 出版地 出版社
            actions.NewItem("维护210对照表", "ISBN出版社代码 和 210字段$a出版地$c出版社名 的对照表", "Manage210", false);

            // 分割行
            actions.NewSeperator();

        }

        this.ScriptActions = actions;
    }
Esempio n. 27
0
        int RunVerifyCsScript(
            object sender,
            GenerateDataEventArgs e,
            string strCode,
            string strRef,
            out VerifyHost hostObj,
            out string strError)
        {
            strError = "";
            string[] saRef = null;
            int nRet;
            hostObj = null;

            nRet = ScriptManager.GetRefsFromXml(strRef,
                out saRef,
                out strError);
            if (nRet == -1)
                return -1;

            // 2007/12/4 
            ScriptManager.RemoveRefsBinDirMacro(ref saRef);

            string[] saAddRef = {
                                    "system.dll",
                                    "system.xml.dll",
                                    "system.windows.forms.dll",
                                    "system.drawing.dll",
                                    "System.Runtime.Serialization.dll",

									Environment.CurrentDirectory + "\\digitalplatform.dll",
									Environment.CurrentDirectory + "\\digitalplatform.IO.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Text.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Xml.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marceditor.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marcfixedfieldcontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marckernel.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marcquery.dll",
									Environment.CurrentDirectory + "\\digitalplatform.gcatclient.dll",
									Environment.CurrentDirectory + "\\digitalplatform.script.dll",
									Environment.CurrentDirectory + "\\digitalplatform.commoncontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.circulationclient.dll",
									Environment.CurrentDirectory + "\\digitalplatform.libraryclient.dll",

                                    Environment.CurrentDirectory + "\\dp2circulation.exe"
								};

            if (saAddRef != null)
            {
                string[] saTemp = new string[saRef.Length + saAddRef.Length];
                Array.Copy(saRef, 0, saTemp, 0, saRef.Length);
                Array.Copy(saAddRef, 0, saTemp, saRef.Length, saAddRef.Length);
                saRef = saTemp;
            }

            Assembly assembly = null;
            string strErrorInfo = "";
            string strWarningInfo = "";
            nRet = ScriptManager.CreateAssembly_1(strCode,
                saRef,
                null,   // strLibPaths,
                out assembly,
                out strErrorInfo,
                out strWarningInfo);
            if (nRet == -1)
            {
                strError = "脚本编译发现错误或警告:\r\n" + strErrorInfo;
                return -1;
            }

            // 得到Assembly中VerifyHost派生类Type
            Type entryClassType = ScriptManager.GetDerivedClassType(
                assembly,
                "dp2Circulation.VerifyHost");
            if (entryClassType == null)
            {

                strError = "dp2Circulation.VerifyHost派生类没有找到";
                return -1;
            }

            {
                // new一个VerifyHost派生对象
                hostObj = (VerifyHost)entryClassType.InvokeMember(null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                    null);

                if (hostObj == null)
                {
                    strError = "new VerifyHost派生类对象失败";
                    return -1;
                }

                // 为Host派生类设置参数
                hostObj.DetailForm = this;
                hostObj.Assembly = assembly;

                HostEventArgs e1 = new HostEventArgs();
                e1.e = e;   // 2009/2/24 

                hostObj.Main(sender, e1);
            }

            return 0;
        }
Esempio n. 28
0
        public void Invoke(string strFuncName,
    object sender,
    GenerateDataEventArgs e)
        {
            Type classType = this.GetType();

            while (classType != null)
            {
                try
                {
                    // 有两个参数的成员函数
                    classType.InvokeMember(strFuncName,
                        BindingFlags.DeclaredOnly |
                        BindingFlags.Public | BindingFlags.NonPublic |
                        BindingFlags.Instance | BindingFlags.InvokeMethod
                        ,
                        null,
                        this,
                        new object[] { sender, e });
                    return;

                }
                catch (System.MissingMethodException/*ex*/)
                {
                    classType = classType.BaseType;
                    if (classType == null)
                        break;
                }
            }

            if (strFuncName == "Main")
            {
                classType = this.GetType();

                // 老的HostEventArgs e 参数
                while (classType != null)
                {
                    try
                    {
                        // 有两个参数的成员函数
                        classType.InvokeMember(strFuncName,
                            BindingFlags.DeclaredOnly |
                            BindingFlags.Public | BindingFlags.NonPublic |
                            BindingFlags.Instance | BindingFlags.InvokeMethod
                            ,
                            null,
                            this,
                            new object[] { sender, new HostEventArgs() });
                        return;

                    }
                    catch (System.MissingMethodException/*ex*/)
                    {
                        classType = classType.BaseType;
                        if (classType == null)
                            break;
                    }
                }
            }


            classType = this.GetType();

            while (classType != null)
            {
                try
                {
                    // 兼容以前的书写方法 -- 没有参数
                    classType.InvokeMember(strFuncName,
                        BindingFlags.DeclaredOnly |
                        BindingFlags.Public | BindingFlags.NonPublic |
                        BindingFlags.Instance | BindingFlags.InvokeMethod
                        ,
                        null,
                        this,
                        null);
                    return;
                }
                catch (System.MissingMethodException/*ex*/)
                {
                    classType = classType.BaseType;
                }
            }

            throw new Exception("函数 void " + strFuncName + "(object sender, GenerateDataEventArgs e) 或 void " + strFuncName + "() 没有找到");
        }
Esempio n. 29
0
        int RunCsScript(
            object sender,
            GenerateDataEventArgs e,
            string strCode,
            string strRef,
            out string strError)
        {
            strError = "";
            string[] saRef = null;
            int nRet;
            // string strWarning = "";

            nRet = ScriptManager.GetRefsFromXml(strRef,
                out saRef,
                out strError);
            if (nRet == -1)
                return -1;

            // 2007/12/4 
            ScriptManager.RemoveRefsBinDirMacro(ref saRef);

            string[] saAddRef = {
                                    // 2011/3/4 增加
                                    "system.dll",
                                    "system.xml.dll",
                                    "system.windows.forms.dll",
                                    "system.drawing.dll",
                                    "System.Runtime.Serialization.dll",

									Environment.CurrentDirectory + "\\digitalplatform.dll",
									Environment.CurrentDirectory + "\\digitalplatform.IO.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Text.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Xml.dll",
									//Environment.CurrentDirectory + "\\digitalplatform.xmleditor.dll",
									//Environment.CurrentDirectory + "\\digitalplatform.rms.dll",
									//Environment.CurrentDirectory + "\\digitalplatform.rms.client.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marceditor.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marcfixedfieldcontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marckernel.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marcquery.dll",
									Environment.CurrentDirectory + "\\digitalplatform.gcatclient.dll",
									Environment.CurrentDirectory + "\\digitalplatform.script.dll",
									Environment.CurrentDirectory + "\\digitalplatform.commoncontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.circulationclient.dll",
									Environment.CurrentDirectory + "\\digitalplatform.libraryclient.dll",

                                    //Environment.CurrentDirectory + "\\digitalplatform.library.dll",
									// Environment.CurrentDirectory + "\\Interop.SHDocVw.dll",
									Environment.CurrentDirectory + "\\dp2circulation.exe"
								};

            if (saAddRef != null)
            {
                string[] saTemp = new string[saRef.Length + saAddRef.Length];
                Array.Copy(saRef, 0, saTemp, 0, saRef.Length);
                Array.Copy(saAddRef, 0, saTemp, saRef.Length, saAddRef.Length);
                saRef = saTemp;
            }

            Assembly assembly = null;
            string strErrorInfo = "";
            string strWarningInfo = "";
            nRet = ScriptManager.CreateAssembly_1(strCode,
                saRef,
                null,   // strLibPaths,
                out assembly,
                out strErrorInfo,
                out strWarningInfo);
            if (nRet == -1)
            {
                strError = "脚本编译发现错误或警告:\r\n" + strErrorInfo;
                return -1;
            }

            // 得到Assembly中Host派生类Type
            Type entryClassType = ScriptManager.GetDerivedClassType(
                assembly,
                "dp2Circulation.Host");
            if (entryClassType == null)
            {
                entryClassType = ScriptManager.GetDerivedClassType(
                    assembly,
                    "dp2Circulation.DetailHost");
                if (entryClassType == null)
                {
                    strError = "dp2Circulation.Host的派生类和dp2Circulation.DetailHost的派生类都没有找到";
                    return -1;
                }

                // new一个DetailHost派生对象
                DetailHost hostObj = (DetailHost)entryClassType.InvokeMember(null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                    null);

                if (hostObj == null)
                {
                    strError = "new DetailHost的派生类对象时失败";
                    return -1;
                }

                using (hostObj)
                {
                    // 为DetailHost派生类设置参数
                    hostObj.DetailForm = this;
                    hostObj.Assembly = assembly;

                    // hostObj.Main(sender, e);

                    // 2009/2/27 
                    hostObj.Invoke(String.IsNullOrEmpty(e.ScriptEntry) == true ? "Main" : e.ScriptEntry,
                        sender,
                        e);
                }
                return 0;
            }
            else
            {
                // 为了兼容,保留以往的调用方式

                // new一个Host派生对象
                Host hostObj = (Host)entryClassType.InvokeMember(null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                    null);

                if (hostObj == null)
                {
                    strError = "new Host派生类对象失败";
                    return -1;
                }

                {
                    // 为Host派生类设置参数
                    hostObj.DetailForm = this;
                    hostObj.Assembly = assembly;

                    HostEventArgs e1 = new HostEventArgs();
                    e1.e = e;   // 2009/2/24 

                    /*
                    nRet = this.Flush(out strError);
                    if (nRet == -1)
                        return -1;
                     * */


                    hostObj.Main(sender, e1);

                    /*
                    nRet = this.Flush(out strError);
                    if (nRet == -1)
                        return -1;
                     * */
                }
            }

            return 0;
        }
Esempio n. 30
0
 private void entityEditControl1_ControlKeyDown(object sender, ControlKeyEventArgs e)
 {
     if (e.e.KeyCode == Keys.A && e.e.Control == true)
     {
         if (this.GenerateData != null)
         {
             GenerateDataEventArgs e1 = new GenerateDataEventArgs();
             e1.FocusedControl = sender; // sender为 EntityEditControl
             this.GenerateData(this, e1);
         }
         e.e.SuppressKeyPress = true;    // 2015/5/28
         return;
     }
 }