Пример #1
0
 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;
 }
Пример #2
0
 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);
 }
Пример #3
0
 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 = "";
 }
Пример #4
0
 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();
     }
 }
Пример #5
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)
     {
     }
 }