Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4426


Ignore:
Timestamp:
09/18/10 04:03:28 (14 years ago)
Author:
swagner
Message:

Worked on OKB data model and services (#1174)

Files:
20 added
12 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB/HeuristicLab.Clients.OKB-3.3/AdministrationMenuItem.cs

    r4388 r4426  
    2222using System.Collections.Generic;
    2323using System.Windows.Forms;
     24using HeuristicLab.MainForm;
    2425using HeuristicLab.Optimizer;
    2526
    2627namespace HeuristicLab.Clients.OKB {
    2728  internal class AdministrationMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     29    private Administrator administrator;
     30
    2831    private ToolStripMenuItem menuItem;
    2932
     
    3942
    4043    public override void Execute() {
    41       AdministrationView view = new AdministrationView();
    42       view.Show();
     44      if (administrator == null) administrator = new Administrator();
     45      MainFormManager.MainForm.ShowContent(administrator);
    4346    }
    4447  }
  • branches/OKB/HeuristicLab.Clients.OKB-3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r4422 r4426  
    7171  </ItemGroup>
    7272  <ItemGroup>
     73    <Compile Include="Administrator.cs">
     74      <SubType>Code</SubType>
     75    </Compile>
    7376    <Compile Include="AdministrationMenuItem.cs" />
    74     <Compile Include="AlgorithmCollectionView.cs">
     77    <Compile Include="HeuristicLabClientsOKBPlugin.cs" />
     78    <Compile Include="Properties\AssemblyInfo.cs" />
     79    <Compile Include="ServiceClients\AlgorithmClass.cs" />
     80    <Compile Include="ServiceClients\IOKBItem.cs" />
     81    <Compile Include="ServiceClients\INamedOKBItem.cs" />
     82    <Compile Include="ServiceClients\OKBItem.cs" />
     83    <Compile Include="ServiceClients\ServiceClients.cs" />
     84    <Compile Include="ServiceClients\Algorithm.cs" />
     85    <Compile Include="Views\AdministratorView.cs">
    7586      <SubType>UserControl</SubType>
    7687    </Compile>
    77     <Compile Include="AlgorithmCollectionView.Designer.cs">
     88    <Compile Include="Views\AdministratorView.Designer.cs">
     89      <DependentUpon>AdministratorView.cs</DependentUpon>
     90    </Compile>
     91    <Compile Include="Views\AlgorithmClassCollectionView.cs">
     92      <SubType>UserControl</SubType>
     93    </Compile>
     94    <Compile Include="Views\AlgorithmClassCollectionView.Designer.cs">
     95      <DependentUpon>AlgorithmClassCollectionView.cs</DependentUpon>
     96    </Compile>
     97    <Compile Include="Views\AlgorithmCollectionView.cs">
     98      <SubType>UserControl</SubType>
     99    </Compile>
     100    <Compile Include="Views\AlgorithmCollectionView.Designer.cs">
    78101      <DependentUpon>AlgorithmCollectionView.cs</DependentUpon>
    79102    </Compile>
    80     <Compile Include="Extensions.cs" />
    81     <Compile Include="HeuristicLabClientsOKBPlugin.cs" />
    82     <Compile Include="AdministrationView.cs">
     103    <Compile Include="Views\OKBItemView.cs">
    83104      <SubType>UserControl</SubType>
    84105    </Compile>
    85     <Compile Include="AdministrationView.Designer.cs">
    86       <DependentUpon>AdministrationView.cs</DependentUpon>
     106    <Compile Include="Views\OKBItemView.Designer.cs">
     107      <DependentUpon>OKBItemView.cs</DependentUpon>
    87108    </Compile>
    88     <Compile Include="OKBItem.cs" />
    89     <Compile Include="NamedEntityView.cs">
     109    <Compile Include="Views\NamedOKBItemView.cs">
    90110      <SubType>UserControl</SubType>
    91111    </Compile>
    92     <Compile Include="NamedEntityView.Designer.cs">
    93       <DependentUpon>NamedEntityView.cs</DependentUpon>
     112    <Compile Include="Views\NamedOKBItemView.Designer.cs">
     113      <DependentUpon>NamedOKBItemView.cs</DependentUpon>
    94114    </Compile>
    95     <Compile Include="AlgorithmClassCollectionView.cs">
    96       <SubType>UserControl</SubType>
    97     </Compile>
    98     <Compile Include="AlgorithmClassCollectionView.Designer.cs">
    99       <DependentUpon>AlgorithmClassCollectionView.cs</DependentUpon>
    100     </Compile>
    101     <Compile Include="Properties\AssemblyInfo.cs" />
    102     <Compile Include="ServiceClients.cs" />
    103115    <None Include="app.config" />
    104     <None Include="GenerateServiceClients.cmd" />
    105116    <None Include="Properties\AssemblyInfo.frame" />
     117    <None Include="ServiceClients\GenerateServiceClients.cmd" />
    106118    <None Include="UpdateLocalInstallation.cmd" />
    107119  </ItemGroup>
  • trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs

    r4407 r4426  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Data.Linq;
    2324using System.Linq;
     
    3132  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    3233  public class AdminService : IAdminService {
    33     public void AddAlgorithmClass(AlgorithmClass algorithmClass) {
    34       using (OKBDataContext okb = new OKBDataContext()) {
    35         okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() {
    36           Name = algorithmClass.Name,
    37           Description = algorithmClass.Description
    38         });
    39         okb.SubmitChanges();
    40       }
    41     }
    42     public AlgorithmClass[] GetAlgorithmClasses() {
     34    public AlgorithmClass GetAlgorithmClass(long algorithmClassId) {
     35      using (OKBDataContext okb = new OKBDataContext()) {
     36        return okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClassId);
     37      }
     38    }
     39    public IEnumerable<AlgorithmClass> GetAlgorithmClasses() {
    4340      using (OKBDataContext okb = new OKBDataContext()) {
    4441        return okb.AlgorithmClasses.ToArray();
    4542      }
    4643    }
    47     public void UpdateAlgorithmClass(AlgorithmClass algorithmClass) {
    48       using (OKBDataContext okb = new OKBDataContext()) {
    49         AlgorithmClass original = okb.AlgorithmClasses.First(a => a.Id == algorithmClass.Id);
    50         original.Name = algorithmClass.Name;
    51         original.Description = algorithmClass.Description;
     44    public void StoreAlgorithmClass(AlgorithmClass algorithmClass) {
     45      using (OKBDataContext okb = new OKBDataContext()) {
     46        AlgorithmClass original = okb.AlgorithmClasses.FirstOrDefault(a => a.Id == algorithmClass.Id);
     47        if (original == null) {
     48          okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() {
     49            Name = algorithmClass.Name,
     50            Description = algorithmClass.Description
     51          });
     52        } else {
     53          original.Name = algorithmClass.Name;
     54          original.Description = algorithmClass.Description;
     55        }
    5256        okb.SubmitChanges();
    5357      }
     
    6064    }
    6165
    62     public void AddAlgorithm(Algorithm algorithm) {
    63       using (OKBDataContext okb = new OKBDataContext()) {
    64         okb.Algorithms.InsertOnSubmit(new Algorithm() {
    65           AlgorithmClassId = algorithm.AlgorithmClassId,
    66           PlatformId = algorithm.PlatformId,
    67           Name = algorithm.Name,
    68           Description = algorithm.Description
    69         });
    70         okb.SubmitChanges();
    71       }
    72     }
    73     public Algorithm[] GetAlgorithms() {
     66    public Algorithm GetAlgorithm(long algorithmId) {
     67      using (OKBDataContext okb = new OKBDataContext()) {
     68        return okb.Algorithms.FirstOrDefault(a => a.Id == algorithmId);
     69      }
     70    }
     71    public IEnumerable<Algorithm> GetAlgorithms() {
    7472      using (OKBDataContext okb = new OKBDataContext()) {
    7573        return okb.Algorithms.ToArray();
    7674      }
    7775    }
    78     public void UpdateAlgorithm(Algorithm algorithm) {
    79       using (OKBDataContext okb = new OKBDataContext()) {
    80         Algorithm original = okb.Algorithms.First(a => a.Id == algorithm.Id);
    81         original.AlgorithmClassId = algorithm.AlgorithmClassId;
    82         original.PlatformId = algorithm.PlatformId;
    83         original.Name = algorithm.Name;
    84         original.Description = algorithm.Description;
     76    public void StoreAlgorithm(Algorithm algorithm) {
     77      using (OKBDataContext okb = new OKBDataContext()) {
     78        Algorithm original = okb.Algorithms.FirstOrDefault(a => a.Id == algorithm.Id);
     79        if (original == null) {
     80          okb.Algorithms.InsertOnSubmit(new Algorithm() {
     81            Name = algorithm.Name,
     82            Description = algorithm.Description
     83          });
     84        } else {
     85          original.Name = algorithm.Name;
     86          original.Description = algorithm.Description;
     87        }
    8588        okb.SubmitChanges();
    8689      }
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IAdminService.cs

    r4407 r4426  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Net.Security;
    2324using System.ServiceModel;
     
    3132  public interface IAdminService {
    3233    [OperationContract]
    33     void AddAlgorithmClass(AlgorithmClass algorithmClass);
     34    AlgorithmClass GetAlgorithmClass(long algorithmClassId);
    3435    [OperationContract]
    35     AlgorithmClass[] GetAlgorithmClasses();
     36    IEnumerable<AlgorithmClass> GetAlgorithmClasses();
    3637    [OperationContract]
    37     void UpdateAlgorithmClass(AlgorithmClass algorithmClass);
     38    void StoreAlgorithmClass(AlgorithmClass algorithmClass);
    3839    [OperationContract]
    3940    void DeleteAlgorithmClass(long algorithmClassId);
    4041
    4142    [OperationContract]
    42     void AddAlgorithm(Algorithm algorithm);
     43    Algorithm GetAlgorithm(long algorithmId);
    4344    [OperationContract]
    44     Algorithm[] GetAlgorithms();
     45    IEnumerable<Algorithm> GetAlgorithms();
    4546    [OperationContract]
    46     void UpdateAlgorithm(Algorithm algorithm);
     47    void StoreAlgorithm(Algorithm algorithm);
    4748    [OperationContract]
    4849    void DeleteAlgorithm(long algorithmId);
Note: See TracChangeset for help on using the changeset viewer.