Example #1
0
 private WeatherProviderYandex(IWeatherReader reader)
 {
     lock (_locker)
     {
         _extractor = new YandexWeatherExtractor(reader);
     }
 }
Example #2
0
        public static IWeatherProvider get(IWeatherReader reader = null)
        {
            if (_self == null)
            {
                _self = new WeatherProviderYandex(reader);
            }

            _refcounter++;
            return(_self);
        }
Example #3
0
        public YandexWeatherExtractor(IWeatherReader reader)
        {
#if STATISTICS
            read_statistics();
#endif
            if (reader != null)
            {
                _sitereader = reader;
            }
            else
            {
                _sitereader = new YandexFileReaderWriter(WeatherSource.YC);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                _folder = args[0];
            }

            if (args.Length > 1)
            {
                _type = (WeatherSource)int.Parse(args[1]);
            }

            bool nocheck = false;

            if (args.Length > 2)
            {
                nocheck = true;
            }

            bool nokill = false;

            if (args.Length > 3)
            {
                nokill = true;
            }

            if (!nocheck)
            {
                // check if mother app is running
                Process[] pl      = Process.GetProcesses();
                bool      running = false;
                foreach (var p in pl)
                {
                    if (p.ProcessName.Equals("PictureSlideshowScreensaver", StringComparison.OrdinalIgnoreCase))
                    {
                        running = true;
                        break;
                    }
                }

                if (!running)
                {
                    return;
                }
            }

            // nokill = true;
            if (!nokill)
            {
                string browsername = "chrome";
                string drivername  = "chromedriver";
                if (_type == WeatherSource.NI || _type == WeatherSource.YI)
                {
                    browsername = "iexplore";
                    drivername  = "IEDriverServer";
                }
                else if (_type == WeatherSource.NE || _type == WeatherSource.YE)
                {
                    browsername = "edge";
                    drivername  = "msedgeDriver";
                }

                Process[] pl = Process.GetProcesses();

                foreach (var p in pl)
                {
                    string mwt = p.MainWindowTitle;
                    string pn  = p.ProcessName;
                    if (p.ProcessName.Equals(browsername, StringComparison.OrdinalIgnoreCase))
                    {
                        //p.CloseMainWindow();
                        try
                        {
                            p.Kill();
                        }
                        catch (Exception)
                        {
                        }
                    }
                }

                foreach (var p in pl)
                {
                    string mwt = p.MainWindowTitle;
                    string pn  = p.ProcessName;
                    if (p.ProcessName.Equals(drivername, StringComparison.OrdinalIgnoreCase))
                    {
                        p.Kill();
                    }
                }
            }


            IWeatherWriter writer = null;
            IWeatherReader reader = null;

            if (_type == WeatherSource.NI || _type == WeatherSource.NC || _type == WeatherSource.NE)
            {
                reader = new NGSSeleniumReader(_type);
                writer = new NGSFileReaderWriter(_type);
            }
            else if (_type == WeatherSource.YI || _type == WeatherSource.YC || _type == WeatherSource.YE)
            {
                reader = new YandexSeleniumReader(_type);
                writer = new YandexFileReaderWriter(_type);
            }

            string temp = "", current = "", forecast = "", except = "";

            try
            {
                temp = reader.temperature();
            }
            catch (Exception e)
            {
                except += "\n\n\n ======================= \n" + e.Message;
            }

            try
            {
                current = reader.current();
            }
            catch (Exception e)
            {
                except += "\n\n\n ======================= \n" + e.Message;
            }

            try
            {
                forecast = reader.forecast();
            }
            catch (Exception e)
            {
                except += "\n\n\n ======================= \n" + e.Message;
            }

            writer.writeinfo(temp, current, forecast, except);
            reader.close();
        }
 public IrelandTemperatuesController(IConfiguration configuration, IWeatherReader weatherReader, IScraper htmlScraper)
 {
     _configuration = configuration;
     _weatherReader = weatherReader;
     _htmlScraper   = htmlScraper;
 }
Example #6
0
 private WeatherProviderNGS()
 {
     _sitereader = new NGSFileReaderWriter(WeatherSource.NC);
 }
Example #7
0
 public ExtremesController(IConfiguration configuration, IWeatherReader weatherReader, IScraper htmlScraper)
 {
     _configuration = configuration;
     _weatherReader = weatherReader;
     _htmlScraper   = htmlScraper;
 }