Exemplo n.º 1
0
 private void getLicense_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         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();
                 Commit com = new Commit(filepath, this);
                 com.ShowDialog();
                 if (this.goodcertificate)
                 {
                     this.komSend = "";
                     Connection con = new Connection();
                     if (con.IsAvailableNetworkActive())
                     {
                         Eksport ex = new Eksport(this.savePath, true, this, this.licensePath, this.password);
                         try
                         {
                             ex.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 ex2)
                             {
                                 MessageBox.Show("Protokół został wysłany, ale nie można zmienić jego statusu. " + ex2.Message, "Uwaga");
                                 base.Close();
                             }
                         }
                     }
                     else
                     {
                         this.komSend = "Protokół nie został wysłany na serwer z powodu braku internetu";
                     }
                     MessageBox.Show(this.komSend, "Uwaga");
                     base.Close();
                 }
             }
             catch (System.ArgumentOutOfRangeException)
             {
             }
         }
     }
     catch (System.Exception)
     {
     }
 }
Exemplo n.º 2
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)
     {
     }
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
0
 private void LicencesTable_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0)
         {
             if (e.ColumnIndex == this.LicencesTable.Columns["action"].Index)
             {
                 try
                 {
                     if (!System.IO.Directory.Exists(this.path + "\\Licenses"))
                     {
                         try
                         {
                             System.IO.Directory.CreateDirectory(this.path + "\\Licenses");
                         }
                         catch (System.ArgumentNullException)
                         {
                             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"Licenses\"", "Error");
                         }
                         catch (System.ArgumentException)
                         {
                             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"Licenses\"", "Error");
                         }
                         catch (System.UnauthorizedAccessException)
                         {
                             MessageBox.Show("Nie masz uprawnień do tworzenia katalogów. Otwórz aplikacje jako adnimistrator.", "Uwaga");
                         }
                         catch (System.IO.PathTooLongException)
                         {
                             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"Licenses\"", "Error");
                         }
                         catch (System.IO.DirectoryNotFoundException)
                         {
                             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"Licenses\"", "Error");
                         }
                         catch (System.NotSupportedException)
                         {
                             MessageBox.Show("Nieprawidłowy format ścieżki. Nie można utworzyć katalogu \"Licenses\"", "Error");
                         }
                         catch (System.IO.IOException)
                         {
                             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"Licenses\"", "Error");
                         }
                     }
                     object name = this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value;
                     string filepath = this.path + "\\Licenses\\" + name.ToString();
                     Commit com = new Commit(filepath, this);
                     com.ShowDialog();
                     if (this.logged)
                     {
                         this.logged = false;
                         string[] ou = this.readOU(filepath).Split(new char[]
                         {
                             '-'
                         });
                         if (ou[2] == "P" || ou[2] == "O" || ou[2] == "Z")
                         {
                             this.wait.setWaitPanel("Trwa przygotowanie listy protokołów", "Proszę czekać");
                             this.wait.setVisible(true);
                             ProtocolsList startprotocols = new ProtocolsList(filepath, this, filepath, Kalkulator1.instalClass.Version.getVersion());
                             startprotocols.ShowDialog();
                         }
                         if (ou[2] == "A")
                         {
                             this.jns = "";
                             bool powiat = false;
                             string jnsTMP = ou[1];
                             if (jnsTMP.Length < 6)
                             {
                                 while (jnsTMP.Length < 6)
                                 {
                                     jnsTMP = "0" + jnsTMP;
                                 }
                             }
                             if (jnsTMP[4] == '0' && jnsTMP[5] == '0')
                             {
                                 powiat = true;
                                 RegionList rl = new RegionList(this, filepath, ou[1]);
                                 try
                                 {
                                     rl.ShowDialog();
                                 }
                                 catch (System.Exception)
                                 {
                                 }
                             }
                             else
                             {
                                 this.jns = ou[1];
                             }
                             if (this.jns != null && this.jns != "")
                             {
                                 ProtocolsList startprotocols = new ProtocolsList(filepath, this, filepath, Kalkulator1.instalClass.Version.getVersion(), this.jns, powiat);
                                 startprotocols.ShowDialog();
                             }
                             this.jns = "";
                         }
                     }
                 }
                 catch (System.ArgumentOutOfRangeException)
                 {
                 }
                 catch (System.Exception ex)
                 {
                     MessageBox.Show("Operacja nie powiodła się. Spróbuj jeszcze raz. Orginal error: " + ex.Message, "Uwaga");
                 }
             }
             if (e.ColumnIndex == this.LicencesTable.Columns["remove"].Index)
             {
                 try
                 {
                     DialogResult result = MessageBox.Show("Czy napewno usunąć licencje " + this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value.ToString() + "?", "Usuwanie", MessageBoxButtons.YesNo);
                     if (result == DialogResult.Yes)
                     {
                         try
                         {
                             System.IO.File.Delete(this.path + "\\Licenses\\" + this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value.ToString());
                             System.IO.File.Delete(this.path + "\\Licenses\\" + this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value.ToString().Replace(".crt", ".key"));
                             this.LicencesTable.Rows.Remove(this.LicencesTable.Rows[e.RowIndex]);
                         }
                         catch (System.ArgumentNullException)
                         {
                             MessageBox.Show("Błędna scieżka do licencji", "Error");
                         }
                         catch (System.ArgumentException)
                         {
                             MessageBox.Show("Błędna scieżka do licencji", "Error");
                         }
                         catch (System.IO.DirectoryNotFoundException)
                         {
                             MessageBox.Show("Błąd znalezienia pliku licencji", "Error");
                         }
                         catch (System.IO.PathTooLongException)
                         {
                             MessageBox.Show("Zbyt długa scieżka do licencji", "Error");
                         }
                         catch (System.IO.IOException)
                         {
                             MessageBox.Show("Nie można usunąć licencji. Jeden z jej plików jest obecnie używany.", "Error");
                         }
                         catch (System.NotSupportedException)
                         {
                             MessageBox.Show("Błędna scieżka do licencji", "Error");
                         }
                         catch (System.UnauthorizedAccessException)
                         {
                             MessageBox.Show("Program nie posiada uprawnień do usuwania plików", "Error");
                         }
                     }
                     this.getActiveLicense();
                     this.getOtherLicense();
                 }
                 catch (System.ArgumentOutOfRangeException)
                 {
                 }
             }
             else
             {
                 if (e.ColumnIndex == this.LicencesTable.Columns["save"].Index)
                 {
                     try
                     {
                         System.IO.StreamReader sr = new System.IO.StreamReader(this.path + "\\Licenses\\" + this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value.ToString());
                         string file = sr.ReadToEnd();
                         sr.Close();
                         SaveFileDialog wnd = new SaveFileDialog();
                         wnd.Title = "Zapisywanie licencji";
                         wnd.Filter = "(*.pem)|*.pem";
                         wnd.FileName = this.LicencesTable.Rows[e.RowIndex].Cells["Licencja"].Value.ToString();
                         wnd.ShowDialog();
                         this.wait.setWaitPanel("Trwa zapisywanie licencji", "Proszę czekać");
                         this.wait.setVisible(true);
                         string name2 = wnd.FileName;
                         try
                         {
                             if (name2 != "")
                             {
                                 System.IO.StreamWriter sw = new System.IO.StreamWriter(name2, false);
                                 sw.Write(file);
                                 sw.Close();
                             }
                             this.wait.setVisible(false);
                         }
                         catch (System.UnauthorizedAccessException)
                         {
                             MessageBox.Show("Nie można zapisać pliku. Otwórz aplikacje jako administracje", "Error");
                         }
                         catch (System.Exception ex)
                         {
                             MessageBox.Show("Nie można zapisać pliku. Orginal exception: " + ex.Message, "Error");
                         }
                     }
                     catch (System.ArgumentOutOfRangeException)
                     {
                     }
                 }
             }
         }
     }
     catch (System.Exception)
     {
     }
 }