Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Server/3.3/Server.cs @ 2195

Last change on this file since 2195 was 2195, checked in by gkronber, 15 years ago

Fixed compile errors #712.

File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Windows.Forms;
26using HeuristicLab.PluginInfrastructure;
27using System.Net;
28using System.ServiceModel;
29using HeuristicLab.CEDMA.DB.Interfaces;
30using HeuristicLab.CEDMA.DB;
31using System.ServiceModel.Description;
32using HeuristicLab.Grid;
33using HeuristicLab.Grid.HiveBridge;
34using HeuristicLab.Core;
35using HeuristicLab.Modeling.Database;
36using HeuristicLab.Modeling.Database.SQLServerCompact;
37
38namespace HeuristicLab.CEDMA.Server {
39  public class Server : IViewable {
40    private static readonly string sqlServerCompactFile = AppDomain.CurrentDomain.BaseDirectory + "HeuristicLab.Modeling.database";
41    private static readonly string sqlServerCompactConnectionString = @"Data Source=" + sqlServerCompactFile;
42
43    private DatabaseService database;
44    private IDispatcher dispatcher;
45    public IDispatcher Dispatcher { get { return dispatcher; } }
46    private IExecuter executer;
47    public IExecuter Executer { get { return executer; } }
48    private Problem problem;
49    public Problem Problem { get { return problem; } }
50
51    private string gridServiceUrl;
52    public string GridServiceUrl {
53      get { return gridServiceUrl; }
54      set { gridServiceUrl = value; }
55    }
56
57    public Server() {
58      database = new DatabaseService(sqlServerCompactConnectionString);
59      problem = new Problem();
60      try {
61        problem.Dataset = database.GetDataset();
62      }
63      catch (InvalidOperationException ex) {
64      }
65    }
66
67    internal void Connect(string serverUrl) {
68      dispatcher = new SimpleDispatcher(database, problem);
69      IGridServer gridServer = null;
70      if (serverUrl.Contains("ExecutionEngine")) {
71        gridServer = new HiveGridServerWrapper(serverUrl);
72      } else {
73        // default is grid backend
74        gridServer = new GridServerProxy(serverUrl);
75      }
76      executer = new GridExecuter(dispatcher, gridServer, database);
77      executer.Start();
78    }
79    #region IViewable Members
80
81    public IView CreateView() {
82      return new ServerView(this);
83    }
84    #endregion
85  }
86}
Note: See TracBrowser for help on using the repository browser.