Exemplo n.º 1
0
		private void SaveStreamCollectionItems(SQLiteConnection connection, StreamItemCollectionState collection)
		{
			using (var statement = connection.Prepare(@"INSERT OR REPLACE INTO STREAM_ITEM(ID, STREAM_ID, PUBLISHED, TITLE, WEB_URI, CONTENT, UNREAD, NEED_SET_READ_EXPLICITLY, IS_SELECTED, STARRED, SAVED) VALUES(@ID, @STREAM_ID, @PUBLISHED, @TITLE, @WEB_URI, @CONTENT, @UNREAD, @NEED_SET_READ_EXPLICITLY, @IS_SELECTED, @STARRED, @SAVED);"))
			{
				foreach (var item in collection.Items)
				{
					if (item is EmptySpaceStreamItem || item is HeaderSpaceStreamItem)
						continue;

					statement.Bind("@ID", item.Id);
					statement.Bind("@STREAM_ID", collection.StreamId);
					statement.Bind("@PUBLISHED", item.Published.ToString("O"));
					statement.Bind("@TITLE", item.Title);
					statement.Bind("@WEB_URI", item.WebUri);
					statement.Bind("@CONTENT", item.Content);
					statement.Bind("@UNREAD", item.Unread ? 1 : 0);
					statement.Bind("@NEED_SET_READ_EXPLICITLY", item.NeedSetReadExplicitly ? 1 : 0);
					statement.Bind("@IS_SELECTED", item.IsSelected ? 1 : 0);
					statement.Bind("@STARRED", item.Starred ? 1 : 0);
					statement.Bind("@SAVED", item.Saved ? 1 : 0);

					statement.Step();

					// Resets the statement, to that it can be used again (with different parameters).
					statement.Reset();
					statement.ClearBindings();
				}
			}
		}
Exemplo n.º 2
0
		private void SaveStreamCollectionInternal(StreamItemCollectionState collection)
		{
			try
			{
				using (var connection = new SQLiteConnection(DatabaseFilename))
				{
					EnableForeignKeys(connection);

					BeginTransaction(connection);

					SaveStreamCollection(connection, collection);
					SaveStreamCollectionItems(connection, collection);

					CommitTransaction(connection);
				}
			}
			catch (Exception e)
			{
				_telemetryClient.TrackException(e);
			}
		}
Exemplo n.º 3
0
		private void SaveStreamCollection(SQLiteConnection connection, StreamItemCollectionState collection)
		{
			using (var statement = connection.Prepare(@"INSERT OR REPLACE INTO STREAM_COLLECTION(STREAM_ID, CONTINUATION, SHOW_NEWEST_FIRST, STREAM_TIMESTAMP, FAULT) 
																			VALUES(@STREAM_ID, @CONTINUATION, @SHOW_NEWEST_FIRST, @STREAM_TIMESTAMP, @FAULT);"))
			{
				statement.Bind("@STREAM_ID", collection.StreamId);
				statement.Bind("@CONTINUATION", collection.Continuation);
				statement.Bind("@SHOW_NEWEST_FIRST", collection.ShowNewestFirst ? 1 : 0);
				statement.Bind("@STREAM_TIMESTAMP", collection.StreamTimestamp);
				statement.Bind("@FAULT", collection.Fault ? 1 : 0);

				statement.Step();
			}
		}
Exemplo n.º 4
0
		public Task SaveStreamCollectionAsync(StreamItemCollectionState collection)
		{
			if (collection == null) throw new ArgumentNullException("collection");

			return Task.Run(() => { SaveStreamCollectionInternal(collection); });
		}