Esempio n. 1
0
 public static DataSet Run()
 {
     using (var mysql = new MySqlData())
     {
         return mysql.ExecuteDataSet("GetRetweetRank", commandType: CommandType.StoredProcedure);
     }
 }
Esempio n. 2
0
        public static void Insert(TwitterStream data)
        {
            using (var mysql = new MySqlData())
            {
                string sql = "INSERT INTO `toketee`.`twitterstream` " +
                             "(`Id`, `CreateDate`,`UpdateDate`,`SoftDeleted`," +
                             "`Data`,`Serializable`,`DataType`,`StatusId`,`Sent`,`SenderId`," +
                             "`RecipientId`,`InReplyToStatusId`) VALUES " +
                             "(@Id, @CreateDate, @UpdateDate, @SoftDeleted, @Data, @Serializable," +
                             "@DataType, @StatusId, @Sent, @SenderId, @RecipientId, @InReplyToStatusId)";

                MySqlCommand cmd = new MySqlCommand(sql, mysql.Context);

                cmd.Parameters.AddWithValue("@Id", data.Id);
                cmd.Parameters.AddWithValue("@CreateDate", DateTime.Now);
                cmd.Parameters.AddWithValue("@UpdateDate", DateTime.Now);
                cmd.Parameters.AddWithValue("@SoftDeleted", 0);
                cmd.Parameters.AddWithValue("@Data", data.Data);
                cmd.Parameters.AddWithValue("@Serializable", data.Serializable);
                cmd.Parameters.AddWithValue("@DataType", data.DataType);
                cmd.Parameters.AddWithValue("@StatusId", data.StatusId);
                cmd.Parameters.AddWithValue("@Sent", data.Sent);
                cmd.Parameters.AddWithValue("@SenderId", data.SenderId);
                cmd.Parameters.AddWithValue("@RecipientId", data.RecipientId);
                cmd.Parameters.AddWithValue("@InReplyToStatusId", data.InReplyToStatusId);

                cmd.ExecuteNonQuery();

            }
        }
Esempio n. 3
0
 public static string GetMaxId()
 {
     using (var mysql = new MySqlData())
     {
         string sql = "SELECT max(Id) FROM twitterstatus ";
         return mysql.ExecuteScalar(sql).ToString();
     }
 }
Esempio n. 4
0
        public static string GetMaxId()
        {
            using (var mysql = new MySqlData())
            {
                string sql = "SELECT max(Id) FROM toketee.twitterstream ";

                var cmd = new MySqlCommand(sql, mysql.Context);
                return cmd.ExecuteScalar().ToString();
            }
        }
Esempio n. 5
0
 public static DataSet Run(DateTime startTime, DateTime endTime)
 {
     using (var mysql = new MySqlData())
     {
         return mysql.ExecuteDataSet("GetRetweetRankTimeFilter", commandType: CommandType.StoredProcedure,
         list: new []
               	{
               		new MySqlParameter("@StartTime", startTime),
                     new MySqlParameter("@EndTime", endTime)
               	});
     }
 }
Esempio n. 6
0
 public static void Run(string id)
 {
     using (var mysql = new MySqlData())
     {
         mysql.Execute("IncrementRetweetCount",
             commandType: CommandType.StoredProcedure,
             list: new[]
                 {
                     new MySqlParameter("@id", id),
                     new MySqlParameter("@date", DateTime.Now.ToUniversalTime())
                 });
     }
 }
Esempio n. 7
0
        public static void Insert(string id, DateTime sent, string data)
        {
            using (var mysql = new MySqlData())
            {

                string sql = "INSERT INTO TwitterStatus (Id, Sent, Data) VALUES " +
                             "(@Id, @Sent, @Data)";

                mysql.Execute(sql, list: new[] {
                          new MySqlParameter("@Id", long.Parse(id)),
                          new MySqlParameter("@Sent", sent),
                          new MySqlParameter("@Data", data)});
            }
        }
Esempio n. 8
0
        public static void Insert(long retweetId, long originalTweetId, int secondsSinceOriginal, DateTime retweetTime)
        {
            using (var mysql = new MySqlData())
            {
                string sql = "INSERT INTO retweettrack (retweetid, originaltweetid, secondssinceoriginal, retweettime)" +
                             " VALUES (@retweetid, @originaltweetid, @secondssinceoriginal, @retweettime)";

                mysql.Execute(sql, list: new [] {
                    new MySqlParameter("@retweetid", retweetId),
                    new MySqlParameter("@originaltweetid", originalTweetId),
                    new MySqlParameter("@secondssinceoriginal", secondsSinceOriginal),
                    new MySqlParameter("@retweettime", retweetTime)
                    });

            }
        }
Esempio n. 9
0
        public static DataSet Select(string since, bool fromApi = true, string where = null)
        {
            using (var mysql = new MySqlData())
            {
                string whereClause = "";
                if (where != null)
                {
                    whereClause = " AND Data LIKE @Like ";
                }
                // LIKE CONCAT('\'%' + in_arg + '%\''))
                string sql = "SELECT Id, Data FROM twitterstatus " +
                    " WHERE Id > @Id " + whereClause +
                    "ORDER BY Id";

                if (fromApi) sql += " LIMIT 500";

                return mysql.ExecuteDataSet(sql, new[] { new MySqlParameter("@Id", long.Parse(since)),
                (where != null) ? new MySqlParameter("@Like", "%" + where + "%") : null});
            }
        }
Esempio n. 10
0
        public static DataSet Select(string since, bool fromApi = true)
        {
            using (var mysql = new MySqlData())
            {
                string sql = "SELECT Id, Data FROM toketee.twitterstream " +
                    " WHERE Id > @Id AND DataType = 'status'" +
                    "ORDER BY Id";

                if (fromApi) sql += " LIMIT 500";

                var cmd = new MySqlCommand(sql, mysql.Context);
                cmd.Parameters.AddWithValue("@Id", since);

                MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);

                //var reader = cmd.ExecuteReader().

                return ds;
            }
        }