示例#1
0
        void m_genDataViewer_MyFormClosed(object sender, EventArgs e)
        {
            if (m_genDataViewer != null)
            {
                this.MainForm.AppInfo.SetBoolean("detailform", "gen_auto_run", m_genDataViewer.AutoRun);

                {	// 保存列宽度
                    string strWidths = DpTable.GetColumnWidthListString(m_genDataViewer.ActionTable);
                    this.MainForm.AppInfo.SetString(
                        "gen_data_dlg",
                        "column_width",
                        strWidths);
                }

                this.MainForm.AppInfo.UnlinkFormState(m_genDataViewer);
                this.m_genDataViewer = null;
            }
        }
示例#2
0
        void DisplayAutoGenMenuWindow(bool bOpenWindow)
        {
            string strError = "";

            // 优化,避免无谓地进行服务器调用
            if (bOpenWindow == false)
            {
                if (this.MainForm.PanelFixedVisible == false
                    && (m_genDataViewer == null || m_genDataViewer.Visible == false))
                    return;
            }


            if (this.m_genDataViewer == null
                || (bOpenWindow == true && this.m_genDataViewer.Visible == false))
            {
                m_genDataViewer = new GenerateDataForm();

                m_genDataViewer.AutoRun = this.MainForm.AppInfo.GetBoolean("detailform", "gen_auto_run", false);
                // GuiUtil.SetControlFont(m_genDataViewer, this.Font, false);

                {	// 恢复列宽度
                    string strWidths = this.MainForm.AppInfo.GetString(
                                   "gen_data_dlg",
                                    "column_width",
                                   "");
                    if (String.IsNullOrEmpty(strWidths) == false)
                    {
                        DpTable.SetColumnHeaderWidth(m_genDataViewer.ActionTable,
                            strWidths,
                            true);
                    }
                }

                // m_genDataViewer.MainForm = this.MainForm;  // 必须是第一句
                m_genDataViewer.Text = "创建数据";

                m_genDataViewer.DoDockEvent -= new DoDockEventHandler(m_genDataViewer_DoDockEvent);
                m_genDataViewer.DoDockEvent += new DoDockEventHandler(m_genDataViewer_DoDockEvent);

                m_genDataViewer.SetMenu -= new RefreshMenuEventHandler(m_genDataViewer_SetMenu);
                m_genDataViewer.SetMenu += new RefreshMenuEventHandler(m_genDataViewer_SetMenu);

                m_genDataViewer.TriggerAction -= new TriggerActionEventHandler(m_genDataViewer_TriggerAction);
                m_genDataViewer.TriggerAction += new TriggerActionEventHandler(m_genDataViewer_TriggerAction);

                m_genDataViewer.MyFormClosed -= new EventHandler(m_genDataViewer_MyFormClosed);
                m_genDataViewer.MyFormClosed += new EventHandler(m_genDataViewer_MyFormClosed);

                m_genDataViewer.FormClosed -= new FormClosedEventHandler(m_genDataViewer_FormClosed);
                m_genDataViewer.FormClosed += new FormClosedEventHandler(m_genDataViewer_FormClosed);

            }


            if (bOpenWindow == true)
            {
                if (m_genDataViewer.Visible == false)
                {
                    this.MainForm.AppInfo.LinkFormState(m_genDataViewer, "autogen_viewer_state");
                    m_genDataViewer.Show(this);
                    m_genDataViewer.Activate();

                    this.MainForm.CurrentGenerateDataControl = null;
                }
                else
                {
                    if (m_genDataViewer.WindowState == FormWindowState.Minimized)
                        m_genDataViewer.WindowState = FormWindowState.Normal;
                    m_genDataViewer.Activate();
                }
            }
            else
            {
                if (m_genDataViewer.Visible == true)
                {

                }
                else
                {
                    if (this.MainForm.CurrentGenerateDataControl != m_genDataViewer.Table)
                        m_genDataViewer.DoDock(false); // 不会自动显示FixedPanel
                }
            }

            if (this.m_genDataViewer != null)
                this.m_genDataViewer.CloseWhenComplete = bOpenWindow;

            return;
        ERROR1:
            MessageBox.Show(this, "DisplayAutoGenMenu() 出错: " + strError);
        }
示例#3
0
        void m_genDataViewer_TriggerAction(object sender, TriggerActionArgs e)
        {
            string strError = "";
            if (this.m_detailHostObj != null)
            {
                if (this.IsDisposed == true)
                {
                    if (this.m_genDataViewer != null)
                    {
                        this.m_genDataViewer.Clear();
                        this.m_genDataViewer.Close();
                        this.m_genDataViewer = null;
                        return;
                    }
                }
                if (String.IsNullOrEmpty(e.EntryName) == false)
                {
                    try
                    {
                        this.m_detailHostObj.Invoke(e.EntryName,
                            e.sender,
                            e.e);
                    }
                    catch(Exception ex)
                    {
                        // 2015/8/24
                        strError = "MARC记录窗的记录 '"+this.SavePath+"' 在执行创建数据脚本的时候出现异常: " + ExceptionUtil.GetDebugText(ex)
                            + "\r\n\r\n建议检查此书目记录相关的 dp2catalog_marc_autogen.cs 配置文件,试着刷新相关书目库定义,或者与数字平台的工程师取得联系";
                        goto ERROR1;
                    }
                }

                if (this.m_genDataViewer != null)
                    this.m_genDataViewer.RefreshState();
            }
            return;
        ERROR1:
            // MessageBox.Show(this, strError);
            {
                bool bSendReport = true;
                DialogResult result = MessageDlg.Show(this,
        "dp2Catalog 发生异常:\r\n\r\n" + strError,
        "dp2Catalog 发生异常",
        MessageBoxButtons.OK,
        MessageBoxDefaultButton.Button1,
        ref bSendReport,
        new string[] { "确定" },
        "将信息发送给开发者");
                // 发送异常报告
                if (bSendReport)
                    Program.CrashReport(strError);
            }
        }
示例#4
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);
        }