纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Linq;
  9. using System.Net.Http;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace ICSSoft.DataProject
  13. {
  14. /// <summary>
  15. /// 使用中
  16. /// 获取用户权限
  17. /// </summary>
  18. public class ICSUserPowerService
  19. {
  20. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  21. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
  22. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  23. public DataTable GetUserPower(ICSUserPower info)
  24. {
  25. DataTable dt = null;
  26. //string json = "";
  27. var language = LanguageHelper.GetName("WMSAPIInfo");
  28. if (info == null)
  29. {
  30. throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
  31. }
  32. string res = string.Empty;
  33. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  34. conn.Open();
  35. SqlTransaction sqlTran = conn.BeginTransaction();
  36. SqlCommand cmd = new SqlCommand();
  37. cmd.Transaction = sqlTran;
  38. cmd.Connection = conn;
  39. try
  40. {
  41. string sql = string.Empty;
  42. if (string.IsNullOrWhiteSpace(info.UserId))
  43. throw new Exception(language.GetNameByCode("WMSAPIInfo176"));//"用户不能为空!");
  44. if (string.IsNullOrWhiteSpace(info.MenuCode))
  45. throw new Exception(language.GetNameByCode("WMSAPIInfo177"));//"菜单不能为空!");
  46. if (string.IsNullOrWhiteSpace(info.WorkPoint))
  47. throw new Exception(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!"
  48. sql = @"IF EXISTS(SELECT F_Id FROM Sys_SRM_User WHERE F_IsAdministrator='1' AND F_Id='{0}' AND F_Location='{2}')
  49. BEGIN
  50. SELECT d.F_EnCode AS ButtonName,d.F_FullName AS ButtonText
  51. FROM Sys_SRM_ModuleButton d
  52. INNER JOIN Sys_SRM_Module e ON d.F_ModuleId=e.F_Id
  53. WHERE e.F_FullName='{1}'
  54. END
  55. ELSE
  56. BEGIN
  57. SELECT d.F_EnCode AS ButtonName,d.F_FullName AS ButtonText
  58. FROM Sys_SRM_User a
  59. INNER JOIN Sys_SRM_Role b ON a.F_RoleId=b.F_Id
  60. INNER JOIN Sys_SRM_RoleAuthorize c ON a.F_RoleId=c.F_ObjectId
  61. INNER JOIN Sys_SRM_ModuleButton d ON c.F_ItemId=d.F_Id
  62. INNER JOIN Sys_SRM_Module e ON d.F_ModuleId=e.F_Id
  63. WHERE a.F_Id='{0}' AND e.F_FullName='{1}' AND a.F_Location='{2}'
  64. END";
  65. sql = string.Format(sql, info.UserId, info.MenuCode, info.WorkPoint);
  66. dt = DBHelper.SQlReturnData(sql, cmd);
  67. //json = JsonConvert.SerializeObject(dt);
  68. cmd.Transaction.Commit();
  69. return dt;
  70. }
  71. catch (Exception ex)
  72. {
  73. if (cmd.Transaction != null)
  74. cmd.Transaction.Rollback();
  75. log.Error(ex.Message);
  76. throw new Exception(ex.Message);
  77. }
  78. finally
  79. {
  80. if (conn.State == ConnectionState.Open)
  81. {
  82. conn.Close();
  83. }
  84. conn.Dispose();
  85. }
  86. }
  87. public DataTable GetExtensionEnable(ICSWorkPoint info)
  88. {
  89. DataTable dt = null;
  90. //string json = "";
  91. var language = LanguageHelper.GetName("WMSAPIInfo");
  92. if (info == null)
  93. {
  94. throw new Exception(language.GetNameByCode("WMSAPIInfo007"));//"传送数据为空!"
  95. }
  96. string res = string.Empty;
  97. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  98. conn.Open();
  99. SqlTransaction sqlTran = conn.BeginTransaction();
  100. SqlCommand cmd = new SqlCommand();
  101. cmd.Transaction = sqlTran;
  102. cmd.Connection = conn;
  103. try
  104. {
  105. string sql = string.Empty;
  106. if (string.IsNullOrWhiteSpace(info.WorkPointCode))
  107. throw new Exception(language.GetNameByCode("WMSAPIInfo004"));//"站点不能为空!"
  108. sql = @"SELECT ID,ColCode,ColName,Enable,MTIME,MUSER,MUSERName,WorkPoint,EATTRIBUTE1
  109. FROM ICSExtensionEnable WHERE WorkPoint='{0}'and Enable='1'";
  110. sql = string.Format(sql, info.WorkPointCode);
  111. dt = DBHelper.SQlReturnData(sql, cmd);
  112. //json = JsonConvert.SerializeObject(dt);
  113. cmd.Transaction.Commit();
  114. return dt;
  115. }
  116. catch (Exception ex)
  117. {
  118. if (cmd.Transaction != null)
  119. cmd.Transaction.Rollback();
  120. log.Error(ex.Message);
  121. throw new Exception(ex.Message);
  122. }
  123. finally
  124. {
  125. if (conn.State == ConnectionState.Open)
  126. {
  127. conn.Close();
  128. }
  129. conn.Dispose();
  130. }
  131. }
  132. }
  133. }