예제 #1
0
        public void UpdateDateInfo()
        {
            DateTime current = DateTime.UtcNow.AddHours(6);

            if (current.Hour >= 12)
            {
                _date = new DateTime(current.Year, current.Month, current.Day, 15, 0, 0);
            }
            else
            {
                _date = new DateTime(current.Year, current.Month, current.Day, 3, 0, 0);
            }

            string _sqlSelect   = "SELECT ID FROM Dates WHERE Date = @Date";
            string _sqlInsert   = "INSERT INTO Dates (Date) VALUES (@Date)";
            string _sqlSelectID = "SELECT MAX(ID) FROM Dates";

            using (var DataBaseConnection = KanColleSenkaManager.NewSQLiteConnection())
                using (var cmd = new SQLiteCommand(_sqlSelect, DataBaseConnection)) {
                    DataBaseConnection.Open();
                    SQLiteParameter date = new SQLiteParameter("@Date", DbType.DateTime);
                    cmd.Parameters.Add(date);
                    cmd.Parameters["@Date"].Value = _date;
                    object id = cmd.ExecuteScalar();
                    if (id != null)
                    {
                        _dateID = Convert.ToInt64(id);
                    }
                    else
                    {
                        cmd.CommandText = _sqlInsert;
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = _sqlSelectID;
                        cmd.Parameters.Clear();
                        _dateID = Convert.ToInt64(cmd.ExecuteScalar());
                    }
                }
        }
예제 #2
0
 public KanColleSenkaService()
 {
     Inprocess = false;
     sm        = new KanColleSenkaManager();
     timer1    = new Timer(TimerTick, null, 3000, 10000);
 }