예제 #1
0
        public List <GoogleAnalyticsKeywordsCostDataRow> GetData()
        {
            List <GoogleAnalyticsKeywordsCostDataRow> GoogleAnalyticsDataRowList = new List <GoogleAnalyticsKeywordsCostDataRow>();

            //  Thread.CurrentThread.CurrentCulture = new CultureInfo("uk-UA");

            foreach (DataEntry entry in this.feed.Entries)
            {
                GoogleAnalyticsKeywordsCostDataRow new_GoogleAnalyticsDataRow = new GoogleAnalyticsKeywordsCostDataRow();
                new_GoogleAnalyticsDataRow.adGroup = entry.Dimensions[0].Value;
                new_GoogleAnalyticsDataRow.keyword = entry.Dimensions[1].Value;
                // string str_test = entry.Metrics[0].Value.Substring(0,6).Trim();
                new_GoogleAnalyticsDataRow.cost = double.Parse(entry.Metrics[0].Value, CultureInfo.InvariantCulture);
                GoogleAnalyticsDataRowList.Add(new_GoogleAnalyticsDataRow);
            }

            return(GoogleAnalyticsDataRowList);
        }
예제 #2
0
        public void Execute_SetVisitsCost(DateTime StartDate, DateTime FinishDate, string ids, int ClientId_, GoogleAnalyticsKeywordsCostDataRow row)
        {
            try
               {
               using (MySqlConnection objConn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CallTrackingDBContext"].ConnectionString))
               {
                   //Source source = _sourceRep.FindBy(t => t.Name == row.adGroup && t.ClientId == ClientId_).FirstOrDefault();
                   //SourceKeyword sourcekeyword = _sourcekeywordsRep.FindBy(t => t.ClientId == ClientId_ && t.Keyword == row.keyword && t.SourceId==source.Id).FirstOrDefault();

                   /* objConn.Open();
                    MySqlCommand objSetVisitsCost = new MySqlCommand();
                    objSetVisitsCost.Connection = objConn;
                    objSetVisitsCost.CommandType = CommandType.StoredProcedure;
                    objSetVisitsCost.CommandText = "SetVisitsCost";
                    objSetVisitsCost.Parameters.Add("@startdate", MySqlDbType.DateTime).Value = StartDate;
                    objSetVisitsCost.Parameters.Add("@finishdate", MySqlDbType.VarChar).Value = FinishDate;
                    objSetVisitsCost.Parameters.Add("@ClientId_", MySqlDbType.Int32).Value = ClientId_;
                    objSetVisitsCost.Parameters.Add("@sourcekeyword", MySqlDbType.VarChar).Value = row.keyword.Trim();
                    objSetVisitsCost.Parameters.Add("@sourcename", MySqlDbType.VarChar).Value = row.adGroup.Trim();
                    objSetVisitsCost.Parameters.Add("@VisitsCost_", MySqlDbType.Double).Value = row.cost;

                    objSetVisitsCost.ExecuteNonQuery();
                    objConn.Close();*/

                   //IQueryable<Visit> visits = _visitsRep.FindBy(t => t.sourcekeyword.Keyword == row.keyword && t.Source.Name == row.adGroup && t.clientId == ClientId_ && t.datetime >=StartDate && t.datetime<FinishDate);
                   //if (visits.Count() > 0)
                   //{
                   //    foreach (Visit item in visits)
                   //    {
                   //        item.VisitsCost = row.cost;
                   //        _visitsRep.Edit(item);
                   //    }
                   //    _visitsRep.Save();
                   //}

                   objConn.Open();
                   MySqlCommand objSetVisitsCost = new MySqlCommand();
                   objSetVisitsCost.Connection = objConn;

                   objSetVisitsCost.CommandText = @"update Visits v left join sources s on s.Id=v.SourceId
            left join sourcekeywords sk on sk.Id=v.sourcekeywordId
            set VisitsCost = @VisitsCost_
            where  v.clientId=@clientId_
            and sk.keyword = @keyword_
            and s.name=@name_
            and v.SourceId is not null
            and v.sourcekeywordId is not null
            and Date(datetime)=Date(@start_)";

                   objSetVisitsCost.Parameters.Add("@VisitsCost_", MySqlDbType.Double).Value = row.cost;
                   objSetVisitsCost.Parameters.Add("@clientId_", MySqlDbType.Int32).Value = ClientId_;
                   objSetVisitsCost.Parameters.Add("@keyword_", MySqlDbType.VarChar).Value = row.keyword.Trim();
                   objSetVisitsCost.Parameters.Add("@name_", MySqlDbType.VarChar).Value = row.adGroup.Trim();
                   objSetVisitsCost.Parameters.Add("@start_", MySqlDbType.DateTime).Value = StartDate;

                   objSetVisitsCost.ExecuteNonQuery();
                   objConn.Close();
               }
            }
               catch (Exception ex)
               {
               while (ex.InnerException != null)
                   ex = ex.InnerException;
               Console.WriteLine("Message: " + ex.Message + "   TargetSite: " + ex.TargetSite + "   StackTrace: " + ex.StackTrace);
               }
        }
예제 #3
0
        public List<GoogleAnalyticsKeywordsCostDataRow> GetData()
        {
            List<GoogleAnalyticsKeywordsCostDataRow> GoogleAnalyticsDataRowList = new List<GoogleAnalyticsKeywordsCostDataRow>();

              //  Thread.CurrentThread.CurrentCulture = new CultureInfo("uk-UA");

            foreach (DataEntry entry in this.feed.Entries)
            {
                GoogleAnalyticsKeywordsCostDataRow new_GoogleAnalyticsDataRow = new GoogleAnalyticsKeywordsCostDataRow();
                new_GoogleAnalyticsDataRow.adGroup = entry.Dimensions[0].Value;
                new_GoogleAnalyticsDataRow.keyword = entry.Dimensions[1].Value;
               // string str_test = entry.Metrics[0].Value.Substring(0,6).Trim();
                new_GoogleAnalyticsDataRow.cost = double.Parse(entry.Metrics[0].Value, CultureInfo.InvariantCulture);
                GoogleAnalyticsDataRowList.Add(new_GoogleAnalyticsDataRow);
            }

            return GoogleAnalyticsDataRowList;
        }