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


C# IProgressHandler.ReportMessage方法代码示例

本文整理汇总了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;
        }
开发者ID:CUAHSI,项目名称:HydroClient,代码行数:19,代码来源:MetadataCacheSearcher.cs

示例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);
        }
开发者ID:CUAHSI,项目名称:HydroClient,代码行数:84,代码来源:HisCentralSearcher.cs


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