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


C# IProgressReporter.Report方法代码示例

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


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

示例1: WriteDelimitedFile

        /// <summary>
        /// Writes a delimited file using the given format.
        /// </summary>
        /// <param name="reporter"></param>
        /// <param name="data"></param>
        /// <param name="writer"></param>
        /// <param name="delimiter_type"></param>
        /// <param name="format"></param>
        public static void WriteDelimitedFile(
            IProgressReporter reporter,
            string[][] data,
            TextWriter writer,
            DelimiterType delimiter_type,
            IDelimitedFormat format)
        {
            // get the delimiter character
            char delimiter = GetDelimiterChar(delimiter_type);

            // initialize the progress status.
            ProgressStatus status = new ProgressStatus();
            if (reporter != null)
            {
                status.TotalNumber = data.Length;
                status.Status = ProgressStatus.ProgressStatusEnum.Busy;
                status.CurrentNumber = 0;
                status.Message = "Creating File...";

                // report the status.
                reporter.Report(status);
            }

            // export data
            if (reporter != null)
            {
                status.Message = "Exporting... {progress}!";
            }
            for (int idx = 0; idx < data.Length; idx++)
            {
                string[] line = data[idx];
                if (line != null &&
                    line.Length > 0)
                {
                    for (int col_idx = 0; col_idx < line.Length; col_idx++)
                    {
                        if (format.DoExport(idx))
                        {
                            object field_data = line[col_idx];
                            string field_data_string = format.ConvertValue(col_idx, field_data);
                            writer.Write(field_data_string);
                            // only delimiter at the end
                            if (col_idx < line.Length - 1)
                            {
                                writer.Write(delimiter);
                            }
                        }
                    }
                }
                if (reporter != null)
                {
                    status.CurrentNumber = idx + 1;
                    reporter.Report(status);
                }
                writer.WriteLine();
            }

            // report done
            if (reporter != null)
            {
                status.Message = "Exporting Done!";
                status.Status = ProgressStatus.ProgressStatusEnum.Succeeded;
                reporter.Report(status);
            }
        }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:73,代码来源:DelimitedFileHandler.cs

示例2: ReadDelimitedFile

        /// <summary>
        /// Reads a delimited file.
        /// </summary>
        /// <param name="reporter"></param>
        /// <param name="file"></param>
        /// <param name="delimiter"></param>
        /// <param name="firstRowHasHeaders"></param>
        /// <returns></returns>
        public static string[][] ReadDelimitedFile(
            IProgressReporter reporter, 
            FileInfo file, 
            DelimiterType delimiter, 
            bool firstRowHasHeaders)
        {
            if (reporter == null)
            {
                reporter = EmptyProgressReporter.Instance;
            }

            char delimiterChar = DelimitedFileHandler.GetDelimiterChar(delimiter);

            List<string[]> delimited_data_set;
            //int iCounter = 0;
            ProgressStatus status;
            if (!file.Exists)
            {
                throw new FileNotFoundException(string.Format("Input file {0} not found!", file.FullName));
            }
            else
            {
                // Build dataset
                delimited_data_set = new List<string[]>();
                //Add the table               'Read the delimited file

                System.Text.Encoding enc = null;
                enc = System.Text.Encoding.GetEncoding("iso-8859-1");
                FileStream fileStream = new FileStream(file.FullName,
                    FileMode.Open, FileAccess.Read, FileShare.Read);
                StringBuilder strBuild = new StringBuilder(Convert.ToInt32(fileStream.Length));

                // report the status.
                status = new ProgressStatus();
                status.Status = ProgressStatus.ProgressStatusEnum.Busy;
                status.CurrentNumber = 0;
                status.Message = "Opening file...";

                reporter.Report(status);

                for (int i = 0; i <= Convert.ToInt32(fileStream.Length) - 1; i++)
                {
                    byte[] bytes = new byte[] {Convert.ToByte(fileStream.ReadByte())};
                    strBuild.Append(enc.GetString(bytes, 0, bytes.Length));
                }

                fileStream.Close();
                string str = strBuild.ToString();
                StringReader strReader = new StringReader(str);
                List<string> lines = new List<string>();
                while ((strReader.Peek() > -1)) {
                    lines.Add(strReader.ReadLine());
                }

                // Now add in the Rows
                // report the status.
                status = new ProgressStatus();
                status.Status = ProgressStatus.ProgressStatusEnum.Busy;
                status.CurrentNumber = 0;
                status.Message = "Reading file...";
                reporter.Report(status);

                int startLine = 0;
                if (firstRowHasHeaders)
                {
                    startLine = 1;
                }

                //Loop while there are rows in the delimited file
                for (int l = startLine; l < lines.Count; l++) {
                    string line = lines[l];

                    //Add the items to the DataSet
                    delimited_data_set.Add(line.Split(delimiterChar));

                    // report the status.
                    status = new ProgressStatus();
                    status.Status = ProgressStatus.ProgressStatusEnum.Busy;
                    status.CurrentNumber = l;
                    status.TotalNumber = lines.Count - 1;
                    status.Message = "Reading file...";
                    reporter.Report(status);
                }
            }

            // report the status.
            status = new ProgressStatus();
            status.Status = ProgressStatus.ProgressStatusEnum.Succeeded;
            status.CurrentNumber = 0;
            status.Message = "Reading file...";
            reporter.Report(status);

//.........这里部分代码省略.........
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:101,代码来源:DelimitedFileHandler.cs

示例3: Save

        /// <summary>
        /// Saves the solution file.
        /// </summary>
        /// <param name = "reporter">The progress reporter to use for logging.</param>
        public override void Save(IProgressReporter reporter)
        {
            reporter.ProgressVisible = true;
            for (int i = 0; i < Nodes.Count; i++)
            {
                reporter.Report("Saving {0}.", Nodes[i].Name);
                Nodes[i].Save(reporter);
                //progressReporter.ProgressPercentage = (int)(((double)Nodes.Count / (double)i) * 100);
            }

            reporter.Report("Writing solution file.");

            using (var writer = new StreamWriter(FilePath.FullPath))
            {
                using (var solutionWriter = new SolutionWriter(writer))
                {
                    solutionWriter.WriteSolution(this);
                }
            }

            reporter.Report("Writing solution settings.");

            Settings.Save(FilePath.ChangeExtension(".litesettings").FullPath);

            reporter.Report("Finished saving solution.");
            reporter.ProgressVisible = false;
            HasUnsavedData = false;
        }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:32,代码来源:Solution.cs


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