Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/24/10 00:23:16 (14 years ago)
Author:
hmayr
Message:

following changes (#1046):

  • extended DatabaseUtil.cs
  • extended HeuristicLabUser.cs
  • created HeuristicLabUserTest.cs
  • created AbstractHeuristicLabTest.cs
  • implemented a demo method in HeuristicLabMembershipProvider.cs to show usage of HeuristicLabUser.cs and DatabaseUtil.cs
Location:
branches/HeuristicLab.Services.Authentication Prototype/Persistence
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml

    r3942 r3943  
    44    <Type Name="HeuristicLabUser">
    55      <Column Name="id" Member="ID" Storage="_id" Type="System.Int64" IsReadOnly="true" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
    6       <Column Name="UserName" Modifier="Override" Type="System.String" IsReadOnly="true" CanBeNull="false" />
     6      <Column Name="UserName" Modifier="Virtual" Type="System.String" IsReadOnly="true" CanBeNull="false" />
    77      <Column Name="Password" Type="System.String" CanBeNull="false" />
    8       <Column Name="LastPasswordChangedDate" Modifier="Override" Type="System.DateTime" IsReadOnly="true" CanBeNull="false" />
    9       <Column Name="PasswordQuestion" Modifier="Override" Type="System.String" IsReadOnly="true" CanBeNull="false" />
     8      <Column Name="LastPasswordChangedDate" Modifier="Virtual" Type="System.DateTime" IsReadOnly="true" CanBeNull="false" />
     9      <Column Name="PasswordQuestion" Modifier="Virtual" Type="System.String" IsReadOnly="true" CanBeNull="false" />
    1010      <Column Name="PasswordAnswer" Type="System.String" CanBeNull="false" />
    11       <Column Name="Email" Modifier="Override" Type="System.String" CanBeNull="false" />
    12       <Column Name="Comment" Modifier="Override" Type="System.String" CanBeNull="false" />
     11      <Column Name="Email" Modifier="Virtual" Type="System.String" CanBeNull="false" />
     12      <Column Name="Comment" Modifier="Virtual" Type="System.String" CanBeNull="false" />
    1313      <Association Name="HeuristicLabUser_HeuristicLabUserRole" Member="HeuristicLabUserRole" ThisKey="ID" OtherKey="HeuristicLabUserID" Type="HeuristicLabUserRole" />
    1414    </Type>
    1515  </Table>
    1616  <Table Name="" Member="HeuristicLabAbstractRoles">
    17     <Type Name="HeuristicLabAbstractRole" IsInheritanceDefault="true" Modifier="Abstract">
     17    <Type Name="HeuristicLabAbstractRole" Modifier="Abstract">
    1818      <Column Name="ID" Type="System.Int64" IsReadOnly="true" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
    1919      <Column Name="roleName" Member="RoleName" Storage="_roleName" Type="System.String" CanBeNull="false" />
    2020      <Column Name="parentRoleID" Member="ParentRoleID" Storage="_parentRoleID" Type="System.Int64" CanBeNull="false" />
    21       <Column Member="RoleType" Type="System.String" IsReadOnly="true" CanBeNull="false" UpdateCheck="Always" IsDiscriminator="true" />
     21      <Column Name="RoleType" Type="System.String" IsReadOnly="true" CanBeNull="false" IsDiscriminator="true" />
     22      <Association Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole" Member="HeuristicLabAbstractRole2" ThisKey="ID" OtherKey="ParentRoleID" Type="HeuristicLabAbstractRole" />
    2223      <Association Name="HeuristicLabAbstractRole_HeuristicLabUserRole" Member="HeuristicLabUserRole" ThisKey="ID" OtherKey="HeuristicLabRoleID" Type="HeuristicLabUserRole" />
    23       <Association Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole" Member="HeuristicLabAbstractRole2" ThisKey="ID" OtherKey="ParentRoleID" Type="HeuristicLabAbstractRole" />
    2424      <Association Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole" Member="HeuristicLabAbstractRole1" ThisKey="ParentRoleID" OtherKey="ID" Type="HeuristicLabAbstractRole" IsForeignKey="true" />
    2525      <Type Name="HeuristicLabPermissionRole" InheritanceCode="permission" />
    26       <Type Name="HeuristicLabRole" InheritanceCode="role" />
     26      <Type Name="HeuristicLabRole" InheritanceCode="role" IsInheritanceDefault="true" />
    2727    </Type>
    2828  </Table>
    2929  <Table Name="" Member="HeuristicLabUserRole">
    3030    <Type Name="HeuristicLabUserRole">
    31       <Column Member="ID" Type="System.Int64" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
    32       <Column Member="HeuristicLabUserID" Type="System.Int64" CanBeNull="false" />
    33       <Column Member="HeuristicLabRoleID" Type="System.Int64" CanBeNull="false" />
     31      <Column Name="ID" Type="System.Int64" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
     32      <Column Name="HeuristicLabUserID" Type="System.Int64" CanBeNull="false" />
     33      <Column Name="HeuristicLabRoleID" Type="System.Int64" CanBeNull="false" />
    3434      <Association Name="HeuristicLabUser_HeuristicLabUserRole" Member="HeuristicLabUser" ThisKey="HeuristicLabUserID" OtherKey="ID" Type="HeuristicLabUser" IsForeignKey="true" />
    3535      <Association Name="HeuristicLabAbstractRole_HeuristicLabUserRole" Member="HeuristicLabAbstractRole" ThisKey="HeuristicLabRoleID" OtherKey="ID" Type="HeuristicLabAbstractRole" IsForeignKey="true" />
  • branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.dbml.layout

    r3942 r3943  
    2727      </nestedChildShapes>
    2828    </classShape>
    29     <inheritanceConnector edgePoints="[(5.5 : 2.22679768880208); (6.875 : 2.22679768880208)]" fixedFrom="Algorithm" fixedTo="Algorithm" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
     29    <inheritanceConnector edgePoints="[(5.5 : 2.22679768880208); (6.875 : 2.22679768880208)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
    3030      <nodes>
    3131        <classShapeMoniker Id="c7373ccc-61b3-43fb-88fa-14149d69bee9" />
     
    3333      </nodes>
    3434    </inheritanceConnector>
    35     <inheritanceConnector edgePoints="[(5.5 : 1.21719482421875); (6.875 : 1.21719482421875)]" fixedFrom="Algorithm" fixedTo="Algorithm" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
     35    <inheritanceConnector edgePoints="[(5.5 : 1.21719482421875); (6.875 : 1.21719482421875)]" fixedFrom="NotFixed" fixedTo="NotFixed" TargetRelationshipDomainClassId="7a7fe09e-e9ef-4b01-9ff3-bde95e827b62">
    3636      <nodes>
    3737        <classShapeMoniker Id="c7373ccc-61b3-43fb-88fa-14149d69bee9" />
     
    4545      </nestedChildShapes>
    4646    </classShape>
    47     <associationConnector edgePoints="[(1.5625 : 2.97280110677083); (1.5625 : 3.625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     47    <associationConnector edgePoints="[(1.5625 : 2.97280110677083); (1.5625 : 3.625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    4848      <AssociationMoniker Name="/DataClassesDataContext/HeuristicLabUser/HeuristicLabUser_HeuristicLabUserRole" />
    4949      <nodes>
     
    5252      </nodes>
    5353    </associationConnector>
    54     <associationConnector edgePoints="[(3.9687475 : 2.45359537760417); (3.9687475 : 4.35564697265625); (2.625 : 4.35564697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm">
     54    <associationConnector edgePoints="[(3.9687475 : 2.45359537760417); (3.9687475 : 4.35564697265625); (2.625 : 4.35564697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed">
    5555      <AssociationMoniker Name="/DataClassesDataContext/HeuristicLabAbstractRole/HeuristicLabAbstractRole_HeuristicLabUserRole" />
    5656      <nodes>
  • branches/HeuristicLab.Services.Authentication Prototype/Persistence/DataClasses.designer.cs

    r3942 r3943  
    22//------------------------------------------------------------------------------
    33// <auto-generated>
    4 //     Dieser Code wurde von einem Tool generiert.
    5 //     Laufzeitversion:2.0.50727.4927
     4//     This code was generated by a tool.
     5//     Runtime Version:2.0.50727.4927
    66//
    7 //     Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
    8 //     der Code erneut generiert wird.
     7//     Changes to this file may cause incorrect behavior and will be lost if
     8//     the code is regenerated.
    99// </auto-generated>
    1010//------------------------------------------------------------------------------
     
    144144   
    145145    [Column(Storage="_UserName", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
    146     public override string UserName
     146    public virtual string UserName
    147147    {
    148148      get
     
    173173   
    174174    [Column(Storage="_LastPasswordChangedDate", UpdateCheck=UpdateCheck.Never)]
    175     public override System.DateTime LastPasswordChangedDate
     175    public virtual System.DateTime LastPasswordChangedDate
    176176    {
    177177      get
     
    182182   
    183183    [Column(Storage="_PasswordQuestion", CanBeNull=false, UpdateCheck=UpdateCheck.Never)]
    184     public override string PasswordQuestion
     184    public virtual string PasswordQuestion
    185185    {
    186186      get
     
    211211   
    212212    [Column(Storage="_Email", CanBeNull=false)]
    213     public override string Email
     213    public virtual string Email
    214214    {
    215215      get
     
    231231   
    232232    [Column(Storage="_Comment", CanBeNull=false)]
    233     public override string Comment
     233    public virtual string Comment
    234234    {
    235235      get
     
    298298  [Table(Name="")]
    299299  [InheritanceMapping(Code="permission", Type=typeof(HeuristicLabPermissionRole))]
    300   [InheritanceMapping(Code="role", Type=typeof(HeuristicLabRole))]
     300  [InheritanceMapping(Code="role", Type=typeof(HeuristicLabRole), IsDefault=true)]
    301301  public abstract partial class HeuristicLabAbstractRole : INotifyPropertyChanging, INotifyPropertyChanged
    302302  {
     
    312312    private string _RoleType = default(string);
    313313   
     314    private EntitySet<HeuristicLabAbstractRole> _HeuristicLabAbstractRole2;
     315   
    314316    private EntitySet<HeuristicLabUserRole> _HeuristicLabUserRole;
    315    
    316     private EntitySet<HeuristicLabAbstractRole> _HeuristicLabAbstractRole2;
    317317   
    318318    private EntityRef<HeuristicLabAbstractRole> _HeuristicLabAbstractRole1;
     
    330330    public HeuristicLabAbstractRole()
    331331    {
     332      this._HeuristicLabAbstractRole2 = new EntitySet<HeuristicLabAbstractRole>(new Action<HeuristicLabAbstractRole>(this.attach_HeuristicLabAbstractRole2), new Action<HeuristicLabAbstractRole>(this.detach_HeuristicLabAbstractRole2));
    332333      this._HeuristicLabUserRole = new EntitySet<HeuristicLabUserRole>(new Action<HeuristicLabUserRole>(this.attach_HeuristicLabUserRole), new Action<HeuristicLabUserRole>(this.detach_HeuristicLabUserRole));
    333       this._HeuristicLabAbstractRole2 = new EntitySet<HeuristicLabAbstractRole>(new Action<HeuristicLabAbstractRole>(this.attach_HeuristicLabAbstractRole2), new Action<HeuristicLabAbstractRole>(this.detach_HeuristicLabAbstractRole2));
    334334      this._HeuristicLabAbstractRole1 = default(EntityRef<HeuristicLabAbstractRole>);
    335335      OnCreated();
     
    394394    }
    395395   
     396    [Association(Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole", Storage="_HeuristicLabAbstractRole2", ThisKey="ID", OtherKey="ParentRoleID")]
     397    public EntitySet<HeuristicLabAbstractRole> HeuristicLabAbstractRole2
     398    {
     399      get
     400      {
     401        return this._HeuristicLabAbstractRole2;
     402      }
     403      set
     404      {
     405        this._HeuristicLabAbstractRole2.Assign(value);
     406      }
     407    }
     408   
    396409    [Association(Name="HeuristicLabAbstractRole_HeuristicLabUserRole", Storage="_HeuristicLabUserRole", ThisKey="ID", OtherKey="HeuristicLabRoleID")]
    397410    public EntitySet<HeuristicLabUserRole> HeuristicLabUserRole
     
    404417      {
    405418        this._HeuristicLabUserRole.Assign(value);
    406       }
    407     }
    408    
    409     [Association(Name="HeuristicLabAbstractRole_HeuristicLabAbstractRole", Storage="_HeuristicLabAbstractRole2", ThisKey="ID", OtherKey="ParentRoleID")]
    410     public EntitySet<HeuristicLabAbstractRole> HeuristicLabAbstractRole2
    411     {
    412       get
    413       {
    414         return this._HeuristicLabAbstractRole2;
    415       }
    416       set
    417       {
    418         this._HeuristicLabAbstractRole2.Assign(value);
    419419      }
    420420    }
     
    474474    }
    475475   
     476    private void attach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
     477    {
     478      this.SendPropertyChanging();
     479      entity.HeuristicLabAbstractRole1 = this;
     480    }
     481   
     482    private void detach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
     483    {
     484      this.SendPropertyChanging();
     485      entity.HeuristicLabAbstractRole1 = null;
     486    }
     487   
    476488    private void attach_HeuristicLabUserRole(HeuristicLabUserRole entity)
    477489    {
     
    484496      this.SendPropertyChanging();
    485497      entity.HeuristicLabAbstractRole = null;
    486     }
    487    
    488     private void attach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
    489     {
    490       this.SendPropertyChanging();
    491       entity.HeuristicLabAbstractRole1 = this;
    492     }
    493    
    494     private void detach_HeuristicLabAbstractRole2(HeuristicLabAbstractRole entity)
    495     {
    496       this.SendPropertyChanging();
    497       entity.HeuristicLabAbstractRole1 = null;
    498498    }
    499499  }
  • branches/HeuristicLab.Services.Authentication Prototype/Persistence/DatabaseUtil.cs

    r3940 r3943  
    1 namespace Persistence {
     1using System;
     2
     3namespace Persistence {
    24  /// <summary>
    3   ///
     5  /// combines multiple used static methods into one class
    46  /// </summary>
    57  public class DatabaseUtil {
    68    /// <summary>
    7     ///
     9    /// creates and returns a database connection, if possible
    810    /// </summary>
    9     /// <returns></returns>
     11    /// <returns>database connection (could be null)</returns>
    1012    public static DataClassesDataContext createDataClassesDataContext() {
    11       return new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTemp.mdf");
     13      DataClassesDataContext db;
     14      try {
     15        db = new Persistence.DataClassesDataContext(@"C:\TEMP\HeuristicLabTemp.mdf");
     16      }
     17      catch (Exception) {
     18        return null;
     19      }
     20      return db;
     21    }
     22
     23    /// <summary>
     24    /// creates a new database out of the LINQ to SQL classes
     25    /// </summary>
     26    /// <param name="db">DataClassesDataContext</param>
     27    public static void createDatabase(DataClassesDataContext db) {
     28      if (db == null) {
     29        throw new ArgumentNullException("db");
     30      }
     31     
     32      if (db.DatabaseExists()) {
     33        Console.WriteLine("Deleting old database...");
     34        db.DeleteDatabase();
     35        Console.WriteLine("Deleted old database!");
     36      }
     37
     38      Console.WriteLine("Creating new database...");
     39      db.CreateDatabase();
     40      Console.WriteLine("Created new database!");
    1241    }
    1342  }
  • branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUser.cs

    r3941 r3943  
    33
    44namespace Persistence {
     5  /// <summary>
     6  /// implements the MembershipUser for HeuristicLab
     7  /// </summary>
    58  partial class HeuristicLabUser : MembershipUser {
     9    public HeuristicLabUser(string name, string email, string passwordQuestion, string comment) : this() {
     10      _UserName = name;
     11      Password = "INIT"; // just for tests
     12      _LastPasswordChangedDate = System.DateTime.Today;
     13      _PasswordQuestion = passwordQuestion;
     14      PasswordAnswer = "";
     15      Email = email;
     16      Comment = comment;
     17    }
     18
    619    public override bool ChangePassword(string oldPassword, string newPassword) {
    720      if (oldPassword == null) {
Note: See TracChangeset for help on using the changeset viewer.