private static void ProcessInvoiceXML(string invoiceXMLFile) { VoygerBillWithLinq voygerBill = VoygerXMLReader.ReadInvoiceXML(invoiceXMLFile); if (voygerBill != null) { InsertData insertData = new InsertData(); insertData.InsertBillData(voygerBill); } else { LogEvent.WriteEvent("voygerBill Readed, and it is empty"); //TODO: Raise Event and store in database for futher intervention. } LogEvent.WriteEvent("ProcessInvoiceXml is ened"); Watcher.NoOfEvent--; }
/// <summary> /// read invoicexml with linq /// </summary> /// <param name="filename"></param> /// <returns></returns> public static VoygerBillWithLinq ReadInvoiceXML(string filename) { //LogEvent.WriteEvent("ReadInvoiceXML: Started and File is : " + filename); DataSet dataSet = ReadXML(filename); // if (fileWR == null) // fileWR = File.AppendText(filename + "_Process.txt"); if (dataSet != null || dataSet.Tables.Count > 0) { vBill = new VoygerBillWithLinq(); foreach (DataTable table in dataSet.Tables) { //fileWR.WriteLine("TableName: " + table); //fileWR.WriteLine(); switch (table.TableName) { case VoyTable.T_Bill: ReadBill(table); break; case VoyTable.T_Customer: ReadCustomer(table); break; case VoyTable.T_LineItem: ReadLineItems(table); break; case VoyTable.T_Payments: ReadPaymentDetails(table); break; default: break; } } //fileWR.Flush(); //fileWR.Close(); return(vBill); } else { // fileWR.Flush(); //fileWR.Close(); return(null); // Error: Incase failed to read or no data present } }
public void InsertBillData(VoygerBillWithLinq voygerBill) { VoyBill bill = voygerBill.bill; List <LineItems> lineItemList = voygerBill.lineItems; List <VPaymentMode> paymentList = voygerBill.payModes; ConnectLinqDataBase(); var v = from vyb in voyDatabase.VoyBill where vyb.BillNumber == bill.BillNumber && vyb.BillTime == bill.BillTime select new { vyb.ID }; if (v.Count() > 0) { Console.WriteLine("Invoice all ready Present in file"); return; } voyDatabase.VoyBill.InsertOnSubmit(bill); voyDatabase.SubmitChanges(); foreach (LineItems item in lineItemList) { item.VoyBillId = bill.ID; voyDatabase.LineItems.InsertOnSubmit(item); } foreach (VPaymentMode item in paymentList) { item.VoyBillId = bill.ID; voyDatabase.VPaymentMode.InsertOnSubmit(item); } InsertDataLog dataLog = new InsertDataLog() { BillNumber = bill.BillNumber, Remark = "First Step", VoyBillId = bill.ID, }; voyDatabase.InsertDataLogs.InsertOnSubmit(dataLog); voyDatabase.SubmitChanges(); }