private void BViewGroup_Click(object sender, EventArgs e) { try { var group = new SINnerGroup(); group.Groupname = this.tbSearchGroupname.Text; group.IsPublic = false; if ((MyCE?.MySINnerFile.MyGroup != null) && ((String.IsNullOrEmpty(tbSearchGroupname.Text)) || (tbSearchGroupname.Text == MyCE?.MySINnerFile.MyGroup?.Groupname))) { group = MyCE?.MySINnerFile.MyGroup; } if (this.tvGroupSearchResult.SelectedNode != null) { SINnerSearchGroup sel = tvGroupSearchResult.SelectedNode.Tag as SINnerSearchGroup; if (sel != null) { group = new SINnerGroup(sel); } } frmSINnerGroupEdit ge = new frmSINnerGroupEdit(group, false); var result = ge.ShowDialog(this); if (result == DialogResult.OK) { group = ge.MySINnerGroupCreate.MyGroup; } } catch (Exception ex) { Log.Error(ex); Program.MainForm.ShowMessageBox(ex.ToString()); } }
private async void bCreateGroup_Click(object sender, EventArgs e) { try { var group = new SINnerGroup(); group.Groupname = this.tbSearchGroupname.Text; group.IsPublic = false; if ((MyCE?.MySINnerFile.MyGroup != null) && ((String.IsNullOrEmpty(tbSearchGroupname.Text)) || (tbSearchGroupname.Text == MyCE?.MySINnerFile.MyGroup?.Groupname))) { group = MyCE?.MySINnerFile.MyGroup; } if (this.tvGroupSearchResult.SelectedNode != null) { SINnerSearchGroup sel = tvGroupSearchResult.SelectedNode.Tag as SINnerSearchGroup; if (sel != null) { group = new SINnerGroup(sel); } } frmSINnerGroupEdit ge = new frmSINnerGroupEdit(group, false); var result = ge.ShowDialog(this); if (result == DialogResult.OK) { group = ge.MySINnerGroupCreate.MyGroup; try { using (new CursorWait(false, this)) { var a = await CreateGroup(ge.MySINnerGroupCreate.MyGroup); if (a != null) { MySINSearchGroupResult = await SearchForGroups(a.Groupname); if (MyParentForm?.MyParentForm != null) { await MyParentForm?.MyParentForm?.CheckSINnerStatus(); } } } } catch (Exception exception) { Program.MainForm.ShowMessageBox(exception.Message); } } } catch (Exception ex) { Log.Error(ex); Program.MainForm.ShowMessageBox(ex.ToString()); } }
private async void bCreateGroup_Click(object sender, EventArgs e) { try { var group = new SINnerGroup(); group.Groupname = this.tbSearchGroupname.Text; group.IsPublic = false; frmSINnerGroupEdit ge = new frmSINnerGroupEdit(group, false); var result = ge.ShowDialog(this); if (result == DialogResult.OK) { try { using (new CursorWait(false, this)) { var a = await CreateGroup(ge.MySINnerGroupCreate.MyGroup); if (a != null) { MySINSearchGroupResult = await SearchForGroups(a.Groupname, null, null); if (MyParentForm?.MyParentForm != null) { await MyParentForm.MyParentForm.CheckSINnerStatus(); } } } } catch (Exception exception) { MessageBox.Show(exception.Message); } } } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.ToString(), ex); MessageBox.Show(ex.ToString()); } }
private async Task <SINSearchGroupResult> JoinGroupTask(SINnerSearchGroup searchgroup, CharacterExtended myCE) { bool exceptionlogged = false; SINSearchGroupResult ssgr = null; try { DialogResult result = DialogResult.Cancel; frmSINnerGroupEdit groupEdit = null; if (searchgroup.HasPassword == true) { SINnerGroup joinGroup = new SINnerGroup(searchgroup); PluginHandler.MainForm.DoThreadSafe(() => { groupEdit = new frmSINnerGroupEdit(joinGroup, true); result = groupEdit.ShowDialog(this); }); } if ((result == DialogResult.OK) || (searchgroup.HasPassword == false)) { try { using (new CursorWait(true, this)) { var client = StaticUtils.GetClient(); var response = await client.PutSINerInGroupWithHttpMessagesAsync(searchgroup.Id, myCE.MySINnerFile.Id, groupEdit?.MySINnerGroupCreate?.MyGroup?.PasswordHash); if ((response.Response.StatusCode != HttpStatusCode.OK)) { var rescontent = await response.Response.Content.ReadAsStringAsync(); if (response.Response.StatusCode == HttpStatusCode.BadRequest) { if (rescontent.Contains("PW is wrong!")) { throw new ArgumentException("Wrong Password provided!"); } string searchfor = "NoUserRightException\",\"Message\":\""; if (rescontent.Contains(searchfor)) { string msg = rescontent.Substring(rescontent.IndexOf(searchfor) + searchfor.Length); msg = msg.Substring(0, msg.IndexOf("\"")); throw new ArgumentException(msg); } throw new ArgumentException(rescontent); } else { string msg = "StatusCode: " + response.Response.StatusCode + Environment.NewLine; msg += rescontent; throw new ArgumentException(msg); } } else { var found = await client.GetGroupByIdWithHttpMessagesAsync(searchgroup.Id, null, CancellationToken.None); var res = Backend.Utils.HandleError(found); if (found?.Response?.IsSuccessStatusCode == true) { ssgr = new SINSearchGroupResult(found.Body.MyGroup); } } } } catch (Exception e) { Log.Error(e); exceptionlogged = true; throw; } finally { MyParentForm?.MyParentForm?.CheckSINnerStatus(); } } } catch (Exception e) { if (!exceptionlogged) { Log.Error(e); } throw; } return(ssgr); }
private async void bCreateGroup_Click(object sender, EventArgs e) { try { var group = new SINnerGroup(); group.Groupname = this.tbSearchGroupname.Text; group.IsPublic = false; if ((MyCE.MySINnerFile.MyGroup != null) && ((String.IsNullOrEmpty(tbSearchGroupname.Text)) || (tbSearchGroupname.Text == MyCE.MySINnerFile.MyGroup?.Groupname))) { group = MyCE.MySINnerFile.MyGroup; } if (this.tvGroupSearchResult.SelectedNode != null) { SINnerSearchGroup sel = tvGroupSearchResult.SelectedNode.Tag as SINnerSearchGroup; if (sel != null) { group = new SINnerGroup(sel); } } frmSINnerGroupEdit ge = new frmSINnerGroupEdit(group, false); var result = ge.ShowDialog(this); if (result == DialogResult.OK) { group = ge.MySINnerGroupCreate.MyGroup; try { using (new CursorWait(false, this)) { if (group == MyCE.MySINnerFile.MyGroup) { var client = await StaticUtils.GetClient(); var response = await client.PostGroupWithHttpMessagesAsync(group, MyCE.MySINnerFile.Id); if ((response.Response.StatusCode == HttpStatusCode.Accepted) || (response.Response.StatusCode == HttpStatusCode.Created) || (response.Response.StatusCode == HttpStatusCode.OK)) { //ok } else if ((response.Response.StatusCode == HttpStatusCode.NotFound)) { var rescontent = await response.Response.Content.ReadAsStringAsync(); string msg = "StatusCode: " + response.Response.StatusCode + Environment.NewLine; msg += rescontent; throw new ArgumentNullException(nameof(group), msg); } else { var rescontent = await response.Response.Content.ReadAsStringAsync(); throw new ArgumentException(rescontent); } } else { //create mode var a = await CreateGroup(ge.MySINnerGroupCreate.MyGroup); if (a != null) { MySINSearchGroupResult = await SearchForGroups(a.Groupname, null, null); if (MyParentForm?.MyParentForm != null) { await MyParentForm.MyParentForm.CheckSINnerStatus(); } } } } } catch (Exception exception) { MessageBox.Show(exception.Message); } } } catch (Exception ex) { System.Diagnostics.Trace.TraceError(ex.ToString(), ex); MessageBox.Show(ex.ToString()); } }