Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/23/11 20:13:55 (13 years ago)
Author:
ascheibe
Message:

#1648 updated the database scheme and dto's

Location:
branches/ClientUserManagement
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/ClientUserManagement

    • Property svn:ignore
      •  

        old new  
        11*.suo
         2*.testsettings
         3HeuristicLab.Services.Access.vsmdi
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3

    • Property svn:ignore
      •  

        old new  
        22bin
        33obj
         4HeuristicLab.Services.Access-3.3.csproj.user
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/Convert.cs

    r6820 r6825  
    2020#endregion
    2121
     22using System;
     23using System.Linq;
    2224using DA = HeuristicLab.Services.Access.DataAccess;
    2325using DT = HeuristicLab.Services.Access.DataTransfer;
     26
    2427
    2528namespace HeuristicLab.Services.ClientManagement {
     
    3134        Id = source.Id,
    3235        Description = source.Description,
    33         Name = source.Name,
    34         Type = source.Type
     36        Name = source.Name
    3537      };
    3638    }
     
    4042        Id = source.Id,
    4143        Description = source.Description,
    42         Name = source.Name,
    43         Type = source.Type
    44       };
    45     }
    46     #endregion
    47 
    48     #region Group
    49     public static DT.ClientGroup ToDto(DA.Group source) {
     44        Name = source.Name
     45      };
     46    }
     47    #endregion
     48
     49    #region ClientGroup
     50    public static DT.ClientGroup ToDto(DA.ClientGroup source) {
    5051      return new DT.ClientGroup() {
    5152        Id = source.Id,
    5253        Description = source.Description,
    53         Name = source.Name,
    54         Type = source.Type
    55       };
    56     }
    57 
    58     public static DA.Group ToEntity(DT.ClientGroup source) {
    59       return new DA.Group() {
    60         Id = source.Id,
    61         Description = source.Description,
    62         Name = source.Name,
    63         Type = source.Type
     54        Name = source.Name
     55      };
     56    }
     57
     58    public static DA.ClientGroup ToEntity(DT.ClientGroup source) {
     59      return new DA.ClientGroup() {
     60        Id = source.Id,
     61        Description = source.Description,
     62        Name = source.Name,
     63
     64      };
     65    }
     66    #endregion
     67
     68    #region Country
     69    public static DT.Country ToDto(DA.Country source) {
     70      return new DT.Country() {
     71        Id = source.Id,
     72        Name = source.Name
     73      };
     74    }
     75
     76    public static DA.Country ToEntity(DT.Country source) {
     77      return new DA.Country() {
     78        Id = source.Id,
     79        Name = source.Name,
     80
     81      };
     82    }
     83    #endregion
     84
     85    #region OperatingSystem
     86    public static DT.OperatingSystem ToDto(DA.OperatingSystem source) {
     87      return new DT.OperatingSystem() {
     88        Id = source.Id,
     89        Name = source.Name
     90      };
     91    }
     92
     93    public static DA.OperatingSystem ToEntity(DT.OperatingSystem source) {
     94      return new DA.OperatingSystem() {
     95        Id = source.Id,
     96        Name = source.Name,
     97
     98      };
     99    }
     100    #endregion
     101
     102    #region ClientType
     103    public static DT.ClientType ToDto(DA.ClientType source) {
     104      return new DT.ClientType() {
     105        Id = source.Id,
     106        Name = source.Name
     107      };
     108    }
     109
     110    public static DA.ClientType ToEntity(DT.ClientType source) {
     111      return new DA.ClientType() {
     112        Id = source.Id,
     113        Name = source.Name,
     114
     115      };
     116    }
     117    #endregion
     118
     119    #region ClientConfiguration
     120    public static DT.ClientConfiguration ToDto(DA.ClientConfiguration source) {
     121      return new DT.ClientConfiguration() {
     122        Id = source.Id,
     123        Hash = source.Hash,
     124        Description = source.Description
     125      };
     126    }
     127
     128    public static DA.ClientConfiguration ToEntity(DT.ClientConfiguration source) {
     129      return new DA.ClientConfiguration() {
     130        Id = source.Id,
     131        Hash = source.Hash,
     132        Description = source.Description
     133      };
     134    }
     135    #endregion
     136
     137    #region Plugin
     138    public static DT.Plugin ToDto(DA.Plugin source) {
     139      return new DT.Plugin() {
     140        Id = source.Id,
     141        Name = source.Name,
     142        StrongName = source.StrongName,
     143        Version = source.Version
     144      };
     145    }
     146
     147    public static DA.Plugin ToEntity(DT.Plugin source) {
     148      return new DA.Plugin() {
     149        Id = source.Id,
     150        Name = source.Name,
     151        StrongName = source.StrongName,
     152        Version = source.Version
    64153      };
    65154    }
     
    72161        Description = source.Description,
    73162        Name = source.Name,
    74         Type = source.Type,
    75         Country = source.Country,
     163        ClientConfiguration = ToDto(source.ClientConfiguration),
    76164        HeuristicLabVersion = source.HeuristicLabVersion,
    77         IPAddress = source.IPAddress,
    78         MemorySize = source.MemorySize,
    79         NumberOfCores = source.NumberOfCores,
    80         OperatingSystem = source.OperatingSystem,
     165        Country = ToDto(source.Country),
     166        OperatingSystem = ToDto(source.OperatingSystem),
     167        MemorySize = source.MemorySize.GetValueOrDefault(),
     168        Timestamp = source.Timestamp.GetValueOrDefault(),
     169        NumberOfCores = source.NumberOfCores.GetValueOrDefault(),
    81170        ProcessorType = source.ProcessorType,
    82         ClientType = source.ClientType
     171        ClientType = ToDto(source.ClientType)
    83172      };
    84173    }
     
    89178        Description = source.Description,
    90179        Name = source.Name,
    91         Type = source.Type,
    92         Country = source.Country,
     180        ClientConfiguration = ToEntity(source.ClientConfiguration),
    93181        HeuristicLabVersion = source.HeuristicLabVersion,
    94         IPAddress = source.IPAddress,
     182        Country = ToEntity(source.Country),
     183        OperatingSystem = ToEntity(source.OperatingSystem),
    95184        MemorySize = source.MemorySize,
     185        Timestamp = source.Timestamp,
    96186        NumberOfCores = source.NumberOfCores,
    97         OperatingSystem = source.OperatingSystem,
    98187        ProcessorType = source.ProcessorType,
    99         ClientType = source.ClientType
     188        ClientType = ToEntity(source.ClientType)
    100189      };
    101190    }
     
    107196        Timestamp = source.Timestamp,
    108197        ResourceId = source.ResourceId,
    109         Exception = source.Exception,
    110198        Message = source.Message
    111199      };
     
    116204        Timestamp = source.Timestamp,
    117205        ResourceId = source.ResourceId,
     206        Message = source.Message
     207      };
     208    }
     209    #endregion
     210
     211    #region ClientError
     212    public static DT.ClientError ToDto(DA.ClientError source) {
     213      return new DT.ClientError() {
     214        Id = source.Id,
     215        Timestamp = source.Timestamp,
    118216        Exception = source.Exception,
    119         Message = source.Message
    120       };
     217        UserComment = source.UserComment,
     218        ConfigDump = source.ConfigDump,
     219        ClientId = source.ClientId.GetValueOrDefault(),
     220        UserId = source.UserId.GetValueOrDefault()
     221      };
     222    }
     223
     224    public static DA.ClientError ToEntity(DT.ClientError source) {
     225      return new DA.ClientError() {
     226        Id = source.Id,
     227        Timestamp = source.Timestamp,
     228        Exception = source.Exception,
     229        UserComment = source.UserComment,
     230        ConfigDump = source.ConfigDump,
     231        ClientId = source.ClientId,
     232        UserId = source.UserId
     233      };
     234    }
     235    #endregion
     236
     237    #region UserGroup
     238    public static DT.UserGroup ToDto(DA.UserGroup source) {
     239      return new DT.UserGroup() {
     240        Id = source.Id,
     241        Name = source.Name
     242      };
     243    }
     244
     245    public static DA.UserGroup ToEntity(DT.UserGroup source) {
     246      return new DA.UserGroup() {
     247        Id = source.Id,
     248        Name = source.Name
     249      };
     250    }
     251    #endregion
     252
     253    #region User
     254    public static DT.User ToDto(DA.User source, DA.aspnet_User aspUserSource, DA.aspnet_Membership aspMembershipSource) {
     255      return new DT.User() {
     256        Id = source.Id,
     257        FullName = source.FullName,
     258        Comment = aspMembershipSource.Comment,
     259        CreationDate = aspMembershipSource.CreateDate,
     260        Email = aspMembershipSource.Email,
     261        IsApproved = aspMembershipSource.IsApproved,
     262        LastActivityDate = aspUserSource.LastActivityDate,
     263        LastLoginDate = aspMembershipSource.LastLoginDate,
     264        LastPasswordChangedDate = aspMembershipSource.LastPasswordChangedDate,
     265        UserName = aspUserSource.UserName
     266      };
     267    }
     268
     269    public static void ToEntity(DT.User source, out DA.User accessUser, out DA.aspnet_User aspUser, out DA.aspnet_Membership aspMembership, out bool userExistsInASP) {
     270      userExistsInASP = false;
     271      accessUser = new DA.User();
     272      aspUser = new DA.aspnet_User();
     273      aspMembership = new DA.aspnet_Membership();
     274
     275      if (source.Id != Guid.Empty) {
     276        using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) {
     277          var userCol = context.aspnet_Users.Where(s => s.UserId == source.Id);
     278          var membershipCol = context.aspnet_Memberships.Where(s => s.UserId == source.Id);
     279          if (userCol.Count() > 0 && membershipCol.Count() > 0) {
     280            aspUser = userCol.First();
     281            aspMembership = membershipCol.First();
     282            userExistsInASP = true;
     283          }
     284        }
     285      }
     286
     287      accessUser.Id = source.Id;
     288      accessUser.FullName = source.FullName;
     289
     290      aspUser.UserId = source.Id;
     291      aspUser.LastActivityDate = source.LastActivityDate;
     292      aspUser.UserName = source.UserName;
     293
     294      aspMembership.UserId = source.Id;
     295      aspMembership.Comment = source.Comment;
     296      aspMembership.CreateDate = source.CreationDate;
     297      aspMembership.Email = source.Email;
     298      aspMembership.IsApproved = source.IsApproved;
     299      aspMembership.LastLoginDate = source.LastLoginDate;
     300      aspMembership.LastPasswordChangedDate = source.LastPasswordChangedDate;
    121301    }
    122302    #endregion
Note: See TracChangeset for help on using the changeset viewer.