Program.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Configuration;
  3. using System.Text;
  4. using System.Threading;
  5. using Cksoft.Data;
  6. using Cksoft.Data.Repository;
  7. using DllEapDal;
  8. namespace EapAsync
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Console.OutputEncoding = Encoding.Default;
  15. Console.WriteLine("开始执行");
  16. // var configuration = builder.Build();
  17. string eapconn = ConfigurationManager.AppSettings["eap"];
  18. IDatabase eapdb = null;
  19. try
  20. {
  21. while (true)
  22. {
  23. eapdb = DbFactory.Base(eapconn, DatabaseType.MySql);
  24. eapdb.BeginTrans();
  25. var dal = new McaEventStatisticByDayDal(eapdb);
  26. string error = string.Empty;
  27. if (dal.Async(DateTime.Now, ref error) < 0)
  28. {
  29. eapdb.Rollback();
  30. Console.WriteLine(error);
  31. return;
  32. }
  33. eapdb.Commit();
  34. Console.WriteLine("汇总成功");
  35. Thread.Sleep(30 * 60 * 1000);
  36. }
  37. }
  38. catch (Exception e)
  39. {
  40. //if (eapdb != null&&eapdb.)
  41. // eapdb.Rollback();
  42. Console.WriteLine(e.StackTrace);
  43. Console.WriteLine(e.Message);
  44. }
  45. finally
  46. {
  47. if (eapdb != null)
  48. {
  49. eapdb.Close();
  50. }
  51. }
  52. }
  53. }
  54. }