/// <summary> /// 加载桌台状态 /// </summary> /// <param name="type"></param> private void LoaderTableItem(ICollection <Table> tables) { if (tables != null && tables.Count > 0) { foreach (var table in tables) { ICollection <TableItem> items = table.TableItem; if (items != null && items.Count > 0) { foreach (var item in items) { DeskDishes dd = _DeskDishesService.GetDeskDischesByTableId(item.Id); if (item.Status == 0) { TableItems.Add(new TableItemModel(item.Id + "", table.Name, (double)item.Money, TableStatus.Idle, 6, (int)item.SeatedNum, false)); } if (item.Status == 1) { TableItems.Add(new TableItemModel(item.Id + "", table.Name, (double)item.Money, TableStatus.Using, 8, (int)item.SeatedNum, true)); } if (item.Status == 2) { TableItems.Add(new TableItemModel(item.Id + "", table.Name, TableStatus.Waiting)); } } } } } }
//Check if item content contains preview image private async Task CheckItemContentContainsPreviewImage(TableItems LoadTable) { try { int ItemImagecount = 0; bool FoundPreviewImage = false; //Check the preview image string ItemImageLink = LoadTable.item_image; if (string.IsNullOrWhiteSpace(ItemImageLink)) { item_image.item_source.Source = null; item_image.Visibility = Visibility.Collapsed; return; } //Check if there are images and the preview image is included CheckTextBlockForPreviewImage(rtb_ItemContent, ItemImageLink, ref ItemImagecount, ref FoundPreviewImage); //Update the preview image based on result if (ItemImagecount == 0 || !FoundPreviewImage) { System.Diagnostics.Debug.WriteLine("No media found in rich text block, adding item image."); //Check if media is a gif(v) file bool ImageIsGif = ItemImageLink.ToLower().Contains(".gif"); //Check if low bandwidth mode is enabled if (ImageIsGif && (bool)AppVariables.ApplicationSettings["LowBandwidthMode"]) { //System.Diagnostics.Debug.WriteLine("Low bandwidth mode skipping gif."); item_image.item_status.Text = "Gif not loaded,\nlow bandwidth mode."; item_image.Visibility = Visibility.Visible; return; } if (ImageIsGif) { item_image.item_video_status.Source = await AVImage.LoadBitmapImage("ms-appx:///Assets/iconVideoPause.png", false); item_image.item_video.Visibility = Visibility.Visible; } item_image.MaxHeight = AppVariables.MaximumItemImageHeight; item_image.item_source.Source = await AVImage.LoadBitmapImage(ItemImageLink, true); item_image.Visibility = Visibility.Visible; } else { item_image.item_source.Source = null; item_image.Visibility = Visibility.Collapsed; } } catch { item_image.item_source.Source = null; item_image.Visibility = Visibility.Collapsed; } }
//Validate table items public static bool ValidateTableItems(List <string> IgnoredFeedList, TableItems ValidateItem) { try { if (AppVariables.LoadStarred) { return(ValidateItem.item_star_status); } else { DateTime RemoveItemsRange = DateTime.UtcNow.AddDays(-Convert.ToDouble(AppSettingLoad("RemoveItemsRange"))); if ((bool)AppSettingLoad("DisplayReadMarkedItems")) { if (ValidateItem.item_datetime > RemoveItemsRange && !IgnoredFeedList.Any(y => y == ValidateItem.item_feed_id)) { return(true); } } else { if (ValidateItem.item_read_status == false && ValidateItem.item_datetime > RemoveItemsRange && !IgnoredFeedList.Any(y => y == ValidateItem.item_feed_id)) { return(true); } } } } catch { } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="MainPage"/> class. /// Adding loading message and intiates list loading of all movies /// </summary> public MainPage() { InitializeComponent(); TableItems.Add(new Movie() { Title = "Loading.." }); //Sends an empty string so that it will load all movies GetListsAsync(""); }
//Check if there are images and the preview image is included private void CheckItemContentContainsPreviewImage(TableItems loadTable) { try { //Check the preview image string itemImageLink = loadTable.item_image; if (string.IsNullOrWhiteSpace(itemImageLink)) { item_image.image_link = null; item_image.IsVisible = false; return; } //Check if there are images or the preview image is included IEnumerable <View> imageContainers = item_content.Children.Where(x => x.GetType() == typeof(ImageContainer)); int itemImageCount = imageContainers.Count(); bool foundPreviewImage = false; foreach (ImageContainer imageContainer in imageContainers) { try { string CompareBitmapLink = Regex.Replace(imageContainer.image_link, @"^(?:http(?:s)?://)?(?:www(?:[0-9]+)?\.)?", string.Empty, RegexOptions.IgnoreCase).ToLower(); string CompareItemImageLink = Regex.Replace(itemImageLink, @"^(?:http(?:s)?://)?(?:www(?:[0-9]+)?\.)?", string.Empty, RegexOptions.IgnoreCase).ToLower(); //Debug.WriteLine("Comparing image: " + CompareBitmapLink + " vs " + CompareItemImageLink); if (CompareBitmapLink == CompareItemImageLink) { foundPreviewImage = true; break; } } catch { } } //Update the preview image based on result if (itemImageCount == 0 || !foundPreviewImage) { Debug.WriteLine("No media found in rich text block, showing item image: " + itemImageLink); item_image.image_link = itemImageLink; item_image.IsVisible = true; } else { item_image.image_link = null; item_image.IsVisible = false; } } catch { item_image.image_link = null; item_image.IsVisible = false; } }
/// <summary> /// 选择餐桌类型或者区域时调用 /// </summary> public void TypeItemSelectionChanged() { //MessageBox.Show("确定要对进行开台吗?" + TypeSelectedItem.Name + TypeSelectedItem.Id, "提示", MessageBoxButton.YesNo); if (TypeSelectedItem.Id == -1) { InitTableLocationItemData(1); } else { List <Table> tables = _TableStatusService.GetTableAndRefByTypeId(TypeSelectedItem.Id); TableItems.Clear(); LoaderTableItem(tables); } }
/// <summary> /// Creates HTML Table to display Lookup data /// </summary> /// <param name="totalRows">Total Number of Rows in HTML Table</param> /// <param name="totalColumns">Total Number of Columns in HTML Table</param> private void CreateTable(int totalRows, int totalColumns) { TableItems.Rows.Clear(); TableItems.Dispose(); for (int row = 0; row < totalRows + 4; row++) { TableRow tr = new TableRow(); for (int column = 0; column <= totalColumns + 2; column++) { TableCell td = new TableCell(); td.Wrap = false; tr.Cells.Add(td); } TableItems.Rows.Add(tr); } }
/// <summary> /// 加载餐桌类型 /// </summary> /// <param name="types"></param> /// /// <param name="status">status=0表示初始化加载,status=1表示点击类型加载对应桌台</param> private void LoaderTableType(List <TableType> types, int status) { TableItems.Clear(); if (types != null && types.Count > 0) { foreach (var type in types) { if (status == 0) { BaseTableModel ttms = new BaseTableModel(type.TableTypeId, type.Code, type.Name); TypeItems.Add(ttms); } ICollection <Table> tables = type.Table; LoaderTableItem(tables); } } }
/// <summary> /// 加载区域 /// </summary> /// <param name="locations"></param> private void LoaderLocation(List <Location> locations, int status) { TableItems.Clear(); if (locations != null && locations.Count > 0) { foreach (var location in locations) { if (status == 0) { BaseTableModel ttms = new BaseTableModel(location.LocationId, location.Code, location.Name); TypeItems.Add(ttms); } ICollection <Table> tables = location.Table; LoaderTableItem(tables); } } }
/// <summary> /// 状态选择时过滤对应的桌台 /// </summary> internal void TableStatusSelectionChanged() { List <TableItem> items = null; switch (TableStatusSelectedItem.Color) { case TableStatus.Idle: items = _TableItemService.GetDetailByStatus(0); break; case TableStatus.Using: items = _TableItemService.GetDetailByStatus(1); break; case TableStatus.Waiting: items = _TableItemService.GetDetailByStatus(2); break; case TableStatus.Scheduled: items = _TableItemService.GetDetailByStatus(3); break; case TableStatus.Excess: items = _TableItemService.GetDetailByStatus(4); break; } TableItems.Clear(); if (items != null && items.Count > 0) { foreach (var item in items) { if (item.Status == 0) { TableItems.Add(new TableItemModel(item.Id + "", item.Table.Name, (double)item.Money, TableStatus.Idle, 6, (int)item.SeatedNum, false)); } if (item.Status == 1) { TableItems.Add(new TableItemModel(item.Id + "", item.Table.Name, (double)item.Money, TableStatus.Using, 8, (int)item.SeatedNum, true)); } if (item.Status == 2) { TableItems.Add(new TableItemModel(item.Id + "", item.Table.Name, TableStatus.Waiting)); } } } }
//Check if item content contains preview image private void CheckItemContentContainsPreviewImage(TableItems LoadTable) { try { int ItemImagecount = 0; bool FoundPreviewImage = false; //Check the preview image string ItemImageLink = LoadTable.item_image; if (string.IsNullOrWhiteSpace(ItemImageLink)) { popup_ItemImage.item_image_Value = null; popup_ItemImage.Visibility = Visibility.Collapsed; return; } //Check if there are images and the preview image is included CheckTextBlockForPreviewImage(popup_ItemContent, ItemImageLink, ref ItemImagecount, ref FoundPreviewImage); //Update the preview image based on result if (ItemImagecount == 0 || !FoundPreviewImage) { System.Diagnostics.Debug.WriteLine("No media found in rich text block, adding item image."); popup_ItemImage.MaxHeight = AppVariables.DefaultMediaHeight; popup_ItemImage.item_image_Value = ItemImageLink; popup_ItemImage.Visibility = Visibility.Visible; } else { popup_ItemImage.item_image_Value = null; popup_ItemImage.Visibility = Visibility.Collapsed; } } catch { popup_ItemImage.item_image_Value = null; popup_ItemImage.Visibility = Visibility.Collapsed; } }
private static async Task <bool> MarkReadSingle(ObservableCollection <Items> UpdateList, Items ListItem, string ActionType, bool Silent) { try { bool MarkStatus = false; string ItemId = ListItem.item_id; //Check if internet is available if (Connectivity.NetworkAccess != NetworkAccess.Internet || ApiMessageError.StartsWith("(Off)")) { if (!Silent) { EventProgressDisableUI("Off marking item as " + ActionType.ToLower() + "...", true); } Debug.WriteLine("Off marking item as " + ActionType.ToLower() + "..."); await AddOfflineSync(ItemId, ActionType); MarkStatus = true; } else { if (!Silent) { EventProgressDisableUI("Marking item as " + ActionType.ToLower() + "...", true); } Debug.WriteLine("Marking item as " + ActionType.ToLower() + "..."); string[][] RequestHeader = new string[][] { new[] { "Authorization", "GoogleLogin auth=" + AppSettingLoad("ConnectApiAuth").ToString() } }; StringContent PostContent; if (ActionType == "Read") { PostContent = new StringContent("i=" + ItemId + "&a=user/-/state/com.google/read", Encoding.UTF8, "application/x-www-form-urlencoded"); } else { PostContent = new StringContent("i=" + ItemId + "&r=user/-/state/com.google/read", Encoding.UTF8, "application/x-www-form-urlencoded"); } Uri PostUri = new Uri(ApiConnectionUrl + "edit-tag"); string PostHttp = await AVDownloader.SendPostRequestAsync(7500, "News Scroll", RequestHeader, PostUri, PostContent); if (PostHttp != null && (PostHttp == "OK" || PostHttp.Contains("<error>Not found</error>"))) { MarkStatus = true; } } if (MarkStatus) { //Get the current page name string currentPage = App.Current.MainPage.ToString(); //Mark item in database and list TableItems TableEditItems = await vSQLConnection.Table <TableItems>().Where(x => x.item_id == ItemId).FirstOrDefaultAsync(); if (TableEditItems != null) { if (ActionType == "Read") { TableEditItems.item_read_status = true; ListItem.item_read_status = true; ListItem.item_read_icon = ImageSource.FromResource("NewsScroll.Assets.iconRead-Dark.png"); } else { TableEditItems.item_read_status = false; ListItem.item_read_status = false; ListItem.item_read_icon = null; } } //Update the items in database await vSQLConnection.UpdateAsync(TableEditItems); } else { List <string> messageAnswers = new List <string>(); messageAnswers.Add("Ok"); await MessagePopup.Popup("Failed to mark item " + ActionType.ToLower(), "Please check your internet connection and try again.", messageAnswers); EventProgressEnableUI(); } return(MarkStatus); } catch { Debug.WriteLine("Failed to un/read item."); return(false); } }
static public async Task <bool> ItemsRead(ObservableCollection <Items> UpdateList, bool Silent, bool EnableUI) { try { if (!Silent) { await EventProgressDisableUI("Downloading read status...", true); } Debug.WriteLine("Downloading read status..."); //Wait for busy database await ApiUpdate.WaitForBusyDatabase(); //Get all stored items from the database List <TableItems> CurrentItems = await SQLConnection.Table <TableItems>().ToListAsync(); if (CurrentItems.Any()) { //Get last stored item date minus starred items TableItems LastStoredItem = CurrentItems.Where(x => x.item_star_status == false).OrderByDescending(x => x.item_datetime).LastOrDefault(); if (LastStoredItem != null) { //Date time calculations DateTime RemoveItemsRange = LastStoredItem.item_datetime.AddHours(-1); //Debug.WriteLine("Downloading read items till: " + LastStoredItem.item_title + "/" + RemoveItemsRange); Int64 UnixTimeTicks = (RemoveItemsRange.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks) / 10000000; //Second string[][] RequestHeader = new string[][] { new[] { "Authorization", "GoogleLogin auth=" + AppVariables.ApplicationSettings["ConnectApiAuth"].ToString() } }; Uri DownloadUri = new Uri(ApiConnectionUrl + "stream/items/ids?output=json&s=user/-/state/com.google/read&n=" + AppVariables.ItemsMaximumLoad + "&ot=" + UnixTimeTicks); string DownloadString = await AVDownloader.DownloadStringAsync(10000, "News Scroll", RequestHeader, DownloadUri); if (!String.IsNullOrWhiteSpace(DownloadString)) { JObject WebJObject = JObject.Parse(DownloadString); if (WebJObject["itemRefs"] != null && WebJObject["itemRefs"].HasValues) { if (!Silent) { await EventProgressDisableUI("Updating " + WebJObject["itemRefs"].Count() + " read status...", true); } Debug.WriteLine("Updating " + WebJObject["itemRefs"].Count() + " read status..."); //Check and set the received read item ids string ReadUpdateString = String.Empty; List <String> ReadItemsList = new List <String>(); foreach (JToken JTokenRoot in WebJObject["itemRefs"]) { string FoundItemId = JTokenRoot["id"].ToString().Replace(" ", String.Empty).Replace("tag:google.com,2005:reader/item/", String.Empty); ReadUpdateString += "'" + FoundItemId + "',"; ReadItemsList.Add(FoundItemId); } //Update the read status in database if (ReadItemsList.Any()) { ReadUpdateString = AVFunctions.StringRemoveEnd(ReadUpdateString, ","); Int32 UpdatedItems = await SQLConnection.ExecuteAsync("UPDATE TableItems SET item_read_status = ('1') WHERE item_id IN (" + ReadUpdateString + ") AND item_read_status = ('0')"); Debug.WriteLine("Updated read items: " + UpdatedItems); } //Update the read status in list await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { List <Items> ReadItemsIDList = UpdateList.Where(x => x.item_read_status == Visibility.Collapsed && ReadItemsList.Any(y => y == x.item_id)).ToList(); foreach (Items ReadItem in ReadItemsIDList) { ReadItem.item_read_status = Visibility.Visible; } } catch { } }); //Update the unread status in database string UnreadUpdateString = String.Empty; List <String> UnreadItemsList = (await SQLConnection.Table <TableItems>().ToListAsync()).Where(x => x.item_read_status == true && x.item_datetime > RemoveItemsRange).Select(x => x.item_id).Except(ReadItemsList).ToList(); foreach (String UnreadItem in UnreadItemsList) { UnreadUpdateString += "'" + UnreadItem + "',"; } if (UnreadItemsList.Any()) { UnreadUpdateString = AVFunctions.StringRemoveEnd(UnreadUpdateString, ","); Int32 UpdatedItems = await SQLConnection.ExecuteAsync("UPDATE TableItems SET item_read_status = ('0') WHERE item_id IN (" + UnreadUpdateString + ") AND item_read_status = ('1')"); Debug.WriteLine("Updated unread items: " + UpdatedItems); } //Update the unread status in list await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { List <Items> UnreadItemsIDList = UpdateList.Where(x => x.item_read_status == Visibility.Visible && UnreadItemsList.Any(y => y == x.item_id)).ToList(); foreach (Items UnreadItem in UnreadItemsIDList) { UnreadItem.item_read_status = Visibility.Collapsed; } } catch { } }); } } } } if (EnableUI) { await EventProgressEnableUI(); } return(true); } catch { await EventProgressEnableUI(); return(false); } }
private static TableItems JSonToTableItem(string ItemId, JToken JTokenRoot, bool IgnoreDate, bool Starred) { try { //Check date before adding //DateTime item_date = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((double)JTokenRoot["published"]); DateTime item_date = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds((double)JTokenRoot["crawlTimeMsec"]); if (IgnoreDate || item_date > DateTime.UtcNow.AddDays(-Convert.ToDouble(AppVariables.ApplicationSettings["RemoveItemsRange"]))) { TableItems AddItem = new TableItems(); AddItem.item_id = ItemId; AddItem.item_datetime = item_date; //Set the feed id string StreamId = "0"; try { StreamId = JTokenRoot["origin"]["streamId"].ToString().Replace(" ", String.Empty).Replace("feed/", String.Empty).Replace("/state/com.google/broadcast", String.Empty); } catch { Debug.WriteLine("Failed to get feed id for item: " + ItemId); } AddItem.item_feed_id = StreamId; //Set an unknown feed title string FeedTitle = "Unknown feed"; try { if (StreamId == "0") { FeedTitle = JTokenRoot["origin"]["title"].ToString(); AddItem.item_feed_title = FeedTitle; } else if (StreamId.StartsWith("user/")) { FeedTitle = JTokenRoot["origin"]["title"].ToString() + " (" + JTokenRoot["origin"]["feed_title"].ToString() + ")"; AddItem.item_feed_title = FeedTitle; } } catch { Debug.WriteLine("Failed to get feed title for item: " + ItemId); } //Set the item title string TitleString = "Unknown title"; try { TitleString = WebUtility.HtmlDecode(JTokenRoot["title"].ToString()); //TitleString = WebUtility.UrlDecode(TitleString); TitleString = TitleString.Replace("\n", String.Empty).Replace("\r", String.Empty); TitleString = Regex.Replace(TitleString, "<.*?>", String.Empty, RegexOptions.Singleline); } catch { Debug.WriteLine("Failed to get item title for item: " + ItemId); } AddItem.item_title = TitleString; //Set the item author string AuthorString = "Unknown author"; try { AuthorString = WebUtility.HtmlDecode(JTokenRoot["author"].ToString()); //AuthorString = WebUtility.UrlDecode(AuthorString); AuthorString = AuthorString.Replace("\n", String.Empty).Replace("\r", String.Empty); } catch { Debug.WriteLine("Failed to get item author for item: " + ItemId); } AddItem.item_author = AuthorString; //Set the item link string ItemLinkString = String.Empty; try { ItemLinkString = WebUtility.HtmlDecode(JTokenRoot["canonical"][0]["href"].ToString()); ItemLinkString = WebUtility.UrlDecode(ItemLinkString); } catch { Debug.WriteLine("Failed to get item link for item: " + ItemId); } AddItem.item_link = ItemLinkString; //Set the item content string ItemContentString = String.Empty; try { ItemContentString = JTokenRoot["summary"]["content"].ToString(); ItemContentString = WebUtility.HtmlDecode(ItemContentString); //ItemContentString = WebUtility.UrlDecode(ItemContentString); } catch { Debug.WriteLine("Failed to get item content for item: " + ItemId); } AddItem.item_content = Process.ProcessItemTextSummary(ItemContentString, false, true); AddItem.item_content_full = ItemContentString; //Check the item image string ItemImageLink = String.Empty; try { //Get the image source link if (JTokenRoot["enclosure"] != null && JTokenRoot["enclosure"][0]["href"] != null && (JTokenRoot["enclosure"][0]["type"].ToString().StartsWith("image") || JTokenRoot["enclosure"][0]["type"].ToString().StartsWith("unknown"))) { ItemImageLink = JTokenRoot["enclosure"][0]["href"].ToString(); } else { ItemImageLink = Process.GetItemHtmlFirstImage(AddItem.item_content_full, string.Empty); } //Decode the image source link ItemImageLink = WebUtility.HtmlDecode(ItemImageLink); ItemImageLink = WebUtility.UrlDecode(ItemImageLink); //Split http(s):// tags from uri if (ItemImageLink.Contains("https://") && ItemImageLink.LastIndexOf("https://") <= 20) { ItemImageLink = ItemImageLink.Substring(ItemImageLink.LastIndexOf("https://")); } if (ItemImageLink.Contains("http://") && ItemImageLink.LastIndexOf("http://") <= 20) { ItemImageLink = ItemImageLink.Substring(ItemImageLink.LastIndexOf("http://")); } //Check if image link is valid if (ItemImageLink.StartsWith("//")) { Debug.WriteLine("Invalid image link, adding: http: to " + ItemImageLink); ItemImageLink = "http:" + ItemImageLink; } else if (ItemImageLink.StartsWith("/")) { if (JTokenRoot["origin"]["htmlUrl"] != null) { Debug.WriteLine("Invalid image link, adding: " + JTokenRoot["origin"]["htmlUrl"].ToString() + " to " + ItemImageLink); ItemImageLink = JTokenRoot["origin"]["htmlUrl"].ToString() + ItemImageLink; } } } catch { Debug.WriteLine("Failed to get item image for item: " + ItemId); } AddItem.item_image = ItemImageLink; //Check item status string Categories = String.Empty; try { Categories = JTokenRoot["categories"].ToString(); } catch { Debug.WriteLine("Failed to check categories for item: " + ItemId); } //Read the item if (Categories.Contains("\"user/-/state/com.google/read\"")) { AddItem.item_read_status = true; } else { AddItem.item_read_status = false; } //Star the item if (Starred || Categories.Contains("\"user/-/state/com.google/starred\"")) { AddItem.item_star_status = true; } else { AddItem.item_star_status = false; } return(AddItem); } else { //Debug.WriteLine("Invalid process item: " + ItemId); return(null); } } catch (Exception ex) { Debug.WriteLine("Failed to process item: " + ItemId + "/" + ex.Message); return(null); } }
private static async Task <bool> DownloadToTableItemList(bool Preload, bool IgnoreDate, string DownloadString, bool Silent, bool EnableUI) { try { JObject WebJObject = JObject.Parse(DownloadString); if (WebJObject["items"] != null && WebJObject["items"].HasValues) { Int32 TotalItemsCount = WebJObject["items"].Count(); if (!Silent) { await EventProgressDisableUI("Processing " + TotalItemsCount + " items...", true); } Debug.WriteLine("Processing " + TotalItemsCount + " items..."); //Check the received item ids Int32 ProcessedItems = 0; Int32 PreloadedItems = AppVariables.ItemsToPreloadBatch; //Wait for busy database await ApiUpdate.WaitForBusyDatabase(); List <TableItems> TableUpdatedItems = new List <TableItems>(); List <TableItems> TableCurrentItems = await SQLConnection.Table <TableItems>().ToListAsync(); //Filter un/ignored feeds List <String> IgnoredFeedList = (await SQLConnection.Table <TableFeeds>().Where(x => x.feed_ignore_status == true).ToListAsync()).Select(x => x.feed_id).ToList(); foreach (JToken JTokenRoot in WebJObject["items"]) //.OrderByDescending(obj => (string)obj["crawlTimeMsec"]) { string FoundItemId = JTokenRoot["id"].ToString().Replace(" ", String.Empty).Replace("tag:google.com,2005:reader/item/", String.Empty); TableItems TableResult = TableCurrentItems.Where(x => x.item_id == FoundItemId).FirstOrDefault(); if (TableResult == null) { //Debug.WriteLine("Adding item: " + FoundItemId); TableResult = JSonToTableItem(FoundItemId, JTokenRoot, IgnoreDate, AppVariables.LoadStarred); if (TableResult != null) { TableUpdatedItems.Add(TableResult); TableCurrentItems.Add(TableResult); } } else { //Debug.WriteLine("Updating item: " + FoundItemId); //Check item status string Categories = String.Empty; try { Categories = JTokenRoot["categories"].ToString(); } catch { } //Read the item if (Categories.Contains("\"user/-/state/com.google/read\"")) { TableResult.item_read_status = true; } else { TableResult.item_read_status = false; } //Star the item if (AppVariables.LoadStarred || Categories.Contains("\"user/-/state/com.google/starred\"")) { TableResult.item_star_status = true; } else { TableResult.item_star_status = false; } TableUpdatedItems.Add(TableResult); } //Check if items need to be preloaded if (Preload && TableResult != null && PreloadedItems <= AppVariables.ItemsToPreloadMax) { //Validate the processed item if (ProcessItemLoad.ValidateTableItems(IgnoredFeedList, TableResult)) { ProcessedItems++; } //Preload items to the list if (ProcessedItems == PreloadedItems || ProcessedItems == TotalItemsCount) { Debug.WriteLine("Preloading " + AppVariables.ItemsToPreloadBatch + " new items..."); await ProcessItemLoad.DatabaseToList(null, TableCurrentItems, AppVariables.CurrentItemsLoaded, AppVariables.ItemsToPreloadBatch, true, false); PreloadedItems += AppVariables.ItemsToPreloadBatch; } } } //Update the items in database if (TableUpdatedItems.Any()) { if (!Silent) { await EventProgressDisableUI("Updating " + TableUpdatedItems.Count() + " items...", true); } Debug.WriteLine("Updating " + TableUpdatedItems.Count() + " items..."); await SQLConnection.InsertOrReplaceAllAsync(TableUpdatedItems); } } return(true); } catch (Exception ex) { Debug.WriteLine("Failed DownloadToTableItemList: " + ex.Message); return(false); } }
private static async Task <bool> DownloadToTableItemList(bool IgnoreDate, string DownloadString, bool Silent, bool EnableUI) { try { JObject WebJObject = JObject.Parse(DownloadString); if (WebJObject["items"] != null && WebJObject["items"].HasValues) { int TotalItemsCount = WebJObject["items"].Count(); if (!Silent) { await EventProgressDisableUI("Processing " + TotalItemsCount + " items...", true); } System.Diagnostics.Debug.WriteLine("Processing " + TotalItemsCount + " items..."); List <TableItems> TableUpdatedItems = new List <TableItems>(); List <TableItems> TableCurrentItems = await SQLConnection.Table <TableItems>().ToListAsync(); //Filter un/ignored feeds List <string> IgnoredFeedList = (await SQLConnection.Table <TableFeeds>().Where(x => x.feed_ignore_status == true).ToListAsync()).Select(x => x.feed_id).ToList(); foreach (JToken JTokenRoot in WebJObject["items"]) //.OrderByDescending(obj => (string)obj["crawlTimeMsec"]) { string FoundItemId = JTokenRoot["id"].ToString().Replace(" ", string.Empty).Replace("tag:google.com,2005:reader/item/", string.Empty); TableItems TableResult = TableCurrentItems.Where(x => x.item_id == FoundItemId).FirstOrDefault(); if (TableResult == null) { //System.Diagnostics.Debug.WriteLine("Adding item: " + FoundItemId); TableResult = JSonToTableItem(FoundItemId, JTokenRoot, IgnoreDate, AppVariables.LoadStarred); if (TableResult != null) { TableUpdatedItems.Add(TableResult); TableCurrentItems.Add(TableResult); } } else { //System.Diagnostics.Debug.WriteLine("Updating item: " + FoundItemId); //Check item status string Categories = string.Empty; try { Categories = JTokenRoot["categories"].ToString(); } catch { } //Read the item if (Categories.Contains("\"user/-/state/com.google/read\"")) { TableResult.item_read_status = true; } else { TableResult.item_read_status = false; } //Star the item if (AppVariables.LoadStarred || Categories.Contains("\"user/-/state/com.google/starred\"")) { TableResult.item_star_status = true; } else { TableResult.item_star_status = false; } TableUpdatedItems.Add(TableResult); } } //Update the items in database if (TableUpdatedItems.Any()) { if (!Silent) { await EventProgressDisableUI("Updating " + TableUpdatedItems.Count() + " items...", true); } System.Diagnostics.Debug.WriteLine("Updating " + TableUpdatedItems.Count() + " items..."); await SQLConnection.InsertAllAsync(TableUpdatedItems, "OR REPLACE"); } } return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Failed DownloadToTableItemList: " + ex.Message); return(false); } }
//Load item into the viewer private async Task LoadItem(string CustomItemContent) { try { //Load the full item TableItems LoadTable = await SQLConnection.Table <TableItems>().Where(x => x.item_id == vCurrentWebSource.item_id).FirstOrDefaultAsync(); if (LoadTable != null) { //Check if media needs to load AppVariables.LoadMedia = true; if (!NetworkInterface.GetIsNetworkAvailable() && !(bool)AppVariables.ApplicationSettings["DisplayImagesOffline"]) { AppVariables.LoadMedia = false; } //Set the date time string DateTime convertedDate = DateTime.SpecifyKind(LoadTable.item_datetime, DateTimeKind.Utc).ToLocalTime(); string DateAuthorString = convertedDate.ToString(AppVariables.CultureInfoFormat.LongDatePattern, AppVariables.CultureInfoFormat) + ", " + convertedDate.ToString(AppVariables.CultureInfoFormat.ShortTimePattern, AppVariables.CultureInfoFormat); //Add the author to date time if (!string.IsNullOrWhiteSpace(LoadTable.item_author)) { DateAuthorString += " by " + LoadTable.item_author; } tb_ItemDateString.Text = DateAuthorString; //Load the item content bool SetHtmlToRichTextBlock = false; if (!string.IsNullOrWhiteSpace(CustomItemContent)) { await HtmlToXaml(rtb_ItemContent, CustomItemContent, string.Empty); SetHtmlToRichTextBlock = true; } else if (!string.IsNullOrWhiteSpace(LoadTable.item_content_full)) { SetHtmlToRichTextBlock = await HtmlToXaml(rtb_ItemContent, LoadTable.item_content_full, string.Empty); } //Check if html to xaml has failed if (!SetHtmlToRichTextBlock || !rtb_ItemContent.Children.Any()) { //Load summary text TextBlock textLabel = new TextBlock(); textLabel.Text = AVFunctions.StringCut(LoadTable.item_content, AppVariables.MaximumItemTextLength, "..."); //Add paragraph to rich text block rtb_ItemContent.Children.Clear(); rtb_ItemContent.Children.Add(textLabel); } //Check if item content contains preview image await CheckItemContentContainsPreviewImage(LoadTable); //Adjust the itemviewer size await AdjustItemViewerSize(); } } catch { } }
private void CollectionForm_Closing(object sender, CancelEventArgs e) { // Get Collection Form CollectionForm collectionForm = (CollectionForm)sender; // Get edited collection object object editValue = collectionForm.EditValue; // Check if collection edits have been OK'ed or Canceled DialogResult dialogResult = collectionForm.DialogResult; switch (dialogResult) { case DialogResult.OK: // Get Schema Model DiagrammerEnvironment d = DiagrammerEnvironment.Default; SchemaModel schemaModel = d.SchemaModel; // Suspect Model Draws schemaModel.Suspend(); // Get TableItems Collection TableItems tableItems = (TableItems)editValue; // Store items in new List List <TableItem> list = new List <TableItem>(); foreach (TableItem tableItem in tableItems) { list.Add(tableItem); } // Clear TableItems Collection tableItems.Clear(); // Re-add all items. foreach (TableItem tableItem in list) { // If the Table property is not set then use TableItems::Add to append the item. // This will ensure that Table, GradientColor, Indent properties are correctly set. // This will also reset the height of the TableItems collection. if (tableItem.Indent == 0f) { tableItems.Add(tableItem); } else { ((IList)tableItems).Add(tableItem); } } // Refresh Model schemaModel.Resume(); schemaModel.Refresh(); break; case DialogResult.Cancel: default: // Collection edits are canceled. No need to refresh. break; } }
//Load item into the viewer private async Task LoadItem(string CustomItemContent) { try { //Set item bindings Binding binding_item_title = new Binding(); binding_item_title.Source = vCurrentItem; binding_item_title.Path = new PropertyPath("item_title"); tb_ItemTitle.SetBinding(TextBlock.TextProperty, binding_item_title); Binding binding_item_datestring = new Binding(); binding_item_datestring.Source = vCurrentItem; binding_item_datestring.Path = new PropertyPath("item_datestring"); tb_ItemDateString.SetBinding(TextBlock.TextProperty, binding_item_datestring); Binding binding_item_read_status = new Binding(); binding_item_read_status.Source = vCurrentItem; binding_item_read_status.Path = new PropertyPath("item_read_status"); image_item_read_status.SetBinding(Image.VisibilityProperty, binding_item_read_status); Binding binding_item_star_status = new Binding(); binding_item_star_status.Source = vCurrentItem; binding_item_star_status.Path = new PropertyPath("item_star_status"); image_item_star_status.SetBinding(Image.VisibilityProperty, binding_item_star_status); Binding binding_feed_icon = new Binding(); binding_feed_icon.Source = vCurrentItem; binding_feed_icon.Path = new PropertyPath("feed_icon"); image_feed_icon.SetBinding(Image.SourceProperty, binding_feed_icon); Binding binding_feed_title = new Binding(); binding_feed_title.Source = vCurrentItem; binding_feed_title.Path = new PropertyPath("feed_title"); ToolTip header_tooltip = new ToolTip(); header_tooltip.SetBinding(ToolTip.ContentProperty, binding_feed_title); ToolTipService.SetToolTip(stackpanel_HeaderItem, header_tooltip); //Load the full item TableItems LoadTable = await SQLConnection.Table <TableItems>().Where(x => x.item_id == vCurrentItem.item_id).FirstOrDefaultAsync(); if (LoadTable != null) { //Load the item content bool SetHtmlToRichTextBlock = false; if (!string.IsNullOrWhiteSpace(CustomItemContent)) { await HtmlToXaml(popup_ItemContent, CustomItemContent, string.Empty); SetHtmlToRichTextBlock = true; } else if (!string.IsNullOrWhiteSpace(LoadTable.item_content_full)) { SetHtmlToRichTextBlock = await HtmlToXaml(popup_ItemContent, LoadTable.item_content_full, string.Empty); } //Check if html to xaml has failed if (!SetHtmlToRichTextBlock || !popup_ItemContent.Children.Any()) { //Load summary text TextBlock textLabel = new TextBlock(); textLabel.Text = AVFunctions.StringCut(LoadTable.item_content, AppVariables.MaximumItemTextLength, "..."); //Add paragraph to rich text block popup_ItemContent.Children.Clear(); popup_ItemContent.Children.Add(textLabel); } //Check if item content contains preview image CheckItemContentContainsPreviewImage(LoadTable); } } catch { } }
private static async Task <bool> MarkReadSingle(ObservableCollection <Items> UpdateList, Items ListItem, string ActionType, bool Silent) { try { bool MarkStatus = false; string ItemId = ListItem.item_id; //Check if internet is available if (!NetworkInterface.GetIsNetworkAvailable() || ApiMessageError.StartsWith("(Off)")) { if (!Silent) { await EventProgressDisableUI("Off marking item as " + ActionType.ToLower() + "...", true); } Debug.WriteLine("Off marking item as " + ActionType.ToLower() + "..."); await AddOfflineSync(ItemId, ActionType); MarkStatus = true; } else { if (!Silent) { await EventProgressDisableUI("Marking item as " + ActionType.ToLower() + "...", true); } Debug.WriteLine("Marking item as " + ActionType.ToLower() + "..."); string[][] RequestHeader = new string[][] { new[] { "Authorization", "GoogleLogin auth=" + AppVariables.ApplicationSettings["ConnectApiAuth"].ToString() } }; HttpStringContent PostContent; if (ActionType == "Read") { PostContent = new HttpStringContent("i=" + ItemId + "&a=user/-/state/com.google/read", Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/x-www-form-urlencoded"); } else { PostContent = new HttpStringContent("i=" + ItemId + "&r=user/-/state/com.google/read", Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/x-www-form-urlencoded"); } HttpResponseMessage PostHttp = await AVDownloader.SendPostRequestAsync(7500, "News Scroll", RequestHeader, new Uri(ApiConnectionUrl + "edit-tag"), PostContent); if (PostHttp != null && (PostHttp.Content.ToString() == "OK" || PostHttp.Content.ToString().Contains("<error>Not found</error>"))) { MarkStatus = true; } } if (MarkStatus) { //Wait for busy database await ApiUpdate.WaitForBusyDatabase(); //Mark item in database and list TableItems TableEditItems = await SQLConnection.Table <TableItems>().Where(x => x.item_id == ItemId).FirstOrDefaultAsync(); if (TableEditItems != null) { if (ActionType == "Read") { TableEditItems.item_read_status = true; ListItem.item_read_status = Visibility.Visible; //Updates itemviewer if (App.vApplicationFrame.SourcePageType.ToString().EndsWith("NewsPage") && NewsPage.vCurrentLoadingFeedFolder.feed_id != "1" && (bool)AppVariables.ApplicationSettings["HideReadMarkedItem"]) { UpdateList.Remove(ListItem); } } else { TableEditItems.item_read_status = false; ListItem.item_read_status = Visibility.Collapsed; //Updates itemviewer if (App.vApplicationFrame.SourcePageType.ToString().EndsWith("NewsPage") && NewsPage.vCurrentLoadingFeedFolder.feed_id == "1" && (bool)AppVariables.ApplicationSettings["HideReadMarkedItem"]) { UpdateList.Remove(ListItem); } } } //Update the items in database await SQLConnection.UpdateAsync(TableEditItems); } else { await AVMessageBox.Popup("Failed to mark item " + ActionType.ToLower(), "Please check your internet connection and try again.", "Ok", "", "", "", "", false); await EventProgressEnableUI(); } return(MarkStatus); } catch { Debug.WriteLine("Failed to un/read item."); return(false); } }
/// <summary> </summary> public override bool Equals(object obj) { var typedObj = obj as DataItemThresholds; if (typedObj == null) { return(false); } // ObdGuid if (ObdGuid != typedObj.ObdGuid) { return(false); } // DateRange if (DateRange == null && typedObj.DateRange != null) { return(false); } if (DateRange != null && !DateRange.Equals(typedObj.DateRange)) { return(false); } // Lower and Upper limits if (LowerLimit != typedObj.LowerLimit || UpperLimit != typedObj.UpperLimit) { return(false); } // String Algorithm if (StringAlgorithm != typedObj.StringAlgorithm) { return(false); } // String Input if (String.IsNullOrEmpty(StringInput) && !String.IsNullOrEmpty(typedObj.StringInput)) { return(false); } if (!String.IsNullOrEmpty(StringInput) && !StringInput.Equals(typedObj.StringInput, StringComparison.InvariantCultureIgnoreCase)) { return(false); } // TableItems // If both are null, return true if (TableItems == null && typedObj.TableItems == null) { return(true); } // If only one is null, return false. if (TableItems == null || typedObj.TableItems == null) { return(false); } // If they don't have the same # of items, return false. if (TableItems.Count != typedObj.TableItems.Count) { return(false); } // See if the first list contains all of the items in the second list. If not, return false. if (!TableItems.ContainsAll(typedObj.TableItems)) { return(false); } return(true); }
//Load item into the viewer private async Task LoadItem(string item_content_custom) { try { //Load the full item TableItems LoadTable = await vSQLConnection.Table <TableItems>().Where(x => x.item_id == vItemViewerItem.item_id).FirstOrDefaultAsync(); if (LoadTable != null) { //Set the date time string DateTime convertedDate = DateTime.SpecifyKind(LoadTable.item_datetime, DateTimeKind.Utc).ToLocalTime(); string DateAuthorString = convertedDate.ToString(AppVariables.CultureInfoLocal.DateTimeFormat.LongDatePattern, AppVariables.CultureInfoLocal.DateTimeFormat) + ", " + convertedDate.ToString(AppVariables.CultureInfoLocal.DateTimeFormat.ShortTimePattern, AppVariables.CultureInfoLocal.DateTimeFormat); //Add the author to date time if (!string.IsNullOrWhiteSpace(LoadTable.item_author)) { DateAuthorString += " by " + LoadTable.item_author; } tb_ItemDateString.Text = DateAuthorString; //fix ////Enable or disable text selection //if ((bool)AppSettingLoad("ItemTextSelection")) //{ // tb_ItemTitle.IsTextSelectionEnabled = true; // tb_ItemDateString.IsTextSelectionEnabled = true; // item_content.IsTextSelectionEnabled = true; //} //else //{ // tb_ItemTitle.IsTextSelectionEnabled = false; // tb_ItemDateString.IsTextSelectionEnabled = false; // item_content.IsTextSelectionEnabled = false; //} //Load the item content bool SetHtmlToRichLabel = false; if (!string.IsNullOrWhiteSpace(item_content_custom)) { SetHtmlToRichLabel = HtmlToStackLayout(item_content, item_content_custom, string.Empty); } else if (!string.IsNullOrWhiteSpace(LoadTable.item_content_full)) { SetHtmlToRichLabel = HtmlToStackLayout(item_content, LoadTable.item_content_full, string.Empty); } //Check if html to xaml has failed if (!SetHtmlToRichLabel || !item_content.Children.Any()) { //Load summary text Label labelSummary = new Label(); labelSummary.Text = AVFunctions.StringCut(LoadTable.item_content, AppVariables.MaximumItemTextLength, "..."); //Add paragraph to rich text block item_content.Children.Clear(); item_content.Children.Add(labelSummary); } //Check if item content contains preview image CheckItemContentContainsPreviewImage(LoadTable); } } catch { } }
IOrderedEnumerable <SlinkUser> GetOrderedSections() { return(TableItems.DistinctBy(c => c.FacebookID).Where(c => c.Cards.Where(d => d.Retained == true && d.Deleted == false).Count() > 0).OrderBy(c => c.FirstName)); }
private static async Task <bool> MarkStarSingle(Items ListItem, bool RemoveFromList, string ActionType, bool Silent) { try { bool MarkStatus = false; string ItemId = ListItem.item_id; //Check if internet is available if (!AppVariables.InternetAccess || ApiMessageError.StartsWith("(Off)")) { if (!Silent) { await EventProgressDisableUI("Off " + ActionType.ToLower() + "ring the item...", true); } System.Diagnostics.Debug.WriteLine("Off " + ActionType.ToLower() + "ring the item..."); await AddOfflineSync(ItemId, ActionType); MarkStatus = true; } else { if (!Silent) { await EventProgressDisableUI(ActionType + "ring the item...", true); } System.Diagnostics.Debug.WriteLine(ActionType + "ring the item..."); string[][] RequestHeader = new string[][] { new[] { "Authorization", "GoogleLogin auth=" + AppVariables.ApplicationSettings["ConnectApiAuth"].ToString() } }; StringContent PostContent; if (ActionType == "Star") { PostContent = new StringContent("i=" + ItemId + "&a=user/-/state/com.google/starred", Encoding.UTF8, "application/x-www-form-urlencoded"); } else { PostContent = new StringContent("i=" + ItemId + "&r=user/-/state/com.google/starred", Encoding.UTF8, "application/x-www-form-urlencoded"); } string PostHttp = await AVDownloader.SendPostRequestAsync(7500, "News Scroll", RequestHeader, new Uri(ApiConnectionUrl + "edit-tag"), PostContent); if (PostHttp == "OK" || PostHttp.Contains("<error>Not found</error>")) { MarkStatus = true; } } if (MarkStatus) { //Mark item in database and list TableItems TableEditItems = await SQLConnection.Table <TableItems>().Where(x => x.item_id == ItemId).FirstOrDefaultAsync(); if (TableEditItems != null) { if (ActionType == "Star") { TableEditItems.item_star_status = true; ListItem.item_star_status = Visibility.Visible; } else { TableEditItems.item_star_status = false; ListItem.item_star_status = Visibility.Collapsed; if (RemoveFromList) { List_StarredItems.Remove(ListItem); } } } //Update the items in database await SQLConnection.UpdateAsync(TableEditItems); } else { await new MessagePopup().OpenPopup("Failed to " + ActionType.ToLower() + " item", "Please check your internet connection and try again.", "Ok", "", "", "", "", false); await EventProgressEnableUI(); } return(MarkStatus); } catch { System.Diagnostics.Debug.WriteLine("Failed to un/star item."); return(false); } }