private void Button_Insert_LKT_Click(object sender, RoutedEventArgs e) { if ((ComboBox_DestinationProtocol.SelectedIndex >= 0) && (TextArea_DestinationAddress.Text.Length > 0) && (TextArea_DestinationAddress.Text.Length > 0)) { ProtocolsList destinationProtocol = getProtocolFromID(ComboBox_DestinationProtocol.SelectedItem); if (ListBox_ProtocolsList.SelectedIndex == 2) { LKTS_list.Add(new LookUpTable_Element(int.Parse(TextArea_SourceAddress.Text), int.Parse(TextArea_DestinationAddress.Text), destinationProtocol, Convert.ToByte(ComboBox_LIN_PIDType.SelectedIndex), byte.Parse(TextArea_LIN_BytesOnPID.Text))); } else { LKTS_list.Add(new LookUpTable_Element(int.Parse(TextArea_SourceAddress.Text), int.Parse(TextArea_DestinationAddress.Text), destinationProtocol)); } } }
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; }
public Eksport(string xml, bool send, ProtocolsList p) { this.p2 = p; this.InitializeComponent(); this.con = new Connection(); this.c = new Certificate(); this.savePath = xml; if (send) { this.Text = "Wysyłanie protokołu na serwer"; } else { this.Text = "Eksport"; } this.path = (this.path = System.IO.Path.GetTempPath() + "KBW"); this.label4.Text = "Trwa wysyłanie protokołu"; this.password.Visible = false; this.log.Visible = false; this.send2_Click(); base.Close(); }
public LookUpTable_Element(int sa, int da, ProtocolsList dp, byte PIDType, byte PIDBytes) { sourceAddress = sa; destinationAddress = da; destinationProtocol = dp; LIN_PIDTypeValue = PIDType; switch (LIN_PIDTypeValue) { case 0: LIN_PIDTypeText = "Publisher"; break; case 1: LIN_PIDTypeText = "Subscriber"; break; } LIN_PIDBytes = PIDBytes; switch (destinationProtocol) { case ProtocolsList.CAN: destinationProtocolText = "CAN"; break; case ProtocolsList.I2C: destinationProtocolText = "I2C"; break; case ProtocolsList.LIN: destinationProtocolText = "LIN"; break; case ProtocolsList.RS232: destinationProtocolText = "RS232"; break; } }
public LookUpTable_Element(int sa, int da, ProtocolsList dp) { sourceAddress = sa; destinationAddress = da; destinationProtocol = dp; switch (destinationProtocol) { case ProtocolsList.CAN: destinationProtocolText = "CAN"; break; case ProtocolsList.I2C: destinationProtocolText = "I2C"; break; case ProtocolsList.LIN: destinationProtocolText = "LIN"; break; case ProtocolsList.RS232: destinationProtocolText = "RS232"; break; } }
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); }