コード例 #1
0
        public void OnFileCopy(object sender, MainFormEventArgs e)
        {
            copySource      = FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item);
            copiedEntryName = "CopyOf" + MyFile.GetFileNameWithoutExtension(FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item).Name) +
                              MyFile.GetExtension(FileFactory.CreateEntry(e.CurrentDir + @"\" + e.Item).Name);

            /*Copied = e.CurrentDir + e.Item;
             * CopyName = "CopyOf" + e.Item;
             * OpenedDirectory(e.CurrentDir);*/
        }
コード例 #2
0
 public MyZip(string name)
 {
     if (MyFile.GetExtension(name) != ".zip")
     {
         throw new ArgumentException();
     }
     else
     {
         fullName = name;
     }
 }
コード例 #3
0
        public override void try_findinfo()
        {
            MyFile f2 = new MyFile(FileForRegex);



            Stopwatch watch = new Stopwatch();

            watch.Start();
            // сначала необходимо собрать всю информацию по файлам в папке


            Visitor v = new Visitor();

            this.Accept(v);

            /*
             * Самое время запустить все потоки и собрать информацию
             */

            // создаем массив из 4-х процессов. (Ровно столько же, сколько у нашего компьютера ядер)

            MultiRegex[] mr = new MultiRegex[Environment.ProcessorCount];
            for (int i = 0; i < mr.Length; i++)
            {
                mr[i] = new MultiRegex(file_reg_archive, i);
            }

            // запускаем потоки
            for (int i = 0; i < mr.Length; i++)
            {
                mr[i].Start();
            }



            for (int i = 0; i < mr.Length; i++)
            {
                mr[i].End();
            }

            for (int i = 0; i < mr.Length; i++)         // из каждого потока берем его List data
            {
                for (int j = 0; j < data.Length; j++)   // @, INN, VK
                {
                    foreach (string s in mr[i].data[j]) // string из List<string>
                    {
                        data[j].Add(s);
                    }
                }
            }
            FileWrite(FileForRegex);
        }
コード例 #4
0
 public static IEntry CreateEntry(string path)
 {
     if (path == String.Empty)
     {
         throw new MyException("Пустая строка", new ArgumentException());
     }
     if (path.EndsWith(".zip"))
     {
         return(new MyZip(path));
     }
     if (MyFile.GetExtension(path) == String.Empty)
     {
         return(new MyDirectory(path));
     }
     return(new MyFile(path));
 }
コード例 #5
0
        public void OnStartClick(object sender, MainFormEventArgs e)
        {
            List <string> allWords = new List <string>(MyFile.ReadAllText(e.CurrentDir + @"\" + e.Item).ToLower().Split(new[] { " ", "\r" }, StringSplitOptions.None));

            int words   = allWords.AsParallel().Where(word => !string.IsNullOrWhiteSpace(word) && !string.IsNullOrEmpty(word)).Count();
            int strings = allWords.AsParallel().Where(word => word.Contains('\r') || word.Contains('\n')).Count();

            allWords = allWords.AsParallel().Select(word => word.Replace("\n", "").Replace("\r", ""))
                       .Where(word => !string.IsNullOrEmpty(word) && !string.IsNullOrWhiteSpace(word)).ToList();



            int n = 0;

            List <int> counts = new List <int>();
            //if (progressBar.BInvoke())
            List <string> ordered = allWords.AsParallel().AsOrdered().OrderByDescending(
                word =>
            {
                int count = allWords.AsParallel().AsOrdered().Where(w => w == word).Count();
                counts.Add(count);
                n++;


                //progressBar.PerformStep();
                return(count);
            }).Distinct().ToList();


            counts = counts.AsParallel().AsOrdered().OrderByDescending(q => q).Distinct().ToList();

            int i = 0;

            while (i < ordered.Count)
            {
                StatisticsForm.TopTenList.Add("    " + "\n" + ordered[i] + "  ");
                i++;
            }



            StatisticsForm.totalWords   = "Total words" + words.ToString();
            StatisticsForm.totalStrings = "Total strings" + strings.ToString();

            StatisticsForm.ImproveChanges();
        }
コード例 #6
0
        public override void try_findinfo()
        {
            MyFile f4 = new MyFile(FileForRegex);



            Stopwatch watch = new Stopwatch();

            watch.Start();
            // сначала необходимо собрать всю информацию по файлам в папке


            Visitor v = new Visitor();

            this.Accept(v);
            IDelegates();


            //int Stoped = 0;
            Task[] r = new Task[file_reg_archive.Count];

            int n = 0;

            for (int i = 0; i < four_file_reg_archive.Length - 1; i++)
            {
                r[n] = Task.Factory.StartNew(() =>
                {
                    FindInfoInFile(four_file_reg_archive[i]);
                });
            }
            r[n].GetAwaiter().OnCompleted(() =>
            {
                // Stoped++;
            }); n++;

            FileWrite(FileForRegex);
            watch.Stop();
        }