Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6253


Ignore:
Timestamp:
05/23/11 16:08:27 (13 years ago)
Author:
msammer
Message:

#1520 Added the Run-detail-view which shows the properties and the values of a run. Property-values are shown in a AJAX-based extra view

Location:
branches/WebApplication/MVC2
Files:
1 added
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/QueryController.cs

    r6226 r6253  
    99//using HLWebPluginHost.OKBService;
    1010using System.Diagnostics;
     11using System.Reflection;
     12using System.Text;
    1113using HLWebPluginHost.Models;
    1214using HLWebOKBQueryPlugin.OKBQueryService;
     
    4547            return View(qm);
    4648        }
     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
    47117    }
    48118}
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/HLWebOKBQueryPlugin.csproj

    r6226 r6253  
    163163    <Content Include="Views\Home\About.aspx" />
    164164    <Content Include="Views\Home\Index.aspx" />
     165    <Content Include="Views\Query\Details.aspx" />
    165166    <Content Include="Views\Query\Index.aspx" />
    166167    <EmbeddedResource Include="Views\Query\Menu.ascx" />
    167168    <Content Include="Views\Query\Results.aspx" />
    168169    <EmbeddedResource Include="Views\Query\RunCollectionTable.ascx" />
     170    <EmbeddedResource Include="Views\Query\RunCollectionDetail.ascx" />
    169171    <Content Include="Views\ServiceTest\Index.aspx" />
    170172    <Content Include="Web.config">
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Helpers/IParams.cs

    r6076 r6253  
    55
    66namespace HLWebOKBQueryPlugin.Helpers {
    7     interface IParams {
     7    public interface IParams {
    88        int Seed { get; set; }
    99        bool SetSeedRandomly { get; set; }
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Helpers/IResult.cs

    r6076 r6253  
    55
    66namespace HLWebOKBQueryPlugin.Helpers {
    7     interface IResult {
     7    public interface IResult {
    88        string ExecutionTime { get; set; }
    99        int EvaluatedSolutions { get; set; }
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/QueryModel.cs

    r6226 r6253  
    2929        }
    3030
     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
    3143        // just 4 testing
    3244        public IList<RunCollectionData> getTestRuns() {
     
    5163            return new List<RunCollectionData>();
    5264        }
     65
    5366    }
    5467}
  • branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Views/Query/Menu.ascx

    r6118 r6253  
    88    <%: Html.ActionLink("Results", "Results", "Query") %>
    99</li>
     10<% if (Session["QueryRunDetailId"] != null) { %>
     11<li <% if(Session["SelectedSubMenu"] == "Details") {%> class="selected" <%}%>>
     12    <%: Html.ActionLink("Details", "Details", "Query")%>
     13</li>
     14<% } %>
    1015<li <% if(Session["SelectedSubMenu"] == "Chart") {%> class="selected" <%}%>>
    1116    <%: 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"  %>
    24
    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                            &nbsp;
     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                            &nbsp;
     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  
    2323                    <td><%: Html.ActionLink("details", "Details", rvd) %></td>
    2424
    25                     <% foreach (PropertyInfo pi in typeof(RunCollectionData).GetProperties()) {
    26                            try { %>
    27                     <td><%= pi.GetValue(rcd, null).ToString()%></td>
    28                     <%     } catch (Exception e) { %>
    29                         &nbsp;</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                         &nbsp;
     31                    <%   } %>
     32                    </td>
     33
     34                    <%   } %>
    3235                </tr>
    3336               <% } %>
  • branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Views/Shared/Site.Master

    r5072 r6253  
    88  </title>
    99  <link href="../../Content/themes/hl/Site.css" rel="stylesheet" type="text/css" />
     10  <!-- for ajax -->
     11  <script src="<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>" type="text/javascript"></script> 
     12  <script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js") %>" type="text/javascript"></script>
     13
    1014</head>
    1115<body>
Note: See TracChangeset for help on using the changeset viewer.