Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6246


Ignore:
Timestamp:
05/21/11 22:07:58 (14 years ago)
Author:
wtollsch
Message:

#1433 AlgorithmClass, Algorithm, ProblemClass, Problem create/update appropriate controller/models/views, File upload (Algorithm / Problem)

Location:
branches/WebApplication/MVC2/HLWebOKBAdminPlugin
Files:
8 added
17 edited

Legend:

Unmodified
Added
Removed
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AdminController.cs

    r6218 r6246  
    66using System.Web.Security;
    77using System.ServiceModel.Security;
    8 //using HLWebPluginHost.OKBService;
    98using System.Diagnostics;
    109using HLWebOKBAdminPlugin.OKBAdministrationService;
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmController.cs

    r6213 r6246  
    66using HLWebOKBAdminPlugin.Models;
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
     8using System.IO;
    89
    910namespace HLWebOKBAdminPlugin.Controllers
     
    7980        }
    8081
     82        public ActionResult UploadFile(FormCollection collection) {
     83            Session["SelectedSubMenu"] = "Algorithm";
     84
     85            long algorithmId = long.Parse(collection.Get("AlgorithmId"));
     86
     87            AlgorithmModel pm = new AlgorithmModel();
     88
     89            foreach (string inputTagName in Request.Files) {
     90                HttpPostedFileBase file = Request.Files[inputTagName];
     91                if (file.ContentLength > 0) {
     92                    // maybe for storage on server
     93                    //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName));
     94                    if (file.InputStream.CanRead) {
     95                        //file length
     96                        int fileLength = file.ContentLength;
     97
     98                        //bytearray
     99                        byte[] data = new byte[fileLength];
     100
     101                        //initialize input stream
     102                        Stream dataStream = file.InputStream;
     103
     104                        //read file into byte array
     105                        dataStream.Read(data, 0, fileLength);
     106
     107                        //save data
     108                        pm.UpdateAlgorithmData(algorithmId, data);
     109                    }//if
     110                }
     111            }//foreach
     112
     113            return View("Index", pm);
     114        }//UploadFile
     115
    81116        /// <summary>
    82117        /// Controller for Detail View
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemController.cs

    r6213 r6246  
    66using HLWebOKBAdminPlugin.Models;
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
     8using System.IO;
    89
    910namespace HLWebOKBAdminPlugin.Controllers
     
    8889            return View("Index", pm);
    8990        }
     91       
     92        public ActionResult UploadFile(FormCollection collection) {
     93            Session["SelectedSubMenu"] = "Problem";
     94
     95            long problemId = long.Parse(collection.Get("ProblemId"));           
     96
     97            ProblemModel pm = new ProblemModel();
     98
     99            foreach (string inputTagName in Request.Files) {
     100                HttpPostedFileBase file = Request.Files[inputTagName];
     101                if (file.ContentLength > 0) {
     102                    // maybe for storage on server
     103                    //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName));
     104                    if (file.InputStream.CanRead) {
     105                        //file length
     106                        int fileLength = file.ContentLength;
     107
     108                        //bytearray
     109                        byte[] data = new byte[fileLength];
     110
     111                        //initialize input stream
     112                        Stream dataStream = file.InputStream;
     113
     114                        //read file into byte array
     115                        dataStream.Read(data, 0, fileLength);
     116
     117                        //save data
     118                        pm.UpdateProblemData(problemId, data);
     119                    }//if
     120                }
     121            }//foreach
     122
     123            return View("Index", pm);
     124        }//UploadFile
    90125
    91126        /// <summary>
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/HLWebOKBAdminPlugin.csproj

    r6218 r6246  
    8888  <ItemGroup>
    8989    <Compile Include="Controllers\AdminController.cs" />
     90    <Compile Include="Controllers\AlgorithmClassController.cs" />
    9091    <Compile Include="Controllers\AlgorithmController.cs" />
    9192    <Compile Include="Controllers\HomeController.cs" />
     93    <Compile Include="Controllers\ProblemClassController.cs" />
    9294    <Compile Include="Controllers\ProblemController.cs" />
    9395    <Compile Include="Global.asax.cs">
     
    100102    <Compile Include="Models\AlgorithmClassModel.cs" />
    101103    <Compile Include="Models\AlgorithmModel.cs" />
     104    <Compile Include="Models\ProblemClassModel.cs" />
    102105    <Compile Include="Models\ProblemModel.cs" />
    103106    <Compile Include="Properties\AssemblyInfo.cs" />
     
    143146    <Content Include="Views\Admin\Problem.aspx" />
    144147    <Content Include="Views\Admin\ProblemClass.aspx" />
     148    <Content Include="Views\AlgorithmClass\Detail.aspx" />
     149    <Content Include="Views\AlgorithmClass\Index.aspx" />
    145150    <Content Include="Views\Algorithm\Detail.aspx" />
    146151    <Content Include="Views\Algorithm\Index.aspx" />
    147152    <Content Include="Views\Home\About.aspx" />
    148153    <Content Include="Views\Home\Index.aspx" />
     154    <Content Include="Views\ProblemClass\Detail.aspx" />
     155    <Content Include="Views\ProblemClass\Index.aspx" />
    149156    <Content Include="Views\Problem\Detail.aspx" />
    150157    <Content Include="Views\Problem\Index.aspx" />
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AdminModel.cs

    r6218 r6246  
    232232            return 0;
    233233        }//SaveProblem
     234
     235       
    234236    }
    235237}
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs

    r6161 r6246  
    1212
    1313        public String SelectedSubMenu { get; set; }
    14         public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } }
     14        public IList<AlgorithmClass> AlgorithmClasses {
     15            get { return AlgorithmClassGetAll(); }
     16            set { ;}
     17        }
    1518
    1619        public AlgorithmClass AlgorithmClass { get; set; }
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmModel.cs

    r6213 r6246  
    105105            return 0;
    106106        }//SaveAlgorithm
     107
     108        public void UpdateAlgorithmData(long id, byte[] data) {
     109            AdministrationServiceClient adminClient = Admin.GetClientFactory();
     110
     111            if (adminClient != null) {
     112                adminClient.UpdateAlgorithmData(id, data);
     113            }
     114        }//UpdateProblemData
    107115    }
    108116}
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemClassModel.cs

    r6161 r6246  
    1010
    1111        public String SelectedSubMenu { get; set; }
    12         public IList<ProblemClass> ProblemClasses { get { return ProblemClassGetAll(); } }
     12        public IList<ProblemClass> ProblemClasses {
     13            get { return ProblemClassGetAll();}
     14            set {;}
     15        }
    1316
    1417        public ProblemClass ProblemClass { get; set; }
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemModel.cs

    r6213 r6246  
    108108            return 0;
    109109        }//SaveProblem
     110
     111        public void UpdateProblemData(long id, byte[] data) {
     112            AdministrationServiceClient adminClient = Admin.GetClientFactory();
     113
     114            if (adminClient != null) {
     115                adminClient.UpdateProblemData(id, data);
     116            }
     117        }//UpdateProblemData
    110118    }
    111119}
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Admin/Algorithm.aspx

    r6117 r6246  
    11<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
    2 
    3 <asp:Content ID="Content3" runat="server" ContentPlaceHolderID="SubMenuContent">
    4    <% Html.RenderAction("Menu"); %>
    5 </asp:Content>
    62
    73<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Admin/AlgorithmClass.aspx

    r6162 r6246  
    99    <h2>
    1010        AlgorithmClass</h2>
    11     <asp:ListBox ID="lbxAlgorithmClasses" runat="server" DataTextField="Name" DataValueField="Id"
     11    <%--<asp:ListBox ID="lbxAlgorithmClasses" runat="server" DataTextField="Name" DataValueField="Id"
    1212        Height="350px" Style="margin-top: 0px" Width="240px" DataSourceID="odsAlgorithmClasses">
    1313    </asp:ListBox>
     
    1919    <p>
    2020        <%: Html.ActionLink("Create New", "Create") %>
    21     </p>
     21    </p>--%>
    2222
    2323    </form>
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Admin/Menu.ascx

    r6213 r6246  
    33<ul>
    44<li <% if(Session["SelectedSubMenu"] == "AlgorithmClass") {%> class="selected" <%}%>>
    5     <%: Html.ActionLink("AlgorithmClass", "AlgorithmClass", "Admin")%>
     5    <%: Html.ActionLink("AlgorithmClass", "Index", "AlgorithmClassPlgin")%>
    66</li>
    77<li <% if(Session["SelectedSubMenu"] == "Algorithm") {%> class="selected" <%}%>>
     
    99</li>
    1010<li <% if(Session["SelectedSubMenu"] == "ProblemClass") {%> class="selected" <%}%>>
    11     <%: Html.ActionLink("ProblemClass", "ProblemClass", "Admin")%>
     11    <%: Html.ActionLink("ProblemClass", "Index", "ProblemClass")%>
    1212</li>
    1313<li <% if(Session["SelectedSubMenu"] == "Problem") {%> class="selected" <%}%>>
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Admin/Problem.aspx

    r6050 r6246  
    11<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
    22
    3 
    4 <asp:Content ID="Content3" runat="server" ContentPlaceHolderID="SubMenuContent">
    5    <% Html.RenderAction("Menu"); %>
    6 </asp:Content>
    73
    84<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Admin/ProblemClass.aspx

    r6050 r6246  
    11<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
    2 
    3 <asp:Content ID="Content3" runat="server" ContentPlaceHolderID="SubMenuContent">
    4    <% Html.RenderAction("Menu"); %>
    5 </asp:Content>
    62
    73<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Problem/Detail.aspx

    r6162 r6246  
    9595        </tr>
    9696    </table>   
    97     <%: Html.ActionLink("back to Index","Index") %>
     97   
    9898    <% } %>
     99
     100    <% using (Html.BeginForm("UploadFile", "Problem", FormMethod.Post, new { enctype = "multipart/form-data" }))
     101    {%><br />
     102        <% Problem p = ((ProblemModel)Model).Problem; %>       
     103        <table border="1">
     104            <tr>
     105                <td>
     106                    File:
     107                </td>
     108                <td>
     109                    <%: Html.Hidden("ProblemId", p.Id.ToString(), p.Id.ToString()) %>
     110                    <input type="file" name="files" id="file2" size="25" />
     111                </td>
     112            </tr>
     113            <tr>
     114                <td>
     115                    Action:
     116                </td>
     117                <td>
     118                    <input type="submit" value="Upload file" />
     119                </td>
     120            </tr>
     121        </table>                             
     122        <%: Html.ActionLink("back to Index","Index") %>
     123        <% } %>
     124       
     125
    99126</asp:Content>
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Problem/Index.aspx

    r6162 r6246  
    2222            <tr>
    2323                <td>
    24                     <%: Html.ActionLink(p.Name, "Detail",new {p.Id}) %>
     24                    <%: Html.Label(p.Name)%>
    2525                </td>
    2626                <td>
     
    2929                <td>
    3030                    <%: Html.Label(p.DataTypeName)%>
     31                </td>
     32                <td>
     33                    <%: Html.ActionLink("detail", "Detail", new { p.Id })%>
    3134                </td>
    3235                <td>
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Web.config

    r6218 r6246  
    126126          </security>
    127127        </binding>
     128        <binding name="AdministrationService3" closeTimeout="00:01:00"
     129          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
     130          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
     131          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
     132          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
     133          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
     134            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
     135          <reliableSession ordered="true" inactivityTimeout="00:10:00"
     136            enabled="false" />
     137          <security mode="Message">
     138            <transport clientCredentialType="Windows" proxyCredentialType="None"
     139              realm="" />
     140            <message clientCredentialType="UserName" negotiateServiceCredential="true"
     141              algorithmSuite="Default" />
     142          </security>
     143        </binding>
    128144      </wsHttpBinding>
    129145    </bindings>
     
    150166        </identity>
    151167      </endpoint>
     168      <endpoint address="http://services.heuristiclab.com/OKB.SPR-3.3/AdministrationService.svc"
     169        binding="wsHttpBinding" bindingConfiguration="AdministrationService3"
     170        contract="OKBAdministrationService.IAdministrationService" name="AdministrationService3">
     171        <identity>
     172          <certificate encodedValue="AwAAAAEAAAAUAAAAwK1+2oAmcy/mI2P2QjyiJRh0y60gAAAAAQAAACoCAAAwggImMIIBj6ADAgECAhAIkseQ2EEhgU720qJA61gqMA0GCSqGSIb3DQEBBAUAMCQxIjAgBgNVBAMTGXNlcnZpY2VzLmhldXJpc3RpY2xhYi5jb20wHhcNMTAwNTExMTExNDAyWhcNMzkxMjMxMjM1OTU5WjAkMSIwIAYDVQQDExlzZXJ2aWNlcy5oZXVyaXN0aWNsYWIuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCq26Bwmwc7k+4W30qLQ2j+FInEL5BuH6opDY6CSlrtt3xQS/anrhvpbf3QghLDVINzcHkzbPmm/SguG4F85QLB6xO+tJaOvRo0iEK5g3c307vMIru7FJwk/OhplEQ5J1hbDgL3zOJlrWlgtqRVxCtVdF3XroI9BctOt1NkeKv9ewIDAQABo1kwVzBVBgNVHQEETjBMgBCjbgdYd4j5JgUuJ1Wo/GxroSYwJDEiMCAGA1UEAxMZc2VydmljZXMuaGV1cmlzdGljbGFiLmNvbYIQCJLHkNhBIYFO9tKiQOtYKjANBgkqhkiG9w0BAQQFAAOBgQAb/2xk2uQad68shSPl/uixWgvFI8WkxOTBopOLaLtDxwCeZ3mWVHdV9VnixHtThubnEBXAhYOCQSIXWtQuXFWO+gH3YyjTRJY5kTmXyuvBRTn3/so5SrQ7Rdlm9hf6E5YVX3tCjAy7ybUyaDUkQfmH5vmvgvpMzRfsJ1qhnUpJiQ==" />
     173        </identity>
     174      </endpoint>
    152175    </client>
    153176  </system.serviceModel>
Note: See TracChangeset for help on using the changeset viewer.