|
20 | 20 | using Microsoft.Azure.ServiceManagement.Common.Models;
|
21 | 21 | using Microsoft.WindowsAzure.Commands.Common;
|
22 | 22 | using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
|
| 23 | +using Microsoft.WindowsAzure.Commands.Common.Properties; |
23 | 24 | using Microsoft.WindowsAzure.Commands.Common.Utilities;
|
24 | 25 | using System;
|
25 | 26 | using System.Collections.Concurrent;
|
@@ -57,12 +58,6 @@ public abstract class AzurePSCmdlet : PSCmdlet, IDisposable
|
57 | 58 | protected IList<Regex> _matchers { get; private set; } = new List<Regex>();
|
58 | 59 | private static readonly Regex _defaultMatcher = new Regex("(\\s*\"access_token\"\\s*:\\s*)\"[^\"]+\"");
|
59 | 60 |
|
60 |
| - // Using Ansi Code to control font color(97(Bold White)) and background color(0;120;212(RGB)) |
61 |
| - private static readonly string ansiCodePrefix = "\u001b[97;48;2;0;120;212m"; |
62 |
| - |
63 |
| - // using '[k' for erase in line. '[0m' to ending ansi code |
64 |
| - private static readonly string ansiCodeSuffix = "\u001b[K\u001b[0m"; |
65 |
| - |
66 | 61 | protected AzurePSDataCollectionProfile _dataCollectionProfile
|
67 | 62 | {
|
68 | 63 | get
|
@@ -463,40 +458,16 @@ protected bool IsVerbose()
|
463 | 458 |
|
464 | 459 | protected void WriteSurvey()
|
465 | 460 | {
|
466 |
| - HostInformationMessage newLine = new HostInformationMessage() |
467 |
| - { |
468 |
| - Message = ansiCodePrefix + "\n" + ansiCodeSuffix |
469 |
| - }; |
470 |
| - HostInformationMessage howWas = new HostInformationMessage() |
471 |
| - { |
472 |
| - Message = ansiCodePrefix + "[Survey] Help us improve Azure PowerShell by sharing your experience. This survey should take about 5 minutes. Run "+ ansiCodeSuffix, |
473 |
| - NoNewLine = true |
474 |
| - }; |
475 |
| - HostInformationMessage link = new HostInformationMessage() |
476 |
| - { |
477 |
| - Message = ansiCodePrefix + "'Open-AzSurveyLink'"+ ansiCodeSuffix, |
478 |
| - NoNewLine = true, |
479 |
| - }; |
480 |
| - HostInformationMessage action = new HostInformationMessage() |
481 |
| - { |
482 |
| - Message = ansiCodePrefix + " to open in browser. Learn more at "+ ansiCodeSuffix, |
483 |
| - NoNewLine = true, |
484 |
| - |
485 |
| - }; |
486 |
| - HostInformationMessage website = new HostInformationMessage() |
487 |
| - { |
488 |
| - Message = ansiCodePrefix + "https://go.microsoft.com/fwlink/?linkid=2202892"+ ansiCodeSuffix, |
489 |
| - NoNewLine = true, |
490 |
| - }; |
491 |
| - WriteInformation(newLine, new string[] { "PSHOST" }); |
492 |
| - WriteInformation(howWas, new string[] { "PSHOST" }); |
493 |
| - WriteInformation(link, new string[] { "PSHOST" }); |
494 |
| - WriteInformation(action, new string[] { "PSHOST" }); |
495 |
| - WriteInformation(website, new string[] { "PSHOST" }); |
496 |
| - WriteInformation(newLine, new string[] { "PSHOST" }); |
497 |
| - |
498 |
| - |
| 461 | + // Using color same with Azure brand event. |
| 462 | + // Using Ansi Code to control font color(97(Bold White)) and background color(0;120;212(RGB)) |
| 463 | + string ansiCodePrefix = "\u001b[97;48;2;0;120;212m"; |
| 464 | + // using '[k' for erase in line. '[0m' to ending ansi code |
| 465 | + string ansiCodeSuffix = "\u001b[K\u001b[0m"; |
| 466 | + var website = "https://go.microsoft.com/fwlink/?linkid=2202892"; |
| 467 | + WriteInformation(Environment.NewLine); |
| 468 | + WriteInformation(ansiCodePrefix + string.Format(Resources.SurveyPreface, website) + ansiCodeSuffix, false); |
499 | 469 | }
|
| 470 | + |
500 | 471 | protected new void WriteError(ErrorRecord errorRecord)
|
501 | 472 | {
|
502 | 473 | FlushDebugMessages();
|
@@ -551,6 +522,18 @@ protected void WriteSurvey()
|
551 | 522 | base.WriteWarning(text);
|
552 | 523 | }
|
553 | 524 |
|
| 525 | + protected new void WriteInformation(object messageData, string[] tags) |
| 526 | + { |
| 527 | + FlushDebugMessages(); |
| 528 | + base.WriteInformation(messageData, tags); |
| 529 | + } |
| 530 | + |
| 531 | + protected void WriteInformation(string text, bool? noNewLine = null) |
| 532 | + { |
| 533 | + HostInformationMessage message = new HostInformationMessage { Message = text, NoNewLine = noNewLine }; |
| 534 | + WriteInformation(message, new string[1] { "PSHOST" }); |
| 535 | + } |
| 536 | + |
554 | 537 | protected new void WriteCommandDetail(string text)
|
555 | 538 | {
|
556 | 539 | FlushDebugMessages();
|
@@ -593,6 +576,16 @@ protected void WriteWarningWithTimestamp(string message)
|
593 | 576 | }
|
594 | 577 | }
|
595 | 578 |
|
| 579 | + protected void WriteInformationWithTimestamp(string message) |
| 580 | + { |
| 581 | + if (CommandRuntime != null) |
| 582 | + { |
| 583 | + WriteInformation( |
| 584 | + new HostInformationMessage { Message = string.Format("{0:T} - {1}", DateTime.Now, message), NoNewLine = false }, |
| 585 | + new string[1] { "PSHOST" }); |
| 586 | + } |
| 587 | + } |
| 588 | + |
596 | 589 | protected void WriteDebugWithTimestamp(string message, params object[] args)
|
597 | 590 | {
|
598 | 591 | if (CommandRuntime != null)
|
|
0 commit comments