/// <summary> /// Iports the invoice from XML. /// </summary> /// <param name="stream">The stream.</param> /// <param name="url">The URL.</param> /// <param name="listIndex">Index of the list.</param> /// <param name="fileName">Name of the file.</param> /// <param name="progressChanged">The progress changed.</param> public static void IportInvoiceFromXml(Stream stream, string url, int listIndex, string fileName, ProgressChangedEventHandler progressChanged) { try { using (Entities edc = new Entities(url)) { String message = String.Format("Import of the invoice message {0} starting.", fileName); ActivityLogCT.WriteEntry(edc, m_Title, message); InvoiceXml document = InvoiceXml.ImportDocument(stream); InvoiceLib entry = Element.GetAtIndex <InvoiceLib>(edc.InvoiceLibrary, listIndex); GetXmlContent(document, edc, entry); ActivityLogCT.WriteEntry(edc, m_Title, String.Format("Import of the invoice message {0} finished", fileName)); } } catch (CAS.SmartFactory.IPR.WebsiteModel.InputDataValidationException _iove) { _iove.ReportActionResult(url, fileName); ActivityLogCT.WriteEntry(m_Title, "Import of the invoice message failed", url); } catch (Exception ex) { ActivityLogCT.WriteEntry("Aborted Invoice message import because of the error", ex.Message, url); ActivityLogCT.WriteEntry(m_Title, "Import of the invoice message failed", url); } }
internal static void GetXmlContent(InvoiceXml xml, Entities edc, InvoiceLib entry) { entry.ClearenceIndex = null; entry.InvoiceLibraryReadOnly = false; try { entry.InvoiceLibraryStatus = GetXmlContent(xml.Item, edc, entry); edc.SubmitChanges(); } catch (Exception) { entry.BillDoc = String.Empty.NotAvailable(); entry.InvoiceLibraryStatus = false; edc.SubmitChanges(); throw; } }