Changeset 4298 for trunk/sources/HeuristicLab.Services.OKB/3.3
- Timestamp:
- 08/24/10 02:37:56 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Services.OKB/3.3
- Files:
-
- 5 deleted
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/DataService.cs
r4279 r4298 72 72 private byte[] GetData(EntityType type, int id) { 73 73 Log("loading data", type, id); 74 OKBDataContext okb = new OKBDataContext(); 75 switch (type) { 76 case EntityType.Algorithm: 77 Algorithm algorithm = okb.Algorithms.Single(a => a.Id == id); 78 if (algorithm.AlgorithmData == null) { 79 algorithm.AlgorithmData = new AlgorithmData() { 80 AlgorithmId = algorithm.Id, 81 Data = new Binary(new byte[0]) 82 }; 83 okb.SubmitChanges(); 84 } 85 return algorithm.AlgorithmData.Data.ToArray(); 86 break; 87 case EntityType.Problem: 88 Problem problem = okb.Problems.Single(p => p.Id == id); 89 if (problem.ProblemData == null) { 90 problem.ProblemData = new ProblemData() { 91 ProblemId = problem.Id, 92 Data = new Binary(new byte[0]) 93 }; 94 okb.SubmitChanges(); 95 } 96 return problem.ProblemData.Data.ToArray(); 97 break; 98 default: 99 throw new FaultException("Unsupported EntityType"); 74 using (OKBDataContext okb = new OKBDataContext()) { 75 switch (type) { 76 case EntityType.Algorithm: 77 Algorithm algorithm = okb.Algorithms.Single(a => a.Id == id); 78 if (algorithm.AlgorithmData == null) { 79 algorithm.AlgorithmData = new AlgorithmData() { 80 AlgorithmId = algorithm.Id, 81 Data = new Binary(new byte[0]) 82 }; 83 okb.SubmitChanges(); 84 } 85 return algorithm.AlgorithmData.Data.ToArray(); 86 break; 87 case EntityType.Problem: 88 Problem problem = okb.Problems.Single(p => p.Id == id); 89 if (problem.ProblemData == null) { 90 problem.ProblemData = new ProblemData() { 91 ProblemId = problem.Id, 92 Data = new Binary(new byte[0]) 93 }; 94 okb.SubmitChanges(); 95 } 96 return problem.ProblemData.Data.ToArray(); 97 break; 98 default: 99 throw new FaultException("Unsupported EntityType"); 100 } 100 101 } 101 okb.Dispose();102 102 } 103 103 -
trunk/sources/HeuristicLab.Services.OKB/3.3/ExperimentKit.cs
r4297 r4298 21 21 22 22 using System.Runtime.Serialization; 23 using HeuristicLab.Services.OKB.DataAccess; 23 24 24 namespace HeuristicLab.Services.OKB.DataAccess { 25 25 namespace HeuristicLab.Services.OKB { 26 /// <summary> 27 /// Contains an <see cref="Algorithm"/> and a <see cref="Problem"/> populated with all 28 /// required data to execute experiments. 29 /// </summary> 26 30 [DataContract] 27 31 public class ExperimentKit { 32 /// <summary> 33 /// Gets an <see cref="Algorithm"/> populated with all required data to execute 34 /// experiments. 35 /// </summary> 36 /// <value>An <see cref="Algorithm"/>.</value> 28 37 [DataMember] 29 38 public Algorithm Algorithm { get; set; } 30 39 40 /// <summary> 41 /// Gets a <see cref="Problem"/> populated with all required data to execute 42 /// experiments. 43 /// </summary> 44 /// <value>A <see cref="Problem"/>.</value> 31 45 [DataMember] 32 46 public Problem Problem { get; set; } -
trunk/sources/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj
r4283 r4298 120 120 <RequiredTargetFramework>3.0</RequiredTargetFramework> 121 121 </Reference> 122 <Reference Include="System.ServiceModel.Activation" />123 122 <Reference Include="System.ServiceProcess" /> 124 123 <Reference Include="System.Xml.Linq"> … … 134 133 <Compile Include="AdminService.cs" /> 135 134 <Compile Include="AttributeSelector.cs" /> 136 <Compile Include="CertificateServiceHostFactory.cs" />137 <Compile Include="CustomCertificateValidator.cs" />138 <Compile Include="CertificateServiceHost.cs" />139 135 <Compile Include="DataService.cs" /> 136 <Compile Include="ExperimentKit.cs" /> 140 137 <Compile Include="Interfaces\IDataService.cs" /> 141 138 <Compile Include="Interfaces\ITableService.cs" /> … … 157 154 <ItemGroup> 158 155 <None Include="app.config" /> 159 <EmbeddedResource Include="client.cer" />160 <EmbeddedResource Include="server.pfx" />161 156 <None Include="HeuristicLab.snk" /> 162 157 </ItemGroup> -
trunk/sources/HeuristicLab.Services.OKB/3.3/Hoster.cs
r4279 r4298 53 53 } 54 54 55 static ILog logger = log4net.LogManager.GetLogger("HeuristicLab. OKB.Hoster");55 static ILog logger = log4net.LogManager.GetLogger("HeuristicLab.Services.OKB.Hoster"); 56 56 57 57 static void UnhandledException(object sender, UnhandledExceptionEventArgs e) { … … 64 64 65 65 private static void StartService(Type type) { 66 ServiceHost host = new CertificateServiceHost(type);66 ServiceHost host = new ServiceHost(type); 67 67 try { 68 68 host.Open(); -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunnerService.cs
r4279 r4298 142 142 public void AddRun(Algorithm algorithm, Problem problem, Project project) { 143 143 Log("adding run for {0}@{1}({2})[{3}, {4}]", 144 algorithm.Name, problem.Name, project.Name, authentication.User.Name, authentication.Client.Name);144 algorithm.Name, problem.Name, project.Name, currentUser.Name, currentClient.Name); 145 145 try { 146 146 using (OKBDataContext okb = new OKBDataContext()) { 147 var user = okb.Users.Single(u => u.Id == authentication.User.Id); 148 var client = okb.Clients.Single(c => c.Id == authentication.Client.Id); 149 Experiment experiment = GetOrCreateExperiment(algorithm, problem, project, authentication.User, okb); 147 Experiment experiment = GetOrCreateExperiment(algorithm, problem, project, currentUser, okb); 150 148 Run run = new Run() { 151 149 Experiment = experiment, 152 UserId = authentication.User.Id,153 ClientId = authentication.Client.Id,150 UserId = currentUser.Id, 151 ClientId = currentClient.Id, 154 152 FinishedDate = DateTime.Now, 155 153 ResultValues = algorithm.ResultValues … … 175 173 Log("reusing existing experiment"); 176 174 Experiment experiment = experimentQuery.First(); 177 if (experiment.ExperimentCreators.Where(ec => ec.UserId == user.Id).Count() == 0) {178 experiment.ExperimentCreators.Add(new ExperimentCreator() { UserId = user.Id });179 }180 175 return experiment; 181 176 } else { … … 187 182 ParameterValues = algorithm.ParameterValues 188 183 }; 189 experiment.ExperimentCreators.Add(new ExperimentCreator() { UserId = user.Id });190 184 okb.Experiments.InsertOnSubmit(experiment); 191 185 return experiment; … … 292 286 /// </summary> 293 287 /// <returns> 294 /// 288 /// <c>true</c> if this instance is connected; otherwise, <c>false</c>. 295 289 /// </returns> 296 290 public bool IsConnected() { 297 return authentication != null; 298 } 299 300 Authentication authentication = null; 291 return currentUser != null; 292 } 293 294 User currentUser = null; 295 Client currentClient = null; 301 296 302 297 /// <summary> … … 309 304 /// <param name="clientname">The clientname.</param> 310 305 /// <returns> 311 /// 306 /// <c>true</c> if the login was successful; <c>false</c> otherwise. 312 307 /// </returns> 313 308 public bool Login(string username, string clientname) { … … 320 315 } 321 316 using (OKBDataContext okb = new OKBDataContext()) { 322 authentication = new Authentication() { 323 User = okb.Users.SingleOrDefault(u => u.Name == username), 324 Client = okb.Clients.SingleOrDefault(c => c.Name == clientname) 325 }; 326 if (authentication.User == null) { 327 User user = new User() { Name = username, Id = Guid.NewGuid() }; 328 okb.Users.InsertOnSubmit(user); 329 authentication.User = user; 317 currentUser = okb.Users.SingleOrDefault(u => u.Name == username); 318 currentClient = okb.Clients.SingleOrDefault(c => c.Name == clientname); 319 if (currentUser == null) { 320 currentUser = new User() { Name = username, Id = Guid.NewGuid() }; 321 okb.Users.InsertOnSubmit(currentUser); 330 322 okb.SubmitChanges(); 331 323 } 332 if (authentication.Client == null) { 333 Client client = new Client() { Name = clientname, Id = Guid.NewGuid() }; 334 okb.Clients.InsertOnSubmit(client); 335 authentication.Client = client; 324 if (currentClient == null) { 325 currentClient = new Client() { Name = clientname, Id = Guid.NewGuid() }; 326 okb.Clients.InsertOnSubmit(currentClient); 336 327 okb.SubmitChanges(); 337 328 } 338 Log(" auth = {0}", authentication);329 Log(" user = {0}, client = {1}", currentUser, currentClient); 339 330 return true; 340 331 } … … 346 337 public void Logout() { 347 338 Log("Logging out"); 348 authentication = null; 339 currentUser = null; 340 currentClient = null; 349 341 } 350 342 -
trunk/sources/HeuristicLab.Services.OKB/3.3/TableService.cs
r4279 r4298 66 66 public void UpdateDataTable(DataTable updatedRows, string tableName) { 67 67 logger.Info("updating table: " + tableName); 68 Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab. OKB." + tableName, true);68 Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab.Services.OKB.DataAccess." + tableName, true); 69 69 var properties = from p in tableType.GetProperties() 70 70 where SupportedTypes.Contains(p.PropertyType) … … 126 126 public void DeleteTableRows(int[] ids, string tableName) { 127 127 logger.Info("delete rows from table: " + tableName); 128 Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab. OKB." + tableName, true);128 Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab.Services.OKB.DataAccess" + tableName, true); 129 129 OKBDataContext okb = GetDataContext(); 130 130 ITable table = okb.GetTable(tableType); … … 148 148 public DataTable PrepareDataTable(string tableName, out int count) { 149 149 logger.Info("preparing data table: " + tableName); 150 Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab. OKB." + tableName, true);150 Type tableType = Assembly.GetAssembly(typeof(Run)).GetType("HeuristicLab.Services.OKB.DataAccess" + tableName, true); 151 151 properties = from p in tableType.GetProperties() 152 152 where SupportedTypes.Contains(p.PropertyType) -
trunk/sources/HeuristicLab.Services.OKB/3.3/app.config
r4279 r4298 1 1 <?xml version="1.0"?> 2 2 <configuration> 3 <connectionStrings> 4 <add name="HeuristicLab.Authentication" 5 connectionString="data source=localhost;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication"/> 6 <add name="HeuristicLab.Services.OKB.DataAccess.Properties.Settings.OKBConnectionString" 7 connectionString="Data Source=localhost;Initial Catalog=HeuristicLab.OKB;Integrated Security=SSPI" 8 providerName="System.Data.SqlClient" /> 9 </connectionStrings> 10 11 <system.web> 12 <authentication mode="Forms" /> 13 <compilation debug="true" targetFramework="4.0" /> 14 15 <membership> 16 <providers> 17 <clear/> 18 <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication" 19 enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" 20 maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" 21 applicationName="HeuristicLab.Authentication" /> 22 </providers> 23 </membership> 24 25 <roleManager enabled="true"> 26 <providers> 27 <clear/> 28 <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication" /> 29 </providers> 30 </roleManager> 31 </system.web> 32 3 33 <system.serviceModel> 4 34 <bindings> 5 35 <netTcpBinding> 6 36 <binding name="LargeMessages" openTimeout="00:00:30" receiveTimeout="00:00:30" sendTimeout="00:00:30" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 7 <security mode=" Transport">8 < transport clientCredentialType="Certificate" protectionLevel="EncryptAndSign"/>37 <security mode="Message"> 38 <message clientCredentialType="UserName"/> 9 39 </security> 10 40 <readerQuotas maxArrayLength="2147483647"/> … … 13 43 </netTcpBinding> 14 44 </bindings> 45 15 46 <client/> 47 16 48 <behaviors> 17 49 <serviceBehaviors> … … 19 51 <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/OKB/RunnerMex"/> 20 52 <serviceDebug includeExceptionDetailInFaults="true"/> 53 <serviceAuthorization principalPermissionMode="UseAspNetRoles" 54 roleProviderName="AspNetSqlRoleProvider" /> 55 <serviceCredentials> 56 <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" /> 57 <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 58 membershipProviderName="AspNetSqlMembershipProvider"/> 59 </serviceCredentials> 21 60 </behavior> 22 61 <behavior name="AdminServiceBehaviour"> 23 62 <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/OKB/AdminMex"/> 24 63 <serviceDebug includeExceptionDetailInFaults="true"/> 64 <serviceAuthorization principalPermissionMode="UseAspNetRoles" 65 roleProviderName="AspNetSqlRoleProvider" /> 66 <serviceCredentials> 67 <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" /> 68 <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 69 membershipProviderName="AspNetSqlMembershipProvider"/> 70 </serviceCredentials> 25 71 </behavior> 26 72 <behavior name="TableServiceBehaviour"> 27 73 <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/OKB/TableMex"/> 28 74 <serviceDebug includeExceptionDetailInFaults="true"/> 75 <serviceAuthorization principalPermissionMode="UseAspNetRoles" 76 roleProviderName="AspNetSqlRoleProvider" /> 77 <serviceCredentials> 78 <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" /> 79 <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 80 membershipProviderName="AspNetSqlMembershipProvider"/> 81 </serviceCredentials> 29 82 </behavior> 30 83 <behavior name="QueryServiceBehaviour"> 31 84 <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/OKB/QueryMex"/> 32 85 <serviceDebug includeExceptionDetailInFaults="true"/> 86 <serviceAuthorization principalPermissionMode="UseAspNetRoles" 87 roleProviderName="AspNetSqlRoleProvider" /> 88 <serviceCredentials> 89 <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" /> 90 <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 91 membershipProviderName="AspNetSqlMembershipProvider"/> 92 </serviceCredentials> 33 93 </behavior> 34 94 <behavior name="DataServiceBehaviour"> 35 95 <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/OKB/DataMex"/> 36 96 <serviceDebug includeExceptionDetailInFaults="true"/> 97 <serviceAuthorization principalPermissionMode="UseAspNetRoles" 98 roleProviderName="AspNetSqlRoleProvider" /> 99 <serviceCredentials> 100 <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName" /> 101 <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 102 membershipProviderName="AspNetSqlMembershipProvider"/> 103 </serviceCredentials> 37 104 </behavior> 38 105 </serviceBehaviors> 39 106 </behaviors> 107 40 108 <services> 41 <service behaviorConfiguration="RunnerServiceBehaviour" name="HeuristicLab. OKB.RunnerService">109 <service behaviorConfiguration="RunnerServiceBehaviour" name="HeuristicLab.Services.OKB.RunnerService"> 42 110 <endpoint address="http://localhost:8000/OKB/RunnerMex" binding="mexHttpBinding" contract="IMetadataExchange"/> 43 <endpoint address="net.tcp://localhost:8001/OKB/RunnerService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab.OKB.IRunnerService"> 44 <identity> 45 <dns value="HEAL"/> 46 </identity> 111 <endpoint address="net.tcp://localhost:8001/OKB/RunnerService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab.Services.OKB.IRunnerService"> 47 112 </endpoint> 48 113 </service> 49 <service behaviorConfiguration="AdminServiceBehaviour" name="HeuristicLab. OKB.AdminService">114 <service behaviorConfiguration="AdminServiceBehaviour" name="HeuristicLab.Services.OKB.AdminService"> 50 115 <endpoint address="http://localhost:8000/OKB/AdminMex" binding="mexHttpBinding" contract="IMetadataExchange"/> 51 <endpoint address="net.tcp://localhost:8001/OKB/AdminService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab. OKB.IAdminService"/>116 <endpoint address="net.tcp://localhost:8001/OKB/AdminService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab.Services.OKB.IAdminService"/> 52 117 </service> 53 <service behaviorConfiguration="TableServiceBehaviour" name="HeuristicLab. OKB.TableService">118 <service behaviorConfiguration="TableServiceBehaviour" name="HeuristicLab.Services.OKB.TableService"> 54 119 <endpoint address="http://localhost:8000/OKB/TableMex" binding="mexHttpBinding" contract="IMetadataExchange"/> 55 <endpoint address="net.tcp://localhost:8001/OKB/TableService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab. OKB.ITableService"/>120 <endpoint address="net.tcp://localhost:8001/OKB/TableService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab.Services.OKB.ITableService"/> 56 121 </service> 57 <service behaviorConfiguration="QueryServiceBehaviour" name="HeuristicLab. OKB.QueryService">122 <service behaviorConfiguration="QueryServiceBehaviour" name="HeuristicLab.Services.OKB.QueryService"> 58 123 <endpoint address="http://localhost:8000/OKB/QueryMex" binding="mexHttpBinding" contract="IMetadataExchange"/> 59 <endpoint address="net.tcp://localhost:8001/OKB/QueryService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab. OKB.IQueryService"/>124 <endpoint address="net.tcp://localhost:8001/OKB/QueryService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab.Services.OKB.IQueryService"/> 60 125 </service> 61 <service behaviorConfiguration="DataServiceBehaviour" name="HeuristicLab. OKB.DataService">126 <service behaviorConfiguration="DataServiceBehaviour" name="HeuristicLab.Services.OKB.DataService"> 62 127 <endpoint address="http://localhost:8000/OKB/DataMex" binding="mexHttpBinding" contract="IMetadataExchange"/> 63 <endpoint address="net.tcp://localhost:8001/OKB/DataService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab. OKB.IDataService"/>128 <endpoint address="net.tcp://localhost:8001/OKB/DataService" binding="netTcpBinding" bindingConfiguration="LargeMessages" contract="HeuristicLab.Services.OKB.IDataService"/> 64 129 </service> 65 130 </services>
Note: See TracChangeset
for help on using the changeset viewer.