Exemple #1
0
        void Potok4(string line)
        {
            Print_scan_listBox("Идет распаковка архивов.");
            Preparation_scan pr = new Preparation_scan();

            pr.preparation(line);
            Print_scan_listBox("Распаковка архивов закончена.");

            ScanEngine Seng = new ScanEngine();
            var        Observer_Virus_detection_DaD = new Observer_Virus_detection();

            Seng.Attach(Observer_Virus_detection_DaD);
            string full_path_file = Path.GetDirectoryName(line) + @"\" + Path.GetFileNameWithoutExtension(line);

            this.Invoke(new System.Threading.ThreadStart(delegate
            {
                scanir.Enabled = false;
                timer_nach     = DateTime.Now;
                btimer         = true;
            }));
            if (!backgroundWorker2.IsBusy)
            {
                backgroundWorker2.RunWorkerAsync();
            }

            List <string> InfFile = Seng.scan_List(full_path_file);

            Print_scan_listBox(full_path_file, InfFile);
            Seng.Detach(Observer_Virus_detection_DaD);
            this.Invoke(new System.Threading.ThreadStart(delegate
            {
                btimer = false;
            }));
        }
Exemple #2
0
        public async void Update(ISubject subject)
        {
            string line;

            if ((subject as FileWatcher).BoolPath_Create)
            {
                line = String.Format("FileWatcher: Обнаружен новый файл, передаю его сканеру:{0}", (subject as FileWatcher).FullPath_Create.ToString());
                Program.fm1.Filewatcher_listbox(line);

                ScanEngine wf    = new ScanEngine();
                bool       virus = false;
                virus = wf.scan_String((subject as FileWatcher).Put, (subject as FileWatcher).FullPath_Create.ToString());

                if (virus)
                {
                    line = String.Format("FileWatcher: Новый файл является вирусом! {0}", (subject as FileWatcher).FullPath_Create.ToString());
                    Program.fm1.Filewatcher_listbox(line);
                }
                else
                {
                    line = String.Format("FileWatcher: Обнаруженный файл не является вирусом {0}", (subject as FileWatcher).FullPath_Create.ToString());
                    Program.fm1.Filewatcher_listbox(line);
                }
            }

            if ((subject as FileWatcher).BoolPath_Deleted)
            {
                line = String.Format("FileWatcher: Удален файл! {0}", (subject as FileWatcher).FullPath_Deleted.ToString());
                Program.fm1.Filewatcher_listbox(line);
            }
        }
Exemple #3
0
        //----------------------------------------Листбокс FileWatcher-----------------------------------------


        //Drag and Drop

        void Potok3(string obj, List <string> paths, ScanEngine Seng, Preparation_scan pr)
        {
            var observerDragandDrop = new Observer_Virus_detection();

            Seng.Attach(observerDragandDrop);


            Print_scan_listBox("Идет распаковка архивов.");
            pr.preparation(obj);
            Print_scan_listBox("Распаковка архивов закончена.");


            paths = Seng.scan_List(obj);
            Print_scan_listBox("Кол-во вирусом: " + paths.Count.ToString());
            Seng.Detach(observerDragandDrop);
        }
Exemple #4
0
        //void Potok1(object sender, EventArgs e)
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            String line = key_create.GetValue("path").ToString();

            var subject   = new ScanEngine();
            var observerA = new Observer_Virus_detection();

            subject.Attach(observerA);

            this.Invoke(new System.Threading.ThreadStart(delegate
            {
                scanir.Enabled = false;
                //progressBar1.Style = ProgressBarStyle.Marquee;
                timer_nach = DateTime.Now;
                btimer     = true;
            }));

            if (!backgroundWorker2.IsBusy)
            {
                backgroundWorker2.RunWorkerAsync();
            }

            Print_scan_listBox("Идет распаковка архивов.");
            Preparation_scan pr = new Preparation_scan();

            pr.preparation(line);
            Print_scan_listBox("Распаковка архивов закончена.");


            List <string> InfFile = subject.scan_List(line);

            this.Invoke(new System.Threading.ThreadStart(delegate
            {
                //progressBar1.Style = ProgressBarStyle.Blocks;
                btimer = false;
            }));

            subject.Detach(observerA);

            Print_scan_listBox(line, InfFile);
            this.Invoke(new System.Threading.ThreadStart(delegate
            {
                scanir.Enabled = true;
            }));
        }
Exemple #5
0
        void DragAndDrop_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            List <string>    paths = new List <string>();
            ScanEngine       Seng  = new ScanEngine();
            Preparation_scan pr    = new Preparation_scan();

            foreach (string obj in (string[])e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop))
            {
                if (Directory.Exists(obj))
                {
                    bw         = new BackgroundWorker();
                    bw.DoWork += (obj2, ea) => Potok3(obj, paths, Seng, pr);
                    bw.RunWorkerAsync();
                }
                else
                {
                    string file_no_raz = (Path.GetDirectoryName(obj) + @"\" + Path.GetFileNameWithoutExtension(obj) + ".zip");
                    if (file_no_raz == obj)
                    {
                        bw2         = new BackgroundWorker();
                        bw2.DoWork += (obj2, ea) => Potok4(obj);
                        bw2.RunWorkerAsync();
                        continue;
                    }

                    if (Seng.scan_String(Path.GetDirectoryName(obj), obj))
                    {
                        //string line = String.Format("Файл является вирусом! {0}", obj);
                        scan_listBox.Items.Add("Файл является вирусом!");
                        scan_listBox.Items.Add(obj);
                    }
                    else
                    {
                        string line = String.Format("Файл не является вирусом {0}", obj);
                        scan_listBox.Items.Add(line);
                    }
                }
            }
        }