Пример #1
0
        public Wordbook GetWords(string user_id)
        {
            //int userid = GetUserId(user_id);
            Wordbook wordbook = new Wordbook();
            wordbook.Words = new List<Word>();
            SQLiteCommand command = GetCommand("SELECT id,item,trans,time FROM wordbook where userid=" + user_id);
            using (SQLiteConnection connection = new SQLiteConnection(_dbConnection))
            {
                connection.Open();
                command.Connection = connection;
                using (var reader = command.ExecuteReader())
                {
                    int count = 0;
                    while (reader.Read())
                    {
                        Word word = new Word();
                        word.Item = reader.GetString(1);
                        word.Trans = reader.GetString(2);
                        Int64 timeI = reader.GetInt64(3);
                        DateTime time = baseTime.AddSeconds(timeI);
                        word.Time = new TDateTime();
                        word.Time.Year = (short)time.Year;
                        word.Time.Month = (short)time.Month;
                        word.Time.Day = (short)time.Day;
                        word.Time.Hour = (short)time.Hour;
                        word.Time.Minute = (short)time.Minute;
                        word.Time.Second = (short)time.Second;
                        count++;
                        wordbook.Words.Add(word);
                    }
                    wordbook.Count = count;
                }
            }

            return wordbook;
        }
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 0:
         if (field.Type == TType.Struct) {
           Success = new Wordbook();
           Success.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }