async void StartDownloadWithoutLimitation(Publication publication, bool isUpdate) { ProgressStatusLabel.StringValue = "Uploading..."; tokenSource = new CancellationTokenSource(); DownloadResult downloadResult = await PublicationUtil.Instance.DownloadPublicationByBookId(publication.BookId, tokenSource.Token, UpdateDownloadProgress); string status = String.Empty; switch (downloadResult.DownloadStatus) { case DownLoadEnum.Canceled: status = "Update failed"; SetProgressViewStatus(status); break; case DownLoadEnum.Failure: status = "Update failed"; SetProgressViewStatus(status); break; case DownLoadEnum.NetDisconnected: status = "Missing connection"; SetProgressViewStatus(status); break; case DownLoadEnum.Success: BookInfo = downloadResult.Publication; PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo); //update Publication data PublicationsDataManager.SharedInstance.CurrentPubliction = BookInfo; //Console.WriteLine ("DownLoadEnum.Success CurrentPubliction:update{0}", BookInfo.UpdateCount); SetProgressViewStatus(status); RefreshInfoView(); break; } AlertSheet.DestroyConfirmAlert(); }
public void RefreshDownloadStatus(DownloadResult downloadResult, bool isUpdate) { string status = String.Empty; switch (downloadResult.DownloadStatus) { case DownLoadEnum.Canceled: status = "Update failed"; SetProgressViewStatus(status); break; case DownLoadEnum.Failure: status = "Update failed"; SetProgressViewStatus(status); break; case DownLoadEnum.NetDisconnected: status = "Missing connection"; SetProgressViewStatus(status); break; case DownLoadEnum.Success: BookInfo = downloadResult.Publication; PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo); //update Publication data PublicationsDataManager.SharedInstance.CurrentPublication = BookInfo; SetProgressViewStatus(status); UpdateStatus = 2; RefreshInfoView(); NSNotificationCenter.DefaultCenter.PostNotificationName(LNRConstants.LNPublicationDidFinishedDownload, NSObject.FromObject(BookInfo.BookId)); break; } AlertSheet.DestroyConfirmAlert(); }
private void RefreshDownloadStatus(DownloadResult downloadResult, bool isUpdate) { string status = String.Empty; switch (downloadResult.DownloadStatus) { case DownLoadEnum.Canceled: if (isUpdate) { status = "Update failed"; } else { status = "Download failed"; } ShowProgressView(false); AlertSheet.DestroyConfirmAlert(); break; case DownLoadEnum.Failure: if (isUpdate) { status = "Update failed"; } else { status = "Download failed"; } ShowProgressView(false); AlertSheet.DestroyConfirmAlert(); break; case DownLoadEnum.NetDisconnected: status = "Missing connection"; ShowProgressView(false); if (!Utility.IsKeyWindowLogin()) { AlertSheet.ShowMissingConnectAlert(); } break; case DownLoadEnum.Success: BookInfo = downloadResult.Publication; PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo); PublicationsDataManager.SharedInstance.CurrentPublication = BookInfo; UpdateTitleStatus(); AlertSheet.DestroyConfirmAlert(); break; } if (status.Length > 0) { NSAttributedString attributeTitle = Utility.AttributedTitle(status, Utility.ColorWithHexColorValue("#000000", 1.0f), "System", 12.0f, NSTextAlignment.Left); titleStatusLabel.AttributedStringValue = attributeTitle; } if (downloadResult.DownloadStatus == DownLoadEnum.Failure) { if (!Utility.IsKeyWindowLogin()) { AlertSheet.RunPromptAlert("Installation Error", "Installation of the book has been interrupted. Please re-install the book."); } } }
private void RefreshDownloadStatus(DownloadResult downloadResult, bool isUpdate) { UpdateStatus = 0; string status = String.Empty; switch (downloadResult.DownloadStatus) { case DownLoadEnum.Canceled: if (isUpdate) { status = "Update failed"; } else { status = "Download failed"; } downloadPreUpdate = isUpdate; ShowSashView(false); AlertSheet.DestroyConfirmAlert(); break; case DownLoadEnum.Failure: if (isUpdate) { status = "Update failed"; } else { status = "Download failed"; } downloadPreUpdate = isUpdate; ShowSashView(false); AlertSheet.DestroyConfirmAlert(); break; case DownLoadEnum.NetDisconnected: status = "Missing connection"; downloadPreUpdate = isUpdate; ShowSashView(false); if (!Utility.IsKeyWindowLogin()) { AlertSheet.ShowMissingConnectAlert(); } break; case DownLoadEnum.Success: BookInfo = downloadResult.Publication; PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo); PublicationsDataManager.SharedInstance.CurrentPublication = BookInfo; UpdateTitleStatus(); var winController = (PublicationsWindowController)Window.WindowController; winController.PublicationsVC.RefreshHistoryView(); AlertSheet.DestroyConfirmAlert(); NSNotificationCenter.DefaultCenter.PostNotificationName(LNRConstants.LNPublicationDidFinishedDownload, NSObject.FromObject(BookInfo.BookId)); break; } if (status.Length > 0) { NSAttributedString attributeTitle = Utility.AttributedTitle(status, Utility.ColorWithHexColorValue("#000000", 1.0f), "System", 12.0f, NSTextAlignment.Left); titleStatusLabel.AttributedStringValue = attributeTitle; } if (downloadResult.DownloadStatus == DownLoadEnum.Failure) { if (!Utility.IsKeyWindowLogin()) { AlertSheet.RunPromptAlert("Installation Error", "Installation of the book has been interrupted. Please re-install the book."); } } }