[4583] | 1 | using System;
|
---|
[5335] | 2 | using System.Text;
|
---|
[4583] | 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Linq;
|
---|
[5335] | 5 |
|
---|
[4953] | 6 | using HeuristicLab.Services.Authentication;
|
---|
[5335] | 7 | using HL = HeuristicLab.Services.Authentication;
|
---|
[4953] | 8 | using DA = HeuristicLab.Services.Authentication.DataAccess;
|
---|
| 9 | using DT = HeuristicLab.Services.Authentication.DataTransfer;
|
---|
[5335] | 10 | using System.Data;
|
---|
| 11 | using System.Data.Common;
|
---|
| 12 | using System.Data.Linq;
|
---|
| 13 | using System.Collections;
|
---|
[4583] | 14 |
|
---|
[5335] | 15 | namespace Test {
|
---|
| 16 | class Program {
|
---|
| 17 | static void Main(string[] args) {
|
---|
[4583] | 18 |
|
---|
[5335] | 19 | //// //DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(@"Data Source=.\SQL2008;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True");
|
---|
| 20 | //// DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext();
|
---|
[4953] | 21 |
|
---|
[5335] | 22 | //// if (dc.DatabaseExists()) {
|
---|
| 23 | //// Console.WriteLine("DB exsits");
|
---|
| 24 | //// dc.DeleteDatabase();
|
---|
| 25 | //// dc.SubmitChanges();
|
---|
| 26 | //// Console.WriteLine("DB deleted");
|
---|
| 27 | //// }
|
---|
| 28 | //// Console.WriteLine("DB create");
|
---|
| 29 | //// dc.CreateDatabase();
|
---|
| 30 | //// dc.SubmitChanges();
|
---|
| 31 | //// Console.WriteLine("Finished");
|
---|
[4583] | 32 |
|
---|
[5335] | 33 | //// AuthenticationService cs = new AuthenticationService();
|
---|
[4953] | 34 |
|
---|
[5335] | 35 | //// DT.Client c = new DT.Client();
|
---|
[4953] | 36 |
|
---|
[5335] | 37 | //// c.Id = Guid.NewGuid();
|
---|
| 38 | //// c.Name = "Eagle-Eye";
|
---|
| 39 | //// c.Description = "Development-PC";
|
---|
| 40 | //// c.IPAdress = "192.168.0.1";
|
---|
[4953] | 41 |
|
---|
[5335] | 42 | //// //c.ResourceType = "Client";
|
---|
| 43 | //// DT.ResourceGroup r = new DT.ResourceGroup();
|
---|
| 44 | //// r.Name = "test";
|
---|
[4583] | 45 |
|
---|
[5335] | 46 | //// //r.Id = cs.AddResourceGroup(r);
|
---|
[4953] | 47 |
|
---|
[5335] | 48 | //// //c.ResourceGroup = r.Id;
|
---|
| 49 | //// //c.Id = cs.AddClient(c);
|
---|
[4583] | 50 |
|
---|
[5335] | 51 | //// //ResourceResourceGroup rrg = new ResourceResourceGroup();
|
---|
| 52 | //// //rrg.ResourceGroup = r;
|
---|
| 53 | //// //rrg.Client = c;
|
---|
[4583] | 54 |
|
---|
| 55 |
|
---|
[5335] | 56 | //// //dc.GetTable<Resource>().InsertOnSubmit(r);
|
---|
| 57 | //// //dc.GetTable<Resource>().InsertOnSubmit(c);
|
---|
[4583] | 58 |
|
---|
[5335] | 59 | //// //dc.GetTable<ResourceResourceGroup>().InsertOnSubmit(rrg);
|
---|
[4583] | 60 |
|
---|
[5335] | 61 | //// //dc.SubmitChanges();
|
---|
[4583] | 62 |
|
---|
[5335] | 63 |
|
---|
| 64 | ////// cs.GetClients();
|
---|
| 65 |
|
---|
| 66 | //// //cs.DeleteClient(c);
|
---|
| 67 | ////cs.DeleteResourceGroup(r);
|
---|
| 68 | //Guid groupID1 = Guid.NewGuid();
|
---|
| 69 | //string groupName1 = "groupName1";
|
---|
| 70 | //Guid groupID2 = Guid.NewGuid();
|
---|
| 71 | //string groupName2 = "groupName2";
|
---|
| 72 | //Guid groupID3 = Guid.NewGuid();
|
---|
| 73 | //string groupName3 = "groupName3";
|
---|
| 74 |
|
---|
| 75 | //Guid clientID1 = Guid.NewGuid();
|
---|
| 76 | //string clientName1 = "clientName1";
|
---|
| 77 | //Guid clientID2 = Guid.NewGuid();
|
---|
| 78 | //string clientName2 = "clientName2";
|
---|
| 79 |
|
---|
| 80 | //DA.ClientManagmentDataContext dc = null;
|
---|
| 81 |
|
---|
| 82 | //DT.Client cl1 = null;
|
---|
| 83 | //DT.Client cl2 = null;
|
---|
| 84 | //DT.Client cl3 = null;
|
---|
| 85 |
|
---|
| 86 | //DT.ResourceGroup rg1 = null;
|
---|
| 87 | //DT.ResourceGroup rg2 = null;
|
---|
| 88 | //DT.ResourceGroup rg3 = null;
|
---|
| 89 |
|
---|
| 90 | //DA.ResourceResourceGroup rrg1 = null;
|
---|
| 91 | //DA.ResourceResourceGroup rrg2 = null;
|
---|
| 92 | //DA.ResourceResourceGroup rrg3 = null;
|
---|
| 93 |
|
---|
| 94 | //dc = new DA.ClientManagmentDataContext();
|
---|
| 95 | //if (dc.DatabaseExists()) {
|
---|
| 96 | // //dc.DeleteDatabase();
|
---|
| 97 | // dc.ExecuteCommand("delete from ResourceResourceGroup");
|
---|
| 98 | // dc.ExecuteCommand("delete from Resource");
|
---|
| 99 | // dc.SubmitChanges();
|
---|
| 100 | //}
|
---|
| 101 | //else {
|
---|
| 102 | // dc.CreateDatabase();
|
---|
| 103 | // dc.SubmitChanges();
|
---|
| 104 | //}
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | //// create groups
|
---|
| 108 | //rg1 = new DT.ResourceGroup();
|
---|
| 109 | //rg1.Name = groupName1;
|
---|
| 110 | //rg1.Id = groupID1;
|
---|
| 111 | //rg1.Description = "descr rg1";
|
---|
| 112 | //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg1));
|
---|
| 113 |
|
---|
| 114 | //rg2 = new DT.ResourceGroup();
|
---|
| 115 | //rg2.Name = groupName2;
|
---|
| 116 | //rg2.Id = groupID2;
|
---|
| 117 |
|
---|
| 118 | //IList<Guid> rgList = new List<Guid>();
|
---|
| 119 | //rgList.Add(rg1.Id);
|
---|
| 120 | //rg2.ResourceGroup = rgList;
|
---|
| 121 |
|
---|
| 122 | //rg2.Description = "descrrg2";
|
---|
| 123 | //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg2));
|
---|
| 124 |
|
---|
| 125 | //rg3 = new DT.ResourceGroup();
|
---|
| 126 | //rg3.Name = groupName3;
|
---|
| 127 | //rg3.Id = groupID3;
|
---|
| 128 | //rg3.Description = "descrrg3";
|
---|
| 129 | //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(rg3));
|
---|
| 130 |
|
---|
| 131 | //// create clients
|
---|
| 132 | //cl1 = new DT.Client();
|
---|
| 133 | //cl1.Name = clientName1;
|
---|
| 134 | //cl1.Id = clientID1;
|
---|
| 135 |
|
---|
| 136 | //IList<Guid> rgList1 = new List<Guid>();
|
---|
| 137 | //rgList.Add(groupID1);
|
---|
| 138 | //cl1.ResourceGroup = rgList1;
|
---|
| 139 |
|
---|
| 140 | //cl1.Description = "Test-PC-1";
|
---|
| 141 | //cl1.IPAdress = "192.168.0.10";
|
---|
| 142 | //cl1.NumberOfProcessors = "2";
|
---|
| 143 | //cl1.NumberOfThreads = "4";
|
---|
| 144 | //cl1.OperatingSystem = "WINXP";
|
---|
| 145 | //cl1.MemorySize = "2048";
|
---|
| 146 | //cl1.ProcessorType = "AMD";
|
---|
| 147 | //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(cl1));
|
---|
| 148 |
|
---|
| 149 | //cl2 = new DT.Client();
|
---|
| 150 | //cl2.Name = clientName2;
|
---|
| 151 | //cl2.Id = clientID2;
|
---|
| 152 |
|
---|
| 153 | //IList<Guid> rgList2 = new List<Guid>();
|
---|
| 154 | //rgList.Add(groupID2);
|
---|
| 155 | //cl2.ResourceGroup = rgList2;
|
---|
| 156 |
|
---|
| 157 | //cl2.Description = "Test-PC-2";
|
---|
| 158 | //cl2.IPAdress = "192.168.0.20";
|
---|
| 159 | //cl2.NumberOfProcessors = "4";
|
---|
| 160 | //cl2.NumberOfThreads = "4";
|
---|
| 161 | //cl2.OperatingSystem = "Vista";
|
---|
| 162 | //cl2.MemorySize = "4096";
|
---|
| 163 | //cl2.ProcessorType = "Intel";
|
---|
| 164 | //dc.GetTable<DA.Resource>().InsertOnSubmit(HL.Convert.ToEntity(cl2));
|
---|
| 165 |
|
---|
| 166 | //// ResourceResourceGroups
|
---|
| 167 | //rrg1 = new DA.ResourceResourceGroup();
|
---|
| 168 | //rrg1.ResourceId = cl1.Id;
|
---|
| 169 | //rrg1.ResourceGroupId = rg1.Id;
|
---|
| 170 | //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg1);
|
---|
| 171 |
|
---|
| 172 | //rrg2 = new DA.ResourceResourceGroup();
|
---|
| 173 | //rrg2.ResourceId = cl2.Id;
|
---|
| 174 | //rrg2.ResourceGroupId = rg2.Id;
|
---|
| 175 | //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg2);
|
---|
| 176 |
|
---|
| 177 | //rrg3 = new DA.ResourceResourceGroup();
|
---|
| 178 | //rrg3.ResourceId = rg1.Id;
|
---|
| 179 | //rrg3.ResourceGroupId = rg3.Id;
|
---|
| 180 | //dc.GetTable<DA.ResourceResourceGroup>().InsertOnSubmit(rrg3);
|
---|
| 181 |
|
---|
| 182 | //dc.SubmitChanges();
|
---|
| 183 |
|
---|
| 184 |
|
---|
| 185 | // AuthenticationService cs = new AuthenticationService();
|
---|
| 186 |
|
---|
| 187 | // DA.Client client = dc.Resources.OfType<DA.Client>().First(x => x.Id == cl1.Id);
|
---|
| 188 | // DT.Client modClient = HeuristicLab.Services.Authentication.Convert.ToDto(client);
|
---|
| 189 |
|
---|
| 190 | // //cl1.Id ;
|
---|
| 191 | // //cl1.ResourceType ;
|
---|
| 192 | // modClient.Name = "clientName1_modified";
|
---|
| 193 |
|
---|
| 194 | //// IList<Guid> rgList = new List<Guid>();
|
---|
| 195 | //// rgList.Add(groupID3);
|
---|
| 196 |
|
---|
| 197 | // //cl1.ResourceGroup = rgList;
|
---|
| 198 |
|
---|
| 199 | // modClient.Description = "Test-PC-1_modifiet";
|
---|
| 200 | // modClient.IPAdress = "192.168.0.11";
|
---|
| 201 | // modClient.NumberOfProcessors = "4";
|
---|
| 202 | // modClient.NumberOfThreads = "2";
|
---|
| 203 | // modClient.OperatingSystem = "Vista";
|
---|
| 204 | // modClient.MemorySize = "2196";
|
---|
| 205 | // modClient.ProcessorType = "Intel";
|
---|
| 206 |
|
---|
| 207 | // cs.UpdateClient(modClient);
|
---|
| 208 |
|
---|
[4583] | 209 | }
|
---|
[5335] | 210 | }
|
---|
[4583] | 211 | }
|
---|