Exemple #1
0
        // return:
        //		-1	error
        //		0	正常结束
        //		1	希望跳过后来的OnEnd()
        int DoExportFile(
            string[] dbpaths,
            string strOutputFileName,
            ExportFileType exportType,
            Encoding targetEncoding,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            string strDeleteStyle = "";
            if (this.checkBox_export_fastMode.Checked == true)
                strDeleteStyle = "fastmode";

            string strInfo = "";    // 汇总信息,在完成后显示

            FileStream outputfile = null;	// Backup和Xml格式输出都需要这个
            XmlTextWriter writer = null;   // Xml格式输出时需要这个

            bool bAppend = true;

            Debug.Assert(dbpaths != null, "");

            if (dbpaths.Length == 0)
            {
                strError = "尚未指定源库...";
                goto ERROR1;
            }

            if (String.IsNullOrEmpty(strOutputFileName) == false)
            {
                // 探测输出文件是否已经存在
                FileInfo fi = new FileInfo(strOutputFileName);
                bAppend = true;
                if (fi.Exists == true && fi.Length > 0)
                {
                    if (exportType == ExportFileType.BackupFile
                        || exportType == ExportFileType.ISO2709File)
                    {
                        DialogResult result = MessageBox.Show(this,
                            "文件 '" + strOutputFileName + "' 已存在,是否追加?\r\n\r\n--------------------\r\n注:(是)追加  (否)覆盖  (取消)中断处理",
                            "dp2batch",
                            MessageBoxButtons.YesNoCancel,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1);
                        if (result == DialogResult.Yes)
                        {
                            bAppend = true;
                        }
                        if (result == DialogResult.No)
                        {
                            bAppend = false;
                        }
                        if (result == DialogResult.Cancel)
                        {
                            strError = "放弃处理...";
                            goto ERROR1;
                        }
                    }
                    else if (exportType == ExportFileType.XmlFile)
                    {
                        DialogResult result = MessageBox.Show(this,
                            "文件 '" + strOutputFileName + "' 已存在,是否覆盖?\r\n\r\n--------------------\r\n注:(是)覆盖  (否)中断处理",
                            "dp2batch",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result != DialogResult.Yes)
                        {
                            strError = "放弃处理...";
                            goto ERROR1;
                        }
                    }


                }

                // 打开文件
                if (exportType == ExportFileType.BackupFile
                    || exportType == ExportFileType.ISO2709File)
                {
                    outputfile = File.Open(
                        strOutputFileName,
                        FileMode.OpenOrCreate,	// 原来是Open,后来修改为OpenOrCreate。这样对临时文件被系统管理员手动意外删除(但是xml文件中仍然记载了任务)的情况能够适应。否则会抛出FileNotFoundException异常
                        FileAccess.Write,
                        FileShare.ReadWrite);
                }
                else if (exportType == ExportFileType.XmlFile)
                {
                    outputfile = File.Create(
                        strOutputFileName);

                    writer = new XmlTextWriter(outputfile, Encoding.UTF8);
                    writer.Formatting = Formatting.Indented;
                    writer.Indentation = 4;
                }
            }

            if ((exportType == ExportFileType.BackupFile
                || exportType == ExportFileType.ISO2709File)
                && outputfile != null)
            {
                if (bAppend == true)
                    outputfile.Seek(0, SeekOrigin.End);	// 具有追加的能力
                else
                    outputfile.SetLength(0);
            }

            WriteLog("开始输出");

            try
            {

                // string[] dbpaths = textBox_dbPath.Text.Split(new char[] { ';' });

                for (int f = 0; f < dbpaths.Length; f++)
                {
                    string strOneDbPath = dbpaths[f];

                    ResPath respath = new ResPath(strOneDbPath);

                    channel = this.Channels.GetChannel(respath.Url);

                    string strDbName = respath.Path;
                    if (String.IsNullOrEmpty(strInfo) == false)
                        strInfo += "\r\n";
                    strInfo += "" + strDbName;

                    // 实际处理的首尾号
                    string strRealStartNo = "";
                    string strRealEndNo = "";

                    /*
                    DialogResult result;
                    if (checkBox_export_delete.Checked == true)
                    {
                        result = MessageBox.Show(this,
                            "确实要删除 '" + respath.Path + "' 内指定范围的记录?\r\n\r\n---------\r\n(是)删除 (否)放弃批处理",
                            "dp2batch",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result != DialogResult.Yes)
                            continue;
                    }
                     * 
                     * */


                    //channel = this.Channels.GetChannel(respath.Url);

                    //string strDbName = respath.Path;

                    // 如果为多库输出
                    if (dbpaths.Length > 0)
                    {
                        // 如果为全选
                        if (this.radioButton_all.Checked == true)
                        {
                            // 恢复为最大范围
                            this.textBox_startNo.Text = "1";
                            this.textBox_endNo.Text = "9999999999";
                        }

                        // 校验起止号
                        if (checkBox_verifyNumber.Checked == true)
                        {
                            nRet = VerifyRange(channel,
                                strDbName,
                                out strError);
                            if (nRet == -1)
                                MessageBox.Show(this, strError);

                            if (nRet == 0)
                            {
                                // 库中无记录
                                AutoCloseMessageBox.Show(this, "数据库 " + strDbName + " 中无记录。");
                                strInfo += "(无记录)";
                                WriteLog("发现数据库 " + strDbName + " 中无记录");
                                continue;
                            }
                        }
                        else
                        {
                            if (this.textBox_startNo.Text == "")
                            {
                                strError = "尚未指定起始号";
                                goto ERROR1;
                            }
                            if (this.textBox_endNo.Text == "")
                            {
                                strError = "尚未指定结束号";
                                goto ERROR1;
                            }
                        }
                    }

                    string strOutputStartNo = "";
                    string strOutputEndNo = "";
                    // 虽然界面不让校验起止号,但是也要校验,为了设置好进度条
                    if (checkBox_verifyNumber.Checked == false)
                    {
                        // 校验起止号
                        // return:
                        //      0   不存在记录
                        //      1   存在记录
                        nRet = VerifyRange(channel,
                            strDbName,
                            this.textBox_startNo.Text,
                            this.textBox_endNo.Text,
                            out strOutputStartNo,
                            out strOutputEndNo,
                            out strError);
                    }

                    //try
                    //{

                    Int64 nStart = 0;
                    Int64 nEnd = 0;
                    Int64 nCur = 0;
                    bool bAsc = true;

                    bAsc = GetDirection(
                        this.textBox_startNo.Text,
                        this.textBox_endNo.Text,
                        out nStart,
                        out nEnd);

                    // 探测到的号码
                    long nOutputEnd = 0;
                    long nOutputStart = 0;
                    if (checkBox_verifyNumber.Checked == false)
                    {
                        GetDirection(
                            strOutputStartNo,
                            strOutputEndNo,
                            out nOutputStart,
                            out nOutputEnd);
                    }

                    // 设置进度条范围
                    if (checkBox_verifyNumber.Checked == true)
                    {

                        Int64 nMax = nEnd - nStart;
                        if (nMax < 0)
                            nMax *= -1;
                        nMax++;

                        /*
                        ProgressRatio = nMax / 10000;
                        if (ProgressRatio < 1.0)
                            ProgressRatio = 1.0;

                        progressBar_main.Minimum = 0;
                        progressBar_main.Maximum = (int)(nMax / ProgressRatio);
                        progressBar_main.Value = 0;
                         * */
                        stop.SetProgressRange(0, nMax);
                    }
                    else
                    {
                        Int64 nMax = nOutputEnd - nOutputStart;
                        if (nMax < 0)
                            nMax *= -1;
                        nMax++;
                        stop.SetProgressRange(0, nMax);
                    }


                    bool bFirst = true;	// 是否为第一次取记录

                    string strID = this.textBox_startNo.Text;

                    stop.OnStop += new StopEventHandler(this.DoStop);
                    stop.Initial("正在导出数据");
                    stop.BeginLoop();

                    EnableControls(false);

                    if (exportType == ExportFileType.XmlFile
                        && writer != null)
                    {
                        writer.WriteStartDocument();
                        writer.WriteStartElement("dprms", "collection", DpNs.dprms);
                        //writer.WriteStartElement("collection");
                        //writer.WriteAttributeString("xmlns:marc",
                        //	"http://www.loc.gov/MARC21/slim");

                    }

                    WriteLog("开始输出数据库 '" + strDbName + "' 内的数据记录");

                    m_nRecordCount = 0;
                    // 循环
                    for (; ; )
                    {
                        Application.DoEvents();	// 出让界面控制权

                        if (stop.State != 0)
                        {
                            WriteLog("打开对话框 '确实要中断当前批处理操作?'");
                            DialogResult result = MessageBox.Show(this,
                                "确实要中断当前批处理操作?",
                                "dp2batch",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2);
                            WriteLog("关闭对话框 '确实要中断当前批处理操作?'");
                            if (result == DialogResult.Yes)
                            {
                                strError = "用户中断";
                                goto ERROR1;
                            }
                            else
                            {
                                stop.Continue();
                            }
                        }

                        string strDirectionComment = "";
                        string strStyle = "";
                        if (outputfile != null)
                            strStyle = "data,content,timestamp,outputpath";
                        else
                            strStyle = "timestamp,outputpath";	// 优化

                        if (bFirst == true)
                        {
                            strStyle += "";
                        }
                        else
                        {
                            if (bAsc == true)
                            {
                                strStyle += ",next";
                                strDirectionComment = "的后一条记录";
                            }
                            else
                            {
                                strStyle += ",prev";
                                strDirectionComment = "的前一条记录";
                            }
                        }


                        string strPath = strDbName + "/" + strID;
                        string strXmlBody = "";
                        string strMetaData = "";
                        byte[] baOutputTimeStamp = null;
                        string strOutputPath = "";

                        bool bFoundRecord = false;

                        bool bNeedRetry = true;

                    REDO_GETRES:
                        // 获得资源
                        // return:
                        //		-1	出错。具体出错原因在this.ErrorCode中。this.ErrorInfo中有出错信息。
                        //		0	成功
                        long lRet = channel.GetRes(strPath,
                            strStyle,
                            out strXmlBody,
                            out strMetaData,
                            out baOutputTimeStamp,
                            out strOutputPath,
                            out strError);


                        if (lRet == -1)
                        {
                            if (channel.ErrorCode == ChannelErrorCode.NotFound)
                            {
                                if (bFirst == true)
                                {
                                    if (checkBox_forceLoop.Checked == true)
                                    {
                                        string strText = "记录 " + strID + strDirectionComment + " 不存在。\r\n\r\n按 确认 继续。";
                                        WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                        AutoCloseMessageBox.Show(this, strText);
                                        WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");

                                        bFirst = false;
                                        goto CONTINUE;
                                    }
                                    else
                                    {
                                        // 如果不要强制循环,此时也不能结束,否则会让用户以为数据库里面根本没有数据
                                        string strText = "您为数据库 " + strDbName + " 指定的首记录 " + strID + strDirectionComment + " 不存在。\r\n\r\n(注:为避免出现此提示,可在操作前勾选“校准首尾ID”)\r\n\r\n按 确认 继续向后找...";
                                        WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                        AutoCloseMessageBox.Show(this, strText);
                                        WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");

                                        bFirst = false;
                                        goto CONTINUE;
                                    }
                                }
                                else
                                {
                                    Debug.Assert(bFirst == false, "");

                                    if (bFirst == true)
                                    {
                                        strError = "记录 " + strID + strDirectionComment + " 不存在。处理结束。";
                                    }
                                    else
                                    {
                                        if (bAsc == true)
                                            strError = "记录 " + strID + " 是最末一条记录。处理结束。";
                                        else
                                            strError = "记录 " + strID + " 是最前一条记录。处理结束。";
                                    }

                                    if (dbpaths.Length > 1)
                                        break;  // 多库情况,继续其它库循环
                                    else
                                    {
                                        bNeedRetry = false; // 单库情况,也没有必要出现重试对话框

                                        WriteLog("打开对话框 '" + strError.Replace("\r\n", "\\n") + "'");
                                        MessageBox.Show(this, strError);
                                        WriteLog("关闭对话框 '" + strError.Replace("\r\n", "\\n") + "'");
                                        break;
                                    }
                                }

                            }
                            else if (channel.ErrorCode == ChannelErrorCode.EmptyRecord)
                            {
                                bFirst = false;
                                bFoundRecord = false;
                                // 把id解析出来
                                strID = ResPath.GetRecordId(strOutputPath);
                                goto CONTINUE;

                            }

                            // 允许重试
                            if (bNeedRetry == true)
                            {
                                string strText = "获取记录 '" + strPath + "' (style='" + strStyle + "')时出现错误: " + strError + "\r\n\r\n重试,还是中断当前批处理操作?\r\n(Retry 重试;Cancel 中断批处理)";
                                WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                DialogResult redo_result = MessageBox.Show(this,
                                    strText,
                                    "dp2batch",
                                    MessageBoxButtons.RetryCancel,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1);
                                WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                if (redo_result == DialogResult.Cancel)
                                    goto ERROR1;
                                goto
                                    REDO_GETRES;
                            }
                            else
                            {
                                goto ERROR1;
                            }
                        }

                        // 2008/11/9 
                        if (String.IsNullOrEmpty(strXmlBody) == true)
                        {
                            bFirst = false;
                            bFoundRecord = false;
                            // 把id解析出来
                            strID = ResPath.GetRecordId(strOutputPath);
                            goto CONTINUE;
                        }

                        bFirst = false;

                        bFoundRecord = true;

                        // 把id解析出来
                        strID = ResPath.GetRecordId(strOutputPath);
                        stop.SetMessage("已导出记录 " + strOutputPath + "  " + m_nRecordCount.ToString());

                        if (String.IsNullOrEmpty(strRealStartNo) == true)
                        {
                            strRealStartNo = strID;
                        }

                        strRealEndNo = strID;

                    CONTINUE:

                        // 是否超过循环范围
                        try
                        {
                            nCur = Convert.ToInt64(strID);
                        }
                        catch
                        {
                            // ???
                            nCur = 0;
                        }

                        if (checkBox_verifyNumber.Checked == false)
                        {
                            // 如果当前记录号码突破预计的头部和尾部
                            if (nCur > nOutputEnd
                                || nCur < nOutputStart)
                            {
                                if (nCur > nOutputEnd)
                                    nOutputEnd = nCur;

                                if (nCur < nOutputStart)
                                    nOutputStart = nCur;

                                // 重新计算和设置进度条
                                long nMax = nOutputEnd - nOutputStart;
                                if (nMax < 0)
                                    nMax *= -1;
                                nMax++;

                                stop.SetProgressRange(0, nMax);
                            }
                        }

                        if (bAsc == true && nCur > nEnd)
                            break;
                        if (bAsc == false && nCur < nEnd)
                            break;

                        string strMarc = "";

                        // 将Xml转换为MARC
                        if (exportType == ExportFileType.ISO2709File
                            && bFoundRecord == true)    // 2008/11/13 
                        {
                            nRet = GetMarc(strXmlBody,
                                out strMarc,
                                out strError);
                            if (nRet == -1)
                            {
                                strError = "记录 " + strOutputPath + " 在将XML格式转换为MARC时出错: " + strError;
                                goto ERROR1;
                            }
                        }

                        if (this.MarcFilter != null)
                        {
                            // 触发filter中的Record相关动作
                            // TODO: 有可能strMarc为空哟,需要测试一下
                            nRet = MarcFilter.DoRecord(
                                null,
                                strMarc,
                                m_nRecordCount,
                                out strError);
                            if (nRet == -1)
                                goto ERROR1;
                        }

                        // 触发Script的Outputing()代码
                        if (bFoundRecord == true && this.AssemblyMain != null)
                        {
                            // 这些变量要先初始化,因为filter代码可能用到这些Batch成员.
                            batchObj.XmlRecord = strXmlBody;

                            batchObj.MarcSyntax = this.CurMarcSyntax;

                            batchObj.MarcRecord = strMarc;	// MARC记录体
                            batchObj.MarcRecordChanged = false;	// 为本轮Script运行准备初始状态

                            batchObj.SearchPanel.ServerUrl = channel.Url;
                            batchObj.ServerUrl = channel.Url;
                            batchObj.RecPath = strOutputPath;	// 记录路径
                            batchObj.RecIndex = m_nRecordCount;	// 当前记录在一批中的序号
                            batchObj.TimeStamp = baOutputTimeStamp;


                            BatchEventArgs args = new BatchEventArgs();

                            batchObj.Outputing(this, args);
                            /*
                            if (args.Continue == ContinueType.SkipMiddle)
                                goto CONTINUEDBS;
                            if (args.Continue == ContinueType.SkipBeginMiddle)
                                goto CONTINUEDBS;
                            */
                            if (args.Continue == ContinueType.SkipAll)
                                goto CONTINUEDBS;

                            // 观察用于输出的MARC记录是否被改变
                            if (batchObj.MarcRecordChanged == true)
                                strMarc = batchObj.MarcRecord;

                            // 观察XML记录是否被改变
                            if (batchObj.XmlRecordChanged == true)
                                strXmlBody = batchObj.XmlRecord;

                        }


                        if (bFoundRecord == true
                            && outputfile != null)
                        {
                            if (exportType == ExportFileType.BackupFile)
                            {
                                // 写磁盘
                                nRet = WriteRecordToBackupFile(
                                    outputfile,
                                    strDbName,
                                    strID,
                                    strMetaData,
                                    strXmlBody,
                                    baOutputTimeStamp,
                                    out strError);
                                if (nRet == -1)
                                {
                                    // 询问是否继续
                                    goto ERROR1;
                                }
                            }
                            else if (exportType == ExportFileType.ISO2709File)
                            {
                                // 写磁盘
                                nRet = WriteRecordToISO2709File(
                                    outputfile,
                                    strDbName,
                                    strID,
                                    strMarc,
                                    baOutputTimeStamp,
                                    targetEncoding,
                                    this.OutputCrLf,
                                    this.AddG01,
                                    this.Remove998,
                                    out strError);
                                if (nRet == -1)
                                {
                                    // 询问是否继续
                                    goto ERROR1;
                                }
                            }
                            else if (exportType == ExportFileType.XmlFile)
                            {
                                XmlDocument dom = new XmlDocument();

                                try
                                {
                                    dom.LoadXml(strXmlBody);

                                    ResPath respathtemp = new ResPath();
                                    respathtemp.Url = channel.Url;
                                    respathtemp.Path = strOutputPath;


                                    // DomUtil.SetAttr(dom.DocumentElement, "xmlns:dprms", DpNs.dprms);
                                    // 给根元素设置几个参数
                                    DomUtil.SetAttr(dom.DocumentElement, "path", DpNs.dprms, respathtemp.FullPath);
                                    DomUtil.SetAttr(dom.DocumentElement, "timestamp", DpNs.dprms, ByteArray.GetHexTimeStampString(baOutputTimeStamp));

                                    // DomUtil.SetAttr(dom.DocumentElement, "xmlns:marc", null);
                                    dom.DocumentElement.WriteTo(writer);
                                }
                                catch (Exception ex)
                                {
                                    strError = ExceptionUtil.GetAutoText(ex);
                                    // 询问是否继续
                                    goto ERROR1;
                                }

                            }
                        }

                        // 删除
                        if (checkBox_export_delete.Checked == true)
                        {

                            byte[] baOutputTimeStamp1 = null;
                            strPath = strOutputPath;	// 得到实际的路径
                            lRet = channel.DoDeleteRes(
                                strPath,
                                baOutputTimeStamp,
                                strDeleteStyle,
                                out baOutputTimeStamp1,
                                out strError);
                            if (lRet == -1)
                            {
                                // 询问是否继续
                                goto ERROR1;
                            }
                            stop.SetMessage("已删除记录" + strPath + "  " + m_nRecordCount.ToString());
                        }

                        if (bFoundRecord == true)
                            m_nRecordCount++;


                        if (bAsc == true)
                        {
                            //progressBar_main.Value = (int)((nCur - nStart + 1) / ProgressRatio);
                            stop.SetProgressValue(nCur - nStart + 1);
                        }
                        else
                        {
                            // ?
                            // progressBar_main.Value = (int)((nStart - nCur + 1) / ProgressRatio);
                            stop.SetProgressValue(nStart - nCur + 1);
                        }


                        // 对已经作过的进行判断
                        if (bAsc == true && nCur >= nEnd)
                            break;
                        if (bAsc == false && nCur <= nEnd)
                            break;


                    } // end of for one database

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

                    EnableControls(true);

                //}

            CONTINUEDBS:
                    strInfo += " : " + m_nRecordCount.ToString() + "条 (ID " + strRealStartNo + "-" + strRealEndNo + ")";

                }   // end of dbpaths loop


            }   // end of try
            finally
            {
                if (writer != null)
                {
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                    writer.Close();
                    writer = null;
                }

                if (outputfile != null)
                {
                    outputfile.Close();
                    outputfile = null;
                }
            }

            // END1:
            channel = null;

            if (checkBox_export_delete.Checked == true)
                strError = "数据导出和删除完成。\r\n---\r\n" + strInfo;
            else
                strError = "数据导出完成。\r\n---\r\n" + strInfo;

            WriteLog("结束输出");

            return 0;
        ERROR1:
            stop.EndLoop();
            stop.OnStop -= new StopEventHandler(this.DoStop);
            stop.Initial("");

            EnableControls(true);
            channel = null;
            return -1;
        }
Exemple #2
0
        // 上载一个item
        // parameter:
        //		strError: error info
        // return:
        //		-1	出错
        //		0	正常
        //		1	结束
        public int DoXmlItemUpload(
            bool bFastMode,
            string strXml,
            DbNameMap map,
            bool bSkip,
            string strCount,
            out string strError)
        {
            strError = "";
            int nRet = 0;
            // bool bRet = false;

            // MessageBox.Show(this, strXml);

            if (bSkip == true)
                return 0;

            XmlDocument dataDom = new XmlDocument();
            try
            {
                dataDom.LoadXml(strXml);
            }
            catch (Exception ex)
            {
                strError = "加载数据到dom出错!\r\n" + ex.Message;
                goto ERROR1;
            }

            XmlNode node = dataDom.DocumentElement;

            string strResPath = DomUtil.GetAttr(DpNs.dprms, node, "path");

            string strTargetPath = "";

            string strSourceDbPath = "";

            if (strResPath != "")
            {
                // 从map中查询覆盖还是追加?
                ResPath respath0 = new ResPath(strResPath);
                respath0.MakeDbName();
                strSourceDbPath = respath0.FullPath;
            }

        REDO:

            DbNameMapItem mapItem = null;


            mapItem = map.MatchItem(strSourceDbPath/*strResPath*/);
            if (mapItem != null)
                goto MAPITEMOK;

            if (mapItem == null)
            {

                if (strSourceDbPath/*strResPath*/ == "")
                {
                    string strText = "源数据文件中记录 " + Convert.ToString(this.m_nRecordCount) + " 没有来源数据库,对所有这样的数据,将作如何处理?";
                    WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    nRet = DbNameMapItemDlg.AskNullOriginBox(
                        this,
                        this.AppInfo,
                        strText,
                        this.SearchPanel,
                        map);
                    WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");

                    if (nRet == 0)
                    {
                        strError = "用户中断";
                        goto ERROR1;	// 中断整个处理
                    }

                    goto REDO;

                }
                else
                {
                    string strText = "源数据文件中记录 " + Convert.ToString(this.m_nRecordCount) + " 的来源数据库 '" + strSourceDbPath/*strResPath*/ + "' 没有找到对应的目标库, 对所有这样的数据,将作如何处理?";
                    WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    nRet = DbNameMapItemDlg.AskNotMatchOriginBox(
                        this,
                        this.AppInfo,
                        strText,
                        this.SearchPanel,
                        strSourceDbPath/*strResPath*/,
                        map);
                    WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    if (nRet == 0)
                    {
                        strError = "用户中断";
                        goto ERROR1;	// 中断整个处理
                    }

                    goto REDO;
                }
            }

        MAPITEMOK:

            if (mapItem.Style == "skip")
                return 0;

            // 构造目标路径

            // 1)从源路径中提取id。源路径来自备份文件数据
            ResPath respath = new ResPath(strResPath);
            string strID = respath.GetRecordId();

            if (strID == null || strID == ""
                || (mapItem.Style == "append")
                )
            {
                strID = "?";	// 将来加一个对话框
            }

            // 2)用目标库路径构造完整的记录路径
            string strTargetFullPath = "";
            if (mapItem.Target == "*")
            {
                // 此时target为*, 需要从strResPath中获得库名

                if (strResPath == "")
                {
                    Debug.Assert(false, "不可能出现的情况");
                }

                respath = new ResPath(strResPath);
                respath.MakeDbName();
                strTargetFullPath = respath.FullPath;
            }
            else
            {
                strTargetFullPath = mapItem.Target;
            }

            respath = new ResPath(strTargetFullPath);


            // 需要检查目标库所允许的MARC格式
            if (CheckTargetDb != null)
            {
                CheckTargetDbEventArgs e = new CheckTargetDbEventArgs();
                e.DbFullPath = strTargetFullPath;
                e.CurrentMarcSyntax = this.CurMarcSyntax;
                this.CheckTargetDb(this, e);
                if (e.Cancel == true)
                {
                    if (e.ErrorInfo == "")
                        strError = "CheckTargetDb 事件导致中断";
                    else
                        strError = e.ErrorInfo;
                    return -1;
                }

            }


            strTargetPath = respath.Path + "/" + strID;
            // strRecordPath = strTargetPath;

            channel = this.Channels.GetChannel(respath.Url);

            string strTimeStamp = DomUtil.GetAttr(DpNs.dprms, node, "timestamp");

            byte[] timestamp = ByteArray.GetTimeStampByteArray(strTimeStamp);

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

            // 2012/5/30
            if (batchObj != null)
            {
                batchObj.MarcSyntax = strOutMarcSyntax;
                batchObj.MarcRecord = strMARC;
                batchObj.MarcRecordChanged = false;	// 为本轮Script运行准备初始状态
            }


            if (this.MarcFilter != null)
            {
                // 触发filter中的Record相关动作
                nRet = MarcFilter.DoRecord(
                    null,
                    batchObj.MarcRecord,
                    m_nRecordCount,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
            }

            // C#脚本 -- Inputing
            if (this.AssemblyMain != null)
            {
                // 这些变量要先初始化,因为filter代码可能用到这些Batch成员.
                batchObj.SkipInput = false;
                batchObj.XmlRecord = strXml;

                //batchObj.MarcSyntax = this.CurMarcSyntax;
                //batchObj.MarcRecord = strMarc;	// MARC记录体
                //batchObj.MarcRecordChanged = false;	// 为本轮Script运行准备初始状态


                batchObj.SearchPanel.ServerUrl = channel.Url;
                batchObj.ServerUrl = channel.Url;
                batchObj.RecPath = strTargetPath;	// 记录路径
                batchObj.RecIndex = m_nRecordCount;	// 当前记录在一批中的序号
                batchObj.TimeStamp = timestamp;


                BatchEventArgs args = new BatchEventArgs();

                batchObj.Inputing(this, args);
                if (args.Continue == ContinueType.SkipAll)
                {
                    strError = "脚本中断SkipAll";
                    goto END2;
                }

                if (batchObj.SkipInput == true)
                    return 0;	// 继续处理后面的
            }


            string strWarning = "";
            byte[] output_timestamp = null;
            string strOutputPath = "";

        REDOSAVE:
            if (stop != null)
            {
                if (strTargetPath.IndexOf("?") == -1)
                {
                    stop.SetMessage("正在上载 "
                        + strTargetPath + strWarning + " " + strCount);
                }
            }


            // 保存Xml记录
            long lRet = channel.DoSaveTextRes(strTargetPath,
                strXml,
                false,	// bIncludePreamble
                    bFastMode == true ? "fastmode" : "",//strStyle,
                timestamp,
                out output_timestamp,
                out strOutputPath,
                out strError);

            if (lRet == -1)
            {
                if (stop != null)
                    stop.Continue();

                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    string strDisplayRecPath = strOutputPath;
                    if (string.IsNullOrEmpty(strDisplayRecPath) == true)
                        strDisplayRecPath = strTargetPath;

                    if (this.bNotAskTimestampMismatchWhenOverwrite == true)
                    {
                        timestamp = new byte[output_timestamp.Length];
                        Array.Copy(output_timestamp, 0, timestamp, 0, output_timestamp.Length);
                        strWarning = " (时间戳不匹配, 自动重试)";
                        goto REDOSAVE;
                    }

                    string strText = "上载 '" + strDisplayRecPath
                        + " 时发现时间戳不匹配。详细情况如下:\r\n---\r\n"
                        + strError + "\r\n---\r\n\r\n是否以新时间戳强行上载?\r\n注:(是)强行上载 (否)忽略当前记录或资源上载,但继续后面的处理 (取消)中断整个批处理";
                    WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    DialogResult result = MessageDlg.Show(this,
                        strText,
                        "dp2batch",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxDefaultButton.Button1,
                        ref this.bNotAskTimestampMismatchWhenOverwrite);
                    WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    if (result == DialogResult.Yes)
                    {
                        timestamp = new byte[output_timestamp.Length];
                        Array.Copy(output_timestamp, 0, timestamp, 0, output_timestamp.Length);
                        strWarning = " (时间戳不匹配, 应用户要求重试)";
                        goto REDOSAVE;
                    }

                    if (result == DialogResult.No)
                    {
                        return 0;	// 继续作后面的资源
                    }

                    if (result == DialogResult.Cancel)
                    {
                        strError = "用户中断";
                        goto ERROR1;	// 中断整个处理
                    }
                }

                // 询问是否重试
                {
                    string strText = "上载 '" + strTargetPath
                        + " 时发生错误。详细情况如下:\r\n---\r\n"
                        + strError + "\r\n---\r\n\r\n是否重试?\r\n注:(是)重试 (否)不重试,但继续后面的处理 (取消)中断整个批处理";
                    WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");

                    DialogResult result1 = MessageBox.Show(this,
                        strText,
                        "dp2batch",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1);
                    WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    if (result1 == DialogResult.Yes)
                        goto REDOSAVE;
                    if (result1 == DialogResult.No)
                        return 0;	// 继续作后面的资源
                }

                goto ERROR1;
            }

            // C#脚本 -- Inputed()
            if (this.AssemblyMain != null)
            {
                // 大部分变量保留刚才Inputing()时的原样,只修改部分

                batchObj.RecPath = strOutputPath;	// 记录路径
                batchObj.TimeStamp = output_timestamp;

                BatchEventArgs args = new BatchEventArgs();

                batchObj.Inputed(this, args);
                /*
                if (args.Continue == ContinueType.SkipMiddle)
                {
                    strError = "脚本中断SkipMiddle";
                    goto END1;
                }
                if (args.Continue == ContinueType.SkipBeginMiddle)
                {
                    strError = "脚本中断SkipBeginMiddle";
                    goto END1;
                }
                */
                if (args.Continue == ContinueType.SkipAll)
                {
                    strError = "脚本中断SkipAll";
                    goto END1;
                }
            }

            this.m_nRecordCount++;

            if (stop != null)
            {
                stop.SetMessage("已上载成功 '"
                    + strOutputPath + "' " + strCount);
            }


            // strRecordPath = strOutputPath;

            return 0;
        END1:
        END2:

        ERROR1:
            return -1;
        }
Exemple #3
0
        // 输出
        void DoExport(string strProjectName,
            string strProjectLocate)
        {
            string strError = "";
            int nRet = 0;

            Assembly assemblyMain = null;
            MyFilterDocument filter = null;
            batchObj = null;
            m_nRecordCount = -1;


            // 准备脚本
            if (strProjectName != "" && strProjectName != null)
            {
                nRet = PrepareScript(strProjectName,
                    strProjectLocate,
                    out assemblyMain,
                    out filter,
                    out batchObj,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.AssemblyMain = assemblyMain;
                if (filter != null)
                    this.AssemblyFilter = filter.Assembly;
                else
                    this.AssemblyFilter = null;

            }


            // 执行脚本的OnInitial()

            // 触发Script中OnInitial()代码
            // OnInitial()和OnBegin的本质区别, 在于OnInitial()适合检查和设置面板参数
            if (batchObj != null)
            {
                BatchEventArgs args = new BatchEventArgs();
                batchObj.OnInitial(this, args);
                /*
                if (args.Continue == ContinueType.SkipBeginMiddle)
                    goto END1;
                if (args.Continue == ContinueType.SkipMiddle) 
                {
                    strError = "OnInitial()中args.Continue不能使用ContinueType.SkipMiddle.应使用ContinueType.SkipBeginMiddle";
                    goto ERROR1;
                }
                */
                if (args.Continue == ContinueType.SkipAll)
                    goto END1;
            }

            string strOutputFileName = "";

            if (textBox_dbPath.Text == "")
            {
                MessageBox.Show(this, "尚未选择源库...");
                return;
            }

            string[] dbpaths = this.textBox_dbPath.Text.Split(new char[] { ';' });

            Debug.Assert(dbpaths.Length != 0, "");

            // 如果为单库输出
            if (dbpaths.Length == 1)
            {
                // 否则移到DoExportFile()函数里面去校验
                ResPath respath = new ResPath(dbpaths[0]);

                channel = this.Channels.GetChannel(respath.Url);

                string strDbName = respath.Path;

                // 校验起止号
                if (checkBox_verifyNumber.Checked == true)
                {
                    nRet = VerifyRange(channel,
                        strDbName,
                        out strError);
                    if (nRet == -1)
                        MessageBox.Show(this, strError);
                }
                else
                {
                    if (this.textBox_startNo.Text == "")
                    {
                        strError = "尚未指定起始号";
                        goto ERROR1;
                    }
                    if (this.textBox_endNo.Text == "")
                    {
                        strError = "尚未指定结束号";
                        goto ERROR1;
                    }
                }
            }
            else
            {
                // 多库输出。修改界面要素,表示针对每个库都是全库处理
                this.radioButton_all.Checked = true;
                this.textBox_startNo.Text = "1";
                this.textBox_endNo.Text = "9999999999";
            }


            SaveFileDialog dlg = null;

            if (checkBox_export_delete.Checked == true)
            {
                DialogResult result = MessageBox.Show(this,
                        "确实要(在输出的同时)删除数据库记录?\r\n\r\n---------\r\n(确定)删除 (放弃)放弃批处理",
                        "dp2batch",
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                if (result != DialogResult.OK)
                {
                    strError = "放弃处理...";
                    goto ERROR1;
                }

                result = MessageBox.Show(this,
                    "在删除记录的同时, 是否将记录输出到文件?\r\n\r\n--------\r\n(是)一边删除一边输出 (否)只删除不输出",
                    "dp2batch",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button1);
                if (result != DialogResult.Yes)
                    goto SKIPASKFILENAME;
            }


            // 获得输出文件名
            dlg = new SaveFileDialog();

            dlg.Title = "请指定要保存的备份文件名";
            dlg.CreatePrompt = false;
            dlg.OverwritePrompt = false;
            dlg.FileName = strLastOutputFileName;
            dlg.FilterIndex = nLastOutputFilterIndex;

            dlg.Filter = "备份文件 (*.dp2bak)|*.dp2bak|XML文件 (*.xml)|*.xml|ISO2709文件 (*.iso;*.mrc)|*.iso;*.mrc|All files (*.*)|*.*";

            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog(this) != DialogResult.OK)
            {
                strError = "放弃处理...";
                goto ERROR1;
            }

            strLastOutputFileName = dlg.FileName;
            nLastOutputFilterIndex = dlg.FilterIndex;
            strOutputFileName = dlg.FileName;

        SKIPASKFILENAME:

            // 触发Script中OnBegin()代码
            // OnBegin()中仍然有修改MainForm面板的自由
            if (batchObj != null)
            {
                BatchEventArgs args = new BatchEventArgs();
                batchObj.OnBegin(this, args);
                /*
                if (args.Continue == ContinueType.SkipMiddle)
                    goto END1;
                if (args.Continue == ContinueType.SkipBeginMiddle)
                    goto END1;
                */
                if (args.Continue == ContinueType.SkipAll)
                    goto END1;
            }



            if (dlg == null || dlg.FilterIndex == 1)
                nRet = DoExportFile(
                    dbpaths,
                    strOutputFileName,
                    ExportFileType.BackupFile,
                    null,
                    out strError);
            else if (dlg.FilterIndex == 2)
                nRet = DoExportFile(
                    dbpaths,
                    strOutputFileName,
                    ExportFileType.XmlFile,
                    null,
                    out strError);
            else if (dlg.FilterIndex == 3)
            {
                ResPath respath = new ResPath(dbpaths[0]);

                string strMarcSyntax = "";
                // 从marcdef配置文件中获得marc格式定义
                // return:
                //		-1	出错
                //		0	没有找到
                //		1	找到
                nRet = this.SearchPanel.GetMarcSyntax(respath.FullPath,
                    out strMarcSyntax,
                    out strError);
                if (nRet == 0 || nRet == -1)
                {
                    strError = "获取数据库 '" + dbpaths[0] + "' 的MARC格式时发生错误: " + strError;
                    goto ERROR1;
                }

                // 如果多于一个数据库输出到一个文件,需要关心每个数据库的MARC格式是否相同,给与适当的警告
                if (dbpaths.Length > 1)
                {
                    string strWarning = "";
                    for (int i = 1; i < dbpaths.Length; i++)
                    {
                        ResPath current_respath = new ResPath(dbpaths[i]);

                        string strPerMarcSyntax = "";
                        // 从marcdef配置文件中获得marc格式定义
                        // return:
                        //		-1	出错
                        //		0	没有找到
                        //		1	找到
                        nRet = this.SearchPanel.GetMarcSyntax(current_respath.FullPath,
                            out strPerMarcSyntax,
                            out strError);
                        if (nRet == 0 || nRet == -1)
                        {
                            strError = "获取数据库 '" + dbpaths[i] + "' 的MARC格式时发生错误: " + strError;
                            goto ERROR1;
                        }

                        if (strPerMarcSyntax != strMarcSyntax)
                        {
                            if (String.IsNullOrEmpty(strWarning) == false)
                                strWarning += "\r\n";
                            strWarning += "数据库 '" + dbpaths[i] + "' (" + strPerMarcSyntax + ")";

                        }
                    }

                    if (String.IsNullOrEmpty(strWarning) == false)
                    {
                        strWarning = "所选择的数据库中,下列数据库的MARC格式和第一个数据库( '" + dbpaths[0] + "' (" + strMarcSyntax + "))的不同: \r\n---\r\n" + strWarning + "\r\n---\r\n\r\n如果把这些不同MARC格式的记录混合输出到一个文件中,可能会造成许多软件以后读取它时发生困难。\r\n\r\n确实要这样混合着转出到一个文件中?";
                        DialogResult result = MessageBox.Show(this,
                            strWarning,
                            "dp2batch",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result == DialogResult.No)
                        {
                            strError = "放弃处理...";
                            goto ERROR1;
                        }
                    }
                }

                OpenMarcFileDlg marcdlg = new OpenMarcFileDlg();
                MainForm.SetControlFont(marcdlg, this.DefaultFont);
                marcdlg.IsOutput = true;
                marcdlg.Text = "请指定要输出的 ISO2709 文件属性";
                marcdlg.FileName = strOutputFileName;
                marcdlg.MarcSyntax = strMarcSyntax;
                marcdlg.EnableMarcSyntax = false;   // 不允许用户选择marc syntax,因为这是数据库配置好了的属性 2007/8/18

                marcdlg.CrLf = this.OutputCrLf;
                marcdlg.AddG01 = this.AddG01;
                marcdlg.RemoveField998 = this.Remove998;


                this.AppInfo.LinkFormState(marcdlg, "OpenMarcFileDlg_output_state");
                marcdlg.ShowDialog(this);
                this.AppInfo.UnlinkFormState(marcdlg);


                if (marcdlg.DialogResult != DialogResult.OK)
                {
                    strError = "放弃处理...";
                    goto ERROR1;
                }

                if (marcdlg.AddG01 == true)
                {
                    MessageBox.Show(this, "您选择了在导出的ISO2709记录中加入-01字段。请注意dp2Batch在将来导入这样的ISO2709文件的时候,记录中-01字段***起不到***覆盖定位的作用。“加入-01字段”功能是为了将导出的ISO2709文件应用到dt1000系统而设计的。\r\n\r\n如果您这样做的目的是为了对dp2系统书目库中的数据进行备份,请改用.xml格式或.dp2bak格式。");
                }


                strOutputFileName = marcdlg.FileName;
                this.CurMarcSyntax = strMarcSyntax;
                this.OutputCrLf = marcdlg.CrLf;
                this.AddG01 = marcdlg.AddG01;
                this.Remove998 = marcdlg.RemoveField998;

                nRet = DoExportFile(
                    dbpaths,
                    marcdlg.FileName,
                    ExportFileType.ISO2709File,
                    marcdlg.Encoding,
                    out strError);
            }
            else
            {
                strError = "不支持的文件类型...";
                goto ERROR1;
            }

            /*
            if (nRet == 1)
                goto END2;
            */
            if (nRet == -1)
                goto ERROR1;
        END1:
            // 触发Script的OnEnd()代码
            if (batchObj != null)
            {
                BatchEventArgs args = new BatchEventArgs();
                batchObj.OnEnd(this, args);
            }

            // END2:

            this.AssemblyMain = null;
            this.AssemblyFilter = null;
            if (filter != null)
                filter.Assembly = null;
            this.MarcFilter = null;

            if (String.IsNullOrEmpty(strError) == false)
                MessageBox.Show(this, strError);
            return;

        ERROR1:
            this.AssemblyMain = null;
            this.AssemblyFilter = null;
            if (filter != null)
                filter.Assembly = null;
            this.MarcFilter = null;


            MessageBox.Show(this, strError);

        }
Exemple #4
0
 public virtual void OnPrint(object sender, BatchEventArgs e)
 {
 }
Exemple #5
0
        void DoImport(string strProjectName,
            string strProjectLocate)
        {
            string strError = "";
            int nRet = 0;

            Assembly assemblyMain = null;
            MyFilterDocument filter = null;
            this.MarcFilter = null;
            batchObj = null;
            m_nRecordCount = -1;

            // 准备脚本
            if (strProjectName != "" && strProjectName != null)
            {
                nRet = PrepareScript(strProjectName,
                    strProjectLocate,
                    out assemblyMain,
                    out filter,
                    out batchObj,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.AssemblyMain = assemblyMain;
                if (filter != null)
                    this.AssemblyFilter = filter.Assembly;
                else
                    this.AssemblyFilter = null;

                this.MarcFilter = filter;
            }

            // 执行脚本的OnInitial()

            // 触发Script中OnInitial()代码
            // OnInitial()和OnBegin的本质区别, 在于OnInitial()适合检查和设置面板参数
            if (batchObj != null)
            {
                BatchEventArgs args = new BatchEventArgs();
                batchObj.OnInitial(this, args);
                /*
                if (args.Continue == ContinueType.SkipBeginMiddle)
                    goto END1;
                if (args.Continue == ContinueType.SkipMiddle) 
                {
                    strError = "OnInitial()中args.Continue不能使用ContinueType.SkipMiddle.应使用ContinueType.SkipBeginMiddle";
                    goto ERROR1;
                }
                */
                if (args.Continue == ContinueType.SkipAll)
                    goto END1;
            }


            if (this.textBox_import_fileName.Text == "")
            {
                strError = "尚未指定输入文件名...";
                goto ERROR1;
            }
            FileInfo fi = new FileInfo(this.textBox_import_fileName.Text);
            if (fi.Exists == false)
            {
                strError = "文件" + this.textBox_import_fileName.Text + "不存在...";
                goto ERROR1;
            }

            OpenMarcFileDlg dlg = null;

            // ISO2709文件需要预先准备条件
            if (String.Compare(fi.Extension, ".iso", true) == 0
                || String.Compare(fi.Extension, ".mrc", true) == 0)
            {
                // 询问encoding和marcsyntax
                dlg = new OpenMarcFileDlg();
                MainForm.SetControlFont(dlg, this.DefaultFont);

                dlg.Text = "请指定要导入的 ISO2709 文件属性";
                dlg.FileName = this.textBox_import_fileName.Text;

                this.AppInfo.LinkFormState(dlg, "OpenMarcFileDlg_input_state");
                dlg.ShowDialog(this);
                this.AppInfo.UnlinkFormState(dlg);

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

                this.textBox_import_fileName.Text = dlg.FileName;
                this.CurMarcSyntax = dlg.MarcSyntax;
            }

            // 触发Script中OnBegin()代码
            // OnBegin()中仍然有修改MainForm面板的自由
            if (batchObj != null)
            {
                BatchEventArgs args = new BatchEventArgs();
                batchObj.OnBegin(this, args);
                /*
                if (args.Continue == ContinueType.SkipMiddle)
                    goto END1;
                if (args.Continue == ContinueType.SkipBeginMiddle)
                    goto END1;
                */
                if (args.Continue == ContinueType.SkipAll)
                    goto END1;
            }

            if (String.Compare(fi.Extension, ".dp2bak", true) == 0)
                nRet = this.DoImportBackup(this.textBox_import_fileName.Text,
                    out strError);

            else if (String.Compare(fi.Extension, ".xml", true) == 0)
                nRet = this.DoImportXml(this.textBox_import_fileName.Text,
                    out strError);

            else if (String.Compare(fi.Extension, ".iso", true) == 0
                || String.Compare(fi.Extension, ".mrc", true) == 0)
            {
                this.m_tableMarcSyntax.Clear(); // 2015/5/29
                this.CheckTargetDb += new CheckTargetDbEventHandler(CheckTargetDbCallBack);

                try
                {
                    nRet = this.DoImportIso2709(dlg.FileName,
                        dlg.MarcSyntax,
                        dlg.Encoding,
                        out strError);
                }
                finally
                {
                    this.CheckTargetDb -= new CheckTargetDbEventHandler(CheckTargetDbCallBack);
                }

            }
            else
            {
                strError = "未知的文件类型...";
                goto ERROR1;
            }


        END1:
            // 触发Script的OnEnd()代码
            if (batchObj != null)
            {
                BatchEventArgs args = new BatchEventArgs();
                batchObj.OnEnd(this, args);
            }

            // END2:

            this.AssemblyMain = null;
            this.AssemblyFilter = null;
            if (filter != null)
                filter.Assembly = null;


            if (strError != "")
                MessageBox.Show(this, strError);

            this.MarcFilter = null;
            return;

        ERROR1:
            this.AssemblyMain = null;
            this.AssemblyFilter = null;
            if (filter != null)
                filter.Assembly = null;

            this.MarcFilter = null;

            MessageBox.Show(this, strError);
        }
Exemple #6
0
 public virtual void Inputed(object sender, BatchEventArgs e)
 {
 }
Exemple #7
0
 public virtual void OnEnd(object sender, BatchEventArgs e)
 {
 }
Exemple #8
0
 public virtual void OnBegin(object sender, BatchEventArgs e)
 {
 }
Exemple #9
0
 public virtual void Outputing(object sender, BatchEventArgs e)
 {
 }
Exemple #10
0
		public virtual void OnPrint(object sender, BatchEventArgs e)
		{

		}
Exemple #11
0
 public virtual void OnInitial(object sender, BatchEventArgs e)
 {
 }
Exemple #12
0
		public virtual void OnEnd(object sender, BatchEventArgs e)
		{

		}
Exemple #13
0
		public virtual void Inputed(object sender, BatchEventArgs e)
		{

		}
Exemple #14
0
		public virtual void Outputing(object sender, BatchEventArgs e)
		{

		}
Exemple #15
0
		public virtual void OnBegin(object sender, BatchEventArgs e)
		{

		}
Exemple #16
0
		public virtual void OnInitial(object sender, BatchEventArgs e)
		{

		}