private void CheckAndUpdateOffline(MNode megaNode) { var offlineNodePath = OfflineService.GetOfflineNodePath(megaNode); if ((megaNode.getType() == MNodeType.TYPE_FILE && FileService.FileExists(offlineNodePath)) || (megaNode.getType() == MNodeType.TYPE_FOLDER && FolderService.FolderExists(offlineNodePath)) || TransferService.ExistPendingNodeOfflineTransfer(this)) { if (SavedForOfflineDB.ExistsNodeByLocalPath(offlineNodePath)) { SavedForOfflineDB.UpdateNode(megaNode); } else { SavedForOfflineDB.InsertNode(megaNode); } this.IsSavedForOffline = true; return; } if (SavedForOfflineDB.ExistsNodeByLocalPath(offlineNodePath)) { SavedForOfflineDB.DeleteNodeByLocalPath(offlineNodePath); } this.IsSavedForOffline = false; }
private void AddOfflineNodeFromTransfer(TransferObjectModel megaTransfer) { var parentNode = SdkService.MegaSdk.getParentNode(megaTransfer.SelectedNode.OriginalMNode); // Need get the path on the transfer finish because the file name can be changed if already exists in the destiny path. var offlineNodePath = Path.Combine( OfflineService.GetOfflineParentNodePath(megaTransfer.SelectedNode.OriginalMNode), megaTransfer.Transfer.getFileName()); var sfoNode = new SavedForOfflineDB { Fingerprint = SdkService.MegaSdk.getNodeFingerprint(megaTransfer.SelectedNode.OriginalMNode), Base64Handle = megaTransfer.SelectedNode.OriginalMNode.getBase64Handle(), LocalPath = offlineNodePath, ParentBase64Handle = parentNode != null? parentNode.getBase64Handle() : string.Empty }; if (SavedForOfflineDB.ExistsNodeByLocalPath(sfoNode.LocalPath)) { SavedForOfflineDB.UpdateNode(sfoNode); } else { SavedForOfflineDB.InsertNode(sfoNode); } UiService.OnUiThread(() => megaTransfer.SelectedNode.IsSavedForOffline = true); OfflineService.CheckOfflineNodePath(megaTransfer.SelectedNode.OriginalMNode); }
/// <summary> /// Remove the node from the offline section. /// </summary> /// <returns>TRUE if the node was successfully removed or FALSE in other case.</returns> public bool RemoveFromOffline() { var nodePath = OfflineService.GetOfflineNodePath(this.OriginalMNode); var parentNodePath = OfflineService.GetOfflineParentNodePath(this.OriginalMNode); // Search if the file has a pending transfer for offline and cancel it on this case TransferService.CancelPendingNodeOfflineTransfers(this); bool result = true; if (this.IsFolder) { result &= OfflineService.RemoveFolderFromOfflineDB(nodePath); result &= FolderService.DeleteFolder(nodePath, true); } else { result &= SavedForOfflineDB.DeleteNodeByLocalPath(nodePath); result &= FileService.DeleteFile(nodePath); } result &= OfflineService.CleanOfflineFolderNodePath(parentNodePath); this.IsSavedForOffline = !result; return(result); }
public void Initialize(Settings settings, OfflineService offlineService, Reddit redditService, Dictionary<string, bool> initialFilter) { _settings = settings; _initialFilter = initialFilter; _offlineService = offlineService; _redditService = redditService; }
public async void GetDeals(int len, int amount, bool addon) { if (IsBusy) { return; } IsBusy = true; noItems = false; try { ObservableCollection <Product> result = null; if (CrossConnectivity.Current.IsConnected) { result = await ProductService.Instance.FetchDeals(amount, null, null, len); if (result == null) { isDone = true; if (DealList.Count < 1) { noItems = true; } return; } OfflineService.Write <ObservableCollection <Product> >(result, Strings.DealList_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <Product> >(Strings.DealList_Offline_fileName, null); } if (result == null) { isDone = true; if (DealList.Count < 1) { noItems = true; } return; } ProductList = result; if (addon) { DealList.AddRange(formData(result)); } else { DealList = formData(result); } } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsBusy = false; } }
public async void GetCart() { if (IsBusy) { return; } IsBusy = true; noItems = false; try { CartType result = null; if (CrossConnectivity.Current.IsConnected) { result = await CartService.Instance.FetchUserCart(AccountService.Instance.Current_Account.Email); if (result == null) { noItems = true; hidecheck = false; MyCartList = new ObservableCollection <mCart>(); CalculateGrandPrice(); return; } OfflineService.Write <CartType>(result, Strings.MyCart_Offline_fileName, null); } else { result = await OfflineService.Read <CartType>(Strings.MyCart_Offline_fileName, null); } if (result == null) { noItems = true; hidecheck = false; MyCartList = new ObservableCollection <mCart>(); CalculateGrandPrice(); return; } CartType orgnize = result; MyProductList = orgnize.Prop1; MyCartList = await BindClickables(FormatCart(MyProductList, orgnize.Prop2)); CalculateGrandPrice(); hidecheck = true; } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsBusy = false; IsListRefereshing = false; } }
public async Task <ObservableCollection <Product> > GetDeals() { if (IsBusy_Deal) { return(null); } IsBusy_Deal = true; try { ObservableCollection <Product> result = null; if (CrossConnectivity.Current.IsConnected) { result = await ProductService.Instance.FetchDeals(6, null, null, 0); if (result == null) { //No Item Found(WORK ON) return(new ObservableCollection <Product>()); } OfflineService.Write <ObservableCollection <Product> >(result, Strings.DashDeals_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <Product> >(Strings.DashDeals_Offline_fileName, null); } if (result == null) { //No Item Found(WORK ON) return(new ObservableCollection <Product>()); } for (var i = 0; i < result.Count; i++) { result[i].Thumbnail = result[i].Images[0]; } return(result); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); return(null); } finally { IsBusy_Deal = false; } }
public BaconProvider() { WebRequest.RegisterPrefix("http://", SharpGIS.WebRequestCreator.GZip); WebRequest.RegisterPrefix("https://", SharpGIS.WebRequestCreator.GZip); var redditService = new OfflineDelayableRedditService(); var imagesService = new ImagesService(); var liveTileService = new LiveTileService(); var notificationService = new NotificationService(); var settingsService = new SettingsService(); var offlineService = new OfflineService(redditService, notificationService, settingsService); var simpleHttpService = new SimpleHttpService(); var systemServices = new SystemServices(); var navigationService = new NavigationServices(); var webViewWrapper = new WebViewWrapper(); var userService = new UserService(); var videoService = new VideoService(simpleHttpService, notificationService, settingsService); _services = new Dictionary <Type, object> { { typeof(IImagesService), imagesService }, { typeof(ILiveTileService), liveTileService }, { typeof(IRedditService), redditService }, { typeof(IOfflineService), offlineService }, { typeof(ISimpleHttpService), simpleHttpService }, { typeof(INotificationService), notificationService }, { typeof(ISettingsService), settingsService }, { typeof(ISystemServices), systemServices }, { typeof(INavigationService), navigationService }, { typeof(IWebViewWrapper), webViewWrapper }, { typeof(IUserService), userService }, { typeof(IVideoService), videoService } }; SimpleIoc.Default.Register <IImagesService>(() => imagesService); SimpleIoc.Default.Register <ILiveTileService>(() => liveTileService); SimpleIoc.Default.Register <IRedditService>(() => redditService); SimpleIoc.Default.Register <IOfflineService>(() => offlineService); SimpleIoc.Default.Register <ISimpleHttpService>(() => simpleHttpService); SimpleIoc.Default.Register <INotificationService>(() => notificationService); SimpleIoc.Default.Register <ISettingsService>(() => settingsService); SimpleIoc.Default.Register <ISystemServices>(() => systemServices); SimpleIoc.Default.Register <INavigationService>(() => navigationService); SimpleIoc.Default.Register <IWebViewWrapper>(() => webViewWrapper); SimpleIoc.Default.Register <IUserService>(() => userService); SimpleIoc.Default.Register <IVideoService>(() => videoService); redditService.Initialize(GetService <ISettingsService>(), GetService <IOfflineService>(), GetService <ISimpleHttpService>(), GetService <IUserService>(), GetService <INotificationService>()); }
private async void GetMyNotfiy(string email) { if (IsBusy) { return; } try { IsBusy = true; IsEmpty = false; if (CrossConnectivity.Current.IsConnected) { var result = await NotifyService.Instance.FetchNotfiy(email); if (result == null) { IsEmpty = true; NotifyList = new ObservableCollection <mNotify>(); return; } NotifyList = formatData(result); OfflineService.Write <ObservableCollection <mNotify> >(result, Strings.Notify_Offline_fileName, null); } else { var result = await OfflineService.Read <ObservableCollection <mNotify> >(Strings.Notify_Offline_fileName, null); if (result == null) { IsEmpty = true; NotifyList = new ObservableCollection <mNotify>(); return; } NotifyList = formatData(result); } } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsBusy = false; IsRefresing = false; } }
public async void GetSave() { if (IsBusy) { return; } IsBusy = true; noItems = false; try { ObservableCollection <Product> result = null; if (CrossConnectivity.Current.IsConnected) { result = await SavelaterService.Instance.Fetchitems(AccountService.Instance.Current_Account.Email); if (result == null) { noItems = true; MySaveList = new ObservableCollection <mSavelaterR>(); return; } OfflineService.Write <ObservableCollection <Product> >(result, Strings.MySaveLater_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <Product> >(Strings.MySaveLater_Offline_fileName, null); } if (result == null) { noItems = true; MySaveList = new ObservableCollection <mSavelaterR>(); return; } MyProductList = result; MySaveList = await BindClickables(FormatList(result)); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsBusy = false; IsListRefereshing = false; } }
/// <summary> /// Insert a node in the database. /// </summary> /// <param name="megaNode">Node to insert.</param> public static void InsertNode(MNode megaNode) { var offlineNodePath = OfflineService.GetOfflineNodePath(megaNode); var parentNode = SdkService.MegaSdk.getParentNode(megaNode); var sfoNode = new SavedForOfflineDB() { Fingerprint = SdkService.MegaSdk.getNodeFingerprint(megaNode), Base64Handle = megaNode.getBase64Handle(), LocalPath = offlineNodePath, ParentBase64Handle = parentNode != null? parentNode.getBase64Handle() : string.Empty }; InsertItem(sfoNode); }
/// <summary> /// 下行准入控制的入口 /// </summary> /// <param name="iSimulationCarrierList"></param> /// <param name="currentTTI"></param> public void DlAdmissionControlExecute(List<ISimulationCarrier> iSimulationCarrierList, int currentTTI) { SetGBRServicePriorityList(iSimulationCarrierList, currentTTI); //if (SimulationConstant.IS_ADMISSION_CONTROL_ON) if(true) { foreach (IAdmissionCarrier carrier in iSimulationCarrierList) { this.CalculateServiceSatisfy(carrier, currentTTI); OfflineService service = new OfflineService(currentTTI, this.m_OfflineThresholdParam); service.OfflineVoiceUserService(carrier.DlVoiceWaitUserList, carrier.OffLineUserList); service.OfflineDataUserService(carrier.DlDataWaitUserList, this.m_GBRUserlist, carrier.OffLineUserList); if (carrier.DLHandOverDataUserList.Count != 0) { carrier.DlDataNewAccessUserList.AddRange(carrier.DLHandOverDataUserList); carrier.DLHandOverDataUserList.Clear(); } if (carrier.DLHandOverVoiceUserList.Count != 0) { carrier.DlVoiceNewAccessUserList.AddRange(carrier.DLHandOverVoiceUserList); carrier.DLHandOverVoiceUserList.Clear(); } } foreach (IAdmissionCarrier carrier in iSimulationCarrierList) { if (currentTTI < (this.m_LBThresholdParam.LbBalanceTime + this.m_LBThresholdParam.FirstLbTime)) { this.LoadBanlance(iSimulationCarrierList, currentTTI, carrier); } else { this.LoadControl(currentTTI, carrier); } } foreach (IAdmissionCarrier carrier in iSimulationCarrierList) { AdmissionCellTag admissionCarrierTag = carrier.AdmissionCarrierTag as AdmissionCellTag; admissionCarrierTag.DLAcceptHOThroughput = 0.0; //admissionCarrierTag.DLHasOutThroughput = 0.0; //修改by任鹏飞 admissionCarrierTag.DLTotalHOThroughput = 0.0; admissionCarrierTag.DLHasOutThroughput = 0.0; admissionCarrierTag.DLSourceOutThroughput = 0.0; carrier.IsDLLoadBalance = false; } } }
public async void GetAddresses() { if (IsBusy) { return; } IsBusy = true; noItems = false; try { ObservableCollection <mOrderAddress> result = null; if (CrossConnectivity.Current.IsConnected) { result = await AddressService.Instance.FetchAddresses(AccountService.Instance.Current_Account.Email, 100, 0); if (result == null) { noItems = true; Addresses = new ObservableCollection <mOrderAddress>(); return; } OfflineService.Write <ObservableCollection <mOrderAddress> >(result, Strings.MyAddress_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <mOrderAddress> >(Strings.MyAddress_Offline_fileName, null); } if (result == null) { noItems = true; Addresses = new ObservableCollection <mOrderAddress>(); return; } Addresses = await BindClickables(result); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsBusy = false; } }
/// <summary> /// Remove the node from the offline section. /// </summary> /// <param name="isMultiSelect">Indicate if is removing multiple nodes.</param> /// <returns>NULL if the user cancel the action, TRUE if the node was successfully removed or FALSE in other case.</returns> public async Task <bool?> RemoveFromOfflineAsync(bool isMultiSelect = false) { bool?result = true; if (!isMultiSelect) { var userSelection = await DialogService.ShowOkCancelAsync( ResourceService.AppMessages.GetString("AM_RemoveFromOfflineQuestion_Title"), string.Format(ResourceService.AppMessages.GetString("AM_RemoveFromOfflineQuestion"), this.Name)); if (!userSelection) { return(null); } } // Search if the node has pending transfers for offline and cancel them on this case TransferService.CancelPendingNodeOfflineTransfers(this); var directoryInfo = new DirectoryInfo(this.NodePath).Parent; if (directoryInfo != null) { var parentFolderPath = directoryInfo.FullName; if (this.IsFolder) { result &= OfflineService.RemoveFolderFromOfflineDB(this.NodePath); result &= FolderService.DeleteFolder(this.NodePath, true); } else { result &= SavedForOfflineDB.DeleteNodeByLocalPath(this.NodePath); result &= FileService.DeleteFile(this.NodePath); } result &= OfflineService.CleanOfflineFolderNodePath(parentFolderPath); } result &= this.Parent?.ItemCollection?.Items?.Remove(this); return(result); }
public async void GetMyOrders() { try { noItems = false; if (CrossConnectivity.Current.IsConnected) { var result = await OrderService.Instance.FetchOrders(AccountService.Instance.Current_Account.Email); if (result == null) { noItems = true; MyOrders = new ObservableCollection <mOrder>(); return; } MyOrders = FormatData(result); OfflineService.Write <ObservableCollection <mOrder> >(result, Strings.Order_Offline_fileName, null); } else { var result = await OfflineService.Read <ObservableCollection <mOrder> >(Strings.Order_Offline_fileName, null); if (result == null) { noItems = true; MyOrders = new ObservableCollection <mOrder>(); return; } MyOrders = FormatData(result); } } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); } finally { IsListRefereshing = false; IsBusy = false; } }
protected void FinishInit() { Current = this; _listingFilter = new NSFWListingFilter(); if (IsInDesignMode) { _initializationBlob = new InitializationBlob { Settings = new Dictionary<string, string>(), NSFWFilter = new Dictionary<string, bool>() }; } else { OfflineService = new OfflineService(); _initializationBlob = OfflineService.LoadInitializationBlob(""); } Settings = new Model.Settings(_initializationBlob.Settings); SettingsHub = new SettingsViewModel(Settings); RedditUserState = _initializationBlob.DefaultUser ?? new UserState(); SnooStreamViewModel.ActivityManager.OAuth = SnooStreamViewModel.RedditUserState != null && SnooStreamViewModel.RedditUserState.OAuth != null ? JsonConvert.SerializeObject(SnooStreamViewModel.RedditUserState) : ""; SnooStreamViewModel.ActivityManager.CanStore = SnooStreamViewModel.RedditUserState != null && SnooStreamViewModel.RedditUserState.IsDefault; NotificationService = new Common.NotificationService(); CaptchaProvider = new CaptchaService(); RedditService = new Reddit(_listingFilter, RedditUserState, OfflineService, CaptchaProvider, "3m9rQtBinOg_rA", null, "http://www.google.com"); Login = new LoginViewModel(); _listingFilter.Initialize(Settings, OfflineService, RedditService, _initializationBlob.NSFWFilter); CommandDispatcher = new CommandDispatcher(); SubredditRiver = new SubredditRiverViewModel(_initializationBlob.Subreddits); SelfStream = new SelfStreamViewModel(); ModStream = new ModStreamViewModel(); NavMenu = new NavMenu(Enumerable.Empty<LinkRiverViewModel>(), this); MessengerInstance.Register<UserLoggedInMessage>(this, OnUserLoggedIn); if (RedditUserState.Username != null) { SelfUser = new AboutUserViewModel(RedditUserState.Username); } }
public void MyTestInitialize() { m_VoicewaitUserList = new List<ISimulationUser>(); SimulationUser ue1 = new SimulationUser(); m_VoicewaitUserList.Add(ue1); m_OfflineUserList = new List<ISimulationUser>(); m_OfflineUserList.Add(ue1); m_OffLineVUService = new OfflineService(m_CurrentTTI, m_OfflineThresholdParam ); m_DataWaitUserList = new List<ISimulationUser>(); m_GBRUserList = new List<ISimulationUser>(); m_OfflineUserList = new List<ISimulationUser>(); m_DataWaitUserList.Add(ue1); m_GBRUserList.Add(ue1); m_OfflineUserList.Add(ue1); m_OffLineDUService = new OfflineService(m_CurrentTTI, m_OfflineThresholdParam); m_DataUser = new SimulationUser(); SimulationUser DU1 = new SimulationUser(); m_OfflineThresholdParam = new OfflineThresholdParam(); m_OfflineDU = new OfflineService(m_CurrentTTI, m_OfflineThresholdParam); m_CurrentTTI = 1000; }
public async void SaveForOffline() { // User must be online to perform this operation if (!await IsUserOnlineAsync()) { return; } var offlineParentNodePath = OfflineService.GetOfflineParentNodePath(this.OriginalMNode); if (!FolderService.FolderExists(offlineParentNodePath)) { FolderService.CreateFolder(offlineParentNodePath); } var existingNode = SavedForOfflineDB.SelectNodeByFingerprint(MegaSdk.getNodeFingerprint(this.OriginalMNode)); if (existingNode != null) { bool result = this.IsFolder ? await FolderService.CopyFolderAsync(existingNode.LocalPath, offlineParentNodePath) : await FileService.CopyFileAsync(existingNode.LocalPath, offlineParentNodePath); if (result) { SavedForOfflineDB.InsertNode(this.OriginalMNode); } } else { TransferService.MegaTransfers.Add(this.OfflineTransfer); this.OfflineTransfer.StartTransfer(true); } this.IsSavedForOffline = true; OfflineService.CheckOfflineNodePath(this.OriginalMNode); }
public async Task <ObservableCollection <mUserItem> > GetRandomProducts(int amount, int len) { IsBusy = true; try { //ObservableCollection<mUserItem> result = null; if (CrossConnectivity.Current.IsConnected) { result = await ItemService.Instance.FetchRandom(amount, null, null, len); if (result == null) { DialogService.ShowToast("No More Results"); return(new ObservableCollection <mUserItem>()); } OfflineService.Write <ObservableCollection <mUserItem> >(result, Strings.BuySellDash_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <mUserItem> >(Strings.BuySellDash_Offline_fileName, null); if (result == null) { IsNoConnection = true; } } if (result == null) { //No Item Found(WORK ON) return(new ObservableCollection <mUserItem>()); } if (result.Count > 19) { ShowLoadMore = true; } for (var i = 0; i < result.Count; i++) { result[i].Thumbnail = result[i].Images[0]; if (i == result.Count) { result[i].ThumbnailHeight = "1000"; continue; } result[i].ThumbnailHeight = "100"; int max_Name_Length = 28; if (result[i].Name.Length > max_Name_Length) { result[i].SummaryName = result[i].Name.Substring(0, max_Name_Length) + "..."; } else { result[i].SummaryName = result[i].Name; } } IsNoConnection = false; return(result); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); return(null); } finally { IsBusy = false; } }
public async void GetMyItems(int amount, int len, bool addon = false) { if (IsBusy) { return; } IsBusy = true; try { noItems = false; ObservableCollection <mUserItem> result = null; if (CrossConnectivity.Current.IsConnected) { result = await ItemService.Instance.FetchUsersItems(AccountService.Instance.Current_Account.Email, amount, len); if (result != null) { var newResult = await BindDelete(result); for (var i = 0; i < newResult.Count; i++) { newResult[i].Thumbnail = newResult[i].Images[0]; //newResult[i].CreatedDate = newResult[i].CreatedDate.Split('T')[0]; int max_description_length = 159; int max_Name_length = 21; if (newResult[i].Name.Length > max_Name_length) { newResult[i].SummaryName = newResult[i].Name.Substring(0, max_Name_length) + "..."; } else { newResult[i].SummaryName = newResult[i].Name; } if (newResult[i].Description.Length > max_description_length) { newResult[i].SummaryDesc = newResult[i].Description.Substring(0, max_description_length) + "..."; } else { newResult[i].SummaryDesc = newResult[i].Description; } if (newResult[i].Visable == "false") { newResult[i].Visable = "Not Visible"; } else { newResult[i].Visable = "Visible"; } } if (addon) { MyItemList.AddRange(newResult); } else { MyItemList = newResult; } return; } OfflineService.Write <ObservableCollection <mUserItem> >(result, Strings.MyItems_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <mUserItem> >(Strings.MyItems_Offline_fileName, null); } if (result != null) { var newResult = await BindDelete(result); for (var i = 0; i < newResult.Count; i++) { newResult[i].Thumbnail = newResult[i].Images[0]; newResult[i].CreatedDate = newResult[i].CreatedDate.Split('T')[0]; } if (addon) { MyItemList.AddRange(newResult); } else { MyItemList = newResult; } return; } if (addon) { isDone = true; } else { noItems = true; MyItemList = new ObservableCollection <mUserItem>(); } } catch (Exception ex) { DialogService.ShowError(Strings.SomethingWrong); Debug.WriteLine(Keys.TAG + ex); Crashes.TrackError(ex); } finally { IsListRefereshing = false; IsBusy = false; } }
public async void GetQuestionList(int len, int amount, bool addon = false, string txt = null) { if (IsBusy) { return; } IsBusy = true; IsEmpty = false; try { string link = Keys.Url_Main + "item-question/get-question/" + Itemid; if (txt != null) { link += "?Search=" + txt; } ObservableCollection <mQuestion> result = new ObservableCollection <mQuestion>(); if (CrossConnectivity.Current.IsConnected) { result = await QuestionService.Instance.FetchQuestions(link, len, amount); if (result == null) { if (addon) { isDone = true; return; } IsEmpty = true; return; } OfflineService.Write <ObservableCollection <mQuestion> >(result, Strings.ItemQuestion_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <mQuestion> >(Strings.ItemQuestion_Offline_fileName, null); } if (result == null) { if (addon) { isDone = true; return; } IsEmpty = true; return; } if (addon) { Questionlist.AddRange(result); } else { Questionlist = result; } } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); return; } finally { IsBusy = false; IsListRefereshing = false; } }
public async Task <ObservableCollection <Product> > GetRecentroducts() { if (IsBusy_Recent) { return(null); } IsBusy_Recent = true; try { ObservableCollection <Product> result = null; if (CrossConnectivity.Current.IsConnected) { result = await ProductService.Instance.FetchRecent(8, null, null, 0); if (result == null) { //No Item Found(WORK ON) return(new ObservableCollection <Product>()); } OfflineService.Write <ObservableCollection <Product> >(result, Strings.DashRecent_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <Product> >(Strings.DashRecent_Offline_fileName, null); if (result == null) { IsNoConnection = true; } } if (result == null) { //No Item Found(WORK ON) return(new ObservableCollection <Product>()); } for (var i = 0; i < result.Count; i++) { result[i].Thumbnail = result[i].Images[0]; int max_Name_length = 24; if (result[i].Name.Length > max_Name_length) { result[i].SummaryName = result[i].Name.Substring(0, max_Name_length) + "..."; } else { result[i].SummaryName = result[i].Name; } } IsNoConnection = false; return(result); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); return(null); } finally { IsBusy_Recent = false; } }
public async Task <ObservableCollection <Product> > GetInterestProductsAsync() { IsBusy = true; try { ObservableCollection <Product> result = null; if (CrossConnectivity.Current.IsConnected) { result = await ProductService.Instance.FetchUserInterets(AccountService.Instance.Current_Account.Email); if (result == null) { //ComeBack return(new ObservableCollection <Product>()); } OfflineService.Write <ObservableCollection <Product> >(result, Strings.MyInterest_Offline_fileName, null); } else { result = await OfflineService.Read <ObservableCollection <Product> >(Strings.MyInterest_Offline_fileName, null); if (result == null) { IsNoConnection = true; } } if (result == null) { //ComeBack return(new ObservableCollection <Product>()); } for (var i = 0; i < result.Count; i++) { result[i].Thumbnail = result[i].Images[0]; if (i == result.Count) { result[i].ThumbnailHeight = "1000"; continue; } result[i].ThumbnailHeight = "100"; int max_Name_Length = 39; if (result[i].Name.Length > max_Name_Length) { result[i].SummaryName = result[i].Name.Substring(0, max_Name_Length) + "..."; } else { result[i].SummaryName = result[i].Name; } } IsNoConnection = false; return(result); } catch (Exception ex) { Debug.WriteLine(Keys.TAG + ex); DialogService.ShowError(Strings.SomethingWrong); Crashes.TrackError(ex); return(null); } finally { IsBusy = false; } }