private void drukToolStripMenuItem_Click(object sender, System.EventArgs e) { this.wait.setWaitPanel("Trwa przygotowanie do druku protokołu", "Proszę czekać"); this.wait.setVisible(true); if (this.currentStep != 0) { XmlNode status = this.save.SelectSingleNode("/save/status"); if (status != null && !(status.InnerText == "podpisany") && !(status.InnerText == "wysłany")) { this.saves(this.currentStep); } else { System.Threading.Thread.Sleep(2000); } } else { System.Threading.Thread.Sleep(2000); } this.save.Load(this.savePath); string controlSum = ""; if (this.currentStep == 0) { string docXml = ""; XmlNode header = this.save.SelectSingleNode("/save/header"); if (header != null) { docXml += header.OuterXml; } XmlNode step = this.save.SelectSingleNode("/save/step"); if (step != null) { docXml += step.OuterXml; } XmlNode form = this.save.SelectSingleNode("/save/form"); if (form != null) { docXml += form.OuterXml; } XmlNode komisja_sklad = this.save.SelectSingleNode("/save/komisja_sklad"); if (komisja_sklad != null) { docXml += komisja_sklad.OuterXml; } XmlNode hardWarningCode = this.save.SelectSingleNode("/save/hardWarningCode"); if (hardWarningCode != null) { docXml += hardWarningCode.OuterXml; } XmlNode softError = this.save.SelectSingleNode("/save/softError"); if (softError != null) { docXml += softError.OuterXml; } XmlNode hardError = this.save.SelectSingleNode("/save/hardError"); if (hardError != null) { docXml += hardError.OuterXml; } XmlNode hardWarning = this.save.SelectSingleNode("/save/hardWarning"); if (hardWarning != null) { docXml += hardWarning.OuterXml; } ClassMd5 i = new ClassMd5(); controlSum = i.CreateMD5Hash(docXml); } try { 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 instJNS = dataPath[4]; string obwod = dataPath[2].Replace("Obw", ""); string okreg = dataPath[5].Replace("Okr", ""); okreg = okreg.Replace(".xml", ""); protocol.ProtocolPrint(this.header, this.save, this.candidates, this.docxDefinition, controlSum, false, obwod, inst, okreg, this.candDefinition, instJNS); } catch (System.Exception ex) { MessageBox.Show("Komunikat błedu: funkcja drukToolStripMenuItem_Click (wywołanie p.ProtocolPrint(...)): " + ex.Message, "Uwaga"); } this.wait.setVisible(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); }
private void getProtocol_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.ColumnIndex == this.protocolsTable.Columns["fill"].Index) { if (e.RowIndex >= 0) { try { int result = System.DateTime.Compare(this.electionData, System.DateTime.Now); result = -1; if (result <= 0) { try { object st = this.protocolsTable.Rows[e.RowIndex].Cells["Status"].Value; if (st != null && st.ToString().ToLower() != "podpisany" && st.ToString().ToLower() != "wysłany") { object protokol = this.protocolsTable.Rows[e.RowIndex].Cells["Protokol"].Value; object jns = this.protocolsTable.Rows[e.RowIndex].Cells["Gmina"].Value; object obw = this.protocolsTable.Rows[e.RowIndex].Cells["Obwód"].Value; object inst = this.protocolsTable.Rows[e.RowIndex].Cells["Instytucja"].Value; object okr = this.protocolsTable.Rows[e.RowIndex].Cells["Okręg"].Value; if (jns != null && obw != null && inst != null && okr != null && protokol != null) { try { string save = ""; string[] protocolpart = protokol.ToString().Split(new char[] { '-' }); string instJNS = protocolpart[4]; string[] okr2 = okr.ToString().Split(new char[] { ' ' }); save = this.path + "\\saves\\" + protokol.ToString(); string candidates = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), "-", instJNS, "-", okr2[0], ".xml" }); string protocolDefinition = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), ".xml" }); string committee = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", this.jns, "-", obw.ToString(), ".xml" }); string validateDefinition = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), "_Walidacja.xml" }); string OU = ""; if (this.role == "P" || this.role == "Z") { OU = string.Concat(new object[] { this.electoralEampaignURL.Trim(new char[] { ' ' }), "-", jns, "-", this.role, "-", this.circuit }); } if (this.role == "O" || this.role == "A") { OU = string.Concat(new object[] { this.electoralEampaignURL.Trim(new char[] { ' ' }), "-", jns, "-", this.role }); } ProtocolForm pf = new ProtocolForm(this, this.header, protocolDefinition, candidates, committee, validateDefinition, save, OU, this.licensepath, this.version); try { pf.ShowDialog(); } catch (System.Exception ex) { this.createProtocols(); } this.refreshListOfProtocols(); } catch (XmlException) { MessageBox.Show("Nieprawidłowy XML", "Error"); } } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error"); } } else { MessageBox.Show("Protokoły wypełniać można od " + this.electionData.ToShortDateString(), "Komunikat"); } } catch (System.Exception ex) { MessageBox.Show("Fill: " + ex.Message, "Error"); } } } if (e.ColumnIndex == this.protocolsTable.Columns["new"].Index) { try { if (e.RowIndex >= 0) { object protokol = this.protocolsTable.Rows[e.RowIndex].Cells["Protokol"].Value; object jns = this.protocolsTable.Rows[e.RowIndex].Cells["Gmina"].Value; object obw = this.protocolsTable.Rows[e.RowIndex].Cells["Obwód"].Value; object inst = this.protocolsTable.Rows[e.RowIndex].Cells["Instytucja"].Value; object okr = this.protocolsTable.Rows[e.RowIndex].Cells["Okręg"].Value; object status = this.protocolsTable.Rows[e.RowIndex].Cells["Status"].Value; if (jns != null && obw != null && inst != null && okr != null) { try { if (protokol != null && status != null && (status.ToString().ToLower() == "podpisany" || status.ToString().ToLower() == "wysłany")) { DialogResult dr = MessageBox.Show("Utworzenie nowego protokołu spowoduje nadpisanie wcześniej zachowanych danych. Czy kontynuować?", "Nowy protokół", MessageBoxButtons.YesNo); DialogResult dialogResult = dr; if (dialogResult == DialogResult.No) { return; } string protokolname = protokol.ToString(); string[] partname = protokol.ToString().Split(new char[] { ' ' }); if (partname.Length >= 2) { protokolname = partname[0]; } int num = System.IO.Directory.GetFiles(this.path + "\\saves", protokolname + "*.xml").Length; string namefile = protokolname.Replace(".xml", ""); namefile = namefile + " " + (num + 1).ToString(); System.IO.File.Move(this.path + "\\saves\\" + protokol.ToString(), this.path + "\\saves\\" + namefile + ".xml"); } System.IO.StreamWriter sw = new System.IO.StreamWriter(this.path + "\\saves\\" + protokol.ToString(), false); sw.Write("<?xml version=\"1.0\"?><save><status>niewypełniony</status></save>"); sw.Close(); this.getProtocols(false); if (jns != null && obw != null && inst != null && okr != null) { try { string save = ""; string[] protocolpart = protokol.ToString().Split(new char[] { '-' }); string instJNS = protocolpart[4]; string[] okr2 = okr.ToString().Split(new char[] { ' ' }); save = this.path + "\\saves\\" + protokol.ToString(); string candidates = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), "-", instJNS, "-", okr2[0], ".xml" }); string protocolDefinition = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), ".xml" }); string committee = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", this.jns, "-", obw.ToString(), ".xml" }); string validateDefinition = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), "_Walidacja.xml" }); string OU = ""; if (this.role == "P" || this.role == "Z") { OU = string.Concat(new object[] { this.electoralEampaignURL.Trim(new char[] { ' ' }), "-", jns, "-", this.role, "-", this.circuit }); } if (this.role == "O") { OU = string.Concat(new object[] { this.electoralEampaignURL.Trim(new char[] { ' ' }), "-", jns, "-", this.role }); } ProtocolForm pf = new ProtocolForm(this, this.header, protocolDefinition, candidates, committee, validateDefinition, save, OU, this.licensepath, this.version); try { pf.ShowDialog(); } catch (System.Exception) { this.createProtocols(); } this.refreshListOfProtocols(); } catch (XmlException) { MessageBox.Show("Nieprawidłowy XML", "Error"); } } } catch (XmlException) { MessageBox.Show("Nieprawidłowy XML", "Error"); } } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error"); } } if (e.ColumnIndex == this.protocolsTable.Columns["print"].Index | e.ColumnIndex == this.protocolsTable.Columns["pdf"].Index) { try { if (e.RowIndex >= 0) { object protokol = this.protocolsTable.Rows[e.RowIndex].Cells["Protokol"].Value; object jns = this.protocolsTable.Rows[e.RowIndex].Cells["Gmina"].Value; object obw = this.protocolsTable.Rows[e.RowIndex].Cells["Obwód"].Value; object inst = this.protocolsTable.Rows[e.RowIndex].Cells["Instytucja"].Value; object okr = this.protocolsTable.Rows[e.RowIndex].Cells["Okręg"].Value; if (jns != null && obw != null && inst != null && okr != null && protokol != null) { this.wait.setWaitPanel("Trwa przygotowanie do druku", "Druk"); if (e.ColumnIndex == this.protocolsTable.Columns["pdf"].Index) { this.wait.setWaitPanel("Trwa generowanie PDF", "PDF"); } this.wait.setVisible(true); try { string save = ""; string[] protocolpart = protokol.ToString().Split(new char[] { '-' }); string instJNS = protocolpart[4]; string[] okr2 = okr.ToString().Split(new char[] { ' ' }); save = this.path + "\\saves\\" + protokol.ToString(); string candidates = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), "-", instJNS, "-", okr2[0], ".xml" }); string protocolDefinition = string.Concat(new string[] { this.path, "\\ProtocolsDef\\", this.electoralEampaignSave, "-", inst.ToString(), ".xml" }); string docDefinition = protocolDefinition.Replace(".xml", ".docx"); XmlDocument protocolDefinition2 = new XmlDocument(); XmlDocument save2 = new XmlDocument(); XmlDocument candidates2 = new XmlDocument(); protocolDefinition2.Load(protocolDefinition); save2.Load(save); candidates2.Load(candidates); string controlSum = ""; XmlNode saveStep = save2.SelectSingleNode("/save/step"); if (saveStep != null && saveStep.InnerText == "0") { string docXml = ""; XmlNode header = save2.SelectSingleNode("/save/header"); if (header != null) { docXml += header.OuterXml; } XmlNode step = save2.SelectSingleNode("/save/step"); if (step != null) { docXml += step.OuterXml; } XmlNode form = save2.SelectSingleNode("/save/form"); if (form != null) { docXml += form.OuterXml; } XmlNode komisja_sklad = save2.SelectSingleNode("/save/komisja_sklad"); if (komisja_sklad != null) { docXml += komisja_sklad.OuterXml; } XmlNode hardWarningCode = save2.SelectSingleNode("/save/hardWarningCode"); if (hardWarningCode != null) { docXml += hardWarningCode.OuterXml; } XmlNode softError = save2.SelectSingleNode("/save/softError"); if (softError != null) { docXml += softError.OuterXml; } XmlNode hardError = save2.SelectSingleNode("/save/hardError"); if (hardError != null) { docXml += hardError.OuterXml; } XmlNode hardWarning = save2.SelectSingleNode("/save/hardWarning"); if (hardWarning != null) { docXml += hardWarning.OuterXml; } ClassMd5 i = new ClassMd5(); controlSum = i.CreateMD5Hash(docXml); } printProtocolNew p = new printProtocolNew(); if (e.ColumnIndex == this.protocolsTable.Columns["print"].Index) { p.ProtocolPrint(this.header, save2, candidates2, docDefinition, controlSum, false, obw.ToString(), inst.ToString(), okr.ToString(), candidates, instJNS); } else { p.ProtocolPrint(this.header, save2, candidates2, docDefinition, controlSum, true, obw.ToString(), inst.ToString(), okr.ToString(), candidates, instJNS); } } catch (XmlException) { MessageBox.Show("Nieprawidłowy XML", "Error"); } } this.wait.setVisible(false); } } catch (System.Exception ex) { MessageBox.Show("Print: " + ex.Message, "Error"); } } if (e.ColumnIndex == this.protocolsTable.Columns["send"].Index) { try { if (e.RowIndex >= 0) { object st = this.protocolsTable.Rows[e.RowIndex].Cells["Status"].Value; if (st != null && (st.ToString().ToLower() == "podpisany" || st.ToString().ToLower() == "wysłany")) { object protokol = this.protocolsTable.Rows[e.RowIndex].Cells["Protokol"].Value; object jns = this.protocolsTable.Rows[e.RowIndex].Cells["Gmina"].Value; object obw = this.protocolsTable.Rows[e.RowIndex].Cells["Obwód"].Value; object inst = this.protocolsTable.Rows[e.RowIndex].Cells["Instytucja"].Value; object okr = this.protocolsTable.Rows[e.RowIndex].Cells["Okręg"].Value; if (jns != null && obw != null && inst != null && okr != null && protokol != null) { try { string save = ""; string[] okr2 = okr.ToString().Split(new char[] { ' ' }); save = this.path + "\\saves\\" + protokol.ToString(); System.IO.StreamReader sr = new System.IO.StreamReader(save); string fileXML = sr.ReadToEnd(); sr.Close(); fileXML = fileXML.Replace("<status>wysłany</status>", "<status>podpisany</status>"); if (this.con.IsAvailableNetworkActive()) { this.erros = false; this.send = false; Eksport ex2 = new Eksport(fileXML, true, this); try { ex2.ShowDialog(); } catch (System.Exception) { } if (this.send) { this.send = false; fileXML = fileXML.Replace("<status>podpisany</status>", "<status>wysłany</status>"); System.IO.StreamWriter sw = new System.IO.StreamWriter(save); sw.Write(fileXML); sw.Close(); this.refreshListOfProtocols(); } if (!this.send && this.erros) { XmlDocument saveTmp = new XmlDocument(); fileXML = fileXML.Replace("<status>podpisany</status>", "<status>roboczy</status>"); fileXML = fileXML.Replace("<status>wysłany</status>", "<status>roboczy</status>"); saveTmp.LoadXml(fileXML); XmlNode root = saveTmp.DocumentElement; try { root.RemoveChild(root.SelectSingleNode("/save/codeBar")); } catch (System.Exception) { } try { root.RemoveChild(root.SelectSingleNode("/save/Signature")); } catch (System.Exception) { } saveTmp.Save(save); this.refreshListOfProtocols(); } } else { MessageBox.Show("Protokół nie został wysłany z powodu braku Internetu."); } } catch (XmlException) { MessageBox.Show("Nieprawidłowy XML", "Error"); } catch (System.NullReferenceException) { MessageBox.Show("Podanno inny xml niz header", "Error"); } } } if (st != null && (st.ToString().ToLower() == "roboczy" || (st != null && st.ToString().ToLower() == "niewypełniony"))) { MessageBox.Show("Nie można wysłać protokołu o statusie: \"" + st.ToString().ToLower() + "\"", "Komunikat"); } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error"); } } if (e.ColumnIndex == this.protocolsTable.Columns["save1"].Index) { if (e.RowIndex >= 0) { object protokol = this.protocolsTable.Rows[e.RowIndex].Cells["Protokol"].Value; string savePath = this.path + "\\saves\\" + protokol.ToString(); System.IO.StreamReader sr = new System.IO.StreamReader(savePath); string file = sr.ReadToEnd(); sr.Close(); string[] nameFile = savePath.Split(new char[] { '\\' }); SaveFileDialog wnd = new SaveFileDialog(); wnd.Filter = "(*.xml)|*.xml"; wnd.FileName = nameFile[nameFile.Length - 1]; if (wnd.ShowDialog() != DialogResult.Cancel) { this.wait.setWaitPanel("Trwa eksportowanie protokołu", "Proszę czekać"); this.wait.setVisible(true); if (wnd.CheckPathExists) { string name = wnd.FileName; try { if (name != null && name != "" && name != nameFile[nameFile.Length - 1]) { System.IO.StreamWriter sw = new System.IO.StreamWriter(name, false); sw.Write(file); sw.Close(); } this.wait.setVisible(false); } catch (System.UnauthorizedAccessException) { MessageBox.Show("Nie jestes uprawniony do zapisania pliku we wskazanym miejscu", "Uwaga"); } } } } } } catch (System.ArgumentOutOfRangeException ex_17A7) { } catch (System.Exception ex) { } }