Exemple #1
0
        // 根据读者证条码号,装入读者记录
        // parameters:
        //      edit    读者编辑控件。可以==null
        //      webbHtml    用于显示HTML的WebBrowser控件。可以==null
        //      webbXml   用于显示XML的WebBrowser控件。可以==null
        // return:
        //      0   cancelled
        internal int LoadRecord(ref string strBarcode,
            ReaderEditControl edit,
            WebExternalHost external_html,
            // WebBrowser webbHtml,
            WebBrowser webbXml)
        {
            string strError = "";
            int nRet = 0;

            if (edit != null
                && edit.Changed == true)
            {
                // 警告尚未保存
                DialogResult result = MessageBox.Show(this,
"当前有信息被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要根据证条码号重新装载内容? ",
"ActivateForm",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
                if (result != DialogResult.Yes)
                    return 0;   // cancelled

            }

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();

            this.Update();
            this.MainForm.Update();

            EnableControls(false);

            if (edit != null)
                edit.Clear();
#if NO
            if (webbHtml != null)
            {
                Global.ClearHtmlPage(webbHtml,
                    this.MainForm.DataDir);
            }
#endif
            if (external_html != null)
            {
                external_html.ClearHtmlPage();
            }

            if (webbXml != null)
            {
                Global.ClearHtmlPage(webbXml,
                    this.MainForm.DataDir);
            }

            try
            {
                byte[] baTimestamp = null;
                string strRecPath = "";

                int nRedoCount = 0;
            REDO:
                stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");

                string[] results = null;

                long lRet = Channel.GetReaderInfo(
                    stop,
                    strBarcode,
                    "xml,html",
                    out results,
                    out strRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                if (lRet == 0)
                    goto ERROR1;

                if (lRet > 1)
                {
                    // 如果重试后依然发生重复
                    if (nRedoCount > 0)
                    {
                        strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,放弃装入读者记录。\r\n\r\n注意这是一个严重错误,请系统管理员尽快排除。";
                        goto ERROR1;    // 当出错处理
                    }
                    SelectPatronDialog dlg = new SelectPatronDialog();

                    dlg.Overflow = StringUtil.SplitList(strRecPath).Count < lRet;
                    nRet = dlg.Initial(
                        this.MainForm,
                        this.Channel,
                        this.stop,
                        StringUtil.SplitList(strRecPath),
                        "请选择一个读者记录",
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    // TODO: 保存窗口内的尺寸状态
                    this.MainForm.AppInfo.LinkFormState(dlg, "ActivateForm_SelectPatronDialog_state");
                    dlg.ShowDialog(this);
                    this.MainForm.AppInfo.UnlinkFormState(dlg);

                    if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        strError = "放弃选择";
                        return 0;
                    }

                    strBarcode = dlg.SelectedBarcode;
                    nRedoCount++;
                    goto REDO;
                }



                // this.ReaderBarcode = strBarcode;

                if (results == null || results.Length < 2)
                {
                    strError = "返回的results不正常。";
                    goto ERROR1;
                }

                string strXml = "";
                strXml = results[0];
                string strHtml = results[1];

                if (edit != null)
                {
                    nRet = edit.SetData(
                        strXml,
                        strRecPath,
                        baTimestamp,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                }

                if (webbXml != null)
                {
                    /*
                    SetXmlToWebbrowser(webbXml,
                        strXml);
                     * */
                    Global.SetXmlToWebbrowser(webbXml,
                        this.MainForm.DataDir,
                        "xml",
                        strXml);
                }

                // this.m_strSetAction = "change";

#if NO
                if (webbHtml != null)
                {
                    Global.SetHtmlString(webbHtml,
                            strHtml,
                            this.MainForm.DataDir,
                            "activateform_html");
                }
#endif

                if (external_html != null)
                    external_html.SetHtmlString(strHtml, "activateform_html");
            }
            finally
            {
                EnableControls(true);

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

            return 1;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemple #2
0
        // 根据读者证条码号,装入读者记录
        // return:
        //      0   cancelled
        /// <summary>
        ///
        /// </summary>
        /// <param name="strBarcode">读者证条码号</param>
        /// <returns>-1: 出错; 0: 放弃; 1: 成功</returns>
        public int LoadRecord(ref string strBarcode)
        {
            string strError = "";
            int    nRet     = 0;

            if (this.Changed == true)
            {
                // 警告尚未保存
                DialogResult result = MessageBox.Show(this,
                                                      "当前有信息被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要根据证条码号重新装载内容? ",
                                                      "ReaderManageForm",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);
                if (result != DialogResult.Yes)
                {
                    return(0);   // cancelled
                }
            }

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();

            this.Update();
            Program.MainForm.Update();

            EnableControls(false);

            this.ClearOperationInfo();

            try
            {
                byte[] baTimestamp = null;
                string strRecPath  = "";

                int nRedoCount = 0;
REDO:
                stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");

                string[] results = null;

                long lRet = Channel.GetReaderInfo(
                    stop,
                    strBarcode,
                    "xml,html",
                    out results,
                    out strRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }

                if (lRet == 0)
                {
                    goto ERROR1;
                }

                if (lRet > 1)
                {
                    // 如果重试后依然发生重复
                    if (nRedoCount > 0)
                    {
                        strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,放弃装入读者记录。\r\n\r\n注意这是一个严重错误,请系统管理员尽快排除。";
                        goto ERROR1;    // 当出错处理
                    }
                    SelectPatronDialog dlg = new SelectPatronDialog();

                    dlg.Overflow = StringUtil.SplitList(strRecPath).Count < lRet;
                    nRet         = dlg.Initial(
                        // Program.MainForm,
                        StringUtil.SplitList(strRecPath),
                        "请选择一个读者记录",
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                    // TODO: 保存窗口内的尺寸状态
                    Program.MainForm.AppInfo.LinkFormState(dlg, "ReaderManageForm_SelectPatronDialog_state");
                    dlg.ShowDialog(this);
                    Program.MainForm.AppInfo.UnlinkFormState(dlg);

                    if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        strError = "放弃选择";
                        return(0);
                    }

                    // strBarcode = dlg.SelectedBarcode;
                    strBarcode = "@path:" + dlg.SelectedRecPath;   // 2015/11/16

                    nRedoCount++;
                    goto REDO;
                }

                this.ReaderBarcode = strBarcode;

                this.RecPath = strRecPath;

                this.Timestamp = baTimestamp;

                if (results == null || results.Length < 2)
                {
                    strError = "返回的results不正常。";
                    goto ERROR1;
                }
                string strXml  = "";
                string strHtml = "";

                strXml  = results[0];
                strHtml = results[1];

                // 保存刚获得的记录
                this.OldRecord = strXml;

                /*
                 * int nRet = this.readerEditControl1.SetData(
                 *  strXml,
                 *  strRecPath,
                 *  baTimestamp,
                 *  out strError);
                 * if (nRet == -1)
                 *  goto ERROR1;
                 * */

                /*
                 * this.SetXmlToWebbrowser(this.webBrowser_xml,
                 *  strXml);
                 * */
                Global.SetXmlToWebbrowser(this.webBrowser_xml,
                                          Program.MainForm.DataDir,
                                          "xml",
                                          strXml);

                // this.m_strSetAction = "change";

                /*
                 * lRet = Channel.GetReaderInfo(
                 *  stop,
                 *  strBarcode,
                 *  "html",
                 *  out strHtml,
                 *  out strRecPath,
                 *  out baTimestamp,
                 *  out strError);
                 * if (lRet == -1)
                 * {
                 *  ChargingForm.SetHtmlString(this.webBrowser_normalInfo,
                 * "装载读者记录发生错误: " + strError);
                 *
                 * }
                 * else
                 * {
                 *  ChargingForm.SetHtmlString(this.webBrowser_normalInfo,
                 *      strHtml);
                 * }
                 * */
#if NO
                Global.SetHtmlString(this.webBrowser_normalInfo,
                                     strHtml,
                                     Program.MainForm.DataDir,
                                     "readermanageform_reader");
#endif
                this.m_webExternalHost.SetHtmlString(strHtml,
                                                     "readermanageform_reader");

                nRet = LoadOperationInfo(out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.Changed = false;
            }
            finally
            {
                EnableControls(true);

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

            return(1);

ERROR1:
            MessageBox.Show(this, strError);
            return(-1);
        }
Exemple #3
0
        // 装入读者记录
        // return:
        //      -1  error
        //      0   没有找到
        //      1   成功
        //      2   放弃
        int LoadReaderRecord(ref string strBarcode,
            out string strError)
        {
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();

            this.Update();
            this.MainForm.Update();

            EnableControls(false);

            try
            {

                SetReaderRenderString("(空)");

                SetBiblioRenderString("(空)");
                SetItemRenderString("(空)");

                string strStyle = this.PatronRenderFormat;

                if (this.VoiceName == true)
                    strStyle += ",summary";

                stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");

                string[] results = null;
                byte[] baTimestamp = null;
                string strRecPath = "";
                long lRet = Channel.GetReaderInfo(
                    stop,
                    GetRequestPatronBarcode(strBarcode),
                    strStyle,   // this.RenderFormat, // "html",
                    out results,
                    out strRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == 0)
                {
                    if (StringUtil.IsIdcardNumber(strBarcode) == true)
                        SetReaderRenderString("证条码号(或身份证号)为 '" + strBarcode + "' 的读者记录没有找到 ...");
                    else
                        SetReaderRenderString("证条码号为 '" + strBarcode + "' 的读者记录没有找到 ...");
                    return 0;   // not found
                }
                if (lRet == -1)
                    goto ERROR1;

                if (results == null || results.Length == 0)
                {
                    strError = "返回的results不正常。";
                    goto ERROR1;
                }
                string strResult = "";
                strResult = results[0];


                if (lRet > 1)
                {
                    /*
                    strError = "读者证条码号 '" + strBarcode + "' 命中 " + lRet.ToString() + " 条读者记录。这是一个严重错误,请系统管理员尽快排除。\r\n\r\n(当前窗口中显示的是其中的第一个记录)";
                    goto ERROR1;
                     * */
                    SelectPatronDialog dlg = new SelectPatronDialog();

                    MainForm.SetControlFont(dlg, this.Font, false);
                    dlg.NoBorrowHistory = this.NoBorrowHistory;
                    dlg.ColorBarVisible = false;
                    dlg.MessageVisible = false;
                    dlg.Overflow = StringUtil.SplitList(strRecPath).Count < lRet;
                    int nRet = dlg.Initial(
                        this.MainForm,
                        //this.Channel,
                        //this.stop,
                        StringUtil.SplitList(strRecPath),
                        "请选择一个读者记录",
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    // TODO: 保存窗口内的尺寸状态
                    this.MainForm.AppInfo.LinkFormState(dlg, "ChargingForm_SelectPatronDialog_state");
                    dlg.ShowDialog(this);
                    this.MainForm.AppInfo.UnlinkFormState(dlg);

                    if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                        return 2;

                    strBarcode = dlg.SelectedBarcode;
                    strResult = dlg.SelectedHtml;
                }

                SetReaderRenderString(ReplaceMacro(strResult));

                this.m_strCurrentBarcode = strBarcode;  // 2011/6/24

                if (this.VoiceName == true && results.Length >= 2)
                {
                    string strName = results[1];
                    this.MainForm.Speak(strName);
                }
            }
            finally
            {
                EnableControls(true);

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

            return 1;
        ERROR1:
            return -1;
        }
Exemple #4
0
        // 根据读者证条码号,装入读者记录
        // parameters:
        //      edit    读者编辑控件。可以==null
        //      webbHtml    用于显示HTML的WebBrowser控件。可以==null
        //      webbXml   用于显示XML的WebBrowser控件。可以==null
        // return:
        //      0   cancelled
        internal int LoadRecord(ref string strBarcode,
                                ReaderEditControl edit,
                                WebExternalHost external_html,
                                // WebBrowser webbHtml,
                                WebBrowser webbXml)
        {
            string strError = "";
            int    nRet     = 0;

            if (edit != null &&
                edit.Changed == true)
            {
                // 警告尚未保存
                DialogResult result = MessageBox.Show(this,
                                                      "当前有信息被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要根据证条码号重新装载内容? ",
                                                      "ActivateForm",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);
                if (result != DialogResult.Yes)
                {
                    return(0);   // cancelled
                }
            }

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();

            this.Update();
            Program.MainForm.Update();

            EnableControls(false);

            if (edit != null)
            {
                edit.Clear();
            }
#if NO
            if (webbHtml != null)
            {
                Global.ClearHtmlPage(webbHtml,
                                     Program.MainForm.DataDir);
            }
#endif
            if (external_html != null)
            {
                external_html.ClearHtmlPage();
            }

            if (webbXml != null)
            {
                Global.ClearHtmlPage(webbXml,
                                     Program.MainForm.DataDir);
            }

            try
            {
                byte[] baTimestamp = null;
                string strRecPath  = "";

                int nRedoCount = 0;
REDO:
                stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");

                long lRet = Channel.GetReaderInfo(
                    stop,
                    strBarcode,
                    "xml,html",
                    out string[] results,
                    out strRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }

                if (lRet == 0)
                {
                    goto ERROR1;
                }

                if (lRet > 1)
                {
                    // 如果重试后依然发生重复
                    if (nRedoCount > 0)
                    {
                        strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,放弃装入读者记录。\r\n\r\n注意这是一个严重错误,请系统管理员尽快排除。";
                        goto ERROR1;    // 当出错处理
                    }
                    SelectPatronDialog dlg = new SelectPatronDialog();

                    dlg.Overflow = StringUtil.SplitList(strRecPath).Count < lRet;
                    nRet         = dlg.Initial(
                        // Program.MainForm,
                        StringUtil.SplitList(strRecPath),
                        "请选择一个读者记录",
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                    // TODO: 保存窗口内的尺寸状态
                    Program.MainForm.AppInfo.LinkFormState(dlg, "ActivateForm_SelectPatronDialog_state");
                    dlg.ShowDialog(this);
                    Program.MainForm.AppInfo.UnlinkFormState(dlg);

                    if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        strError = "放弃选择";
                        return(0);
                    }

                    // strBarcode = dlg.SelectedBarcode;
                    strBarcode = "@path:" + dlg.SelectedRecPath;   // 2015/11/16

                    nRedoCount++;
                    goto REDO;
                }



                // this.ReaderBarcode = strBarcode;

                if (results == null || results.Length < 2)
                {
                    strError = "返回的results不正常。";
                    goto ERROR1;
                }

                string strXml = "";
                strXml = results[0];
                string strHtml = results[1];

                if (edit != null)
                {
                    nRet = edit.SetData(
                        strXml,
                        strRecPath,
                        baTimestamp,
                        out strError);
                    if (nRet == -1)
                    {
                        goto ERROR1;
                    }
                }

                if (webbXml != null)
                {
                    /*
                     * SetXmlToWebbrowser(webbXml,
                     *  strXml);
                     * */
                    Global.SetXmlToWebbrowser(webbXml,
                                              Program.MainForm.DataDir,
                                              "xml",
                                              strXml);
                }

                // this.m_strSetAction = "change";

#if NO
                if (webbHtml != null)
                {
                    Global.SetHtmlString(webbHtml,
                                         strHtml,
                                         Program.MainForm.DataDir,
                                         "activateform_html");
                }
#endif

                if (external_html != null)
                {
                    external_html.SetHtmlString(strHtml, "activateform_html");
                }
            }
            finally
            {
                EnableControls(true);

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

            return(1);

ERROR1:
            MessageBox.Show(this, strError);
            return(-1);
        }
Exemple #5
0
        // 根据读者证条码号,装入读者记录
        // parameters:
        //      bForceLoad  在发生重条码的情况下是否强行装入第一条
        /// <summary>
        /// 根据读者证条码号,装入读者记录
        /// </summary>
        /// <param name="strBarcode">读者证条码号</param>
        /// <param name="bForceLoad">在发生重条码的情况下是否强行装入第一条</param>
        /// <returns>-1: 出错; 0: 放弃; 1: 成功</returns>
        public int LoadRecord(string strBarcode,
            bool bForceLoad)
        {
            string strError = "";
            int nRet = 0;

#if NO
            // 2013/12/4
            this.m_webExternalHost.StopPrevious();
            this.webBrowser_readerInfo.Stop();
#endif

            if (this.ReaderXmlChanged == true
                || this.ObjectChanged == true)
            {
                // 警告尚未保存
                DialogResult result = MessageBox.Show(this,
"当前有信息被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要根据证条码号重新装载内容? ",
"ReaderInfoForm",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
                if (result != DialogResult.Yes)
                    return 0;   // cancelled

            }

            this.m_nChannelInUse++;
            if (this.m_nChannelInUse > 1)
            {
                this.m_nChannelInUse--;
                strError = "通道已经被占用。请稍后重试";
                goto ERROR1;
            }
            try
            {

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在初始化浏览器组件 ...");
                stop.BeginLoop();

                this.Update();
                this.MainForm.Update();

                EnableControls(false);

                this.readerEditControl1.Clear();
#if NO
                Global.ClearHtmlPage(this.webBrowser_readerInfo,
                    this.MainForm.DataDir);
#endif
                ClearReaderHtmlPage();
                this.binaryResControl1.Clear();

                try
                {
                    byte[] baTimestamp = null;
                    string strOutputRecPath = "";
                    int nRedoCount = 0;

                    REDO:
                    stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");

                    string[] results = null;
                    long lRet = Channel.GetReaderInfo(
                        stop,
                        strBarcode,
                        "xml,html",
                        out results,
                        out strOutputRecPath,
                        out baTimestamp,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                    if (lRet == 0)
                        goto ERROR1;

                    if (lRet > 1)
                    {
#if NO
                        if (bForceLoad == true)
                        {
                            strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,但仍装入其中第一条读者记录。\r\n\r\n这是一个严重错误,请系统管理员尽快排除。";
                            MessageBox.Show(this, strError);    // 警告后继续装入第一条 
                        }
                        else
                        {
                            strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,放弃装入读者记录。\r\n\r\n注意这是一个严重错误,请系统管理员尽快排除。";
                            goto ERROR1;    // 当出错处理
                        }
#endif
                        // 如果重试后依然发生重复
                        if (nRedoCount > 0)
                        {
                            if (bForceLoad == true)
                            {
                                strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,但仍装入其中第一条读者记录。\r\n\r\n这是一个严重错误,请系统管理员尽快排除。";
                                MessageBox.Show(this, strError);    // 警告后继续装入第一条 
                            }
                            else
                            {
                                strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,放弃装入读者记录。\r\n\r\n注意这是一个严重错误,请系统管理员尽快排除。";
                                goto ERROR1;    // 当出错处理
                            }
                        }

                        SelectPatronDialog dlg = new SelectPatronDialog();

                        dlg.Overflow = StringUtil.SplitList(strOutputRecPath).Count < lRet;
                        nRet = dlg.Initial(
                            this.MainForm,
                            this.Channel,
                            this.stop,
                            StringUtil.SplitList(strOutputRecPath),
                            "请选择一个读者记录",
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;

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

                        if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                            return 0;

                        strBarcode = dlg.SelectedBarcode;
                        nRedoCount++;
                        goto REDO;
                    }

                    this.ReaderBarcode = strBarcode;

                    /*
                    this.RecPath = strRecPath;

                    this.Timestamp = baTimestamp;

                    // 保存刚获得的记录
                    this.OldRecord = strXml;
                     */


                    if (results == null || results.Length < 2)
                    {
                        strError = "返回的results不正常。";
                        goto ERROR1;
                    }

                    string strXml = "";
                    string strHtml = "";
                    strXml = results[0];
                    strHtml = results[1];

                    nRet = this.readerEditControl1.SetData(
                        strXml,
                        strOutputRecPath,
                        baTimestamp,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;


                    // 接着装入对象资源
                    {
                        nRet = this.binaryResControl1.LoadObject(strOutputRecPath,    // 2008/11/2 changed
                            strXml,
                            out strError);
                        if (nRet == -1)
                        {
                            MessageBox.Show(this, strError);
                            // return -1;
                        }
                    }

                    /*
                    this.SetXmlToWebbrowser(this.webBrowser_xml,
                        strXml);
                     * */
                    Global.SetXmlToWebbrowser(this.webBrowser_xml,
                        this.MainForm.DataDir,
                        "xml",
                        strXml);

                    this.m_strSetAction = "change";

                    /*
                    lRet = Channel.GetReaderInfo(
                        stop,
                        strBarcode,
                        "html",
                        out strHtml,
                        out strRecPath,
                        out baTimestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        ChargingForm.SetHtmlString(this.webBrowser_readerInfo,
    "装载读者记录发生错误: " + strError);

                    }
                    else
                    {
                        ChargingForm.SetHtmlString(this.webBrowser_readerInfo,
                            strHtml,
        this.MainForm.DataDir,
        "readerinfoform_reader");
                    }
                     * */

#if NO
                    // 2013/12/21
                    this.m_webExternalHost.StopPrevious();
                    this.webBrowser_readerInfo.Stop();

                    Global.SetHtmlString(this.webBrowser_readerInfo,
        strHtml,
        this.MainForm.DataDir,
        "readerinfoform_reader");
#endif
                    this.SetReaderHtmlString(strHtml);

                }
                finally
                {
                    EnableControls(true);

                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");
                }
            }
            finally
            {
                this.m_nChannelInUse--;
            }

            return 1;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemple #6
0
        // return:
        //      -1  error
        //      0   放弃
        //      1   成功
        internal int SelectOnePatron(long lRet,
            string strRecPath,
            out string strBarcode,
            out string strResult,
            out string strError)
        {
            strError = "";
            strResult = "";
            strBarcode = "";

            if (lRet <= 1)
            {
                strError = "没有必要调用 SelectMultiPatron()";
                return -1;
            }

            if (this.IsDisposed)
                return 0;

            if (this.InvokeRequired)
            {
                Delegate_SelectOnePatron d = new Delegate_SelectOnePatron(SelectOnePatron);
                object[] args = new object[5];
                args[0] = lRet;
                args[1] = strRecPath;
                args[2] = strBarcode;
                args[3] = strResult;
                args[4] = strError;
                int result = (int)this.Invoke(d, args);

                // 取出out参数值
                strBarcode = (string)args[2];
                strResult = (string)args[3];
                strError = (string)args[4];
                return result;
            }

            /*
            strError = "读者证条码号 '" + strBarcode + "' 命中 " + lRet.ToString() + " 条读者记录。这是一个严重错误,请系统管理员尽快排除。\r\n\r\n(当前窗口中显示的是其中的第一个记录)";
            goto ERROR1;
             * */
            SelectPatronDialog dlg = new SelectPatronDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.NoBorrowHistory = this.NoBorrowHistory;
            dlg.ColorBarVisible = false;
            dlg.MessageVisible = false;
            dlg.Overflow = StringUtil.SplitList(strRecPath).Count < lRet;
            int nRet = dlg.Initial(
                this.MainForm,
                //this.Channel,
                //this.stop,
                StringUtil.SplitList(strRecPath),
                "请选择一个读者记录",
                out strError);
            if (nRet == -1)
                return -1;
            // TODO: 保存窗口内的尺寸状态
            this.MainForm.AppInfo.LinkFormState(dlg, "QuickChargingForm_SelectPatronDialog_state");
            dlg.ShowDialog(this.SafeWindow);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                return 0;

            strBarcode = dlg.SelectedBarcode;
            strResult = dlg.SelectedHtml;

            return 1;
        }
Exemple #7
0
        // 根据读者证条码号,装入读者记录
        // return:
        //      0   cancelled
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strBarcode">读者证条码号</param>
        /// <returns>-1: 出错; 0: 放弃; 1: 成功</returns>
        public int LoadRecord(ref string strBarcode)
        {
            string strError = "";
            int nRet = 0;

            if (this.Changed == true)
            {
                // 警告尚未保存
                DialogResult result = MessageBox.Show(this,
"当前有信息被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要根据证条码号重新装载内容? ",
"ReaderManageForm",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2);
                if (result != DialogResult.Yes)
                    return 0;   // cancelled

            }

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();

            this.Update();
            this.MainForm.Update();

            EnableControls(false);

            this.ClearOperationInfo();

            try
            {

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

                int nRedoCount = 0;
            REDO:
                stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");

                string[] results = null;

                long lRet = Channel.GetReaderInfo(
                    stop,
                    strBarcode,
                    "xml,html",
                    out results,
                    out strRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                if (lRet == 0)
                    goto ERROR1;

                if (lRet > 1)
                {
                    // 如果重试后依然发生重复
                    if (nRedoCount > 0)
                    {
                        strError = "条码 " + strBarcode + " 命中记录 " + lRet.ToString() + " 条,放弃装入读者记录。\r\n\r\n注意这是一个严重错误,请系统管理员尽快排除。";
                        goto ERROR1;    // 当出错处理
                    }
                    SelectPatronDialog dlg = new SelectPatronDialog();

                    dlg.Overflow = StringUtil.SplitList(strRecPath).Count < lRet;
                    nRet = dlg.Initial(
                        this.MainForm,
                        //this.Channel,
                        //this.stop,
                        StringUtil.SplitList(strRecPath),
                        "请选择一个读者记录",
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    // TODO: 保存窗口内的尺寸状态
                    this.MainForm.AppInfo.LinkFormState(dlg, "ReaderManageForm_SelectPatronDialog_state");
                    dlg.ShowDialog(this);
                    this.MainForm.AppInfo.UnlinkFormState(dlg);

                    if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        strError = "放弃选择";
                        return 0;
                    }

                    // strBarcode = dlg.SelectedBarcode;
                    strBarcode = "@path:" + dlg.SelectedRecPath;   // 2015/11/16

                    nRedoCount++;
                    goto REDO;
                }

                this.ReaderBarcode = strBarcode;

                this.RecPath = strRecPath;

                this.Timestamp = baTimestamp;

                if (results == null || results.Length < 2)
                {
                    strError = "返回的results不正常。";
                    goto ERROR1;
                }
                string strXml = "";
                string strHtml = "";

                strXml = results[0];
                strHtml = results[1];

                // 保存刚获得的记录
                this.OldRecord = strXml;

                /*
                int nRet = this.readerEditControl1.SetData(
                    strXml,
                    strRecPath,
                    baTimestamp,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
                 * */

                /*
                this.SetXmlToWebbrowser(this.webBrowser_xml,
                    strXml);
                 * */
                Global.SetXmlToWebbrowser(this.webBrowser_xml,
                    this.MainForm.DataDir,
                    "xml",
                    strXml);

                // this.m_strSetAction = "change";

                /*
                lRet = Channel.GetReaderInfo(
                    stop,
                    strBarcode,
                    "html",
                    out strHtml,
                    out strRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    ChargingForm.SetHtmlString(this.webBrowser_normalInfo,
"装载读者记录发生错误: " + strError);

                }
                else
                {
                    ChargingForm.SetHtmlString(this.webBrowser_normalInfo,
                        strHtml);
                }
                 * */
#if NO
                Global.SetHtmlString(this.webBrowser_normalInfo,
                    strHtml,
                    this.MainForm.DataDir,
                    "readermanageform_reader");
#endif
                this.m_webExternalHost.SetHtmlString(strHtml,
                    "readermanageform_reader");

                nRet = LoadOperationInfo(out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.Changed = false;
            }
            finally
            {
                EnableControls(true);

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

            return 1;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemple #8
0
        // 装入读者记录
        // parameters:
        //      strBarcode  [in][out] 输入证条码号,或者身份证号等其他号码。输出证条码号
        // return:
        //      -1  error
        //      0   not found
        //      >=1 命中的读者记录条数
        int LoadReaderHtmlRecord(ref string strBarcode,
            out string strXml,
            out string strError)
        {
            strXml = "";
            int nRet = 0;

            if (String.IsNullOrEmpty(strBarcode) == true)
            {
                strError = "strBarcode参数不能为空";
                goto ERROR1;
            }

#if NO
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在初始化浏览器组件 ...");
            stop.BeginLoop();
#endif

            //this.Update();
            //this.MainForm.Update();

            int nRecordCount = 0;

            try
            {

                Global.ClearHtmlPage(this.webBrowser_readerInfo, this.MainForm.DataDir);

                byte[] baTimestamp = null;
                string strOutputRecPath = "";
                int nRedoCount = 0;

            REDO:

                stop.SetMessage("正在装入读者记录 " + strBarcode + " ...");
                string[] results = null;

                long lRet = Channel.GetReaderInfo(
                    stop,
                    strBarcode,
                    "html,xml",
                    out results,
                    out strOutputRecPath,
                    out baTimestamp,
                    out strError);
                if (lRet == 0)
                {
                    // Global.SetHtmlString(this.webBrowser_readerInfo, "证条码号为 '" + strBarcode + "' 的读者记录没有找到 ...");
                    this.m_webExternalHost.SetTextString("证条码号为 '" + strBarcode + "' 的读者记录没有找到 ...");

                    return 0;   // not found
                }

                if (lRet == -1)
                    goto ERROR1;

                nRecordCount = (int)lRet;

                if (lRet > 1 && nRedoCount == 0)
                {
                    SelectPatronDialog dlg = new SelectPatronDialog();

                    dlg.Overflow = StringUtil.SplitList(strOutputRecPath).Count < lRet;
                    nRet = dlg.Initial(
                        this.MainForm,
                        //this.Channel,
                        //this.stop,
                        StringUtil.SplitList(strOutputRecPath),
                        "请选择一个读者记录",
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    // TODO: 保存窗口内的尺寸状态
                    this.MainForm.AppInfo.LinkFormState(dlg, "AmerceForm_SelectPatronDialog_state");
                    dlg.ShowDialog(this);
                    this.MainForm.AppInfo.UnlinkFormState(dlg);

                    if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                    {
                        strError = "放弃选择";
                        return 0;
                    }

                    // strBarcode = dlg.SelectedBarcode;
                    strBarcode = "@path:" + dlg.SelectedRecPath;   // 2015/11/16

                    nRedoCount++;
                    goto REDO;
                }


                if (results == null || results.Length < 2)
                {
                    strError = "返回的results不正常。";
                    goto ERROR1;
                }

                string strHtml = "";
                strHtml = results[0];
                strXml = results[1];

                // 2013/10/14
                string strOutputBarcode = "";
                // 从读者记录 XML 字符串中取出读者证条码号
                // return:
                //      -1  出错
                //      0   成功
                nRet = GetReaderBarcode(strXml,
                    out strOutputBarcode,
                    out strError);
                if (nRet == -1)
                    return -1;

                strBarcode = strOutputBarcode;

#if NO
                Global.SetHtmlString(this.webBrowser_readerInfo,
                    strHtml,
                    this.MainForm.DataDir,
                    "amercing_reader");
#endif
                this.m_webExternalHost.SetHtmlString(strHtml,
                    "amercing_reader");
            }
            finally
            {
#if NO
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
#endif
            }

            return nRecordCount;
        ERROR1:
            return -1;
        }