本文整理汇总了C#中IProgressStatus.ReportStatus方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressStatus.ReportStatus方法的具体用法?C# IProgressStatus.ReportStatus怎么用?C# IProgressStatus.ReportStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressStatus
的用法示例。
在下文中一共展示了IProgressStatus.ReportStatus方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishQueuedItems
public static bool PublishQueuedItems(Item triggerItem, Database[] targets, IProgressStatus progress = null)
{
if (ManuallyAddedCandidates.Count == 0) return false;
foreach (var database in targets)
{
if (progress != null) progress.ReportStatus("> Publishing {0} synced item{2} in queue to {1}", MessageType.Debug, ManuallyAddedCandidates.Count, database.Name, ManuallyAddedCandidates.Count == 1 ? string.Empty : "s");
var publishOptions = new PublishOptions(triggerItem.Database, database, PublishMode.SingleItem, triggerItem.Language, DateTime.UtcNow) { RootItem = triggerItem };
var result = new Publisher(publishOptions).PublishWithResult();
if (progress != null) progress.ReportStatus("> Published synced items to {0} (New: {1}, Updated: {2}, Deleted: {3} Skipped: {4})", MessageType.Debug, database.Name, result.Statistics.Created, result.Statistics.Updated, result.Statistics.Deleted, result.Statistics.Skipped);
}
return true;
}
示例2: GetPresetName
private IList<IncludeEntry> GetPresetName(IProgressStatus progress)
{
string presetName = Request.QueryString["preset"] ?? "default";
progress.ReportStatus("Using preset name {0}", MessageType.Info, presetName);
return SerializationUtility.GetPreset(presetName);
}
示例3: 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())
{
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>");
}
示例4: Process
protected override void Process(IProgressStatus progress)
{
progress.ReportStatus("Starting WebForms tasks demonstration...");
const int subtasks = 3;
for (int i = 1; i <= subtasks; i++)
{
using (var subtask = new SubtaskProgressStatus("Demonstration sub-task #" + i.ToString(CultureInfo.InvariantCulture), progress, i, subtasks + 1, false))
{
ExecuteTask(subtask);
}
progress.ReportStatus("Sub-task {0}/{1} done. Waiting a sec.", i, subtasks);
Thread.Sleep(1000);
}
progress.ReportStatus("Demonstrating nested sub-tasks...");
// you can also nest subtasks
// many times this might be used if a method that accepts an IProgressStatus itself calls sub-methods that also take an IProgressStatus
// methods that accept an IProgressStatus should *ALWAYS* presume that their progress should be reported as 0-100 (ie that they are running in a subtask)
using (var subtask = new SubtaskProgressStatus("Demonstration parent sub-task", progress, subtasks+1, subtasks + 1))
{
using (var innerSubtask = new SubtaskProgressStatus("Inner task 1", subtask, 1, 2))
{
ExecuteTask(innerSubtask);
}
using (var innerSubtask2 = new SubtaskProgressStatus("Inner task 2", subtask, 2, 2))
{
ExecuteTask(innerSubtask2);
}
}
progress.ReportStatus("WebForms tasks demo complete.");
progress.ReportStatus("Done.");
}
示例5: Process
protected override void Process(IProgressStatus progress)
{
// load the requested (or default) preset
var presets = GetPresetName(progress);
if (presets == null)
{
progress.ReportStatus("Preset did not exist in configuration.", MessageType.Error);
return;
}
for (int i = 0; i < presets.Count; i++)
{
using (var subtask = new SubtaskProgressStatus("Syncing preset path " + new ItemReference(presets[i].Database, presets[i].Path), progress, i+1, presets.Count))
{
ProcessPreset(presets[i], subtask);
}
}
}
示例6: 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);
}
}
示例7: 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>");
}
示例8: ShouldForceUpdate
/// <summary>
/// Checks to see if we should force an item to be written from the serialized version.
/// This changes the rules slightly from the default deserializer by forcing if the dates are
/// different instead of only if they are newer on disk.
/// </summary>
private bool ShouldForceUpdate(SyncItem syncItem, IProgressStatus progress)
{
Database db = Factory.GetDatabase(syncItem.DatabaseName);
Assert.IsNotNull(db, "Database was null");
Item target = db.GetItem(syncItem.ID);
if (target == null) return true; // target item doesn't exist - must force
// see if the modified date is different in any version (because disk is master, ANY changes we want to force overwrite)
return syncItem.Versions.Any(version =>
{
Item targetVersion = target.Database.GetItem(target.ID, Language.Parse(version.Language), Sitecore.Data.Version.Parse(version.Version));
var serializedModified = version.Values[FieldIDs.Updated.ToString()];
var itemModified = targetVersion[FieldIDs.Updated.ToString()];
if (!string.IsNullOrEmpty(serializedModified))
{
var result = string.Compare(serializedModified, itemModified, StringComparison.InvariantCulture) != 0;
if (result)
progress.ReportStatus(
string.Format("{0} ({1} #{2}): Disk modified {3}, Item modified {4}", syncItem.ItemPath, version.Language,
version.Version, serializedModified, itemModified), MessageType.Debug);
return result;
}
// ocasionally a version will not have a modified date, only a revision so we compare those as a backup
var serializedRevision = version.Values[FieldIDs.Revision.ToString()];
var itemRevision = targetVersion.Statistics.Revision;
if (!string.IsNullOrEmpty(serializedRevision))
{
var result = string.Compare(serializedRevision, itemRevision, StringComparison.InvariantCulture) != 0;
if (result)
progress.ReportStatus(
string.Format("{0} ({1} #{2}): Disk revision {3}, Item revision {4}", syncItem.ItemPath, version.Language,
version.Version, serializedRevision, itemRevision), MessageType.Debug);
return result;
}
// if we get here we have no valid updated or revision to compare. Let's ignore the item as if it was a real item it'd have one of these.
if(!syncItem.ItemPath.StartsWith("/sitecore/templates/System") && !syncItem.ItemPath.StartsWith("/sitecore/templates/Sitecore Client")) // this occurs a lot in stock system templates - we ignore warnings for those as it's expected.
progress.ReportStatus(string.Format("{0} ({1} #{2}): Serialized version had no modified or revision field to check for update.", syncItem.ItemPath, version.Language, version.Version), MessageType.Warning);
return false;
});
}
示例9: DeleteItem
/// <summary>
/// Deletes an item from Sitecore
/// </summary>
/// <returns>true if the item's database should have its template engine reloaded, false otherwise</returns>
private bool DeleteItem(Item item, IProgressStatus progress)
{
bool resetFromChild = DeleteItems(item.Children, progress);
Database db = item.Database;
ID id = item.ID;
string path = item.Paths.Path;
item.Recycle();
if (EventDisabler.IsActive)
{
db.Caches.ItemCache.RemoveItem(id);
db.Caches.DataCache.RemoveItemInformation(id);
}
progress.ReportStatus("[DELETED] {0}:{1} because it did not exist on disk".FormatWith(db.Name, path), MessageType.Warning);
if (!resetFromChild && item.Database.Engines.TemplateEngine.IsTemplatePart(item))
{
return true;
}
return false;
}
示例10: 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>");
}