当前位置: 首页>>代码示例>>C#>>正文


C# RmsChannel.DoSaveTextRes方法代码示例

本文整理汇总了C#中DigitalPlatform.rms.Client.RmsChannel.DoSaveTextRes方法的典型用法代码示例。如果您正苦于以下问题:C# RmsChannel.DoSaveTextRes方法的具体用法?C# RmsChannel.DoSaveTextRes怎么用?C# RmsChannel.DoSaveTextRes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DigitalPlatform.rms.Client.RmsChannel的用法示例。


在下文中一共展示了RmsChannel.DoSaveTextRes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyBiblioChildRecords


//.........这里部分代码省略.........
                    try
                    {
                        dom.LoadXml(info.OldRecord);
                    }
                    catch (Exception ex)
                    {
                        strError = "记录 '" + info.RecPath + "' 装入XMLDOM发生错误: " + ex.Message;
                        goto ERROR1;
                    }
                    DomUtil.SetElementText(dom.DocumentElement,
                        "parent",
                        strParentID);

                    // 复制的情况,要避免出现操作后的条码号重复现象
                    if (strAction == "copy")
                    {
                        // 修改册条码号,避免发生条码号重复
                        string strOldItemBarcode = DomUtil.GetElementText(dom.DocumentElement,
                            "barcode");
                        if (String.IsNullOrEmpty(strOldItemBarcode) == false)
                        {
                            // 2014/1/5
                            if (string.IsNullOrEmpty(strNewBarcode) == true)
                                strNewBarcode = "temp_" + strOldItemBarcode;
                            DomUtil.SetElementText(dom.DocumentElement,
                                "barcode",
                                strNewBarcode);
                        }

                        // 2014/1/5
                        DomUtil.SetElementText(dom.DocumentElement,
                            "refID",
                            null);

                        // 把借者清除
                        // (源实体记录中如果有借阅信息,在普通界面上是无法删除此记录的。只能用出纳窗正规进行归还,然后才能删除)
                        {
                            DomUtil.SetElementText(dom.DocumentElement,
                                "borrower",
                                null);
                            DomUtil.SetElementText(dom.DocumentElement,
                                "borrowPeriod",
                                null);
                            DomUtil.SetElementText(dom.DocumentElement,
                                "borrowDate",
                                null);
                        }
                    }

                    // TODO: 可以顺便确认有没有对象资源。如果没有,就省略CopyRecord操作

                    long lRet = channel.DoCopyRecord(info.RecPath,
                         strTargetRecPath,
                         strAction == "move" ? true : false,   // bDeleteSourceRecord
                         out output_timestamp,
                         out strOutputRecPath,
                         out strError);
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == ChannelErrorCode.NotFound)
                            continue;
                        strError = "复制实体记录 '" + info.RecPath + "' 时发生错误: " + strError;
                        goto ERROR1;
                    }



                    // 修改xml记录。<parent>元素发生了变化
                    byte[] baOutputTimestamp = null;
                    string strOutputRecPath1 = "";
                    lRet = channel.DoSaveTextRes(strOutputRecPath,
                        dom.OuterXml,
                        false,
                        "content", // ,ignorechecktimestamp
                        output_timestamp,
                        out baOutputTimestamp,
                        out strOutputRecPath1,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                    oldrecordpaths.Add(info.RecPath);
                    newrecordpaths.Add(strOutputRecPath);
                    parentids.Add(strParentID);
                    if (strAction == "move")
                        oldrecords.Add(info.OldRecord);
                }
                finally
                {
                    this.EntityLocks.UnlockForWrite(info.ItemBarcode);
                }

                nOperCount++;
            }

            return nOperCount;
        ERROR1:
            // 不要Undo
            return -1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AppEntity.cs

示例2: ModifyEntityRecord


//.........这里部分代码省略.........
                        return -1;
                    }

                    /*
                    result.Value = -1;
                    result.ErrorInfo = "册条码号为 '" + strItemBarcode + "' 的册记录有 " + aPath.Count.ToString() + " 条,无法进行修复操作。请在附加册记录路径后重新提交修复操作。";
                    result.ErrorCode = ErrorCode.ItemBarcodeDup;

                    aDupPath = new string[aPath.Count];
                    aPath.CopyTo(aDupPath);
                    return result;
                     * */

                }
                else
                {
                    Debug.Assert(nRet == 1, "");
                    Debug.Assert(aPath.Count == 1, "");

                    if (nRet == 1)
                    {
                        strOutputItemRecPath = aPath[0];
                    }
                }
            }

            XmlDocument itemdom = null;
            nRet = LibraryApplication.LoadToDom(strItemXml,
                out itemdom,
                out strError);
            if (nRet == -1)
            {
                strError = "装载册记录进入XML DOM时发生错误: " + strError;
                return -1;
            }

            // 校验册条码号参数是否和XML记录中完全一致
            string strTempItemBarcode = DomUtil.GetElementText(itemdom.DocumentElement,
                "barcode");
            if (strItemBarcode != strTempItemBarcode)
            {
                strError = "修改册记录ModifyEntityRecord()操作被拒绝。因册条码号参数 '" + strItemBarcode + "' 和册记录中<barcode>元素内的册条码号值 '" + strTempItemBarcode + "' 不一致。";
                return -1;
            }

            // 看看册记录中是否有指回读者记录的链
            string strBorrower = DomUtil.GetElementText(itemdom.DocumentElement,
                "borrower");
            if (strBorrower != strReaderBarcode)
            {
                // strError = "ModifyEntityRecord()操作被拒绝。您所请求要修复的链,本是一条完整正确的链。可直接进行普通还书操作。";
                strError = "修改册记录ModifyEntityRecord()操作被拒绝。因册记录 " + strOutputItemRecPath + " 中的[borrower]值 '" + strBorrower + "' 和发源(来找册条码号 '" + strItemBarcode + "')的读者证条码号 '" + strReaderBarcode + "' 不一致,不能构成一条完整正确的链。请及时排除此故障。";
                return -1;
            }

            // 2007/1/1注:应当看看记录中<borrower>元素是否有内容才改写<borrowDate>和<borrowPeriod>元素。

            DomUtil.SetElementText(itemdom.DocumentElement, "borrowDate", strBorrowDate);
            DomUtil.SetElementText(itemdom.DocumentElement, "borrowPeriod", strBorrowPeriod);

#if NO
            if (channel == null)
            {
                channel = Channels.GetChannel(this.WsUrl);
                if (channel == null)
                {
                    strError = "get channel error";
                    return -1;
                }
            }
#endif
            byte[] output_timestamp = null;
            string strOutputPath = "";

            // 写回册记录
            lRet = channel.DoSaveTextRes(strOutputItemRecPath,
                itemdom.OuterXml,
                false,
                "content",  // ,ignorechecktimestamp
                item_timestamp,
                out output_timestamp,
                out strOutputPath,
                out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    nRedoCount++;
                    if (nRedoCount > 10)
                    {
                        strError = "ModifyEntityRecord()写回册记录的时候,遇到时间戳冲突,并因此重试10次,仍失败...";
                        return -1;
                    }
                    goto REDO_CHANGE;
                }
                return -1;
            } // end of 写回册记录失败

            return 1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppUpgrade.cs

示例3: SaveToTemplate


//.........这里部分代码省略.........
			if (nRet == -1) 
				goto ERROR1;


			tempdlg.Text = "请选择要修改的模板记录";
			tempdlg.CheckNameExist = false;	// 按OK按钮时不警告"名字不存在",这样允许新建一个模板
			tempdlg.ap = this.MainForm.AppInfo;
			tempdlg.ApCfgTitle = "detailform_selecttemplatedlg";
			tempdlg.ShowDialog(this);

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

			string strXmlBody = "";
            bool bHasUploadedFile = false;


			nRet = GetXmlRecord(out strXmlBody,
                out bHasUploadedFile,
                out strError);
			if (nRet == -1)
				goto ERROR1;



			// 修改配置文件内容
			if (tempdlg.textBox_name.Text != "")
			{
				// 替换或者追加一个记录
				nRet = tempdlg.ReplaceRecord(tempdlg.textBox_name.Text,
					strXmlBody,
					out strError);
				if (nRet == -1) 
				{
					goto ERROR1;
				}
			}

			if (tempdlg.Changed == false)	// 没有必要保存回去
				return;

			string strOutputXml = tempdlg.OutputXml;


			// 使用Channel
			channelSave = channel;

			// 重新获得一次channel, 是因为前面GetXmlRecord()函数有可能摧毁这个变量
			channel = Channels.GetChannel(respath.Url);
			Debug.Assert(channel != null, "Channels.GetChannel 异常");

			try 
			{


				// 存回配置文件
                stop.OnStop += new StopEventHandler(this.DoStop);
				stop.Initial("正在保存配置文件 " + strCfgFilePath);
				stop.BeginLoop();

				byte [] baOutputTimeStamp = null;
				// string strOutputPath = "";

				EnableControlsInLoading(true);

				lRet = channel.DoSaveTextRes(strCfgFilePath,
					strOutputXml,
					true,	// bInlucdePreamble
					"",	// style
					baTimeStamp,
					out baOutputTimeStamp,
					out strOutputPath,
					out strError);

				EnableControlsInLoading(false);

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


				if (lRet == -1) 
				{
					strError = "保存配置文件"+ strCfgFilePath +"失败,原因: "+strError;
					goto ERROR1;
				}
			}
			finally 
			{
				channel = channelSave;
			}

			MessageBox.Show(this, "修改模板配置文件成功。");

			return;

			ERROR1:
				MessageBox.Show(this, strError);

		}
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:DetailForm.cs

示例4: DoNotifyNext


//.........这里部分代码省略.........
                records,
                channel,
                strReaderBarcode,
                strItemBarcode,
                bOnShelf,
                out strReservationReaderBarcode,
                out strError);
            if (nRet == -1)
                return -1;

            // 3) 通知预约到书的操作
            List<string> DeletedNotifyRecPaths = null;  // 被删除的通知记录。

            if (String.IsNullOrEmpty(strReservationReaderBarcode) == false)
            {
                // 通知下一读者

                // 出于对读者库加锁方面的便利考虑, 单独做了此函数
                // return:
                //      -1  error
                //      0   没有找到<request>元素
                //      1   已成功处理
                nRet = this.DoReservationNotify(
                    records,
                    channel,
                    strReservationReaderBarcode,
                    true,
                    strItemBarcode,
                    bOnShelf,
                    false,   // 不要修改当前册记录的<request> state属性,因为前面ClearArrivedInfo()中已经调用了DoItemReturnReservationCheck(), 修改了当前册的<request> state属性。
                    out DeletedNotifyRecPaths,
                    out strError);
                if (nRet == -1)
                    return -1;
            }
            else
            {
                // outof 的记录何时删除?
                // 册记录中的馆藏地点 #reservation何时消除?一个是现在就消除,一个是盘点模块扫描条码时消除。

                // 把记录状态修改为 outofreservation
                DomUtil.SetElementText(queue_rec_dom.DocumentElement,
                    "state",
                    "outof");

                // channel = channels.GetChannel(this.WsUrl);

                string strOutputPath = "";
                lRet = channel.DoSaveTextRes(strQueueRecPath,
                    queue_rec_dom.OuterXml,
                    false,
                    "content,ignorechecktimestamp",
                    baQueueRecTimeStamp,
                    out output_timestamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    strError = "写回预约到书记录 '" + strQueueRecPath + "' 时发生错误: " + strError;
                    return -1;
                }

                // TODO: 通知馆员进行上架操作
                // 可以在系统某目录不断追加到一个文本文件,工作人员可以查对。
                // 格式:每行 册条码号 最后一个预约的读者证条码号
                if (String.IsNullOrEmpty(this.StatisDir) == false)
                {
                    string strLogFileName = this.StatisDir + "\\outof_reservation_" + Statis.GetCurrentDate() + ".txt";
                    StreamUtil.WriteText(strLogFileName, strItemBarcode + " " + strReaderBarcode + "\r\n");
                }

                return 1;
            }

            // 4) 删除当前通知记录

            // 2007/7/5 
            bool bAlreadeDeleted = false;
            if (DeletedNotifyRecPaths != null)
            {
                if (DeletedNotifyRecPaths.IndexOf(strQueueRecPath) != -1)
                    bAlreadeDeleted = true;
            }

            if (bAlreadeDeleted == false)
            {
                lRet = channel.DoDeleteRes(
                    strQueueRecPath,
                    baQueueRecTimeStamp,
                    out output_timestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "DoNotifyNext()删除通知记录 '" + strQueueRecPath + "' 时失败: " + strError;
                    return -1;
                }
            }

            return 0;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppReservation.cs

示例5: CopyBiblioChildItems


//.........这里部分代码省略.........
                        goto ERROR1;
                    }
                    DomUtil.SetElementText(dom.DocumentElement,
                        "parent",
                        strParentID);

                    // 复制的情况
                    if (strAction == "copy")
                    {
                        // 避免refID重复
                        DomUtil.SetElementText(dom.DocumentElement,
                            "refID",
                            null);
                    }

                    long lRet = channel.DoCopyRecord(info.RecPath,
                         strTargetItemDbName + "/?",
                         strAction == "move" ? true : false,   // bDeleteSourceRecord
                         out output_timestamp,
                         out strOutputRecPath,
                         out strError);
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == ChannelErrorCode.NotFound)
                            continue;
                        strError = "复制" + this.ItemName + "记录 '" + info.RecPath + "' 时发生错误: " + strError;
                        goto ERROR1;
                    }

                    // 2011/5/24
                    // 修改xml记录。<parent>元素发生了变化
                    byte[] baOutputTimestamp = null;
                    string strOutputRecPath1 = "";
                    lRet = channel.DoSaveTextRes(strOutputRecPath,
                        dom.OuterXml,
                        false,
                        "content", // ,ignorechecktimestamp
                        output_timestamp,
                        out baOutputTimestamp,
                        out strOutputRecPath1,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                    oldrecordpaths.Add(info.RecPath);
                    newrecordpaths.Add(strOutputRecPath);
                }
                finally
                {
                    // this.EntityLocks.UnlockForWrite(info.ItemBarcode);
                }

                // 增补到日志DOM中
                if (domOperLog != null)
                {
                    Debug.Assert(root != null, "");

                    XmlNode node = domOperLog.CreateElement("record");
                    root.AppendChild(node);

                    DomUtil.SetAttr(node, "recPath", info.RecPath);
                    DomUtil.SetAttr(node, "targetRecPath", strOutputRecPath);
                }

                nOperCount++;
            }
开发者ID:paopaofeng,项目名称:dp2,代码行数:67,代码来源:ItemDatabase.cs

示例6: DoOverwriteXmlRecord

        // 覆盖一条XML记录
        int DoOverwriteXmlRecord(
            bool bFastMode,
            string strRecFullPath,
            string strXmlBody,
            byte[] timestamp,
            out string strError)
        {
            strError = "";

            ResPath respath = new ResPath(strRecFullPath);

            RmsChannel channelSave = channel;

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

            try
            {

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

            REDOSAVE:

                // 保存Xml记录
                long lRet = channel.DoSaveTextRes(respath.Path,
                    strXmlBody,
                    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 = respath.Path;

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


                        DialogResult result = MessageDlg.Show(this,
                            "上载 '" + strDisplayRecPath
                            + " 时发现时间戳不匹配。详细情况如下:\r\n---\r\n"
                            + strError + "\r\n---\r\n\r\n是否以新时间戳强行上载?\r\n注:(是)强行上载 (否)忽略当前记录或资源上载,但继续后面的处理 (取消)中断整个批处理",
                            "dp2batch",
                            MessageBoxButtons.YesNoCancel,
                            MessageBoxDefaultButton.Button1,
                            ref this.bNotAskTimestampMismatchWhenOverwrite);
                        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;	// 中断整个处理
                        }
                    }

                    // 询问是否重试
                    DialogResult result1 = MessageBox.Show(this,
                        "上载 '" + respath.Path
                        + " 时发生错误。详细情况如下:\r\n---\r\n"
                        + strError + "\r\n---\r\n\r\n是否重试?\r\n注:(是)重试 (否)不重试,但继续后面的处理 (取消)中断整个批处理",
                        "dp2batch",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1);
                    if (result1 == DialogResult.Yes)
                        goto REDOSAVE;
                    if (result1 == DialogResult.No)
                        return 0;	// 继续作后面的资源


                    goto ERROR1;
                }
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:MainForm.cs

示例7: DoReservationNotify


//.........这里部分代码省略.........
                        // return:
                        //      -1  error
                        //      0   没有修改
                        //      1   进行过修改
                        nRet = DoItemReturnReservationCheck(
                            bOnShelf,   // 当册现在还在架上的时候,册记录的 <location> 就没有 #reservation。这样在借书环节检查册是否被预约的时候,就不能只看 <location> 了
                            ref itemdom,
                            out strTempReservationReaderBarcode,
                            out strError);
                        if (nRet == -1)
                        {
                            strError = "修改册记录'" + strBarcode + "' 预约到书状态时(DoItemReturnReservationCheck)发生错误: " + strError;
                            return -1;
                        }
                        // 对册记录如果没有改动
                        if (nRet == 0)
                            continue;
                    }
                    else
                    {
                        // 如果是同一请求中的其他册记录

                        // 删除对应的<request>元素
                        XmlNode itemrequestnode = itemdom.DocumentElement.SelectSingleNode("reservations/request[@reader='" + strReservationReaderBarcode + "']");
                        if (itemrequestnode == null)
                            continue;

                        itemrequestnode.ParentNode.RemoveChild(itemrequestnode);
                    }

                    if (item_record == null)
                    {
                        // 写回册记录
                        lRet = channel.DoSaveTextRes(strOutputItemRecPath,
                            itemdom.OuterXml,
                            false,
                            "content,ignorechecktimestamp",
                            timestamp,
                            out output_timestamp,
                            out strOutputPath,
                            out strError);
                        if (lRet == -1)
                        {
                            strError = "写回册记录'" + strBarcode + "' (记录路径'" + strOutputItemRecPath + "')时发生错误: " + strError;
                            return -1;
                        }
                    }
                    else
                        item_record.Changed = true;

                } // end of for

                // 读者记录中为对应的<request>元素打上状态记号
                DomUtil.SetAttr(readerRequestNode, "state", "arrived");
                // 到达时间
                DomUtil.SetAttr(readerRequestNode, "arrivedDate", this.Clock.GetClock());
                // 实际到达的一个册条码号 2007/1/18 
                DomUtil.SetAttr(readerRequestNode, "arrivedItemBarcode", strItemBarcodeParam);

                if (reader_record == null)
                {
                    // 写回读者记录
                    lRet = channel.DoSaveTextRes(strOutputReaderRecPath,
                        readerdom.OuterXml,
                        false,
                        "content,ignorechecktimestamp",
开发者ID:renyh1013,项目名称:dp2,代码行数:67,代码来源:AppReservation.cs

示例8: SettlementOneRecord


//.........这里部分代码省略.........

                // 清除两个信息
                DomUtil.DeleteElement(amerced_dom.DocumentElement,
                    "undoSettlementOperTime");
                DomUtil.DeleteElement(amerced_dom.DocumentElement,
                    "undoSettlementOperator");


                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "settlementOperTime", strOperTime);
                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "settlementOperator", strOperator);
            }
            else
            {
                Debug.Assert(strAction == "undosettlement", "");

                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "state", "amerced");


                // 清除两个信息
                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "settlementOperTime", "");
                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "settlementOperator", "");


                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "undoSettlementOperTime", strOperTime);
                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "undoSettlementOperator", strOperator);

            }

            if (bCreateOperLog == true)
            {
                DomUtil.SetElementText(domOperLog.DocumentElement, "operator",
                    strOperator);   // 操作者
                DomUtil.SetElementText(domOperLog.DocumentElement, "operTime",
                    strOperTime);   // 操作时间
            }


            // 保存回数据库
            lRet = channel.DoSaveTextRes(strAmercedRecPath,
                amerced_dom.OuterXml,
                false,
                "content", // ?????,ignorechecktimestamp
                amerced_timestamp,
                out output_timestamp,
                out strOutputPath,
                out strError);
            if (lRet == -1)
            {
                strError = "写回违约金记录 '" + strAmercedRecPath + "' 时出错: " + strError;
                return -1;
            }

            if (bCreateOperLog == true)
            {
                // amerceRecord
                XmlNode nodeAmerceRecord = DomUtil.SetElementText(domOperLog.DocumentElement,
                    "amerceRecord", amerced_dom.OuterXml);
                DomUtil.SetAttr(nodeAmerceRecord, "recPath", strAmercedRecPath);
            }


        END1:
            if (bCreateOperLog == true)
            {
                if (this.Statis != null)
                {
                    if (strAction == "settlement")
                        this.Statis.IncreaseEntryValue(
                            strLibraryCode,
                            "费用结算", "结算记录数", 1);
                    else if (strAction == "undosettlement")
                        this.Statis.IncreaseEntryValue(
                            strLibraryCode,
                            "费用结算", "撤销结算记录数", 1);
                    else if (strAction == "delete")
                        this.Statis.IncreaseEntryValue(
                            strLibraryCode,
                            "费用结算", "删除结算记录数", 1);
                }


                nRet = this.OperLog.WriteOperLog(domOperLog,
                    strClientAddress,
                    out strError);
                if (nRet == -1)
                {
                    strError = "settlement() API 写入日志时发生错误: " + strError;
                    return -2;
                }
            }

            return 0;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppCirculation.cs

示例9: UndoBorrowReaderRecord

        // Borrow()下级函数
        // 撤销已经写入读者记录的借阅信息
        // 如果记录已经不存在?是否需要用读者证条码号再查出新位置的读者记录来?
        // 因为没有借阅信息的读者记录,确实可能被另外的用户移动位置。
        // parameters:
        //      strReaderRecPath    读者记录路径
        //      strReaderBarcode    读者证条码号。若需要检查记录,看看里面条码号是否已经变化了,就使用这个参数。如果不想检查,就用null
        //      strItemBarcode  已经借的册条码号
        // return:
        //      -1  error
        //      0   没有必要Undo
        //      1   Undo成功
        int UndoBorrowReaderRecord(
            RmsChannel channel,
            string strReaderRecPath,
            string strReaderBarcode,
            string strItemBarcode,
            out string strError)
        {
            strError = "";
            long lRet = 0;
            int nRet = 0;

            string strMetaData = "";
            byte[] reader_timestamp = null;
            string strOutputPath = "";

            string strReaderXml = "";

            int nRedoCount = 0;

        REDO:

            lRet = channel.GetRes(strReaderRecPath,
    out strReaderXml,
    out strMetaData,
    out reader_timestamp,
    out strOutputPath,
    out strError);
            if (lRet == -1)
            {
                strError = "读出原记录 '" + strReaderRecPath + "' 时出错";
                return -1;
            }

            XmlDocument readerdom = null;
            nRet = LibraryApplication.LoadToDom(strReaderXml,
                out readerdom,
                out strError);
            if (nRet == -1)
            {
                strError = "装载库中读者记录 '" + strReaderRecPath + "' 进入XML DOM时发生错误: " + strError;
                return -1;
            }

            // 检查读者证条码号字段 是否发生变化
            if (String.IsNullOrEmpty(strReaderBarcode) == false)
            {
                string strReaderBarcodeContent = DomUtil.GetElementText(readerdom.DocumentElement,
                    "barcode");
                if (strReaderBarcode != strReaderBarcodeContent)
                {
                    strError = "发现从数据库中读出的读者记录 '" + strReaderRecPath + "' ,其<barcode>字段内容 '" + strReaderBarcodeContent + "' 和要Undo的读者记录证条码号 '" + strReaderBarcode + "' 已不同。";
                    return -1;
                }
            }

            // 去除dom中表示借阅的节点
            XmlNode node = readerdom.DocumentElement.SelectSingleNode("borrows/borrow[@barcode='" + strItemBarcode + "']");
            if (node == null)
                return 0;   // 已经没有必要Undo了

            node.ParentNode.RemoveChild(node);

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

            // 写回读者记录
            lRet = channel.DoSaveTextRes(strReaderRecPath,
                readerdom.OuterXml,
                false,
                "content",  // ,ignorechecktimestamp
                reader_timestamp,
                out output_timestamp,
                out strOutputPath,
                out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    nRedoCount++;
                    if (nRedoCount > 10)
                    {
                        strError = "写回读者记录的时候发生时间戳冲突,并且已经重试10次,仍发生错误,只好停止重试";
                        return -1;
                    }
                    goto REDO;
                }

                strError = "写回读者记录的时候发生错误" + strError;
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppCirculation.cs

示例10: ClearArrivedInfo


//.........这里部分代码省略.........
                else
                    readerdom = reader_record.Dom;

                // 从当前读者记录中删除有关字段
                XmlNodeList nodes = readerdom.DocumentElement.SelectNodes("reservations/request");
                XmlNode readerRequestNode = null;
                string strItems = "";
                bool bFound = false;
                for (int i = 0; i < nodes.Count; i++)
                {
                    readerRequestNode = nodes[i];
                    strItems = DomUtil.GetAttr(readerRequestNode, "items");
                    if (IsInBarcodeList(strItemBarcode, strItems) == true)
                    {
                        bFound = true;
                        break;
                    }
                }

                if (bFound == true)
                {
                    Debug.Assert(readerRequestNode != null, "");

                    // 是清除,还是修改状态标记并保留一段?
                    // 现在是清除。如果能同时写入日志最好,以便将来查询
                    readerRequestNode.ParentNode.RemoveChild(readerRequestNode);
                }

                // 写回读者记录
                if (bFound == true)
                {
                    if (reader_record == null)
                    {
                        lRet = channel.DoSaveTextRes(strOutputReaderRecPath,
                            readerdom.OuterXml,
                            false,
                            "content,ignorechecktimestamp",
                            timestamp,
                            out output_timestamp,
                            out strOutputPath,
                            out strError);
                        if (lRet == -1)
                        {
                            strError = "写回读者记录 '" + strOutputReaderRecPath + "' 时发生错误 : " + strError;
                            return -1;
                        }
                    }
                    else
                    {
                        reader_record.Changed = true;
                    }
                }

            DOITEM:
                // 顺便获得下一个预约读者证条码号
                string strItemXml = "";
                string strOutputItemRecPath = "";
                // 获得册记录
                // return:
                //      -1  error
                //      0   not found
                //      1   命中1条
                //      >1  命中多于1条
                nRet = this.GetItemRecXml(
                    channel,
                    strItemBarcode,
开发者ID:renyh1013,项目名称:dp2,代码行数:67,代码来源:AppCirculation.cs

示例11: ChangeEntityBorrower


//.........这里部分代码省略.........

                string strBorrower = DomUtil.GetElementText(itemdom.DocumentElement,
                    "borrower");

                if (String.IsNullOrEmpty(strBorrower) == true)
                {
                    strError = "实体记录中没有借者信息(<borrower>元素内容)";
                    goto ERROR1;
                }

                // 核对旧读者证条码号
                if (strBorrower != strOldReaderBarcode)
                {
                    strError = "实体记录中,已有借者证条码号 '" + strBorrower + "' 和期望的改前证条码号 '" + strOldReaderBarcode + "' 不一致...";
                    goto ERROR1;
                }

                // 修改为新读者证条码号
                DomUtil.SetElementText(itemdom.DocumentElement,
                    "borrower",
                    strNewReaderBarcode);

                // 加上一个注释
                DomUtil.SetElementText(itemdom.DocumentElement,
                    "devolveComment",
                    "本册原为读者 " + strOldReaderBarcode + " 所借阅,后于 "
                    + strOperTimeString + " 被转移到读者 " + strNewReaderBarcode + " 名下");

#if NO
                if (channel == null)
                {
                    channel = Channels.GetChannel(this.WsUrl);
                    if (channel == null)
                    {
                        strError = "get channel error";
                        goto ERROR1;
                    }
                }
#endif

                // 保存实体记录
                byte[] output_timestamp = null;
                string strOutputPath = "";

                lRet = channel.DoSaveTextRes(strOutputItemRecPath,
                    itemdom.OuterXml,
                    false,
                    "content",  // ,ignorechecktimestamp
                    item_timestamp,
                    out output_timestamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                    {
                        if (nRedoCount > 10)
                            goto ERROR1;
                        nRedoCount++;
                        item_timestamp = output_timestamp;
                        goto REDO;
                    }
                }

                // 将保存了的记录写入日志
                if (domOperLog != null)
                {
                    XmlNode nodeLogRecord = domOperLog.CreateElement("changedEntityRecord");
                    domOperLog.DocumentElement.AppendChild(nodeLogRecord);
                    DomUtil.SetAttr(nodeLogRecord, "recPath", strOutputPath);

                    if (attachment == null)
                    {
                        // 实体记录完全保存到日志记录中
                        nodeLogRecord.InnerText = itemdom.OuterXml;
                    }
                    else
                    {
                        // 实体记录保存到附件中,只在日志记录中留下序号

                        // 保存附件序号
                        DomUtil.SetAttr(nodeLogRecord, "attachmentIndex", nAttachmentIndex.ToString());

                        byte[] content = Encoding.UTF8.GetBytes(itemdom.OuterXml);
                        byte[] length = BitConverter.GetBytes((long)content.LongLength);
                        attachment.Write(length, 0, length.Length);
                        attachment.Write(content, 0, content.Length);

                        nAttachmentIndex++;
                    }
                }
            }
            finally
            {
                this.EntityLocks.UnlockForWrite(strEntityBarcode);
            }
            return 1;
        ERROR1:
            return -1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppCirculation.cs

示例12: CreateAmerceRecords

        // 在违约金数据库中创建若干新的违约金记录
        // parameters:
        //      AmerceRecordXmls    需要写入的新记录的数组
        //      CreatedNewPaths 已经创建的新记录的路径数组。可以用于Undo(删除刚刚创建的新记录)
        int CreateAmerceRecords(
            // RmsChannelCollection channels,
            RmsChannel channel,
            List<string> AmerceRecordXmls,
            out List<string> CreatedNewPaths,
            out string strError)
        {
            strError = "";
            CreatedNewPaths = new List<string>();
            long lRet = 0;

            if (string.IsNullOrEmpty(this.AmerceDbName) == true)
            {
                strError = "尚未配置违约金库名";
                return -1;
            }

#if NO
            RmsChannel channel = channels.GetChannel(this.WsUrl);
            if (channel == null)
            {
                strError = "get channel error";
                return -1;
            }
#endif

            for (int i = 0; i < AmerceRecordXmls.Count; i++)
            {
                string strXml = AmerceRecordXmls[i];

                string strPath = this.AmerceDbName + "/?";

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

                // 写新记录
                lRet = channel.DoSaveTextRes(
                    strPath,
                    strXml,
                    false,
                    "content,ignorechecktimestamp",
                    timestamp,
                    out output_timestamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                    return -1;

                CreatedNewPaths.Add(strOutputPath);
            }

            return 0;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:58,代码来源:AppCirculation.cs

示例13: AddNotifyRecordToQueue


//.........这里部分代码省略.........
            {
                if (string.IsNullOrEmpty(strItemBarcode) == true)
                {
                    if (string.IsNullOrEmpty(strRefID) == true)
                    {
                        strError = "AddNotifyRecordToQueue() 函数当 strItemBarcode 参数为空的时候,必须让 strRefID 参数不为空";
                        return -1;
                    }

                    Debug.Assert(string.IsNullOrEmpty(strRefID) == false, "");
                    // 旧的用法。避免检索时候查不到
                    DomUtil.SetElementText(new_queue_dom.DocumentElement, "itemBarcode", "@refID:" + strRefID);
                }
                else
                    DomUtil.SetElementText(new_queue_dom.DocumentElement, "itemBarcode", strItemBarcode); // 2015/5/20 添加,修正 BUG
            }

            // 改为存储在元素中 2015/5/7
            if (bOnShelf == true)
                DomUtil.SetElementText(new_queue_dom.DocumentElement, "onShelf", "true");

            // 2012/10/26
            DomUtil.SetElementText(new_queue_dom.DocumentElement, "libraryCode", strLibraryCode);

            DomUtil.SetElementText(new_queue_dom.DocumentElement, "readerBarcode", strReaderBarcode);
            DomUtil.SetElementText(new_queue_dom.DocumentElement, "notifyDate", this.Clock.GetClock());

            // 2015/6/13
            DomUtil.SetElementText(new_queue_dom.DocumentElement, "location", strLocation);

            string strPath = this.ArrivedDbName + "/?";

            // 写新记录
            lRet = channel.DoSaveTextRes(
                strPath,
                new_queue_dom.OuterXml,
                false,
                "content,ignorechecktimestamp",
                timestamp,
                out output_timestamp,
                out strOutputPath,
                out strError);
            if (lRet == -1)
            {
                // 写入错误日志 2007/1/3 
                this.WriteErrorLog("创建新的预约到书队列记录时出错: " + strError);
                return -1;
            }

            string strReaderEmailAddress = "";
            string strName = "";
            nRet = GetReaderNotifyInfo(
                strReaderXml,
                out strName,
                out strReaderEmailAddress,
                out strError);
            if (nRet == -1)
                return -1;

            // 获得图书摘要信息
            string strSummary = "";
            string strBiblioRecPath = "";

            nRet = this.GetBiblioSummary(strItemBarcode,
                "", //  strConfirmItemRecPath,
                null,   //  strBiblioRecPathExclude,
开发者ID:paopaofeng,项目名称:dp2,代码行数:67,代码来源:AppReservation.cs

示例14: WriteOneXmlRecord

        // 写入一条 XML 记录
        // return:
        //      -1  出错
        //      0   邀请中断整个处理
        //      1   成功
        //      2   跳过本条,继续处理后面的
        public static int WriteOneXmlRecord(
            IWin32Window owner,
            Stop stop,
            RmsChannel channel,
            UploadRecord record,
            ref bool bDontPromptTimestampMismatchWhenOverwrite,
            out string strError)
        {
            strError = "";

            string strWarning = "";

            // 询问库名映射关系

            string strTargetPath = record.RecordBody.Path;
            byte[] output_timestamp = null;
            string strOutputPath = "";
        REDOSAVE:
            // 保存Xml记录
            long lRet = channel.DoSaveTextRes(strTargetPath,
                record.RecordBody.Xml,
                false,	// bIncludePreamble
                "", //     bFastMode == true ? "fastmode" : "",//strStyle,
                record.RecordBody.Timestamp,
                out output_timestamp,
                out strOutputPath,
                out strError);
            if (lRet == -1)
                return -1;
            if (lRet == -1)
            {
                if (stop != null)
                    stop.Continue();

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

                    if (bDontPromptTimestampMismatchWhenOverwrite == true)
                    {
                        record.RecordBody.Timestamp = output_timestamp;
                        strWarning = " (时间戳不匹配, 自动重试)";
                        // TODO: 如何防止死循环?
                        goto REDOSAVE;
                    }

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

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

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

                // 询问是否重试
                {
                    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(owner,
                        strText,
                        "dp2batch",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1);
                    //WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                    if (result1 == DialogResult.Yes)
                        goto REDOSAVE;
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:ImportUtil.cs

示例15: AddReaderOutOfReservationInfo

        // 给读者记录里加上预约到书后超期不取的状态
        int AddReaderOutOfReservationInfo(
            // RmsChannelCollection channels,
            RmsChannel channel,
            string strReaderBarcode,
            string strItemBarcode,
            string strNotifyDate,
            out string strError)
        {
            strError = "";
            int nRet = 0;
            long lRet = 0;

            int nRedoCount = 0;

        REDO_MEMO:
            // 加读者记录锁
#if DEBUG_LOCK_READER
            this.App.WriteErrorLog("AddReaderOutOfReservationInfo 开始为读者加写锁 '" + strReaderBarcode + "'");
#endif
            this.App.ReaderLocks.LockForWrite(strReaderBarcode);

            try // 读者记录锁定范围开始
            {

                // 读入读者记录
                string strReaderXml = "";
                string strOutputReaderRecPath = "";
                byte[] reader_timestamp = null;
                nRet = this.App.GetReaderRecXml(
                    // channels,
                    channel,
                    strReaderBarcode,
                    out strReaderXml,
                    out strOutputReaderRecPath,
                    out reader_timestamp,
                    out strError);
                if (nRet == 0)
                {
                    strError = "读者证条码号 '" + strReaderBarcode + "' 不存在";
                    return -1;
                }
                if (nRet == -1)
                {
                    strError = "读入读者记录时发生错误: " + strError;
                    return -1;
                }

                XmlDocument readerdom = null;
                nRet = LibraryApplication.LoadToDom(strReaderXml,
                    out readerdom,
                    out strError);
                if (nRet == -1)
                {
                    strError = "装载读者记录进入XML DOM时发生错误: " + strError;
                    return -1;
                }

                XmlNode root = readerdom.DocumentElement.SelectSingleNode("outofReservations");
                if (root == null)
                {
                    root = readerdom.CreateElement("outofReservations");
                    readerdom.DocumentElement.AppendChild(root);
                }

                // 累计次数
                string strCount = DomUtil.GetAttr(root, "count");
                if (String.IsNullOrEmpty(strCount) == true)
                    strCount = "0";
                int nCount = 0;
                try
                {
                    nCount = Convert.ToInt32(strCount);
                }
                catch
                {
                }
                nCount++;
                DomUtil.SetAttr(root, "count", nCount.ToString());

                // 追加<request>元素
                XmlNode request = readerdom.CreateElement("request");
                root.AppendChild(request);
                DomUtil.SetAttr(request, "itemBarcode", strItemBarcode);
                DomUtil.SetAttr(request, "notifyDate", strNotifyDate);

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

#if NO
                RmsChannel channel = channels.GetChannel(this.App.WsUrl);
                if (channel == null)
                {
                    strError = "get channel error";
                    return -1;
                }
#endif

                // 写回读者记录
                lRet = channel.DoSaveTextRes(strOutputReaderRecPath,
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:ArriveMonitor.cs


注:本文中的DigitalPlatform.rms.Client.RmsChannel.DoSaveTextRes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。