Ejemplo n.º 1
0
        public YADataDBURLQueue(string dbConnectionString, int mode = 0)
        {
            Console.WriteLine("Создаем очередь");
            tick += Tick;
            work = false;
            jobs_made = 0;
            got_jobs = new Queue<DataDBURLJob>(0);
            photo_aps = new Queue<DirtyApartments>(0);
            disposed = false; 
            //обновляем ссылку на подключение к базе для всяких асинхронных передач данных в духе ошибок
            ddbs = new DataDBAsynchService(dbConnectionString);
            ddbs.WriteErrorMessage(dbConnectionString, 0, "", "start");
            //получаем задания на парсинг
            jobs = new DataDBURLJobs(ddbs, mode, false);
            //jobs.SetJobToStartOrStop(true);
            t_fill = new System.Timers.Timer();
            t_fill.Elapsed += new System.Timers.ElapsedEventHandler(fill_timer);
            t_fill.Interval = 30000;
            t_restart = new System.Timers.Timer();
            t_restart.Elapsed += new System.Timers.ElapsedEventHandler(restart_timer);
            //рестартить раз в 12 часов
            t_restart.Interval = 12 * 60 * 60 * 1000;
            this.mode = mode;

            pq = new PhotoQueue(ddbs);
            arw = new AsyncRunWork();
            ap = new apartments();
            work = true;
            t_fill.Start();
            t_restart.Start();
            Console.WriteLine("Создали очередь");
        }
Ejemplo n.º 2
0
        public EventQueue(string dbConnectionString, int mode = 0)
        {
            needjobs += GetJobs;
            getpages += GetPages;
            processonepage += ProcessOnePage;
            getphotosfromonepage += GetPhotosFromOnePage;
            statusesadd += StatusesAdd;
            sendapartmentsandstatuses += SendApartmentsAndStatuses;
            fillqueue += FillQueue;

            jobs_made = 0;
            //обновляем ссылку на подключение к базе для всяких асинхронных передач данных в духе ошибок
            ddbs = new DataDBAsynchService(dbConnectionString);
            ddbs.WriteErrorMessage(dbConnectionString, 0, "", "start");
            this.mode = mode;
            arw = new AsyncRunWork();
            starttime = DateTime.Now;

            if (jobs != null)
                lock (jobs)
                    jobs = new DataDBURLJobs(ddbs, mode, false);
            else
                jobs = new DataDBURLJobs(ddbs, mode, false);
            lock (jobs)
                if (jobs.Count() < 100)
                    needjobs();
    }
Ejemplo n.º 3
0
 private void Initialize()
 {
     string _dbConnectionString = "Data Source=vparsers.r-slon.com;Initial Catalog=AlcionaParsers;Persist Security Info=True;User ID=parsers08;Password=GjrjKtybt2011;Connection Timeout=120;Network Library=DBMSSOCN;Max Pool Size=1000";
     ddbs = new DataDBAsynchService(_dbConnectionString);
     jobs = new DataDBURLJobs(ddbs, 14, true);
     das = new List<Alciona.AlcionaDAL.DirtyApartments>();
     made = new List<DataDBURLJob>();
 }
Ejemplo n.º 4
0
        public DataDBURLQueue(string dbConnectionString, int maxthreads, int mode=0)
        {
            //обновляем ссылку на подключение к базе для всяких асинхронных передач данных в духе ошибок
            ddbs = new DataDBAsynchService(dbConnectionString);
            //получаем задания на парсинг
            jobs = new DataDBURLJobs(ddbs, mode,false);
            this.max_threads = maxthreads;
            //jobs.SetJobToStartOrStop(true);
            t_fill = new System.Timers.Timer();
            t_fill.Elapsed += new System.Timers.ElapsedEventHandler(fill_timer);
            t_fill.Interval = 30000;
            t_restart = new System.Timers.Timer();
            t_restart.Elapsed += new System.Timers.ElapsedEventHandler(restart_timer);
            //рестартить раз в 12 часов
            t_restart.Interval = 12*1000*60*60;
            this.mode = mode;
            bws = new BackgroundWorker[max_threads];
            states = new WOrkingThreadState[max_threads];

            pq = new DataDBCollector.PhotoQueue(ddbs);
            //ThreadPool.SetMaxThreads(40, 40);
        }
Ejemplo n.º 5
0
        public NewDataDBURLQueue(string dbConnectionString, int maxthreads, int mode=0)
        {
            //обновляем ссылку на подключение к базе для всяких асинхронных передач данных в духе ошибок
            ddbs = new DataDBAsynchService(dbConnectionString);
            //получаем задания на парсинг
            jobs = new DataDBURLJobs(ddbs, mode,false);
            this.max_threads = maxthreads;
            this.mode = mode;
            bws = new AbortableBackgroundWorker[max_threads];
            states = new WOrkingThreadState[max_threads];

            pq = new DataDBCollector.PhotoQueue(ddbs);
            //ThreadPool.SetMaxThreads(40, 40);
        }