private void performChainContainer(string document_id, Dictionary <string, byte[]> additionalTicketsToBeChained) { APICon.Container.ChainContainer container = new APICon.Container.ChainContainer(); Event[] e = controller.getAllBindedEventsInChain(document_id); foreach (Event ev in e) { //Console.WriteLine(ev.ToString()); GetContentResponse cr = controller.getUPDDocumentContent(ev.document_id); string name = GetTextFromXml(cr.body, "Файл[@*]/@ИдФайл"); container.AddEntry(name + ".xml", Utils.Base64DecodeToBytes(cr.body, "windows-1251")); container.AddEntry(name + GetSignExtensionForContainer(), GetSignEncodedBodyForContainer(cr.sign)); if (ev.event_status.StartsWith("УПД")) { byte[] pdf = Utils.Base64DecodeToBytes(controller.GetPdf(ev.document_id), "UTF-8"); container.AddEntry(name + ".pdf", pdf); container.docFunction = GetTextFromXml(cr.body, "Файл/Документ/@Функция"); string[] s = { "КСЧФ", "КСЧФДИС", "ДИС" }; container.docNumber = GetTextFromXml(cr.body, s.Contains(container.docFunction) ? "Файл/Документ/СвКСчФ/@НомерКСчФ" : "Файл/Документ/СвСчФакт/@НомерСчФ"); container.docDate = GetTextFromXml(cr.body, s.Contains(container.docFunction) ? "Файл/Документ/СвКСчФ/@ДатаКСчФ" : "Файл/Документ/СвСчФакт/@ДатаСчФ"); container.SetContainerName(); } } foreach (string key in additionalTicketsToBeChained.Keys) { container.AddEntry(key, additionalTicketsToBeChained[key]); } DFSHelper.saveContainer(container); }
public static void saveContainer(APICon.Container.ChainContainer container) { try { byte[] containerBody = ZipHelper.zipChainContainer(container); string path = Program.conf.EDOTickets.chainContainer.value; if (Program.conf.EDOTickets.chainContainer.useSubFolders) { path += container.docDate.Split('.')[1] + "." + container.docDate.Split('.')[2]; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!path.EndsWith("\\")) { path += "\\"; } File.WriteAllBytes(path + container.name, containerBody); Logger.log("container [" + container.name + "] saved to [" + path + "]"); } catch (Exception e) { Console.WriteLine(e.StackTrace); Logger.log(e.Message); } }