本文整理汇总了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);
}
}
示例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);
//.........这里部分代码省略.........
示例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;
}