LogUnitOfWork.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.Entities.Log;
  7. using System.Data.SqlClient;
  8. using System.Data;
  9. using System.Data.Entity;
  10. using System.Data.Entity.Validation;
  11. using System.Diagnostics;
  12. using System.Data.Entity.Core.Objects;
  13. using System.Data.Entity.Core.Metadata.Edm;
  14. using System.Data.Entity.Infrastructure;
  15. using System.Linq.Expressions;
  16. using System.Reflection;
  17. using System.Threading;
  18. using Bowin.Common.Linq;
  19. namespace EMIS.DataLogic
  20. {
  21. public class LogUnitOfWork : EMISNewLogContext, IDisposable
  22. {
  23. public LogUnitOfWork()
  24. : base("EMISNewLogContext")
  25. {
  26. }
  27. void IDisposable.Dispose()
  28. {
  29. Dispose();
  30. }
  31. private static void WriteLogsThreading(object logList)
  32. {
  33. if (logList is IList<Log_Operate>)
  34. {
  35. try
  36. {
  37. (logList as List<Log_Operate>).ExecuteBulkCopy("EMISNewLogContext", "Log_Operate");
  38. }
  39. catch (Exception ex)
  40. {
  41. throw ex;
  42. }
  43. }
  44. }
  45. public static void WriteLogs(IList<Log_Operate> logList)
  46. {
  47. Thread logThread = new Thread(WriteLogsThreading);
  48. logThread.Start(logList);
  49. }
  50. public void RemoveLogs(IList<Guid?> operateLogIDList)
  51. {
  52. this.Delete<Log_Operate>(x => operateLogIDList.Contains(x.OperateID));
  53. }
  54. }
  55. }