本文整理汇总了C#中IProgressStatus.ReportTransientStatus方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressStatus.ReportTransientStatus方法的具体用法?C# IProgressStatus.ReportTransientStatus怎么用?C# IProgressStatus.ReportTransientStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressStatus
的用法示例。
在下文中一共展示了IProgressStatus.ReportTransientStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessInternal
protected virtual void ProcessInternal(IProgressStatus progress)
{
if (_headingService != null && !_isAutomatedTool)
{
progress.ReportStatus(_headingService.GetHeadingHtml());
}
// note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs
progress.ReportTransientStatus("Executing.");
var heartbeat = new Timer(3000);
var startTime = DateTime.Now;
heartbeat.AutoReset = true;
heartbeat.Elapsed += (sender, args) =>
{
var elapsed = Math.Round((args.SignalTime - startTime).TotalSeconds);
try
{
progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
}
catch
{
// e.g. HTTP connection disconnected - prevent infinite looping
heartbeat.Stop();
}
};
heartbeat.Start();
try
{
using (new SecurityDisabler())
{
_processAction(progress);
}
}
finally
{
heartbeat.Stop();
}
progress.Report(100);
progress.ReportTransientStatus("Completed.");
progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
progress.ReportStatus(_isAutomatedTool ? "Completed." : "Completed. Want to <a href=\"?verb=\">return to the control panel?</a>");
}
示例2: Process
protected override void Process(IProgressStatus progress)
{
progress.ReportStatus("Starting WebForms demonstration...");
for (int i = 0; i <= 100; i++)
{
// slight delay to see loading time
System.Threading.Thread.Sleep(50);
// advance the progress bar status (you can use x % as well as x of y total items)
progress.Report(i);
// demonstrate setting a substatus of the progress bar (e.g. "making database backup")
if (i % 10 == 0) progress.ReportTransientStatus(string.Format("{0}/{1}", i, 100));
// write some stuff to the console to demonstrate detailed output
progress.ReportStatus("At {0}", MessageType.Info, i);
if (i == 90) progress.ReportStatus("Oops, fake error", MessageType.Error);
if (i == 91) progress.ReportStatus("Warning: this can be harmful if misused.", MessageType.Warning);
if (i == 92)
{
progress.ReportStatus("You can also {0} {1}", MessageType.Debug, "use", "string formatting");
}
if (i == 95)
{
progress.ReportStatus("I'm about to throw an exception and write its data to the console!");
// code that can throw an exception should have it caught and written to the console
// normally you might wrap the whole processing in a try-catch block
try
{
throw new Exception("I'm giving it all she's got Jim!", new Exception("Warp core breach"));
}
catch(Exception ex)
{
progress.ReportException(ex);
}
}
}
progress.ReportStatus("WebForms demo complete. See the <a href=\"Tasks.aspx\">tasks demo</a> and the <a href=\"customized.aspx\">customization demo</a>");
}
示例3: ExecuteTask
protected void ExecuteTask(IProgressStatus progress)
{
for (int i = 0; i <= 100; i++)
{
// slight delay to see loading time
Thread.Sleep(10);
// demonstrate setting a substatus of the progress bar (e.g. "making database backup")
if (i % 10 == 0)
{
progress.ReportTransientStatus(string.Format("{0}/{1}", i, 100));
// write some stuff to the console to demonstrate detailed output
progress.ReportStatus("Task percent {0}", MessageType.Info, i);
}
// advance the progress bar status (you can use x % as well as x of y total items)
progress.Report(i);
}
}
示例4: ProcessInternal
protected virtual void ProcessInternal(IProgressStatus progress)
{
// this bad-ass ASCII art is from http://www.ascii-art.de/ascii/uvw/unicorn.txt - original credit to 'sk'
const string unicorn = @"<pre>
/
.7
\ , //
|\.--._/|//
/\ ) ) ).'/
/( \ // / _ _ _ _ ___ ____ ___ ____ _ _
/( J`((_/ \ | | | | \ | |_ _/ ___/ _ \| _ \| \ | |
/ ) | _\ / | | | | \| || | | | | | | |_) | \| |
/|) \ eJ L | |_| | |\ || | |__| |_| | _ <| |\ |
| \ L \ L L \___/|_| \_|___\____\___/|_| \_\_| \_|
/ \ J `. J L
| ) L \/ \
/ \ J (\ /
| \ \ \```
</pre>";
// note: these logs are intentionally to progress and not loggingConsole as we don't need them in the Sitecore logs
progress.ReportStatus(unicorn, MessageType.Warning);
progress.ReportTransientStatus("Executing.");
var heartbeat = new Timer(3000);
var startTime = DateTime.Now;
heartbeat.AutoReset = true;
heartbeat.Elapsed += (sender, args) =>
{
var elapsed = Math.Round((args.SignalTime - startTime).TotalSeconds);
progress.ReportTransientStatus("Executing for {0} sec.", elapsed.ToString(CultureInfo.InvariantCulture));
};
heartbeat.Start();
try
{
using (new SecurityDisabler())
{
using (new ItemFilterDisabler()) // disable all item filtering (if we're running in live mode we need this to get unadulterated items)
{
Process(progress);
}
}
}
finally
{
heartbeat.Stop();
}
progress.Report(100);
progress.ReportTransientStatus("Completed.");
progress.ReportStatus(_isAutomatedTool ? "\r\n" : "<br>");
progress.ReportStatus("Completed. Want to <a href=\"?verb=\">return to the control panel?</a>");
}