Ejemplo n.º 1
0
        public override void ProcessMessage(BasicDeliverEventArgs message)
        {
            Thread.Sleep(4000);
            MssUpdateAlexaCompany mss = Newtonsoft.Json.JsonConvert.DeserializeObject <MssUpdateAlexaCompany>(UTF8Encoding.UTF8.GetString(message.Body));

            try
            {
                var alexa = Common.GetRankAlexa(mss.Domain);
                if (alexa != null)
                {
                    string strQuery = @"
                                    update Web 
                                    set  AlexaRank = @AlexaRank, LastUpdateAlexa = getdate()
                                    where id =@Id";
                    bool   bOK      = this._sqlDbProduct.RunQuery(strQuery, CommandType.Text,
                                                                  new SqlParameter[] { SqlDb.CreateParamteterSQL("@Id", mss.CompanyId, SqlDbType.BigInt), SqlDb.CreateParamteterSQL("@AlexaRank", alexa.AlexaRankContries, SqlDbType.Int), });
                    Logger.Info(string.Format("AlexaSeo updated: {0} {1} {2} => {3}\r\n", mss.Domain, alexa.AlexaRank, alexa.AlexaRankContries, bOK));
                }
                else
                {
                    _log.InfoFormat("Fail alexa for {0}", mss.Domain);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex + string.Format("Company: {0} {1}", mss.CompanyId, mss.Domain));
            }

            this.GetChannel().BasicAck(message.DeliveryTag, true);
        }
Ejemplo n.º 2
0
        public override void ProcessMessage(BasicDeliverEventArgs message)
        {
            Thread.Sleep(4000);

            MssUpdateAlexaCompany mss = Newtonsoft.Json.JsonConvert.DeserializeObject <MssUpdateAlexaCompany>(UTF8Encoding.UTF8.GetString(message.Body));
            var    alexa    = Common.GetRankAlexaFull(mss.Domain);
            string strQuery =
                @"
DELETE FROM Company_Alexa WHERE Id = @Id;
INSERT INTO [dbo].[Company_Alexa]
           ([Id]
           ,[Domain]
           ,[BounceRate]
           ,[BounceRateChange]
           ,[BounceRateChangeTitle]
           ,[DailyPageView]
           ,[DailyPageViewChange]
           ,[DailyPageViewTitle]
           ,[DailyTimeOnSite]
           ,[DailyTimeOnSiteChange]
           ,[DailyTimeOnSiteTitle]
           ,[Contries]
           ,[AlexaRank]
           ,[AlexaRankContries])
     VALUES
           ( @Id
           , @Domain
           , @BounceRate
           , @BounceRateChange
           , @BounceRateChangeTitle
           , @DailyPageView
           , @DailyPageViewChange
           , @DailyPageViewTitle
           , @DailyTimeOnSite
           , @DailyTimeOnSiteChange
           , @DailyTimeOnSiteTitle
           , @Contries
           , @AlexaRank
           , @AlexaRankContries)
";
            bool bOK = this._sqlDbProduct.RunQuery(strQuery, CommandType.Text,
                                                   new SqlParameter[]
            {
                SqlDb.CreateParamteterSQL("@Id", mss.CompanyId, SqlDbType.BigInt),
                SqlDb.CreateParamteterSQL("@Domain", mss.Domain, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@BounceRate", alexa.BounceRate, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@BounceRateChange", alexa.BounceRateChange, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@BounceRateChangeTitle", alexa.BounceRateChangeTitle, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@DailyPageView", alexa.DailyPageView, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@DailyPageViewChange", alexa.DailyPageViewChange, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@DailyPageViewTitle", alexa.DailyPageViewTitle, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@DailyTimeOnSite", alexa.DailyTimeOnSite, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@DailyTimeOnSiteChange", alexa.DailyTimeOnSiteChange, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@DailyTimeOnSiteTitle", alexa.DailyTimeOnSiteTitle, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@Contries", alexa.Contries, SqlDbType.VarChar),
                SqlDb.CreateParamteterSQL("@AlexaRank", alexa.AlexaRank, SqlDbType.Int),
                SqlDb.CreateParamteterSQL("@AlexaRankContries", alexa.AlexaRankContries, SqlDbType.Int)
            });

            _log.Info(string.Format("AlexaFull {0} {1} {2} => {3} \r\n", mss.Domain, alexa.AlexaRank, alexa.AlexaRankContries, bOK));
            this.GetChannel().BasicAck(message.DeliveryTag, true);
        }