Changeset 6253 for branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Timestamp:
- 05/23/11 16:08:27 (13 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Files:
-
- 1 added
- 2 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/QueryController.cs
r6226 r6253 9 9 //using HLWebPluginHost.OKBService; 10 10 using System.Diagnostics; 11 using System.Reflection; 12 using System.Text; 11 13 using HLWebPluginHost.Models; 12 14 using HLWebOKBQueryPlugin.OKBQueryService; … … 45 47 return View(qm); 46 48 } 49 50 public ActionResult Details(long id = 0) { 51 QueryServiceClient client = Query.GetClientFactory(); 52 53 QueryModel qm = new QueryModel(); 54 Session["SelectedSubMenu"] = "Details"; 55 if (id != 0) 56 Session["QueryRunDetailId"] = id; 57 return View(qm); 58 } 59 60 public ActionResult RunCollectionDetail() { 61 QueryModel qm = new QueryModel(); 62 Session["QueryRunDetail"] = qm.getRun((long)Session["QueryRunDetailId"]); 63 return View(qm); 64 } 65 66 public string DetailValue(String id) { 67 // get current property and return value 68 string retVal = String.Empty; 69 70 RunCollectionData rcd = (RunCollectionData)Session["QueryRunDetail"]; 71 72 PropertyInfo pi = rcd.GetType().GetProperties().First(p => p.Name.Equals(id)); 73 Object pv = pi.GetValue(rcd, null); 74 75 if (pv.GetType() == typeof(bool)) 76 retVal = GetCheckBox("Value: ", (bool)pv); 77 if (pv.GetType() == typeof(int)) 78 retVal = GetTextBox("Value: ", pv.ToString()); 79 if (pv.GetType() == typeof(double)) 80 retVal = GetTextBox("Value: ", ((Double)pv).ToString("#,##0.00")); 81 if (pv.GetType() == typeof(string)) 82 retVal = GetTextBox("Value: ", (string)pv); 83 84 if (retVal.Equals(String.Empty)) 85 retVal = GetTextBox("Value:", ""); 86 87 return retVal; 88 } 89 90 91 92 93 94 /*** 95 * Helper 96 */ 97 private string GetTextBox(string caption, string value) { 98 StringBuilder sb = new StringBuilder(); 99 100 sb.Append("<label>" + caption + "</label> "); 101 sb.Append("<input type=\"text\" value=\"" + value + "\" />"); 102 103 return sb.ToString(); 104 } 105 106 private string GetCheckBox(string caption, bool value) { 107 StringBuilder sb = new StringBuilder(); 108 109 sb.Append("<label>" + caption + "</label> "); 110 sb.Append("<input type=\"checkbox\" value=\"" + value + "\""); 111 sb.Append(value ? " checked=\"checked\"" : ""); 112 sb.Append(" />"); 113 114 return sb.ToString(); 115 } 116 47 117 } 48 118 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/HLWebOKBQueryPlugin.csproj
r6226 r6253 163 163 <Content Include="Views\Home\About.aspx" /> 164 164 <Content Include="Views\Home\Index.aspx" /> 165 <Content Include="Views\Query\Details.aspx" /> 165 166 <Content Include="Views\Query\Index.aspx" /> 166 167 <EmbeddedResource Include="Views\Query\Menu.ascx" /> 167 168 <Content Include="Views\Query\Results.aspx" /> 168 169 <EmbeddedResource Include="Views\Query\RunCollectionTable.ascx" /> 170 <EmbeddedResource Include="Views\Query\RunCollectionDetail.ascx" /> 169 171 <Content Include="Views\ServiceTest\Index.aspx" /> 170 172 <Content Include="Web.config"> -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Helpers/IParams.cs
r6076 r6253 5 5 6 6 namespace HLWebOKBQueryPlugin.Helpers { 7 interface IParams {7 public interface IParams { 8 8 int Seed { get; set; } 9 9 bool SetSeedRandomly { get; set; } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Helpers/IResult.cs
r6076 r6253 5 5 6 6 namespace HLWebOKBQueryPlugin.Helpers { 7 interface IResult {7 public interface IResult { 8 8 string ExecutionTime { get; set; } 9 9 int EvaluatedSolutions { get; set; } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/QueryModel.cs
r6226 r6253 29 29 } 30 30 31 public RunCollectionData getRun(long id) { 32 QueryServiceClient client = Query.GetClientFactory(); 33 34 if (client != null) { 35 Run run = client.GetRuns(new long[1] { id }, false).ToList<Run>().First(); 36 RunCollectionData rcd = new RunCollectionData(run); 37 38 return rcd; 39 } 40 return null; 41 } 42 31 43 // just 4 testing 32 44 public IList<RunCollectionData> getTestRuns() { … … 51 63 return new List<RunCollectionData>(); 52 64 } 65 53 66 } 54 67 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Query/Menu.ascx
r6118 r6253 8 8 <%: Html.ActionLink("Results", "Results", "Query") %> 9 9 </li> 10 <% if (Session["QueryRunDetailId"] != null) { %> 11 <li <% if(Session["SelectedSubMenu"] == "Details") {%> class="selected" <%}%>> 12 <%: Html.ActionLink("Details", "Details", "Query")%> 13 </li> 14 <% } %> 10 15 <li <% if(Session["SelectedSubMenu"] == "Chart") {%> class="selected" <%}%>> 11 16 <%: Html.ActionLink("Chart", "Index", "Chart") %> -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Query/RunCollectionDetail.ascx
r5977 r6253 1 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RunCollectionDetail.ascx.cs" Inherits="HLWebOKBQueryPlugin.Views.Query.RunCollectionDetail" %> 1 <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> 2 <%@ Import Namespace="HLWebOKBQueryPlugin.Helpers" %> 3 <%@ Import Namespace="System.Reflection" %> 2 4 3 <asp:Table ID="TableRunDetail" runat="server"> 4 <asp:TableHeaderRow> 5 <asp:TableHeaderCell Text="Property" /> 6 <asp:TableHeaderCell Text="Value" /> 7 </asp:TableHeaderRow> 8 </asp:Table> 5 <div id="RunDetailProperties"> 6 <table><tr><td> 7 <table> 8 <thead> 9 <tr><th colspan="3">Result</th></tr> 10 </thead> 11 <tbody> 12 <% IResult result = (RunCollectionData)Session["QueryRunDetail"]; 13 foreach (PropertyInfo pi in typeof(IResult).GetProperties()) { 14 RouteValueDictionary rvd = new RouteValueDictionary(); 15 rvd.Add("controller", "Query"); 16 rvd.Add("id", pi.Name); %> 17 <tr> 18 <td style="width: 5%;"><%= Ajax.ActionLink("detail", "DetailValue", rvd, new AjaxOptions { UpdateTargetId = "ctrlValue" })%></td> 19 <td style="width: 45%;"><%= pi.Name %></td> 20 <td> 21 <% try { %> 22 <%= pi.GetValue(result, null).ToString()%> 23 <% } catch (Exception e) { %> 24 25 <% } %> 26 </td> 27 </tr> 28 <% } %> 29 </tbody> 30 </table> 31 32 <table> 33 <thead> 34 <tr><th colspan="3">Parameter</th></tr> 35 </thead> 36 <tbody> 37 <% IParams parameters = (RunCollectionData)Session["QueryRunDetail"]; 38 foreach (PropertyInfo pi in typeof(IParams).GetProperties()) { 39 RouteValueDictionary rvd = new RouteValueDictionary(); 40 rvd.Add("controller", "Query"); 41 rvd.Add("id", pi.Name); %> 42 <tr> 43 <td style="width: 5%;"><%= Ajax.ActionLink("detail", "DetailValue", rvd, new AjaxOptions { UpdateTargetId = "ctrlValue" })%></td> 44 <td style="width: 45%;"><%= pi.Name %></td> 45 <td> 46 <% try { %> 47 <%= pi.GetValue(parameters, null).ToString()%> 48 <% } catch (Exception e) { %> 49 50 <% } %> 51 </td> 52 </tr> 53 <% } %> 54 </tbody> 55 </table> 56 </td> 57 <td style="vertical-align: top;"> 58 <div> 59 <div id="ctrlValue"><label>Value:</label><input type="text" value="" /></div> 60 </div> 61 </td></tr></table> 62 </div> -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Query/RunCollectionTable.ascx
r6226 r6253 23 23 <td><%: Html.ActionLink("details", "Details", rvd) %></td> 24 24 25 <% foreach (PropertyInfo pi in typeof(RunCollectionData).GetProperties()) { 26 try { %> 27 <td><%= pi.GetValue(rcd, null).ToString()%></td> 28 <% } catch (Exception e) { %> 29 </td> 30 <% } 31 } %> 25 <% foreach (PropertyInfo pi in typeof(RunCollectionData).GetProperties()) { %> 26 <td> 27 <% try { %> 28 <%= pi.GetValue(rcd, null).ToString()%> 29 <% } catch (Exception e) { %> 30 31 <% } %> 32 </td> 33 34 <% } %> 32 35 </tr> 33 36 <% } %>
Note: See TracChangeset
for help on using the changeset viewer.