Example #1
0
 private bool CheckOtherRunning(long companyId)
 {
     if (_redisWaitCrawler.CheckRunningCrawler(companyId))
     {
         _redisWaitCrawler.SetNexReload(companyId, 1);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #2
0
 private bool CheckOtherRunning()
 {
     if (_redisWaitCrawler.CheckRunningCrawler(this._companyId))
     {
         LogData(string.Format("Thead {0}. Other running {1} crawler with session {2}. Wait next session", _indexThread, _companyId, _session));
         this._redisWaitCrawler.SetNexReload(_companyId, 1);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #3
0
 private bool CheckOtherRunning()
 {
     if (this._typeRun == TypeReload.AutoNextCompany)
     {
         if (_redisWaitCrawler.CheckRunningCrawler(this._companyId))
         {
             _log.InfoFormat("Thead {0}. Other running for company {1} crawler with session {2}. Wait next session", _indexThread, _companyId, _session);
             this._redisWaitCrawler.SetNexReload(_companyId, 1);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
Example #4
0
        public static void PushCmp()
        {
            var server     = RabbitMQManager.GetRabbitMQServer(ConfigCrawler.KeyRabbitMqCrawler);
            var sqldb      = new SqlDb(ConfigCrawler.ConnectProduct);
            var tupleSetup = new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("00", "Vip.Cmp.Crl.Fn"),
                new Tuple <string, string>("10", "Vip.Cmp.Crl.Rl"),
                new Tuple <string, string>("01", "Normal.Cmp.Crl.Fn"),
                new Tuple <string, string>("11", "Normal.Cmp.Crl.Rl"),
            };

            foreach (var tuple in tupleSetup)
            {
                Log.Info(string.Format("Push to {0} {1}", tuple.Item1, tuple.Item2));
                var            producer = new ProducerBasic(server, tuple.Item2);
                var            chanl    = server.CreateChannel();
                QueueDeclareOk dcl      = chanl.QueueDeclare(tuple.Item2, true, false, false, null);
                if (dcl.MessageCount < 1)
                {
                    var tblCmpFn = sqldb.GetTblData("[prc_Company_GetCmpToPushCrl]", CommandType.StoredProcedure, new[]
                    {
                        SqlDb.CreateParamteterSQL("@TypeCrl", tuple.Item1, SqlDbType.VarChar)
                    });
                    foreach (DataRow variable in tblCmpFn.Rows)
                    {
                        long companyId = Common.Obj2Int64(variable["ID"]);
                        if (!RedisCompanyWaitCrawler.CheckRunningCrawler(companyId))
                        {
                            producer.PublishString(new JobCompanyCrawler()
                            {
                                CheckRunning = true,
                                CompanyId    = companyId
                            }.GetJSon());
                            Log.Info(string.Format("Pushed for cmp: {0}", companyId));
                        }
                        else
                        {
                            Log.Info("Not push because running");
                        }
                    }
                }
            }
            return;
        }