Exemplo n.º 1
0
 public void RemoveGroup(LogGroup group)
 {
     Logs.Groups.RemoveAll(g => g.Id.Equals(group.Id));
     SaveState();
     OnLogGroupCollectionChanged();
     OnLogGroupDeleted();
 }
Exemplo n.º 2
0
 public void AddGroup(LogGroup group)
 {
     Logs.Groups.Add(group);
     SaveState();
     OnLogGroupCollectionChanged();
     OnLogGroupAdded(group);
 }
 public EditGroupWindow(LogGroup group)
     : this()
 {
     var vm = DataContext as AddGroupViewModel;
     if (vm == null) return;
     vm.Group = group;
 }
Exemplo n.º 4
0
        public void UpdateGroup(LogGroup group)
        {
            var existingGroup = Logs.Groups.First(g => g.Id.Equals(group.Id));

            existingGroup.Name = group.Name;
            SaveState();
            OnLogGroupCollectionChanged();
            OnLogGroupEdited(group);
        }
Exemplo n.º 5
0
        public LogPicker(LogGroup selectedGroup)
            : this()
        {
            var vm = DataContext as LogPickerDialogViewModel;
            if(vm == null)
                throw new InvalidOperationException("Group context not found!");

            vm.SelectedGroup = selectedGroup;
        }
Exemplo n.º 6
0
        public void Execute(object parameter)
        {
            var window = parameter as Window;
            if (window == null) return;

            var group = new LogGroup(_vm.GroupName);
            LogSource.Instance.Logs.AddLogGroup(group);

            window.Hide();
            window.Close();
        }
Exemplo n.º 7
0
        public static void ZipGroup(LogGroup logGroup, string saveLocation, IProgressProvider progressProvider)
        {
            Trace.WriteLine("task started");
            progressProvider.ProgressBarValue = 0;
            using (var ms = new FileStream(saveLocation, FileMode.CreateNew))
            {
                // create the archive to go into the file
                using (var zip = new ZipArchive(ms, ZipArchiveMode.Create))
                {
                    var progressFactor = 100 / logGroup.Logs.Count;

                    // add each log to the archive
                    foreach (var log in logGroup.Logs)
                    {
                        if (!File.Exists(log.Filename))
                            continue;

                        progressProvider.ProgressText = $"Processing {log.Filename}...";

                        // create the entry
                        var entry = zip.CreateEntry(Path.GetFileName(log.Filename), CompressionLevel.Fastest);

                        // fill the entry
                        using (var entryStream = entry.Open())
                        {
                            using (
                                var logFileStream = File.Open(log.Filename, FileMode.Open, FileAccess.Read,
                                    FileShare.ReadWrite))
                            {
                                var fileBytes = new byte[logFileStream.Length];
                                logFileStream.Read(fileBytes, 0, fileBytes.Length);
                                using (var logStream = new MemoryStream(fileBytes))
                                {
                                    logStream.CopyTo(entryStream);
                                    progressProvider.ProgressBarValue += progressFactor;
                                }
                            }
                        }
                    }
                }
            }

            progressProvider.ProgressText = string.Empty;
            progressProvider.ProgressBarValue = 0;
        }
Exemplo n.º 8
0
        public void AddLog(LogGroup group, IEnumerable <LogInfo> logs)
        {
            var saveGroup = Logs.Groups.FirstOrDefault(g => g.Name.Equals(@group.Name, StringComparison.InvariantCultureIgnoreCase)) ?? @group;

            foreach (var log in logs)
            {
                if (!saveGroup.Logs.Any(l => l.Alias.Equals(log.Alias, StringComparison.Ordinal)))
                {
                    var highestOrder = saveGroup.Logs.Max(l => l.Order);
                    log.Order = highestOrder + 1;
                    saveGroup.Logs.Add(log);
                }

                OnLogAdded(log, saveGroup.Id);
            }

            SaveState();
        }
Exemplo n.º 9
0
 /// <summary>
 /// Adds the log group to the LogSource singleton.
 /// </summary>
 /// <param name="group">The group.</param>
 public void AddLogGroup(LogGroup group)
 {
     LogSource.Instance.AddGroup(group);
 }
Exemplo n.º 10
0
 public void AddGroup(LogGroup group)
 {
     Logs.Groups.Add(group);
     SaveState();
     OnLogGroupCollectionChanged();
     OnLogGroupAdded(group);
 }
Exemplo n.º 11
0
 private void OnLogGroupEdited(LogGroup logGroup)
 {
     Debug.WriteLine("LogGroupEdited fired (LogSource)");
     LogGroupEdited?.Invoke(this, new LogGroupEventArgs(logGroup));
 }
Exemplo n.º 12
0
 private void OnLogGroupAdded(LogGroup newGroup)
 {
     Debug.WriteLine("OnLogAdded fired (LogSource)");
     LogGroupAdded?.Invoke(this, new LogGroupEventArgs(newGroup));
 }
Exemplo n.º 13
0
 public void UpdateGroup(LogGroup group)
 {
     var existingGroup = Logs.Groups.First(g => g.Id.Equals(group.Id));
     existingGroup.Name = group.Name;
     SaveState();
     OnLogGroupCollectionChanged();
     OnLogGroupEdited(group);
 }
Exemplo n.º 14
0
 public void RemoveGroup(LogGroup group)
 {
     Logs.Groups.RemoveAll(g => g.Id.Equals(group.Id));
     SaveState();
     OnLogGroupCollectionChanged();
     OnLogGroupDeleted();
 }
Exemplo n.º 15
0
 private void OnLogGroupAdded(LogGroup newGroup)
 {
     Debug.WriteLine("OnLogAdded fired (LogSource)");
     LogGroupAdded?.Invoke(this, new LogGroupEventArgs(newGroup));
 }
Exemplo n.º 16
0
 public LogGroupEventArgs(LogGroup newGroup)
 {
     NewGroup = newGroup;
 }
Exemplo n.º 17
0
 private void OnLogGroupEdited(LogGroup logGroup)
 {
     Debug.WriteLine("LogGroupEdited fired (LogSource)");
     LogGroupEdited?.Invoke(this, new LogGroupEventArgs(logGroup));
 }
Exemplo n.º 18
0
 public LogGroupEventArgs(LogGroup newGroup)
 {
     NewGroup = newGroup;
 }
Exemplo n.º 19
0
        public void AddLog(LogGroup group, IEnumerable<LogInfo> logs)
        {
            var saveGroup = Logs.Groups.FirstOrDefault(g => g.Name.Equals(@group.Name, StringComparison.InvariantCultureIgnoreCase)) ?? @group;

            foreach (var log in logs)
            {
                if (!saveGroup.Logs.Any(l => l.Alias.Equals(log.Alias, StringComparison.Ordinal)))
                {
                    var highestOrder = saveGroup.Logs.Max(l => l.Order);
                    log.Order = highestOrder + 1;
                    saveGroup.Logs.Add(log);
                }

                OnLogAdded(log, saveGroup.Id);
            }

            SaveState();
        }
Exemplo n.º 20
0
 /// <summary>
 /// Adds the log group to the LogSource singleton.
 /// </summary>
 /// <param name="group">The group.</param>
 public void AddLogGroup(LogGroup group)
 {
     LogSource.Instance.AddGroup(group);
 }
Exemplo n.º 21
0
 public AddGroupViewModel()
 {
     Group = new LogGroup();
     CreateGroupCommand = new CreateGroupCommand(this);
     EditGroupCommand = new EditGroupCommand(this);
 }