Info.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace WebAPIBase.NetCore.BusinessCore
  8. {
  9. public class Info
  10. {
  11. private static GetCurrentUser gcu;
  12. private static Hashtable currentList = new Hashtable();
  13. public static GetCurrentUser GCU
  14. {
  15. set
  16. {
  17. gcu = value;
  18. }
  19. }
  20. public static CurrentInfo Current
  21. {
  22. get
  23. {
  24. int currentUserCode = gcu.GetCurrentUserCode();
  25. if (currentList.ContainsKey(currentUserCode))
  26. {
  27. return (CurrentInfo)currentList[currentUserCode];
  28. }
  29. CurrentInfo currentInfo = CurrentInfo.Instance(currentUserCode);
  30. try
  31. {
  32. currentList.Add(currentUserCode, currentInfo);
  33. }
  34. catch
  35. {
  36. }
  37. return currentInfo;
  38. }
  39. }
  40. public static void Clear()
  41. {
  42. currentList.Clear();
  43. }
  44. }
  45. public abstract class GetCurrentUser
  46. {
  47. public abstract int GetCurrentUserCode();
  48. }
  49. public class CurrentInfo
  50. {
  51. public int UserCode;
  52. public string UserName;
  53. public FdcUser fdcUser;
  54. private CurrentInfo()
  55. {
  56. }
  57. private CurrentInfo(int usercode)
  58. {
  59. init(usercode);
  60. }
  61. private void init(int usercode)
  62. {
  63. fdcUser = FdcUnitStructure.Instance.GetFdcUserByCode(usercode);
  64. if (fdcUser != null)
  65. {
  66. int.TryParse(fdcUser.UserCode, out UserCode);
  67. UserName = fdcUser.UserName;
  68. }
  69. else
  70. {
  71. UserCode = 0;
  72. UserName = "-";
  73. }
  74. }
  75. public static CurrentInfo Instance(int usercode)
  76. {
  77. return new CurrentInfo(usercode);
  78. }
  79. }
  80. public enum RightScope
  81. {
  82. 无,
  83. 个人,
  84. 部门
  85. }
  86. public class FdcFunctionUnit
  87. {
  88. public string FunctionCode;
  89. public FdcUnit unit;
  90. public int IsPerson;
  91. }
  92. }