예제 #1
0
 public int InsertWords(Word word, string userid)
 {
     int ret = 0;
     SQLiteCommand command = new SQLiteCommand();
     using (SQLiteConnection connection = new SQLiteConnection(_dbConnection))
     {
         connection.Open();
         command.Connection = connection;
         if (String.IsNullOrEmpty(word.Trans))
         {
             command.CommandText = "INSERT INTO wordbook('userid','item','time') VALUES (" + userid + ",'" + word.Item + "', " + (DateTime.Now - baseTime).Seconds + ")";
         }
         else
         {
             command.CommandText = "INSERT INTO wordbook('userid','item', 'trans','time') VALUES (" + userid + ",'" + word.Item + "','" + word.Trans + "', " + (DateTime.Now - baseTime).Seconds + ")";
         }
         ret =command.ExecuteNonQuery();
     }
     return ret;
 }
예제 #2
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.I32) {
           Count = iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.List) {
           {
             Words = new List<Word>();
             TList _list0 = iprot.ReadListBegin();
             for( int _i1 = 0; _i1 < _list0.Count; ++_i1)
             {
               Word _elem2 = new Word();
               _elem2 = new Word();
               _elem2.Read(iprot);
               Words.Add(_elem2);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
예제 #3
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 send_insertWord(Word word)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("insertWord", TMessageType.Call, seqid_));
   insertWord_args args = new insertWord_args();
   args.Word = word;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
 public int insertWord(Word word)
 {
     String user_id = Context.Session[Context.Session.SessionID].ToString();
     return database.InsertWords(word, user_id);
 }
 public IAsyncResult send_insertWord(AsyncCallback callback, object state, Word word)
      public int insertWord(Word word)
      {
        #if !SILVERLIGHT
        send_insertWord(word);
        return recv_insertWord();

        #else
        var asyncResult = Begin_insertWord(null, null, word);
        return End_insertWord(asyncResult);

        #endif
      }
 public IAsyncResult Begin_insertWord(AsyncCallback callback, object state, Word word)
 {
   return send_insertWord(callback, state, word);
 }
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.Struct) {
           Word = new Word();
           Word.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.List) {
           {
             Words = new List<Word>();
             TList _list4 = iprot.ReadListBegin();
             for( int _i5 = 0; _i5 < _list4.Count; ++_i5)
             {
               Word _elem6 = new Word();
               _elem6 = new Word();
               _elem6.Read(iprot);
               Words.Add(_elem6);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.String) {
           Userid = iprot.ReadString();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }