using System; using System.Text; using System.Collections.Generic; using System.Linq; using HeuristicLab.Services.Authentication; using HL = HeuristicLab.Services.Authentication; using DA = HeuristicLab.Services.Authentication.DataAccess; using DT = HeuristicLab.Services.Authentication.DataTransfer; using System.Data; using System.Data.Common; using System.Data.Linq; using System.Collections; namespace Test { class Program { static void Main(string[] args) { //// //DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(@"Data Source=.\SQL2008;Initial Catalog=HeuristicLab.ClientManagment;Integrated Security=True"); //// DA.ClientManagmentDataContext dc = new DA.ClientManagmentDataContext(); //// if (dc.DatabaseExists()) { //// Console.WriteLine("DB exsits"); //// dc.DeleteDatabase(); //// dc.SubmitChanges(); //// Console.WriteLine("DB deleted"); //// } //// Console.WriteLine("DB create"); //// dc.CreateDatabase(); //// dc.SubmitChanges(); //// Console.WriteLine("Finished"); //// AuthenticationService cs = new AuthenticationService(); //// DT.Client c = new DT.Client(); //// c.Id = Guid.NewGuid(); //// c.Name = "Eagle-Eye"; //// c.Description = "Development-PC"; //// c.IPAdress = "192.168.0.1"; //// //c.ResourceType = "Client"; //// DT.ResourceGroup r = new DT.ResourceGroup(); //// r.Name = "test"; //// //r.Id = cs.AddResourceGroup(r); //// //c.ResourceGroup = r.Id; //// //c.Id = cs.AddClient(c); //// //ResourceResourceGroup rrg = new ResourceResourceGroup(); //// //rrg.ResourceGroup = r; //// //rrg.Client = c; //// //dc.GetTable().InsertOnSubmit(r); //// //dc.GetTable().InsertOnSubmit(c); //// //dc.GetTable().InsertOnSubmit(rrg); //// //dc.SubmitChanges(); ////// cs.GetClients(); //// //cs.DeleteClient(c); ////cs.DeleteResourceGroup(r); //Guid groupID1 = Guid.NewGuid(); //string groupName1 = "groupName1"; //Guid groupID2 = Guid.NewGuid(); //string groupName2 = "groupName2"; //Guid groupID3 = Guid.NewGuid(); //string groupName3 = "groupName3"; //Guid clientID1 = Guid.NewGuid(); //string clientName1 = "clientName1"; //Guid clientID2 = Guid.NewGuid(); //string clientName2 = "clientName2"; //DA.ClientManagmentDataContext dc = null; //DT.Client cl1 = null; //DT.Client cl2 = null; //DT.Client cl3 = null; //DT.ResourceGroup rg1 = null; //DT.ResourceGroup rg2 = null; //DT.ResourceGroup rg3 = null; //DA.ResourceResourceGroup rrg1 = null; //DA.ResourceResourceGroup rrg2 = null; //DA.ResourceResourceGroup rrg3 = null; //dc = new DA.ClientManagmentDataContext(); //if (dc.DatabaseExists()) { // //dc.DeleteDatabase(); // dc.ExecuteCommand("delete from ResourceResourceGroup"); // dc.ExecuteCommand("delete from Resource"); // dc.SubmitChanges(); //} //else { // dc.CreateDatabase(); // dc.SubmitChanges(); //} //// create groups //rg1 = new DT.ResourceGroup(); //rg1.Name = groupName1; //rg1.Id = groupID1; //rg1.Description = "descr rg1"; //dc.GetTable().InsertOnSubmit(HL.Convert.ToEntity(rg1)); //rg2 = new DT.ResourceGroup(); //rg2.Name = groupName2; //rg2.Id = groupID2; //IList rgList = new List(); //rgList.Add(rg1.Id); //rg2.ResourceGroup = rgList; //rg2.Description = "descrrg2"; //dc.GetTable().InsertOnSubmit(HL.Convert.ToEntity(rg2)); //rg3 = new DT.ResourceGroup(); //rg3.Name = groupName3; //rg3.Id = groupID3; //rg3.Description = "descrrg3"; //dc.GetTable().InsertOnSubmit(HL.Convert.ToEntity(rg3)); //// create clients //cl1 = new DT.Client(); //cl1.Name = clientName1; //cl1.Id = clientID1; //IList rgList1 = new List(); //rgList.Add(groupID1); //cl1.ResourceGroup = rgList1; //cl1.Description = "Test-PC-1"; //cl1.IPAdress = "192.168.0.10"; //cl1.NumberOfProcessors = "2"; //cl1.NumberOfThreads = "4"; //cl1.OperatingSystem = "WINXP"; //cl1.MemorySize = "2048"; //cl1.ProcessorType = "AMD"; //dc.GetTable().InsertOnSubmit(HL.Convert.ToEntity(cl1)); //cl2 = new DT.Client(); //cl2.Name = clientName2; //cl2.Id = clientID2; //IList rgList2 = new List(); //rgList.Add(groupID2); //cl2.ResourceGroup = rgList2; //cl2.Description = "Test-PC-2"; //cl2.IPAdress = "192.168.0.20"; //cl2.NumberOfProcessors = "4"; //cl2.NumberOfThreads = "4"; //cl2.OperatingSystem = "Vista"; //cl2.MemorySize = "4096"; //cl2.ProcessorType = "Intel"; //dc.GetTable().InsertOnSubmit(HL.Convert.ToEntity(cl2)); //// ResourceResourceGroups //rrg1 = new DA.ResourceResourceGroup(); //rrg1.ResourceId = cl1.Id; //rrg1.ResourceGroupId = rg1.Id; //dc.GetTable().InsertOnSubmit(rrg1); //rrg2 = new DA.ResourceResourceGroup(); //rrg2.ResourceId = cl2.Id; //rrg2.ResourceGroupId = rg2.Id; //dc.GetTable().InsertOnSubmit(rrg2); //rrg3 = new DA.ResourceResourceGroup(); //rrg3.ResourceId = rg1.Id; //rrg3.ResourceGroupId = rg3.Id; //dc.GetTable().InsertOnSubmit(rrg3); //dc.SubmitChanges(); // AuthenticationService cs = new AuthenticationService(); // DA.Client client = dc.Resources.OfType().First(x => x.Id == cl1.Id); // DT.Client modClient = HeuristicLab.Services.Authentication.Convert.ToDto(client); // //cl1.Id ; // //cl1.ResourceType ; // modClient.Name = "clientName1_modified"; //// IList rgList = new List(); //// rgList.Add(groupID3); // //cl1.ResourceGroup = rgList; // modClient.Description = "Test-PC-1_modifiet"; // modClient.IPAdress = "192.168.0.11"; // modClient.NumberOfProcessors = "4"; // modClient.NumberOfThreads = "2"; // modClient.OperatingSystem = "Vista"; // modClient.MemorySize = "2196"; // modClient.ProcessorType = "Intel"; // cs.UpdateClient(modClient); } } }