public async Task <CharacterExtended> SetCharacterFrom(CharacterShared mySINner) { InitializeComponent(); _mySINner = mySINner; //if (PluginHandler.MyCharExtendedDic.ContainsKey(mySINner.CharacterObject.FileName)) //{ // CharacterExtended outce; // if (!PluginHandler.MyCharExtendedDic.TryGetValue(mySINner.CharacterObject.FileName, out outce)) // { // throw new ArgumentException("Could not get character from MyCharExtendedDic", nameof(mySINner)); // } // MyCE = outce; //} //else //{ MyCE = new CharacterExtended(mySINner.CharacterObject, null, PluginHandler.MySINnerLoading); MyCE.ZipFilePath = await MyCE.PrepareModel(); //} MyCE.MySINnerFile.SiNnerMetaData.Tags = MyCE.PopulateTags(); TabSINnersBasic = new ucSINnersBasic(this) { Visible = true }; TabSINnersAdvanced = new ucSINnersAdvanced(this) { Visible = true }; this.tabPageBasic.Controls.Add(TabSINnersBasic); this.tabPageAdvanced.Controls.Add(TabSINnersAdvanced); this.AutoSize = true; return(MyCE); }
public async Task <CharacterExtended> SetCharacterFrom(CharacterShared mySINner) { InitializeComponent(); _mySINner = mySINner; MyCE = new CharacterExtended(mySINner.CharacterObject, null, PluginHandler.MySINnerLoading); MyCE.ZipFilePath = await MyCE.PrepareModel(); MyCE.MySINnerFile.SiNnerMetaData.Tags = MyCE.PopulateTags(); TabSINnersBasic = new ucSINnersBasic(this) { Visible = true }; TabSINnersAdvanced = new ucSINnersAdvanced(this) { Visible = true }; this.tabPageBasic.Controls.Add(TabSINnersBasic); this.tabPageAdvanced.Controls.Add(TabSINnersAdvanced); this.AutoSize = true; if ((ucSINnersOptions.UploadOnSave == true)) { try { mySINner.CharacterObject.OnSaveCompleted = null; mySINner.CharacterObject.OnSaveCompleted += PluginHandler.MyOnSaveUpload; } catch (Exception e) { System.Diagnostics.Trace.TraceInformation(e.ToString()); } } return(MyCE); }
public async Task <CharacterExtended> SetCharacterFrom(CharacterShared mySINner) { InitializeComponent(); _mySINner = mySINner ?? throw new ArgumentNullException(nameof(mySINner)); MyCE = new CharacterExtended(mySINner.CharacterObject, null, PluginHandler.MySINnerLoading); MyCE.ZipFilePath = await MyCE.PrepareModel(); TabSINnersBasic = new ucSINnersBasic(this) { Visible = true }; TabSINnersAdvanced = new ucSINnersAdvanced(this) { Visible = true }; this.tabPageBasic.Controls.Add(TabSINnersBasic); this.tabPageAdvanced.Controls.Add(TabSINnersAdvanced); this.AutoSize = true; if (ucSINnersOptions.UploadOnSave) { try { mySINner.CharacterObject.OnSaveCompleted = null; mySINner.CharacterObject.OnSaveCompleted += PluginHandler.MyOnSaveUpload; } catch (Exception e) { Log.Warn(e); } } //MyCE.MySINnerFile.SiNnerMetaData.Tags = MyCE.PopulateTags(); return(MyCE); }
public static async Task <HttpOperationResponse> UploadChummerFileAsync(CharacterExtended ce) { HttpOperationResponse res = null; try { if (String.IsNullOrEmpty(ce.ZipFilePath)) { ce.ZipFilePath = await ce.PrepareModel(); } using (FileStream fs = new FileStream(ce.ZipFilePath, FileMode.Open, FileAccess.Read)) { try { var client = await StaticUtils.GetClient(); if (!StaticUtils.IsUnitTest) { HttpStatusCode myStatus = HttpStatusCode.Unused; res = await client.PutSINWithHttpMessagesAsync(ce.MySINnerFile.Id.Value, fs); //var task = res.ContinueWith((sender) => //{ string msg = "Upload ended with statuscode: "; msg += res?.Response?.StatusCode + Environment.NewLine; msg += res?.Response?.ReasonPhrase; msg += Environment.NewLine + res?.Response?.Content.ReadAsStringAsync().Result; System.Diagnostics.Trace.TraceInformation(msg); myStatus = res.Response.StatusCode; if (!StaticUtils.IsUnitTest) { PluginHandler.MainForm.DoThreadSafe(() => { if (myStatus != HttpStatusCode.OK) { MessageBox.Show(msg); } using (new CursorWait(true, PluginHandler.MainForm)) { Chummer.Plugins.PluginHandler.MainForm.CharacterRoster.LoadCharacters(false, false, false, true); } }); } else { System.Diagnostics.Trace.TraceInformation(msg); } //}); } else { client.PutSIN(ce.MySINnerFile.Id.Value, fs); } } catch (Exception e) { System.Diagnostics.Trace.TraceError(e.ToString()); PluginHandler.MainForm.DoThreadSafe(() => { MessageBox.Show(e.Message); }); } } } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.ToString()); throw; } return(res); }