Source code of Windows XP (NT5)
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.

145 lines
3.9 KiB

  1. <%
  2. SUB CheckRefreshItemCache
  3. rem check cache validity once per session per database
  4. if 0 = VarType( Session("cache" & Application("dbCache")(Session("DBSOURCE")) ) ) then
  5. RefreshItemCache
  6. Session("cache" & Application("dbCache")(Session("DBSOURCE"))) = true
  7. end if
  8. END SUB
  9. SUB IncludeItemCache
  10. CheckRefreshItemCache
  11. Response.Write Application("cache" & Application("dbCache")(Session("DBSOURCE")))
  12. END SUB
  13. SUB RefreshItemCache
  14. Dim Conn,Comm,RS,cache,cnfg,crlf,Ver,v,Values,i,j,CheckFields,fld,pos,fDoUpd
  15. Set Conn = Server.CreateObject("ADODB.Connection")
  16. Set Comm = Server.CreateObject("ADODB.Command")
  17. Set RS = Server.CreateObject("ADODB.Recordset")
  18. Conn.Open Session("DSN")
  19. Set Comm.ActiveConnection = Conn
  20. Set RS.Source = Comm
  21. RS.CursorType = adOpenStatic
  22. cache = "cache" & Application("dbCache")(Session("DBSOURCE"))
  23. cnfg = "cnfg" & Application("dbCache")(Session("DBSOURCE"))
  24. crlf = chr(13) & chr(10)
  25. rem check revision # for field item cache
  26. Comm.CommandText = "Select FldItemsRev,DefaultVersionNumber from RaidSys where id=1"
  27. RS.Open
  28. Ver = RS.GetRows()
  29. RS.Close
  30. Application.Lock
  31. if 0 = VarType(Application("fld" & Application("dbCache")(Session("DBSOURCE")))) then
  32. Comm.CommandText = "Select DBColName,FriendlyName,XPos,YPos,Width,Height,HelpText,Type,fForcedEntry from flds"
  33. RS.Open
  34. FldArray = RS.GetRows()
  35. RS.Close
  36. Application("fld" & Application("dbCache")(Session("DBSOURCE"))) = FldArray
  37. end if
  38. if 0 = VarType(Application(cnfg)) then
  39. fDoUpd = TRUE
  40. else
  41. if Application(cnfg)(0,0) <> Ver(0,0) then
  42. fDoUpd = TRUE
  43. end if
  44. end if
  45. if fDoUpd then
  46. Application(cnfg) = Ver
  47. rem generate cache file for field items
  48. Comm.CommandText = "Select DBColName,FldID,Type,fForcedEntry from flds"
  49. RS.Open
  50. FldArray = RS.GetRows()
  51. RS.Close
  52. CheckFields = Array("Status","IssueType","Severity","Priority","Accessibility","Source","HowFound","Lang","Resolution","Cause","CodeChange", "Component", "Software", "Urgency", "Regression", "LangSup", "Processor", "NumCPU")
  53. v = "<script language=" & chr(34) & "JavaScript" & chr(34) & ">" & crlf & "// FldItemsRev:" & Ver(0,0) & crlf
  54. for each fld in CheckFields
  55. v = v & "var ck" & fld & "=new Array("
  56. for i = 0 to UBound(FldArray,2)
  57. if FldArray(0,i) = fld then
  58. exit for
  59. end if
  60. next
  61. Comm.CommandText = "Select Name from flditems where fDeleted=0 AND FldID=" & FldArray(1,i)
  62. Set RS.Source = Comm
  63. RS.CursorType = adOpenStatic
  64. RS.Open
  65. Values = RS.GetRows()
  66. RS.Close
  67. for j = 0 to UBound(Values,2)
  68. if j > 0 then
  69. v = v & ","
  70. else
  71. rem if not mandatory then allow empty string
  72. if FldArray(3,i) = 0 then
  73. v = v & chr(34) & chr(34) & ","
  74. end if
  75. end if
  76. v = v & chr(34) & Values(0,j) & chr(34)
  77. next
  78. v = v & ");" & crlf
  79. i = i + 1
  80. next
  81. rem checks[] is array of value arrays
  82. v = v & "var checks=new Array("
  83. j = 0
  84. for each fld in CheckFields
  85. if j > 0 then
  86. v = v & ","
  87. end if
  88. v = v & "ck" & fld
  89. j = j + 1
  90. next
  91. v = v & ");" & crlf
  92. rem checkfields[] is array of field names
  93. v = v & "var checkfields=new Array("
  94. j = 0
  95. for each fld in CheckFields
  96. if j > 0 then
  97. v = v & ","
  98. end if
  99. v = v & chr(34) & fld & chr(34)
  100. j = j + 1
  101. next
  102. v = v & ");" & crlf & "</script>" & crlf
  103. Application(cache) = v
  104. end if
  105. Application.Unlock
  106. Conn.Close
  107. END SUB
  108. %>