/// <summary> /// DL開始 /// </summary> public ILoadProcess Start(IJobEngine engine, IAccessLocation srcLocation, ICriFileData data) { // アクセス先 // 現在進行系 if (engine.HasRequest(data.Identifier)) { // 完了するまで待つ return(WaitLoadProcess.Wait(m_dlRequestDict, (dict) => dict[data.Identifier])); } // 保存先 var dstLocation = m_storage.ToLocation(data.Path); // 同時リクエスト対応 m_dlRequestDict[data.Identifier] = false; var job = DoRequest(engine, srcLocation, dstLocation, data); return(new LoadProcess <FileInfo>( job, file => { if (GetSuccessDL?.Invoke(data, file) ?? false) { // 上書き OnInstalled?.Invoke(data); // リクエスト完了とする m_dlRequestDict[data.Identifier] = true; } }, onError: code => DoError(code))); }
private void Client_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (e.Error != null || e.Cancelled) { InvokeOnMainThread(() => { UIAlertView _error = new UIAlertView("An error occurred", "An error occurred during your download. Please try again," + " and make sure the connection to your PC is stable!", null, "Ok", null); _error.Show(); ResetDownloader(); }); } else { InvokeOnMainThread(() => { StatusText.Text = "Extracting TSO Files..."; }); (new Thread(() => { //try zip extract string zipPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "The Sims Online.zip"); Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "The Sims Online/")); string extractPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "The Sims Online/"); try { ZipFile.ExtractToDirectory(zipPath, extractPath); } catch (Exception ex) { InvokeOnMainThread(() => { UIAlertView _error = new UIAlertView("An error occurred", "Fatal error occurred during zip extraction. " + ex.ToString(), null, "Ok", null); _error.Show(); ResetDownloader(); return; }); } InvokeOnMainThread(() => { OnInstalled?.Invoke(); }); })).Start(); } }