Beispiel #1
0
        public async Task AddAsync(StreamItem item)
        {
            if (_items.Value.Any(t => t.Id == item.Id))
            {
                return;
            }

            var folderName = Guid.NewGuid().ToString("N");

            var parser    = new HtmlParser();
            var plainText = parser.GetPlainText(item.Content, 200);

            var cacheFolder = await _rootCacheFolder.CreateFolderAsync(CacheFolderName, CreationCollisionOption.OpenIfExists).AsTask().ConfigureAwait(false);

            var folder = await cacheFolder.CreateFolderAsync(folderName).AsTask().ConfigureAwait(false);

            var newHtml = await SaveImagesAsync(folder, item.Content).ConfigureAwait(false);

            var savedItem = new SavedStreamItem
            {
                Id           = item.Id,
                Title        = item.Title,
                Published    = item.Published,
                WebUri       = item.WebUri,
                ShortContent = plainText,
                Content      = newHtml,
                ImageFolder  = folderName
            };

            _items.Value.Add(savedItem);
            _storageManager.Save(savedItem);
        }
Beispiel #2
0
        public List <SavedStreamItem> LoadSavedStreamItems()
        {
            var result = new List <SavedStreamItem>();

            using (var connection = new SQLiteConnection(DatabaseFilename))
            {
                using (var statement = connection.Prepare(@"SELECT ID, TITLE, PUBLISHED, WEBURI, SHORT_CONTENT, CONTENT, IMAGE_FOLDER FROM SAVED_STREAM_ITEM;"))
                {
                    while (statement.Step() == SQLiteResult.ROW)
                    {
                        var item = new SavedStreamItem
                        {
                            Id           = (string)statement[0],
                            Title        = (string)statement[1],
                            Published    = DateTimeOffset.Parse((string)statement[2]),
                            WebUri       = (string)statement[3],
                            ShortContent = (string)statement[4],
                            Content      = (string)statement[5],
                            ImageFolder  = (string)statement[6],
                        };

                        result.Add(item);
                    }
                }
            }

            return(result);
        }
Beispiel #3
0
        public void Save([NotNull] SavedStreamItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            using (var connection = new SQLiteConnection(DatabaseFilename))
            {
                using (var statement = connection.Prepare(@"INSERT OR REPLACE INTO SAVED_STREAM_ITEM(ID, TITLE, PUBLISHED, WEBURI, SHORT_CONTENT, CONTENT, IMAGE_FOLDER) 
																			VALUES(@ID, @TITLE, @PUBLISHED, @WEBURI, @SHORT_CONTENT, @CONTENT, @IMAGE_FOLDER);"                                                                            ))
                {
                    statement.Bind("@ID", item.Id);
                    statement.Bind("@TITLE", item.Title);
                    statement.Bind("@PUBLISHED", item.Published.ToString("O"));
                    statement.Bind("@WEBURI", item.WebUri);
                    statement.Bind("@SHORT_CONTENT", item.ShortContent);
                    statement.Bind("@CONTENT", item.Content);
                    statement.Bind("@IMAGE_FOLDER", item.ImageFolder);

                    statement.Step();

                    //// Resets the statement, to that it can be used again (with different parameters).
                    //statement.Reset();
                    //statement.ClearBindings();
                }
            }
        }
		public async Task AddAsync(StreamItem item)
		{
			if (_items.Value.Any(t => t.Id == item.Id))
				return;

			var folderName = Guid.NewGuid().ToString("N");

			var parser = new HtmlParser();
			var plainText = parser.GetPlainText(item.Content, 200);

			var cacheFolder = await _rootCacheFolder.CreateFolderAsync(CacheFolderName, CreationCollisionOption.OpenIfExists).AsTask().ConfigureAwait(false);
			var folder = await cacheFolder.CreateFolderAsync(folderName).AsTask().ConfigureAwait(false);

			var newHtml = await SaveImagesAsync(folder, item.Content).ConfigureAwait(false);

			var savedItem = new SavedStreamItem
			{
				Id = item.Id,
				Title = item.Title,
				Published = item.Published,
				WebUri = item.WebUri,
				ShortContent = plainText,
				Content = newHtml,
				ImageFolder = folderName
			};

			_items.Value.Add(savedItem);
			_storageManager.Save(savedItem);
		}
 public override void OnNavigatedTo(object navigationParameter, NavigationMode navigationMode, Dictionary<string, object> viewModelState)
 {
     var id = (string) navigationParameter;
     Item = _savedStreamManager.Items.First(t => t.Id == id);
 }
		public List<SavedStreamItem> LoadSavedStreamItems()
		{
			var result = new List<SavedStreamItem>();

			using (var connection = new SQLiteConnection(DatabaseFilename))
			{
				using (var statement = connection.Prepare(@"SELECT ID, TITLE, PUBLISHED, WEBURI, SHORT_CONTENT, CONTENT, IMAGE_FOLDER FROM SAVED_STREAM_ITEM;"))
				{
					while (statement.Step() == SQLiteResult.ROW)
					{
						var item = new SavedStreamItem
						{
							Id = (string)statement[0],
							Title = (string)statement[1],
							Published = DateTimeOffset.Parse((string)statement[2]),
							WebUri = (string)statement[3],
							ShortContent = (string)statement[4],
							Content = (string)statement[5],
							ImageFolder = (string)statement[6],
						};

						result.Add(item);
					}
				}
			}

			return result;
		}