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


C# RmsChannel.GetRes方法代码示例

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


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

示例1: GetBiblioSummary


//.........这里部分代码省略.........
                //      >1  命中多于1条
                nRet = this.GetItemRecXml(
                    channel,
                    strItemBarcode,
                    out strItemXml,
                    out strOutputItemPath,
                    out strError);
                if (nRet == 0)
                {
                    result.Value = 0;
                    result.ErrorInfo = "册记录没有找到";
                    result.ErrorCode = ErrorCode.NotFound;
                    return result;
                }

                if (nRet == -1)
                    goto ERROR1;
            }

            // 如果命中多于一条(或者没有条码号),并且已经有确定的册记录路径辅助判断
            if (string.IsNullOrEmpty(strItemBarcode) == true
                ||
                (nRet > 1 && String.IsNullOrEmpty(strConfirmItemRecPath) == false))
            {
                // 检查路径中的库名,是不是实体库、订购库、期库、评注库名
                nRet = CheckRecPath(strConfirmItemRecPath,
                    "item,order,issue,comment",
                    out strError);
                if (nRet != 1)
                    goto ERROR1;

                byte[] item_timestamp = null;

                lRet = channel.GetRes(strConfirmItemRecPath,
                    out strItemXml,
                    out strMetaData,
                    out item_timestamp,
                    out strOutputItemPath,
                    out strError);
                if (lRet == -1)
                {
                    strError = "根据strConfirmItemRecPath '" + strConfirmItemRecPath + "' 获得记录失败: " + strError;
                    goto ERROR1;
                }

                bByRecPath = true;
            }

            // 从册记录中获得从属的种id
            string strBiblioRecID = "";

            XmlDocument dom = new XmlDocument();
            try
            {
                dom.LoadXml(strItemXml);
            }
            catch (Exception ex)
            {
                strError = "册记录XML装载到DOM出错:" + ex.Message;
                goto ERROR1;
            }

            if (bByRecPath == true
                && string.IsNullOrEmpty(strItemBarcode) == false)   // 2011/9/6
            {
                // 这种情况需要核实册条码号
开发者ID:paopaofeng,项目名称:dp2,代码行数:67,代码来源:AppBiblio.cs

示例2: LoadRecord

		// 装载记录
		// 把strRecordPath表示的记录装载到窗口中,并且在窗口第一行
		// 路径内容设置好
		// parameters:
		//		strRecordPath	记录路径。如果==null,表示直接用textBox_recPath中当前的内容作为路径
		//		strExtStyle	如果为null,表示获取strRecordPath或textbox表示的记录。如果为"next"或"prev",
		//					则表示取其后或前一条记录
		// return:
		//		-2	放弃
		//		-1	出错
		//		0	正常
		//		1	到头或者到尾
		public int LoadRecord(string strRecordPath,
			string strExtStyle,
			out string strError)
		{
			strError = "";

			EnableControlsInLoading(true);

			try 
			{

				if (this.Changed == true)
				{

					DialogResult result = MessageBox.Show(this, 
						"装载新内容前, 发现当前窗口中已有内容修改后未来得及保存。是否要继续装载新内容到窗口中(这样将丢失先前修改过的内容)?\r\n\r\n(是)继续装载新内容 (否)不装载新内容",
						"dp2rms",
						MessageBoxButtons.YesNo,
						MessageBoxIcon.Question,
						MessageBoxDefaultButton.Button2);
					if (result != DialogResult.Yes) 
					{
						strError = "装载新内容操作被放弃...";
						return -2;
					}
				}

				if (strRecordPath != null)
					textBox_recPath.Text = strRecordPath;

				ResPath respath = new ResPath(textBox_recPath.Text);

				this.Text = respath.ReverseFullPath;


				string strContent;
				string strMetaData;
				// string strError;
				byte [] baTimeStamp = null;
				string strOutputPath;


				// 使用Channel
				RmsChannel channelSave = channel;

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

				try 
				{

					string strStyle = "content,data,metadata,timestamp,outputpath,withresmetadata";	// 

					if (strExtStyle != null && strExtStyle != "")
					{
						strStyle += "," + strExtStyle;
					}

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


            
					long lRet = channel.GetRes(respath.Path,
						strStyle,
						// this.eventClose,
						out strContent,
						out strMetaData,
						out baTimeStamp,
						out strOutputPath,
						out strError);


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

					this.TimeStamp = baTimeStamp;	// 设置时间戳很重要。即便xml不合法,也应设置好时间戳,否则窗口无法进行正常删除。

                    this.strDatabaseOriginPath = respath.Url+"?"+strOutputPath; // 保存从数据库中来的原始path

					if (lRet == -1) 
					{
                        if (channel.ErrorCode == ChannelErrorCode.NotFoundSubRes)
                        {
                            // 下级资源不存在, 警告一下就行了
                            MessageBox.Show(this, strError);
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:DetailForm.cs

示例3: RefreshDatabase

        // 根据数据库模板的定义,刷新一个已经存在的数据库的定义
        // return:
        //      -1
        //      0   keys定义没有更新
        //      1   keys定义更新了
        int RefreshDatabase(RmsChannel channel,
            string strTemplateDir,
            string strDatabaseName,
            string strIncludeFilenames,
            string strExcludeFilenames,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            strIncludeFilenames = strIncludeFilenames.ToLower();
            strExcludeFilenames = strExcludeFilenames.ToLower();

            bool bKeysChanged = false;

            DirectoryInfo di = new DirectoryInfo(strTemplateDir);
            FileInfo[] fis = di.GetFiles();

            // 创建所有文件对象
            for (int i = 0; i < fis.Length; i++)
            {
                string strName = fis[i].Name;
                if (strName == "." || strName == "..")
                    continue;

                if (FileUtil.IsBackupFile(strName) == true)
                    continue;

                /*
                if (strName.ToLower() == "keys"
                    || strName.ToLower() == "browse")
                    continue;
                 * */

                // 如果Include和exclude里面都有一个文件名,优先依exclude(排除)
                if (StringUtil.IsInList(strName, strExcludeFilenames) == true)
                    continue;

                if (strIncludeFilenames != "*")
                {
                    if (StringUtil.IsInList(strName, strIncludeFilenames) == false)
                        continue;
                }


                string strFullPath = fis[i].FullName;

                nRet = ConvertGb2312TextfileToUtf8(strFullPath,
                    out strError);
                if (nRet == -1)
                    return -1;

                string strExistContent = "";
                string strNewContent = "";

                Stream new_stream = new FileStream(strFullPath, FileMode.Open);

                {
                    StreamReader sr = new StreamReader(new_stream, Encoding.UTF8);
                    strNewContent = ConvertCrLf(sr.ReadToEnd());
                }

                new_stream.Seek(0, SeekOrigin.Begin);


                try
                {
                    string strPath = strDatabaseName + "/cfgs/" + strName;


                    // 获取已有的配置文件对象
                    byte[] timestamp = null;
                    string strOutputPath = "";
                    string strMetaData = "";

                    string strStyle = "content,data,metadata,timestamp,outputpath";
                    MemoryStream exist_stream = new MemoryStream();

                    try
                    {

                        long lRet = channel.GetRes(
                            strPath,
                            exist_stream,
                            null,	// stop,
                            strStyle,
                            null,	// byte [] input_timestamp,
                            out strMetaData,
                            out timestamp,
                            out strOutputPath,
                            out strError);
                        if (lRet == -1)
                        {
                            // 配置文件不存在,怎么返回错误码的?
                            if (channel.ErrorCode == ChannelErrorCode.NotFound)
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AppDatabase.cs

示例4: GetMarcDefCfgFile

		// return:
		//		-1	出错
		//		0	没有找到
		//		1	找到
		int GetMarcDefCfgFile(string strUrl,
			string strDbName,
			out Stream s,
			out string strError)
		{
			strError = "";
			s = null;

            if (String.IsNullOrEmpty(strUrl) == true)
            {
                /*
                strError = "URL为空";
                goto ERROR1;
                 */
                return 0;
            }

			string strPath = strDbName + "/cfgs/marcdef";

			// 使用Channel
			RmsChannel channelSave = channel;

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

			try 
			{

				string strContent;
				// string strError;

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在下载文件" + strPath);
				stop.BeginLoop();

				byte[] baTimeStamp = null;
				string strMetaData;
				string strOutputPath;

				long lRet = channel.GetRes(
					MainForm.cfgCache,
					strPath,
					out strContent,
					out strMetaData,
					out baTimeStamp,
					out strOutputPath,
					out strError);

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


				if (lRet == -1) 
				{
					if (channel.ErrorCode == ChannelErrorCode.NotFound)
						return 0;

					strError = "获得配置文件 '" +strPath+ "' 时出错:" + strError;
					goto ERROR1;
				}
				else 
				{
					byte [] baContent = StringUtil.GetUtf8Bytes(strContent, true);
					MemoryStream stream = new MemoryStream(baContent);
					s = stream;
				}

			}
			finally 
			{
				channel = channelSave;		
			}

			return 1;
			ERROR1:
			return -1;
		}
开发者ID:paopaofeng,项目名称:dp2,代码行数:82,代码来源:DetailForm.cs

示例5: MarcEditor_GetConfigDom

        private void MarcEditor_GetConfigDom(object sender, GetConfigDomEventArgs e)
        {
            if (String.IsNullOrEmpty(textBox_recPath.Text) == true)
            {
                e.ErrorInfo = "记录路径为空,无法获得配置文件 '" + e.Path + "'";
                return;
            }
            ResPath respath = new ResPath(textBox_recPath.Text);

            // 得到干净的文件名
            string strCfgFileName = e.Path;
            int nRet = strCfgFileName.IndexOf("#");
            if (nRet != -1)
            {
                strCfgFileName = strCfgFileName.Substring(0, nRet);
            }

            string strPath = ResPath.GetDbName(respath.Path) + "/cfgs/" + strCfgFileName;

            // 在cache中寻找
            e.XmlDocument = this.MainForm.DomCache.FindObject(strPath);
            if (e.XmlDocument != null)
                return;

            // 使用Channel

            RmsChannel channelSave = channel;

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

            m_nInGetCfgFile++;

            try
            {
                string strContent;
                string strError;

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在下载文件" + strPath);
                stop.BeginLoop();

                byte[] baTimeStamp = null;
                string strMetaData;
                string strOutputPath;

                long lRet = channel.GetRes(
                    MainForm.cfgCache,
                    strPath,
                    out strContent,
                    out strMetaData,
                    out baTimeStamp,
                    out strOutputPath,
                    out strError);

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

                if (lRet == -1)
                {
                    if (channel.ErrorCode == ChannelErrorCode.NotFound)
                    {
                        e.ErrorInfo = "";
                        return;
                    }


                    e.ErrorInfo = "获得配置文件 '" + strPath + "' 时出错:" + strError;
                    return;
                }


                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strContent);
                }
                catch (Exception ex)
                {
                    e.ErrorInfo = "配置文件 '" + strPath + "' 装入XMLDUM时出错: " + ex.Message;
                    return;
                }
                e.XmlDocument = dom;
                this.MainForm.DomCache.SetObject(strPath, dom);  // 保存到缓存
            }
            finally
            {
                channel = channelSave;

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

示例6: DownloadOneFile

		int DownloadOneFile(string strID,
			out string strError)
		{

			strError = "";
			ResPath respath = new ResPath(textBox_recPath.Text);
			string strResPath = respath.Path + "/object/" + strID;

			strResPath = strResPath.Replace(":", "/");


			string strLocalPath = this.listView_resFiles.GetLocalFileName(strID);

			SaveFileDialog dlg = new SaveFileDialog();

			dlg.Title = "请指定要保存的本地文件名";
			dlg.CreatePrompt = false;
			dlg.FileName = strLocalPath == "" ? strID + ".res" : strLocalPath;
			dlg.InitialDirectory = Environment.CurrentDirectory;
			// dlg.Filter = "projects files (outer*.xml)|outer*.xml|All files (*.*)|*.*" ;

			dlg.RestoreDirectory = true ;

			if(dlg.ShowDialog() != DialogResult.OK)
			{
				strError = "放弃";
				return -1;
			}


			// 使用Channel
			RmsChannel channelSave = channel;

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

			try 
			{

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在下载资源文件 " + strResPath);
				stop.BeginLoop();

				byte [] baOutputTimeStamp = null;

				EnableControlsInLoading(true);

				string strMetaData;
				string strOutputPath = "";

				long lRet = channel.GetRes(strResPath,
					dlg.FileName,
					stop,
					out strMetaData,
					out baOutputTimeStamp,
					out strOutputPath,
					out strError);

				EnableControlsInLoading(false);

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


				if (lRet == -1) 
				{
					MessageBox.Show(this, "下载资源文件失败,原因: "+strError);
					goto ERROR1;
				}

			}
			finally 
			{
				channel = channelSave;
			}
			return 0;

			ERROR1:
			return -1;

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

示例7: AutoGenerate

		// 自动加工数据
		public void AutoGenerate()
		{
			// 库名部分路径
			ResPath respath = new ResPath(textBox_recPath.Text);
			respath.MakeDbName();

			string strError;
			string strCode;
			string strRef;

			// 使用Channel
			RmsChannel channelSave = channel;

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

			try 
			{
				string strCfgPath = respath.Path + "/cfgs/autoGenerate.cs";

				string strCfgRefPath = respath.Path + "/cfgs/autoGenerate.cs.ref";

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在下载文件" + strCfgPath);
				stop.BeginLoop();

				byte[] baTimeStamp = null;
				string strMetaData;
				string strOutputPath;

				long lRet = channel.GetRes(
					MainForm.cfgCache,
					strCfgPath,
					out strCode,
					out strMetaData,
					out baTimeStamp,
					out strOutputPath,
					out strError);

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

				if (lRet == -1) 
				{
					MessageBox.Show(this, strError);
					return;
				}


                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在下载文件" + strCfgRefPath);
				stop.BeginLoop();

				lRet = channel.GetRes(
					MainForm.cfgCache,
					strCfgRefPath,
					out strRef,
					out strMetaData,
					out baTimeStamp,
					out strOutputPath,
					out strError);

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


				if (lRet == -1) 
				{
					MessageBox.Show(this, strError);
					return;
				}

			}
			finally 
			{
				channel = channelSave;
			}



			// 执行代码
			int nRet = RunScript(strCode,
                strRef,
                out strError);
			if (nRet == -1) 
			{
				MessageBox.Show(this, strError);
				return;
			}

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

示例8: WriteResToBackupFile

        // 下载资源,保存到备份文件
        public static int WriteResToBackupFile(
            IWin32Window owner,
            Stream outputfile,
            string strXmlRecPath,
            string[] res_ids,
            RmsChannel channel,
            DigitalPlatform.Stop stop,
            out string strError)
        {
            strError = "";


            long lRet;

            for (int i = 0; i < res_ids.Length; i++)
            {
                Application.DoEvents();	// 出让界面控制权

                if (stop.State != 0)
                {
                    DialogResult result = MessageBox.Show(owner,
                        "确实要中断当前批处理操作?",
                        "dp2batch",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.Yes)
                    {
                        strError = "用户中断";
                        return -1;
                    }
                    else
                    {
                        stop.Continue();
                    }
                }

                string strID = res_ids[i].Trim();

                if (strID == "")
                    continue;

                string strResPath = strXmlRecPath + "/object/" + strID;

                string strMetaData;

                if (stop != null)
                    stop.SetMessage("正在下载 " + strResPath);

                long lResStart = 0;
                // 写res的头。
                // 如果不能预先确知整个res的长度,可以用随便一个lTotalLength值调用本函数,
                // 但是需要记忆下函数所返回的lStart,最后调用EndWriteResToBackupFile()。
                // 如果能预先确知整个res的长度,则最后不必调用EndWriteResToBackupFile()
                lRet = Backup.BeginWriteResToBackupFile(
                    outputfile,
                    0,	// 未知
                    out lResStart);

                byte[] baOutputTimeStamp = null;
                string strOutputPath;

            REDO_GETRES:
                lRet = channel.GetRes(strResPath,
                    (Stream)null,	// 故意不获取资源体
                    stop,
                    "metadata,timestamp,outputpath",
                    null,
                    out strMetaData,	// 但是要获得metadata
                    out baOutputTimeStamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    // TODO: 允许重试
                    DialogResult redo_result = MessageBox.Show(owner,
                        "获取记录 '" + strResPath + "' 时出现错误: " + strError + "\r\n\r\n重试,还是中断当前批处理操作?\r\n(Retry 重试;Cancel 中断批处理)",
                        "dp2batch",
                        MessageBoxButtons.RetryCancel,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button1);
                    if (redo_result == DialogResult.Cancel)
                        return -1;
                    goto
                        REDO_GETRES;
                }

                byte[] timestamp = baOutputTimeStamp;

                ResPath respath = new ResPath();
                respath.Url = channel.Url;
                respath.Path = strOutputPath;	// strResPath;

                // strMetaData还要加入资源id?
                ExportUtil.ChangeMetaData(ref strMetaData,
                    strID,
                    null,
                    null,
                    null,
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:MainForm.cs

示例9: VerifyRange

		// 校验起止号
        // return:
        //      0   不存在记录
        //      1   存在记录
        int VerifyRange(RmsChannel channel,
			string strDbName,
			out string strError)
		{
            bool bStartNotFound = false;
            bool bEndNotFound = false;

			strError = "";

			// 如果edit中为空,则假定为“全部范围”
			if (textBox_startNo.Text == "")
				textBox_startNo.Text = "1";

			if (textBox_endNo.Text == "")
				textBox_endNo.Text = "9999999999";


			bool bAsc = true;

			Int64 nStart = 0;
			Int64 nEnd = 9999999999;
			
			
			try 
			{
				nStart = Convert.ToInt64(textBox_startNo.Text);
			}
			catch 
			{
			}

				
			try 
			{
				nEnd = Convert.ToInt64(textBox_endNo.Text);
			}
			catch 
			{
			}


			if (nStart > nEnd)
				bAsc = false;
			else
				bAsc = true;

			string strPath = strDbName + "/" + textBox_startNo.Text;
			string strStyle = "outputpath";

			if (bAsc == true)
				strStyle += ",next,myself";
			else 
				strStyle += ",prev,myself";

			string strResult;
			string strMetaData;
			byte [] baOutputTimeStamp;
			string strOutputPath;

			string strError0  = "";

			string strStartID = "";
			string strEndID = "";

			// 获得资源
			// return:
			//		-1	出错。具体出错原因在this.ErrorCode中。this.ErrorInfo中有出错信息。
			//		0	成功
			long lRet = channel.GetRes(strPath,
				strStyle,
				out strResult,
				out strMetaData,
				out baOutputTimeStamp,
				out strOutputPath,
				out strError0);
			if (lRet == -1) 
			{
				if (channel.ErrorCode == ChannelErrorCode.NotFound)
				{
					strStartID = textBox_startNo.Text;
                    bStartNotFound = true;
				}
				else 
					strError += "校验startno时出错: " + strError0 + " ";
				
			}
			else 
			{
				// 取得返回的id
				strStartID = ResPath.GetRecordId(strOutputPath);


			}

			if (strStartID == "")
			{
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:MainForm.cs

示例10: DoExportXmlFile


//.........这里部分代码省略.........
						strError = "用户中断";
						goto ERROR1;
					}

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

					if (bFirst == true)
						strStyle += "";
					else 
					{
						if (bAsc == true)
							strStyle += ",next";
						else
							strStyle += ",prev";
					}


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

					bool bFoundRecord = false;

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


					if (lRet == -1) 
					{
						if (channel.ErrorCode == ChannelErrorCode.NotFound) 
						{
							if (checkBox_forceLoop.Checked == true && bFirst == true)
							{
								AutoCloseMessageBox.Show(this, "记录 " + strID + " 不存在。\r\n\r\n按 确认 继续。");

								bFirst = false;
								goto CONTINUE;
							}
							else 
							{
								if (bFirst == true)
								{
									strError = "记录 " + strID + " 不存在。处理结束。";
								}
								else 
								{
									if (bAsc == true)
										strError = "记录 " + strID + " 是最末一条记录。处理结束。";
									else
										strError = "记录 " + strID + " 是最前一条记录。处理结束。";
								}
开发者ID:renyh1013,项目名称:dp2,代码行数:67,代码来源:MainForm.cs

示例11: DoExportFile


//.........这里部分代码省略.........
                        {
                            strStyle += "";
                        }
                        else
                        {
                            if (bAsc == true)
                            {
                                strStyle += ",next";
                                strDirectionComment = "的后一条记录";
                            }
                            else
                            {
                                strStyle += ",prev";
                                strDirectionComment = "的前一条记录";
                            }
                        }


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

                        bool bFoundRecord = false;

                        bool bNeedRetry = true;

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


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

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

示例12: GetUserRecord

        // 获得用户记录
        // return:
        //      -1  error
        //      0   not found
        //      >=1   检索命中的条数
        public static int GetUserRecord(
            RmsChannel channel,
            string strUserName,
            out string strRecPath,
            out string strXml,
            out byte[] baTimeStamp,
            out string strError)
        {
            strError = "";

            strXml = "";
            strRecPath = "";
            baTimeStamp = null;

            if (strUserName == "")
            {
                strError = "用户名为空";
                return -1;
            }

            string strQueryXml = "<target list='" + Defs.DefaultUserDb.Name
                + ":" + Defs.DefaultUserDb.SearchPath.UserName + "'><item><word>"
                + strUserName + "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>10</maxCount></item><lang>chi</lang></target>";

            long nRet = channel.DoSearch(strQueryXml,
                "default",
                "", // strOutputStyle
                out strError);
            if (nRet == -1)
            {
                strError = "检索帐户库时出错: " + strError;
                return -1;
            }

            if (nRet == 0)
                return 0;	// not found

            long nSearchCount = nRet;

            List<string> aPath = null;
            nRet = channel.DoGetSearchResult(
                "default",
                1,
                "zh",
                null,	// stop,
                out aPath,
                out strError);
            if (nRet == -1)
            {
                strError = "检索注册用户库获取检索结果时出错: " + strError;
                return -1;
            }
            if (aPath.Count == 0)
            {
                strError = "检索注册用户库获取的检索结果为空";
                return -1;
            }

            // strRecID = ResPath.GetRecordId((string)aPath[0]);
            strRecPath = (string)aPath[0];

            string strStyle = "content,data,timestamp,withresmetadata";
            string strMetaData;
            string strOutputPath;

            nRet = channel.GetRes((string)aPath[0],
                strStyle,
                out strXml,
                out strMetaData,
                out baTimeStamp,
                out strOutputPath,
                out strError);
            if (nRet == -1)
            {
                strError = "获取注册用户库记录体时出错: " + strError;
                return -1;
            }


            return (int)nSearchCount;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:86,代码来源:InstallLibraryParamDlg.cs

示例13: MapFileToLocal

        // 将内核网络配置文件映射到本地
        // return:
        //      -1  出错
        //      0   不存在
        //      1   找到
        public int MapFileToLocal(
            // RmsChannelCollection Channels,
            RmsChannel channel,
            string strPath,
            out string strLocalPath,
            out string strError)
        {
            strLocalPath = "";
            strError = "";

            strLocalPath = this.RootDir + "/" + strPath;

            // 确保目录存在
            PathUtil.CreateDirIfNeed(Path.GetDirectoryName(strLocalPath));

            this.locks.LockForRead(strLocalPath);
            try {
                // 看看物理文件是否存在
                FileInfo fi = new FileInfo(strLocalPath);
                if (fi.Exists == true) {
                    if (fi.Length == 0)
                        return 0;   // not exist
                    return 1;
                }
            }
            finally
            {
                this.locks.UnlockForRead(strLocalPath);
            }

            // 确保目录存在
            PathUtil.CreateDirIfNeed(Path.GetDirectoryName(strLocalPath));

            this.locks.LockForWrite(strLocalPath);
            try
            {
#if NO
                RmsChannel channel = Channels.GetChannel(this.ServerUrl);
                if (channel == null)
                {
                    strError = "GetChannel error";
                    return -1;
                }
#endif

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

                long lRet = channel.GetRes(strPath,
                    strLocalPath,
                    (Stop)null,
                    out strMetaData,
                    out baOutputTimestamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    if (channel.ErrorCode == ChannelErrorCode.NotFound)
                    {
                        // 为了避免以后再次从网络获取耗费时间, 需要在本地写一个0字节的文件
                        FileStream fs = File.Create(strLocalPath);
                        fs.Close();
                        return 0;
                    }
                    return -1;
                }

                return 1;
            }
            finally
            {
                this.locks.UnlockForWrite(strLocalPath);
            }
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:80,代码来源:CfgsMap.cs

示例14: DoBiblioOperMove

        // 移动或者复制书目记录
        // strExistingXml和请求中传来的old xml的时间戳比较,在本函数外、调用前进行
        // parameters:
        //      strAction   动作。为"onlycopybiblio" "onlymovebiblio"之一。增加 copy / move
        //      strNewBiblio    需要在目标记录中更新的内容。如果 == null,表示不特意更新
        //      strMergeStyle   如何合并两条记录的元数据部分? reserve_source / reserve_target。 空表示 reserve_source
        int DoBiblioOperMove(
            string strAction,
            SessionInfo sessioninfo,
            RmsChannel channel,
            string strOldRecPath,
            string strExistingSourceXml,
            // byte[] baExistingSourceTimestamp, // 请求中提交过来的时间戳
            string strNewRecPath,
            string strNewBiblio,    // 已经经过Merge预处理的新记录XML
            string strMergeStyle,
            out string strOutputTargetXml,
            out byte[] baOutputTimestamp,
            out string strOutputRecPath,
            out string strError)
        {
            strError = "";
            long lRet = 0;
            baOutputTimestamp = null;
            strOutputRecPath = "";

            strOutputTargetXml = ""; // 最后保存成功的记录

            // 检查路径
            if (strOldRecPath == strNewRecPath)
            {
                strError = "当action为\"" + strAction + "\"时,strNewRecordPath路径 '" + strNewRecPath + "' 和strOldRecPath '" + strOldRecPath + "' 必须不相同";
                goto ERROR1;
            }

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

            // 检查即将覆盖的目标位置是不是有记录,如果有,则不允许进行move操作。
            bool bAppendStyle = false;  // 目标路径是否为追加形态?
            string strTargetRecId = ResPath.GetRecordId(strNewRecPath);
            string strExistTargetXml = "";

            if (strTargetRecId == "?" || String.IsNullOrEmpty(strTargetRecId) == true)
            {
                // 2009/11/1 
                if (String.IsNullOrEmpty(strTargetRecId) == true)
                    strNewRecPath += "/?";

                bAppendStyle = true;
            }


            string strOutputPath = "";
            string strMetaData = "";

            if (bAppendStyle == false)
            {
                byte[] exist_target_timestamp = null;

                // 获取覆盖目标位置的现有记录
                lRet = channel.GetRes(strNewRecPath,
                    out strExistTargetXml,
                    out strMetaData,
                    out exist_target_timestamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    if (channel.ErrorCode == ChannelErrorCode.NotFound)
                    {
                        // 如果记录不存在, 说明不会造成覆盖态势
                        /*
                        strExistSourceXml = "<root />";
                        exist_source_timestamp = null;
                        strOutputPath = info.NewRecPath;
                         * */
                    }
                    else
                    {
                        strError = "移动操作发生错误, 在读入即将覆盖的目标位置 '" + strNewRecPath + "' 原有记录阶段:" + strError;
                        goto ERROR1;
                    }
                }
                else
                {
#if NO
                    // 如果记录存在,则目前不允许这样的操作
                    strError = "移动(move)操作被拒绝。因为在即将覆盖的目标位置 '" + strNewRecPath + "' 已经存在书目记录。请先删除(delete)这条记录,再进行移动(move)操作";
                    goto ERROR1;
#endif
                }
            }

            /*
            // 把两个记录装入DOM

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

示例15: SaveToTemplate

		// 保存记录到模板配置文件
		// parameters:
		public void SaveToTemplate()
		{
			// 选择目标数据库
			OpenResDlg dlg = new OpenResDlg();
            dlg.Font = GuiUtil.GetDefaultFont();

			dlg.Text = "请选择目标数据库";
			dlg.EnabledIndices = new int[] { ResTree.RESTYPE_DB };
			dlg.ap = this.MainForm.AppInfo;
			dlg.ApCfgTitle = "detailform_openresdlg";
			dlg.Path = textBox_recPath.Text;
			dlg.Initial( MainForm.Servers,
				this.Channels);	
			// dlg.StartPosition = FormStartPosition.CenterScreen;
			dlg.ShowDialog(this);

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


			// 下载模板配置文件
			ResPath respath = new ResPath(dlg.Path);

			string strError;
			string strContent;
			byte[] baTimeStamp = null;
			string strMetaData;
			string strOutputPath;

			string strCfgFilePath = respath.Path + "/cfgs/template";

			long lRet = 0;

			// 使用Channel
			RmsChannel channelSave = channel;

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

			try 
			{

                stop.OnStop += new StopEventHandler(this.DoStop);
				stop.Initial("正在下载文件" + strCfgFilePath);
				stop.BeginLoop();



				lRet = channel.GetRes(
					MainForm.cfgCache,
					strCfgFilePath,
					out strContent,
					out strMetaData,
					out baTimeStamp,
					out strOutputPath,
					out strError);

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

				if (lRet == -1) 
				{
					this.TimeStamp = null;
					MessageBox.Show(this, strError);
					return;
				}

			}
			finally 
			{
				channel = channelSave;
			}

			SelectRecordTemplateDlg tempdlg = new SelectRecordTemplateDlg();
            tempdlg.Font = GuiUtil.GetDefaultFont();

            int nRet = tempdlg.Initial(strContent, out strError);
			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);
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:DetailForm.cs


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