本文整理汇总了C#中DigitalPlatform.Stop.SetMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Stop.SetMessage方法的具体用法?C# Stop.SetMessage怎么用?C# Stop.SetMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DigitalPlatform.Stop
的用法示例。
在下文中一共展示了Stop.SetMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFileSize
// 获得一个日志文件的尺寸
// return:
// -2 此类型的日志尚未启用
// -1 error
// 0 file not found
// 1 found
static int GetFileSize(
Stop stop,
LibraryChannel channel,
string strCacheDir,
string strLogFileName,
LogType logType,
out long lServerFileSize,
out long lCacheFileSize,
out string strError)
{
strError = "";
lServerFileSize = 0;
lCacheFileSize = 0;
string strCacheFilename = PathUtil.MergePath(strCacheDir, strLogFileName);
FileInfo fi = new FileInfo(strCacheFilename);
if (fi.Exists == true)
lCacheFileSize = fi.Length;
stop.SetMessage("正获得日志文件 " + strLogFileName + " 的尺寸...");
string strXml = "";
long lAttachmentTotalLength = 0;
byte[] attachment_data = null;
string strStyle = "level-0";
if ((logType & LogType.AccessLog) != 0)
strStyle += ",accessLog";
// 获得日志文件尺寸
// return:
// -1 error
// 0 file not found
// 1 succeed
// 2 超过范围
long lRet = channel.GetOperLog(
stop,
strLogFileName,
-1, // lIndex,
-1, // lHint,
strStyle,
"", // strFilter
out strXml,
out lServerFileSize,
0, // lAttachmentFragmentStart,
0, // nAttachmentFramengLength,
out attachment_data,
out lAttachmentTotalLength,
out strError);
if (lRet == 0)
{
lServerFileSize = 0;
Debug.Assert(lServerFileSize == 0, "");
return 0;
}
if (lRet != 1)
return -1;
if (lServerFileSize == -1)
{
strError = "日志尚未启用";
return -2;
}
Debug.Assert(lServerFileSize >= 0, "");
return 1;
}
示例2: SearchAllLocation
//.........这里部分代码省略.........
{
#if NO
strError = "not found";
return 0; // not found
#endif
continue;
}
if (lRet == -1)
return -1;
long lHitCount = lRet;
long lStart = 0;
long lCount = lHitCount;
DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null;
// 装入浏览格式
for (; ; )
{
Application.DoEvents(); // 出让界面控制权
if (stop != null && stop.State != 0)
{
strError = "用户中断";
return -1;
}
lRet = channel.GetSearchResult(
stop,
"batchno", // strResultSetName
lStart,
lCount,
"keycount",
"zh",
out searchresults,
out strError);
if (lRet == -1)
{
strError = "GetSearchResult() error: " + strError;
return -1;
}
if (lRet == 0)
{
// MessageBox.Show(this, "未命中");
continue;
}
// 处理浏览结果
foreach (Record record in searchresults)
{
if (record.Cols == null)
{
strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出馆藏地的功能";
return -1;
}
if (this._libraryCodeList.Count > 0
&& MatchLibraryCode(this._libraryCodeList, record.Path) == false)
continue;
// 跳过数字为 0 的事项
if (record.Cols.Length > 0 && record.Cols[0] == "0")
continue;
ListViewItem item = new ListViewItem();
item.Text = string.IsNullOrEmpty(record.Path) == false ? record.Path : "[空]";
ListViewUtil.ChangeItemText(item, 1, record.Cols[0]);
this.listView_records.Items.Add(item);
}
lStart += searchresults.Length;
lCount -= searchresults.Length;
stop.SetMessage("共命中 " + (lTotalCount + lHitCount).ToString() + " 条,已装入 " + (lTotalCount + lStart).ToString() + " 条");
if (lStart >= lHitCount || lCount <= 0)
break;
}
lTotalCount += lHitCount;
}
if (lTotalCount == 0)
{
strError = "not found";
return 0;
}
}
finally
{
stop.EndLoop();
stop.OnStop -= new StopEventHandler(channel.DoStop);
stop.Initial("");
// EnableControls(true);
}
return 1;
}
示例3: SearchAllBatchNo
//.........这里部分代码省略.........
+ StringUtil.GetXmlStringSimple("")
+ "</word><match>left</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>";
strQueryXml += "<operator value='OR' />";
strQueryXml += "<item><word>"
+ StringUtil.GetXmlStringSimple("")
+ "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang></target>";
#endif
long lRet = channel.Search(
stop,
text.ToString(),
"batchno",
"keycount", // strOutputStyle
out strError);
if (lRet == 0)
{
strError = "not found";
return 0; // not found
}
if (lRet == -1)
return -1;
long lHitCount = lRet;
long lStart = 0;
long lCount = lHitCount;
DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null;
// 装入浏览格式
for (; ; )
{
Application.DoEvents(); // 出让界面控制权
if (stop != null && stop.State != 0)
{
strError = "用户中断";
return -1;
}
lRet = channel.GetSearchResult(
stop,
"batchno", // strResultSetName
lStart,
lCount,
"keycount",
"zh",
out searchresults,
out strError);
if (lRet == -1)
{
strError = "GetSearchResult() error: " + strError;
return -1;
}
if (lRet == 0)
{
// MessageBox.Show(this, "未命中");
return 0;
}
// 处理浏览结果
foreach (Record record in searchresults)
{
if (record.Cols == null)
{
strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出批次号的功能";
return -1;
}
// 跳过数字为 0 的事项
if (record.Cols.Length > 0 && record.Cols[0] == "0")
continue;
ListViewItem item = new ListViewItem();
item.Text = string.IsNullOrEmpty(record.Path) == false ? record.Path : "[空]";
ListViewUtil.ChangeItemText(item, 1, record.Cols[0]);
this.listView_records.Items.Add(item);
}
lStart += searchresults.Length;
lCount -= searchresults.Length;
stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条");
if (lStart >= lHitCount || lCount <= 0)
break;
}
}
finally
{
stop.EndLoop();
stop.OnStop -= new StopEventHandler(channel.DoStop);
stop.Initial("");
// EnableControls(true);
}
return 1;
}
示例4: ProcessFiles
//.........这里部分代码省略.........
strCacheDir,
"version.xml",
channel.LibraryCodeList,
channel.Url,
out strError);
if (nRet == -1)
return -1;
if (nRet == 1)
{
// 清空当前缓存目录
nRet = Global.DeleteDataDir(
owner,
strCacheDir,
out strError);
if (nRet == -1)
return -1;
PathUtil.CreateDirIfNeed(strCacheDir); // 重新创建目录
// 创建版本文件
nRet = CreateCacheVersionFile(
strCacheDir,
"version.xml",
channel.LibraryCodeList,
channel.Url,
out strError);
if (nRet == -1)
return -1;
}
}
long lTotalSize = 0;
List<string> lines = new List<string>(); // 经过处理后排除了不存在的文件名
List<long> sizes = new List<long>();
stop.SetMessage("正在准备获得日志文件尺寸 ...");
foreach (string strLine in filenames)
{
Application.DoEvents();
if (stop != null && stop.State != 0)
{
strError = "用户中断";
return 1;
}
if (String.IsNullOrEmpty(strLine) == true)
continue;
string strFilename = strLine.Trim();
// 去掉注释
nRet = strFilename.IndexOf("#");
if (nRet != -1)
strFilename = strFilename.Substring(0, nRet).Trim();
if (String.IsNullOrEmpty(strFilename) == true)
continue;
string strLogFilename = "";
string strRange = "";
nRet = strFilename.IndexOf(":");
if (nRet != -1)
{
strLogFilename = strFilename.Substring(0, nRet).Trim();
strRange = strFilename.Substring(nRet + 1).Trim();
}
else
示例5: ProcessFile
// 装入一个日志文件中的若干记录
// parameters:
// strStyle 如果包含 accessLog,表示这是需要获取只读日志
// strCacheDir 存储本地缓存文件的目录
// lServerFileSize 服务器端日志文件的尺寸。如果为-1,表示函数内会自动获取
// lSize 进度条所采用的最大尺寸。如果必要,可能会被本函数推动
// return:
// -2 此类型的日志尚未启用
// -1 error
// 0 正常结束
// 1 用户中断
static int ProcessFile(
IWin32Window owner,
Stop stop,
ProgressEstimate estimate,
LibraryChannel channel,
string strLogFileName,
int nLevel,
long lServerFileSize,
string strRange,
string strStyle,
string strCacheDir,
object param,
Delegate_doRecord procDoRecord,
ref long lProgressValue,
ref long lSize,
out string strError)
{
strError = "";
int nRet = 0;
long lRet = 0;
stop.SetMessage("正在装入日志文件 " + strLogFileName + " 中的记录。"
+ "剩余时间 " + ProgressEstimate.Format(estimate.Estimate(lProgressValue)) + " 已经过时间 " + ProgressEstimate.Format(estimate.delta_passed));
bool bAccessLog = StringUtil.IsInList("accessLog", strStyle);
string strXml = "";
long lAttachmentTotalLength = 0;
byte[] attachment_data = null;
long lFileSize = 0;
if (lServerFileSize == -1)
{
lServerFileSize = 0;
string strTempStyle = "level-" + nLevel.ToString();
if (bAccessLog)
strTempStyle += ",accessLog";
// 获得服务器端日志文件尺寸
lRet = channel.GetOperLog(
stop,
strLogFileName,
-1, // lIndex,
-1, // lHint,
strTempStyle,
"", // strFilter
out strXml,
out lServerFileSize,
0, // lAttachmentFragmentStart,
0, // nAttachmentFramengLength,
out attachment_data,
out lAttachmentTotalLength,
out strError);
// 2015/11/25
if (lRet == -1)
return -1;
// 2010/12/13
if (lRet == 0)
return 0;
if (lServerFileSize == -1)
{
strError = "日志尚未启用";
return -2;
}
}
Stream stream = null;
bool bCacheFileExist = false;
bool bRemoveCacheFile = false; // 是否要自动删除未全部完成的本地缓存文件
bool bAutoCache = StringUtil.IsInList("autocache", strStyle);
if (bAutoCache == true)
{
nRet = PrepareCacheFile(
strCacheDir,
bAccessLog ? strLogFileName + ".a" : strLogFileName,
lServerFileSize,
out bCacheFileExist,
out stream,
out strError);
if (nRet == -1)
return -1;
if (bCacheFileExist == false && stream != null)
bRemoveCacheFile = true;
}
//.........这里部分代码省略.........
示例6: SearchOneLocationItems
//.........这里部分代码省略.........
out strError);
if (lRet == -1)
return -1;
long lHitCount = lRet;
long lStart = 0;
long lCount = lHitCount;
DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null;
bool bOutputBiblioRecPath = false;
bool bOutputItemRecPath = false;
string strStyle = "";
if (strOutputStyle == "bibliorecpath")
{
bOutputBiblioRecPath = true;
strStyle = "id,cols,format:@coldef:*/parent";
}
else
{
bOutputItemRecPath = true;
strStyle = "id";
}
// 实体库名 --> 书目库名
Hashtable dbname_table = new Hashtable();
// 书目库记录路径,用于去重
Hashtable bilio_recpath_table = new Hashtable();
// 装入浏览格式
for (; ; )
{
Application.DoEvents(); // 出让界面控制权
if (stop != null && stop.State != 0)
{
strError = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条,用户中断...";
return -1;
}
lRet = channel.GetSearchResult(
stop,
null, // strResultSetName
lStart,
lCount,
strStyle, // bOutputKeyCount == true ? "keycount" : "id,cols",
"zh",
out searchresults,
out strError);
if (lRet == -1)
{
strError = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条," + strError;
return -1;
}
if (lRet == 0)
{
return 0;
}
// 处理浏览结果
for (int i = 0; i < searchresults.Length; i++)
{
DigitalPlatform.LibraryClient.localhost.Record searchresult = searchresults[i];
if (bOutputBiblioRecPath == true)
{
string strItemDbName = Global.GetDbName(searchresult.Path);
string strBiblioDbName = (string)dbname_table[strItemDbName];
if (string.IsNullOrEmpty(strBiblioDbName) == true)
{
strBiblioDbName = main_form.GetBiblioDbNameFromItemDbName(strItemDbName);
dbname_table[strItemDbName] = strBiblioDbName;
}
string strBiblioRecPath = strBiblioDbName + "/" + searchresult.Cols[0];
if (bilio_recpath_table.ContainsKey(strBiblioRecPath) == false)
{
results.Add(strBiblioRecPath);
bilio_recpath_table[strBiblioRecPath] = true;
}
}
else if (bOutputItemRecPath == true)
results.Add(searchresult.Path);
}
lStart += searchresults.Length;
lCount -= searchresults.Length;
stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条");
if (lStart >= lHitCount || lCount <= 0)
break;
}
return 0;
}
示例7: GetBatchNoTable
//.........这里部分代码省略.........
"批次号",
"left",
strLang,
"batchno", // strResultSetName
"desc",
"keycount", // strOutputStyle
out strError);
}
else
{
Debug.Assert(false, "");
}
if (lRet == -1)
goto ERROR1;
if (lRet == 0)
{
strError = "没有找到任何" + strName + "批次号检索点";
return;
}
long lHitCount = lRet;
long lStart = 0;
long lCount = lHitCount;
DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null;
// 装入浏览格式
for (; ; )
{
Application.DoEvents(); // 出让界面控制权
if (stop != null)
{
if (stop.State != 0)
{
strError = "用户中断";
goto ERROR1;
}
}
lRet = Channel.GetSearchResult(
stop,
"batchno", // strResultSetName
lStart,
lCount,
"keycount",
strLang,
out searchresults,
out strError);
if (lRet == -1)
{
strError = "GetSearchResult() error: " + strError;
goto ERROR1;
}
if (lRet == 0)
{
// MessageBox.Show(this, "未命中");
return;
}
// 处理浏览结果
for (int i = 0; i < searchresults.Length; i++)
{
if (searchresults[i].Cols == null)
{
strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出" + strName + "批次号的功能";
goto ERROR1;
}
KeyCount keycount = new KeyCount();
keycount.Key = searchresults[i].Path;
keycount.Count = Convert.ToInt32(searchresults[i].Cols[0]);
e.KeyCounts.Add(keycount);
}
lStart += searchresults.Length;
lCount -= searchresults.Length;
stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条");
if (lStart >= lHitCount || lCount <= 0)
break;
}
}
finally
{
stop.EndLoop();
stop.OnStop -= new StopEventHandler(Channel.DoStop);
stop.Initial("");
// EnableControls(true);
}
return;
ERROR1:
MessageBox.Show(owner, strError);
}
示例8: button_test_channelAttack_Click
private void button_test_channelAttack_Click(object sender, EventArgs e)
{
_stop = new DigitalPlatform.Stop();
_stop.Register(this.MainForm.stopManager, true); // 和容器关联
_stop.OnStop += new StopEventHandler(this.DoStop);
_stop.Style = StopStyle.EnableHalfStop;
_stop.Initial("正在测试耗费通道 ...");
_stop.BeginLoop();
this.button_test_channelAttack.Enabled = false;
this.numericUpDown_test_tryChannelCount.Enabled = false;
try
{
for (int i = 0; i < this.numericUpDown_test_tryChannelCount.Value; i++ )
{
Application.DoEvents();
if (_stop != null && _stop.State != 0)
break;
LibraryChannel channel = new LibraryChannel();
channel.Url = this.MainForm.LibraryServerUrl;
channel.BeforeLogin -= new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);
channel.BeforeLogin += new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);
string strValue = "";
string strError = "";
long lRet = channel.GetSystemParameter(_stop,
"library",
"name",
out strValue,
out strError);
#if NO
if (lRet == -1)
{
if (channel.ErrorCode == DigitalPlatform.CirculationClient.localhost.ErrorCode.OutofSession)
break;
}
#endif
_stop.SetMessage(i.ToString());
}
}
finally
{
this.numericUpDown_test_tryChannelCount.Enabled = true;
this.button_test_channelAttack.Enabled = true;
_stop.EndLoop();
_stop.OnStop -= new StopEventHandler(this.DoStop);
_stop.Initial("");
if (_stop != null) // 脱离关联
{
_stop.Unregister(); // 和容器关联
_stop = null;
}
}
}
示例9: button_test_loginAttack_Click
private void button_test_loginAttack_Click(object sender, EventArgs e)
{
LibraryChannel channel = new LibraryChannel();
channel.Url = this.MainForm.LibraryServerUrl;
channel.BeforeLogin -= new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);
channel.BeforeLogin += new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);
_stop = new DigitalPlatform.Stop();
_stop.Register(this.MainForm.stopManager, true); // 和容器关联
_stop.OnStop += new StopEventHandler(this.DoStop);
_stop.Style = StopStyle.EnableHalfStop;
_stop.Initial("正在试探密码 ...");
_stop.BeginLoop();
this.button_test_loginAttack.Enabled = false;
this.numericUpDown_test_tryChannelCount.Enabled = false;
try
{
for (int i = 0; i < this.numericUpDown_test_tryChannelCount.Value; i++)
{
Application.DoEvents();
if (_stop != null && _stop.State != 0)
break;
string strUserName = "supervisor";
string strPassword = i.ToString();
string strRights = "";
string strLibraryCode = "";
string strOutputUserName = "";
string strError = "";
long lRet = channel.Login(
strUserName,
strPassword,
"",
out strOutputUserName,
out strRights,
out strLibraryCode,
out strError);
#if NO
if (lRet == -1)
{
if (channel.ErrorCode == DigitalPlatform.CirculationClient.localhost.ErrorCode.OutofSession)
break;
}
#endif
_stop.SetMessage(i.ToString() + " username="+strUserName+" password="+strPassword+" lRet = " + lRet.ToString() + " " + strError);
}
}
finally
{
this.numericUpDown_test_tryChannelCount.Enabled = true;
this.button_test_loginAttack.Enabled = true;
_stop.EndLoop();
_stop.OnStop -= new StopEventHandler(this.DoStop);
_stop.Initial("");
if (_stop != null) // 脱离关联
{
_stop.Unregister(); // 和容器关联
_stop = null;
}
}
}
示例10: ReloadFullElementSet
// 为选定的行装入Full元素集的记录
public void ReloadFullElementSet()
{
string strError = "";
int nRet = 0;
ZConnection connection = this.GetCurrentZConnection();
if (connection == null)
{
strError = "当前ZConnection为空";
goto ERROR1;
}
if (connection.VirtualItems.SelectedIndices.Count == 0)
{
strError = "尚未选定要装入完整格式的浏览行";
goto ERROR1;
}
DigitalPlatform.Stop stop = null;
stop = new DigitalPlatform.Stop();
stop.Register(this.MainForm.stopManager, true); // 和容器关联
stop.BeginLoop();
this.EnableControls(false);
try
{
List<int> selected = new List<int>();
selected.AddRange(connection.VirtualItems.SelectedIndices);
stop.SetProgressRange(0, selected.Count);
for (int i = 0; i < selected.Count; i++)
{
Application.DoEvents(); // 出让界面控制权
if (stop != null)
{
if (stop.State != 0)
{
strError = "用户中断";
goto ERROR1;
}
}
int index = selected[i];
stop.SetMessage("正在重新装载记录 "+(index+1).ToString()+" 的详细格式...");
byte[] baTimestamp = null;
string strSavePath = "";
string strOutStyle = "";
LoginInfo logininfo = null;
long lVersion = 0;
string strXmlFragment = "";
DigitalPlatform.Z3950.Record record = null;
Encoding currentEncoding = null;
string strMARC = "";
nRet = this.GetOneRecord(
"marc",
index, // 即将废止
"index:" + index.ToString(),
"force_full", // false,
out strSavePath,
out strMARC,
out strXmlFragment,
out strOutStyle,
out baTimestamp,
out lVersion,
out record,
out currentEncoding,
out logininfo,
out strError);
if (nRet == -1)
goto ERROR1;
stop.SetProgressValue(i);
}
return;
}
finally
{
stop.EndLoop();
stop.SetMessage("");
stop.Unregister(); // 和容器关联
stop = null;
this.EnableControls(true);
}
// return 0;
ERROR1:
MessageBox.Show(this, strError);
}
示例11: FillAmercedLine
// 填充一个新的amerced行
// stop已经被外层BeginLoop()了
// TODO: Summary获得时出错,最好作为警告而不是错误。
// parameters:
// item ListView事项。如果为null,表示本函数需要创建新的事项
int FillAmercedLine(
ListViewItem item,
Stop stop,
string strXml,
string strRecPath,
bool bFillSummary,
out string strError)
{
strError = "";
XmlDocument dom = new XmlDocument();
try
{
dom.LoadXml(strXml);
}
catch (Exception ex)
{
strError = "XML装载到DOM时发生错误: " + ex.Message;
return -1;
}
string strItemBarcode = DomUtil.GetElementText(dom.DocumentElement, "itemBarcode");
string strItemRecPath = DomUtil.GetElementText(dom.DocumentElement, "itemRecPath");
string strSummary = "";
string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement, "readerBarcode");
string strLibraryCode = DomUtil.GetElementText(dom.DocumentElement, "libraryCode");
string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price");
string strComment = DomUtil.GetElementText(dom.DocumentElement, "comment");
string strReason = DomUtil.GetElementText(dom.DocumentElement, "reason");
string strBorrowDate = DomUtil.GetElementText(dom.DocumentElement, "borrowDate");
strBorrowDate = DateTimeUtil.LocalTime(strBorrowDate, "u");
string strBorrowPeriod = DomUtil.GetElementText(dom.DocumentElement, "borrowPeriod");
string strReturnDate = DomUtil.GetElementText(dom.DocumentElement, "returnDate");
strReturnDate = DateTimeUtil.LocalTime(strReturnDate, "u");
string strID = DomUtil.GetElementText(dom.DocumentElement, "id");
string strReturnOperator = DomUtil.GetElementText(dom.DocumentElement, "returnOperator");
string strState = DomUtil.GetElementText(dom.DocumentElement, "state");
strState = GetDisplayStateText(strState); // 2009/1/29
string strAmerceOperator = DomUtil.GetElementText(dom.DocumentElement, "operator");
string strAmerceTime = DomUtil.GetElementText(dom.DocumentElement, "operTime");
strAmerceTime = DateTimeUtil.LocalTime(strAmerceTime, "u");
string strSettlementOperator = DomUtil.GetElementText(dom.DocumentElement, "settlementOperator");
string strSettlementTime = DomUtil.GetElementText(dom.DocumentElement, "settlementOperTime");
strSettlementTime = DateTimeUtil.LocalTime(strSettlementTime, "u");
if (bFillSummary == true)
{
// stop.OnStop += new StopEventHandler(this.DoStop);
stop.SetMessage("正在获取摘要 " + strItemBarcode + " ...");
// stop.BeginLoop();
try
{
string strBiblioRecPath = "";
long lRet = Channel.GetBiblioSummary(
stop,
strItemBarcode,
strItemRecPath,
null,
out strBiblioRecPath,
out strSummary,
out strError);
if (lRet == -1)
{
strSummary = strError;
// return -1;
}
}
finally
{
// stop.EndLoop();
// stop.OnStop -= new StopEventHandler(this.DoStop);
// stop.Initial("");
}
}
string strOldState = null;
if (item == null)
{
item = new ListViewItem(strID, 0);
this.listView_amerced.Items.Add(item);
//.........这里部分代码省略.........
示例12: ExportToExcel
//.........这里部分代码省略.........
else if (header.TextAlign == HorizontalAlignment.Right)
alignments.Add(XLAlignmentHorizontalValues.Right);
else
alignments.Add(XLAlignmentHorizontalValues.Left);
column_max_chars.Add(0);
}
string strFontName = list.Font.FontFamily.Name;
int nRowIndex = 1;
int nColIndex = 1;
// foreach (ColumnHeader header in list.Columns)
foreach (int index in indices)
{
ColumnHeader header = list.Columns[index];
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(header.Text);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.Bold = true;
cell.Style.Font.FontName = strFontName;
cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
nColIndex++;
}
nRowIndex++;
//if (stop != null)
// stop.SetMessage("");
foreach (ListViewItem item in items)
{
Application.DoEvents();
if (stop != null
&& stop.State != 0)
{
strError = "用户中断";
return 0;
}
// List<CellData> cells = new List<CellData>();
nColIndex = 1;
// foreach (ListViewItem.ListViewSubItem subitem in item.SubItems)
foreach (int index in indices)
{
string strText = "";
ListViewItem.ListViewSubItem subitem = null;
if (index < item.SubItems.Count)
{
subitem = item.SubItems[index];
strText = subitem.Text;
}
else
{
}
// 统计最大字符数
int nChars = column_max_chars[nColIndex - 1];
if (string.IsNullOrEmpty(strText) == false && strText.Length > nChars)
{
column_max_chars[nColIndex - 1] = strText.Length;
}
IXLCell cell = sheet.Cell(nRowIndex, nColIndex).SetValue(strText);
cell.Style.Alignment.WrapText = true;
cell.Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
cell.Style.Font.FontName = strFontName;
cell.Style.Alignment.Horizontal = alignments[nColIndex - 1];
nColIndex++;
}
if (stop != null)
stop.SetProgressValue(nRowIndex - 1);
nRowIndex++;
}
if (stop != null)
stop.SetMessage("正在调整列宽度 ...");
Application.DoEvents();
double char_width = ClosedXmlUtil.GetAverageCharPixelWidth(list);
// 字符数太多的列不要做 width auto adjust
const int MAX_CHARS = 30; // 60
{
int i = 0;
foreach (IXLColumn column in sheet.Columns())
{
int nChars = column_max_chars[i];
if (nChars < MAX_CHARS)
column.AdjustToContents();
else
column.Width = (double)list.Columns[i].Width / char_width; // Math.Min(MAX_CHARS, nChars);
i++;
}
}
return 1;
}
示例13: UploadFile
//.........这里部分代码省略.........
{
for (int j = 0; j < ranges.Length; j++)
{
if (stop != null && stop.State != 0)
{
strError = "用户中断";
goto ERROR1;
}
RangeList rl = new RangeList(ranges[j]);
long uploaded = ((RangeItem)rl[0]).lStart;
string strPercent = "";
if (rl.Count >= 1)
{
double ratio = (double)uploaded / (double)fi.Length;
strPercent = String.Format("{0,3:N}", ratio * (double)100) + "%";
}
string strUploadedSize = GetSizeString(uploaded);
string strWaiting = "";
if (j == ranges.Length - 1)
{
strWaiting = " please wait ...";
channel.Timeout = new TimeSpan(0, 40, 0); // 40 分钟
}
else if (j > 0)
strWaiting = "剩余时间 " + ProgressEstimate.Format(_estimate.Estimate(uploaded)) + " 已经过时间 " + ProgressEstimate.Format(_estimate.delta_passed);
#if NO
if (stop != null)
stop.SetMessage( // strMessagePrefix +
"正在上载 " + ranges[j] + "/"
+ Convert.ToString(fi.Length)
+ " " + strPercent + " " + strClientFilePath + strWarning + strWaiting);
#endif
ProgressMessage(nCursorLeft, nCursorTop,
"uploading "
// + ranges[j] + "/" + Convert.ToString(fi.Length)
+ " " + strPercent + " "
+ strUploadedSize + "/" + strTotalSize + " "
// + strClientFilePath
+ strWarning + strWaiting);
int nRedoCount = 0;
REDO:
long lRet = channel.SaveResObject(
stop,
strResPath,
strClientFilePath,
strClientFilePath,
strMime,
ranges[j],
// j == ranges.Length - 1 ? true : false, // 最尾一次操作,提醒底层注意设置特殊的WebService API超时时间
timestamp,
strStyle,
out output_timestamp,
out strError);
timestamp = output_timestamp;
strWarning = "";
if (lRet == -1)
{
// 如果是第一个 chunk,自动用返回的时间戳重试一次覆盖
示例14: CreateReaderDetailExcelFile
//.........这里部分代码省略.........
{
ChargingHistoryLoader history_loader = new ChargingHistoryLoader();
history_loader.Channel = channel;
history_loader.Stop = stop;
history_loader.PatronBarcode = strBarcode;
history_loader.TimeRange = strTimeRange;
history_loader.Actions = "return,lost";
history_loader.Order = "descending";
CacheableBiblioLoader summary_loader = new CacheableBiblioLoader();
summary_loader.Channel = channel;
summary_loader.Stop = stop;
summary_loader.Format = "summary";
summary_loader.GetBiblioInfoStyle = GetBiblioInfoStyle.None;
// summary_loader.RecPaths = biblio_recpaths;
// 输出借阅历史表格
// 可能会抛出异常,例如权限不够
OutputBorrowHistory(sheet,
dom,
history_loader,
// this.MainForm.GetBiblioSummary,
summary_loader,
ref nRowIndex,
ref column_max_chars);
}
catch (Exception ex)
{
strError = "输出借阅历史时出现异常: " + ex.Message;
return -1;
}
finally
{
Program.MainForm.ReturnChannel(channel);
}
}
nRowIndex++; // 读者之间的空行
nReaderIndex++;
if (stop != null)
stop.SetProgressValue(nReaderIndex);
}
{
if (stop != null)
stop.SetMessage("正在调整列宽度 ...");
Application.DoEvents();
// 字符数太多的列不要做 width auto adjust
foreach (IXLColumn column in sheet.Columns())
{
int MAX_CHARS = 50; // 60
int nIndex = column.FirstCell().Address.ColumnNumber - 1;
if (nIndex >= column_max_chars.Count)
break;
int nChars = column_max_chars[nIndex];
if (nIndex == 1)
{
column.Width = 10;
continue;
}
if (nIndex == 3)
MAX_CHARS = 50;
else
MAX_CHARS = 24;
if (nChars < MAX_CHARS)
column.AdjustToContents();
else
column.Width = Math.Min(MAX_CHARS, nChars);
}
}
}
finally
{
if (doc != null)
{
doc.SaveAs(dlg.FileName);
doc.Dispose();
}
if (bLaunchExcel)
{
try
{
System.Diagnostics.Process.Start(dlg.FileName);
}
catch
{
}
}
}
return 1;
}
示例15: InitialProperties
//.........这里部分代码省略.........
/*
// 检查服务器端library.xml中<libraryserver url="???">配置是否正常
// return:
// -1 error
// 0 正常
// 1 不正常
nRet = CheckServerUrl(out strError);
if (nRet != 0)
MessageBox.Show(this, strError);
* */
// 核对本地和服务器时钟
// return:
// -1 error
// 0 没有问题
// 1 本地时钟和服务器时钟偏差过大,超过10分钟 strError中有报错信息
nRet = CheckServerClock(false, out strError);
if (nRet != 0)
MessageBox.Show(this, strError);
}
finally
{
EndSearch();
}
}
// 安装条码字体
InstallBarcodeFont();
END1:
Stop = new DigitalPlatform.Stop();
Stop.Register(stopManager, true); // 和容器关联
Stop.SetMessage("正在删除以前遗留的临时文件...");
/*
Type: System.UnauthorizedAccessException
Message: Access to the path 'D:\System Volume Information\' is denied.
Stack:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String
originalUserPath, String searchPattern, SearchOption searchOption,
SearchResultHandler`1 resultHandler)
at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern,
SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles()
at dp2Circulation.MainForm.DeleteAllTempFiles(String strDataDir)
at dp2Circulation.MainForm.DeleteAllTempFiles(String strDataDir)
at dp2Circulation.MainForm.InitialProperties(Boolean bFullInitial,
Boolean bRestoreLastOpenedWindow)
dp2Circulation 版本: dp2Circulation, Version=2.4.5715.19592,
Culture=neutral, PublicKeyToken=null
操作系统:Microsoft Windows NT 5.1.2600 Service Pack 3
* * */
try
{
DeleteAllTempFiles(this.DataDir);
}
catch (System.UnauthorizedAccessException ex)
{
MessageBox.Show(this, "在试图删除数据目录 '"+this.DataDir+"' 内临时文件时出错: " + ex.Message
+ "\r\n\r\n既然您把软件安装到这个目录或者试图从这里运行软件,就该给当前 Windows 用户赋予针对这个目录的列目录和删除文件的权限");
Application.Exit();