Leaked source code of windows server 2003
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.

373 lines
11 KiB

  1. <%@LANGUAGE = Javascript%>
  2. <!--#INCLUDE FILE='Global_DBUtils.asp' -->
  3. <!--#include file='global_serverutils.asp'-->
  4. <%
  5. Response.Buffer = false
  6. var Alias = Request.QueryString("Alias")
  7. %>
  8. <head>
  9. <link rel="stylesheet" TYPE="text/css" HREF="/main.css">
  10. <link rel="stylesheet" TYPE="text/css" HREF="/CustomStyles.css">
  11. </head>
  12. <body bgcolor='#ffffff' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' tabindex='0'>
  13. <OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
  14. HEIGHT=0 WIDTH=0 ID="rdsSaveQuery"
  15. OnDataSetComplete="RefreshLeftNav()">
  16. <PARAM NAME="URL" VALUE="" >
  17. </OBJECT>
  18. <!--OnDataSetComplete="CreateDeliveryTypesDropDown()"-->
  19. <table>
  20. <tr>
  21. <td>
  22. <p class='clsPTitle'>Custom Query Designer</p>
  23. </td>
  24. </tr>
  25. </table>
  26. <SCRIPT LANGUAGE="Javascript">
  27. <%
  28. Response.Write("CompareOperators = { \n" )
  29. for( op in CompareOperators )
  30. {
  31. Response.Write( op + " : { \t\tText:\"" + CompareOperators[op].Text + "\"\t,\t\tSign:\"" + CompareOperators[op].Sign + "\" },\n" )
  32. }
  33. Response.Write( "NONE : { Text: \"\", Sign:\"\" }\n}" )
  34. %>
  35. function RemoveClause( TableName, ClauseToRemove )
  36. {
  37. var I; //standard loop counter
  38. eval( "document.all." + TableName + ClauseToRemove+".style.display='none'" ) ;
  39. eval( "document.all." + TableName + "sField"+ClauseToRemove+".selectedIndex=0" ) ;
  40. eval( "document.all." + TableName + "tbSearchValue"+ClauseToRemove+".value=''" ) ;
  41. ClearCompareField( TableName, ClauseToRemove );
  42. }
  43. function AddClause( TableName )
  44. {
  45. for ( var i=1 ; i< 9 ; i++ )
  46. {
  47. if ( eval( "document.all." + TableName + i+".style.display") == 'none' )
  48. {
  49. eval( "document.all." + TableName + i+".style.display='block'" ) ;
  50. return;
  51. }
  52. }
  53. }
  54. function ClearCompareField( TableName, iFieldNumber )
  55. {
  56. var lenCompareOptions = new Number( eval("document.all." + TableName + "sCompare"+iFieldNumber+".options.length" ) )
  57. //alert ( lenCompareOptions )
  58. for ( var i=0 ; i <= lenCompareOptions ; i++ )
  59. {
  60. eval("document.all." + TableName + "sCompare"+iFieldNumber+".options.remove(0)");
  61. eval("document.all." + TableName +"tbSearchValue"+iFieldNumber+".style.visibility='hidden'");
  62. }
  63. }
  64. function FillInCompareField( TableName, iFieldNumber, fieldname )
  65. {
  66. var field //the field we are workikng on
  67. //make sure the comparison field has nothing in it
  68. if ( eval("document.all." + TableName + "sCompare"+iFieldNumber+".length == 0" ) )
  69. {
  70. for ( field in CompareOperators )
  71. {
  72. var Element=document.createElement("OPTION");
  73. Element.text=CompareOperators[field].Text;
  74. Element.value=CompareOperators[field].Sign ;
  75. eval("document.all." + TableName + "sCompare"+iFieldNumber+".add( Element )" );
  76. eval("document.all." + TableName + "tbSearchValue"+iFieldNumber+".style.visibility='visible'");
  77. }
  78. }
  79. ClearValueTB ( TableName, iFieldNumber )
  80. }
  81. function ValidateCompare ( TableName, cIndex, CompareValue )
  82. {
  83. if ( CompareValue == "IS NOT NULL" | CompareValue == "IS NULL" )
  84. {
  85. eval("document.all." + TableName + "tbSearchValue"+cIndex+".style.visibility='hidden'");
  86. eval("document.all." + TableName + "tbSearchValue"+cIndex+".value=''");
  87. }
  88. else
  89. {
  90. eval("document.all." + TableName + "tbSearchValue"+cIndex+".style.visibility='visible'");
  91. eval("document.all." + TableName + "tbSearchValue"+cIndex+".value=''");
  92. }
  93. }
  94. function ClearValueTB ( TableName, cIndex )
  95. {
  96. eval("document.all." + TableName + "tbSearchValue" + cIndex + ".value=\"\"" )
  97. }
  98. function ShowAdvQuery ()
  99. {
  100. document.all.divAdvancedQuery.style.display='block'
  101. document.all.divTheQuery.style.display='none'
  102. }
  103. function VerifySaveQuery()
  104. {
  105. if( document.all.tbDescription.value == "" )
  106. alert("You must enter a description in order to save this query! " )
  107. else
  108. {
  109. document.all.SaveQuery.value="1"
  110. document.all.submit()
  111. }
  112. }
  113. function VerifySearchData ( TableName, svValue, field )
  114. {
  115. var fieldVal = eval( "document.all." + TableName + "sField" + field + ".selectedIndex" )
  116. var fieldType = new String( eval( TableName + "Fields[" + fieldVal + "].ValType" ) )
  117. var fieldName = new String( eval( TableName + "Fields[" + fieldVal + "].Text" ) )
  118. if ( fieldType == "Number" )
  119. {
  120. if ( isNaN( svValue ) )
  121. {
  122. alert("This field requires a number as input: " + fieldName )
  123. return false
  124. }
  125. }
  126. return true
  127. }
  128. function VerifyCorrectDataTypes()
  129. {
  130. for ( var i=1 ; i < 9 ; i++ )
  131. {
  132. var field = eval( "document.all.sField" + i + ".value" )
  133. alert( field )
  134. }
  135. }
  136. function SaveQuery( TableName, Page, Params )
  137. {
  138. var Description = eval( "document.all." + TableName + "SaveDescription.value" )
  139. var Param1 = eval( "document.all." + TableName + "Top.value" )
  140. var Param2 = encodeURIComponent(BuildWhereClause( TableName ) )
  141. var Param3 = eval( "document.all." + TableName + "OrderBy.value")
  142. var Param4 = eval("document.all." + TableName + "SortDirection.value")
  143. if ( String(Params) == "undefined" || String(Params) == "" )
  144. Params=""
  145. else
  146. Params += "&"
  147. //alert ( Page + "?" + Params + "SP=CUSTOM&Param1=" + Param1 + "&Param2=" + Param2 + "&Param3=" + Param3 + "&Param4=" + Param4)
  148. var FinalParam= Page + "?" + Params + "SP=CUSTOM&Param1=" + Param1 + "&Param2=" + Param2 + "&Param3=" + Param3 + "&Param4=" + Param4
  149. var URL = "Global_GetRS.asp?SP=DBGPortal_SaveCustomQuery&DBConn=CRASHDB3&Param0=<%=GetShortUserAlias()%>&Param1=" + Description + "&Param2=" + escape( FinalParam )
  150. //alert( URL )
  151. rdsSaveQuery.URL = URL
  152. rdsSaveQuery.Refresh()
  153. //try and update the left nav
  154. alert("Your query has been saved! You can run your saved query from the left nav under the heading 'Custom Queries'." )
  155. }
  156. function RefreshLeftNav()
  157. {
  158. try
  159. {
  160. window.parent.parent.frames("SepLeftNav").window.location.reload()
  161. }
  162. catch( err )
  163. {
  164. alert("Could not update the left nav bar. Please refresh your left nav by right clicking anywhere within the left nav and clicking refresh.")
  165. }
  166. }
  167. function ExecuteQuery( TableName, NewWindow, Page, Params )
  168. {
  169. var Param1 = eval( "document.all." + TableName + "Top.value" )
  170. var Param2 = encodeURIComponent(BuildWhereClause( TableName ) )
  171. var Param3 = eval( "document.all." + TableName + "OrderBy.value")
  172. var Param4 = eval("document.all." + TableName + "SortDirection.value")
  173. if ( String(Params) == "undefined" || String(Params) == "" )
  174. Params=""
  175. else
  176. Params += "&"
  177. if ( NewWindow )
  178. window.open( Page + "?" + Params + "SP=CUSTOM&Param1=" + Param1 + "&Param2=" + Param2 + "&Param3=" + Param3 + "&Param4=" + Param4)
  179. else
  180. window.navigate( Page + "?" + Params + "SP=CUSTOM&Param1=" + Param1 + "&Param2=" + Param2 + "&Param3=" + Param3 + "&Param4=" + Param4)
  181. }
  182. function CreateCrashQuery( TableName, NewWindow )
  183. {
  184. //var QueryEnd=new String()
  185. //var Query = new String()
  186. //var WhereClause = new String()
  187. //var Param1 = eval( "document.all." + TableName + "Top.value" )
  188. //var Param3 = eval( "document.all." + TableName + "OrderBy.value")
  189. //var Param4 = eval("document.all." + TableName + "SortDirection.value")
  190. //Query = "SELECT TOP " + eval( "document.all." + TableName + "Top.value")
  191. //Query += " Path, BuildNo, EntryDate, IncidentID, Email, Description, Comments, Repro, TrackID, iBucket from dbgportal_crashdata "
  192. //QueryEnd = " order by " + eval( "document.all." + TableName + "OrderBy.value") + " " + eval("document.all." + TableName + "SortDirection.value")
  193. //var WhereClause = BuildWhereClause( TableName )
  194. //var Query = encodeURIComponent( Query + " " + WhereClause + QueryEnd )
  195. //if ( NewWindow )
  196. //window.open( "DBGPortal_DisplayCrashQuery.asp?SP=CUSTOM&Param1=" + eval( "document.all." + TableName + "Top.value") + "&Param2=" + WhereClause + "&Param3=" + Param3 + "&Param4=" + Param4)
  197. //else
  198. //window.navigate( "DBGPortal_DisplayCrashQuery.asp?SP=CUSTOM&Param1=" + eval( "document.all." + TableName + "Top.value" ) + "&Param2=" + WhereClause + "&Param3=" + Param3 + "&Param4=" + Param4)
  199. }
  200. function CreateAdvancedQuery( TableName, NewWindow )
  201. {
  202. //eval( "document.all." + TableName + "Top.value" )
  203. /*var Query = "SELECT TOP " + eval( "document.all." + TableName + "Top.value") + " BTI.iBucket, BTI.BucketID, FollowUP, [Crash Count], BugID, SolutionID FROM "
  204. Query += "(SELECT TOP 100 PERCENT sBucket, Count(sBucket) as [Crash Count] FROM CrashInstances "
  205. Query += "GROUP BY sBucket "
  206. Query += "ORDER BY [Crash Count] DESC) as one "
  207. Query += "INNER JOIN BucketToInt as BTI on sBucket=BTI.iBucket "
  208. Query += "LEFT JOIN FollowUPIds as F on BTI.iFollowUP = F.iFollowUP "
  209. Query += "LEFT JOIN Solutions.dbo.Solvedbuckets as SOL on BTI.BucketId = SOL.strBucket "
  210. Query += "LEFT JOIN RaidBugs as R on BTI.iBucket = R.iBucket "
  211. */
  212. //var Query = "SELECT TOP " + eval( "document.all." + TableName + "Top.value") + " iBucket, BucketID, FollowUP, CrashCount, BugID, SolutionID FROM "
  213. //Query += "DBGPortal_BucketData "
  214. //var QueryEnd = " order by " + eval( "document.all." + TableName + "OrderBy.value") + " " + eval("document.all." + TableName + "SortDirection.value" )
  215. //var WhereClause = BuildWhereClause( TableName )
  216. ///var Query = encodeURIComponent( Query + " " + WhereClause + QueryEnd )
  217. //if ( NewWindow )
  218. //window.open( "DBGPortal_DisplayQuery.asp?SP=CUSTOM&CustomQuery=" + Query + "&Platform=&QueryType=&Param1=" + Top + "&Param2=" + WhereClause )
  219. //else
  220. //window.navigate( "DBGPortal_DisplayQuery.asp?SP=CUSTOM&CustomQuery=" + Query + "&Platform=&QueryType=&Param1=" + eval( "document.all." + TableName + "Top.value" ) + "&Param2=" + WhereClause )
  221. }
  222. function BuildWhereClause( TableName )
  223. {
  224. var WhereClause = ""
  225. for ( var i=1 ; i < 9 ; i++ )
  226. {
  227. var conjuction = eval ("document.all." + TableName + "sConjunction" + i + ".value" )
  228. var field = eval( "document.all." + TableName + "sField" + i + ".value" )
  229. var UserValue = eval("document.all." + TableName + "tbSearchValue" + i + ".value" )
  230. if ( eval( "document.all." + TableName + "sCompare" + i + ".value" ) == "CONTAINS" )
  231. {
  232. var op = "LIKE '%" + UserValue + "%'"
  233. UserValue = ""
  234. }
  235. else if ( eval( "document.all." + TableName + "sCompare" + i + ".value" ) == "DNCONTAINS" )
  236. {
  237. var op = "NOT LIKE '%" + UserValue + "%'"
  238. UserValue = ""
  239. }
  240. else
  241. {
  242. var op = eval( "document.all." + TableName + "sCompare" + i + ".value" )
  243. }
  244. if ( UserValue != "" )
  245. {
  246. if( !VerifySearchData( TableName, UserValue, i ) )
  247. return false
  248. UserValue = "'" + UserValue + "'"
  249. }
  250. if ( field != "" )
  251. {
  252. if ( WhereClause != "" )
  253. WhereClause += conjuction + " " + field + " " + op + " " + UserValue + " "
  254. else
  255. WhereClause = "WHERE " + field + " " + op + " " + UserValue + " "
  256. }
  257. }
  258. return WhereClause
  259. }
  260. </SCRIPT>
  261. <%
  262. //CreateQueryBuilder( "AdvancedQuery", "ExecuteQuery", SearchFields, "Search Bucket Data:" , "DBGPortal_DisplayQuery.asp" )
  263. //CreateQueryBuilder( "AdvancedCrashQuery", "ExecuteQuery", CrashSearchFields, "Search Crash Data: ", "DBGPortal_DisplayCrashQuery.ASP" )
  264. %>
  265. <%
  266. CreateQueryBuilder( "AdvancedQuery", "ExecuteQuery", "SaveQuery", SearchFields, "Search Bucket Data:" , "DBGPortal_DisplayQuery.asp", "Param0=BUCKETDATA" )
  267. CreateQueryBuilder( "AdvancedCrashQuery", "ExecuteQuery", "SaveQuery", CrashSearchFields, "Search Crash Data: ", "DBGPortal_DisplayQuery.ASP", "Param0=CRASHDATA" )
  268. %>