BaseServices.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web;
  6. using Autofac;
  7. using Bowin.Common;
  8. using EMISOnline.Entities;
  9. using System.Linq.Expressions;
  10. using System.Data.Entity;
  11. using Bowin.Common.Linq.Entity;
  12. using EMISOnline.ViewModel;
  13. using EMISOnline.DataLogic.SystemDAL;
  14. using EMISOnline.Utility.FormValidate;
  15. using EMISOnline.Utility;
  16. namespace EMISOnline.CommonLogic
  17. {
  18. public class BaseServices : IBaseServices
  19. {
  20. public EMISOnline.DataLogic.UnitOfWork UnitOfWork { get; set; }
  21. public BaseServices()
  22. {
  23. }
  24. public void SetNewStatus<T>(T entity)
  25. {
  26. var curUser = EMISOnline.Utility.FormValidate.CustomPrincipal.Current;
  27. var curUserID = curUser.UserID;
  28. //typeof(T).GetProperty(TableKeyDictionary.GetKeyName(entity))
  29. // .SetValue(entity, Guid.NewGuid(), null);
  30. dynamic dyEntity = entity;
  31. dyEntity.RecordStatus = (int)SYS_STATUS.USABLE;
  32. dyEntity.CreateUserID = curUserID;
  33. dyEntity.ModifyUserID = curUserID;
  34. dyEntity.ModifyTime = dyEntity.CreateTime = DateTime.Now;
  35. }
  36. public void SetNewStatus<T>(T entity, int recordStatus)
  37. {
  38. var curUser = EMISOnline.Utility.FormValidate.CustomPrincipal.Current;
  39. var curUserID = curUser.UserID;
  40. //typeof(T).GetProperty(TableKeyDictionary.GetKeyName(entity))
  41. // .SetValue(entity, Guid.NewGuid(), null);
  42. dynamic dyEntity = entity;
  43. dyEntity.RecordStatus = recordStatus;
  44. dyEntity.CreateUserID = curUserID;
  45. dyEntity.ModifyUserID = curUserID;
  46. dyEntity.ModifyTime = dyEntity.CreateTime = DateTime.Now;
  47. }
  48. public void SetModifyStatus<T>(T entity)
  49. {
  50. var curUser = EMISOnline.Utility.FormValidate.CustomPrincipal.Current;
  51. var curUserID = curUser.UserID;
  52. dynamic dyEntity = entity;
  53. dyEntity.ModifyUserID = curUserID;
  54. dyEntity.ModifyTime = DateTime.Now;
  55. }
  56. }
  57. }