Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/11 10:38:36 (13 years ago)
Author:
ascheibe
Message:

#1233

  • moved DTO's to Services.Hive project
  • removed Services.Hive.Common project
  • some cleanups
  • added DTO's for enums
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3
Files:
4 added
7 edited
29 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Convert.cs

    r6703 r6717  
    2424using System.Data.Linq;
    2525using System.Linq;
    26 using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
    27 
    28 namespace HeuristicLab.Services.Hive.DataAccess {
     26using DB = HeuristicLab.Services.Hive.DataAccess;
     27using DT = HeuristicLab.Services.Hive.DataTransfer;
     28
     29
     30namespace HeuristicLab.Services.Hive.DataTransfer {
    2931  public static class Convert {
    3032    #region Job
    31     public static DT.Job ToDto(Job source) {
     33    public static DT.Job ToDto(DB.Job source) {
    3234      if (source == null) return null;
    3335      return new DT.Job {
     
    4042        PluginsNeededIds = (source.RequiredPlugins == null ? new List<Guid>() : source.RequiredPlugins.Select(x => x.PluginId).ToList()),
    4143        LastHeartbeat = source.LastHeartbeat,
    42         State = source.State,
     44        State = Convert.ToDto(source.State),
    4345        StateLog = (source.StateLogs == null ? new List<DT.StateLog>() : source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()),
    4446        IsParentJob = source.IsParentJob,
    4547        FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished,
    46         Command = source.Command,
     48        Command = Convert.ToDto(source.Command),
    4749        LastJobDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate),
    4850        HiveExperimentId = source.HiveExperimentId,
     
    5052      };
    5153    }
    52     public static Job ToEntity(DT.Job source) {
    53       if (source == null) return null;
    54       var entity = new Job(); ToEntity(source, entity);
    55       return entity;
    56     }
    57     public static void ToEntity(DT.Job source, Job target) {
     54
     55    public static DB.Job ToEntity(DT.Job source) {
     56      if (source == null) return null;
     57      var entity = new DB.Job(); ToEntity(source, entity);
     58      return entity;
     59    }
     60    public static void ToEntity(DT.Job source, DB.Job target) {
    5861      if ((source != null) && (target != null)) {
    5962        target.JobId = source.Id;
     
    6467        target.Priority = source.Priority;
    6568        target.LastHeartbeat = source.LastHeartbeat;
    66         target.State = source.State;
    67         if (target.StateLogs == null) target.StateLogs = new EntitySet<StateLog>();
     69        target.State = Convert.ToEntity(source.State);
     70        if (target.StateLogs == null) target.StateLogs = new EntitySet<DB.StateLog>();
    6871        foreach (DT.StateLog sl in source.StateLog.Where(x => x.Id == Guid.Empty)) {
    6972          target.StateLogs.Add(Convert.ToEntity(sl));
     
    7174        target.IsParentJob = source.IsParentJob;
    7275        target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
    73         target.Command = source.Command;
     76        target.Command = Convert.ToEntity(source.Command);
    7477        // RequiredPlugins are added by Dao
    7578        target.HiveExperimentId = source.HiveExperimentId;
     
    8083
    8184    #region JobData
    82     public static DT.JobData ToDto(JobData source) {
     85    public static DT.JobData ToDto(DB.JobData source) {
    8386      if (source == null) return null;
    8487      return new DT.JobData { JobId = source.JobId, Data = source.Data.ToArray(), LastUpdate = source.LastUpdate };
    8588    }
    86     public static JobData ToEntity(DT.JobData source) {
    87       if (source == null) return null;
    88       var entity = new JobData(); ToEntity(source, entity);
    89       return entity;
    90     }
    91     public static void ToEntity(DT.JobData source, JobData target) {
     89    public static DB.JobData ToEntity(DT.JobData source) {
     90      if (source == null) return null;
     91      var entity = new DB.JobData(); ToEntity(source, entity);
     92      return entity;
     93    }
     94    public static void ToEntity(DT.JobData source, DB.JobData target) {
    9295      if ((source != null) && (target != null)) {
    9396        target.JobId = source.JobId; target.Data = new Binary(source.Data); target.LastUpdate = source.LastUpdate;
     
    97100
    98101    #region StateLog
    99     public static DT.StateLog ToDto(StateLog source) {
    100       if (source == null) return null;
    101       return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = source.State, UserId = source.UserId };
    102     }
    103     public static StateLog ToEntity(DT.StateLog source) {
    104       if (source == null) return null;
    105       var entity = new StateLog(); ToEntity(source, entity);
    106       return entity;
    107     }
    108     public static void ToEntity(DT.StateLog source, StateLog target) {
    109       if ((source != null) && (target != null)) {
    110         target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = source.State; target.UserId = source.UserId;
     102    public static DT.StateLog ToDto(DB.StateLog source) {
     103      if (source == null) return null;
     104      return new DT.StateLog { Id = source.StateLogId, DateTime = source.DateTime, Exception = source.Exception, JobId = source.JobId, SlaveId = source.SlaveId, State = Convert.ToDto(source.State), UserId = source.UserId };
     105    }
     106    public static DB.StateLog ToEntity(DT.StateLog source) {
     107      if (source == null) return null;
     108      var entity = new DB.StateLog(); ToEntity(source, entity);
     109      return entity;
     110    }
     111    public static void ToEntity(DT.StateLog source, DB.StateLog target) {
     112      if ((source != null) && (target != null)) {
     113        target.StateLogId = source.Id; target.DateTime = source.DateTime; target.Exception = source.Exception; target.JobId = source.JobId; target.SlaveId = source.SlaveId; target.State = Convert.ToEntity(source.State); target.UserId = source.UserId;
    111114      }
    112115    }
     
    114117
    115118    #region Downtimes
    116     public static DT.Downtime ToDto(Downtime source) {
     119    public static DT.Downtime ToDto(DB.Downtime source) {
    117120      if (source == null) return null;
    118121      return new DT.Downtime { Id = source.DowntimeId, AllDayEvent = source.AllDayEvent, EndDate = source.EndDate, Recurring = source.Recurring, RecurringId = source.RecurringId, ResourceId = source.ResourceId, StartDate = source.StartDate };
    119122    }
    120     public static Downtime ToEntity(DT.Downtime source) {
    121       if (source == null) return null;
    122       var entity = new Downtime(); ToEntity(source, entity);
    123       return entity;
    124     }
    125     public static void ToEntity(DT.Downtime source, Downtime target) {
     123    public static DB.Downtime ToEntity(DT.Downtime source) {
     124      if (source == null) return null;
     125      var entity = new DB.Downtime(); ToEntity(source, entity);
     126      return entity;
     127    }
     128    public static void ToEntity(DT.Downtime source, DB.Downtime target) {
    126129      if ((source != null) && (target != null)) {
    127130        target.DowntimeId = source.Id; target.AllDayEvent = source.AllDayEvent; target.EndDate = source.EndDate; target.Recurring = source.Recurring; target.RecurringId = source.RecurringId; target.ResourceId = source.ResourceId; target.StartDate = source.StartDate;
     
    131134
    132135    #region HiveExperiment
    133     public static DT.HiveExperiment ToDto(HiveExperiment source) {
     136    public static DT.HiveExperiment ToDto(DB.HiveExperiment source) {
    134137      if (source == null) return null;
    135138      return new DT.HiveExperiment { Id = source.HiveExperimentId, Description = source.Description, Name = source.Name, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds, LastAccessed = source.LastAccessed };
    136139    }
    137     public static HiveExperiment ToEntity(DT.HiveExperiment source) {
    138       if (source == null) return null;
    139       var entity = new HiveExperiment(); ToEntity(source, entity);
    140       return entity;
    141     }
    142     public static void ToEntity(DT.HiveExperiment source, HiveExperiment target) {
     140    public static DB.HiveExperiment ToEntity(DT.HiveExperiment source) {
     141      if (source == null) return null;
     142      var entity = new DB.HiveExperiment(); ToEntity(source, entity);
     143      return entity;
     144    }
     145    public static void ToEntity(DT.HiveExperiment source, DB.HiveExperiment target) {
    143146      if ((source != null) && (target != null)) {
    144147        target.HiveExperimentId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames; target.LastAccessed = source.LastAccessed;
     
    148151
    149152    #region HiveExperimentPermission
    150     public static DT.HiveExperimentPermission ToDto(HiveExperimentPermission source) {
    151       if (source == null) return null;
    152       return new DT.HiveExperimentPermission { HiveExperimentId = source.HiveExperimentId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = source.Permission };
    153     }
    154     public static HiveExperimentPermission ToEntity(DT.HiveExperimentPermission source) {
    155       if (source == null) return null;
    156       var entity = new HiveExperimentPermission(); ToEntity(source, entity);
    157       return entity;
    158     }
    159     public static void ToEntity(DT.HiveExperimentPermission source, HiveExperimentPermission target) {
    160       if ((source != null) && (target != null)) {
    161         target.HiveExperimentId = source.HiveExperimentId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = source.Permission;
     153    public static DT.HiveExperimentPermission ToDto(DB.HiveExperimentPermission source) {
     154      if (source == null) return null;
     155      return new DT.HiveExperimentPermission { HiveExperimentId = source.HiveExperimentId, GrantedUserId = source.GrantedUserId, GrantedByUserId = source.GrantedByUserId, Permission = Convert.ToDto(source.Permission) };
     156    }
     157    public static DB.HiveExperimentPermission ToEntity(DT.HiveExperimentPermission source) {
     158      if (source == null) return null;
     159      var entity = new DB.HiveExperimentPermission(); ToEntity(source, entity);
     160      return entity;
     161    }
     162    public static void ToEntity(DT.HiveExperimentPermission source, DB.HiveExperimentPermission target) {
     163      if ((source != null) && (target != null)) {
     164        target.HiveExperimentId = source.HiveExperimentId; target.GrantedUserId = source.GrantedUserId; target.GrantedByUserId = source.GrantedByUserId; target.Permission = Convert.ToEntity(source.Permission);
    162165      }
    163166    }
     
    165168
    166169    #region Plugin
    167     public static DT.Plugin ToDto(Plugin source) {
     170    public static DT.Plugin ToDto(DB.Plugin source) {
    168171      if (source == null) return null;
    169172      return new DT.Plugin { Id = source.PluginId, Name = source.Name, Version = new Version(source.Version), UserId = source.UserId, DateCreated = source.DateCreated, Hash = source.Hash };
    170173    }
    171     public static Plugin ToEntity(DT.Plugin source) {
    172       if (source == null) return null;
    173       var entity = new Plugin(); ToEntity(source, entity);
    174       return entity;
    175     }
    176     public static void ToEntity(DT.Plugin source, Plugin target) {
     174    public static DB.Plugin ToEntity(DT.Plugin source) {
     175      if (source == null) return null;
     176      var entity = new DB.Plugin(); ToEntity(source, entity);
     177      return entity;
     178    }
     179    public static void ToEntity(DT.Plugin source, DB.Plugin target) {
    177180      if ((source != null) && (target != null)) {
    178181        target.PluginId = source.Id; target.Name = source.Name; target.Version = source.Version.ToString(); target.UserId = source.UserId; target.DateCreated = source.DateCreated; target.Hash = source.Hash;
     
    182185
    183186    #region PluginData
    184     public static DT.PluginData ToDto(PluginData source) {
     187    public static DT.PluginData ToDto(DB.PluginData source) {
    185188      if (source == null) return null;
    186189      return new DT.PluginData { Id = source.PluginDataId, PluginId = source.PluginId, Data = source.Data.ToArray(), FileName = source.FileName };
    187190    }
    188     public static PluginData ToEntity(DT.PluginData source) {
    189       if (source == null) return null;
    190       var entity = new PluginData(); ToEntity(source, entity);
    191       return entity;
    192     }
    193     public static void ToEntity(DT.PluginData source, PluginData target) {
     191    public static DB.PluginData ToEntity(DT.PluginData source) {
     192      if (source == null) return null;
     193      var entity = new DB.PluginData(); ToEntity(source, entity);
     194      return entity;
     195    }
     196    public static void ToEntity(DT.PluginData source, DB.PluginData target) {
    194197      if ((source != null) && (target != null)) {
    195198        target.PluginDataId = source.Id; target.PluginId = source.PluginId; target.Data = new Binary(source.Data); target.FileName = source.FileName;
     
    199202
    200203    #region Slave
    201     public static DT.Slave ToDto(Slave source) {
     204    public static DT.Slave ToDto(DB.Slave source) {
    202205      if (source == null) return null;
    203206      return new DT.Slave {
     
    211214        Memory = source.Memory,
    212215        Name = source.Name,
    213         SlaveState = source.SlaveState,
    214         CpuArchitecture = source.CpuArchitecture,
     216        SlaveState = Convert.ToDto(source.SlaveState),
     217        CpuArchitecture = Convert.ToDto(source.CpuArchitecture),
    215218        OperatingSystem = source.OperatingSystem,
    216219        LastHeartbeat = source.LastHeartbeat,
     
    218221      };
    219222    }
    220     public static Slave ToEntity(DT.Slave source) {
    221       if (source == null) return null;
    222       var entity = new Slave(); ToEntity(source, entity);
    223       return entity;
    224     }
    225     public static void ToEntity(DT.Slave source, Slave target) {
     223    public static DB.Slave ToEntity(DT.Slave source) {
     224      if (source == null) return null;
     225      var entity = new DB.Slave(); ToEntity(source, entity);
     226      return entity;
     227    }
     228    public static void ToEntity(DT.Slave source, DB.Slave target) {
    226229      if ((source != null) && (target != null)) {
    227230        target.ResourceId = source.Id;
     
    234237        target.Memory = source.Memory;
    235238        target.Name = source.Name;
    236         target.SlaveState = source.SlaveState;
    237         target.CpuArchitecture = source.CpuArchitecture;
     239        target.SlaveState = Convert.ToEntity(source.SlaveState);
     240        target.CpuArchitecture = Convert.ToEntity(source.CpuArchitecture);
    238241        target.OperatingSystem = source.OperatingSystem;
    239242        target.LastHeartbeat = source.LastHeartbeat;
     
    244247
    245248    #region SlaveGroup
    246     public static DT.SlaveGroup ToDto(SlaveGroup source) {
     249    public static DT.SlaveGroup ToDto(DB.SlaveGroup source) {
    247250      if (source == null) return null;
    248251      return new DT.SlaveGroup { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId };
    249252    }
    250     public static SlaveGroup ToEntity(DT.SlaveGroup source) {
    251       if (source == null) return null;
    252       var entity = new SlaveGroup(); ToEntity(source, entity);
    253       return entity;
    254     }
    255     public static void ToEntity(DT.SlaveGroup source, SlaveGroup target) {
     253    public static DB.SlaveGroup ToEntity(DT.SlaveGroup source) {
     254      if (source == null) return null;
     255      var entity = new DB.SlaveGroup(); ToEntity(source, entity);
     256      return entity;
     257    }
     258    public static void ToEntity(DT.SlaveGroup source, DB.SlaveGroup target) {
    256259      if ((source != null) && (target != null)) {
    257260        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
     
    261264
    262265    #region Resource
    263     public static DT.Resource ToDto(Resource source) {
     266    public static DT.Resource ToDto(DB.Resource source) {
    264267      if (source == null) return null;
    265268      return new DT.Resource { Id = source.ResourceId, Name = source.Name, ParentResourceId = source.ParentResourceId };
    266269    }
    267     public static Resource ToEntity(DT.Resource source) {
    268       if (source == null) return null;
    269       var entity = new Resource(); ToEntity(source, entity);
    270       return entity;
    271     }
    272     public static void ToEntity(DT.Resource source, Resource target) {
     270    public static DB.Resource ToEntity(DT.Resource source) {
     271      if (source == null) return null;
     272      var entity = new DB.Resource(); ToEntity(source, entity);
     273      return entity;
     274    }
     275    public static void ToEntity(DT.Resource source, DB.Resource target) {
    273276      if ((source != null) && (target != null)) {
    274277        target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
     
    278281
    279282    #region Statistics
    280     public static DT.Statistics ToDto(Statistics source) {
     283    public static DT.Statistics ToDto(DB.Statistics source) {
    281284      if (source == null) return null;
    282285      return new DT.Statistics {
     
    287290      };
    288291    }
    289     public static Statistics ToEntity(DT.Statistics source) {
    290       if (source == null) return null;
    291       var entity = new Statistics(); ToEntity(source, entity);
    292       return entity;
    293     }
    294     public static void ToEntity(DT.Statistics source, Statistics target) {
     292    public static DB.Statistics ToEntity(DT.Statistics source) {
     293      if (source == null) return null;
     294      var entity = new DB.Statistics(); ToEntity(source, entity);
     295      return entity;
     296    }
     297    public static void ToEntity(DT.Statistics source, DB.Statistics target) {
    295298      if ((source != null) && (target != null)) {
    296299        target.StatisticsId = source.Id;
     
    302305
    303306    #region SlaveStatistics
    304     public static DT.SlaveStatistics ToDto(SlaveStatistics source) {
     307    public static DT.SlaveStatistics ToDto(DB.SlaveStatistics source) {
    305308      if (source == null) return null;
    306309      return new DT.SlaveStatistics {
     
    314317      };
    315318    }
    316     public static SlaveStatistics ToEntity(DT.SlaveStatistics source) {
    317       if (source == null) return null;
    318       var entity = new SlaveStatistics(); ToEntity(source, entity);
    319       return entity;
    320     }
    321     public static void ToEntity(DT.SlaveStatistics source, SlaveStatistics target) {
     319    public static DB.SlaveStatistics ToEntity(DT.SlaveStatistics source) {
     320      if (source == null) return null;
     321      var entity = new DB.SlaveStatistics(); ToEntity(source, entity);
     322      return entity;
     323    }
     324    public static void ToEntity(DT.SlaveStatistics source, DB.SlaveStatistics target) {
    322325      if ((source != null) && (target != null)) {
    323326        target.StatisticsId = source.Id;
     
    333336
    334337    #region UserStatistics
    335     public static DT.UserStatistics ToDto(UserStatistics source) {
     338    public static DT.UserStatistics ToDto(DB.UserStatistics source) {
    336339      if (source == null) return null;
    337340      return new DT.UserStatistics {
     
    344347      };
    345348    }
    346     public static UserStatistics ToEntity(DT.UserStatistics source) {
    347       if (source == null) return null;
    348       var entity = new UserStatistics(); ToEntity(source, entity);
    349       return entity;
    350     }
    351     public static void ToEntity(DT.UserStatistics source, UserStatistics target) {
     349    public static DB.UserStatistics ToEntity(DT.UserStatistics source) {
     350      if (source == null) return null;
     351      var entity = new DB.UserStatistics(); ToEntity(source, entity);
     352      return entity;
     353    }
     354    public static void ToEntity(DT.UserStatistics source, DB.UserStatistics target) {
    352355      if ((source != null) && (target != null)) {
    353356        target.StatisticsId = source.Id;
     
    360363    }
    361364    #endregion
     365
     366
     367    #region JobState
     368    public static DT.JobState ToDto(DB.JobState source) {
     369      if (source == DB.JobState.Aborted) {
     370        return JobState.Aborted;
     371      } else if (source == DB.JobState.Calculating) {
     372        return JobState.Calculating;
     373      } else if (source == DB.JobState.Failed) {
     374        return JobState.Failed;
     375      } else if (source == DB.JobState.Finished) {
     376        return JobState.Finished;
     377      } else if (source == DB.JobState.Offline) {
     378        return JobState.Offline;
     379      } else if (source == DB.JobState.Paused) {
     380        return JobState.Paused;
     381      } else if (source == DB.JobState.Transferring) {
     382        return JobState.Transferring;
     383      } else if (source == DB.JobState.Waiting) {
     384        return JobState.Waiting;
     385      } else
     386        return JobState.Failed;
     387    }
     388
     389    public static DB.JobState ToEntity(DT.JobState source) {
     390      if (source == DT.JobState.Aborted) {
     391        return DB.JobState.Aborted;
     392      } else if (source == DT.JobState.Calculating) {
     393        return DB.JobState.Calculating;
     394      } else if (source == DT.JobState.Failed) {
     395        return DB.JobState.Failed;
     396      } else if (source == DT.JobState.Finished) {
     397        return DB.JobState.Finished;
     398      } else if (source == DT.JobState.Offline) {
     399        return DB.JobState.Offline;
     400      } else if (source == DT.JobState.Paused) {
     401        return DB.JobState.Paused;
     402      } else if (source == DT.JobState.Transferring) {
     403        return DB.JobState.Transferring;
     404      } else if (source == DT.JobState.Waiting) {
     405        return DB.JobState.Waiting;
     406      } else
     407        return DB.JobState.Failed;
     408    }
     409    #endregion
     410
     411    #region Permission
     412    public static DT.Permission ToDto(DB.Permission source) {
     413      if (source == DB.Permission.Full) {
     414        return Permission.Full;
     415      } else if (source == DB.Permission.NotAllowed) {
     416        return Permission.NotAllowed;
     417      } else if (source == DB.Permission.Read) {
     418        return Permission.Read;
     419      } else
     420        return Permission.NotAllowed;
     421    }
     422
     423    public static DB.Permission ToEntity(DT.Permission source) {
     424      if (source == DT.Permission.Full) {
     425        return DB.Permission.Full;
     426      } else if (source == DT.Permission.NotAllowed) {
     427        return DB.Permission.NotAllowed;
     428      } else if (source == DT.Permission.Read) {
     429        return DB.Permission.Read;
     430      } else
     431        return DB.Permission.NotAllowed;
     432    }
     433    #endregion
     434
     435
     436    #region Command
     437    public static DT.Command? ToDto(DB.Command? source) {
     438      if (source.HasValue) {
     439        if (source.Value == DB.Command.Abort) {
     440          return Command.Abort;
     441        } else if (source.Value == DB.Command.Pause) {
     442          return Command.Pause;
     443        } else if (source.Value == DB.Command.Stop) {
     444          return Command.Stop;
     445        } else
     446          return Command.Pause;
     447      }
     448      return null;
     449    }
     450
     451    public static DB.Command? ToEntity(DT.Command? source) {
     452      if (source.HasValue) {
     453        if (source == DT.Command.Abort) {
     454          return DB.Command.Abort;
     455        } else if (source == DT.Command.Pause) {
     456          return DB.Command.Pause;
     457        } else if (source == DT.Command.Stop) {
     458          return DB.Command.Stop;
     459        } else
     460          return DB.Command.Pause;
     461      } else
     462        return null;
     463    }
     464
     465    #endregion
     466
     467    #region CpuArchiteture
     468    public static DT.CpuArchitecture ToDto(DB.CpuArchitecture source) {
     469      if (source == DB.CpuArchitecture.x64) {
     470        return CpuArchitecture.x64;
     471      } else if (source == DB.CpuArchitecture.x86) {
     472        return CpuArchitecture.x86;
     473      } else
     474        return CpuArchitecture.x86;
     475    }
     476
     477    public static DB.CpuArchitecture ToEntity(DT.CpuArchitecture source) {
     478      if (source == DT.CpuArchitecture.x64) {
     479        return DB.CpuArchitecture.x64;
     480      } else if (source == DT.CpuArchitecture.x86) {
     481        return DB.CpuArchitecture.x86;
     482      } else
     483        return DB.CpuArchitecture.x86;
     484    }
     485    #endregion
     486
     487    #region SlaveState
     488    public static DT.SlaveState ToDto(DB.SlaveState source) {
     489      if (source == DB.SlaveState.Calculating) {
     490        return SlaveState.Calculating;
     491      } else if (source == DB.SlaveState.Idle) {
     492        return SlaveState.Idle;
     493      } else if (source == DB.SlaveState.Offline) {
     494        return SlaveState.Offline;
     495      } else
     496        return SlaveState.Offline;
     497    }
     498
     499    public static DB.SlaveState ToEntity(DT.SlaveState source) {
     500      if (source == DT.SlaveState.Calculating) {
     501        return DB.SlaveState.Calculating;
     502      } else if (source == DT.SlaveState.Idle) {
     503        return DB.SlaveState.Idle;
     504      } else if (source == DT.SlaveState.Offline) {
     505        return DB.SlaveState.Offline;
     506      } else
     507        return DB.SlaveState.Offline;
     508    }
     509    #endregion
    362510  }
    363511}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Command.cs

    r6703 r6717  
    2222using System;
    2323
    24 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     24namespace HeuristicLab.Services.Hive.DataTransfer {
    2525  [Serializable]
    2626  public enum Command {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Downtime.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  public class Downtime : HiveItem {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/HiveExperiment.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/HiveExperimentPermission.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/HiveItem.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Job.cs

    r6703 r6717  
    2424using System.Runtime.Serialization;
    2525
    26 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     26namespace HeuristicLab.Services.Hive.DataTransfer {
    2727  [DataContract]
    2828  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/JobData.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/JobState.cs

    r6703 r6717  
    2222using System;
    2323
    24 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     24namespace HeuristicLab.Services.Hive.DataTransfer {
    2525  [Serializable]
    2626  public enum JobState {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/LightweightJob.cs

    r6703 r6717  
    2525using System.Runtime.Serialization;
    2626
    27 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     27namespace HeuristicLab.Services.Hive.DataTransfer {
    2828  [DataContract]
    2929  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/NamedHiveItem.cs

    r6703 r6717  
    2222using System.Runtime.Serialization;
    2323
    24 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     24namespace HeuristicLab.Services.Hive.DataTransfer {
    2525  [DataContract]
    2626  public abstract class NamedHiveItem : HiveItem {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Permission.cs

    r6703 r6717  
    2020#endregion
    2121
    22 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     22namespace HeuristicLab.Services.Hive.DataTransfer {
    2323  public enum Permission {
    2424    /// <summary>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Plugin.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/PluginData.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [Serializable]
    2727  [DataContract]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Resource.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Slave.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  public enum CpuArchitecture {
    2727    x86, x64
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/SlaveGroup.cs

    r6703 r6717  
    2222using System.Runtime.Serialization;
    2323
    24 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     24namespace HeuristicLab.Services.Hive.DataTransfer {
    2525  [DataContract]
    2626  public class SlaveGroup : Resource {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/SlaveState.cs

    r6703 r6717  
    2121
    2222
    23 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     23namespace HeuristicLab.Services.Hive.DataTransfer {
    2424  public enum SlaveState {
    2525    Idle,
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/SlaveStatistics.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/StateLog.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/Statistics.cs

    r6703 r6717  
    2424using System.Runtime.Serialization;
    2525
    26 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     26namespace HeuristicLab.Services.Hive.DataTransfer {
    2727  [DataContract]
    2828  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/DataTransfer/UserStatistics.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common.DataTransfer {
     25namespace HeuristicLab.Services.Hive.DataTransfer {
    2626  [DataContract]
    2727  [Serializable]
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLab.Services.Hive-3.3.csproj

    r6701 r6717  
    9292    <Reference Include="System.Data.Linq" />
    9393    <Reference Include="System.Drawing" />
     94    <Reference Include="System.Runtime.Serialization" />
    9495    <Reference Include="System.ServiceModel" />
    9596    <Reference Include="System.Transactions" />
     
    103104  </ItemGroup>
    104105  <ItemGroup>
     106    <Compile Include="Convert.cs" />
     107    <Compile Include="DataTransfer\Command.cs" />
     108    <Compile Include="DataTransfer\Downtime.cs" />
     109    <Compile Include="DataTransfer\Heartbeat.cs" />
     110    <Compile Include="DataTransfer\HiveExperiment.cs" />
     111    <Compile Include="DataTransfer\HiveExperimentPermission.cs" />
     112    <Compile Include="DataTransfer\HiveItem.cs" />
     113    <Compile Include="DataTransfer\Job.cs" />
     114    <Compile Include="DataTransfer\JobData.cs" />
     115    <Compile Include="DataTransfer\JobState.cs" />
     116    <Compile Include="DataTransfer\LightweightJob.cs" />
     117    <Compile Include="DataTransfer\NamedHiveItem.cs" />
     118    <Compile Include="DataTransfer\Permission.cs" />
     119    <Compile Include="DataTransfer\Plugin.cs" />
     120    <Compile Include="DataTransfer\PluginData.cs" />
     121    <Compile Include="DataTransfer\Resource.cs" />
     122    <Compile Include="DataTransfer\Slave.cs" />
     123    <Compile Include="DataTransfer\SlaveGroup.cs" />
     124    <Compile Include="DataTransfer\SlaveState.cs" />
     125    <Compile Include="DataTransfer\SlaveStatistics.cs" />
     126    <Compile Include="DataTransfer\StateLog.cs" />
     127    <Compile Include="DataTransfer\Statistics.cs" />
     128    <Compile Include="DataTransfer\UserStatistics.cs" />
     129    <Compile Include="HiveDao.cs" />
     130    <Compile Include="Interfaces\IHiveDao.cs" />
    105131    <Compile Include="Interfaces\IUserManager.cs" />
    106132    <Compile Include="Manager\UserManager.cs" />
     
    118144    <Compile Include="HiveService.cs" />
    119145    <Compile Include="Interfaces\IAuthorizationManager.cs" />
     146    <Compile Include="MessageContainer.cs" />
    120147    <Compile Include="Properties\AssemblyInfo.cs" />
     148    <Compile Include="Properties\Settings.Designer.cs">
     149      <DependentUpon>Settings.settings</DependentUpon>
     150      <AutoGen>True</AutoGen>
     151      <DesignTimeSharedInput>True</DesignTimeSharedInput>
     152    </Compile>
     153    <Compile Include="ServiceContracts\IHiveService.cs" />
     154    <Compile Include="ServiceFaults\PluginAlreadyExistsFault.cs" />
    121155    <Compile Include="ServiceLocator.cs" />
    122   </ItemGroup>
    123   <ItemGroup>
    124     <ProjectReference Include="..\..\HeuristicLab.Services.Hive.Common\3.3\HeuristicLab.Services.Hive.Common-3.3.csproj">
    125       <Project>{14424A16-48D4-445E-80BF-DDF617548BBB}</Project>
    126       <Name>HeuristicLab.Services.Hive.Common-3.3</Name>
    127     </ProjectReference>
     156    <None Include="Properties\Settings.settings">
     157      <Generator>PublicSettingsSingleFileGenerator</Generator>
     158      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
     159    </None>
     160  </ItemGroup>
     161  <ItemGroup>
    128162    <ProjectReference Include="..\..\HeuristicLab.Services.Hive.DataAccess\3.3\HeuristicLab.Services.Hive.DataAccess-3.3.csproj">
    129163      <Project>{EC2C8109-6E1E-4C88-9A2B-908CFF2EF4AC}</Project>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HeuristicLabServicesHivePlugin.cs.frame

    r6701 r6717  
    3232  [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3333  [PluginDependency("HeuristicLab.Core", "3.3")]
    34   [PluginDependency("HeuristicLab.Persistence", "3.3")]
    35   [PluginDependency("HeuristicLab.Services.Hive.Common", "3.3")]
     34  [PluginDependency("HeuristicLab.Persistence", "3.3")] 
    3635  [PluginDependency("HeuristicLab.Services.Hive.DataAccess", "3.3")]
    3736  public class HeuristicLabServicesHivePlugin : PluginBase {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r6703 r6717  
    2424using System.Linq;
    2525using System.Linq.Expressions;
    26 using HeuristicLab.Services.Hive.Common.DataTransfer;
    27 using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
     26using DT = HeuristicLab.Services.Hive.DataTransfer;
    2827
    2928namespace HeuristicLab.Services.Hive.DataAccess {
     
    4039    public DT.Job GetJob(Guid id) {
    4140      using (var db = CreateContext()) {
    42         return Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id));
     41        return DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id));
    4342      }
    4443    }
     
    4645    public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) {
    4746      using (var db = CreateContext()) {
    48         return db.Jobs.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     47        return db.Jobs.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    4948      }
    5049    }
     
    5251    public Guid AddJob(DT.Job dto) {
    5352      using (var db = CreateContext()) {
    54         var entity = Convert.ToEntity(dto);
     53        var entity = DT.Convert.ToEntity(dto);
    5554        db.Jobs.InsertOnSubmit(entity);
    5655        db.SubmitChanges();
     
    6665      using (var db = CreateContext()) {
    6766        var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id);
    68         if (entity == null) db.Jobs.InsertOnSubmit(Convert.ToEntity(dto));
    69         else Convert.ToEntity(dto, entity);
     67        if (entity == null) db.Jobs.InsertOnSubmit(DT.Convert.ToEntity(dto));
     68        else DT.Convert.ToEntity(dto, entity);
    7069        foreach (Guid pluginId in dto.PluginsNeededIds) {
    7170          if (db.RequiredPlugins.Count(p => p.PluginId == pluginId) == 0) {
     
    108107                           select child).Count() > 0
    109108                    orderby ar.Job.Priority descending, db.Random()
    110                     select Convert.ToDto(ar.Job);
     109                    select DT.Convert.ToDto(ar.Job);
    111110        return count == 0 ? query.ToArray() : query.Take(count).ToArray();
    112111      }
     
    126125                       && ar.Job.MemoryNeeded <= slave.FreeMemory
    127126                    orderby ar.Job.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
    128                     select Convert.ToDto(ar.Job);
     127                    select DT.Convert.ToDto(ar.Job);
    129128        var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray();
    130129        return waitingJobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
     
    146145        db.SubmitChanges();
    147146        job = db.Jobs.SingleOrDefault(x => x.JobId == jobId);
    148         return Convert.ToDto(job);
     147        return DT.Convert.ToDto(job);
    149148      }
    150149    }
     
    154153    public DT.JobData GetJobData(Guid id) {
    155154      using (var db = CreateContext(true)) {
    156         return Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id));
     155        return DT.Convert.ToDto(db.JobDatas.SingleOrDefault(x => x.JobId == id));
    157156      }
    158157    }
     
    160159    public IEnumerable<DT.JobData> GetJobDatas(Expression<Func<JobData, bool>> predicate) {
    161160      using (var db = CreateContext(true)) {
    162         return db.JobDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     161        return db.JobDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    163162      }
    164163    }
     
    166165    public Guid AddJobData(DT.JobData dto) {
    167166      using (var db = CreateContext(true)) {
    168         var entity = Convert.ToEntity(dto);
     167        var entity = DT.Convert.ToEntity(dto);
    169168        db.JobDatas.InsertOnSubmit(entity);
    170169        db.SubmitChanges();
     
    176175      using (var db = CreateContext(true)) {
    177176        var entity = db.JobDatas.FirstOrDefault(x => x.JobId == dto.JobId);
    178         if (entity == null) db.JobDatas.InsertOnSubmit(Convert.ToEntity(dto));
    179         else Convert.ToEntity(dto, entity);
     177        if (entity == null) db.JobDatas.InsertOnSubmit(DT.Convert.ToEntity(dto));
     178        else DT.Convert.ToEntity(dto, entity);
    180179        db.SubmitChanges();
    181180      }
     
    194193    public DT.StateLog GetStateLog(Guid id) {
    195194      using (var db = CreateContext()) {
    196         return Convert.ToDto(db.StateLogs.SingleOrDefault(x => x.StateLogId == id));
     195        return DT.Convert.ToDto(db.StateLogs.SingleOrDefault(x => x.StateLogId == id));
    197196      }
    198197    }
     
    200199    public IEnumerable<DT.StateLog> GetStateLogs(Expression<Func<StateLog, bool>> predicate) {
    201200      using (var db = CreateContext()) {
    202         return db.StateLogs.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     201        return db.StateLogs.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    203202      }
    204203    }
     
    206205    public Guid AddStateLog(DT.StateLog dto) {
    207206      using (var db = CreateContext()) {
    208         var entity = Convert.ToEntity(dto);
     207        var entity = DT.Convert.ToEntity(dto);
    209208        db.StateLogs.InsertOnSubmit(entity);
    210209        db.SubmitChanges();
     
    216215      using (var db = CreateContext()) {
    217216        var entity = db.StateLogs.FirstOrDefault(x => x.StateLogId == dto.Id);
    218         if (entity == null) db.StateLogs.InsertOnSubmit(Convert.ToEntity(dto));
    219         else Convert.ToEntity(dto, entity);
     217        if (entity == null) db.StateLogs.InsertOnSubmit(DT.Convert.ToEntity(dto));
     218        else DT.Convert.ToEntity(dto, entity);
    220219        db.SubmitChanges();
    221220      }
     
    234233    public DT.HiveExperiment GetHiveExperiment(Guid id) {
    235234      using (var db = CreateContext()) {
    236         return AddStatsToExperiment(db, Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)));
     235        return AddStatsToExperiment(db, DT.Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)));
    237236      }
    238237    }
     
    251250    public IEnumerable<DT.HiveExperiment> GetHiveExperiments(Expression<Func<HiveExperiment, bool>> predicate) {
    252251      using (var db = CreateContext()) {
    253         return db.HiveExperiments.Where(predicate).Select(x => AddStatsToExperiment(db, Convert.ToDto(x))).ToArray();
     252        return db.HiveExperiments.Where(predicate).Select(x => AddStatsToExperiment(db, DT.Convert.ToDto(x))).ToArray();
    254253      }
    255254    }
     
    257256    public Guid AddHiveExperiment(DT.HiveExperiment dto) {
    258257      using (var db = CreateContext()) {
    259         var entity = Convert.ToEntity(dto);
     258        var entity = DT.Convert.ToEntity(dto);
    260259        db.HiveExperiments.InsertOnSubmit(entity);
    261260        db.SubmitChanges();
     
    267266      using (var db = CreateContext()) {
    268267        var entity = db.HiveExperiments.FirstOrDefault(x => x.HiveExperimentId == dto.Id);
    269         if (entity == null) db.HiveExperiments.InsertOnSubmit(Convert.ToEntity(dto));
    270         else Convert.ToEntity(dto, entity);
     268        if (entity == null) db.HiveExperiments.InsertOnSubmit(DT.Convert.ToEntity(dto));
     269        else DT.Convert.ToEntity(dto, entity);
    271270        db.SubmitChanges();
    272271      }
     
    285284    public DT.HiveExperimentPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
    286285      using (var db = CreateContext()) {
    287         return Convert.ToDto(db.HiveExperimentPermissions.SingleOrDefault(x => x.HiveExperimentId == hiveExperimentId && x.GrantedUserId == grantedUserId));
     286        return DT.Convert.ToDto(db.HiveExperimentPermissions.SingleOrDefault(x => x.HiveExperimentId == hiveExperimentId && x.GrantedUserId == grantedUserId));
    288287      }
    289288    }
     
    291290    public IEnumerable<DT.HiveExperimentPermission> GetHiveExperimentPermissions(Expression<Func<HiveExperimentPermission, bool>> predicate) {
    292291      using (var db = CreateContext()) {
    293         return db.HiveExperimentPermissions.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     292        return db.HiveExperimentPermissions.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    294293      }
    295294    }
     
    297296    public void AddHiveExperimentPermission(DT.HiveExperimentPermission dto) {
    298297      using (var db = CreateContext()) {
    299         var entity = Convert.ToEntity(dto);
     298        var entity = DT.Convert.ToEntity(dto);
    300299        db.HiveExperimentPermissions.InsertOnSubmit(entity);
    301300        db.SubmitChanges();
     
    306305      using (var db = CreateContext()) {
    307306        var entity = db.HiveExperimentPermissions.FirstOrDefault(x => x.HiveExperimentId == dto.HiveExperimentId && x.GrantedUserId == dto.GrantedUserId);
    308         if (entity == null) db.HiveExperimentPermissions.InsertOnSubmit(Convert.ToEntity(dto));
    309         else Convert.ToEntity(dto, entity);
     307        if (entity == null) db.HiveExperimentPermissions.InsertOnSubmit(DT.Convert.ToEntity(dto));
     308        else DT.Convert.ToEntity(dto, entity);
    310309        db.SubmitChanges();
    311310      }
     
    350349    public DT.Plugin GetPlugin(Guid id) {
    351350      using (var db = CreateContext()) {
    352         return Convert.ToDto(db.Plugins.SingleOrDefault(x => x.PluginId == id));
     351        return DT.Convert.ToDto(db.Plugins.SingleOrDefault(x => x.PluginId == id));
    353352      }
    354353    }
     
    356355    public IEnumerable<DT.Plugin> GetPlugins(Expression<Func<Plugin, bool>> predicate) {
    357356      using (var db = CreateContext()) {
    358         return db.Plugins.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     357        return db.Plugins.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    359358      }
    360359    }
     
    362361    public Guid AddPlugin(DT.Plugin dto) {
    363362      using (var db = CreateContext()) {
    364         var entity = Convert.ToEntity(dto);
     363        var entity = DT.Convert.ToEntity(dto);
    365364        db.Plugins.InsertOnSubmit(entity);
    366365        db.SubmitChanges();
     
    372371      using (var db = CreateContext()) {
    373372        var entity = db.Plugins.FirstOrDefault(x => x.PluginId == dto.Id);
    374         if (entity == null) db.Plugins.InsertOnSubmit(Convert.ToEntity(dto));
    375         else Convert.ToEntity(dto, entity);
     373        if (entity == null) db.Plugins.InsertOnSubmit(DT.Convert.ToEntity(dto));
     374        else DT.Convert.ToEntity(dto, entity);
    376375        db.SubmitChanges();
    377376      }
     
    390389    public DT.PluginData GetPluginData(Guid id) {
    391390      using (var db = CreateContext()) {
    392         return Convert.ToDto(db.PluginDatas.SingleOrDefault(x => x.PluginDataId == id));
     391        return DT.Convert.ToDto(db.PluginDatas.SingleOrDefault(x => x.PluginDataId == id));
    393392      }
    394393    }
     
    396395    public IEnumerable<DT.PluginData> GetPluginDatas(Expression<Func<PluginData, bool>> predicate) {
    397396      using (var db = CreateContext()) {
    398         return db.PluginDatas.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     397        return db.PluginDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    399398      }
    400399    }
     
    402401    public Guid AddPluginData(DT.PluginData dto) {
    403402      using (var db = CreateContext()) {
    404         var entity = Convert.ToEntity(dto);
     403        var entity = DT.Convert.ToEntity(dto);
    405404        db.PluginDatas.InsertOnSubmit(entity);
    406405        db.SubmitChanges();
     
    412411      using (var db = CreateContext()) {
    413412        var entity = db.PluginDatas.FirstOrDefault(x => x.PluginId == dto.PluginId);
    414         if (entity == null) db.PluginDatas.InsertOnSubmit(Convert.ToEntity(dto));
    415         else Convert.ToEntity(dto, entity);
     413        if (entity == null) db.PluginDatas.InsertOnSubmit(DT.Convert.ToEntity(dto));
     414        else DT.Convert.ToEntity(dto, entity);
    416415        db.SubmitChanges();
    417416      }
     
    430429    public DT.Slave GetSlave(Guid id) {
    431430      using (var db = CreateContext()) {
    432         return Convert.ToDto(db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id));
     431        return DT.Convert.ToDto(db.Resources.OfType<Slave>().SingleOrDefault(x => x.ResourceId == id));
    433432      }
    434433    }
     
    436435    public IEnumerable<DT.Slave> GetSlaves(Expression<Func<Slave, bool>> predicate) {
    437436      using (var db = CreateContext()) {
    438         return db.Resources.OfType<Slave>().Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     437        return db.Resources.OfType<Slave>().Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    439438      }
    440439    }
     
    442441    public Guid AddSlave(DT.Slave dto) {
    443442      using (var db = CreateContext()) {
    444         var entity = Convert.ToEntity(dto);
     443        var entity = DT.Convert.ToEntity(dto);
    445444        db.Resources.InsertOnSubmit(entity);
    446445        db.SubmitChanges();
     
    452451      using (var db = CreateContext()) {
    453452        var entity = db.Resources.OfType<Slave>().FirstOrDefault(x => x.ResourceId == dto.Id);
    454         if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto));
    455         else Convert.ToEntity(dto, entity);
     453        if (entity == null) db.Resources.InsertOnSubmit(DT.Convert.ToEntity(dto));
     454        else DT.Convert.ToEntity(dto, entity);
    456455        db.SubmitChanges();
    457456      }
     
    470469    public DT.SlaveGroup GetSlaveGroup(Guid id) {
    471470      using (var db = CreateContext()) {
    472         return Convert.ToDto(db.Resources.OfType<SlaveGroup>().SingleOrDefault(x => x.ResourceId == id));
     471        return DT.Convert.ToDto(db.Resources.OfType<SlaveGroup>().SingleOrDefault(x => x.ResourceId == id));
    473472      }
    474473    }
     
    476475    public IEnumerable<DT.SlaveGroup> GetSlaveGroups(Expression<Func<SlaveGroup, bool>> predicate) {
    477476      using (var db = CreateContext()) {
    478         return db.Resources.OfType<SlaveGroup>().Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     477        return db.Resources.OfType<SlaveGroup>().Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    479478      }
    480479    }
     
    484483        if (dto.Id == Guid.Empty)
    485484          dto.Id = Guid.NewGuid();
    486         var entity = Convert.ToEntity(dto);
     485        var entity = DT.Convert.ToEntity(dto);
    487486        db.Resources.InsertOnSubmit(entity);
    488487        db.SubmitChanges();
     
    494493      using (var db = CreateContext()) {
    495494        var entity = db.Resources.OfType<SlaveGroup>().FirstOrDefault(x => x.ResourceId == dto.Id);
    496         if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto));
    497         else Convert.ToEntity(dto, entity);
     495        if (entity == null) db.Resources.InsertOnSubmit(DT.Convert.ToEntity(dto));
     496        else DT.Convert.ToEntity(dto, entity);
    498497        db.SubmitChanges();
    499498      }
     
    517516    public DT.Resource GetResource(Guid id) {
    518517      using (var db = CreateContext()) {
    519         return Convert.ToDto(db.Resources.SingleOrDefault(x => x.ResourceId == id));
     518        return DT.Convert.ToDto(db.Resources.SingleOrDefault(x => x.ResourceId == id));
    520519      }
    521520    }
     
    523522    public IEnumerable<DT.Resource> GetResources(Expression<Func<Resource, bool>> predicate) {
    524523      using (var db = CreateContext()) {
    525         return db.Resources.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     524        return db.Resources.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    526525      }
    527526    }
     
    529528    public Guid AddResource(DT.Resource dto) {
    530529      using (var db = CreateContext()) {
    531         var entity = Convert.ToEntity(dto);
     530        var entity = DT.Convert.ToEntity(dto);
    532531        db.Resources.InsertOnSubmit(entity);
    533532        db.SubmitChanges();
     
    539538      using (var db = CreateContext()) {
    540539        var entity = db.Resources.FirstOrDefault(x => x.ResourceId == dto.Id);
    541         if (entity == null) db.Resources.InsertOnSubmit(Convert.ToEntity(dto));
    542         else Convert.ToEntity(dto, entity);
     540        if (entity == null) db.Resources.InsertOnSubmit(DT.Convert.ToEntity(dto));
     541        else DT.Convert.ToEntity(dto, entity);
    543542        db.SubmitChanges();
    544543      }
     
    564563      using (var db = CreateContext()) {
    565564        var job = db.Jobs.Where(x => x.JobId == jobId).Single();
    566         return job.AssignedResources.Select(x => Convert.ToDto(x.Resource)).ToArray();
     565        return job.AssignedResources.Select(x => DT.Convert.ToDto(x.Resource)).ToArray();
    567566      }
    568567    }
     
    575574        var resources = new List<Resource>();
    576575        CollectParentResources(resources, db.Resources.Where(r => r.ResourceId == resourceId).Single());
    577         return resources.Select(r => Convert.ToDto(r)).ToArray();
     576        return resources.Select(r => DT.Convert.ToDto(r)).ToArray();
    578577      }
    579578    }
     
    592591        var childs = new List<DT.Resource>();
    593592        foreach (var child in db.Resources.Where(x => x.ParentResourceId == resourceId)) {
    594           childs.Add(Convert.ToDto(child));
     593          childs.Add(DT.Convert.ToDto(child));
    595594          childs.AddRange(GetChildResources(child.ResourceId));
    596595        }
     
    608607          j.StateLogs.OrderByDescending(x => x.DateTime).First().SlaveId.HasValue &&
    609608          resources.Contains(j.StateLogs.OrderByDescending(x => x.DateTime).First().SlaveId.Value));
    610         return jobs.Select(j => Convert.ToDto(j)).ToArray();
     609        return jobs.Select(j => DT.Convert.ToDto(j)).ToArray();
    611610      }
    612611    }
     
    664663    public DT.Downtime GetDowntime(Guid id) {
    665664      using (var db = CreateContext()) {
    666         return Convert.ToDto(db.Downtimes.SingleOrDefault(x => x.DowntimeId == id));
     665        return DT.Convert.ToDto(db.Downtimes.SingleOrDefault(x => x.DowntimeId == id));
    667666      }
    668667    }
     
    670669    public IEnumerable<DT.Downtime> GetDowntimes(Expression<Func<Downtime, bool>> predicate) {
    671670      using (var db = CreateContext()) {
    672         return db.Downtimes.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     671        return db.Downtimes.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    673672      }
    674673    }
     
    676675    public Guid AddDowntime(DT.Downtime dto) {
    677676      using (var db = CreateContext()) {
    678         var entity = Convert.ToEntity(dto);
     677        var entity = DT.Convert.ToEntity(dto);
    679678        db.Downtimes.InsertOnSubmit(entity);
    680679        db.SubmitChanges();
     
    686685      using (var db = CreateContext()) {
    687686        var entity = db.Downtimes.FirstOrDefault(x => x.DowntimeId == dto.Id);
    688         if (entity == null) db.Downtimes.InsertOnSubmit(Convert.ToEntity(dto));
    689         else Convert.ToEntity(dto, entity);
     687        if (entity == null) db.Downtimes.InsertOnSubmit(DT.Convert.ToEntity(dto));
     688        else DT.Convert.ToEntity(dto, entity);
    690689        db.SubmitChanges();
    691690      }
     
    704703    public DT.Statistics GetStatistic(Guid id) {
    705704      using (var db = CreateContext()) {
    706         return Convert.ToDto(db.Statistics.SingleOrDefault(x => x.StatisticsId == id));
     705        return DT.Convert.ToDto(db.Statistics.SingleOrDefault(x => x.StatisticsId == id));
    707706      }
    708707    }
     
    710709    public IEnumerable<DT.Statistics> GetStatistics(Expression<Func<Statistics, bool>> predicate) {
    711710      using (var db = CreateContext()) {
    712         return db.Statistics.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     711        return db.Statistics.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
    713712      }
    714713    }
     
    716715    public Guid AddStatistics(DT.Statistics dto) {
    717716      using (var db = CreateContext()) {
    718         var entity = Convert.ToEntity(dto);
     717        var entity = DT.Convert.ToEntity(dto);
    719718        db.Statistics.InsertOnSubmit(entity);
    720719        db.SubmitChanges();
    721720        foreach (var slaveStat in dto.SlaveStatistics) {
    722721          slaveStat.Id = entity.StatisticsId;
    723           db.SlaveStatistics.InsertOnSubmit(Convert.ToEntity(slaveStat));
     722          db.SlaveStatistics.InsertOnSubmit(DT.Convert.ToEntity(slaveStat));
    724723        }
    725724        foreach (var userStat in dto.UserStatistics) {
    726725          userStat.Id = entity.StatisticsId;
    727           db.UserStatistics.InsertOnSubmit(Convert.ToEntity(userStat));
     726          db.UserStatistics.InsertOnSubmit(DT.Convert.ToEntity(userStat));
    728727        }
    729728        db.SubmitChanges();
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r6698 r6717  
    2424using System.Linq;
    2525using System.ServiceModel;
    26 using HeuristicLab.Services.Hive.Common;
    27 using HeuristicLab.Services.Hive.Common.DataTransfer;
    28 using HeuristicLab.Services.Hive.Common.ServiceContracts;
     26using HeuristicLab.Services.Hive.DataTransfer;
     27using HeuristicLab.Services.Hive.ServiceContracts;
     28using DA = HeuristicLab.Services.Hive.DataAccess;
     29using DT = HeuristicLab.Services.Hive.DataTransfer;
     30
    2931
    3032namespace HeuristicLab.Services.Hive {
     
    3638  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, IgnoreExtensionDataObject = true)]
    3739  public class HiveService : IHiveService {
    38     private DataAccess.IHiveDao dao {
     40    private IHiveDao dao {
    3941      get { return ServiceLocator.Instance.HiveDao; }
    4042    }
     
    4547      get { return ServiceLocator.Instance.AuthorizationManager; }
    4648    }
    47     private ITransactionManager trans {
     49    private DataAccess.ITransactionManager trans {
    4850      get { return ServiceLocator.Instance.TransactionManager; }
    4951    }
     
    6971        }
    7072        dao.AddJobData(jobData);
    71         dao.UpdateJobState(job.Id, JobState.Waiting, null, userManager.CurrentUserId, null);
     73        dao.UpdateJobState(job.Id, DA.JobState.Waiting, null, userManager.CurrentUserId, null);
    7274        return jobData.JobId;
    7375      }, false, true);
     
    167169      author.AuthorizeForJob(jobId, Permission.Full);
    168170      return trans.UseTransaction(() => {
    169         Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
     171        Job job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(jobState), slaveId, userId, exception);
    170172
    171173        if (job.Command.HasValue && job.Command.Value == Command.Pause && job.State == JobState.Paused) {
     
    177179        } else if (jobState == JobState.Paused && !job.Command.HasValue) {
    178180          // slave paused and uploaded the job (no user-command) -> set waiting.
    179           job = dao.UpdateJobState(jobId, JobState.Waiting, slaveId, userId, exception);
     181          job = dao.UpdateJobState(jobId, DataTransfer.Convert.ToEntity(JobState.Waiting), slaveId, userId, exception);
    180182        }
    181183
     
    188190      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    189191      var jobs = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
    190       foreach(var job in jobs)
     192      foreach (var job in jobs)
    191193        author.AuthorizeForJob(job.Id, Permission.Read);
    192194      return jobs;
     
    229231      author.AuthorizeForJob(jobId, Permission.Full);
    230232      trans.UseTransaction(() => {
    231         Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, userManager.CurrentUserId, string.Empty);
     233        Job job = dao.UpdateJobState(jobId, DA.JobState.Waiting, null, userManager.CurrentUserId, string.Empty);
    232234        job.Command = null;
    233235        dao.UpdateJob(job);
     
    242244      var hiveExperiment = dao.GetHiveExperiments(x =>
    243245            x.HiveExperimentId == id
    244             && (x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0)
     246            && (x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0)
    245247          ).FirstOrDefault();
    246248      if (hiveExperiment != null) {
    247         hiveExperiment.Permission = dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId);
     249        hiveExperiment.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId));
    248250        hiveExperiment.OwnerUsername = userManager.GetUserById(hiveExperiment.OwnerUserId).UserName;
    249251      }
     
    253255    public IEnumerable<HiveExperiment> GetHiveExperiments() {
    254256      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    255       var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
     257      var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != DA.Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
    256258      foreach (var he in hiveExperiments) {
    257259        author.AuthorizeForExperiment(he.Id, Permission.Read);
    258         he.Permission = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
     260        he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));
    259261        he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName;
    260262      }
     
    266268      var hiveExperiments = dao.GetHiveExperiments(x => true);
    267269      foreach (var he in hiveExperiments) { // no authorization here, since this method is admin-only! (admin is allowed to read all jobs)
    268         he.Permission = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
     270        he.Permission = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));
    269271        he.OwnerUsername = userManager.GetUserById(he.OwnerUserId).UserName;
    270272      }
     
    304306        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
    305307        if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));
    306         Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
     308        Permission perm = DT.Convert.ToDto(dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId));
    307309        if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    308         dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, permission);
     310        dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DT.Convert.ToEntity(permission));
    309311      });
    310312    }
     
    315317        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
    316318        if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));
    317         Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
    318         if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    319         dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, Permission.NotAllowed);
     319        DA.Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
     320        if (perm != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
     321        dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, DA.Permission.NotAllowed);
    320322      });
    321323    }
     
    323325      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    324326      return trans.UseTransaction(() => {
    325         Permission currentUserPermission = dao.GetPermissionForExperiment(hiveExperimentId, userManager.CurrentUserId);
    326         if (currentUserPermission != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment"));
     327        DA.Permission currentUserPermission = dao.GetPermissionForExperiment(hiveExperimentId, userManager.CurrentUserId);
     328        if (currentUserPermission != DA.Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment"));
    327329        return dao.GetHiveExperimentPermissions(x => x.HiveExperimentId == hiveExperimentId);
    328330      });
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IAuthorizationManager.cs

    r6463 r6717  
    2121
    2222using System;
    23 using HeuristicLab.Services.Hive.Common.DataTransfer;
     23using HeuristicLab.Services.Hive.DataTransfer;
     24
    2425namespace HeuristicLab.Services.Hive {
    2526  public interface IAuthorizationManager {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r6703 r6717  
    2323using System.Collections.Generic;
    2424using System.Linq.Expressions;
    25 using HeuristicLab.Services.Hive.Common.DataTransfer;
    26 using DT = HeuristicLab.Services.Hive.Common.DataTransfer;
     25using HeuristicLab.Services.Hive.DataAccess;
     26using DT = HeuristicLab.Services.Hive.DataTransfer;
    2727
    28 namespace HeuristicLab.Services.Hive.DataAccess {
     28namespace HeuristicLab.Services.Hive {
    2929  public interface IHiveDao {
    3030    #region Job Methods
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r6463 r6717  
    2222using System;
    2323using System.Security;
    24 using HeuristicLab.Services.Hive.Common.DataTransfer;
     24using HeuristicLab.Services.Hive.DataAccess;
     25using DT = HeuristicLab.Services.Hive.DataTransfer;
     26
    2527
    2628namespace HeuristicLab.Services.Hive {
     
    3133    }
    3234
    33     public void AuthorizeForJob(Guid jobId, Permission requiredPermission) {
     35    public void AuthorizeForJob(Guid jobId, DT.Permission requiredPermission) {
    3436      if (ServiceLocator.Instance.AuthenticationManager.IsInRole(HiveRoles.Slave)) return; // slave-users can access all jobs
    3537
    3638      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForJob(jobId, ServiceLocator.Instance.UserManager.CurrentUserId);
    37       if (permission == Permission.NotAllowed || (permission != requiredPermission && requiredPermission == Permission.Full))
     39      if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
    3840        throw new SecurityException("Current user is not authorized to access job");
    3941    }
    4042
    41     public void AuthorizeForExperiment(Guid experimentId, Permission requiredPermission) {
     43    public void AuthorizeForExperiment(Guid experimentId, DT.Permission requiredPermission) {
    4244      Permission permission = ServiceLocator.Instance.HiveDao.GetPermissionForExperiment(experimentId, ServiceLocator.Instance.UserManager.CurrentUserId);
    43       if (permission == Permission.NotAllowed || (permission != requiredPermission && requiredPermission == Permission.Full))
     45      if (permission == Permission.NotAllowed || (permission != DT.Convert.ToEntity(requiredPermission) && DT.Convert.ToEntity(requiredPermission) == Permission.Full))
    4446        throw new SecurityException("Current user is not authorized to access experiment");
    4547    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/EventManager.cs

    r6698 r6717  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Services.Hive.Common;
    26 using HeuristicLab.Services.Hive.Common.DataTransfer;
     25using HeuristicLab.Services.Hive.DataAccess;
     26using HeuristicLab.Services.Hive.DataAccess;
     27using DT = HeuristicLab.Services.Hive.DataTransfer;
     28
    2729
    2830namespace HeuristicLab.Services.Hive {
     
    3133  /// </summary>
    3234  public class EventManager : IEventManager {
    33     private DataAccess.IHiveDao dao {
     35    private IHiveDao dao {
    3436      get { return ServiceLocator.Instance.HiveDao; }
    3537    }
     
    5254      var slaves = dao.GetSlaves(x => x.SlaveState == SlaveState.Calculating || x.SlaveState == SlaveState.Idle);
    5355
    54       var stats = new Statistics();
     56      var stats = new DataTransfer.Statistics();
    5557      stats.TimeStamp = DateTime.Now;
    56       var slaveStats = new List<SlaveStatistics>();
     58      var slaveStats = new List<DT.SlaveStatistics>();
    5759      foreach (var slave in slaves) {
    58         slaveStats.Add(new SlaveStatistics() {
     60        slaveStats.Add(new DT.SlaveStatistics() {
    5961          SlaveId = slave.Id,
    6062          Cores = slave.Cores.HasValue ? slave.Cores.Value : 0,
     
    7577    private void SetTimeoutSlavesOffline() {
    7678      var slaves = dao.GetSlaves(x => x.SlaveState != SlaveState.Offline);
    77       foreach (Slave slave in slaves) {
    78         if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > Settings.Default.SlaveHeartbeatTimeout) {
    79           slave.SlaveState = SlaveState.Offline;
     79      foreach (DT.Slave slave in slaves) {
     80        if (!slave.LastHeartbeat.HasValue || (DateTime.Now - slave.LastHeartbeat.Value) > HeuristicLab.Services.Hive.Properties.Settings.Default.SlaveHeartbeatTimeout) {
     81          slave.SlaveState = DT.SlaveState.Offline;
    8082          SetJobsWaiting(slave.Id);
    8183          dao.UpdateSlave(slave);
     
    9799      var jobs = dao.GetJobs(x => x.State == JobState.Calculating).Where(x => x.StateLog.Last().SlaveId == slaveId);
    98100      foreach (var j in jobs) {
    99         Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out.");
     101        DT.Job job = dao.UpdateJobState(j.Id, JobState.Waiting, slaveId, null, "Slave timed out.");
    100102        job.Command = null;
    101103        dao.UpdateJob(job);
     
    107109    /// </summary>
    108110    private void SetTimeoutJobsWaiting() {
    109       var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > Settings.Default.CalculatingJobHeartbeatTimeout)
    110                                || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > Settings.Default.TransferringJobHeartbeatTimeout));
     111      var jobs = dao.GetJobs(x => (x.State == JobState.Calculating && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.CalculatingJobHeartbeatTimeout)
     112                               || (x.State == JobState.Transferring && (DateTime.Now - x.LastHeartbeat) > HeuristicLab.Services.Hive.Properties.Settings.Default.TransferringJobHeartbeatTimeout));
    111113      foreach (var j in jobs) {
    112         Job job = dao.UpdateJobState(j.Id, JobState.Waiting, null, null, "Slave timed out.");
     114        DT.Job job = dao.UpdateJobState(j.Id, JobState.Waiting, null, null, "Slave timed out.");
    113115        job.Command = null;
    114116        dao.UpdateJob(job);
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs

    r6463 r6717  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Services.Hive.Common;
    26 using HeuristicLab.Services.Hive.Common.DataTransfer;
     25using HeuristicLab.Services.Hive.DataTransfer;
     26using DA = HeuristicLab.Services.Hive.DataAccess;
    2727
    2828namespace HeuristicLab.Services.Hive {
    2929  public class HeartbeatManager {
    30     private DataAccess.IHiveDao dao {
     30    private IHiveDao dao {
    3131      get { return ServiceLocator.Instance.HiveDao; }
    3232    }
     
    7575      if (dao.GetJob(job.Id).State != JobState.Waiting) return false;
    7676
    77       job = dao.UpdateJobState(job.Id, JobState.Transferring, slave.Id, null, null);
     77      job = dao.UpdateJobState(job.Id, DataAccess.JobState.Transferring, slave.Id, null, null);
    7878
    7979      // from now on the job has some time to send the next heartbeat (ApplicationConstants.TransferringJobHeartbeatTimeout)
     
    102102            // job does not exist in db
    103103            actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, jobProgress.Key));
    104             LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);
     104            DA.LogFactory.GetLogger(this.GetType().Namespace).Log("Job does not exist in DB: " + jobProgress.Key);
    105105          } else {
    106106            if (curJob.CurrentStateLog.SlaveId == Guid.Empty || curJob.CurrentStateLog.SlaveId != heartbeat.SlaveId) {
    107107              // assigned slave does not match heartbeat
    108108              actions.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    109               LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);
     109              DA.LogFactory.GetLogger(this.GetType().Namespace).Log("The slave " + heartbeat.SlaveId + " is not supposed to calculate Job: " + curJob);
    110110            } else if (!JobIsAllowedToBeCalculatedBySlave(heartbeat.SlaveId, curJob)) {
    111111              // assigned resources ids of job do not match with slaveId (and parent resourceGroupIds); this might happen when slave is moved to different group
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/MessageContainer.cs

    r6703 r6717  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Services.Hive.Common {
     27namespace HeuristicLab.Services.Hive {
    2828  /// <summary>
    2929  /// The MessageContainer is a container class for Messages. Its two parts are:
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/Properties/Settings.Designer.cs

    r6703 r6717  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.225
     4//     Runtime Version:4.0.30319.235
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    99//------------------------------------------------------------------------------
    1010
    11 namespace HeuristicLab.Services.Hive.Common {
     11namespace HeuristicLab.Services.Hive.Properties {
    1212   
    1313   
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r6703 r6717  
    2424using System.Net.Security;
    2525using System.ServiceModel;
    26 using HeuristicLab.Services.Hive.Common.DataTransfer;
    27 
    28 namespace HeuristicLab.Services.Hive.Common.ServiceContracts {
     26using HeuristicLab.Services.Hive.DataTransfer;
     27
     28namespace HeuristicLab.Services.Hive.ServiceContracts {
    2929
    3030  [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]
     
    3838    Guid AddChildJob(Guid parentJobId, Job job, JobData jobData);
    3939
    40     [OperationContract] 
     40    [OperationContract]
    4141    Job GetJob(Guid jobId);
    4242
    43     [OperationContract] 
     43    [OperationContract]
    4444    IEnumerable<Job> GetJobs();
    4545
    46     [OperationContract] 
     46    [OperationContract]
    4747    IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds);
    4848
    49     [OperationContract] 
     49    [OperationContract]
    5050    IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent);
    5151
    52     [OperationContract] 
     52    [OperationContract]
    5353    IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId);
    5454
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/ServiceFaults/PluginAlreadyExistsFault.cs

    r6703 r6717  
    2323using System.Runtime.Serialization;
    2424
    25 namespace HeuristicLab.Services.Hive.Common {
     25namespace HeuristicLab.Services.Hive {
    2626  [DataContract]
    2727  public class PluginAlreadyExistsFault {
Note: See TracChangeset for help on using the changeset viewer.