Пример #1
0
 public void RefreshPluginData()
 {
     try
     {
         var found = false;
         foreach (var plugin in MainViewModel.Instance.Plugins)
         {
             if (!plugin.StartsWith(Global.LibdcpluginLogging))
             {
                 continue;
             }
             var a = plugin.Split(',');
             LogFile = a[1];
             found   = true;
         }
         if (!found)
         {
             LogFile   = string.Empty;
             IsLogging = false;
             LogLines.Clear();
         }
     }
     catch (Exception)
     {
         LogFile   = string.Empty;
         IsLogging = false;
         LogLines.Clear();
     }
 }
        private async Task GenerateScriptsInternalAsync(string commandValue)
        {
            LogLines.Clear();
            DacDbHistorySchemaControllerBuilder builder    = new DacDbHistorySchemaControllerBuilder(this.Configuration, this.LogLines);
            DbHistorySchemaController           controller = null;

            DacSchemaReader reader       = null;
            FileStream      sourceStream = null;

            switch (_sourceType)
            {
            case EndPointType.FilePath:
                sourceStream = new FileStream(_source, FileMode.Open, FileAccess.Read);
                reader       = new DacSchemaReader(sourceStream, true, this.LogLines);
                break;

            case EndPointType.ConnectionString:
                reader = new DacSchemaReader(_source, this.LogLines);
                break;

            case EndPointType.FolderPath:
                throw new InvalidOperationException("Source cannot be of type folder");
            }
            try
            {
                switch (_destinationType)
                {
                case EndPointType.FilePath:
                    controller = builder.Build(reader, new FileScriptDestinationWriter(Destination, this.Configuration, this.LogLines));
                    break;

                case EndPointType.ConnectionString:
                    controller = builder.Build(reader, new DbScriptDestinationWriter(Destination, this.LogLines));
                    break;

                case EndPointType.FolderPath:
                    controller = builder.Build(reader, new FolderScriptDestinationWriter(new DestinationConfiguration()
                    {
                        Common      = this.Configuration,
                        Destination = Destination
                    }, this.LogLines));
                    break;
                }
                if (controller != null)
                {
                    controller.GenerateHistorySchemaObjects();
                }
            }
            finally
            {
                if (sourceStream != null)
                {
                    sourceStream.Dispose();
                }
            }
        }
Пример #3
0
        private void OnLogTextChanged(RawContentsChangedEventArgs args)
        {
            Debug.WriteLine("RawContentChanged event fired");

            LogLines.Clear();
            LogLines.AddRange(args.NewText
                              .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                              .Select(line => new LogLine(line.Trim(), LogHighlight.None)));

            RawContentChanged?.Invoke(this, args);
        }
Пример #4
0
        protected override void UpdateFromSelected()
        {
            try
            {
                this.LogLines?.Clear();
                var content = File.ReadLines(Path.Combine(this.LogPath, this.SelectedLogFile));
                foreach (var line in content)
                {
                    LogLines.Add(new LogViewer.Log(line));
                }
            }
            catch (Exception ex)
            {
                Log("Read log failed" + ex.Message, Category.Warn);

                LogLines?.Clear();
            }
        }
Пример #5
0
        // Jeder Aufruf des ViewModel targets wird ins ViewModel eingetragen. (Log Level Checks passieren ja schon im NLog Framework).
        private void LogViewModel(string level, string message)
        {
            NLog.LogLevel nl    = NLog.LogLevel.FromString(level);
            Level         myLev = FromNlogLevel(nl);

            Application.Current.Dispatcher.BeginInvoke(
                new Action(() => {
                if (LogLines.Count > C_MAXLINESINGUI)
                {
                    LogLines.Clear();
                    LogLines.Add(new LogRecord()
                    {
                        Level = Level.Error, Message = $"******* GUI deleted Log lines after {C_MAXLINESINGUI} lines! *******"
                    });
                }
                LogLines.Add(new LogRecord()
                {
                    Level = myLev, Message = message
                });
            }
                           ));
        }
Пример #6
0
        private async void Log()
        {
            try
            {
                if (_isLogging)
                {
                    if (!string.IsNullOrEmpty(_logFile))
                    {
                        if (File.Exists(_logFile))
                        {
                            await Task.Run(() =>
                            {
                                using (var reader = new StreamReader(new FileStream(_logFile,
                                                                                    FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                                {
                                    //start at the end of the file
                                    var lastMaxOffset = reader.BaseStream.Length;

                                    while (_isLogging)
                                    {
                                        Thread.Sleep(100);
                                        //if the file size has not changed, idle
                                        if (reader.BaseStream.Length == lastMaxOffset)
                                        {
                                            continue;
                                        }

                                        //seek to the last max offset
                                        reader.BaseStream.Seek(lastMaxOffset, SeekOrigin.Begin);

                                        //read out of the file until the EOF
                                        string line;
                                        while ((line = reader.ReadLine()) != null)
                                        {
                                            var logLine = new LogLine(line);
                                            AddLogLine(logLine);
                                        }

                                        //update the last max offset
                                        lastMaxOffset = reader.BaseStream.Position;
                                    }
                                }
                            });
                        }
                        else
                        {
                            IsLogging = false;
                            _windowManager.ShowMetroMessageBox(
                                LocalizationEx.GetUiString("log_modal_no_log_file_text", Thread.CurrentThread.CurrentCulture),
                                LocalizationEx.GetUiString("log_modal_no_log_file_header", Thread.CurrentThread.CurrentCulture),
                                MessageBoxButton.OK, BoxType.Warning);
                        }
                    }
                    else
                    {
                        IsLogging = false;
                        _windowManager.ShowMetroMessageBox(
                            LocalizationEx.GetUiString("log_modal_no_log_file_text", Thread.CurrentThread.CurrentCulture),
                            LocalizationEx.GetUiString("log_modal_no_log_file_header", Thread.CurrentThread.CurrentCulture),
                            MessageBoxButton.OK, BoxType.Warning);
                    }
                }
                else
                {
                    Execute.OnUIThread(() => { LogLines.Clear(); });
                }
            }
            catch (Exception)
            {
            }
        }