本文整理汇总了C#中LibraryChannel.GetRes方法的典型用法代码示例。如果您正苦于以下问题:C# LibraryChannel.GetRes方法的具体用法?C# LibraryChannel.GetRes怎么用?C# LibraryChannel.GetRes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibraryChannel
的用法示例。
在下文中一共展示了LibraryChannel.GetRes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitialInfo
// 从服务器端得到XML数据,初始化若干变量
// parameters:
// page 如果!=null,允许灵敏中断
// return:
// -1 出错
// 0 正常结束
// 1 被用户中断
public int InitialInfo(
System.Web.UI.Page page,
LibraryChannel channel,
out string strError)
{
strError = "";
Line line = this;
if (this.m_bInfoInitilized == true)
return 0;
if (String.IsNullOrEmpty(this.m_strRecPath) == true)
{
strError = "m_strRecPath尚未初始化";
return -1;
}
string strStyle = "content,data";
string strContent;
string strMetaData;
byte[] baTimeStamp;
string strOutputPath;
Debug.Assert(channel != null, "Channels.GetChannel 异常");
if (page != null
&& page.Response.IsClientConnected == false) // 灵敏中断
return 1;
long nRet = channel.GetRes(null,
this.m_strRecPath,
strStyle,
out strContent,
out strMetaData,
out baTimeStamp,
out strOutputPath,
out strError);
if (nRet == -1)
{
strError = "获取记录 '" + this.m_strRecPath + "' 时出错: " + strError;
return -1;
}
if (page != null
&& page.Response.IsClientConnected == false) // 灵敏中断
return 1;
// 处理数据
nRet = line.ProcessXml(
page,
strContent,
out strError);
if (nRet == -1)
{
return -1;
}
this.m_bInfoInitilized = true;
return 0;
}
示例2: GetCommentsSearchResult
// 根据特性的评注记录路径,获得一定范围的检索命中结果
// return:
// -1 出错
// 0 没有找到
// 1 找到
public static int GetCommentsSearchResult(
OpacApplication app,
LibraryChannel channel,
ItemLoadEventHandler itemLoadProc,
SetStartEventHandler setStartProc,
int nPerCount,
string strCommentRecPath,
bool bGetRecord,
string strLang, // 2012/7/9
out int nStart,
out string strError)
{
strError = "";
nStart = -1;
long lHitCount = 0;
bool bFound = false;
List<string> aPath = null;
for (int j = 0; ; j++)
{
nStart = j * nPerCount;
// 只获得路径。确保所要的lStart lCount范围全部获得
long lRet = // this.Channel.
channel.GetSearchResult(
null,
"default",
nStart, // 0,
nPerCount, // -1,
strLang,
out aPath,
out strError);
if (lRet == -1)
goto ERROR1;
lHitCount = lRet;
if (lHitCount == 0)
return 0;
if (aPath.Count == 0)
break;
for (int i = 0; i < aPath.Count; i++)
{
if (aPath[i] == strCommentRecPath)
{
bFound = true;
break;
}
}
if (bFound == true)
break;
if (nStart >= lHitCount)
break;
}
if (bFound == true)
{
if (// this.SetStart != null
setStartProc != null)
{
SetStartEventArgs e = new SetStartEventArgs();
e.StartIndex = nStart;
// this.SetStart(this, e);
setStartProc(null, e);
}
for (int i = 0; i < aPath.Count; i++)
{
if (bGetRecord == true)
{
string strXml = "";
string strMetaData = "";
byte[] timestamp = null;
string strOutputPath = "";
string strStyle = LibraryChannel.GETRES_ALL_STYLE;
long lRet = // this.Channel.
channel.GetRes(
null,
aPath[i],
strStyle,
out strXml,
out strMetaData,
out timestamp,
out strOutputPath,
out strError);
if (lRet == -1)
goto ERROR1;
if (//this.ItemLoad != null
//.........这里部分代码省略.........
示例3: GetConfigFile
int GetConfigFile(
LibraryChannel channel,
string strPath,
out ConfigInfo info,
out string strError)
{
strError = "";
info = new ConfigInfo();
string strOutputFileName = Path.GetTempFileName();
try
{
byte[] baOutputTimestamp = null;
string strOutputPath = "";
string strMetadata = "";
long lRet = channel.GetRes(null,
strPath,
strOutputFileName,
out strMetadata,
out baOutputTimestamp,
out strOutputPath,
out strError);
if (lRet == -1)
return -1;
info.Timestamp = baOutputTimestamp;
info.Path = strOutputPath;
// 观察mime
// 取metadata
Hashtable values = StringUtil.ParseMetaDataXml(strMetadata,
out strError);
if (values == null)
{
strError = "ParseMedaDataXml() values == null";
return -1;
}
string strMime = (string)values["mimetype"];
if (strMime == null || strMime == "")
strMime = "text";
string strLocalPath = (string)values["localpath"];
if (strLocalPath == null)
strLocalPath = "";
info.MIME = strMime;
info.LocalPath = strLocalPath;
if (IsText(strMime) == true)
{
using (StreamReader sr = new StreamReader(strOutputFileName, Encoding.UTF8))
{
info.Content = ConvertCrLf(sr.ReadToEnd());
}
}
else
{
strError = "二进制内容 '" + strMime + "' 无法直接编辑";
return -1;
}
return 0;
}
finally
{
if (string.IsNullOrEmpty(strOutputFileName) == false)
File.Delete(strOutputFileName);
}
}
示例4: GetOneObjectMetadata
// 获得一个对象资源的元数据
int GetOneObjectMetadata(
LibraryChannel channel,
string strBiblioRecPath,
string strID,
out string strMetadataXml,
out byte[] timestamp,
out string strError)
{
timestamp = null;
strError = "";
string strResPath = strBiblioRecPath + "/object/" + strID;
strResPath = strResPath.Replace(":", "/");
#if NO
Stop.OnStop += new StopEventHandler(this.DoStop);
Stop.Initial("正在下载对象的元数据 " + strResPath);
Stop.BeginLoop();
#endif
Stop.Initial("正在下载对象的元数据 " + strResPath);
try
{
string strOutputPath = "";
// EnableControlsInLoading(true);
string strResult = "";
// 只得到metadata
long lRet = channel.GetRes(
Stop,
strResPath,
"metadata,timestamp,outputpath",
out strResult,
out strMetadataXml,
out timestamp,
out strOutputPath,
out strError);
if (lRet == -1)
{
strError = "下载对象 " + strResPath + " 元数据失败,原因: " + strError;
return -1;
}
return 0;
}
finally
{
// EnableControlsInLoading(false);
#if NO
Stop.EndLoop();
Stop.OnStop -= new StopEventHandler(this.DoStop);
Stop.Initial("");
#endif
Stop.Initial("");
}
}
示例5: DownloadObject
static int DownloadObject(Stop stop,
LibraryChannel channel,
string strResPath,
string strOutputFileName,
out string strError)
{
strError = "";
PathUtil.CreateDirIfNeed(Path.GetDirectoryName(strOutputFileName));
TimeSpan old_timeout = channel.Timeout;
channel.Timeout = new TimeSpan(0, 5, 0);
if (stop != null)
stop.Initial("正在下载对象 " + strResPath);
try
{
byte[] baOutputTimeStamp = null;
string strMetaData = "";
string strOutputPath = "";
long lRet = channel.GetRes(
stop,
strResPath,
strOutputFileName,
out strMetaData,
out baOutputTimeStamp,
out strOutputPath,
out strError);
if (lRet == -1)
{
strError = "下载对象 '" + strResPath + "' 到文件失败,原因: " + strError;
return -1;
}
return 0;
}
finally
{
channel.Timeout = old_timeout;
if (stop != null)
stop.Initial("");
}
}
示例6: BuildRssFile
//.........这里部分代码省略.........
}
DpRecord record = resultset[i];
string strPath = record.ID;
// TODO: 对于实体库记录或者评注库记录,可以检索其从属的书目记录来取得书名等?
// 或者评注库记录本身就有文章名
// 实体库记录可以link到 book.aspx?itemrecpath=???
string strBiblioDbName = "";
// string strDbName = ResPath.GetDbName(strPath);
string strDbName = StringUtil.GetDbName(strPath);
string strDbType = this.App.GetDbType(strDbName,
out strBiblioDbName);
if (strDbType == null)
{
strError = "数据库 '" + strDbName + "' 的类型无法识别";
return -1;
}
string strItemMetadata = "";
XmlDocument itemdom = null;
string strBiblioRecPath = "";
if (strDbType == "item" || strDbType == "comment")
{
string strStyle = LibraryChannel.GETRES_ALL_STYLE;
string strItemXml = "";
byte[] item_timestamp = null;
string strItemOutputPath = "";
// TODO: 优化为成批获取
lRet = channel.GetRes(null,
strPath,
strStyle,
out strItemXml,
out strItemMetadata,
out item_timestamp,
out strItemOutputPath,
out strError);
if (lRet == -1)
{
strError = "获取记录 '" + strPath + "' 时发生错误: " + strError;
return -1;
}
nRet = OpacApplication.LoadToDom(strItemXml,
out itemdom,
out strError);
if (nRet == -1)
{
strError = "装载记录 '" + strPath + "' 进入XML DOM时发生错误: " + strError;
return -1;
}
string strParentID = DomUtil.GetElementText(itemdom.DocumentElement,
"parent");
strBiblioRecPath = strBiblioDbName + "/" + strParentID;
}
else if (strDbType == "biblio")
{
strBiblioRecPath = strPath;
}
// 从数据库中获取
示例7: DownloadFile
// 从 dp2library 服务器下载一个文件
// return:
// -1 出错
// 0 下载文件成功
static int DownloadFile(
Stop stop,
LibraryChannel channel,
string strServerFilePath,
string strClientFilePath,
out string strError)
{
strError = "";
string strMetaData = "";
byte[] baOutputTimeStamp = null;
string strOutputPath = "";
// parameters:
// strOutputFileName 输出文件名。可以为null。如果调用前文件已经存在, 会被覆盖。
// return:
// -1 出错。具体出错原因在this.ErrorCode中。this.ErrorInfo中有出错信息。
// 0 成功
long lRet = channel.GetRes(
stop,
strServerFilePath,
strClientFilePath,
out strMetaData,
out baOutputTimeStamp,
out strOutputPath,
out strError);
if (lRet == -1)
return -1;
return 0;
}
示例8: DownloadObject0
public int DownloadObject0(System.Web.UI.Page Page,
LibraryChannel channel,
string strPath,
bool bSaveAs,
string strStyle,
out string strError)
{
strError = "";
WebPageStop stop = new WebPageStop(Page);
// strPath = boards.GetCanonicalUri(strPath);
// 获得资源。写入文件的版本。特别适用于获得资源,也可用于获得主记录体。
// parameters:
// fileTarget 文件。注意在调用函数前适当设置文件指针位置。函数只会在当前位置开始向后写,写入前不会主动改变文件指针。
// strStyleParam 一般设置为"content,data,metadata,timestamp,outputpath";
// input_timestamp 若!=null,则本函数会把第一个返回的timestamp和本参数内容比较,如果不相等,则报错
// return:
// -1 出错。具体出错原因在this.ErrorCode中。this.ErrorInfo中有出错信息。
// 0 成功
string strMetaData = "";
string strOutputPath;
byte[] baOutputTimeStamp = null;
byte[] baContent = null;
// 只获得媒体类型
long lRet = channel.GetRes(
stop,
strPath,
0,
0,
"metadata",
out baContent,
out strMetaData,
out strOutputPath,
out baOutputTimeStamp,
out strError);
if (lRet == -1)
{
if (StringUtil.IsInList("hitcount", strStyle))
{
OutputImage(Page,
Color.FromArgb(100, Color.Red),
"?");
return 1;
}
if (channel.ErrorCode == ErrorCode.AccessDenied)
{
// 权限不够
return -1;
}
strError = "GetRes() (for metadata) Error : " + strError;
return -1;
}
if (Page.Response.IsClientConnected == false)
return -1;
// 取 metadata 中的 mime 类型信息
Hashtable values = StringUtil.ParseMedaDataXml(strMetaData,
out strError);
if (values == null)
{
strError = "ParseMedaDataXml() Error :" + strError;
return -1;
}
if (StringUtil.IsInList("hitcount", strStyle))
{
string strReadCount = (string)values["readCount"];
if (string.IsNullOrEmpty(strReadCount) == true)
strReadCount = "?";
OutputImage(Page,
Color.FromArgb(200, Color.DarkGreen),
strReadCount);
return 1;
}
#if NO
RETURN_IMAGE:
if (StringUtil.IsInList("hitcount", strStyle))
{
string strReadCount = (string)values["readCount"];
if (string.IsNullOrEmpty(strReadCount) == true)
strReadCount = "?";
// 文字图片
using (MemoryStream image = ArtText.BuildArtText(
strReadCount,
"Microsoft YaHei",
(float)12,
FontStyle.Regular,
Color.Black,
Color.White,
Color.Gray,
ArtEffect.None,
ImageFormat.Jpeg,
100))
{
//.........这里部分代码省略.........
示例9: MapFileToLocal
// 将内核网络配置文件映射到本地
// return:
// -1 出错
// 0 不存在
// 1 找到
public int MapFileToLocal(
LibraryChannel 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
{
string strMetaData = "";
byte[] baOutputTimestamp = null;
string strOutputPath = "";
long lRet = Channel.GetRes(
null,
strPath,
strLocalPath,
out strMetaData,
out baOutputTimestamp,
out strOutputPath,
out strError);
/*
long lRet = channel.GetRes(strPath,
strLocalPath,
(Stop)null,
out strMetaData,
out baOutputTimestamp,
out strOutputPath,
out strError);
* */
if (lRet == -1)
{
if (Channel.ErrorCode == CirculationClient.localhost.ErrorCode.NotFound)
{
// 为了避免以后再次从网络获取耗费时间, 需要在本地写一个0字节的文件
FileStream fs = File.Create(strLocalPath);
fs.Close();
return 0;
}
return -1;
}
return 1;
}
finally
{
this.locks.UnlockForWrite(strLocalPath);
}
}