示例#1
0
        int ExportToItemSearchForm(
    string strDbType,
    out string strError)
        {
            strError = "";
            string strTempFileName = Path.Combine(this.MainForm.DataDir, "~export_to_searchform.txt");
            int nRet = SaveToEntityRecordPathFile(strDbType,
                strTempFileName,
                out strError);
            if (nRet == -1)
                return -1;

#if NO
            // TODO: 最好为具体类型的 SearchForm 类。否则推出时保留的遗留出鞥口类型不对
            ItemSearchForm form = new ItemSearchForm();
            form.DbType = strDbType;
            form.MdiParent = this.MainForm;
            form.Show();
#endif
            ItemSearchForm form = this.MainForm.OpenItemSearchForm(strDbType);

            nRet = form.ImportFromRecPathFile(strTempFileName,
                "clear",
                out strError);
            if (nRet == -1)
                return -1;
            return 0;
        }
示例#2
0
        // 在一个新开的实体查询窗内检索key
        void listView_searchKeysAtNewWindow_Click(object sender, EventArgs e)
        {
            if (this.listView_records.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未在列表中选定要操作的事项");
                return;
            }

            ItemSearchForm form = new ItemSearchForm();
            form.DbType = this.DbType;
            form.MdiParent = this.MainForm;
            // form.MainForm = this.MainForm;
            form.Show();

            int i = 0;
            foreach (ListViewItem item in this.listView_records.SelectedItems)
            {
                ItemQueryParam query = (ItemQueryParam)item.Tag;
                Debug.Assert(query != null, "");

                ItemQueryParam input_query = new ItemQueryParam();

                input_query.QueryWord = ListViewUtil.GetItemText(item, 1);
                input_query.DbNames = query.DbNames;
                input_query.From = query.From;
                input_query.MatchStyle = "精确一致";

                // 2015/1/17
                if (string.IsNullOrEmpty(input_query.QueryWord) == true)
                    input_query.MatchStyle = "空值";
                else
                    input_query.MatchStyle = "精确一致";


                // 检索命中记录(而不是key)
                int nRet = form.DoSearch(false, false, input_query, i == 0 ? true : false);
                if (nRet != 1)
                    break;

                i++;
            }
        }
示例#3
0
        // 装载数据
        public override bool LoadData()
        {
            string strError = "";
            int    nRet     = 0;

            BiblioInfo info       = this.BiblioInfo;
            string     strRecPath = this.BiblioInfo.RecPath;

            if (string.IsNullOrEmpty(info.OldXml) == true)
            {
                lock (syncRoot)
                {
                    channel = Program.MainForm.GetChannel();
                }
                try
                {
                    // 显示 正在处理
                    this.HTML = GetWaitingHtml("正在获取 " + this.DbType + " 记录 " + strRecPath);
                    ShowData();

                    byte [] baTimestamp      = null;
                    string  strOutputRecPath = "";
                    string  strBiblio        = "";
                    string  strBiblioRecPath = "";
                    string  strXml           = "";

                    // 获得记录
                    channel.Timeout = new TimeSpan(0, 0, 5);
                    long lRet = 0;
                    if (this.DbType == "item")
                    {
                        lRet = channel.GetItemInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "order")
                    {
                        lRet = channel.GetOrderInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "issue")
                    {
                        lRet = channel.GetIssueInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "comment")
                    {
                        lRet = channel.GetCommentInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out strXml,
                            out strOutputRecPath,
                            out baTimestamp,
                            "",
                            out strBiblio,
                            out strBiblioRecPath,
                            out strError);
                    }
                    else if (this.DbType == "patron")
                    {
                        string[] results = null;
                        // 获得读者记录
                        lRet = channel.GetReaderInfo(
                            this.Stop,
                            "@path:" + strRecPath,
                            "xml",
                            out results,
                            out strOutputRecPath,
                            out baTimestamp,
                            out strError);
                        if (lRet == 1)
                        {
                            if (results == null || results.Length == 0)
                            {
                                strError = "results error";
                                nRet     = -1;
                            }
                            else
                            {
                                strXml = results[0];
                            }
                        }
                    }
                    else
                    {
                        lRet     = -1;
                        strError = "无法识别的 DbType '" + this.DbType + "'";
                    }

                    if (lRet == 0)
                    {
                        nRet     = -1;
                        strError = "获取记录 " + strRecPath + " 时出错: " + strError;
                    }
                    else if (lRet == -1)
                    {
                        nRet     = -1;
                        strError = "获取记录 " + strRecPath + " 时出错: " + strError;
                    }
                    else
                    {
                        info.OldXml    = strXml;
                        info.Timestamp = baTimestamp;
                        info.RecPath   = strRecPath;
                    }
                }
                finally
                {
                    LibraryChannel temp_channel = channel;
                    lock (syncRoot)
                    {
                        channel = null;
                    }
                    Program.MainForm.ReturnChannel(temp_channel);
                }
            }

            string strXml1  = "";
            string strHtml2 = "";

            if (nRet == -1)
            {
                strHtml2 = HttpUtility.HtmlEncode(strError);
            }
            else
            {
                nRet = ItemSearchForm.GetXmlHtml(info,
                                                 out strXml1,
                                                 out strHtml2,
                                                 out strError);
                if (nRet == -1)
                {
                    throw new Exception(strError);
                }
            }

            this.HTML = "<html>" +
                        Program.MainForm.GetMarcHtmlHeadString(true) +
                        "<body>" +
                        strHtml2 +
                        EntityForm.GetTimestampHtml(info.Timestamp) +
                        "</body></html>";

            this.XML = strXml1;
            return(true);
        }
示例#4
0
        void menu_createCallNumber_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            Debug.Assert(this.DbType == "item", "");

            if (this.listView_records.SelectedItems.Count == 0)
            {
                strError = "尚未选定要进行批处理的事项";
                goto ERROR1;
            }

            if (stop != null && stop.State == 0)    // 0 表示正在处理
            {
                strError = "目前有长操作正在进行,无法进行创建索取号的操作";
                goto ERROR1;
            }

            bool bOverwrite = false;
            {
                DialogResult result = MessageBox.Show(this,
    "在后面即将进行的处理过程中,对已经存在索取号的册记录,是否要重新创建索取号?\r\n\r\n(Yes: 要重新创建;No: 不重新创建,即:跳过;Cancel: 现在就放弃本次批处理)",
    this.DbType + "SearchForm",
    MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
                if (result == System.Windows.Forms.DialogResult.Yes)
                    bOverwrite = true;
                else if (result == System.Windows.Forms.DialogResult.No)
                    bOverwrite = false;
                else
                    return;

            }

            int nCount = 0;

            stop.Style = StopStyle.EnableHalfStop;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在创建索取号 ...");
            stop.BeginLoop();

            this.EnableControls(false);
            try
            {

                // 打开一个新的种册窗
                EntityForm form = null;

                form = new EntityForm();

                form.MdiParent = this.MainForm;

                form.MainForm = this.MainForm;
                form.Show();

                stop.SetProgressRange(0, this.listView_records.SelectedItems.Count);

                ItemSearchForm itemsearchform = null;
                bool bHideMessageBox = false;

                int i = 0;
                foreach (ListViewItem item in this.listView_records.SelectedItems)
                {
                    Application.DoEvents();	// 出让界面控制权

                    if (stop != null)
                    {
                        if (stop.State != 0)
                        {
                            MessageBox.Show(this, "用户中断");
                            return;
                        }
                    }

                    string strRecPath = ListViewUtil.GetItemText(item, 0);

                    // parameters:
                    //      bAutoSavePrev   是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    form.LoadItemByRecPath(strRecPath, true);

                    // 为当前选定的事项创建索取号
                    // return:
                    //      -1  出错
                    //      0   放弃处理
                    //      1   已经处理
                    nRet = form.EntityControl.CreateCallNumber(bOverwrite, out strError);
                    if (nRet == -1)
                        goto ERROR;

                    if (nRet == 1)
                    {
                        nCount++;
                        // form.DoSaveAll();
                        nRet = form.EntityControl.SaveItems(
                            this.Channel,
                            out strError);
                        if (nRet == -1)
                            goto ERROR;

                        nRet = RefreshBrowseLine(item,
    out strError);
                        if (nRet == -1)
                        {
                            strError = "刷新浏览内容时出错: " + strError;
                            goto ERROR;
#if NO
                            DialogResult result = MessageBox.Show(this,
                                "刷新浏览内容时出错: " + strError + "。\r\n\r\n是否继续刷新? (OK 刷新;Cancel 放弃刷新)",
                                this.DbType + "SearchForm",
                                MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button1);
                            if (result == System.Windows.Forms.DialogResult.Cancel)
                                break;
#endif
                        }
                    }

                ERROR:
                    if (nRet == -1)
                    {
                        if (itemsearchform == null)
                        {
                            Form active_mdi = this.MainForm.ActiveMdiChild;

                            itemsearchform = new ItemSearchForm();
                            itemsearchform.MdiParent = this.MainForm;
                            itemsearchform.MainForm = this.MainForm;
                            itemsearchform.Show();
                            itemsearchform.QueryWordString = "创建索取号过程中出错的册记录";

                            active_mdi.Activate();
                        }

                        ListViewItem new_item = itemsearchform.AddLineToBrowseList(Global.BuildLine(item));
                        ListViewUtil.ChangeItemText(new_item, 1, strError);

                        this.OutputText(strRecPath + " : " + strError, 2);

                        strError = "在为册记录 " + strRecPath + " 创建索取号时出错: " + strError;

                        if (bHideMessageBox == false)
                        {
                            DialogResult result = MessageDialog.Show(this,
                                strError + "。\r\n\r\n是否继续处理后面的记录? (继续: 继续;停止: 停止整个批处理)",
            MessageBoxButtons.OKCancel,
            MessageBoxDefaultButton.Button1,
            "不再出现此对话框",
            ref bHideMessageBox,
            new string[] { "继续", "停止" });
                            if (result == System.Windows.Forms.DialogResult.Cancel)
                                goto ERROR1;
                        }
                        form.EntitiesChanged = false;
                    }

                    stop.SetProgressValue(++i);
                }

                // form.DoSaveAll();
                form.Close();
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();
                stop.Style = StopStyle.None;

                this.EnableControls(true);
            }

            MessageBox.Show(this, "共处理 " + nCount.ToString() + " 个册记录");
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
示例#5
0
        // 将一个读者的操作历史输出到实体查询窗
        // parameters:
        static int OutputBorrowHistory(
            ItemSearchForm form,
            XmlDocument reader_dom,
            ChargingHistoryLoader history_loader,
            ItemBarcodeLoader barcode_loader,
            out string strError)
        {
            strError = "";

            if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "2.67") < 0)
            {
                strError = "输出操作历史到实体查询窗要求 dp2library 为 2.67 或以上版本";
                return -1;
            }

            List<string> barcodes = new List<string>();
            foreach (ChargingItemWrapper wrapper in history_loader)
            {
                ChargingItem item = wrapper.Item;

                string strItemBarcode = item.ItemBarcode;
#if NO
                ChargingItem rel = wrapper.RelatedItem;
                string strBorrowDate = rel == null ? "" : rel.OperTime;
                string strBorrowPeriod = GetDisplayTimePeriodString(rel == null ? "" : rel.Period);
                string strReturnDate = item.OperTime;
#endif

                barcodes.Add(strItemBarcode);
            }

            string strTempFileName = Program.MainForm.GetTempFileName("exphis");
            try
            {
                int nCount = 0;
                using (StreamWriter sw = new StreamWriter(strTempFileName, false, Encoding.UTF8))
                {
                    barcode_loader.Barcodes = barcodes;
                    foreach (EntityItem info in barcode_loader)
                    {
                        string strRecPath = info.RecPath;
                        if (string.IsNullOrEmpty(strRecPath) == true)
                            continue;   // TODO: 是否要警告?
                        sw.WriteLine(strRecPath);
                        nCount++;
                    }
                }

                if (nCount > 0)
                {
                    int nRet = form.ImportFromRecPathFile(strTempFileName,
                        "",
                        out strError);
                    if (nRet == -1)
                        return -1;
                }

                return 0;
            }
            finally
            {
                File.Delete(strTempFileName);
            }
        }