Beispiel #1
0
 public RegionList()
 {
     this.InitializeComponent();
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.con = new Connection();
     this.jns = "";
     this.wait = new WaitPanel("Wait2", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.start = null;
     this.licensepath = "";
 }
 public SendProtocol()
 {
     this.InitializeComponent();
     this.codeWarning = "";
     this.headerName = "";
     this.committeeName = "";
     this.candidatesName = "";
     this.protocolDefinitionName = "";
     this.validateDefinitionName = "";
     this.protocolDefinition = new XmlDocument();
     this.candidates = new XmlDocument();
     this.committee = new XmlDocument();
     this.validateDefinition = new XmlDocument();
     this.header = new XmlDocument();
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.goodcertificate = false;
     this.wait = new WaitPanel("Wait3", base.Width, base.Height);
     this.form = null;
 }
Beispiel #3
0
 public RegionList(Start start, string licensepath, string jns)
 {
     this.con = new Connection();
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.InitializeComponent();
     this.licensepath = licensepath;
     this.jns = jns;
     this.start = start;
     this.Text = this.Text + " (" + Kalkulator1.instalClass.Version.getVersion().ToString() + ")";
     this.wait = new WaitPanel("Wait99", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.exit = false;
     this.getRegions(true);
     if (this.exit)
     {
         base.Close();
     }
 }
 public ProtocolsList()
 {
     this.InitializeComponent();
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.con = new Connection();
     this.header = new XmlDocument();
     this.electoralEampaignSave = "";
     this.jns = "";
     this.role = "";
     this.circuit = "";
     this.wait = new WaitPanel("Wait2", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.start = null;
     this.licensepath = "";
     this.electionData = new System.DateTime(2014, 8, 27, 7, 0, 0);
     this.send = false;
     this.powiat = false;
     this.erros = false;
 }
 public SendProtocol(ProtocolsList form, XmlDocument header, string protocolDefinition, string candidates, string committee, string validateDefinition, string save, string OU, string licensePath)
 {
     this.InitializeComponent();
     this.Text = this.Text + " (" + Kalkulator1.instalClass.Version.getVersion().ToString() + ")";
     this.licensePath = licensePath;
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.preview.Width = 750;
     this.codeWarning = "";
     this.wait = new WaitPanel("Wait3", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.form = form;
     this.OU = OU;
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu", "Proszę czekać");
     form.wait.setVisible(true);
     this.errorProvider1 = new ErrorProvider();
     string[] p = protocolDefinition.Split(new char[]
     {
         '\\'
     });
     this.protocolDefinitionName = p[p.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p2 = candidates.Split(new char[]
     {
         '\\'
     });
     this.candidatesName = p2[p2.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p3 = committee.Split(new char[]
     {
         '\\'
     });
     this.committeeName = p3[p3.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p4 = validateDefinition.Split(new char[]
     {
         '\\'
     });
     this.validateDefinitionName = p4[p4.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p5 = this.committeeName.Split(new char[]
     {
         '-'
     });
     if (p5.Length > 2)
     {
         this.headerName = p5[0] + "-" + p5[1];
     }
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - wczytywanie danych", "Proszę czekać");
     try
     {
         this.header = new XmlDocument();
         this.header = header;
         this.savePath = save;
         if (protocolDefinition != "")
         {
             this.protocolDefinition = new XmlDocument();
             if (System.IO.File.Exists(protocolDefinition))
             {
                 this.protocolDefinition.Load(protocolDefinition);
             }
         }
         if (candidates != "")
         {
             this.candidates = new XmlDocument();
             if (System.IO.File.Exists(candidates))
             {
                 this.candidates.Load(candidates);
             }
         }
         if (committee != "")
         {
             this.committee = new XmlDocument();
             if (System.IO.File.Exists(committee))
             {
                 this.committee.Load(committee);
             }
         }
         if (validateDefinition != "")
         {
             this.validateDefinition = new XmlDocument();
             if (System.IO.File.Exists(validateDefinition))
             {
                 this.validateDefinition.Load(validateDefinition);
             }
         }
         if (save != "")
         {
             this.save = new XmlDocument();
             if (System.IO.File.Exists(save))
             {
                 this.save.Load(save);
             }
         }
     }
     catch (XmlException e)
     {
         MessageBox.Show("Nieprawidłowy XML: " + e.Message, "Error");
     }
     this.goodcertificate = false;
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - sprawdzanie plikow definicyjnych formularza protokołu", "Proszę czekać");
     try
     {
         bool isKlk = true;
         bool isupdatedKlk = true;
         string kom = "Nieaktualnie pliki definicyjne: ";
         int i = 0;
         XmlNode klk = this.save.SelectSingleNode("/save/header/defklk");
         foreach (XmlNode j in klk)
         {
             XmlNode name = j.Attributes.GetNamedItem("name");
             XmlNode data_wersji = j.Attributes.GetNamedItem("data_wersji");
             if (name != null && data_wersji != null)
             {
                 if (this.protocolDefinitionName == name.Value)
                 {
                     XmlNode wersja = this.protocolDefinition.SelectSingleNode("/protokol_info").Attributes.GetNamedItem("data_wersji");
                     if (wersja != null && data_wersji.Value != wersja.Value)
                     {
                         if (i == 0)
                         {
                             string text = kom;
                             kom = string.Concat(new string[]
                             {
                                 text,
                                 this.protocolDefinitionName,
                                 " (wymagany z dnia ",
                                 data_wersji.Value,
                                 ")"
                             });
                         }
                         else
                         {
                             string text = kom;
                             kom = string.Concat(new string[]
                             {
                                 text,
                                 ", ",
                                 this.protocolDefinitionName,
                                 " (wymagany z dnia ",
                                 data_wersji.Value,
                                 ")"
                             });
                         }
                         i++;
                         isupdatedKlk = false;
                     }
                 }
                 else
                 {
                     if (this.candidatesName == name.Value)
                     {
                         XmlNode wersja = this.candidates.SelectSingleNode("/listy").Attributes.GetNamedItem("data_aktualizacji");
                         if (wersja != null && data_wersji.Value != wersja.Value)
                         {
                             if (i == 0)
                             {
                                 string text = kom;
                                 kom = string.Concat(new string[]
                                 {
                                     text,
                                     this.candidatesName,
                                     " (wymagany z dnia ",
                                     data_wersji.Value,
                                     ")"
                                 });
                             }
                             else
                             {
                                 string text = kom;
                                 kom = string.Concat(new string[]
                                 {
                                     text,
                                     ", ",
                                     this.candidatesName,
                                     " (wymagany z dnia ",
                                     data_wersji.Value,
                                     ")"
                                 });
                             }
                             i++;
                             isupdatedKlk = false;
                         }
                     }
                     else
                     {
                         if (this.committeeName == name.Value)
                         {
                             XmlNode wersja = this.committee.SelectSingleNode("/komisja_sklad").Attributes.GetNamedItem("data_wersji");
                             if (wersja != null && data_wersji.Value != wersja.Value)
                             {
                                 if (i == 0)
                                 {
                                     string text = kom;
                                     kom = string.Concat(new string[]
                                     {
                                         text,
                                         this.committeeName,
                                         " (wymagany z dnia ",
                                         data_wersji.Value,
                                         ")"
                                     });
                                 }
                                 else
                                 {
                                     string text = kom;
                                     kom = string.Concat(new string[]
                                     {
                                         text,
                                         ", ",
                                         this.committeeName,
                                         " (wymagany z dnia ",
                                         data_wersji.Value,
                                         ")"
                                     });
                                 }
                                 i++;
                                 isupdatedKlk = false;
                             }
                         }
                         else
                         {
                             if (this.validateDefinitionName == name.Value)
                             {
                                 XmlNode wersja = this.validateDefinition.SelectSingleNode("/validate_info").Attributes.GetNamedItem("data_wersji");
                                 if (wersja != null && data_wersji.Value != wersja.Value)
                                 {
                                     if (i == 0)
                                     {
                                         string text = kom;
                                         kom = string.Concat(new string[]
                                         {
                                             text,
                                             this.validateDefinitionName,
                                             " (wymagany z dnia ",
                                             data_wersji.Value,
                                             ")"
                                         });
                                     }
                                     else
                                     {
                                         string text = kom;
                                         kom = string.Concat(new string[]
                                         {
                                             text,
                                             ", ",
                                             this.validateDefinitionName,
                                             " (wymagany z dnia ",
                                             data_wersji.Value,
                                             ")"
                                         });
                                     }
                                     i++;
                                     isupdatedKlk = false;
                                 }
                             }
                             else
                             {
                                 if (!(this.headerName == name.Value))
                                 {
                                     isKlk = false;
                                     break;
                                 }
                                 XmlNode wersja = this.header.SelectSingleNode("/akcja_wyborcza").Attributes.GetNamedItem("data_aktualizacji");
                                 if (wersja != null && data_wersji.Value != wersja.Value)
                                 {
                                     if (i == 0)
                                     {
                                         string text = kom;
                                         kom = string.Concat(new string[]
                                         {
                                             text,
                                             this.headerName,
                                             " (wymagany z dnia ",
                                             data_wersji.Value,
                                             ")"
                                         });
                                     }
                                     else
                                     {
                                         string text = kom;
                                         kom = string.Concat(new string[]
                                         {
                                             text,
                                             ", ",
                                             this.headerName,
                                             " (wymagany z dnia ",
                                             data_wersji.Value,
                                             ")"
                                         });
                                     }
                                     i++;
                                     isupdatedKlk = false;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (!isKlk)
         {
             MessageBox.Show("Nie posiadasz wszystkich potrzebnych plików klk", "Uwaga");
             base.Close();
         }
         else
         {
             if (!isupdatedKlk)
             {
                 MessageBox.Show("Nie posiadasz odpowiednich plików klk. " + kom, "Uwaga");
                 base.Close();
             }
             else
             {
                 form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - ładowanie podglądu", "Proszę czekać");
                 string controlSum = "";
                 XmlNode saveStep = this.save.SelectSingleNode("/save/step");
                 if (saveStep != null && saveStep.InnerText == "0")
                 {
                     string docXml = "";
                     XmlNode saveheader = this.save.SelectSingleNode("/save/header");
                     if (header != null)
                     {
                         docXml += header.OuterXml;
                     }
                     XmlNode savestep = this.save.SelectSingleNode("/save/step");
                     if (savestep != null)
                     {
                         docXml += savestep.OuterXml;
                     }
                     XmlNode saveform = this.save.SelectSingleNode("/save/form");
                     if (form != null)
                     {
                         docXml += saveform.OuterXml;
                     }
                     XmlNode savekomisja_sklad = this.save.SelectSingleNode("/save/komisja_sklad");
                     if (savekomisja_sklad != null)
                     {
                         docXml += savekomisja_sklad.OuterXml;
                     }
                     XmlNode savehardWarningCode = this.save.SelectSingleNode("/save/hardWarningCode");
                     if (savehardWarningCode != null)
                     {
                         docXml += savehardWarningCode.OuterXml;
                     }
                     XmlNode savesoftError = this.save.SelectSingleNode("/save/softError");
                     if (savesoftError != null)
                     {
                         docXml += savesoftError.OuterXml;
                     }
                     XmlNode savehardError = this.save.SelectSingleNode("/save/hardError");
                     if (savehardError != null)
                     {
                         docXml += savehardError.OuterXml;
                     }
                     XmlNode savehardWarning = this.save.SelectSingleNode("/save/hardWarning");
                     if (savehardWarning != null)
                     {
                         docXml += savehardWarning.OuterXml;
                     }
                     ClassMd5 k = new ClassMd5();
                     controlSum = k.CreateMD5Hash(docXml);
                 }
                 string docDefinition = protocolDefinition.Replace(".xml", ".docx");
                 printProtocolNew protocol = new printProtocolNew();
                 string[] partfilepath = this.savePath.Split(new char[]
                 {
                     '\\'
                 });
                 string[] dataPath = partfilepath[partfilepath.Length - 1].Split(new char[]
                 {
                     '-'
                 });
                 string jns = dataPath[1].Replace("Jns", "");
                 string inst = dataPath[3].Replace("Inst", "");
                 string obwod = dataPath[2].Replace("Obw", "");
                 string instJNS = dataPath[4].Replace("Obw", "");
                 string okreg = dataPath[5].Replace("Okr", "");
                 okreg = okreg.Replace(".xml", "");
                 protocol.ProtocolPrint(this.header, this.save, this.candidates, docDefinition, controlSum, false, obwod, inst, okreg, candidates, instJNS);
                 form.wait.setWaitPanel("Trwa wczytywanie licencji", "Proszę czekać");
                 bool isP = false;
                 bool isZ = false;
                 XmlNode com = this.save.SelectSingleNode("/save/komisja_sklad");
                 foreach (XmlNode j in com)
                 {
                     XmlNode funkcja = j.Attributes.GetNamedItem("funkcja");
                     if (funkcja != null)
                     {
                         if (funkcja.Value == "ZASTĘPCA")
                         {
                             isZ = true;
                         }
                         if (funkcja.Value == "PRZEWODNICZĄCY")
                         {
                             isP = true;
                         }
                     }
                     if (isZ && isP)
                     {
                         break;
                     }
                 }
                 if (isP)
                 {
                     this.zORp += "P";
                 }
                 if (isZ)
                 {
                     this.zORp += "Z";
                 }
                 this.getSignPage();
                 this.LicencesTable.CellClick += new DataGridViewCellEventHandler(this.getLicense_CellClick);
             }
         }
     }
     catch (System.Exception e2)
     {
         MessageBox.Show("Nie mozna wczytać danych. " + e2.Message, "Uwaga");
         base.Close();
     }
     form.wait.setVisible(false);
 }
Beispiel #6
0
 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();
     }
 }
Beispiel #7
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);
     }
 }
 public ProtocolForm(ProtocolsList form, XmlDocument header, string protocolDefinition, string candidates, string committee, string validateDefinition, string save, string OU, string licensePath, string version)
 {
     this.InitializeComponent();
     this.tooltipErrors = new ToolTip();
     this.isKLKCan = true;
     this.isKLK = true;
     this.isKLKPro = true;
     this.isKLKWali = true;
     this.xmlKandydaci = "";
     this.version = version;
     this.licensePath = licensePath;
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.controlsCanBeNull = new System.Collections.Generic.List<string>();
     this.codeWarning = "";
     this.wait = new WaitPanel("Wait3", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.form = form;
     this.OU = OU;
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu", "Proszę czekać");
     form.wait.setVisible(true);
     this.error = false;
     this.range = new System.Collections.Generic.Dictionary<string, ValidationRange>();
     this.lastControl = null;
     this.typeObw = "";
     this.correspondence = false;
     this.errorProvider1 = new KBWErrorProvider();
     this.errorProvider1.clearErrors();
     string[] p = protocolDefinition.Split(new char[]
     {
         '\\'
     });
     this.protocolDefinitionName = p[p.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p2 = candidates.Split(new char[]
     {
         '\\'
     });
     this.candidatesName = p2[p2.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p3 = committee.Split(new char[]
     {
         '\\'
     });
     this.committeeName = p3[p3.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p4 = validateDefinition.Split(new char[]
     {
         '\\'
     });
     this.validateDefinitionName = p4[p4.Length - 1].Replace('_', '/').Replace(".xml", "");
     string[] p5 = this.committeeName.Split(new char[]
     {
         '-'
     });
     if (p5.Length > 2)
     {
         this.headerName = p5[0] + "-" + p5[1];
     }
     form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - wczytywanie danych", "Proszę czekać");
     try
     {
         this.header = new XmlDocument();
         this.header = header;
         this.savePath = save;
         this.docxDefinition = protocolDefinition.Replace(".xml", ".docx");
         this.candDefinition = candidates;
         if (protocolDefinition != "")
         {
             this.protocolDefinition = new XmlDocument();
             if (System.IO.File.Exists(protocolDefinition))
             {
                 this.protocolDefinition.Load(protocolDefinition);
             }
             else
             {
                 this.isKLKPro = false;
             }
         }
         if (candidates != "")
         {
             this.candidates = new XmlDocument();
             if (System.IO.File.Exists(candidates))
             {
                 this.candidates.Load(candidates);
             }
             else
             {
                 this.isKLKCan = false;
             }
         }
         if (committee != "")
         {
             this.committee = new XmlDocument();
             if (System.IO.File.Exists(committee))
             {
                 this.committee.Load(committee);
             }
             else
             {
                 this.isKLK = false;
             }
         }
         if (validateDefinition != "")
         {
             this.validateDefinition = new XmlDocument();
             if (System.IO.File.Exists(validateDefinition))
             {
                 this.validateDefinition.Load(validateDefinition);
             }
             else
             {
                 this.isKLKWali = false;
             }
         }
         if (save != "")
         {
             this.save = new XmlDocument();
             if (System.IO.File.Exists(save))
             {
                 this.save.Load(save);
             }
         }
         string[] partfilepath = this.savePath.Split(new char[]
         {
             '\\'
         });
         string[] dataPath = partfilepath[partfilepath.Length - 1].Split(new char[]
         {
             '-'
         });
         string jns = dataPath[1].Replace("Jns", "");
         string inst = dataPath[3].Replace("Inst", "");
         string obwod = dataPath[2].Replace("Obw", "");
         this.instJNS = dataPath[4];
         string okreg = dataPath[5].Replace("Okr", "");
         okreg = okreg.Replace(".xml", "");
         string organNazwa = "";
         XmlNode headerRoot = header.SelectSingleNode("/akcja_wyborcza/jns");
         foreach (XmlNode xObwod in headerRoot)
         {
             if (xObwod.Attributes["nr"].InnerText == obwod)
             {
                 foreach (XmlNode xInst in xObwod)
                 {
                     if (xInst.Attributes["kod"].InnerText == inst)
                     {
                         foreach (XmlNode xobw in xInst)
                         {
                             if (xobw.Attributes["nr"].InnerText == okreg && System.Convert.ToInt32(xInst.Attributes["inst_jns"].InnerText) == System.Convert.ToInt32(this.instJNS))
                             {
                                 organNazwa = xInst.Attributes["organNazwa"].InnerText;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         if (inst == "WBP")
         {
             if (jns.Substring(0, 4) == "1465" && jns.Length == 6)
             {
                 if (candidates != "")
                 {
                     string candidates2 = candidates.Replace(jns + "-" + okreg + ".xml", "146501-1.xml");
                     this.candidates = new XmlDocument();
                     if (System.IO.File.Exists(candidates2))
                     {
                         this.candidates.Load(candidates2);
                         this.isKLKCan = true;
                     }
                     else
                     {
                         this.isKLKCan = false;
                     }
                 }
             }
         }
         if (inst == "RDA")
         {
             if (jns.Length < 6)
             {
                 while (jns.Length < 6)
                 {
                     jns = "0" + jns;
                 }
             }
             if (jns[2] == '7' || jns[2] == '6')
             {
                 if (jns.Substring(0, 4) == "1465" && organNazwa == "m.st.")
                 {
                     this.protocolDefinition = new XmlDocument();
                     string protocolDefinition2 = protocolDefinition.Replace(".xml", "_M.xml");
                     if (System.IO.File.Exists(protocolDefinition2))
                     {
                         this.protocolDefinition.Load(protocolDefinition2);
                         this.isKLKPro = true;
                     }
                     else
                     {
                         this.isKLKPro = false;
                     }
                     if (validateDefinition != "")
                     {
                         this.validateDefinition = new XmlDocument();
                         string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_M_Walidacja.xml");
                         if (System.IO.File.Exists(validateDefinition2))
                         {
                             this.validateDefinition.Load(validateDefinition2);
                             this.isKLKWali = true;
                         }
                         else
                         {
                             this.isKLKWali = false;
                         }
                     }
                     if (candidates != "")
                     {
                         string candidates2 = candidates.Replace(jns + "-" + okreg + ".xml", "146501-" + okreg + ".xml");
                         this.candidates = new XmlDocument();
                         if (System.IO.File.Exists(candidates2))
                         {
                             this.candidates.Load(candidates2);
                             this.isKLKCan = true;
                         }
                         else
                         {
                             this.isKLK = false;
                             this.isKLKCan = false;
                         }
                     }
                 }
                 if (jns.Substring(0, 4) != "1465")
                 {
                     if (protocolDefinition != "")
                     {
                         this.protocolDefinition = new XmlDocument();
                         string protocolDefinition2 = protocolDefinition.Replace(".xml", "_M.xml");
                         if (System.IO.File.Exists(protocolDefinition2))
                         {
                             this.protocolDefinition.Load(protocolDefinition2);
                             this.isKLKPro = true;
                         }
                         else
                         {
                             this.isKLKPro = false;
                         }
                     }
                     if (validateDefinition != "")
                     {
                         this.validateDefinition = new XmlDocument();
                         string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_M_Walidacja.xml");
                         if (System.IO.File.Exists(validateDefinition2))
                         {
                             this.validateDefinition.Load(validateDefinition2);
                             this.isKLKWali = true;
                         }
                         else
                         {
                             this.isKLKWali = false;
                         }
                     }
                 }
             }
             if (jns.Substring(0, 4) == "1465" && organNazwa == "Dzielnicy")
             {
                 if (protocolDefinition != "")
                 {
                     this.protocolDefinition = new XmlDocument();
                     string protocolDefinition2 = protocolDefinition.Replace(".xml", "_D.xml");
                     if (System.IO.File.Exists(protocolDefinition2))
                     {
                         this.protocolDefinition.Load(protocolDefinition2);
                         this.isKLKPro = true;
                     }
                     else
                     {
                         this.isKLKPro = false;
                     }
                 }
                 if (validateDefinition != "")
                 {
                     this.validateDefinition = new XmlDocument();
                     string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_D_Walidacja.xml");
                     if (System.IO.File.Exists(validateDefinition2))
                     {
                         this.validateDefinition.Load(validateDefinition2);
                         this.isKLKWali = true;
                     }
                     else
                     {
                         this.isKLKWali = false;
                     }
                 }
             }
         }
         if (this.isKLKCan)
         {
             this.deletedCandidates = this.countOfDeletedCandidate();
             if (this.isOneCandidate())
             {
                 this.deletedCandidates = 1;
                 if (protocolDefinition != "")
                 {
                     this.protocolDefinition = new XmlDocument();
                     string protocolDefinition2 = protocolDefinition.Replace(".xml", "_1.xml");
                     if (System.IO.File.Exists(protocolDefinition2))
                     {
                         this.protocolDefinition.Load(protocolDefinition2);
                         this.isKLKPro = true;
                     }
                     else
                     {
                         this.isKLKPro = false;
                     }
                 }
                 if (validateDefinition != "")
                 {
                     this.validateDefinition = new XmlDocument();
                     string validateDefinition2 = validateDefinition.Replace("_Walidacja.xml", "_1_Walidacja.xml");
                     if (System.IO.File.Exists(validateDefinition2))
                     {
                         this.validateDefinition.Load(validateDefinition2);
                         this.isKLKWali = true;
                     }
                     else
                     {
                         this.isKLKWali = false;
                     }
                 }
             }
         }
     }
     catch (XmlException e)
     {
         MessageBox.Show("Nieprawidłowy XML: " + e.Message, "Błąd");
     }
     bool go = false;
     if (this.isKLK && this.isKLKCan && this.isKLKPro && this.isKLKWali)
     {
         go = this.checkProtocol(this.save, this.savePath);
     }
     if (this.isKLK && this.isKLKCan && this.isKLKPro && this.isKLKWali)
     {
         if (go)
         {
             this.committeePanel.Visible = false;
             this.goodcertificate = false;
             this.countcandidatesoflist = new System.Collections.Generic.List<int[]>();
             this.lastValidators = new System.Collections.Generic.List<ValidationPatern>();
             this.candidatesRule = new System.Collections.Generic.Dictionary<string, string>();
             this.typeValidation = new System.Collections.Generic.Dictionary<string, string>();
             form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - ładowanie nagłówka", "Proszę czekać");
             this.getHeader();
             form.wait.setWaitPanel("Trwa otwieranie formularza protokołu - ładowanie pierwszego kroku", "Proszę czekać");
             this.getCalculator();
             this.Form1panel.Visible = true;
             this.Form1panel.Width = 776;
             this.Form2panel.Visible = false;
             this.Form2panel.Width = 776;
             this.committeePanel.Visible = false;
             this.committeePanel.Width = 776;
             this.SummationPanel.Visible = false;
             this.SummationPanel.Width = 776;
             this.signPanel.Visible = false;
             this.signPanel.Width = 776;
             this.raportPanel.Visible = false;
             this.raportPanel.Width = 776;
             this.protocolHeader.Width = 776;
             this.protocolForm1.Enabled = true;
             this.protocolForm2.Enabled = false;
             this.protocolSummation.Enabled = false;
             this.protocolCommittee.Enabled = false;
             this.signProtocol.Enabled = false;
             this.currentStep = 1;
             this.personList.CellClick += new DataGridViewCellEventHandler(this.committee_CellClick);
             this.currentCommittee = false;
             this.clicNext = false;
             this.imported = false;
             this.web = new WebBrowser();
             this.web.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(ProtocolForm.webBrowser_DocumentCompleted);
             form.wait.setVisible(false);
             this.LicencesTable.CellClick += new DataGridViewCellEventHandler(this.getLicense_CellClick);
             this.codeBarText = "";
             this.codeBarCode = "";
         }
         else
         {
             MessageBox.Show("Nie jesteś uprowniony do wypełniana tego protokołu.", "Uwaga");
             base.Close();
         }
     }
     else
     {
         MessageBox.Show("Nie pobrano wszystkich plików klk.", "Uwaga");
         base.Close();
     }
 }
 public ProtocolForm()
 {
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.licensePath = "";
     this.lastControl = null;
     this.controlsCanBeNull = new System.Collections.Generic.List<string>();
     this.InitializeComponent();
     this.codeWarning = "";
     this.typeObw = "";
     this.headerName = "";
     this.committeeName = "";
     this.candidatesName = "";
     this.protocolDefinitionName = "";
     this.validateDefinitionName = "";
     this.docxDefinition = "";
     this.protocolDefinition = new XmlDocument();
     this.candidates = new XmlDocument();
     this.committee = new XmlDocument();
     this.validateDefinition = new XmlDocument();
     this.header = new XmlDocument();
     this.lastValidators = new System.Collections.Generic.List<ValidationPatern>();
     this.countcandidatesoflist = new System.Collections.Generic.List<int[]>();
     this.candidatesRule = new System.Collections.Generic.Dictionary<string, string>();
     this.errorProvider1 = new KBWErrorProvider();
     this.error = false;
     this.range = new System.Collections.Generic.Dictionary<string, ValidationRange>();
     this.personList.Visible = false;
     this.committeePanel.Visible = false;
     this.currentStep = 1;
     this.goodcertificate = false;
     this.personList.CellClick += new DataGridViewCellEventHandler(this.committee_CellClick);
     this.currentCommittee = false;
     this.clicNext = false;
     this.imported = false;
     this.wait = new WaitPanel("Wait3", base.Width, base.Height);
     this.form = null;
     this.typeValidation = new System.Collections.Generic.Dictionary<string, string>();
     this.codeBarText = "";
     this.codeBarCode = "";
     this.xmlKandydaci = "";
 }
Beispiel #10
0
 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();
 }
Beispiel #11
0
 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();
     }
 }
 public ProtocolsList(string filepath, Start start, string licensepath, string version)
 {
     this.InitializeComponent();
     this.start = start;
     start.wait.setWaitPanel("Trwa wczytywanie protokołów", "Proszę czekać");
     start.wait.setVisible(true);
     this.version = version;
     this.licensepath = licensepath;
     this.erros = false;
     this.Text = this.Text + " (" + Kalkulator1.instalClass.Version.getVersion().ToString() + ")";
     this.path = System.IO.Path.GetTempPath() + "KBW";
     this.electionData = new System.DateTime(1, 1, 1, 0, 0, 0);
     DataTable dt = new DataTable();
     this.con = new Connection();
     this.header = new XmlDocument();
     System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate(filepath);
     string subjectCert = cert.Subject;
     string[] tab = subjectCert.Split(new string[]
     {
         ", "
     }, System.StringSplitOptions.None);
     for (int i = 0; i < tab.Length; i++)
     {
         if (System.Text.RegularExpressions.Regex.IsMatch(tab[i], "^OU="))
         {
             string[] tmp = tab[i].Replace("OU=", "").Split(new char[]
             {
                 '-'
             });
             this.electoralEampaignURL = tmp[0];
             this.electoralEampaignSave = tmp[0].Replace('/', '_');
             this.electoralEampaignSave = this.electoralEampaignSave.Replace(" ", "");
             this.jns = tmp[1];
             this.role = tmp[2];
             if (this.role == "P" || this.role == "Z")
             {
                 this.circuit = tmp[3];
             }
             if (this.role == "O" || this.role == "A")
             {
                 this.panWyszukiwanie.Visible = true;
                 this.txtWyszukaj.Focus();
             }
             break;
         }
     }
     this.powiat = false;
     this.wait = new WaitPanel("Wait2", base.Width, base.Height);
     base.Controls.Add(this.wait.getPanel());
     base.Controls[this.wait.getName()].BringToFront();
     this.protocolsTable.CellClick += new DataGridViewCellEventHandler(this.getProtocol_CellClick);
     if (!System.IO.Directory.Exists(this.path + "\\electoralEampaign"))
     {
         try
         {
             System.IO.Directory.CreateDirectory(this.path + "\\electoralEampaign");
         }
         catch (System.ArgumentNullException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"electoralEampaign\"", "Error");
         }
         catch (System.ArgumentException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"electoralEampaign\"", "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 \"electoralEampaign\"", "Error");
         }
         catch (System.IO.DirectoryNotFoundException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"electoralEampaign\"", "Error");
         }
         catch (System.NotSupportedException)
         {
             MessageBox.Show("Nieprawidłowy format ścieżki. Nie można utworzyć katalogu \"electoralEampaign\"", "Error");
         }
         catch (System.IO.IOException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"electoralEampaign\"", "Error");
         }
     }
     if (!System.IO.Directory.Exists(this.path + "\\ProtocolsDef"))
     {
         try
         {
             System.IO.Directory.CreateDirectory(this.path + "\\ProtocolsDef");
         }
         catch (System.ArgumentNullException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"ProtocolsDef\"", "Error");
         }
         catch (System.ArgumentException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"ProtocolsDef\"", "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 \"ProtocolsDef\"", "Error");
         }
         catch (System.IO.DirectoryNotFoundException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"ProtocolsDef\"", "Error");
         }
         catch (System.NotSupportedException)
         {
             MessageBox.Show("Nieprawidłowy format ścieżki. Nie można utworzyć katalogu \"ProtocolsDef\"", "Error");
         }
         catch (System.IO.IOException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"ProtocolsDef\"", "Error");
         }
     }
     if (!System.IO.Directory.Exists(this.path + "\\saves"))
     {
         try
         {
             System.IO.Directory.CreateDirectory(this.path + "\\saves");
         }
         catch (System.ArgumentNullException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"saves\"", "Error");
         }
         catch (System.ArgumentException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"saves\"", "Error");
         }
         catch (System.UnauthorizedAccessException)
         {
             MessageBox.Show("Nie masz uprawnień do tworzenia katalogów. Otwórz aplikacje jako administrator.", "Uwaga");
         }
         catch (System.IO.PathTooLongException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"saves\"", "Error");
         }
         catch (System.IO.DirectoryNotFoundException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"saves\"", "Error");
         }
         catch (System.NotSupportedException)
         {
             MessageBox.Show("Nieprawidłowy format ścieżki. Nie można utworzyć katalogu \"saves\"", "Error");
         }
         catch (System.IO.IOException)
         {
             MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"saves\"", "Error");
         }
     }
     this.getKLK(true);
     this.getProtocols(true);
     start.wait.setVisible(false);
 }
Beispiel #13
0
 public Start()
 {
     try
     {
         this.InitializeComponent();
         this.Text = "Kalkulator (" + Kalkulator1.instalClass.Version.getVersion().ToString() + ")";
         Start.listaPlikow.Add("START");
         this.path = System.IO.Path.GetTempPath() + "KBW";
         if (!System.IO.Directory.Exists(this.path))
         {
             try
             {
                 System.IO.Directory.CreateDirectory(this.path);
             }
             catch (System.ArgumentNullException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.ArgumentException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "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 \"KBW\"", "Error");
             }
             catch (System.IO.DirectoryNotFoundException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.NotSupportedException)
             {
                 MessageBox.Show("Nieprawidłowy format ścieżki. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
             catch (System.IO.IOException)
             {
                 MessageBox.Show("Nieprawidłowa ścieżka. Nie można utworzyć katalogu \"KBW\"", "Error");
             }
         }
         if (!System.IO.Directory.Exists(this.path + "\\tmp"))
         {
             Instal inst = new Instal(this.path);
         }
         if (System.IO.Directory.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp"))
         {
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksport.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksport.xml");
             }
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\import.xml");
             }
             if (!System.IO.File.Exists(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml"))
             {
                 System.IO.File.Create(System.IO.Path.GetTempPath() + "KBW\\tmp\\eksportCode.xml");
             }
         }
         this.logged = false;
         this.certificate = new Certificate();
         this.con = new Connection();
         this.LicencesTable.CellClick += new DataGridViewCellEventHandler(this.LicencesTable_CellClick);
         this.waitLicenses.CellClick += new DataGridViewCellEventHandler(this.waitLicenses_CellClick);
         this.wait = new WaitPanel("Wait1", base.Width, base.Height);
         base.Controls.Add(this.wait.getPanel());
         base.Controls[this.wait.getName()].BringToFront();
         this.getActiveLicense();
         this.getOtherLicense();
         if (!Kalkulator1.instalClass.Version.newApp())
         {
             MessageBox.Show("Twoja wersja kalkulatora wyborczego jest nieaktualna.", "Uwaga");
         }
     }
     catch (System.Exception)
     {
     }
 }