private void sendPetition_Click(object sender, System.EventArgs e) { WaitPanel p = new WaitPanel("Wait_04", base.Size.Width, base.Size.Height); p.setWaitPanel("Trwa generowanie wniosku", "Proszę czekać"); p.setSize(this.passwordPanel.Size); p.setLocation(this.passwordPanel.Location); base.Controls.Add(p.getPanel()); base.Controls[p.getName()].BringToFront(); p.setVisible(true); string uri = "certificates/csrwrite"; Certificate certificate = new Certificate(); certificate.generateCSR(this.ou, this.user, this.passwordCert1.Text); string postData = "csr=" + HttpUtility.UrlEncode(certificate.getCSR()) + "&token=" + HttpUtility.UrlEncode(this.token); p.setWaitPanel("Trwa wysyłanie wniosku", "Proszę czekać"); Code res = this.con.postReq(uri, postData, 0); if (res.getcode() == 0) { MessageBox.Show("Wniosek o licencje został wysłany", "Uwaga"); } else { MessageBox.Show(res.getText(), "Uwaga"); } p.setVisible(false); base.Close(); }
private void LoginNext_Click(object sender, System.EventArgs e) { if (this.con.IsAvailableNetworkActive()) { WaitPanel p = new WaitPanel("Wait_04", base.Size.Width, base.Size.Height); p.setWaitPanel("Trwa autoryzacja użytkownika", "Proszę czekać"); p.setSize(this.passwordPanel.Size); p.setLocation(this.passwordPanel.Location); base.Controls.Add(p.getPanel()); base.Controls[p.getName()].BringToFront(); p.setVisible(true); string postData = "flag=kalkulator&login="******"&password="******"") { this.user = logData.getUser(); this.ou = string.Concat(new string[] { logData.getElections(), "-", logData.getJns(), "-", logData.getRola() }); if (logData.getRola() == "P" || logData.getRola() == "Z") { this.ou = this.ou + "-" + logData.getObwodu(); } this.token = logData.getToken(); this.step1(); } else { MessageBox.Show("Podano błędny login lub hasło", "Uwaga"); base.Close(); } } else { MessageBox.Show("Nie masz połaczenia z internetem!", "Uwaga"); base.Close(); } }
private void log_Click(object sender, System.EventArgs e) { if (this.con.IsAvailableNetworkActive()) { bool logged = this.c.readKey(this.licensePath, this.password.Text); if (logged) { WaitPanel p = new WaitPanel("Wait_04", base.Size.Width, base.Size.Height); p.setWaitPanel("Trwa importowanie danych", "Proszę czekać"); p.setSize(this.passwordPanel.Size); p.setLocation(this.passwordPanel.Location); base.Controls.Add(p.getPanel()); base.Controls[p.getName()].BringToFront(); p.setVisible(true); string[] filenameTab = this.name.Split(new char[] { '\\' }); string filename = filenameTab[filenameTab.Length - 1]; string uri = "protocols/import"; string post = "flag=import&filename=" + HttpUtility.UrlEncode(filename); string[] item = filename.Split(new char[] { '-' }); post = post + "&akcja=" + HttpUtility.UrlEncode(item[0].Replace('_', '/')); post = post + "&jsn=" + item[1]; post = post + "&obw=" + item[2]; post = post + "&inst=" + item[3]; string[] okr = item[4].Replace(".xml", "").Split(new char[] { ' ' }); post = post + "&okr=" + okr[0]; string xml = string.Concat(new string[] { "<import><header><jns_kod>", item[1], "</jns_kod><nrObwodu>", item[2], "</nrObwodu>" }); xml = xml + "<id_intytucji>" + this.instId + "</id_intytucji>"; xml = xml + "<id_okregu>" + this.okregId + "</id_okregu></header></import>"; try { Certificate cer = new Certificate(); cer.SignXmlText(xml, System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml", this.password.Text, this.licensePath); System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml"); xml = sr.ReadToEnd(); sr.Close(); } catch (System.Exception ex) { MessageBox.Show("Import protokołu: " + ex.Message, "Error"); } post = post + "&xmlImport=" + HttpUtility.UrlEncode(xml); ResponseData res = this.con.postImport(uri, post, 0); if (res.getCode().getcode() == 0) { System.IO.StreamWriter sw = new System.IO.StreamWriter(this.name, false); sw.Write(res.getXml()); sw.Close(); this.form2.imported = true; base.Close(); } else { MessageBox.Show(res.getCode().getText(), "Import"); this.form2.imported = false; } p.setVisible(true); } else { this.label6.Visible = true; this.form2.imported = false; } } else { MessageBox.Show("Nie masz połaczenia z internetem!", "Uwaga"); base.Close(); } }
private void send_Click(object sender, System.EventArgs e) { this.obwodList_Validated(this.obwodList, e); this.currentLwyb_Validated(this.currentLwyb, e); this.attendanceHour_Validated(this.attendanceHour, e); this.number_Validated(this.attendanceValue, e); if ((!this.errorValue.Visible && !this.errorHour.Visible && !this.errorOBW.Visible && !this.errorCurrentLwyb.Visible) || (!this.errorValue.Visible && !this.errorHour.Visible && !this.errorOBW.Visible && this.errorCurrentLwyb.Visible && this.errorCurrentLwyb.Text == "Liczba wyborców uprawnionych do głosowania jest mniejsza od 110% i większa od 90% szacowanej liczby wyborców (" + (this.obwodList.SelectedItem as AttendanceOBWItem).getLwyb().ToString() + ").")) { WaitPanel p = new WaitPanel("Wait_04", base.Size.Width, base.Size.Height); p.setWaitPanel("Trwa importowanie danych", "Proszę czekać"); p.setSize(this.FormPanel.Size); p.setLocation(this.FormPanel.Location); base.Controls.Add(p.getPanel()); base.Controls[p.getName()].BringToFront(); p.setVisible(true); string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; xml += "<save>"; string hour = ""; try { if (this.attendanceHour.SelectedItem != null) { hour = (this.attendanceHour.SelectedItem as AttendanceItem).getName(); } } catch (System.Exception ex) { } string value = ""; try { if (this.attendanceValue.Text != null) { value = this.attendanceValue.Text; } } catch (System.Exception ex) { } string text = xml; xml = string.Concat(new string[] { text, "<attendance><attendanceHour>", hour, "</attendanceHour><attendanceValue>", value, "</attendanceValue><currentLwyb>", this.currentLwyb.Text, "</currentLwyb></attendance>" }); xml += "<header>"; xml += this.getHeader(this.header); xml += "</header>"; xml += "</save>"; Commit c = new Commit(this.licensePath, this); c.ShowDialog(); if (this.logged) { try { Certificate cer = new Certificate(); cer.SignXmlText(xml, System.IO.Path.GetTempPath() + "KBW\\tmp\\attendance.xml", this.password, this.licensePath); System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.Path.GetTempPath() + "KBW\\tmp\\attendance.xml"); xml = sr.ReadToEnd(); sr.Close(); string uri = "attendances/readval/" + HttpUtility.UrlEncode((this.attendanceHour.SelectedItem as AttendanceItem).getName()); string post = "xml=" + HttpUtility.UrlEncode(xml); Connection con = new Connection(); Code res = con.postReq(uri, post, 0); MessageBox.Show(res.getText(), "Komunikat"); } catch (System.Exception ex) { MessageBox.Show("Błąd utworzenia wiadomości: " + ex.Message, "Uwaga"); } } p.setVisible(false); } }
private void log_Click(object sender, System.EventArgs e) { if (this.con.IsAvailableNetworkActive()) { Certificate cert = new Certificate(); bool logged = cert.readKey(this.licensePath, this.password.Text); if (logged) { WaitPanel panelWait = new WaitPanel("Wait_04", base.Size.Width, base.Size.Height); panelWait.setWaitPanel("Trwa wysyłanie prośby o przyznanie kodu odblokowującego przez pełnomocnika.", "Proszę czekać"); panelWait.setSize(this.passwordPanel.Size); panelWait.setLocation(this.passwordPanel.Location); base.Controls.Add(panelWait.getPanel()); base.Controls[panelWait.getName()].BringToFront(); panelWait.setVisible(true); this.label6.Visible = false; try { cert.SignXmlText(this.xml, System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml", this.password.Text, this.licensePath); System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml"); this.xml = sr.ReadToEnd(); sr.Close(); } catch (System.Exception ex) { MessageBox.Show("Wprowadzanie kodu: " + ex.Message, "Error"); } string post2 = this.postWarning + this.postWarning2 + "&flag=export&flag2=akcept&xml=" + HttpUtility.UrlEncode(this.xml); string uri = "protocols/export"; ResponseData cod = this.con.postSendCode(uri, post2, 0); if (cod.getCode().getcode() == 0) { WaitPanel p = new WaitPanel("Wait_04", base.Size.Width, base.Size.Height); p.setWaitPanel("Trwa sprawdzanie czy ostrzeżenie/a twarde zostały zaakceptowane - oczekiwanie na przyznanie kodu odblokowującego przez pełnomocnika.", "Proszę czekać"); p.setSize(this.passwordPanel.Size); p.setLocation(this.passwordPanel.Location); base.Controls.Add(p.getPanel()); base.Controls[p.getName()].BringToFront(); p.setVisible(true); bool response = false; int count = 0; while (!response) { count++; string post3 = "flag=export&flag2=check&" + this.postWarning2 + "&xml=" + HttpUtility.UrlEncode(this.xml); ResponseData cod2 = this.con.postSendCode(uri, post3, 0); if (cod2.getCode().getcode() == 10) { this.f.codeField.Text = cod2.getXml(); response = true; base.Close(); } else { if (cod2.getCode().getcode() == 9) { p.setWaitPanel("Protokół z ostrzeżeniami twardymi został odrzucony", "Proszę czekać"); response = true; } else { if (cod2.getCode().getcode() != 11) { if (MessageBox.Show(cod2.getCode().getText() + " Spróbować jeszcze raz?", "Oczekiwanie na odpowiedź", MessageBoxButtons.YesNo) == DialogResult.No) { response = true; base.Close(); } } } } if (count % 11 == 0) { if (MessageBox.Show("Protokół ciągle oczekuje na akceptacje. Kontynuować sprawdzanie?", "Oczekiwanie na odpowiedź", MessageBoxButtons.YesNo) == DialogResult.No) { response = true; base.Close(); } } } base.Close(); } else { MessageBox.Show(cod.getCode().getText(), "Komuniakt"); base.Close(); } panelWait.setVisible(true); } else { this.label6.Visible = true; } } else { MessageBox.Show("Nie masz połaczenia z internetem! Podłącz internet i spróbuj jeszcze raz.", "Uwaga"); base.Close(); } }