本文整理汇总了C#中System.Management.Automation.ProgressRecord类的典型用法代码示例。如果您正苦于以下问题:C# ProgressRecord类的具体用法?C# ProgressRecord怎么用?C# ProgressRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProgressRecord类属于System.Management.Automation命名空间,在下文中一共展示了ProgressRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetByWebAppName
private void GetByWebAppName()
{
const string progressDescriptionFormat = "Progress: {0}/{1} web apps processed.";
var progressRecord = new ProgressRecord(1, string.Format("Get web apps with name '{0}'", Name), "Progress:");
WriteProgress(progressRecord);
var sites = this.ResourcesClient.FilterPSResources(new PSResourceManagerModels.BasePSResourceParameters()
{
ResourceType = "Microsoft.Web/Sites"
}).Where(s => string.Equals(s.Name, Name, StringComparison.OrdinalIgnoreCase)).ToArray();
var list = new List<Site>();
for (var i = 0; i < sites.Length; i++)
{
var s = sites[i];
var result = WebsitesClient.GetWebApp(s.ResourceGroupName, s.Name, null);
if (result != null)
{
list.Add(result);
}
progressRecord.StatusDescription = string.Format(progressDescriptionFormat, i + 1, sites.Length);
progressRecord.PercentComplete = (100 * (i + 1)) / sites.Length;
WriteProgress(progressRecord);
}
WriteObject(list);
}
示例2: PowwaProgressRecord
public PowwaProgressRecord(ProgressRecord record)
{
if (record != null)
{
this.ActivityId = record.ActivityId;
this.ParentActivityId = record.ParentActivityId;
this.Activity = record.Activity;
this.StatusDescription = record.StatusDescription;
this.CurrentOperation = record.CurrentOperation;
this.PercentComplete = record.PercentComplete;
this.RecordType = record.RecordType;
if (record.SecondsRemaining <= 0)
{
this.TimeRemaining = string.Empty;
return;
}
else
{
object[] objArray = new object[1];
objArray[0] = TimeSpan.FromSeconds((double)record.SecondsRemaining);
this.TimeRemaining = string.Format(CultureInfo.CurrentCulture, "{0}", objArray);
return;
}
}
else
{
throw new ArgumentNullException("record");
}
}
示例3: HelpSystem_OnProgress
private void HelpSystem_OnProgress(object sender, HelpProgressInfo arg)
{
ProgressRecord progressRecord = new ProgressRecord(0, base.CommandInfo.Name, arg.Activity) {
PercentComplete = arg.PercentComplete
};
base.WriteProgress(progressRecord);
}
示例4: CmdletListener
//private readonly MemoryStream _MemoryStream = new MemoryStream();
public CmdletListener(DomainCommand command, ProgressRecord progress)
{
//_MemoryStream
//base.Writer = new StreamWriter();
_command = command;
_progress = progress;
}
示例5: RunTransferJob
protected async Task RunTransferJob(FileTransferJob job, ProgressRecord record)
{
this.SetRequestOptionsInTransferJob(job);
job.AccessCondition = this.AccessCondition;
job.OverwritePromptCallback = this.ConfirmOverwrite;
try
{
await this.transferJobRunner.RunTransferJob(job,
(percent, speed) =>
{
record.PercentComplete = (int)percent;
record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.FileTransmitStatus, (int)percent, Util.BytesToHumanReadableSize(speed));
this.OutputStream.WriteProgress(record);
},
this.CmdletCancellationToken);
record.PercentComplete = 100;
record.StatusDescription = Resources.TransmitSuccessfully;
this.OutputStream.WriteProgress(record);
}
catch (OperationCanceledException)
{
record.StatusDescription = Resources.TransmitCancelled;
this.OutputStream.WriteProgress(record);
}
catch (Exception e)
{
record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.TransmitFailed, e.Message);
this.OutputStream.WriteProgress(record);
throw;
}
}
示例6: AddProgress
internal void AddProgress(ProgressRecord item)
{
if (this.progress != null)
{
this.progress.InternalAdd(this.psInstanceId, item);
}
}
示例7: HandleTransferException
static private void HandleTransferException(Exception e, ProgressRecord record, TaskOutputStream outputStream)
{
if (record != null)
{
record.StatusDescription = string.Format(CultureInfo.CurrentCulture, Resources.TransmitFailed, e.Message);
outputStream.WriteProgress(record);
}
}
示例8: Validate
private static ProgressRecord Validate(ProgressRecord progressRecord)
{
if (progressRecord == null)
{
throw new ArgumentNullException("progressRecord");
}
return progressRecord;
}
示例9: OnStartTest
public void OnStartTest()
{
ProgressRecord pr = null;
command.OnTaskStart(pr);
pr = new ProgressRecord(0, "a", "b");
pr.PercentComplete = 10;
command.OnTaskStart(pr);
Assert.AreEqual(0, pr.PercentComplete);
}
示例10: WriteProgress
public override void WriteProgress(long sourceId, ProgressRecord record)
{
var ev = Progress;
if (null == ev)
{
return;
}
ev(this, new ProgressRecordEventArgs(sourceId, record));
}
示例11: ProcessRecord
protected override void ProcessRecord()
{
ProgressRecord progressRecord = new ProgressRecord(this.Id, this.Activity, this.Status) {
ParentActivityId = this.ParentId,
PercentComplete = this.PercentComplete,
SecondsRemaining = this.SecondsRemaining,
CurrentOperation = this.CurrentOperation,
RecordType = (this.Completed != 0) ? ProgressRecordType.Completed : ProgressRecordType.Processing
};
base.WriteProgress((long) this.SourceId, progressRecord);
}
示例12: ProgressRecord
/// <summary>
/// Cloning constructor (all fields are value types - can treat our implementation of cloning as "deep" copy)
/// </summary>
/// <param name="other"></param>
internal ProgressRecord(ProgressRecord other)
{
_activity = other._activity;
_currentOperation = other._currentOperation;
_id = other._id;
_parentId = other._parentId;
_percent = other._percent;
_secondsRemaining = other._secondsRemaining;
_status = other._status;
_type = other._type;
}
示例13: ProgressNode
internal ProgressNode(long sourceId, ProgressRecord record) : base(record.ActivityId, record.Activity, record.StatusDescription)
{
this.Style = ProgressNode.RenderStyle.FullPlus;
base.ParentActivityId = record.ParentActivityId;
base.CurrentOperation = record.CurrentOperation;
base.PercentComplete = Math.Min(record.PercentComplete, 100);
base.SecondsRemaining = record.SecondsRemaining;
base.RecordType = record.RecordType;
this.Style = ProgressNode.RenderStyle.FullPlus;
this.SourceId = sourceId;
}
示例14: SafeWriteProgress
public void SafeWriteProgress(ProgressRecord progress)
{
if (CommandRuntime != null)
{
WriteProgress(progress);
}
else
{
Trace.WriteLine(progress.StatusDescription);
}
}
示例15: Create
internal static ProgressDetails Create(ProgressRecord progressRecord)
{
//progressRecord.RecordType == ProgressRecordType.Completed;
//progressRecord.Activity;
//progressRecord.
return new ProgressDetails
{
PercentComplete = progressRecord.PercentComplete
};
}