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


C# RmsChannel.DoDeleteRes方法代码示例

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


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

示例1: DoOperDelete


//.........这里部分代码省略.........
                    domExist,
                    out strError);
                if (nRet != 1)
                    goto ERROR1;
            }


            // 比较时间戳
            // 观察时间戳是否发生变化
            nRet = ByteArray.Compare(info.OldTimestamp, exist_timestamp);
            if (nRet != 0)
            {
                // 2008/10/19
                if (bForce == true)
                {
                    error = new EntityInfo(info);
                    error.NewTimestamp = exist_timestamp;   // 让前端知道库中记录实际上发生过变化
                    error.ErrorInfo = "数据库中即将删除的册记录已经发生了变化,请重新装载、仔细核对后再行删除。";
                    error.ErrorCode = ErrorCodeValue.TimestampMismatch;
                    ErrorInfos.Add(error);
                    return -1;
                }

                // 如果前端给出了旧记录,就有和库中记录进行比较的基础
                if (String.IsNullOrEmpty(info.OldRecord) == false)
                {
                    // 比较两个记录, 看看和事项要害信息有关的字段是否发生了变化
                    // return:
                    //      0   没有变化
                    //      1   有变化
                    nRet = IsItemInfoChanged(domExist,
                        domOldRec);
                    if (nRet == 1)
                    {

                        error = new EntityInfo(info);
                        error.NewTimestamp = exist_timestamp;   // 让前端知道库中记录实际上发生过变化
                        error.ErrorInfo = "数据库中即将删除的" + this.ItemName + "记录已经发生了变化,请重新装载、仔细核对后再行删除。";
                        error.ErrorCode = ErrorCodeValue.TimestampMismatch;
                        ErrorInfos.Add(error);
                        return -1;
                    }
                }

                info.OldTimestamp = exist_timestamp;
                info.NewTimestamp = exist_timestamp;
            }

            byte[] output_timestamp = null;

            lRet = channel.DoDeleteRes(info.NewRecPath,
                info.OldTimestamp,
                out output_timestamp,
                out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    if (nRedoCount > 10)
                    {
                        strError = "反复删除均遇到时间戳冲突, 超过10次重试仍然失败";
                        goto ERROR1;
                    }
                    // 发现时间戳不匹配
                    // 重复进行提取已存在记录\比较的过程
                    nRedoCount++;
                    goto REDOLOAD;
                }

                error = new EntityInfo(info);
                error.NewTimestamp = output_timestamp;
                error.ErrorInfo = "删除操作发生错误:" + strError;
                error.ErrorCode = channel.OriginErrorCode;
                ErrorInfos.Add(error);
                return -1;
            }
            else
            {
                // 成功
                DomUtil.SetElementText(domOperLog.DocumentElement, "action", "delete");

                // 不创建<record>元素

                // 创建<oldRecord>元素
                XmlNode node = DomUtil.SetElementText(domOperLog.DocumentElement,
                    "oldRecord", strExistingXml);
                DomUtil.SetAttr(node, "recPath", info.NewRecPath);


                // 如果删除成功,则不必要在数组中返回表示成功的信息元素了
            }

            return 0;
        ERROR1:
            error = new EntityInfo(info);
            error.ErrorInfo = strError;
            error.ErrorCode = ErrorCodeValue.CommonError;
            ErrorInfos.Add(error);
            return -1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ItemDatabase.cs

示例2: DeleteRecord

		// 删除记录
		// parameters:
		//		strRecordPath	记录路径。如果==null,表示直接用textBox_recPath中当前的内容作为路径
		public void DeleteRecord(string strRecordPath)
		{
			if (strRecordPath != null)
				textBox_recPath.Text = strRecordPath;

			if (textBox_recPath.Text == "")
			{
				MessageBox.Show(this, "路径不能为空");
				return;
			}

			ResPath respath = new ResPath(textBox_recPath.Text);

			Uri uri = null;
			try 
			{
				uri = new Uri(respath.Url);
			}
			catch (Exception ex)
			{
				MessageBox.Show(this, "路径错误: " + ex.Message);
				return;
			}			// 保存到文件
			if (uri.IsFile)
			{
				MessageBox.Show(this, "暂时不支持删除文件");
				return;
			}


			string strText = "你确实要删除位于服务器 '"+respath.Url+"' 上的记录 '"+respath.Path + "' 吗?";

			DialogResult msgResult = MessageBox.Show(this,
				strText,
				"dp2rms",
				MessageBoxButtons.OKCancel,
				MessageBoxIcon.Question,
				MessageBoxDefaultButton.Button2);
				
			if (msgResult != DialogResult.OK) 
			{
				MessageBox.Show(this, "删除操作被放弃...");
				return;
			}

			string strError;
			byte [] baOutputTimeStamp = null;

			// 使用Channel
			RmsChannel channelSave = channel;

			channel = Channels.GetChannel(respath.Url);
			Debug.Assert(channel != null, "Channels.GetChannel 异常");

			try 
			{

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在删除记录 " + respath.FullPath);
				stop.BeginLoop();


				EnableControlsInLoading(true);

				long lRet = channel.DoDeleteRes(respath.Path,
					this.TimeStamp,
					out baOutputTimeStamp,
					out strError);

				EnableControlsInLoading(false);

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

				if (lRet == -1) 
				{
					MessageBox.Show(this, "删除记录 '"+respath.Path+"' 失败,原因: "+strError);
					return;
				}

			}
			finally
			{
				channel = channelSave;
			}



			// 如果删除成功,原来时间戳遗留在this.TimeStamp中,也无害

			MessageBox.Show(this, "删除记录 '" + respath.FullPath + "' 成功。");

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

示例3: CopyBiblioChildItems


//.........这里部分代码省略.........
                        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++;
            }


            return nOperCount;
        ERROR1:
            // Undo已经进行过的操作
            if (strAction == "copy")
            {
                string strWarning = "";

                foreach (string strRecPath in newrecordpaths)
                {
                    string strTempError = "";
                    byte[] timestamp = null;
                    byte[] output_timestamp = null;
                REDO_DELETE:
                    long lRet = channel.DoDeleteRes(strRecPath,
                        timestamp,
                        out output_timestamp,
                        out strTempError);
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                        {
                            if (timestamp == null)
                            {
                                timestamp = output_timestamp;
                                goto REDO_DELETE;
                            }
                        }
                        strWarning += strTempError + ";";
                    }

                }
                if (string.IsNullOrEmpty(strWarning) == false)
                    strError = strError + "。在Undo过程中,又遇到出错: " + strWarning;
            }
            else if (strAction == "move")
            {
                string strWarning = "";
                for (int i = 0; i < newrecordpaths.Count; i++)
                {
                    byte[] output_timestamp = null;
                    string strOutputRecPath = "";
                    string strTempError = "";
                    long lRet = channel.DoCopyRecord(newrecordpaths[i],
         oldrecordpaths[i],
         true,   // bDeleteSourceRecord
         out output_timestamp,
         out strOutputRecPath,
         out strTempError);
                    if (lRet == -1)
                    {
                        strWarning += strTempError + ";";
                    }
                }
                if (string.IsNullOrEmpty(strWarning) == false)
                    strError = strError + "。在Undo过程中,又遇到出错: " + strWarning;
            }
            return -1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ItemDatabase.cs

示例4: DeleteBiblioChildItems

        // 删除属于同一书目记录的全部实体记录
        // 这是需要提供EntityInfo数组的版本
        // return:
        //      -1  error
        //      0   没有找到属于书目记录的任何实体记录,因此也就无从删除
        //      >0  实际删除的实体记录数
        public int DeleteBiblioChildItems(
            // RmsChannelCollection Channels,
            RmsChannel channel,
            List<DeleteEntityInfo> entityinfos,
            XmlDocument domOperLog,
            out string strError)
        {
            strError = "";

            if (entityinfos == null || entityinfos.Count == 0)
                return 0;

            int nDeletedCount = 0;

            XmlNode root = null;

            if (domOperLog != null)
            {
                root = domOperLog.CreateElement("deleted"+this.ItemNameInternal+"Records");
                domOperLog.DocumentElement.AppendChild(root);
            }

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

            // 真正实行删除
            for (int i = 0; i < entityinfos.Count; i++)
            {
                DeleteEntityInfo info = entityinfos[i];

                byte[] output_timestamp = null;
                int nRedoCount = 0;

            REDO_DELETE:

                // this.EntityLocks.LockForWrite(info.ItemBarcode);
                try
                {

                    long lRet = channel.DoDeleteRes(info.RecPath,
                        info.OldTimestamp,
                        out output_timestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == ChannelErrorCode.NotFound)
                            continue;

                        // 如果不重试,让时间戳出错暴露出来。
                        // 如果要重试,也得加上重新读入册记录并判断重新判断无借还信息才能删除

                        if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                        {
                            if (nRedoCount > 10)
                            {
                                strError = "重试了10次还不行。删除"+this.ItemName+"记录 '" + info.RecPath + "' 时发生错误: " + strError;
                                goto ERROR1;
                            }
                            nRedoCount++;

                            // 重新读入记录
                            string strMetaData = "";
                            string strXml = "";
                            string strOutputPath = "";
                            string strError_1 = "";

                            lRet = channel.GetRes(info.RecPath,
                                out strXml,
                                out strMetaData,
                                out output_timestamp,
                                out strOutputPath,
                                out strError_1);
                            if (lRet == -1)
                            {
                                if (channel.ErrorCode == ChannelErrorCode.NotFound)
                                    continue;

                                strError = "在删除"+this.ItemName+"记录 '" + info.RecPath + "' 时发生时间戳冲突,于是自动重新获取记录,但又发生错误: " + strError_1;
                                goto ERROR1;
                                // goto CONTINUE;
                            }

                            // 检查是否有借阅信息
                            // 把记录装入DOM
                            XmlDocument domExist = new XmlDocument();

                            try
                            {
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:ItemDatabase.cs

示例5: AddNotifyRecordToQueueDatabase

        // TODO: 各个环节要改为尽量使用 refID。要做大量测试
        // text-level: 内部处理
        // 在 预约到书 库中,追加一条新的记录,并作 email / dpmail / mq 通知
        // 注:本函数可能要删除部分通知记录
        // parameters:
        //      strItemBarcode  册条码号。必须是册条码号。如果册条码号为空,参考ID需要使用 strRefID 参数
        //      strRefID        参考ID
        //      bOnShelf    要通知的册是否在架。在架指并没有人借阅过,本来就在书架上。
        //      strLibraryCode  读者所在的馆代码
        //      strReaderXml    预约了图书的读者的XML记录。用于消息通知接口
        int AddNotifyRecordToQueueDatabase(
            // RmsChannelCollection channels,
            RmsChannel channel,
            string strItemBarcodeParam,
            string strRefIDParam,
            string strItemXml,
            bool bOnShelf,
            string strLibraryCode,
            string strReaderBarcode,
            string strReaderXml,
            out List<string> DeletedNotifyRecPaths,
            out string strError)
        {
            strError = "";
            DeletedNotifyRecPaths = new List<string>();

            // 2010/12/31
            if (String.IsNullOrEmpty(this.ArrivedDbName) == true)
            {
                strError = "预约到书库尚未定义, AddNotifyRecordToQueue()调用失败";
                return -1;
            }

            // 准备写记录
            byte[] timestamp = null;
            byte[] output_timestamp = null;
            string strOutputPath = "";
            int nRet = 0;
            long lRet = 0;

            if (String.IsNullOrEmpty(strItemBarcodeParam) == true)
            {
                // 如果检索用的册条码号为空,加上对命中结果数量不设限,那就会造成系统严重繁忙。
                strError = "参数strItemBarcode中的册条码号不能为空。";
                return -1;
            }

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

        REDODELETE:
            // 如果队列中已经存在同册条码号的记录, 要先删除
            string strNotifyXml = "";
            // 获得预约到书队列记录
            // return:
            //      -1  error
            //      0   not found
            //      1   命中1条
            //      >1  命中多于1条
            nRet = GetArrivedQueueRecXml(
                // channels,
                channel,
                strItemBarcodeParam,
                out strNotifyXml,
                out timestamp,
                out strOutputPath,
                out strError);
            if (nRet == -1)
            {
                // 写入错误日志?
                this.WriteErrorLog("在还书操作中,检索册条码号为 " + strItemBarcodeParam + " 的预约到书库记录时出错: " + strError);
            }
            if (nRet >= 1)
            {
                int nRedoDeleteCount = 0;
            // TODO: 这一段删除代码可以专门编制在一个函数中,不必这么费力循环。可以优化处理
            REDO_DELETE:
                lRet = channel.DoDeleteRes(strOutputPath,
                    timestamp,
                    out output_timestamp,
                    out strError);
                if (lRet == -1)
                {
                    // 时间戳不匹配
                    if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch
                        && nRedoDeleteCount < 10)
                    {
                        nRedoDeleteCount++;
                        timestamp = output_timestamp;
                        goto REDO_DELETE;
                    }

                    // 写入错误日志?
                    this.WriteErrorLog("在还书操作中,加入新预约到书记录前, 删除已存在的预约到书库记录 '" + strOutputPath + "' 出错: " + strError);
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppReservation.cs

示例6: 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

示例7: SubmitLog


//.........这里部分代码省略.........
                            MessageBox.Show(this, strError);
                            strErrorText += strError + "\r\n";
                            // return -1;
                        }
                        else
                        {
                            // 如果创建成功,需要把队列中后面的所有即将操作相同对象的动作修改时间戳
                            // 刷新队列中制定位置以后的、针对某个对象的全部操作的时间戳
                            RefreshTimestamp(
                                i + 1,
                                strPath,
                                baOutputTimestamp);
                        }
                    }
                    finally
                    {
                        if (stream != null)
                            stream.Close();
                    }
                }
                if (objevent.Oper == ObjEventOper.Change)
                {
                    MemoryStream stream = null;
                    try
                    {
                        if (objevent.Obj.Type == ResTree.RESTYPE_FILE)
                            stream = new MemoryStream(objevent.Obj.Content);

                        string strPath = objevent.Path;
                        byte[] baOutputTimestamp = null;
                        nRet = NewServerSideObject(strPath,
                            objevent.Obj.Type,
                            stream,
                            objevent.Obj.TimeStamp,
                            out baOutputTimestamp,
                            out strError);
                        if (nRet == -1)
                        {
                            strError = "修改对象 '" + strPath + "' 时发生错误: " + strError;
                            MessageBox.Show(this, strError);
                            strErrorText += strError + "\r\n";
                        }
                        else
                        {
                            // 如果创建成功,需要把队列中后面的所有即将操作相同对象的动作修改时间戳
                            // 刷新队列中制定位置以后的、针对某个对象的全部操作的时间戳
                            RefreshTimestamp(
                                i + 1,
                                strPath,
                                baOutputTimestamp);
                        }
                    }
                    finally
                    {
                        if (stream != null)
                            stream.Close();
                    }

                }
                else if (objevent.Oper == ObjEventOper.Delete)
                {
                    // TODO: 现在已经有时间戳了,可以不必重试

                    this.channel = Channels.GetChannel(this.ServerUrl);

                    Debug.Assert(channel != null, "Channels.GetChannel() 异常");

                    byte[] baTimestamp = new byte[1];
                    byte[] baOutputTimestamp = null;
                    string strPath = objevent.Path;
                // string strOutputPath = "";
                REDO:
                    // 删除数据库对象
                    long lRet = channel.DoDeleteRes(strPath,
                        baTimestamp,
                        "",
                        out baOutputTimestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        // 时间戳不匹配
                        if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                        {
                            baTimestamp = baOutputTimestamp;
                            goto REDO;
                        }
                        strError = "删除对象 '" + strPath + "' 时发生错误: " + strError;
                        MessageBox.Show(this, strError);
                        strErrorText += strError + "\r\n";
                    }
                }

            }

            log.Clear();

            if (strErrorText == "")
                return 0;
            return -1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:DatabaseObjectTree.cs

示例8: DoExportFile


//.........这里部分代码省略.........
                                try
                                {
                                    dom.LoadXml(strXmlBody);

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


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

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

                            }
                        }

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

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

                        if (bFoundRecord == true)
                            m_nRecordCount++;


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


                        // 对已经作过的进行判断
                        if (bAsc == true && nCur >= nEnd)
开发者ID:renyh1013,项目名称:dp2,代码行数:67,代码来源:MainForm.cs

示例9: DoIssueOperDelete


//.........这里部分代码省略.........
            if (String.IsNullOrEmpty(strOldPublishTime) == false)
            {
                string strExistingPublishTime = DomUtil.GetElementText(domExist.DocumentElement,
                    "publishTime");
                if (strExistingPublishTime != strOldPublishTime)
                {
                    strError = "路径为 '" + info.NewRecPath + "' 的期记录中<publishTime>元素中的出版时间 '" + strExistingPublishTime + "' 和strOldXml中<publishTime>元素中的出版时间 '" + strOldPublishTime + "' 不一致。拒绝删除(如果允许删除,则会造成不经意删除了别的期记录的危险)。";
                    goto ERROR1;
                }
            }

            /*
            // 观察已经存在的记录是否有流通信息
            if (IsIssueHasCirculationInfo(domExist) == true)
            {
                strError = "拟删除的期记录 '" + info.NewRecPath + "' 中包含有流通信息,不能删除。";
                goto ERROR1;
            }*/

            // 比较时间戳
            // 观察时间戳是否发生变化
            nRet = ByteArray.Compare(info.OldTimestamp, exist_timestamp);
            if (nRet != 0)
            {
                // 如果前端给出了旧记录,就有和库中记录进行比较的基础
                if (String.IsNullOrEmpty(info.OldRecord) == false)
                {
                    // 比较两个记录, 看看和期要害信息有关的字段是否发生了变化
                    // return:
                    //      0   没有变化
                    //      1   有变化
                    nRet = IsIssueInfoChanged(domExist,
                        domOldRec);
                    if (nRet == 1)
                    {

                        error = new IssueInfo(info);
                        error.NewTimestamp = exist_timestamp;   // 让前端知道库中记录实际上发生过变化
                        error.ErrorInfo = "数据库中即将删除的期记录已经发生了变化,请重新装载、仔细核对后再行删除。";
                        error.ErrorCode = ErrorCodeValue.TimestampMismatch;
                        ErrorInfos.Add(error);
                        return -1;
                    }
                }

                info.OldTimestamp = exist_timestamp;
                info.NewTimestamp = exist_timestamp;
            }

            byte[] output_timestamp = null;

            lRet = channel.DoDeleteRes(info.NewRecPath,
                info.OldTimestamp,
                out output_timestamp,
                out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    if (nRedoCount > 10)
                    {
                        strError = "反复删除均遇到时间戳冲突, 超过10次重试仍然失败";
                        goto ERROR1;
                    }
                    // 发现时间戳不匹配
                    // 重复进行提取已存在记录\比较的过程
                    nRedoCount++;
                    goto REDOLOAD;
                }

                error = new IssueInfo(info);
                error.NewTimestamp = output_timestamp;
                error.ErrorInfo = "删除操作发生错误:" + strError;
                error.ErrorCode = channel.OriginErrorCode;
                ErrorInfos.Add(error);
                return -1;
            }
            else
            {
                // 成功
                DomUtil.SetElementText(domOperLog.DocumentElement, "action", "delete");

                // 不创建<record>元素

                XmlNode node = DomUtil.SetElementText(domOperLog.DocumentElement,
                    "oldRecord", strExistingXml);
                DomUtil.SetAttr(node, "recPath", info.NewRecPath);


                // 如果删除成功,则不必要在数组中返回表示成功的信息元素了
            }

            return 0;
        ERROR1:
            error = new IssueInfo(info);
            error.ErrorInfo = strError;
            error.ErrorCode = ErrorCodeValue.CommonError;
            ErrorInfos.Add(error);
            return -1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:AppIssue.cs

示例10: DoReaderOperDelete


//.........这里部分代码省略.........
                    nRet = IsReaderInfoChanged(
                        element_names,
                        domExist,
                        domOldRec);
                    if (nRet == 1)
                    {

                        strError = "数据库中即将删除的读者记录已经发生了变化,请重新装载、仔细核对后再行删除。";
                        kernel_errorcode = ErrorCodeValue.TimestampMismatch;

                        baNewTimestamp = exist_timestamp;   // 让前端知道库中记录实际上发生过变化
                        goto ERROR1;
                    }
                }

                baOldTimestamp = exist_timestamp;
                baNewTimestamp = exist_timestamp;   // 让前端知道库中记录实际上发生过变化
            }

            string strLibraryCode = "";
            // 观察一个读者记录路径,看看是不是在当前用户管辖的读者库范围内?
            if (this.IsCurrentChangeableReaderPath(strRecPath,
                strCurrentLibraryCode,
                out strLibraryCode) == false)
            {
                strError = "读者记录路径 '" + strRecPath + "' 的读者库不在当前用户管辖范围内";
                goto ERROR1;
            }

            byte[] output_timestamp = null;

            Debug.Assert(strRecPath != "", "");

            lRet = channel.DoDeleteRes(strRecPath,
                baOldTimestamp,
                out output_timestamp,
                out strError);
            if (lRet == -1)
            {
                // 2009/7/17 
                if (channel.ErrorCode == ChannelErrorCode.NotFound)
                {
                    strError = "证条码号为 '" + strOldBarcode + "' 的读者记录(在删除的时候发现)已不存在";
                    kernel_errorcode = ErrorCodeValue.NotFound;
                    return 0;
                }

                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    if (nRedoCount > 10)
                    {
                        strError = "反复删除均遇到时间戳冲突, 超过10次重试仍然失败";
                        baNewTimestamp = output_timestamp;
                        kernel_errorcode = channel.OriginErrorCode;
                        goto ERROR1;
                    }
                    // 发现时间戳不匹配
                    // 重复进行提取已存在记录\比较的过程
                    nRedoCount++;
                    goto REDOLOAD;
                }


                baNewTimestamp = output_timestamp;
                strError = "删除操作发生错误:" + strError;
                kernel_errorcode = channel.OriginErrorCode;
开发者ID:renyh1013,项目名称:dp2,代码行数:67,代码来源:AppReader.cs

示例11: SettlementOneRecord


//.........这里部分代码省略.........
                if (strOldState == "amerced")
                {
                    strError = "撤销结算操作前,记录状态已经为settlemented";
                    return -1;
                }
            }
            else if (strAction == "delete")
            {
                if (strOldState != "settlemented")
                {
                    strError = "删除结算操作前,记录状态必须为settlemented。(但发现为'" + strOldState + "')";
                    return -1;
                }
            }
            else
            {
                strError = "无法识别的strAction参数值 '" + strAction + "'";
                return -1;
            }

            byte[] output_timestamp = null;

            if (bCreateOperLog == true)
            {
                // oldAmerceRecord
                XmlNode nodeOldAmerceRecord = DomUtil.SetElementText(domOperLog.DocumentElement,
    "oldAmerceRecord", strAmercedXml);
                DomUtil.SetAttr(nodeOldAmerceRecord, "recPath", strAmercedRecPath);
            }

            if (strAction == "delete")
            {
                // 删除已结算违约金记录
                lRet = channel.DoDeleteRes(strAmercedRecPath,
                    amerced_timestamp,
                    out output_timestamp,
                    out strError);
                if (lRet == -1)
                {
                    if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch
                        && nRedoCount < 10)
                    {
                        nRedoCount++;
                        amerced_timestamp = output_timestamp;
                        goto REDO;
                    }
                    strError = "删除已结算违约金记录 '" + strAmercedRecPath + "' 失败: " + strError;
                    this.WriteErrorLog(strError);
                    return -1;
                }

                goto END1;  // 写日志
            }

            // 修改状态
            if (strAction == "settlement")
            {
                DomUtil.SetElementText(amerced_dom.DocumentElement,
                    "state", "settlemented");


                // 清除两个信息
                DomUtil.DeleteElement(amerced_dom.DocumentElement,
                    "undoSettlementOperTime");
                DomUtil.DeleteElement(amerced_dom.DocumentElement,
                    "undoSettlementOperator");
开发者ID:renyh1013,项目名称:dp2,代码行数:67,代码来源:AppCirculation.cs

示例12: AddNotifyRecordToQueue

        // text-level: 内部处理
        // 在 预约到书 库中,追加一条新的记录
        // 并作email通知
        // 注:本函数可能要删除部分通知记录
        // parameters:
        //      strItemBarcode  册条码号。必须是册条码号。如果册条码号为空,参考ID需要使用 strRefID 参数
        //      strRefID        参考ID
        //      bOnShelf    要通知的册是否在架。在架指并没有人借阅过,本来就在书架上。
        //      strLibraryCode  读者所在的馆代码
        //      strReaderXml    预约了图书的读者的XML记录。用于消息通知接口
        int AddNotifyRecordToQueue(
            // RmsChannelCollection channels,
            RmsChannel channel,
            string strItemBarcode,
            string strRefID,
            string strItemXml,
            bool bOnShelf,
            string strLibraryCode,
            string strReaderBarcode,
            string strReaderXml,
            out List<string> DeletedNotifyRecPaths,
            out string strError)
        {
            strError = "";
            DeletedNotifyRecPaths = new List<string>();
            
            // 2010/12/31
            if (String.IsNullOrEmpty(this.ArrivedDbName) == true)
            {
                strError = "预约到书库尚未定义, AddNotifyRecordToQueue()调用失败";
                return -1;
            }

            // 准备写记录
            byte[] timestamp = null;
            byte[] output_timestamp = null;
            string strOutputPath = "";
            int nRet = 0;
            long lRet = 0;

            if (String.IsNullOrEmpty(strItemBarcode) == true)
            {
                // 如果检索用的册条码号为空,加上对命中结果数量不设限,那就会造成系统严重繁忙。
                strError = "参数strItemBarcode中的册条码号不能为空。";
                return -1;
            }

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

        REDODELETE:
            // 如果队列中已经存在同册条码号的记录, 要先删除
            string strNotifyXml = "";
            // 获得预约到书队列记录
            // return:
            //      -1  error
            //      0   not found
            //      1   命中1条
            //      >1  命中多于1条
            nRet = GetArrivedQueueRecXml(
                // channels,
                channel,
                strItemBarcode,
                out strNotifyXml,
                out timestamp,
                out strOutputPath,
                out strError);
            if (nRet == -1)
            {
                // 写入错误日志?
                this.WriteErrorLog("在还书操作中,检索册条码号为 " + strItemBarcode + " 的预约到书库记录时出错: " + strError);
            }
            if (nRet >= 1)
            {
                int nRedoDeleteCount = 0;
            // TODO: 这一段删除代码可以专门编制在一个函数中,不必这么费力循环。可以优化处理
            REDO_DELETE:
                lRet = channel.DoDeleteRes(strOutputPath,
                    timestamp,
                    out output_timestamp,
                    out strError);
                if (lRet == -1)
                {
                    // 时间戳不匹配
                    if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch
                        && nRedoDeleteCount < 10)
                    {
                        nRedoDeleteCount++;
                        timestamp = output_timestamp;
                        goto REDO_DELETE;
                    }

                    // 写入错误日志?
                    this.WriteErrorLog("在还书操作中,加入新预约到书记录前, 删除已存在的预约到书库记录 '" + strOutputPath + "' 出错: " + strError);
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AppReservation.cs

示例13: DeleteBiblioChildEntities

        // 删除属于同一书目记录的全部实体记录
        // 这是需要提供EntityInfo数组的版本
        // return:
        //      -1  error
        //      0   没有找到属于书目记录的任何实体记录,因此也就无从删除
        //      >0  实际删除的实体记录数
        public int DeleteBiblioChildEntities(RmsChannel channel,
            List<DeleteEntityInfo> entityinfos,
            XmlDocument domOperLog,
            out string strError)
        {
            strError = "";

            if (entityinfos == null || entityinfos.Count == 0)
                return 0;

            int nDeletedCount = 0;

            XmlNode root = null;

            if (domOperLog != null)
            {
                root = domOperLog.CreateElement("deletedEntityRecords");
                domOperLog.DocumentElement.AppendChild(root);
            }

            // 真正实行删除
            for (int i = 0; i < entityinfos.Count; i++)
            {
                DeleteEntityInfo info = entityinfos[i];

                byte[] output_timestamp = null;
                int nRedoCount = 0;

            REDO_DELETE:

                this.EntityLocks.LockForWrite(info.ItemBarcode);
                try
                {

                    long lRet = channel.DoDeleteRes(info.RecPath,
                        info.OldTimestamp,
                        out output_timestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == ChannelErrorCode.NotFound)
                            continue;

                        // 如果不重试,让时间戳出错暴露出来。
                        // 如果要重试,也得加上重新读入册记录并判断重新判断无借还信息才能删除

                        if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                        {
                            if (nRedoCount > 10)
                            {
                                strError = "重试了10次还不行。删除实体记录 '" + info.RecPath + "' 时发生错误: " + strError;
                                goto ERROR1;
                            }
                            nRedoCount++;

                            // 重新读入记录
                            string strMetaData = "";
                            string strXml = "";
                            string strOutputPath = "";
                            string strError_1 = "";

                            lRet = channel.GetRes(info.RecPath,
                                out strXml,
                                out strMetaData,
                                out output_timestamp,
                                out strOutputPath,
                                out strError_1);
                            if (lRet == -1)
                            {
                                if (channel.ErrorCode == ChannelErrorCode.NotFound)
                                    continue;

                                strError = "在删除实体记录 '" + info.RecPath + "' 时发生时间戳冲突,于是自动重新获取记录,但又发生错误: " + strError_1;
                                goto ERROR1;
                                // goto CONTINUE;
                            }

                            // 检查是否有借阅信息
                            // 把记录装入DOM
                            XmlDocument domExist = new XmlDocument();

                            try
                            {
                                domExist.LoadXml(strXml);
                            }
                            catch (Exception ex)
                            {
                                strError = "实体记录 '"+info.RecPath+"' XML装载进入DOM时发生错误: " + ex.Message;
                                goto ERROR1;
                            }

                            info.ItemBarcode = DomUtil.GetElementText(domExist.DocumentElement,
                                "barcode");

//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AppEntity.cs

示例14: CopyBiblioChildEntities


//.........这里部分代码省略.........
                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);

                    // 2014/1/5
                    if (string.IsNullOrEmpty(strNewBarcode) == false)
                        DomUtil.SetAttr(node, "newBarcode", strNewBarcode);
                }

                nOperCount++;
            }


            return nOperCount;
        ERROR1:
            // Undo已经进行过的操作
            if (strAction == "copy")
            {
                string strWarning = "";

                foreach (string strRecPath in newrecordpaths)
                {
                    string strTempError = "";
                    byte[] timestamp = null;
                    byte[] output_timestamp = null;
                REDO_DELETE:
                    long lRet = channel.DoDeleteRes(strRecPath,
                        timestamp,
                        out output_timestamp,
                        out strTempError);
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                        {
                            if (timestamp == null)
                            {
                                timestamp = output_timestamp;
                                goto REDO_DELETE;
                            }
                        }
                        strWarning += strTempError + ";";
                    }

                }
                if (string.IsNullOrEmpty(strWarning) == false)
                    strError = strError + "。在Undo过程中,又遇到出错: " + strWarning;
            }
            else if (strAction == "move")
            {
                string strWarning = "";
                for (int i = 0; i < newrecordpaths.Count; i++)
                {
                    byte[] output_timestamp = null;
                    string strOutputRecPath = "";
                    string strTempError = "";
                    // TODO: 如果确认没有对象,就可以省略这一步
                    long lRet = channel.DoCopyRecord(newrecordpaths[i],
         oldrecordpaths[i],
         true,   // bDeleteSourceRecord
         out output_timestamp,
         out strOutputRecPath,
         out strTempError);
                    if (lRet == -1)
                    {
                        strWarning += strTempError + ";";
                    }

                    // 修改xml记录。<parent>元素发生了变化
                    byte[] baOutputTimestamp = null;
                    string strOutputRecPath1 = "";
                    lRet = channel.DoSaveTextRes(oldrecordpaths[i],
                        oldrecords[i],
                        false,
                        "content", // ,ignorechecktimestamp
                        output_timestamp,
                        out baOutputTimestamp,
                        out strOutputRecPath1,
                        out strTempError);
                    if (lRet == -1)
                    {
                        strWarning += strTempError + ";";
                    }
                }
                if (string.IsNullOrEmpty(strWarning) == false)
                    strError = strError + "。在Undo过程中,又遇到出错: " + strWarning;
            }
            return -1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AppEntity.cs

示例15: DoEntityOperDelete


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

                // BUG !!! string strBiblioDbName = ResPath.GetDbName(info.NewRecPath);

                // 非工作库
                if (IsOrderWorkBiblioDb(strBiblioDbName) == false)
                {
                    // 非工作库。要求<state>包含“加工中”
                    string strState = DomUtil.GetElementText(domExist.DocumentElement,
                        "state");
                    if (IncludeStateProcessing(strState) == false)
                    {
                        strError = "当前帐户只有order权限而没有setiteminfo(或setentities)权限,不能用delete功能删除从属于非工作库的、状态不包含“加工中”的实体记录 '" + info.NewRecPath + "'";
                        goto ERROR1;    // TODO: 如何返回AccessDenied错误码呢?
                    }
                }
            }

            string strLibraryCode = "";
            // 检查一个册记录的馆藏地点是否符合馆代码列表要求
            // return:
            //      -1  检查过程出错
            //      0   符合要求
            //      1   不符合要求
            nRet = CheckItemLibraryCode(domExist,
                sessioninfo,
                        // sessioninfo.LibraryCodeList,
                        out strLibraryCode,
                        out strError);
            if (nRet == -1)
                goto ERROR1;



            // 检查旧记录是否属于管辖范围
            if (sessioninfo.GlobalUser == false)
            {
                if (nRet != 0)
                {
                    strError = "即将被删除的册记录 '" + info.NewRecPath + "' 其馆藏地点不符合要求: " + strError;
                    goto ERROR1;
                }
            }

            byte[] output_timestamp = null;

            lRet = channel.DoDeleteRes(info.NewRecPath,
                info.OldTimestamp,
                out output_timestamp,
                out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode == ChannelErrorCode.TimestampMismatch)
                {
                    if (nRedoCount > 10)
                    {
                        strError = "反复删除均遇到时间戳冲突, 超过10次重试仍然失败";
                        goto ERROR1;
                    }
                    // 发现时间戳不匹配
                    // 重复进行提取已存在记录\比较的过程
                    nRedoCount++;
                    goto REDOLOAD;
                }

                error = new EntityInfo(info);
                error.NewTimestamp = output_timestamp;
                error.ErrorInfo = "删除操作发生错误:" + strError;
                error.ErrorCode = channel.OriginErrorCode;
                ErrorInfos.Add(error);
                return -1;
            }
            else
            {
                // 成功
                DomUtil.SetElementText(domOperLog.DocumentElement,
    "libraryCode",
    strLibraryCode);    // 册所在的馆代码

                DomUtil.SetElementText(domOperLog.DocumentElement, "action", "delete");
                if (String.IsNullOrEmpty(strStyle) == false)
                    DomUtil.SetElementText(domOperLog.DocumentElement, "style", strStyle);

                // 不创建<record>元素

                XmlNode node = DomUtil.SetElementText(domOperLog.DocumentElement,
                    "oldRecord", strExistingXml);
                DomUtil.SetAttr(node, "recPath", info.NewRecPath);


                // 如果删除成功,则不必要在数组中返回表示成功的信息元素了
            }

            return 0;
        ERROR1:
            error = new EntityInfo(info);
            error.ErrorInfo = strError;
            error.ErrorCode = ErrorCodeValue.CommonError;
            ErrorInfos.Add(error);
            return -1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AppEntity.cs


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