AbstractManager.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Reflection;
  3. using Microsoft.InformationProtection;
  4. using log4net;
  5. using Serilog;
  6. using Serilog.Core;
  7. namespace AipGateway.AIP
  8. {
  9. public abstract class AbstractManager : IDisposable
  10. {
  11. //private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  12. private readonly ILogger _log;
  13. protected readonly string _clientId;
  14. public AbstractManager(Logger logger, string clientId)
  15. {
  16. _log = logger.ForContext<AbstractManager>();
  17. _clientId = clientId;
  18. }
  19. public int LastErrNo { get; internal set; }
  20. public string LastErrMsg { get; internal set; }
  21. protected void SetError(int errNo, string errMsg1, string errMsg2 = "", bool isThrowEx = true)
  22. {
  23. LastErrNo = errNo;
  24. if (errMsg2 == "")
  25. {
  26. LastErrMsg = errMsg1;
  27. }
  28. else
  29. {
  30. LastErrMsg = errMsg1 + "\r\n" + errMsg2;
  31. }
  32. _log.Error("AbstractManager::SetError ==> {0}, {1}, {2}", errNo, errMsg1, errMsg2);
  33. if (isThrowEx && LastErrNo != 0)
  34. {
  35. throw new AipFileException(errNo, LastErrMsg);
  36. }
  37. }
  38. public abstract bool CreateProfile(ref MipContext mipContext);
  39. public abstract bool CreateEngine(ref Identity identity, ref AuthDelegateImplementation authDelegate);
  40. public abstract void Dispose();
  41. }
  42. }