Пример #1
0
 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);
     }
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
 private void getLicense_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0)
         {
             if (e.ColumnIndex == this.LicencesTable.Columns["action"].Index)
             {
                 try
                 {
                     object name = this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value;
                     string filepath = this.path + "\\Licenses\\" + name.ToString();
                     this.wait.setWaitPanel("Trwa autozapis protokołu", "Prosimy czekać");
                     this.wait.setVisible(true);
                     this.saves(4);
                     this.wait.setWaitPanel("Trwa przygotowanie do podpisania protokołu", "Prosimy czekać");
                     this.wait.setVisible(true);
                     string xmlTMP = this.generateSaves(0);
                     Commit com = new Commit(filepath, this, xmlTMP);
                     com.ShowDialog();
                     if (this.goodcertificate)
                     {
                         this.wait.setWaitPanel("Trwa generowanie kodu kreskowego dla protokołu", "Prosimy czekać");
                         this.wait.setVisible(true);
                         string docXml = "";
                         this.currentStep = 0;
                         string xml = xmlTMP;
                         this.save.LoadXml(xml);
                         XmlNode header = this.save.SelectSingleNode("/save/header");
                         if (header != null)
                         {
                             docXml += header.OuterXml;
                         }
                         XmlNode step = this.save.SelectSingleNode("/save/step");
                         if (step != null)
                         {
                             docXml += step.OuterXml;
                         }
                         XmlNode form = this.save.SelectSingleNode("/save/form");
                         if (form != null)
                         {
                             docXml += form.OuterXml;
                         }
                         XmlNode komisja_sklad = this.save.SelectSingleNode("/save/komisja_sklad");
                         if (komisja_sklad != null)
                         {
                             docXml += komisja_sklad.OuterXml;
                         }
                         XmlNode hardWarningCode = this.save.SelectSingleNode("/save/hardWarningCode");
                         if (hardWarningCode != null)
                         {
                             docXml += hardWarningCode.OuterXml;
                         }
                         XmlNode softError = this.save.SelectSingleNode("/save/softError");
                         if (softError != null)
                         {
                             docXml += softError.OuterXml;
                         }
                         XmlNode hardError = this.save.SelectSingleNode("/save/hardError");
                         if (hardError != null)
                         {
                             docXml += hardError.OuterXml;
                         }
                         XmlNode hardWarning = this.save.SelectSingleNode("/save/hardWarning");
                         if (hardWarning != null)
                         {
                             docXml += hardWarning.OuterXml;
                         }
                         ClassMd5 i = new ClassMd5();
                         string controlSum = i.CreateMD5Hash(docXml);
                         codeBar code = new codeBar();
                         code.generateCode(controlSum);
                         this.codeBarCode = code.getCode();
                         this.codeBarText = code.getTextReadable();
                         this.wait.setWaitPanel("Trwa podpisywanie protokołu", "Prosimy czekać");
                         this.wait.setVisible(true);
                         xml = this.generateSaves(this.currentStep);
                         try
                         {
                             Certificate cer = new Certificate();
                             cer.SignXmlText(xml, this.savePath, this.password, filepath);
                         }
                         catch (System.Exception ex)
                         {
                             MessageBox.Show("Sign: " + ex.Message, "Uwaga");
                         }
                         try
                         {
                             this.komSend = "";
                             Connection con = new Connection();
                             if (con.IsAvailableNetworkActive())
                             {
                                 this.wait.setWaitPanel("Trwa wysyłanie protokołu", "Prosimy czekać");
                                 this.wait.setVisible(true);
                                 this.goodcertificate = false;
                                 this.error = false;
                                 Eksport ex2 = new Eksport(this.savePath, true, this, filepath, this.password);
                                 try
                                 {
                                     ex2.ShowDialog();
                                 }
                                 catch (System.Exception)
                                 {
                                 }
                                 if (this.goodcertificate)
                                 {
                                     try
                                     {
                                         System.IO.StreamReader sr = new System.IO.StreamReader(this.savePath);
                                         string file = sr.ReadToEnd();
                                         sr.Close();
                                         file = file.Replace("<status>podpisany</status>", "<status>wysłany</status>");
                                         System.IO.StreamWriter sw = new System.IO.StreamWriter(this.savePath, false);
                                         sw.Write(file);
                                         sw.Close();
                                     }
                                     catch (System.Exception ex3)
                                     {
                                         MessageBox.Show("Protokół został wysłany, ale nie można zmienić jego statusu. " + ex3.Message, "Uwaga");
                                     }
                                 }
                                 if (!this.goodcertificate && this.error)
                                 {
                                     this.codeBarCode = "";
                                     this.codeBarText = "";
                                     this.saves(4);
                                 }
                             }
                             else
                             {
                                 this.komSend = "Protokół nie został wysłany na serwer z powodu braku internetu. Z poziomu listy protokołów bedzie można ponowić operacje.";
                             }
                             this.password = "";
                         }
                         catch (System.Exception ex)
                         {
                             MessageBox.Show("Send: " + ex.Message, "Uwaga");
                         }
                         try
                         {
                             this.wait.setWaitPanel("Trwa zapisywanie protokołu na dysk", "Prosimy czekać");
                             this.wait.setVisible(true);
                             SaveProtocol saveP = new SaveProtocol(this.komSend, this.savePath);
                             saveP.ShowDialog();
                         }
                         catch (System.Exception ex)
                         {
                             MessageBox.Show("Save: " + ex.Message, "Uwaga");
                         }
                         try
                         {
                             this.wait.setWaitPanel("Trwa przygotowanie protokołu do druku", "Prosimy czekać");
                             this.wait.setVisible(true);
                             this.drukToolStripMenuItem_Click(sender, e);
                             this.wait.setVisible(false);
                         }
                         catch (System.Exception ex)
                         {
                             MessageBox.Show("Print: " + ex.Message, "Uwaga");
                         }
                     }
                 }
                 catch (System.ArgumentOutOfRangeException ex_5C5)
                 {
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
     }
 }