You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  1. using System.Collections.Generic;
  2. using Swift.DAL.BL.System.Utility.Helper;
  3. using Swift.DAL.SwiftDAL;
  4. using System.Data;
  5. namespace Swift.DAL.BL.System.Utility
  6. {
  7. public class UploadVoucherDao:SwiftDao
  8. {
  9. readonly XmlGenerator xmlUtil = new XmlGenerator();
  10. private static List<FieldName> TextToXmlColumn(string fieldList)
  11. {
  12. var list = new List<FieldName>();
  13. var i = 0;
  14. foreach (var c in fieldList.Split(','))
  15. {
  16. list.Add(new FieldName(i++, c.Trim()));
  17. }
  18. return list;
  19. }
  20. public DbResult UploadVoucher(string filePath, string user)
  21. {
  22. var dbResult = new DbResult();
  23. xmlUtil.FilePath = filePath;
  24. xmlUtil.FirstLineIsHeader = true;
  25. xmlUtil.CheckFirstLineHeader = true;
  26. xmlUtil.ColSeperator = ",";
  27. xmlUtil.RowSeperator = "\r\n";
  28. xmlUtil.IgnoreInvalidRow = false;
  29. xmlUtil.FieldList = TextToXmlColumn("agentCode,dot,amount,currencyType,xRate,mode,dollar_rate,branch_code,session_id,update_ts");
  30. var xml = xmlUtil.GenerateXML();
  31. if (xmlUtil.Dr.ErrorCode != "0")
  32. return xmlUtil.Dr;
  33. var sql = "EXEC proc_uploadVoucher @flag='upload'";
  34. sql += ", @user=" + FilterString(user);
  35. sql += ", @xml ='" + xml + "'";
  36. return ParseDbResult(sql);
  37. }
  38. public DataTable ShowData(string user)
  39. {
  40. var sql = "EXEC proc_uploadVoucher @flag='s'";
  41. sql += ", @user=" + FilterString(user);
  42. return ExecuteDataTable(sql);
  43. }
  44. }
  45. }