public virtual void onRequestStart(MegaSDK api, MRequest request) { this.api = api; if (!ShowProgressMessage) { return; } var autoReset = new AutoResetEvent(true); Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.SetProgressIndicator(true, ProgressMessage); autoReset.Set(); }); autoReset.WaitOne(); }
public async Task <bool> MultipleRemoveItems() { int count = ChildNodes.Count(n => n.IsMultiSelected); if (count < 1) { return(false); } if (this.CurrentDisplayMode == DriveDisplayMode.RubbishBin || (this.CurrentDisplayMode == DriveDisplayMode.MultiSelect && this.PreviousDisplayMode == DriveDisplayMode.RubbishBin)) { var customMessageDialog = new CustomMessageDialog( AppMessages.MultiSelectRemoveQuestion_Title, String.Format(AppMessages.MultiSelectRemoveQuestion, count), App.AppInformation, MessageDialogButtons.OkCancel, MessageDialogImage.RubbishBin); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveNode)); RemoveOrRubbish(count); }; return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes); } else { var customMessageDialog = new CustomMessageDialog( AppMessages.MultiMoveToRubbishBinQuestion_Title, String.Format(AppMessages.MultiMoveToRubbishBinQuestion, count), App.AppInformation, MessageDialogButtons.OkCancel, MessageDialogImage.RubbishBin); customMessageDialog.OkOrYesButtonTapped += (sender, args) => { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.NodeToTrash)); RemoveOrRubbish(count); }; return(await customMessageDialog.ShowDialogAsync() == MessageDialogResult.OkYes); } }
public MainViewModel() { SourceDirectories = new ObservableCollection <SourceDirectory>(); StarColor = new SolidColorBrush(Colors.White); ScrapedColor = new SolidColorBrush(Colors.White); ToggleFavouriteColor = new SolidColorBrush(Colors.Black); _bookDomain = new BookDomain(); BookTiles = new BookTiles(); BookDetails = new BookDetails(); PdfViewer = new PdfViewer(); FilterOnTitle = true; // var savedView = AppConfig.LoadSetting("SavedView"); //switch (savedView) //{ // case "Tiles": // BookView = BookTiles; // break; // case "Details": // BookView = BookDetails; // break; // default: // BookView = new BookTiles(); // break; //} BookView = BookTiles; ProgressService.RegisterSubscriber(this); var sortt = new List <string> { "Title [A-Z]", "Title [Z-A]", "Date Published [Newest]", "Date Published [Oldest]", "Date Added [Newest]", "Date Added [Oldest]" }; SortList = new ObservableCollection <string>(sortt); RefreshAllBooks(); RefreshPublishersAndAuthors(); SelectedSort = "Title [A-Z]"; }
public virtual void onRequestTemporaryError(MegaSDK api, MRequest request, MError e) { this.api = api; Deployment.Current.Dispatcher.BeginInvoke(() => { if (DebugService.DebugSettings.IsDebugMode || Debugger.IsAttached) { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["MegaRedColor"]); } // If is the first error/retry (timer is not running) start the timer if (apiErrorTimer != null && !apiErrorTimer.IsEnabled) { apiErrorTimer.Start(); } }); }
public Importer(SourceDirectory source) { _excludedDomain = new ExcludedDomain(); ProgressService.RegisterPublisher(this); _source = source; _source.Books = new HashSet <Book>(); _foundPdfFiles = new List <string>(); Worker = new BackgroundWorker(); Worker.DoWork += _worker_DoWork; Worker.ProgressChanged += _worker_ProgressChanged; Worker.RunWorkerCompleted += _worker_RunWorkerCompleted; Worker.WorkerReportsProgress = true; Worker.WorkerSupportsCancellation = true; ProgressArgs = new ProgressWindowEventArgs(); _booksImported = 0; _booksExisted = 0; _booksExcluded = 0; }
private static void FinishedApplyResults(object sender, RunWorkerCompletedEventArgs args) { ProgressService.StopDialog(); if (!args.Cancelled && args.Error == null) { //Need an invoke here? MessageBox.Show("Rom successfully loaded!"); ReadingFinished(false); } else { MessageBox.Show("Error, rom could not successfully load"); ReadingFinished(true); } }
private void FilterDisciplines() { AddDisciplinesList = new List <Discipline>(); AddOnDisciplinesList = new List <Discipline>(); var curriculumService = new CurriculumService(_unit, _unit); var progressService = new ProgressService(_unit, _unit); var group = (Group)cmBox_Group.SelectedItem; var currculum = curriculumService.GetCurriculumBySpecialityAndTermNumber(group.Speciality, Convert.ToInt32(cmBox_Term.SelectedItem)); Curriculum = currculum; var journalCurriculum = currculum.JournalCurricula; var progress = progressService.GetProgressByGroupAndStudentAndTermNumber(group, Student, Convert.ToInt32(cmBox_Term.SelectedItem)); Progress = progress; var journalProgress = progress.JournalProgresses; journalCurriculum.ToList().ForEach(FilterForDiscipline); }
public static void ApplyResults(object sender, DoWorkEventArgs args) { MarioKart64ReaderResults results = (MarioKart64ReaderResults)args.Argument; //To-do: add an error report for any sort of exceptions during saving? ProgressService.SetMessage("Splicing data elements into Rom object"); foreach (N64DataElement element in results.NewElements) { RomProject.Instance.Files[0].AddElement(element); } if (results.KartResults != null) { ProgressService.SetMessage("Splicing kart data into Rom object"); KartReader.ApplyResults(results.KartResults); } // if (results.TrackResults != null) // { // ProgressService.SetMessage("Splicing track data into Rom object"); //TrackReader.ApplyResults(results.TrackResults); // } if (results.TextBank != null) { ProgressService.SetMessage("Splicing text data into Rom object"); MarioKart64ElementHub.Instance.TextBank = results.TextBank; } if (results.TextureResults != null) { ProgressService.SetMessage("Splicing texture data into Rom object"); TextureReader.ApplyResults(results.TextureResults); } //Does this really belong here? if (!RomProject.Instance.Items.Contains(MarioKart64ElementHub.Instance)) { RomProject.Instance.AddRomItem(MarioKart64ElementHub.Instance); } ProgressService.SetMessage("Finished!"); }
public override void onRequestFinish(MegaSDK api, MRequest request, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); }); // If folder link is well structured if (e.getErrorCode() == MErrorType.API_OK) { OnSuccesAction(api, request); } else { // Set the empty state and disable the app bar buttons Deployment.Current.Dispatcher.BeginInvoke(() => { _folderLinkViewModel.FolderLink.SetEmptyContentTemplate(false); _folderLinkViewModel._folderLinkPage.SetApplicationBarData(false); }); switch (e.getErrorCode()) { case MErrorType.API_EARGS: if (_decryptionAlert) { ShowDecryptionKeyNotValidAlert(api, request); //If the user have written the key } else { ShowFolderLinkNoValidAlert(); //Handle length or Key length no valid } break; case MErrorType.API_EINCOMPLETE: //Link has not decryption key ShowDecryptionAlert(api, request); break; } } }
private async void SetProfileDetail() { await ProgressService.ShowAsync(); //initialize the user from cache var name = StorageService.GetTempUserName(); var option = Const.GetDictionary(); option.Add(Const.USER_SCREEN_NAME, name); option.Add(Const.INCLUDE_ENTITIES, Const.DEFAULT_VALUE_FALSE); var user = await userController.ShowAsync(option); user.IsProfileDetail = true; foreach (var item in Items) { (item as IHaveAUser).User = user; } await ProgressService.HideAsync(); }
public async Task SaveForOffline(bool newStatus) { if (newStatus) { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.SaveForOffline)); _node.IsSelectedForOffline = true; await _node.SaveForOffline(); } else { Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, ProgressMessages.RemoveFromOffline)); _node.IsSelectedForOffline = false; await _node.RemoveForOffline(); } Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(false)); }
// Method which is called when the timer event is triggered private void ApiErrorTimerOnTick(object sender, object e) { Deployment.Current.Dispatcher.BeginInvoke(() => { if (apiErrorTimer != null) { apiErrorTimer.Stop(); } }); if (this.api == null) { return; } string message = string.Empty; switch ((MRetryReason)this.api.isWaiting()) { case MRetryReason.RETRY_CONNECTIVITY: message = ProgressMessages.PM_ConnectivityIssue; break; case MRetryReason.RETRY_SERVERS_BUSY: message = ProgressMessages.PM_ServersBusy; break; case MRetryReason.RETRY_API_LOCK: message = ProgressMessages.PM_ApiLocked; break; case MRetryReason.RETRY_RATE_LIMIT: message = ProgressMessages.PM_ApiRateLimit; break; default: return; } Deployment.Current.Dispatcher.BeginInvoke(() => ProgressService.SetProgressIndicator(true, message)); }
public override void onRequestUpdate(MegaSDK api, MRequest request) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(true, String.Format(ProgressMessages.FetchingNodes, request.getTransferredBytes().ToStringAndSuffix(2))); }); if (AppMemoryController.IsThresholdExceeded(75UL.FromMBToBytes())) { Deployment.Current.Dispatcher.BeginInvoke(() => { new CustomMessageDialog( AppMessages.MemoryLimitError_Title, AppMessages.MemoryLimitError, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); Application.Current.Terminate(); }); } }
public override void onRequestFinish(MegaSDK api, MRequest request, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); if (apiErrorTimer != null) { apiErrorTimer.Stop(); } }); if (e.getErrorCode() != MErrorType.API_OK) { switch (e.getErrorCode()) { case MErrorType.API_ENOENT: // E-mail unassociated with a MEGA account or Wrong password Deployment.Current.Dispatcher.BeginInvoke(() => new CustomMessageDialog(ErrorMessageTitle, AppMessages.WrongEmailPasswordLogin, App.AppInformation, MessageDialogButtons.Ok).ShowDialog()); return; case MErrorType.API_ETOOMANY: // Too many failed login attempts Deployment.Current.Dispatcher.BeginInvoke(() => new CustomMessageDialog(ErrorMessageTitle, AppMessages.AM_TooManyFailedLoginAttempts, App.AppInformation, MessageDialogButtons.Ok).ShowDialog()); return; case MErrorType.API_EINCOMPLETE: // Account not confirmed Deployment.Current.Dispatcher.BeginInvoke(() => new CustomMessageDialog(ErrorMessageTitle, AppMessages.AM_AccountNotConfirmed, App.AppInformation, MessageDialogButtons.Ok).ShowDialog()); return; } } base.onRequestFinish(api, request, e); }
public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e) { this.api = api; this.ErrorString = e.getErrorString(); Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); if (apiErrorTimer != null) { apiErrorTimer.Stop(); } }); switch (e.getErrorCode()) { case MErrorType.API_EGOINGOVERQUOTA: // Not enough quota case MErrorType.API_EOVERQUOTA: // Storage overquota error Deployment.Current.Dispatcher.BeginInvoke(DialogService.ShowOverquotaAlert); // Stop all upload transfers LogService.Log(MLogLevel.LOG_LEVEL_INFO, string.Format("Storage quota exceeded ({0}) - Canceling uploads", e.getErrorCode().ToString())); api.cancelTransfers((int)MTransferType.TYPE_UPLOAD); // Disable the "Camera Uploads" service if is enabled if (MediaService.GetAutoCameraUploadStatus()) { LogService.Log(MLogLevel.LOG_LEVEL_INFO, string.Format("Storage quota exceeded ({0}) - Disabling CAMERA UPLOADS service", e.getErrorCode().ToString())); MediaService.SetAutoCameraUpload(false); SettingsService.SaveSetting(SettingsResources.CameraUploadsIsEnabled, false); } break; } }
public override void onRequestFinish(MegaSDK api, MRequest request, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); }); if (e.getErrorCode() == MErrorType.API_OK) { if (request.getType() == MRequestType.TYPE_GET_ATTR_USER) { switch (request.getParamType()) { case (int)MUserAttrType.USER_ATTR_FIRSTNAME: Deployment.Current.Dispatcher.BeginInvoke(() => AccountService.AccountDetails.Firstname = request.getText()); break; case (int)MUserAttrType.USER_ATTR_LASTNAME: Deployment.Current.Dispatcher.BeginInvoke(() => AccountService.AccountDetails.Lastname = request.getText()); break; } } } else { if (request.getType() == MRequestType.TYPE_GET_ATTR_USER) { if (request.getParamType() == (int)MUserAttrType.USER_ATTR_FIRSTNAME) { Deployment.Current.Dispatcher.BeginInvoke(() => AccountService.AccountDetails.Firstname = UiResources.MyAccount); } } } }
private async void SetFileCache(IEnumerable <FileDiscoveryCache> cache) { // Because the cache can either from from the Database or a recent Cache Discovery, we sort the cache here before moving on to display //cache = cache.OrderBy(x => x.FilePath).ToList(); // Once the Cache is sorted, begin the proccessing to update the UI await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Debug.WriteLine($"{nameof(ThemeDetailsViewModel)} - {nameof(RefreshFileCache)} - COMPLETE"); ProgressService.Hide(); // Get the Grouped Cache var groupedCache = GroupedFileCache.FromCacheList(cache); // Clear the previous Cache and add in the new ones FileCache.Clear(); foreach (var c in groupedCache) { FileCache.Add(c); } }); }
/// <summary> /// Called when [new context report]. /// </summary> /// <param name="reportView">The report view.</param> private async void OnNewContextReport(Report reportView) { var errorOccurred = false; var progressService = new ProgressService(); progressService.SetProgress("Creating report", 0, false, true); //await Task.Delay(500); var report = new Report(reportView.SourceTemplate); report.Name = "New report based on " + report.Name; report.IsDefaultReport = false; var operationComplete = await progressService.Execute(() => { AddNewItemCommand.Execute(report); }, opResult => { progressService.SetProgress("Completed", 100, true, false); if (opResult.Status && opResult.Exception != null) { errorOccurred = true; LogEntityError(opResult.Exception.GetBaseException(), typeof(Report), Title); } else { errorOccurred = false; } }, new CancellationToken()); if (operationComplete && !errorOccurred) { OnLoad(); OnNavigateToDetails(report); } }
public override void onRequestFinish(MegaSDK api, MRequest request, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); }); if (e.getErrorCode() == MErrorType.API_OK) { Deployment.Current.Dispatcher.BeginInvoke(() => { _userData.HasAvatarImage = true; var img = new BitmapImage(); img.CreateOptions = BitmapCreateOptions.IgnoreImageCache; img.UriSource = new Uri(request.getFile()); _userData.AvatarUri = img.UriSource; }); } else { Deployment.Current.Dispatcher.BeginInvoke(() => { _userData.HasAvatarImage = false; _userData.AvatarUri = null; }); } Deployment.Current.Dispatcher.BeginInvoke(() => { if (App.UserData != null) { App.UserData.AvatarUri = _userData.AvatarUri; } }); }
private void FinishedExportRom(object sender, RunWorkerCompletedEventArgs args) { if (!args.Cancelled && args.Error == null) { ProgressService.StopDialog(); if (InvokeRequired) { this.Invoke((Action)(() => { MessageBox.Show("Rom successfully exported!"); this.Enabled = true; UpdateSelectedModule(); })); } else { MessageBox.Show("Rom successfully exported!"); this.Enabled = true; UpdateSelectedModule(); } } else { ProgressService.StopDialog(); MessageBox.Show("Error, could not export rom"); if (InvokeRequired) { this.Invoke((Action)(() => { this.Enabled = true; })); } else { this.Enabled = true; } } }
public static void ReadRom(BackgroundWorker worker, byte[] rawData, MarioKart64ReaderResults finalResults) { TextureReaderResults results = new TextureReaderResults(); //Here, load in the texture stuff ProgressService.SetMessage("Loading Textures and Palettes"); foreach (MarioKartRomInfo.MK64ImageInfo imageInfo in MarioKartRomInfo.ImageLocations) { MK64Image image = new MK64Image(imageInfo, rawData); if (image.IsValidImage) { results.AddImage(image); } else { throw new Exception(); } } ProgressService.SetMessage("Loading Kart Images"); foreach (MarioKartRomInfo.MK64ImageInfo imageInfo in KartImageInfo.ImageLocations) { MK64Image image = new MK64Image(imageInfo, rawData); if (image.IsValidImage) { results.AddKartImage(image); } else { throw new Exception(); } } finalResults.TextureResults = results; }
private void FinishedReadProject(object sender, RunWorkerCompletedEventArgs args) { if (!args.Cancelled && args.Error == null) { //If successful, mark flags and put the filename in the status bar if (InvokeRequired) { this.Invoke((Action)(() => { statusBarFile.Text = Path.GetFileNameWithoutExtension(openProjectDialog.FileName); _loadedFilePath = openProjectDialog.FileName; })); } else { statusBarFile.Text = Path.GetFileNameWithoutExtension(openProjectDialog.FileName); _loadedFilePath = openProjectDialog.FileName; } //Load it into the Rom Project ApplyProjectAsync(); } else { ProgressService.StopDialog(); MessageBox.Show("Error, could not open project"); if (InvokeRequired) { this.Invoke((Action)(() => { this.Enabled = true; })); } else { this.Enabled = true; } } }
public Importer(IBookRepository bookRepository, ISourceRepository sourceRepository) { _sourcerepo = sourceRepository; _bookService = new BookService(bookRepository); _sourceService = new SourceService(sourceRepository); ProgressService.RegisterPublisher(this); Worker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; Worker.DoWork += Worker_DoWork; Worker.RunWorkerCompleted += Worker_RunWorkerCompleted; Worker.ProgressChanged += Worker_ProgressChanged; WorkerCleanup = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; WorkerCleanup.DoWork += WorkerCleanup_DoWork; WorkerCleanup.RunWorkerCompleted += WorkerCleanup_RunWorkerCompleted; WorkerCleanup.ProgressChanged += WorkerCleanup_ProgressChanged; }
private void onRequestFinishFolderLink(MegaSDK api, MRequest request, MError e) { Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); if (apiErrorTimer != null) { apiErrorTimer.Stop(); } }); if (e.getErrorCode() == MErrorType.API_OK) { //If getFlag() returns true, the folder link key is invalid. if (request.getFlag()) { // First logout from the folder api.logout(); // Set the empty state and disable the app bar buttons Deployment.Current.Dispatcher.BeginInvoke(() => { _folderLinkViewModel.FolderLink.SetEmptyContentTemplate(false); _folderLinkViewModel._folderLinkPage.SetApplicationBarData(false); }); //If the user have written the key if (_decryptionAlert) { ShowDecryptionKeyNotValidAlert(api, request); } else { ShowFolderLinkNoValidAlert(); } } else { OnSuccesAction(api, request); } } else { Deployment.Current.Dispatcher.BeginInvoke(() => { _folderLinkViewModel.FolderLink.SetEmptyContentTemplate(false); _folderLinkViewModel._folderLinkPage.SetApplicationBarData(false); }); switch (e.getErrorCode()) { case MErrorType.API_ETOOMANY: // Taken down link and the link owner's account is blocked ShowAssociatedUserAccountTerminatedFolderLinkAlert(); break; case MErrorType.API_ENOENT: // Link not exists or has been deleted by user case MErrorType.API_EBLOCKED: // Taken down link ShowUnavailableFolderLinkAlert(); break; default: ShowFolderLinkNoValidAlert(); break; } } }
private async void OnAcceptClick(object sender, System.EventArgs e) { if (LstMediaItems.CheckedItems == null || LstMediaItems.CheckedItems.Count < 1) { new CustomMessageDialog( AppMessages.MinimalPictureSelection_Title, AppMessages.MinimalPictureSelection, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); return; } ProgressService.SetProgressIndicator(true, ProgressMessages.PrepareUploads); SetControlState(false); // Set upload directory only once for speed improvement and if not exists, create dir var uploadDir = AppService.GetUploadDirectoryPath(true); foreach (var checkedItem in LstMediaItems.CheckedItems) { var item = (BaseMediaViewModel <Picture>)checkedItem; if (item == null) { continue; } try { string fileName = Path.GetFileName(item.Name); if (fileName != null) { string newFilePath = Path.Combine(uploadDir, fileName); using (var fs = new FileStream(newFilePath, FileMode.Create)) { await item.BaseObject.GetImage().CopyToAsync(fs); await fs.FlushAsync(); fs.Close(); } var uploadTransfer = new TransferObjectModel(App.MegaSdk, App.CloudDrive.CurrentRootNode, TransferType.Upload, newFilePath); App.MegaTransfers.Add(uploadTransfer); uploadTransfer.StartTransfer(); } } catch (Exception) { new CustomMessageDialog( AppMessages.PrepareImageForUploadFailed_Title, String.Format(AppMessages.PrepareImageForUploadFailed, item.Name), App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); } } ProgressService.SetProgressIndicator(false); SetControlState(true); App.CloudDrive.NoFolderUpAction = true; NavigateService.NavigateTo(typeof(TransferPage), NavigationParameter.PictureSelected); }
public override async void OnSave(bool enableNotificantions = false) { if (string.IsNullOrEmpty(Model.Name) || string.IsNullOrEmpty(Model.GroupPracticePacId)) { MessageBox.Show("Orginization Name and Group Id fields are required", "Invalid Input"); return; } int num; if (int.TryParse(NumberOfMembers, out num)) { Model.NumberofGroupPracticeMembers = num; } else if (!string.IsNullOrEmpty(NumberOfMembers)) { MessageBox.Show("Please enter a valid number for Group Practice Members", "Invalid Input"); return; } Validate(); Model.Validate(); Model.Addresses.ForEach(a => a.Validate()); if (HasErrors || Model.HasErrors || Model.Addresses.Any(a => a.HasErrors)) { return; } try { using (var session = DataServiceProvider.SessionFactory.OpenStatelessSession()) { if (session.Query <MedicalPractice>().FirstOrDefault(x => x.Id != Model.Id && x.GroupPracticePacId == Model.GroupPracticePacId) != null) { MessageBox.Show("There is already a medical practice with the same Group Practice Pac Id. Group Practice Pac Id must be unique.", "Notification"); return; } } Model.IsEdited = true; var errorOccurred = false; Exception errorException = null; var progressService = new ProgressService(); progressService.SetProgress("Saving " + Inflector.Titleize2(typeof(MedicalPractice).Name), 0, false, true); // await Task.Delay(500); var operationComplete = await progressService.Execute(() => OnSave(Model), result => { if (!result.Status && result.Exception != null) { errorOccurred = true; errorException = result.Exception; } else { errorOccurred = false; errorException = null; } }, new CancellationToken()); if (operationComplete) { progressService.SetProgress("Completed", 100, true, false); if (!errorOccurred || errorException == null) { EventAggregator.GetEvent <GenericNotificationEvent>() .Publish(string.Format("MedicalPractice {0} has been saved successfully.", Model.Name)); EventAggregator.GetEvent <RequestLoadMappingTabEvent>().Publish(typeof(MedicalPracticeEditViewModel)); NavigateBack(); } else { Logger.Write(errorException, "Error saving Medical Practice \"{0}\"", Model.Name); } } } catch (Exception exc) { Logger.Write(exc, "Error saving Medical Practice \"{0}\"", Model.Name); } }
public ArticlesIncrementalSource(IShopApiService shopApiService, ProgressService progressService, ArticlesSearchRequest searchRequest) { _shopApiService = shopApiService; _searchRequest = searchRequest; _progressService = progressService; }
public MainPageViewModel() { ShelfHeight = 0; Letters = new ObservableCollection <Letter>(); var zero = new Letter { Name = "0", LWidth = LetterWidth }; var a = new Letter { Name = "A", LWidth = LetterWidth }; var b = new Letter { Name = "B", LWidth = LetterWidth }; var c = new Letter { Name = "C", LWidth = LetterWidth }; var d = new Letter { Name = "D", LWidth = LetterWidth }; var e = new Letter { Name = "E", LWidth = LetterWidth }; var f = new Letter { Name = "F", LWidth = LetterWidth }; var g = new Letter { Name = "G", LWidth = LetterWidth }; var h = new Letter { Name = "H", LWidth = LetterWidth }; var i = new Letter { Name = "I", LWidth = LetterWidth }; var j = new Letter { Name = "J", LWidth = LetterWidth }; var k = new Letter { Name = "K", LWidth = LetterWidth }; var l = new Letter { Name = "L", LWidth = LetterWidth }; var m = new Letter { Name = "M", LWidth = LetterWidth }; var n = new Letter { Name = "N", LWidth = LetterWidth }; var o = new Letter { Name = "O", LWidth = LetterWidth }; var p = new Letter { Name = "P", LWidth = LetterWidth }; var q = new Letter { Name = "Q", LWidth = LetterWidth }; var r = new Letter { Name = "R", LWidth = LetterWidth }; var s = new Letter { Name = "S", LWidth = LetterWidth }; var t = new Letter { Name = "T", LWidth = LetterWidth }; var u = new Letter { Name = "U", LWidth = LetterWidth }; var v = new Letter { Name = "V", LWidth = LetterWidth }; var w = new Letter { Name = "W", LWidth = LetterWidth }; var x = new Letter { Name = "X", LWidth = LetterWidth }; var y = new Letter { Name = "Y", LWidth = LetterWidth }; var z = new Letter { Name = "Z", LWidth = LetterWidth }; Letters.Add(zero); Letters.Add(a); Letters.Add(b); Letters.Add(c); Letters.Add(d); Letters.Add(e); Letters.Add(f); Letters.Add(g); Letters.Add(h); Letters.Add(i); Letters.Add(j); Letters.Add(k); Letters.Add(l); Letters.Add(m); Letters.Add(n); Letters.Add(o); Letters.Add(p); Letters.Add(q); Letters.Add(r); Letters.Add(s); Letters.Add(t); Letters.Add(u); Letters.Add(v); Letters.Add(w); Letters.Add(x); Letters.Add(y); Letters.Add(z); ProgressService.RegisterSubscriber(this); AllBooks = new List <Book>(); AllBooks = ShellViewModel.Books; FilteredBooks = new ObservableCollection <Book>(AllBooks); GetTags(); UpdateShelfBooks(); FilterCount = "Found " + FilteredBooks.Count + " results"; Ratings = new List <int>(); Ratings.Add(0); Ratings.Add(1); Ratings.Add(2); Ratings.Add(3); Ratings.Add(4); Ratings.Add(5); BooksScroll = ScrollMode.Enabled; }
public virtual void onRequestFinish(MegaSDK api, MRequest request, MError e) { this.api = api; Deployment.Current.Dispatcher.BeginInvoke(() => { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); ProgressService.SetProgressIndicator(false); }); switch (e.getErrorCode()) { case MErrorType.API_OK: if (ShowSuccesMessage) { Deployment.Current.Dispatcher.BeginInvoke(() => { new CustomMessageDialog( SuccessMessageTitle, SuccessMessage, App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); }); } if (ActionOnSucces) { OnSuccesAction(api, request); } if (NavigateOnSucces) { Deployment.Current.Dispatcher.BeginInvoke(() => NavigateService.NavigateTo(NavigateToPage, NavigationParameter)); } break; case MErrorType.API_EGOINGOVERQUOTA: // Not enough storage quota LogService.Log(MLogLevel.LOG_LEVEL_INFO, string.Format("Not enough storage quota ({0})", e.getErrorCode().ToString())); UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(true)); break; case MErrorType.API_EOVERQUOTA: //Storage overquota error LogService.Log(MLogLevel.LOG_LEVEL_INFO, string.Format("Storage quota exceeded ({0})", e.getErrorCode().ToString())); UiService.OnUiThread(() => DialogService.ShowStorageOverquotaAlert(false)); break; default: if (e.getErrorCode() != MErrorType.API_EINCOMPLETE) { if (ShowErrorMessage) { Deployment.Current.Dispatcher.BeginInvoke(() => { new CustomMessageDialog( ErrorMessageTitle, String.Format(ErrorMessage, e.getErrorString()), App.AppInformation, MessageDialogButtons.Ok).ShowDialog(); }); } } break; } }
public void onTransferUpdate(MegaSDK api, MTransfer transfer) { // Extra checking to avoid NullReferenceException if (transfer == null) { return; } // Search the corresponding transfer in the transfers list var megaTransfer = TransfersService.SearchTransfer(TransfersService.MegaTransfers.SelectAll(), transfer); if (megaTransfer == null) { return; } var isBusy = api.areTransfersPaused((int)transfer.getType()) ? false : true; var transferState = api.areTransfersPaused((int)transfer.getType()) ? MTransferState.STATE_QUEUED : transfer.getState(); var totalBytes = transfer.getTotalBytes(); var transferedBytes = transfer.getTransferredBytes(); var transferSpeed = transfer.getSpeed().ToStringAndSuffixPerSecond(); var transferMeanSpeed = transfer.getMeanSpeed(); var transferPriority = transfer.getPriority(); Deployment.Current.Dispatcher.BeginInvoke(() => { if (ProgressService.GetProgressBarBackgroundColor() != (Color)Application.Current.Resources["PhoneChromeColor"]) { ProgressService.ChangeProgressBarBackgroundColor((Color)Application.Current.Resources["PhoneChromeColor"]); } // Only update the values if they have changed to improve the UI performance if (megaTransfer.Transfer != transfer) { megaTransfer.Transfer = transfer; } if (megaTransfer.IsBusy != isBusy) { megaTransfer.IsBusy = isBusy; } if (megaTransfer.TransferState != transferState) { megaTransfer.TransferState = transferState; } if (megaTransfer.TotalBytes != totalBytes) { megaTransfer.TotalBytes = totalBytes; } if (megaTransfer.TransferedBytes != transferedBytes) { megaTransfer.TransferedBytes = transferedBytes; } if (megaTransfer.TransferSpeed != transferSpeed) { megaTransfer.TransferSpeed = transferSpeed; } if (megaTransfer.TransferMeanSpeed != transferMeanSpeed) { megaTransfer.TransferMeanSpeed = transferMeanSpeed; } if (megaTransfer.TransferPriority != transferPriority) { megaTransfer.TransferPriority = transferPriority; } }); }