示例#1
0
        private void loadDistricts()
        {
            _districts.Clear();
            string content = _districtCollectionDataResolver.RequestProcess();

            _districts = _districtCollectionParser.ParseDistricts(content);
        }
示例#2
0
        public MainVM()
        {
            _detector.AddListener(this);
            RemoveObserverCommand = new RelayCommand(removeObserver, x => true);
            OpenSettingsCommand   = new RelayCommand(x => openSettings(), y => true);
            string content = _districtCollectionDataResolver.RequestProcess();

            Districts           = _districtCollectionParser.ParseDistricts(content);
            IsDistrictsExpanded = true;
            refreshObserves();
            Load();
            PropertyChanged += onPropertyChanged;

            if (_detector.GetMailReceivers().Count == 0)
            {
                openSettings();
            }
        }
示例#3
0
        public void Process()
        {
            var folder = "Cache";

            if (Directory.Exists("Cache"))
            {
                Directory.Delete("Cache", true);
            }

            if (!Directory.Exists("Cache"))
            {
                Directory.CreateDirectory("Cache");
            }

            _specTasks.Clear();
            _clinicTasks.Clear();
            _districtsTasks.Clear();
            _specs.Clear();
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            string content = _districtCollectionDataResolver.RequestProcess();

            File.WriteAllText($"{folder}/Districts.html", content);
            var districts       = _districtCollectionParser.ParseDistricts(content);
            var districtsFolder = $"{folder}/Districts";

            if (!Directory.Exists(districtsFolder))
            {
                Directory.CreateDirectory(districtsFolder);
            }
            int i = 0;

            foreach (IDistrict district in districts)
            {
                i++;
                System.Console.WriteLine($"_________District {district.Name} {i}/{districts.Count} _________");
                //_districtsTasks.Add( parseDistrict(districtsFolder, district.Id) );
                parseDistrict(districtsFolder, district.Id).GetAwaiter().GetResult();

                if (i == 2)
                {
                    break;
                }
            }

            foreach (var s in _specs)
            {
                _specTasks.Add(parseSpeciality(s.SpecialitiesFolder, s.ClinicId, s.SpecialityId));
            }

            //Parallel.ForEach(_specs, (s) =>
            //{
            //    parseSpeciality(s.SpecialitiesFolder, s.ClinicId, s.SpecialityId);
            //});

            //Task.WhenAll(_districtsTasks).GetAwaiter().GetResult();
            //Task.WhenAll(_clinicTasks).GetAwaiter().GetResult();
            Task.WhenAll(_specTasks).GetAwaiter().GetResult();

            stopwatch.Stop();
            Console.WriteLine("Потрачено тактов на выполнение: " + stopwatch.ElapsedTicks);
        }