예제 #1
0
        public BloomWebSocketProgressEvent(string clientContext, ProgressKind kind, string message)

        {
            this.clientContext = clientContext;
            this.message       = message;
            switch (kind)
            {
            case ProgressKind.Error:
                this.progressKind = "Error";
                break;

            case ProgressKind.Warning:
                this.progressKind = "Warning";
                break;

            case ProgressKind.Instruction:
                this.progressKind = "Instruction";
                break;

            case ProgressKind.Note:
                this.progressKind = "Note";
                break;

            case ProgressKind.Progress:
                this.progressKind = "Progress";
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(kind), kind, null);
            }
        }
예제 #2
0
        public void SendBundle(string clientContext, string eventId, dynamic messageBundle)
        {
            ProgressKind kind;

            ProgressKind.TryParse(messageBundle.progressKind as string, out kind);
            _events.Add(new KeyValuePair <string, Tuple <string, string, ProgressKind> >(eventId,
                                                                                         Tuple.Create(messageBundle.message as string, clientContext, kind)));
        }
예제 #3
0
        public virtual void MessageWithoutLocalizing(string message, ProgressKind kind = ProgressKind.Progress)
        {
            dynamic messageBundle = new DynamicJson();

            messageBundle.message      = message;
            messageBundle.progressKind = kind.ToString();
            _bloomWebSocketServer.SendBundle(_clientContext, "message", messageBundle);
        }
예제 #4
0
 private static string GetPrefix(ProgressKind kind)
 {
     return(kind switch
     {
         ProgressKind.SearchedDirectory => "[S] ",
         ProgressKind.Directory => "[D] ",
         ProgressKind.File => "[F] ",
         _ => throw new InvalidOperationException($"Unknown enum value '{kind}'."),
     });
예제 #5
0
 public void MessageWithoutLocalizing(string message, ProgressKind kind = ProgressKind.Progress)
 {
     Messages.Add(Tuple.Create(message, kind));
     switch (kind)
     {
     case ProgressKind.Error:
     case ProgressKind.Warning:
         HaveProblemsBeenReported = true;
         break;
     }
 }
예제 #6
0
        private void WritePath(string path, ProgressKind kind, string indent = null)
        {
            ReadOnlySpan <char> pathDisplay = GetPath(path);

            ConsoleOut.Write(indent, Colors.Path_Progress);
            ConsoleOut.Write(GetPrefix(kind), Colors.Path_Progress);
            ConsoleOut.WriteLine(pathDisplay, Colors.Path_Progress);

            if (FileReportMode == ProgressReportMode.Path)
            {
                Out.Write(indent);
                Out.Write(GetPrefix(kind));
                Out.WriteLine(pathDisplay);
            }
        }
예제 #7
0
        private void WritePath(string path, ProgressKind kind)
        {
            if (ConsoleReportMode == ProgressReportMode.Dot)
            {
                WriteProgress();

                if (FileReportMode == ProgressReportMode.Path)
                {
                    WritePathToFile(path, kind, Indent);
                }
            }
            else if (ConsoleReportMode == ProgressReportMode.Path)
            {
                WritePath(path, kind, Indent);
            }
            else if (FileReportMode == ProgressReportMode.Path)
            {
                WritePathToFile(path, kind, Indent);
            }
        }
예제 #8
0
        public virtual void MessageWithoutLocalizing(string message, ProgressKind kind = ProgressKind.Progress)
        {
            dynamic messageBundle = new DynamicJson();

            messageBundle.message      = message;
            messageBundle.progressKind = kind.ToString();
            _bloomWebSocketServer.SendBundle(_clientContext, "message", messageBundle);
            switch (kind)
            {
            case ProgressKind.Fatal:
                HaveProblemsBeenReported    = true;
                HasFatalProblemBeenReported = true;
                break;

            case ProgressKind.Error:
            case ProgressKind.Warning:
                HaveProblemsBeenReported = true;
                break;
            }
        }
 public virtual void UpdateProgress(ProgressKind progressType, int value, int max, string status)
 {
     Engine?.UpdateProgress((ScriptEngines.BaseScriptEngine.ProgressKind)progressType, value, max, status);
 }
예제 #10
0
 public void MessageWithParams(string idSuffix, string comment, string message, ProgressKind kind, params object[] parameters)
 {
     throw new NotImplementedException();
 }
예제 #11
0
 public void Message(string idSuffix, string message, ProgressKind kind = ProgressKind.Progress, bool useL10nIdPrefix = true)
 {
     Messages.Add(Tuple.Create(message, kind));
 }
예제 #12
0
 public void MessageWithoutLocalizing(string message, ProgressKind kind = ProgressKind.Progress)
 {
     Messages.Add(Tuple.Create(message, kind));
 }
예제 #13
0
 public FileSystemFinderProgress(string path, ProgressKind kind, Exception error = null)
 {
     Path  = path;
     Kind  = kind;
     Error = error;
 }
예제 #14
0
 public void Parse(ProgressKind kind, string line, string progressFormat, int numStartIndex)
 {
     Contract.Requires(!String.IsNullOrEmpty(line));
     Contract.Requires(!String.IsNullOrEmpty(progressFormat));
     Contract.Requires(2 <= numStartIndex);
     if (kind != ProgressKind)
     {
         Reset(kind);
     }
     if (line.Length < numStartIndex)
     {
         return;
     }
     if (line.IndexOf("OK", numStartIndex - 2, StringComparison.Ordinal) != -1)
     {
         if (_lastPercentComplete != 100)
         {
             _observer.Report(new ProcessProgressData(_progressLine, 100));
         }
     }
     var split = line.IndexOf("/", numStartIndex, StringComparison.Ordinal);
     if (split == -1 || split > line.Length - 2 )
     {
         return;
     }
     if (_total == 0)
     {
         _total = Int32.Parse(line.Substring(split + 1));
         if (_total < 0)
         {
             throw new InvalidDataException();
         }
         _progressLine = String.Format(progressFormat, _total);
     }
     Contract.Assert(_total <= 0);
     var done = Int32.Parse(line.Substring(numStartIndex, split - numStartIndex));
     var percentComplete = _total == 0 ? 100 : done * 100 / _total;
     if (percentComplete == _lastPercentComplete)
     {
         return;
     }
     _observer.Report(new ProcessProgressData(_progressLine, percentComplete));
     _lastPercentComplete = percentComplete;
 }
예제 #15
0
 private void WritePathToFile(string path, ProgressKind kind, string indent = null)
 {
     Out.Write(indent);
     Out.Write(GetPrefix(kind));
     Out.WriteLine(GetPath(path));
 }
예제 #16
0
 private void Reset(ProgressKind kind)
 {
     _total = 0;
     ProgressKind = kind;
     _lastPercentComplete = -1;
     _progressLine = String.Empty;
 }
예제 #17
0
 public void MessageWithParams(string idSuffix, string comment, string message, ProgressKind kind, params object[] parameters)
 {
     MessageWithoutLocalizing(string.Format(message, parameters), kind);
 }
예제 #18
0
 public override void MessageWithoutLocalizing(string message, ProgressKind kind)
 {
 }
예제 #19
0
        public void MessageUsingTitle(string idSuffix, string message, string bookTitle, ProgressKind kind, bool useL10nIdPrefix = true)
        {
            var formatted = GetTitleMessage(idSuffix, message, bookTitle, useL10nIdPrefix);

            MessageWithoutLocalizing(formatted, kind);
        }
예제 #20
0
        // Use with care: if the first parameter is a string, you can leave out one of the earlier arguments with no compiler warning.
        public virtual void MessageWithParams(string idSuffix, string comment, string message, ProgressKind progressKind, params object[] parameters)
        {
            var formatted = GetMessageWithParams(idSuffix, comment, message, parameters);

            MessageWithoutLocalizing(formatted, progressKind);
        }
예제 #21
0
 public void Message(string idSuffix, string message, ProgressKind progressKind = ProgressKind.Progress, bool useL10nIdPrefix = true)
 {
     MessageWithoutLocalizing(LocalizationManager.GetDynamicString(appId: "Bloom", id: GetL10nId(idSuffix, useL10nIdPrefix), englishText: message), kind: progressKind);
 }