Пример #1
0
        async private void start()
        {
            ServiceClient client = ServiceClientCreate.createClient();

            client.startScanner(this.scanPath);
            client.Close();
            Result.Visibility = Visibility.Hidden;

            Label       label       = (Label)StatusBar.Items.GetItemAt(0);
            ProgressBar progressBar = (ProgressBar)this.StatusBar.Items.GetItemAt(2);

            var progress = new Progress <string[]>(r => {
                label.Content     = r[0];
                progressBar.Value = Int32.Parse(r[1]);
            });

            await Task.Run(() =>
            {
                ServiceClient local = ServiceClientCreate.createClient();
                while (local.getScanStatus())
                {
                    this.logger(progress);
                    Thread.Sleep(1000);
                }
                local.Close();
            });

            this.stop();
        }
Пример #2
0
        private void printResults()
        {
            ServiceClient client  = ServiceClientCreate.createClient();
            string        results = client.getScanResult();

            client.Close();

            string[] lines       = results.Split('\n');
            string   description = $"{lines[0]}\n{lines[1]}\n{lines[2]}";

            Result.Label.Content = description;

            if (lines.Length <= 3)
            {
                return;
            }

            Result.StackPanel.Children.Clear();
            for (int i = 3; i < lines.Length; i += 1)
            {
                string line = lines.ElementAt(i);
                if (line.Length == 0)
                {
                    break;
                }
                Result.StackPanel.Children.Add(new FileProcessing(line));
            }

            Label       label       = (Label)StatusBar.Items.GetItemAt(0);
            ProgressBar progressBar = (ProgressBar)this.StatusBar.Items.GetItemAt(2);

            label.Content     = "";
            progressBar.Value = 100;
        }
Пример #3
0
        async private void alwaysGetPlansList()
        {
            var progress = new Progress <PlanDS[]>(plans => {
                StackPanel.Children.Clear();
                foreach (PlanDS plan in plans)
                {
                    StackPanel.Children.Add(new Plan(plan));
                }
            });

            await Task.Run(() =>
            {
                while (true)
                {
                    if (this.Visibility == Visibility.Visible)
                    {
                        ServiceClient client = ServiceClientCreate.createClient();
                        PlanDS[] plans       = client.getAllPlans();
                        this.setPlans(progress, plans);
                        client.Close();
                    }
                    Thread.Sleep(800);
                }
            });
        }
Пример #4
0
        async private void alwaysGetQuarantineList()
        {
            var progress = new Progress <string[]>(viruses => {
                StackPanel.Children.Clear();
                foreach (string virus in viruses)
                {
                    StackPanel.Children.Add(new QuarantineItem(virus));
                }
            });

            await Task.Run(() =>
            {
                while (true)
                {
                    if (this.Visibility == Visibility.Visible)
                    {
                        ServiceClient client = ServiceClientCreate.createClient();
                        string[] viruses     = client.getQuarantineList();
                        this.setViruses(progress, viruses);
                        client.Close();
                    }
                    Thread.Sleep(800);
                }
            });
        }
Пример #5
0
        protected override void OnExit(ExitEventArgs e)
        {
            ServiceClient client = ServiceClientCreate.createClient();

            client.stopScanner();
            client.stopMonitoring();
            base.OnExit(e);
        }
Пример #6
0
        private void logger(IProgress <string[]> progress)
        {
            ServiceClient client = ServiceClientCreate.createClient();
            string        log    = client.logMonitoring();

            client.Close();
            progress.Report(log.Split('\n'));
        }
Пример #7
0
        async private void ButtonPower_Click(object sender, RoutedEventArgs e)
        {
            this.monitoringStarted = !this.monitoringStarted;
            ButtonPower.Content    = this.monitoringStarted ? "Остановить" : "Запуск";
            ServiceClient client = ServiceClientCreate.createClient();

            if (this.monitoringStarted)
            {
                // запустить мониторинг
                client.startMonitoring(this.path);
                Results.ButtonRepair.IsEnabled = false;
                Results.Visibility             = Visibility.Visible;
            }
            else
            {
                // остановить мониторинг
                client.stopMonitoring();
                Results.ButtonRepair.IsEnabled = true;
            }
            client.Close();

            var progress = new Progress <string[]>(log => {
                string information    = log[0];
                Results.Label.Content = information;
                if (log.Length < 3)
                {
                    return;
                }
                Results.StackPanel.Children.Clear();
                for (int i = 1; i < log.Length; i += 1)
                {
                    string virus = log[i];
                    if (virus.Length == 0)
                    {
                        break;
                    }

                    Results.StackPanel.Children.Add(
                        new FileProcessing(virus)
                        );
                }
            });

            await Task.Run(() =>
            {
                ServiceClient local = ServiceClientCreate.createClient();
                while (local.getMonitoringStatus())
                {
                    this.logger(progress);
                    Thread.Sleep(1000);
                }
                local.Close();
            });
        }
Пример #8
0
        private void stop()
        {
            ServiceClient client = ServiceClientCreate.createClient();

            client.stopScanner();
            client.Close();

            ButtonPower.Content           = "Начать сканирование";
            Result.Visibility             = Visibility.Visible;
            Result.ButtonRepair.IsEnabled = true;

            this.printResults();
        }
Пример #9
0
        private void updateList()
        {
            ServiceClient client = ServiceClientCreate.createClient();

            string[] viruses = client.getVirusesFiles();
            client.Close();

            Window.Visibility = Visibility.Visible;
            Window.StackPanel.Children.Clear();
            foreach (string virus in viruses)
            {
                Window.StackPanel.Children.Add(new FileProcessing(virus));
            }
        }
Пример #10
0
        private void ButtonDelete_Click(object sender, RoutedEventArgs e)
        {
            ServiceClient client = ServiceClientCreate.createClient();
            FileDS        file   = new FileDS(TextBlock.Text);

            file.fileHandler = FilesHandler.RemoveFromQuarantine;
            List <FileDS> files = new List <FileDS>();

            files.Add(file);
            client.handlerFiles(files.ToArray());
            client.Close();
            StackPanel parent = (StackPanel)VisualTreeHelper.GetParent(this);

            parent.Children.Remove(this);
        }
Пример #11
0
        private void ButtonAddDate_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            bool pickerIsEmpty = this.DatePicker.Value.ToString().Length == 0;
            bool pathIsEmpty   = this.scanPath.Length == 0;

            if (pickerIsEmpty || pathIsEmpty)
            {
                MessageBox.Show("Заполните все поля");
                return;
            }

            ServiceClient client = ServiceClientCreate.createClient();
            DateTime      picker = (DateTime)this.DatePicker.Value;

            string[] date = picker.ToString().Split(' ')[0].Split('.');
            string[] time = picker.ToString().Split(' ')[1].Split(':');

            string day   = date[0];
            string month = date[1];
            string year  = date[2];
            string hour  = time[0];
            string min   = time[1];

            string   currentStringFormat = $"{year}-{month}-{day}|{hour}:{min}";
            DateTime currentTime         = PlanDS.getTimeFromStringFormat(currentStringFormat);
            DateTime now = DateTime.Now;

            now.AddSeconds(-now.Second);
            now.AddMilliseconds(-now.Millisecond);

            if (now > currentTime)
            {
                MessageBox.Show($"Неверная дата. Введите дату, не ранее {DateTime.Now.ToString()}");
                return;
            }

            PlanDS plan       = new PlanDS(this.scanPath, currentTime);
            bool   successAdd = client.addPlan(plan);

            if (!successAdd)
            {
                MessageBox.Show("Аналогичный план уже имеется в списке");
            }
            client.Close();
        }
Пример #12
0
        private void logger(IProgress <string[]> progressSender)
        {
            ServiceClient client  = ServiceClientCreate.createClient();
            string        results = client.getScanResult();

            client.Close();

            string[] lines = results.Split('\n');

            string description = $"{lines[0]}\n{lines[1]}\n{lines[2]}";

            double totalFiles   = Double.Parse(lines[0].Split(':')[1]);
            double checkedFiles = Double.Parse(lines[1].Split(':')[1]);

            double full     = 100;
            int    progress = (int)Math.Round(full * (checkedFiles / totalFiles));

            string[] result = { description, progress.ToString() };

            progressSender.Report(result);
        }
        private void ButtonRepair_Click(object sender, RoutedEventArgs e)
        {
            ServiceClient client = ServiceClientCreate.createClient();
            List <FileDS> files  = new List <FileDS>();

            foreach (FileProcessing fw in StackPanel.Children)
            {
                string path = (string)fw.label.Content;
                FileDS file = new FileDS(path);
                file.fileHandler = fw.selectedCommand;
                files.Add(file);
            }
            client.handlerFiles(files.ToArray());

            client.Close();
            this.StackPanel.Children.Clear();
            if (this.hiddenAfterRepaitClick)
            {
                this.Visibility = Visibility.Hidden;
            }
        }