Sys_Functions_info_Ext.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using SysBaseLibs;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace SysDataLibs.TableClass
  9. {
  10. partial class Sys_Functions_info
  11. {
  12. public static string GetAllFunStrByUserId(string pcUserId, DBConnSql poDBConn)
  13. {
  14. string lcRetVal = "";
  15. string lcSql = "select functionID from vwUserHasAllFunctions where userid ='" + pcUserId + "'";
  16. rsQuery loQuery = poDBConn.OpenQuery(lcSql);
  17. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  18. {
  19. loQuery.MoveFirst();
  20. for (int i = 0; i < loQuery.RecCount; i++)
  21. {
  22. lcRetVal += (lcRetVal == "" ? "" : ",") + "'" + loQuery.GetString("functionID") + "'";
  23. loQuery.MoveNext();
  24. }
  25. }
  26. if (lcRetVal.Trim().Length == 0)
  27. lcRetVal = "''";
  28. return lcRetVal;
  29. }
  30. public static bool UpdatePowerOfGroupAndUser(string insertSqlStr, string deleteSqlStr, string FunctionColl, string ObjectID, string ObjectType, DBConnSql poDBConn)
  31. {
  32. bool lbRetVal = false;
  33. string lcSql = deleteSqlStr + " " + insertSqlStr;
  34. IdCollection loColl = new IdCollection();
  35. SqlSPPar loSPpar = new SqlSPPar("ObjectID", SqlDbType.NVarChar);
  36. loSPpar.ParaLength = 20;
  37. loSPpar.ParameterValue = ObjectID.Trim();
  38. loColl.Add(loSPpar);
  39. loSPpar = new SqlSPPar("FunctionColl", SqlDbType.NVarChar);
  40. loSPpar.ParaLength = 2000;
  41. loSPpar.ParameterValue = FunctionColl.Trim();
  42. loColl.Add(loSPpar);
  43. loSPpar = new SqlSPPar("ObjectType", SqlDbType.VarChar);
  44. loSPpar.ParaLength = 5;
  45. loSPpar.ParameterValue = ObjectType;
  46. loColl.Add(loSPpar);
  47. if (poDBConn.BeginTrans())
  48. {
  49. if (poDBConn.ExecuteSql(lcSql) && poDBConn.ExecuteStoredProc("Pr_AddFatherFunction", loColl))
  50. {
  51. poDBConn.CommitTrans();
  52. lbRetVal = true;
  53. }
  54. else
  55. poDBConn.RollbackTrans();
  56. }
  57. return lbRetVal;
  58. }
  59. public static bool MoveFunction(string FunctionID, string way, DBConnSql poDBConn)
  60. {
  61. bool lbRetVal = false;
  62. IdCollection loColl = new IdCollection();
  63. SqlSPPar sqlP = new SqlSPPar("CurItem", SqlDbType.VarChar);
  64. sqlP.ParaLength = 20;
  65. sqlP.ParameterValue = FunctionID;
  66. loColl.Add(sqlP);
  67. sqlP = new SqlSPPar("way", SqlDbType.VarChar);
  68. sqlP.ParaLength = 4;
  69. sqlP.ParameterValue = way;
  70. loColl.Add(sqlP);
  71. if (poDBConn.BeginTrans())
  72. {
  73. if (poDBConn.ExecuteStoredProc("Pr_FunctionsSort", loColl))
  74. {
  75. poDBConn.CommitTrans();
  76. lbRetVal = true;
  77. }
  78. else
  79. poDBConn.RollbackTrans();
  80. }
  81. return lbRetVal;
  82. }
  83. public static bool DeleteFunction(string FunctionID, DBConnSql poDBConn)
  84. {
  85. bool lbRetVal = false;
  86. IdCollection loColl = new IdCollection();
  87. SqlSPPar sqlP = new SqlSPPar("FunctionID", SqlDbType.VarChar);
  88. sqlP.ParaLength = 20;
  89. sqlP.ParameterValue = FunctionID;
  90. loColl.Add(sqlP);
  91. if (poDBConn.BeginTrans())
  92. {
  93. if (poDBConn.ExecuteStoredProc("Pr_deleteFunction_ByFunctionID", loColl))
  94. {
  95. poDBConn.CommitTrans();
  96. lbRetVal = true;
  97. }
  98. else
  99. poDBConn.RollbackTrans();
  100. }
  101. return lbRetVal;
  102. }
  103. public static rsXmlNode GetFunctionXmlNode(DBConnSql poDBConn)
  104. {
  105. rsXmlNode loRetVal = null;
  106. if (poDBConn != null && poDBConn.IsOpened)
  107. {
  108. string lcSql = " select " + Sys_Functions_info.cFunctionID + "," + Sys_Functions_info.cFunctionName + "," + Sys_Functions_info.cFatherID + "," + Sys_Functions_info.cDepth + "," + Sys_Functions_info.cIsLeaf + " from " + Tn.Sys_Functions + " order by depth, Sort ";
  109. rsQuery loQuery = poDBConn.OpenQuery(lcSql);
  110. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  111. {
  112. loRetVal = new rsXmlNode("functions", "");
  113. loQuery.MoveFirst();
  114. for (int i = 0; i < loQuery.RecCount; i++)
  115. {
  116. rsXmlNode loNode = new rsXmlNode(loQuery.GetString("FunctionId"), loQuery.GetBool("isleaf") ? " ◇ " + loQuery.GetString(Sys_Functions_info.cFunctionName) + " " : " ◆ " + loQuery.GetString(Sys_Functions_info.cFunctionName) + " ");
  117. loNode.Depth = loQuery.GetInt("Depth");
  118. string lcFather = loQuery.GetString("FatherId");
  119. rsXmlNode loFather = MyUtils.GetChildNode(loRetVal, lcFather);
  120. if (loFather != null)
  121. {
  122. loFather.AddChild(loNode);
  123. }
  124. else
  125. {
  126. loRetVal.AddChild(loNode);
  127. }
  128. loQuery.MoveNext();
  129. }
  130. }
  131. }
  132. return loRetVal;
  133. }
  134. //------------添加自定义的方法-----------
  135. public static Sys_Functions_info CreatTree(rsQuery poQuery)
  136. {
  137. Sys_Functions_info loRoot = null;
  138. poQuery.FilterBy("FunctionID = 'HTSystem'");
  139. //poQuery.FilterBy("FatherID = '0'");
  140. if (poQuery.RecCount == 1)
  141. {
  142. loRoot = new Sys_Functions_info(poQuery.CurrentRow);
  143. //poQuery.FilterBy("FatherID='" + loRoot.FunctionID + "' and FatherID <> '0'");
  144. poQuery.FilterBy("FatherID='" + loRoot.FunctionID + "' and FunctionID <> 'HTSystem'");
  145. poQuery.MoveFirst();
  146. for (int i = 0; i < poQuery.RecCount; i++)
  147. {
  148. Sys_Functions_info loFunctionNode = new Sys_Functions_info(poQuery.CurrentRow);
  149. loRoot.ChildNodes.Add(loFunctionNode);
  150. poQuery.MoveNext();
  151. }
  152. if (loRoot.ChildNodes.Count > 0)
  153. {
  154. foreach (Sys_Functions_info loFuncInfo in loRoot.ChildNodes)
  155. {
  156. CreatTree(poQuery, loFuncInfo);
  157. }
  158. }
  159. }
  160. return loRoot;
  161. }
  162. static void CreatTree(rsQuery poQuery, Sys_Functions_info poFatherNode)
  163. {
  164. //poQuery.FilterBy("FatherID='" + poFatherNode.FunctionID + "' and FatherID <> '0'");
  165. poQuery.FilterBy("FatherID='" + poFatherNode.FunctionID + "' and FunctionID <> 'HTSystem'");
  166. poQuery.MoveFirst();
  167. for (int i = 0; i < poQuery.RecCount; i++)
  168. {
  169. Sys_Functions_info loFunctionNode = new Sys_Functions_info(poQuery.CurrentRow);
  170. poFatherNode.ChildNodes.Add(loFunctionNode);
  171. poQuery.MoveNext();
  172. }
  173. if (poFatherNode.ChildNodes.Count > 0)
  174. {
  175. foreach (Sys_Functions_info loFuncInfo in poFatherNode.ChildNodes)
  176. CreatTree(poQuery, loFuncInfo);
  177. }
  178. }
  179. List<Sys_Functions_info> _ChildNodes = new List<Sys_Functions_info>();
  180. public List<Sys_Functions_info> ChildNodes
  181. {
  182. get { return _ChildNodes; }
  183. set { _ChildNodes = value; }
  184. }
  185. public string ToJason()
  186. {
  187. string lcRetVal = "{";
  188. lcRetVal += "\"FunctionID\": \"" + this.FunctionID + "\",";
  189. lcRetVal += "\"FunctionName\": \"" + this.FunctionName + "\",";
  190. lcRetVal += "\"URL\": \"" + this.URL + "\"";
  191. if (this.ChildNodes.Count > 0)
  192. {
  193. lcRetVal += ",\"children\": [";
  194. string lcString = "";
  195. foreach (Sys_Functions_info loChild in this.ChildNodes)
  196. {
  197. lcString += (lcString == "" ? "" : ",") + loChild.ToJason();
  198. }
  199. lcRetVal += lcString;
  200. lcRetVal += "]";
  201. }
  202. lcRetVal += "}";
  203. return lcRetVal;
  204. }
  205. }
  206. }