public bool SyncData(string savefile, string examplefile, IEnumerable <ColumnSelector> parameters)
        {
            List <string> result         = new List <string>();
            List <string> savedstrings   = _csvReaderWriter.ReadFile(savefile);
            List <string> examplestrings = _csvReaderWriter.ReadFile(examplefile);

            foreach (var saved in savedstrings)
            {
                string synchstring = saved;
                string twin        = examplestrings.FirstOrDefault(s => s.Substring(0, s.IndexOf(';')).ToLower().Trim() == saved.ToLower().Trim());
                if (twin != null)
                {
                    string[] twinparams = twin.Split(';');
                    foreach (var par in parameters)
                    {
                        if (par.Index < twinparams.Length)
                        {
                            synchstring += ";" + twinparams[par.Index];
                        }
                    }
                }
                result.Add(synchstring);
            }
            return(_csvReaderWriter.Write(savefile, new TextFromListGetter(result)));
        }
Example #2
0
        public async void Parse(WhoisParameters parametr)
        {
            _result  = new ConcurrentQueue <string>();
            _domains = new ConcurrentQueue <string>(_csvReaderWriter.ReadFile(parametr.FilePath));
            List <Task> tasks = new List <Task>();

            _pauseToken  = true;
            _cancelToken = true;
            _saver       = true;
            SetParams(parametr);
            StartParsing?.Invoke(_domains.Count, _streamsCount, _timeout);
            _result.Enqueue("Url" + _parser.BuildHeader());
            for (int i = 0; i < _streamsCount; i++)
            {
                tasks.Add(startTask());
            }
            await Task.WhenAll(tasks);

            if (_saver)
            {
                if (_csvReaderWriter.Write(_savefilepath, new TextFromListGetter(_result.ToList())))
                {
                    MessageBox.Show("Done");
                }
            }
            ParsingEnd?.Invoke();
            foreach (var item in tasks)
            {
                item.Dispose();
            }
        }
Example #3
0
        public List <string> Read(string filepath)
        {
            try
            {
                WebClient webClient = new WebClient();
                webClient.DownloadFileAsync(new Uri(filepath), _filename);
            }
            catch (WebException) { MessageBox.Show("Ошибка загрузки файла!"); }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); };
            List <string> result = _csvReaderWriter.ReadFile(_filename);

            File.Delete(_filename);
            return(result);
        }
 public static void ServersInit()
 {
     try
     {
         var txt = _csvReaderWriter.ReadFile(filepath);
         foreach (var item in txt)
         {
             var strings = item.Split(';');
             try
             {
                 AddProxy(Convert.ToInt32(strings[1]), strings[0], strings[2], strings[3], Convert.ToInt32(strings[4]));
             }
             catch (Exception)
             {
                 continue;
             }
         }
     }
     catch (Exception ex) { MessageBox.Show(ex.ToString()); }
 }
Example #5
0
 public List <string> Read(string filepath)
 {
     return(_csvReaderWriter.ReadFile(filepath));
 }