private async void bMultiUpload_Click(object sender, EventArgs e) { OpenFileDialog thisDialog = new OpenFileDialog(); thisDialog.Filter = "Chummer files (*.chum5)|*.chum5|All files (*.*)|*.*"; thisDialog.FilterIndex = 1; thisDialog.RestoreDirectory = true; thisDialog.Multiselect = true; thisDialog.Title = "Please Select Chummer File(s) for Batch-Upload"; if (thisDialog.ShowDialog() != DialogResult.OK) { return; } foreach (var file in thisDialog.FileNames) { try { Log.Trace("Loading: " + file); var c = new Character { FileName = file }; using (frmLoading frmLoadingForm = new frmLoading { CharacterFile = file }) { frmLoadingForm.Reset(36); frmLoadingForm.TopMost = true; frmLoadingForm.Show(); if (!(await c.Load(frmLoadingForm, false))) { continue; } Log.Trace("Character loaded: " + c.Name); } frmCharacterRoster.CharacterCache myCharacterCache = new frmCharacterRoster.CharacterCache(file); CharacterExtended ce = new CharacterExtended(c, null, null, myCharacterCache); await ce.Upload(null); } catch (Exception ex) { string msg = "Exception while loading " + file + ":"; msg += Environment.NewLine + ex.ToString(); Log.Warn(msg); /* run your code here */ Program.MainForm.ShowMessageBox(msg); } } Program.MainForm.ShowMessageBox("Upload of " + thisDialog.FileNames.Length + " files finished (successful or not - its over)."); }
public async static void MyOnSaveUpload(object sender, Character input) { try { input.OnSaveCompleted -= MyOnSaveUpload; CharacterExtended ce = new CharacterExtended(input, null); await ce.Upload(); var found = (from a in MainForm.OpenCharacterForms where a.CharacterObject == input select a) .FirstOrDefault(); if (found == null) { return; } TabPage tabPage = null; if ((found is frmCreate frm) && (frm.TabCharacterTabs.TabPages.ContainsKey("SINners"))) { var index = frm.TabCharacterTabs.TabPages.IndexOfKey("SINners"); tabPage = frm.TabCharacterTabs.TabPages[index]; } if ((found is frmCareer frm2) && (frm2.TabCharacterTabs.TabPages.ContainsKey("SINners"))) { var index = frm2.TabCharacterTabs.TabPages.IndexOfKey("SINners"); tabPage = frm2.TabCharacterTabs.TabPages[index]; } if (tabPage == null) { return; } var ucseq = tabPage.Controls.Find("SINnersBasic", true); foreach (var uc in ucseq) { var sb = uc as SINnersBasic; if (sb != null) { await sb?.CheckSINnerStatus(); } } var ucseq2 = tabPage.Controls.Find("SINnersAdvanced", true); } catch (Exception e) { System.Diagnostics.Trace.TraceError(e.ToString()); } finally { IsSaving = false; } }