本文整理汇总了C#中IProgressHandler.ReportMessage方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressHandler.ReportMessage方法的具体用法?C# IProgressHandler.ReportMessage怎么用?C# IProgressHandler.ReportMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressHandler
的用法示例。
在下文中一共展示了IProgressHandler.ReportMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSeriesCatalogForBox
protected override IEnumerable<SeriesDataCart> GetSeriesCatalogForBox(double xMin, double xMax, double yMin, double yMax, string keyword,
DateTime startDate, DateTime endDate, int[] networkIDs, IProgressHandler bgWorker, long currentTile, long totalTilesCount)
{
bgWorker.ReportMessage(string.Format("Executed query to the database. Keyword: {0}. Tile {1}/{2}.", keyword, currentTile, totalTilesCount));
var dt = _db.GetSeriesDataTableInBox(xMin, xMax, yMin, yMax, new []{keyword}, startDate, endDate, networkIDs);
var seriesList = new List<SeriesDataCart>(dt.Rows.Count);
foreach (DataRow row in dt.Rows)
{
var series = _db.SeriesDataCartFromRow(row);
if (series != null)
{
// Update BeginDate/EndDate/ValueCount to the user-specified range
SearchHelper.UpdateDataCartToDateInterval(series, startDate, endDate);
seriesList.Add(series);
}
}
return seriesList;
}
示例2: GetSeriesCatalogForBox
protected override IEnumerable<SeriesDataCart> GetSeriesCatalogForBox(double xMin, double xMax, double yMin,
double yMax, string keyword,
DateTime startDate, DateTime endDate,
int[] networkIDs,
IProgressHandler bgWorker, long currentTile, long totalTilesCount)
{
var url = new StringBuilder();
url.Append(_hisCentralUrl);
url.Append("/GetSeriesCatalogForBox2");
url.Append("?xmin=");
url.Append(Uri.EscapeDataString(xMin.ToString(_invariantCulture)));
url.Append("&xmax=");
url.Append(Uri.EscapeDataString(xMax.ToString(_invariantCulture)));
url.Append("&ymin=");
url.Append(Uri.EscapeDataString(yMin.ToString(_invariantCulture)));
url.Append("&ymax=");
url.Append(Uri.EscapeDataString(yMax.ToString(_invariantCulture)));
//to append the keyword
url.Append("&conceptKeyword=");
if (!String.IsNullOrEmpty(keyword))
{
url.Append(Uri.EscapeDataString(keyword));
}
//to append the list of networkIDs separated by comma
url.Append("&networkIDs=");
if (networkIDs != null)
{
var serviceParam = new StringBuilder();
for (int i = 0; i < networkIDs.Length - 1; i++)
{
serviceParam.Append(networkIDs[i]);
serviceParam.Append(",");
}
if (networkIDs.Length > 0)
{
serviceParam.Append(networkIDs[networkIDs.Length - 1]);
}
url.Append(Uri.EscapeDataString(serviceParam.ToString()));
}
//to append the start and end date
url.Append("&beginDate=");
url.Append(Uri.EscapeDataString(startDate.ToString("MM/dd/yyyy")));
url.Append("&endDate=");
url.Append(Uri.EscapeDataString(endDate.ToString("MM/dd/yyyy")));
var keywordDesc = string.Format("[{0}. Tile {1}/{2}]",
String.IsNullOrEmpty(keyword) ? "All" : keyword, currentTile,
totalTilesCount);
// Try to send request several times (in case, when server returns timeout)
const int tryCount = 5;
for (int i = 0; i < tryCount; i++)
{
try
{
bgWorker.CheckForCancel();
bgWorker.ReportMessage(i == 0
? string.Format("Sent request: {0}", keywordDesc)
: string.Format("Timeout has occurred for {0}. New Attempt ({1} of {2})...",
keywordDesc, i + 1, tryCount));
var request = WebRequest.Create(url.ToString());
request.Timeout = 30 * 1000;
using (var response = request.GetResponse())
using (var reader = XmlReader.Create(response.GetResponseStream()))
{
bgWorker.ReportMessage(string.Format("Data received for {0}", keywordDesc));
return ParseSeries(reader, startDate, endDate);
}
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.Timeout)
{
continue;
}
throw;
}
}
throw new WebException("Timeout. Try to decrease Search Area, or Select another Keywords.", WebExceptionStatus.Timeout);
}