- Timestamp:
- 07/09/08 10:34:10 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 added
- 1 deleted
- 19 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Console/Agent.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 5 26 using HeuristicLab.Core; 6 27 using System.Xml; 28 using HeuristicLab.CEDMA.DB.Interfaces; 7 29 8 30 namespace HeuristicLab.CEDMA.Console { 9 31 public class Agent : ItemBase, IAgent { 10 private string name; 32 public IDatabase Database { get; set; } 33 public long Id { get; set; } 34 public string Name { get; set; } 35 public AgentStatus Status { get; set; } 11 36 private OperatorGraph operatorGraph; 12 public string Name {13 get { return name; }14 set { name = value; }15 }16 37 17 38 public IOperatorGraph OperatorGraph { … … 19 40 } 20 41 21 public Agent() : base() { 42 public Agent() 43 : base() { 22 44 operatorGraph = new OperatorGraph(); 23 45 } 46 47 public Agent(IDatabase database, long id) : this() { 48 Database = database; 49 Id = id; 50 } 51 52 public void Save() { 53 AgentEntry entry = new AgentEntry(Id, Name, Status, DbPersistenceManager.Save(this)); 54 Database.Update(entry); 55 } 56 57 public void Activate() { 58 Status = AgentStatus.Waiting; 59 Save(); 60 } 61 62 #region persistence 63 public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) { 64 XmlNode node = base.GetXmlNode(name, document, persistedObjects); 65 node.AppendChild(PersistenceManager.Persist("OperatorGraph", operatorGraph, document, persistedObjects)); 66 return node; 67 } 68 69 public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) { 70 base.Populate(node, restoredObjects); 71 operatorGraph = (OperatorGraph)PersistenceManager.Restore(node.SelectSingleNode("OperatorGraph"), restoredObjects); 72 } 73 #endregion 74 24 75 } 25 76 } -
trunk/sources/HeuristicLab.CEDMA.Console/AgentList.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 6 27 using System.Collections; 7 28 using HeuristicLab.CEDMA.DB.Interfaces; 29 using System.Xml; 30 using System.Runtime.Serialization; 31 using System.IO; 8 32 9 33 namespace HeuristicLab.CEDMA.Console { 10 public class AgentList : ItemBase, IAgentList {34 public class AgentList : ItemBase, IAgentList { 11 35 private string serverUri; 12 36 private List<IAgent> agentList; … … 22 46 private void ReloadList() { 23 47 agentList.Clear(); 24 foreach(HeuristicLab.CEDMA.DB.Interfaces.IAgent a in database.GetAgents()) { 25 Agent newAgent = new Agent(); 48 foreach(AgentEntry a in database.GetAgentEntries()) { 49 Agent newAgent = (Agent)DbPersistenceManager.Restore(a.RawData); 50 newAgent.Database = database; 51 newAgent.Id = a.Id; 26 52 newAgent.Name = a.Name; 53 newAgent.Status = a.Status; 27 54 agentList.Add(newAgent); 28 55 } … … 34 61 agentList = new List<IAgent>(); 35 62 } 36 37 public void Add(IAgent agent) { 63 64 public void CreateAgent() { 65 long id = database.CreateAgent(); 66 Agent agent = new Agent(database, id); 67 agent.Name = DateTime.Now.ToString(); 68 agent.Save(); 38 69 agentList.Add(agent); 39 70 } -
trunk/sources/HeuristicLab.CEDMA.Console/AgentListView.cs
r357 r372 94 94 #region Button Events 95 95 private void addButton_Click(object sender, EventArgs e) { 96 Agent agent = new Agent(); 97 string name = DateTime.Now.ToString(); 98 agent.Name = name; 99 AgentList.Add(agent); 96 AgentList.CreateAgent(); 97 UpdateControls(); 100 98 } 101 99 #endregion -
trunk/sources/HeuristicLab.CEDMA.Console/AgentView.Designer.cs
r357 r372 48 48 this.saveButton = new System.Windows.Forms.Button(); 49 49 this.activateButton = new System.Windows.Forms.Button(); 50 this.stopButton = new System.Windows.Forms.Button();51 50 this.SuspendLayout(); 52 51 // … … 72 71 this.saveButton.Text = "&Save"; 73 72 this.saveButton.UseVisualStyleBackColor = true; 73 this.saveButton.Click += new System.EventHandler(this.saveButton_Click); 74 74 // 75 75 // activateButton … … 82 82 this.activateButton.Text = "&Activate"; 83 83 this.activateButton.UseVisualStyleBackColor = true; 84 // 85 // stopButton 86 // 87 this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 88 this.stopButton.Location = new System.Drawing.Point(166, 128); 89 this.stopButton.Name = "stopButton"; 90 this.stopButton.Size = new System.Drawing.Size(75, 23); 91 this.stopButton.TabIndex = 3; 92 this.stopButton.Text = "S&top"; 93 this.stopButton.UseVisualStyleBackColor = true; 84 this.activateButton.Click += new System.EventHandler(this.activateButton_Click); 94 85 // 95 86 // AgentView … … 97 88 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 98 89 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 99 this.Controls.Add(this.stopButton);100 90 this.Controls.Add(this.activateButton); 101 91 this.Controls.Add(this.saveButton); … … 112 102 private System.Windows.Forms.Button saveButton; 113 103 private System.Windows.Forms.Button activateButton; 114 private System.Windows.Forms.Button stopButton;115 104 } 116 105 } -
trunk/sources/HeuristicLab.CEDMA.Console/AgentView.cs
r357 r372 28 28 using System.Windows.Forms; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.CEDMA.DB.Interfaces; 30 31 31 32 namespace HeuristicLab.CEDMA.Console { … … 56 57 editorGroupBox.Enabled = true; 57 58 } 59 60 if(Agent.Status == AgentStatus.Unkown) activateButton.Enabled = true; 61 else activateButton.Enabled = false; 58 62 } 63 } 64 65 private void saveButton_Click(object sender, EventArgs e) { 66 Agent.Save(); 67 } 68 69 private void activateButton_Click(object sender, EventArgs e) { 70 Agent.Activate(); 71 activateButton.Enabled = false; 59 72 } 60 73 } -
trunk/sources/HeuristicLab.CEDMA.Console/Console.cs
r359 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; -
trunk/sources/HeuristicLab.CEDMA.Console/ConsoleEditor.cs
r359 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 16 37 private System.Windows.Forms.TabPage resultsPage; 17 38 private Button connectButton; 39 private ComboBox comboBox1; 40 private Label projectLabel; 41 private Button newButton; 18 42 private Console console; 19 43 … … 31 55 this.resultsPage = new System.Windows.Forms.TabPage(); 32 56 this.connectButton = new System.Windows.Forms.Button(); 57 this.comboBox1 = new System.Windows.Forms.ComboBox(); 58 this.projectLabel = new System.Windows.Forms.Label(); 59 this.newButton = new System.Windows.Forms.Button(); 33 60 this.tabControl.SuspendLayout(); 34 61 this.SuspendLayout(); … … 59 86 this.tabControl.Controls.Add(this.resultsPage); 60 87 this.tabControl.Enabled = false; 61 this.tabControl.Location = new System.Drawing.Point(6, 29);88 this.tabControl.Location = new System.Drawing.Point(6, 56); 62 89 this.tabControl.Name = "tabControl"; 63 90 this.tabControl.SelectedIndex = 0; 64 this.tabControl.Size = new System.Drawing.Size( 407, 242);91 this.tabControl.Size = new System.Drawing.Size(506, 407); 65 92 this.tabControl.TabIndex = 2; 66 93 // … … 70 97 this.overviewPage.Name = "overviewPage"; 71 98 this.overviewPage.Padding = new System.Windows.Forms.Padding(3); 72 this.overviewPage.Size = new System.Drawing.Size( 399, 216);99 this.overviewPage.Size = new System.Drawing.Size(498, 381); 73 100 this.overviewPage.TabIndex = 0; 74 101 this.overviewPage.Text = "Overview"; … … 80 107 this.agentsPage.Name = "agentsPage"; 81 108 this.agentsPage.Padding = new System.Windows.Forms.Padding(3); 82 this.agentsPage.Size = new System.Drawing.Size( 399, 216);109 this.agentsPage.Size = new System.Drawing.Size(498, 381); 83 110 this.agentsPage.TabIndex = 1; 84 111 this.agentsPage.Text = "Agents"; … … 90 117 this.resultsPage.Name = "resultsPage"; 91 118 this.resultsPage.Padding = new System.Windows.Forms.Padding(3); 92 this.resultsPage.Size = new System.Drawing.Size( 399, 216);119 this.resultsPage.Size = new System.Drawing.Size(498, 381); 93 120 this.resultsPage.TabIndex = 2; 94 121 this.resultsPage.Text = "Results"; … … 105 132 this.connectButton.Click += new System.EventHandler(this.connectButton_Click); 106 133 // 134 // comboBox1 135 // 136 this.comboBox1.Enabled = false; 137 this.comboBox1.FormattingEnabled = true; 138 this.comboBox1.Location = new System.Drawing.Point(91, 29); 139 this.comboBox1.Name = "comboBox1"; 140 this.comboBox1.Size = new System.Drawing.Size(121, 21); 141 this.comboBox1.TabIndex = 4; 142 // 143 // projectLabel 144 // 145 this.projectLabel.AutoSize = true; 146 this.projectLabel.Enabled = false; 147 this.projectLabel.Location = new System.Drawing.Point(42, 32); 148 this.projectLabel.Name = "projectLabel"; 149 this.projectLabel.Size = new System.Drawing.Size(43, 13); 150 this.projectLabel.TabIndex = 5; 151 this.projectLabel.Text = "Project:"; 152 // 153 // newButton 154 // 155 this.newButton.Enabled = false; 156 this.newButton.Location = new System.Drawing.Point(218, 27); 157 this.newButton.Name = "newButton"; 158 this.newButton.Size = new System.Drawing.Size(75, 23); 159 this.newButton.TabIndex = 6; 160 this.newButton.Text = "New..."; 161 this.newButton.UseVisualStyleBackColor = true; 162 // 107 163 // ConsoleEditor 108 164 // 109 165 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 166 this.Controls.Add(this.newButton); 167 this.Controls.Add(this.projectLabel); 168 this.Controls.Add(this.comboBox1); 110 169 this.Controls.Add(this.connectButton); 111 170 this.Controls.Add(this.tabControl); … … 113 172 this.Controls.Add(this.uriTextBox); 114 173 this.Name = "ConsoleEditor"; 115 this.Size = new System.Drawing.Size( 416, 274);174 this.Size = new System.Drawing.Size(515, 466); 116 175 this.tabControl.ResumeLayout(false); 117 176 this.ResumeLayout(false); … … 125 184 connectButton.Enabled = false; 126 185 tabControl.Enabled = true; 186 agentsPage.Controls.Clear(); 127 187 agentsPage.Controls.Add((Control)console.AgentList.CreateView()); 188 agentsPage.Controls[0].Dock = DockStyle.Fill; 128 189 } catch(CommunicationException ex) { 129 190 // TASK create helper class for error reporting -
trunk/sources/HeuristicLab.CEDMA.Console/HeuristicLab.CEDMA.Console.csproj
r357 r372 66 66 <SubType>UserControl</SubType> 67 67 </Compile> 68 <Compile Include="DbPersistenceManager.cs" /> 68 69 <Compile Include="HeuristicLabCedmaConsolePlugin.cs" /> 69 70 <Compile Include="IAgent.cs" /> 70 71 <Compile Include="IAgentList.cs" /> 72 <Compile Include="IDatabaseItem.cs" /> 71 73 <Compile Include="Properties\AssemblyInfo.cs" /> 72 74 <Compile Include="AgentListView.cs"> -
trunk/sources/HeuristicLab.CEDMA.Console/IAgent.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; 4 25 using System.Text; 5 26 using HeuristicLab.Core; 27 using HeuristicLab.CEDMA.DB.Interfaces; 6 28 7 29 namespace HeuristicLab.CEDMA.Console { 8 public interface IAgent : I Item {30 public interface IAgent : IDatabaseItem { 9 31 string Name { get; } 32 AgentStatus Status { get; } 10 33 IOperatorGraph OperatorGraph { get; } 34 void Save(); 35 void Activate(); 11 36 } 12 37 } -
trunk/sources/HeuristicLab.CEDMA.Console/IAgentList.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 7 28 namespace HeuristicLab.CEDMA.Console { 8 29 public interface IAgentList : IItem, IEnumerable<IAgent> { 9 void Add(IAgent agent);30 void CreateAgent(); 10 31 } 11 32 } -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/AgentStatus.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 5 26 6 27 namespace HeuristicLab.CEDMA.DB.Interfaces { 7 public enum AgentStatus { Aktive, Finished, Error, Waiting}28 public enum AgentStatus { Unkown, Active, Finished, Error, Waiting} 8 29 } -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/HeuristicLab.CEDMA.DB.Interfaces.csproj
r357 r372 42 42 <RequiredTargetFramework>3.5</RequiredTargetFramework> 43 43 </Reference> 44 <Reference Include="System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> 45 <RequiredTargetFramework>3.0</RequiredTargetFramework> 46 </Reference> 44 47 <Reference Include="System.ServiceModel"> 45 48 <RequiredTargetFramework>3.0</RequiredTargetFramework> … … 55 58 </ItemGroup> 56 59 <ItemGroup> 60 <Compile Include="AgentEntry.cs" /> 57 61 <Compile Include="AgentStatus.cs" /> 62 <Compile Include="ResultEntry.cs" /> 58 63 <Compile Include="HeuristicLabCedmaDbInterfacesPlugin.cs" /> 59 <Compile Include="IAgent.cs" />60 64 <Compile Include="IDatabase.cs" /> 61 65 <Compile Include="Properties\AssemblyInfo.cs" /> -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IDatabase.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; 4 25 using System.Text; 5 26 using System.ServiceModel; 27 using System.Data; 6 28 7 29 namespace HeuristicLab.CEDMA.DB.Interfaces { 8 [ServiceContract(Namespace = "http://HeuristicLab.C edma")]30 [ServiceContract(Namespace = "http://HeuristicLab.CEDMA.DB")] 9 31 public interface IDatabase { 10 32 [OperationContract] 11 I List<IAgent> GetAgents();33 ICollection<AgentEntry> GetAgentEntries(); 12 34 13 35 [OperationContract] 14 IAgent CreateAgent(); 36 long CreateAgent(); 37 38 [OperationContract(Name="UpdateAgent")] 39 void Update(AgentEntry entry); 40 41 [OperationContract(Name ="UpdateResult")] 42 void Update(ResultEntry result); 15 43 } 16 44 } -
trunk/sources/HeuristicLab.CEDMA.DB/Database.cs
r357 r372 1 using System; 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 6 27 using HeuristicLab.CEDMA.DB.Interfaces; 7 28 using System.ServiceModel; 29 using System.Data; 30 using System.Data.SQLite; 31 using System.Data.Common; 8 32 9 33 namespace HeuristicLab.CEDMA.DB { 10 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)] 11 public class Database : DataContext, IDatabase { 12 Table<Agent> Agents; 13 14 public Database() : this("c:\\cedma.mdf") { } 15 16 public Database(string connection) : base(connection) { 34 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, UseSynchronizationContext = true)] 35 public class Database : IDatabase { 36 private string connectionString; 37 public Database(string connectionString) { 38 this.connectionString = connectionString; 17 39 } 18 40 19 public IList<IAgent> GetAgents() { 20 List<IAgent> result = new List<IAgent>(); 21 foreach(Agent a in Agents) { 22 result.Add(a); 41 public void CreateNew() { 42 using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) { 43 cnn.ConnectionString = connectionString; 44 cnn.Open(); 45 46 SQLiteCommand cAgent = cnn.CreateCommand(); 47 cAgent.CommandText = "CREATE TABLE Agent (ID integer primary key autoincrement, ProjectId integer, Name text, Status text default 'Unknown', RawData Blob)"; 48 SQLiteCommand cProject = cnn.CreateCommand(); 49 cProject.CommandText = "CREATE TABLE Project (ID integer primary key autoincrement, Name text, Description text, CreationDate DateTime)"; 50 SQLiteCommand cResult = cnn.CreateCommand(); 51 cResult.CommandText = "CREATE TABLE Result (ID integer primary key autoincrement, AgentId integer, ParentResultId integer, CreationDate DateTime, RawData Blob)"; 52 cAgent.ExecuteNonQuery(); 53 cProject.ExecuteNonQuery(); 54 cResult.ExecuteNonQuery(); 23 55 } 24 return result;25 56 } 26 57 27 public IAgent CreateAgent() { 28 Agent newAgent = new Agent(); 29 newAgent.Name = DateTime.Now.ToString(); 30 newAgent.Status = AgentStatus.Waiting; 31 newAgent.RawData = null; 32 Agents.InsertOnSubmit(newAgent); 33 this.SubmitChanges(); 34 return newAgent; 58 public long CreateAgent() { 59 using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) { 60 cnn.Open(); 61 SQLiteCommand c = cnn.CreateCommand(); 62 c.CommandText = "Insert into Agent (Name) values (@Name); select last_insert_rowid()"; 63 DbParameter nameParam = c.CreateParameter(); 64 nameParam.ParameterName = "@Name"; 65 nameParam.Value = DateTime.Now.ToString(); 66 c.Parameters.Add(nameParam); 67 long id = (long)c.ExecuteScalar(); 68 return id; 69 } 70 } 71 72 public ICollection<AgentEntry> GetAgentEntries() { 73 List<AgentEntry> agents = new List<AgentEntry>(); 74 using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) { 75 cnn.Open(); 76 SQLiteCommand c = cnn.CreateCommand(); 77 c.CommandText = "Select id, name, status, rawdata from Agent"; 78 SQLiteDataReader r = c.ExecuteReader(); 79 while(r.Read()) { 80 AgentEntry agent = new AgentEntry(r.GetInt32(0), r.GetString(1), (AgentStatus)Enum.Parse(typeof(AgentStatus), r.GetString(2)), (byte[])r.GetValue(3)); 81 agents.Add(agent); 82 } 83 } 84 return agents; 85 } 86 87 public ICollection<AgentEntry> GetAgentEntries(AgentStatus status) { 88 List<AgentEntry> agents = new List<AgentEntry>(); 89 using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) { 90 cnn.Open(); 91 SQLiteCommand c = cnn.CreateCommand(); 92 c.CommandText = "Select id, name, status, rawdata from Agent where Status=@Status"; 93 DbParameter statusParameter = c.CreateParameter(); 94 statusParameter.ParameterName = "@Status"; 95 statusParameter.Value = (int)status; 96 c.Parameters.Add(statusParameter); 97 98 SQLiteDataReader r = c.ExecuteReader(); 99 while(r.Read()) { 100 AgentEntry agent = new AgentEntry(r.GetInt32(0), r.GetString(1), (AgentStatus)Enum.Parse(typeof(AgentStatus), r.GetString(2)), (byte[])r.GetValue(3)); 101 agents.Add(agent); 102 } 103 } 104 return agents; 105 } 106 107 public void Update(AgentEntry entry) { 108 using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) { 109 cnn.Open(); 110 SQLiteCommand c = cnn.CreateCommand(); 111 c.CommandText = "Update Agent set Name=@Name, Status=@Status, RawData=@RawData where id=@Id"; 112 DbParameter nameParam = c.CreateParameter(); 113 DbParameter statusParam = c.CreateParameter(); 114 DbParameter rawDataParam = c.CreateParameter(); 115 DbParameter idParam = c.CreateParameter(); 116 nameParam.ParameterName = "@Name"; 117 nameParam.Value = entry.Name; 118 statusParam.ParameterName = "@Status"; 119 statusParam.Value = entry.Status; 120 rawDataParam.ParameterName = "@RawData"; 121 rawDataParam.Value = entry.RawData; 122 idParam.ParameterName = "@Id"; 123 idParam.Value = entry.Id; 124 c.Parameters.Add(nameParam); 125 c.Parameters.Add(statusParam); 126 c.Parameters.Add(rawDataParam); 127 c.Parameters.Add(idParam); 128 c.ExecuteNonQuery(); 129 } 130 } 131 132 public void Update(ResultEntry result) { 133 throw new NotImplementedException(); 35 134 } 36 135 } -
trunk/sources/HeuristicLab.CEDMA.DB/HeuristicLab.CEDMA.DB.csproj
r357 r372 15 15 <SignAssembly>true</SignAssembly> 16 16 <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile> 17 <StartupObject> 18 </StartupObject> 17 19 </PropertyGroup> 18 20 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> … … 62 64 </ItemGroup> 63 65 <ItemGroup> 64 <Compile Include="Agent.cs" />65 66 <Compile Include="Database.cs" /> 66 67 <Compile Include="HeuristicLabCedmaDbPlugin.cs" /> 67 68 <Compile Include="Properties\AssemblyInfo.cs" /> 69 <Compile Include="Properties\Settings.Designer.cs"> 70 <AutoGen>True</AutoGen> 71 <DesignTimeSharedInput>True</DesignTimeSharedInput> 72 <DependentUpon>Settings.settings</DependentUpon> 73 </Compile> 68 74 </ItemGroup> 69 75 <ItemGroup> 70 76 <None Include="HeuristicLab.snk" /> 77 <None Include="Properties\Settings.settings"> 78 <Generator>SettingsSingleFileGenerator</Generator> 79 <LastGenOutput>Settings.Designer.cs</LastGenOutput> 80 </None> 71 81 </ItemGroup> 72 82 <ItemGroup> -
trunk/sources/HeuristicLab.CEDMA.Server/HeuristicLab.CEDMA.Server.csproj
r357 r372 59 59 </ItemGroup> 60 60 <ItemGroup> 61 <Compile Include="AgentScheduler.cs" /> 62 <Compile Include="DbPersistenceManager.cs" /> 61 63 <Compile Include="ServerApplication.cs" /> 62 64 <Compile Include="HeuristicLabCedmaServerPlugin.cs" /> … … 70 72 </ItemGroup> 71 73 <ItemGroup> 74 <ProjectReference Include="..\HeuristicLab.CEDMA.Console\HeuristicLab.CEDMA.Console.csproj"> 75 <Project>{F8880599-F224-4EC7-9288-5C4A6853E7BE}</Project> 76 <Name>HeuristicLab.CEDMA.Console</Name> 77 </ProjectReference> 72 78 <ProjectReference Include="..\HeuristicLab.CEDMA.DB.Interfaces\HeuristicLab.CEDMA.DB.Interfaces.csproj"> 73 79 <Project>{4F9BB789-D561-436B-B226-2BF44B7D0804}</Project> … … 78 84 <Name>HeuristicLab.CEDMA.DB</Name> 79 85 </ProjectReference> 86 <ProjectReference Include="..\HeuristicLab.Core\HeuristicLab.Core.csproj"> 87 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 88 <Name>HeuristicLab.Core</Name> 89 </ProjectReference> 80 90 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> 81 91 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 82 92 <Name>HeuristicLab.PluginInfrastructure</Name> 93 </ProjectReference> 94 <ProjectReference Include="..\HeuristicLab.SequentialEngine\HeuristicLab.SequentialEngine.csproj"> 95 <Project>{B4BE8E53-BA06-4237-9A01-24255F880201}</Project> 96 <Name>HeuristicLab.SequentialEngine</Name> 83 97 </ProjectReference> 84 98 </ItemGroup> -
trunk/sources/HeuristicLab.CEDMA.Server/ServerForm.cs
r357 r372 34 34 using HeuristicLab.CEDMA.DB; 35 35 using HeuristicLab.CEDMA.DB.Interfaces; 36 using System.Data.Common; 37 using System.Threading; 36 38 37 39 namespace HeuristicLab.CEDMA.Server { 38 40 public partial class ServerForm : Form { 39 41 private ServiceHost host; 40 private Database database = new Database(); 41 42 private Database database; 43 private static readonly string dbFile = AppDomain.CurrentDomain.BaseDirectory + "/test.db3"; 44 private static readonly string connectionString = "Data Source=\""+dbFile+"\";Pooling=False"; 42 45 public ServerForm() { 43 46 InitializeComponent(); 47 InitDatabase(); 48 InitAgentScheduler(); 44 49 45 50 // windows XP returns the external ip on index 0 while windows vista returns the external ip on index 2 46 51 if (System.Environment.OSVersion.Version.Major >= 6) { 47 addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":800 0/CEDMA/World";52 addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[2] + ":8002/CEDMA/World"; 48 53 } else { 49 addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":800 0/CEDMA/World";54 addressTextBox.Text = "net.tcp://" + Dns.GetHostAddresses(Dns.GetHostName())[0] + ":8002/CEDMA/World"; 50 55 } 51 56 Start(); 57 } 58 59 private void InitAgentScheduler() { 60 AgentScheduler scheduler = new AgentScheduler(database); 61 ThreadPool.QueueUserWorkItem(delegate(object status) { scheduler.Run(); }); 62 } 63 64 private void InitDatabase() { 65 DbProviderFactory fact; 66 fact = DbProviderFactories.GetFactory("System.Data.SQLite"); 67 if(!System.IO.File.Exists(dbFile)) { 68 database = new Database(connectionString); 69 database.CreateNew(); 70 } else { 71 database = new Database(connectionString); 72 } 52 73 } 53 74 -
trunk/sources/HeuristicLab.DistributedEngine/HeuristicLab.DistributedEngine.csproj
r219 r372 49 49 </ItemGroup> 50 50 <ItemGroup> 51 <Compile Include="OnGridProcessor.cs" /> 51 52 <Compile Include="HeuristicLabDistributedEnginePlugin.cs" /> 52 <Compile Include="JobManager.cs" />53 53 <Compile Include="Properties\AssemblyInfo.cs" /> 54 54 <Compile Include="DistributedEngine.cs" /> … … 64 64 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 65 65 <Name>HeuristicLab.Core</Name> 66 </ProjectReference> 67 <ProjectReference Include="..\HeuristicLab.Data\HeuristicLab.Data.csproj"> 68 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 69 <Name>HeuristicLab.Data</Name> 66 70 </ProjectReference> 67 71 <ProjectReference Include="..\HeuristicLab.Grid\HeuristicLab.Grid.csproj"> -
trunk/sources/HeuristicLab.Grid/HeuristicLab.Grid.csproj
r247 r372 65 65 <Compile Include="IEngineStore.cs" /> 66 66 <Compile Include="IGridServer.cs" /> 67 <Compile Include="JobManager.cs" /> 67 68 <Compile Include="ProcessingEngine.cs" /> 68 69 <Compile Include="Properties\AssemblyInfo.cs" /> -
trunk/sources/HeuristicLab.Grid/JobManager.cs
r371 r372 32 32 using System.Windows.Forms; 33 33 34 namespace HeuristicLab. DistributedEngine{35 class JobManager {34 namespace HeuristicLab.Grid { 35 public class JobManager { 36 36 private IGridServer server; 37 37 private string address; … … 54 54 } 55 55 56 internalvoid Reset() {56 public void Reset() { 57 57 ResetConnection(); 58 58 lock(dictionaryLock) {
Note: See TracChangeset
for help on using the changeset viewer.