Changeset 6858 for branches/ClientUserManagement
- Timestamp:
- 09/30/11 15:44:34 (13 years ago)
- Location:
- branches/ClientUserManagement
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientUserManagement/HeuristicLab.Services.Access-3.3.Tests/App.config
r6840 r6858 2 2 <configuration> 3 3 <connectionStrings> 4 <add name="HeuristicLab. Services.Directoy.DataAccess.Properties.Settings.HeuristicLab_AuthenticationConnectionString"4 <add name="HeuristicLab.Authentication" 5 5 connectionString="Data Source=.;Initial Catalog=HeuristicLab.Authentication;Integrated Security=True" 6 6 providerName="System.Data.SqlClient" /> … … 9 9 providerName="System.Data.SqlClient" /> 10 10 </connectionStrings> 11 <system.web> 12 <membership defaultProvider="AspNetSqlMembershipProvider" userIsOnlineTimeWindow="20"> 13 <providers> 14 <clear /> 15 <add name="AspNetSqlMemberShipProvider" 16 type="System.Web.Security.SqlMembershipProvider" 17 connectionStringName="HeuristicLab.Authentication" 18 enablePasswordRetrieval="false" 19 enablePasswordReset="true" 20 requiresQuestionAndAnswer="false" 21 passwordFormat="Hashed" 22 applicationName="HeuristicLab.Authentication" 23 requiresUniqueEmail="false" 24 minRequiredPasswordLength="1" 25 minRequiredNonalphanumericCharacters="0" 26 maxInvalidPasswordAttempts="50" /> 27 </providers> 28 </membership> 29 <authentication mode="Windows" /> 30 <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider"> 31 <providers> 32 <clear /> 33 <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 34 connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication" /> 35 </providers> 36 </roleManager> 37 </system.web> 11 38 </configuration> -
branches/ClientUserManagement/HeuristicLab.Services.Access-3.3.Tests/UnitTest.cs
r6852 r6858 35 35 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 36 36 context.ExecuteCommand("DELETE FROM dbo.ResourceResourceGroup"); 37 context.ExecuteCommand("DELETE FROM dbo.ClientLog"); 37 38 context.ExecuteCommand("DELETE FROM dbo.Resource"); 38 39 context.ExecuteCommand("DELETE FROM dbo.ClientConfiguration"); 39 40 context.ExecuteCommand("DELETE FROM dbo.ClientError"); 40 context.ExecuteCommand("DELETE FROM dbo.ClientLog");41 41 context.ExecuteCommand("DELETE FROM dbo.ClientType"); 42 42 context.ExecuteCommand("DELETE FROM dbo.Country"); … … 50 50 51 51 [TestMethod] 52 public void AddClient Test() {52 public void AddClientGroupTest() { 53 53 ClearDB(); 54 54 AccessService service = new AccessService(); … … 138 138 } 139 139 140 140 [TestMethod] 141 public void AddUser() { 142 ClearDB(); 143 AccessService service = new AccessService(); 144 145 DT.User user = new DT.User(); 146 user.FullName = "Max Mustermann"; 147 user.UserName = "max"; 148 user.IsApproved = true; 149 user.Comment = "this is a comment"; 150 user.Email = "max@mail.com"; 151 152 DT.User newUser = service.AddUser(user); 153 var users = service.GetAllUsers(); 154 Assert.AreEqual(1, users.Where(x => x.UserName == newUser.UserName).Count()); 155 service.DeleteUser(newUser); 156 users = service.GetAllUsers(); 157 Assert.AreEqual(0, users.Where(x => x.UserName == newUser.UserName).Count()); 158 } 159 160 [TestMethod] 161 public void AddUserGroup() { 162 ClearDB(); 163 AccessService service = new AccessService(); 164 165 DT.User user = new DT.User(); 166 user.FullName = "Max Mustermann"; 167 user.UserName = "max"; 168 user.IsApproved = true; 169 user.Comment = "this is a comment"; 170 user.Email = "max@mail.com"; 171 172 DT.User user2 = new DT.User(); 173 user2.FullName = "Franz Fritz"; 174 user2.UserName = "Franz"; 175 user2.IsApproved = true; 176 user2.Comment = "this is a franz comment"; 177 user2.Email = "franz@mail.com"; 178 179 DT.User newUser = service.AddUser(user); 180 DT.User newUser2 = service.AddUser(user2); 181 182 DT.UserGroup userGroup = new DT.UserGroup(); 183 userGroup.Name = "testGroup"; 184 userGroup.Id = service.AddUserGroup(userGroup); 185 Assert.AreEqual(1, service.GetAllUserGroups().Count()); 186 187 service.AddUserGroupBaseToGroup(newUser, userGroup); 188 service.AddUserGroupBaseToGroup(newUser2, userGroup); 189 Assert.AreEqual(2, service.GetUserGroupMapping().Count()); 190 191 DT.Role role = service.AddRole(new DT.Role() { Name = "NewGroup" }); 192 Assert.AreEqual(1, service.GetRoles().Where(x => x.Name == role.Name).Count()); 193 194 service.AddRoleToGroup(userGroup, role); 195 Assert.AreEqual(1, service.GetUserRoles(newUser).Count()); 196 Assert.AreEqual(1, service.GetUserRoles(newUser2).Count()); 197 198 service.RemoveRoleFromGroup(userGroup, role); 199 200 Assert.AreEqual(0, service.GetUserRoles(newUser).Count()); 201 Assert.AreEqual(0, service.GetUserRoles(newUser2).Count()); 202 203 service.DeleteUser(newUser); 204 service.DeleteUser(newUser2); 205 var users = service.GetAllUsers(); 206 Assert.AreEqual(0, users.Where(x => x.UserName == newUser.UserName).Count()); 207 208 service.DeleteRole(role); 209 Assert.AreEqual(0, service.GetRoles().Where(x => x.Name == role.Name).Count()); 210 } 211 212 [TestMethod] 213 public void AddClientError() { 214 ClearDB(); 215 AccessService service = new AccessService(); 216 217 DT.ClientError error = new DT.ClientError(); 218 error.Timestamp = DateTime.Now; 219 error.UserComment = "this happend when i clicked on..."; 220 error.Exception = "Exception"; 221 error.ConfigDump = "config"; 222 223 service.ReportError(error); 224 Assert.AreEqual(1, service.GetClientErrors().Count()); 225 service.DeleteError(service.GetClientErrors().First()); 226 Assert.AreEqual(0, service.GetClientErrors().Count()); 227 } 141 228 } 142 229 } -
branches/ClientUserManagement/HeuristicLab.Services.Access.DataAccess/3.3/ClientManagement.dbml
r6852 r6858 2 2 <Connection Mode="AppSettings" ConnectionString="Data Source=.;Initial Catalog=HeuristicLab.ClientManagement;Integrated Security=True" SettingsObjectName="HeuristicLab.Services.Access.DataAccess.Properties.Settings" SettingsPropertyName="HeuristicLab_ClientManagementConnectionString" Provider="System.Data.SqlClient" /> 3 3 <Table Name="dbo.Resource" Member="Resources"> 4 <Type Name="Resource" InheritanceCode="Resource" >4 <Type Name="Resource" InheritanceCode="Resource" IsInheritanceDefault="true"> 5 5 <Column Name="Id" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> 6 6 <Column Name="Name" Type="System.String" DbType="NVarChar(MAX) NOT NULL" CanBeNull="false" /> … … 10 10 <Association Name="Resource_ResourceResourceGroup1" Member="ResourceResourceGroupsParents" Storage="_ResourceResourceGroups1" ThisKey="Id" OtherKey="ResourceId" Type="ResourceResourceGroup" /> 11 11 <Association Name="Resource_ClientLog" Member="ClientLogs" ThisKey="Id" OtherKey="ResourceId" Type="ClientLog" /> 12 <Association Name="Resource_ClientError" Member="ClientErrors" ThisKey="Id" OtherKey="ClientId" Type="ClientError" />13 12 <Association Name="Resource_ResourcePlugin" Member="ResourcePlugins" ThisKey="Id" OtherKey="ResourceId" Type="ResourcePlugin" /> 14 <Type Name="Client" InheritanceCode="Client" IsInheritanceDefault="true">13 <Type Name="Client" InheritanceCode="Client"> 15 14 <Column Name="HeuristicLabVersion" Type="System.String" DbType="NVarChar(MAX)" CanBeNull="false" /> 16 15 <Column Name="MemorySize" Type="System.Int32" DbType="Int" CanBeNull="true" /> … … 55 54 <Column Name="ClientId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 56 55 <Column Name="UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 57 <Association Name="Resource_ClientError" Member="Resource" ThisKey="ClientId" OtherKey="Id" Type="Resource" IsForeignKey="true" />58 <Association Name="UserGroupBase_ClientError" Member="UserGroupBase" ThisKey="UserId" OtherKey="Id" Type="UserGroupBase" IsForeignKey="true" />59 56 </Type> 60 57 </Table> 61 58 <Table Name="dbo.UserGroup" Member="UserGroupBases"> 62 <Type Name="UserGroupBase" InheritanceCode="UserGroupBase" >63 <Column Name="Id" AutoSync="Never" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />59 <Type Name="UserGroupBase" InheritanceCode="UserGroupBase" IsInheritanceDefault="true"> 60 <Column Name="Id" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 64 61 <Column Name="Type" Type="System.String" DbType="NVarChar(10) NOT NULL" CanBeNull="false" IsDiscriminator="true" /> 65 <Association Name="UserGroupBase_ClientError" Member="ClientErrors" ThisKey="Id" OtherKey="UserId" Type="ClientError" />66 62 <Association Name="UserGroupBase_UserGroupUserGroup" Member="UserGroupUserGroupsChilds" Storage="_UserGroupUserGroups" ThisKey="Id" OtherKey="UserGroupId" Type="UserGroupUserGroup" /> 67 63 <Association Name="UserGroupBase_UserGroupUserGroup1" Member="UserGroupUserGroupsParents" Storage="_UserGroupUserGroups1" ThisKey="Id" OtherKey="UserGroupUserGroupId" Type="UserGroupUserGroup" /> -
branches/ClientUserManagement/HeuristicLab.Services.Access.DataAccess/3.3/ClientManagement.dbml.layout
r6852 r6858 72 72 </nestedChildShapes> 73 73 </classShape> 74 <associationConnector edgePoints="[(6.625 : 1.84699625651042); (10.375 : 1.84699625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed">75 <AssociationMoniker Name="/ClientManagementDataContext/Resource/Resource_ClientError" />76 <nodes>77 <classShapeMoniker Id="20c6e07e-aa12-43dc-87d6-dae5bf173da4" />78 <classShapeMoniker Id="5e8ae5e1-4026-47e5-91fb-9607de024aad" />79 </nodes>80 </associationConnector>81 74 <classShape Id="452ce94a-9bd2-4968-9a5f-a0ab1dba6b2e" absoluteBounds="7.875, 3.875, 2, 1.1939925130208327"> 82 75 <DataClassMoniker Name="/ClientManagementDataContext/UserGroupBase" /> … … 165 158 </nodes> 166 159 </inheritanceConnector> 167 <associationConnector edgePoints="[(9.875 : 3.90625); (10.53125 : 3.90625); (10.53125 : 2.65549967447917)]" fixedFrom="NotFixed" fixedTo="NotFixed">168 <AssociationMoniker Name="/ClientManagementDataContext/UserGroupBase/UserGroupBase_ClientError" />169 <nodes>170 <classShapeMoniker Id="452ce94a-9bd2-4968-9a5f-a0ab1dba6b2e" />171 <classShapeMoniker Id="5e8ae5e1-4026-47e5-91fb-9607de024aad" />172 </nodes>173 </associationConnector>174 160 <associationConnector edgePoints="[(9.875 : 4.53449625651042); (10.75 : 4.53449625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 175 161 <AssociationMoniker Name="/ClientManagementDataContext/UserGroupBase/UserGroupBase_UserGroupUserGroup" /> -
branches/ClientUserManagement/HeuristicLab.Services.Access.DataAccess/3.3/ClientManagement.designer.cs
r6852 r6858 197 197 198 198 [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Resource")] 199 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="Resource", Type=typeof(Resource) )]200 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="Client", Type=typeof(Client) , IsDefault=true)]199 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="Resource", Type=typeof(Resource), IsDefault=true)] 200 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="Client", Type=typeof(Client))] 201 201 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="ClientGroup", Type=typeof(ClientGroup))] 202 202 public partial class Resource : INotifyPropertyChanging, INotifyPropertyChanged … … 218 218 219 219 private EntitySet<ClientLog> _ClientLogs; 220 221 private EntitySet<ClientError> _ClientErrors;222 220 223 221 private EntitySet<ResourcePlugin> _ResourcePlugins; … … 242 240 this._ResourceResourceGroups1 = new EntitySet<ResourceResourceGroup>(new Action<ResourceResourceGroup>(this.attach_ResourceResourceGroups1), new Action<ResourceResourceGroup>(this.detach_ResourceResourceGroups1)); 243 241 this._ClientLogs = new EntitySet<ClientLog>(new Action<ClientLog>(this.attach_ClientLogs), new Action<ClientLog>(this.detach_ClientLogs)); 244 this._ClientErrors = new EntitySet<ClientError>(new Action<ClientError>(this.attach_ClientErrors), new Action<ClientError>(this.detach_ClientErrors));245 242 this._ResourcePlugins = new EntitySet<ResourcePlugin>(new Action<ResourcePlugin>(this.attach_ResourcePlugins), new Action<ResourcePlugin>(this.detach_ResourcePlugins)); 246 243 OnCreated(); … … 366 363 } 367 364 368 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ClientError", Storage="_ClientErrors", ThisKey="Id", OtherKey="ClientId")]369 public EntitySet<ClientError> ClientErrors370 {371 get372 {373 return this._ClientErrors;374 }375 set376 {377 this._ClientErrors.Assign(value);378 }379 }380 381 365 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ResourcePlugin", Storage="_ResourcePlugins", ThisKey="Id", OtherKey="ResourceId")] 382 366 public EntitySet<ResourcePlugin> ResourcePlugins … … 443 427 444 428 private void detach_ClientLogs(ClientLog entity) 445 {446 this.SendPropertyChanging();447 entity.Resource = null;448 }449 450 private void attach_ClientErrors(ClientError entity)451 {452 this.SendPropertyChanging();453 entity.Resource = this;454 }455 456 private void detach_ClientErrors(ClientError entity)457 429 { 458 430 this.SendPropertyChanging(); … … 1158 1130 private System.Nullable<System.Guid> _UserId; 1159 1131 1160 private EntityRef<Resource> _Resource;1161 1162 private EntityRef<UserGroupBase> _UserGroupBase;1163 1164 1132 #region Extensibility Method Definitions 1165 1133 partial void OnLoaded(); … … 1184 1152 public ClientError() 1185 1153 { 1186 this._Resource = default(EntityRef<Resource>);1187 this._UserGroupBase = default(EntityRef<UserGroupBase>);1188 1154 OnCreated(); 1189 1155 } … … 1300 1266 if ((this._ClientId != value)) 1301 1267 { 1302 if (this._Resource.HasLoadedOrAssignedValue)1303 {1304 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();1305 }1306 1268 this.OnClientIdChanging(value); 1307 1269 this.SendPropertyChanging(); … … 1324 1286 if ((this._UserId != value)) 1325 1287 { 1326 if (this._UserGroupBase.HasLoadedOrAssignedValue)1327 {1328 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();1329 }1330 1288 this.OnUserIdChanging(value); 1331 1289 this.SendPropertyChanging(); … … 1337 1295 } 1338 1296 1339 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ClientError", Storage="_Resource", ThisKey="ClientId", OtherKey="Id", IsForeignKey=true)]1340 public Resource Resource1341 {1342 get1343 {1344 return this._Resource.Entity;1345 }1346 set1347 {1348 Resource previousValue = this._Resource.Entity;1349 if (((previousValue != value)1350 || (this._Resource.HasLoadedOrAssignedValue == false)))1351 {1352 this.SendPropertyChanging();1353 if ((previousValue != null))1354 {1355 this._Resource.Entity = null;1356 previousValue.ClientErrors.Remove(this);1357 }1358 this._Resource.Entity = value;1359 if ((value != null))1360 {1361 value.ClientErrors.Add(this);1362 this._ClientId = value.Id;1363 }1364 else1365 {1366 this._ClientId = default(Nullable<System.Guid>);1367 }1368 this.SendPropertyChanged("Resource");1369 }1370 }1371 }1372 1373 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="UserGroupBase_ClientError", Storage="_UserGroupBase", ThisKey="UserId", OtherKey="Id", IsForeignKey=true)]1374 public UserGroupBase UserGroupBase1375 {1376 get1377 {1378 return this._UserGroupBase.Entity;1379 }1380 set1381 {1382 UserGroupBase previousValue = this._UserGroupBase.Entity;1383 if (((previousValue != value)1384 || (this._UserGroupBase.HasLoadedOrAssignedValue == false)))1385 {1386 this.SendPropertyChanging();1387 if ((previousValue != null))1388 {1389 this._UserGroupBase.Entity = null;1390 previousValue.ClientErrors.Remove(this);1391 }1392 this._UserGroupBase.Entity = value;1393 if ((value != null))1394 {1395 value.ClientErrors.Add(this);1396 this._UserId = value.Id;1397 }1398 else1399 {1400 this._UserId = default(Nullable<System.Guid>);1401 }1402 this.SendPropertyChanged("UserGroupBase");1403 }1404 }1405 }1406 1407 1297 public event PropertyChangingEventHandler PropertyChanging; 1408 1298 … … 1427 1317 1428 1318 [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.UserGroup")] 1429 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="UserGroupBase", Type=typeof(UserGroupBase) )]1319 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="UserGroupBase", Type=typeof(UserGroupBase), IsDefault=true)] 1430 1320 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="User", Type=typeof(User))] 1431 1321 [global::System.Data.Linq.Mapping.InheritanceMappingAttribute(Code="UserGroup", Type=typeof(UserGroup))] … … 1438 1328 1439 1329 private string _Type; 1440 1441 private EntitySet<ClientError> _ClientErrors;1442 1330 1443 1331 private EntitySet<UserGroupUserGroup> _UserGroupUserGroups; … … 1457 1345 public UserGroupBase() 1458 1346 { 1459 this._ClientErrors = new EntitySet<ClientError>(new Action<ClientError>(this.attach_ClientErrors), new Action<ClientError>(this.detach_ClientErrors));1460 1347 this._UserGroupUserGroups = new EntitySet<UserGroupUserGroup>(new Action<UserGroupUserGroup>(this.attach_UserGroupUserGroups), new Action<UserGroupUserGroup>(this.detach_UserGroupUserGroups)); 1461 1348 this._UserGroupUserGroups1 = new EntitySet<UserGroupUserGroup>(new Action<UserGroupUserGroup>(this.attach_UserGroupUserGroups1), new Action<UserGroupUserGroup>(this.detach_UserGroupUserGroups1)); … … 1463 1350 } 1464 1351 1465 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true , IsDbGenerated=true)]1352 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)] 1466 1353 public System.Guid Id 1467 1354 { … … 1503 1390 } 1504 1391 1505 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="UserGroupBase_ClientError", Storage="_ClientErrors", ThisKey="Id", OtherKey="UserId")]1506 public EntitySet<ClientError> ClientErrors1507 {1508 get1509 {1510 return this._ClientErrors;1511 }1512 set1513 {1514 this._ClientErrors.Assign(value);1515 }1516 }1517 1518 1392 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="UserGroupBase_UserGroupUserGroup", Storage="_UserGroupUserGroups", ThisKey="Id", OtherKey="UserGroupId")] 1519 1393 public EntitySet<UserGroupUserGroup> UserGroupUserGroupsChilds … … 1560 1434 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 1561 1435 } 1562 }1563 1564 private void attach_ClientErrors(ClientError entity)1565 {1566 this.SendPropertyChanging();1567 entity.UserGroupBase = this;1568 }1569 1570 private void detach_ClientErrors(ClientError entity)1571 {1572 this.SendPropertyChanging();1573 entity.UserGroupBase = null;1574 1436 } 1575 1437 -
branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/AccessService.cs
r6852 r6858 96 96 select c; 97 97 if (query.Count() > 0) { 98 99 //delete affiliation first 100 var queryMapping = context.ResourceResourceGroups.Where(x => x.ResourceId == client.Id); 101 if (queryMapping.Count() > 0) { 102 context.ResourceResourceGroups.DeleteAllOnSubmit(queryMapping); 103 } 104 98 105 context.Resources.DeleteOnSubmit(query.First()); 99 106 context.SubmitChanges(); … … 349 356 public void DeleteUser(DT.User user) { 350 357 if (user.Id != null && user.Id != Guid.Empty) { 358 //delete asp.net user 351 359 Membership.DeleteUser(user.UserName); 352 360 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 353 context.UserGroupBases.DeleteOnSubmit(Convert.ToEntity(user)); 354 context.SubmitChanges(); 361 var query = context.UserGroupBases.OfType<DA.User>().Where(x => x.Id == user.Id); 362 if (query.Count() > 0) { 363 364 //delete affiliation first 365 var queryMapping = context.UserGroupUserGroups.Where(x => x.UserGroupId == user.Id); 366 if (queryMapping.Count() > 0) { 367 context.UserGroupUserGroups.DeleteAllOnSubmit(queryMapping); 368 } 369 370 //delete user from access db 371 context.UserGroupBases.DeleteOnSubmit(query.First()); 372 context.SubmitChanges(); 373 } 355 374 } 356 375 } … … 405 424 public Guid AddUserGroup(DT.UserGroup group) { 406 425 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 426 //because id is not automatically set because of user, we have to do it here manually for group 427 group.Id = Guid.NewGuid(); 407 428 context.UserGroupBases.InsertOnSubmit(Convert.ToEntity(group)); 408 429 context.SubmitChanges(); … … 464 485 #region Roles 465 486 public IEnumerable<DT.Role> GetRoles() { 466 throw new System.NotImplementedException(); 487 using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) { 488 var query = from u in context.aspnet_Roles 489 select Convert.ToDto(u); 490 return query.ToList(); 491 } 467 492 } 468 493 469 494 public DT.Role AddRole(DT.Role role) { 470 throw new System.NotImplementedException(); 471 } 472 473 public void UpdateRole(DT.Role role) { 474 throw new System.NotImplementedException(); 495 Roles.CreateRole(role.Name); 496 return role; 475 497 } 476 498 477 499 public void DeleteRole(DT.Role role) { 478 throw new System.NotImplementedException();500 Roles.DeleteRole(role.Name); 479 501 } 480 502 481 503 public IEnumerable<DT.Role> GetUserRoles(DT.User user) { 482 throw new System.NotImplementedException(); 504 var roles = Roles.GetRolesForUser(user.UserName); 505 return roles.Select(x => new DT.Role() { Name = x }); 506 } 507 508 public void AddRoleToGroup(DT.UserGroup userGroup, DT.Role role) { 509 Guid[] userIds; 510 string[] aspUsers; 511 512 using (DA.ClientManagementDataContext accessContext = new DA.ClientManagementDataContext()) { 513 userIds = (from u in accessContext.UserGroupUserGroups 514 where u.UserGroupUserGroupId == userGroup.Id 515 select u.UserGroupId).ToArray(); 516 } 517 518 using (DA.ASPNETAuthenticationDataContext aspContext = new DA.ASPNETAuthenticationDataContext()) { 519 aspUsers = (from u in aspContext.aspnet_Users 520 where userIds.Contains(u.UserId) 521 select u.UserName).ToArray(); 522 } 523 524 Roles.AddUsersToRole(aspUsers, role.Name); 525 526 } 527 528 public void RemoveRoleFromGroup(DT.UserGroup userGroup, DT.Role role) { 529 Guid[] userIds; 530 string[] aspUsers; 531 532 using (DA.ClientManagementDataContext accessContext = new DA.ClientManagementDataContext()) { 533 userIds = (from u in accessContext.UserGroupUserGroups 534 where u.UserGroupUserGroupId == userGroup.Id 535 select u.UserGroupId).ToArray(); 536 } 537 538 using (DA.ASPNETAuthenticationDataContext aspContext = new DA.ASPNETAuthenticationDataContext()) { 539 aspUsers = (from u in aspContext.aspnet_Users 540 where userIds.Contains(u.UserId) 541 select u.UserName).ToArray(); 542 } 543 544 Roles.RemoveUsersFromRole(aspUsers.ToArray(), role.Name); 483 545 } 484 546 #endregion … … 486 548 #region Error Reporting 487 549 public void ReportError(DT.ClientError error) { 488 throw new System.NotImplementedException(); 550 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 551 context.ClientErrors.InsertOnSubmit(Convert.ToEntity(error)); 552 context.SubmitChanges(); 553 } 489 554 } 490 555 491 556 public IEnumerable<DT.ClientError> GetClientErrors() { 492 throw new System.NotImplementedException(); 557 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 558 var query = from c in context.ClientErrors 559 select Convert.ToDto(c); 560 return query.ToList(); 561 } 493 562 } 494 563 495 564 public IEnumerable<DT.ClientError> GetLastClientErrors(DateTime startDate) { 496 throw new System.NotImplementedException(); 565 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 566 var query = from c in context.ClientErrors 567 where c.Timestamp >= startDate 568 select Convert.ToDto(c); 569 return query.ToList(); 570 } 497 571 } 498 572 499 573 public void DeleteError(DT.ClientError error) { 500 throw new System.NotImplementedException(); 574 using (DA.ClientManagementDataContext context = new DA.ClientManagementDataContext()) { 575 var query = context.ClientErrors.Where(x => x.Id == error.Id); 576 if (query.Count() > 0) { 577 context.ClientErrors.DeleteOnSubmit(query.First()); 578 context.SubmitChanges(); 579 } 580 } 501 581 } 502 582 #endregion -
branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/App.config
r6815 r6858 11 11 <clear /> 12 12 <add name="AspNetSqlMemberShipProvider" 13 type="System.Web.Security.SqlMembershipProvider" 14 connectionStringName="HeuristicLab.Authentication" 15 enablePasswordRetrieval="false" 16 enablePasswordReset="true" 17 requiresQuestionAndAnswer="false" 18 passwordFormat="Hashed" 19 applicationName="HeuristicLab.Authentication" /> 13 type="System.Web.Security.SqlMembershipProvider" 14 connectionStringName="HeuristicLab.Authentication" 15 enablePasswordRetrieval="false" 16 enablePasswordReset="true" 17 requiresQuestionAndAnswer="false" 18 passwordFormat="Hashed" 19 applicationName="HeuristicLab.Authentication" 20 requiresUniqueEmail="false" 21 minRequiredPasswordLength="1" 22 minRequiredNonalphanumericCharacters="0" 23 maxInvalidPasswordAttempts="50" /> 20 24 </providers> 21 25 </membership> -
branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/Convert.cs
r6852 r6858 360 360 } 361 361 #endregion 362 363 #region Role 364 public static DT.Role ToDto(DA.aspnet_Role r) { 365 return new DT.Role() { 366 Name = r.RoleName 367 }; 368 } 369 public static DA.aspnet_Role ToEntity(DT.Role r) { 370 return new DA.aspnet_Role() { 371 RoleName = r.Name 372 }; 373 } 374 #endregion 362 375 } 363 376 } -
branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/IAccessService.cs
r6852 r6858 172 172 Role AddRole(Role role); 173 173 174 [OperationContract]175 void UpdateRole(Role role); 174 /*[OperationContract] 175 void UpdateRole(Role role);*/ 176 176 177 177 [OperationContract] … … 180 180 [OperationContract] 181 181 IEnumerable<Role> GetUserRoles(User user); 182 183 [OperationContract] 184 void AddRoleToGroup(UserGroup userGroup, Role role); 185 186 [OperationContract] 187 void RemoveRoleFromGroup(UserGroup userGroup, Role role); 182 188 #endregion 183 189
Note: See TracChangeset
for help on using the changeset viewer.