Changeset 4694 for branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/AdminMethods.cs
- Timestamp:
- 10/31/10 03:40:09 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ClientManagement/HeuristicLab.Services.Authentication/HeuristicLab.Services.Authentication.AdminMethods/AdminMethods.cs
r4592 r4694 1 1 2 2 using System; 3 using System.Collections.Generic;4 using System.Linq;5 using System.Data.Linq;6 using System.Data.Linq.Mapping;7 using System.Text;8 9 using HeuristicLab.Services.Authentication.DataAccess;10 using HeuristicLab.Services.Authentication.DataTransfer;11 using HeuristicLab.Services.Authentication;12 using DA = HeuristicLab.Services.Authentication.DataAccess;13 using DT = HeuristicLab.Services.Authentication.DataTransfer;14 using HLSA = HeuristicLab.Services.Authentication;15 16 namespace HeuristicLab.Services.Authentication.AdminMethods {17 class AdminMethods {18 19 public static bool InsertClient(string name, string description, string resourceType, string processorType,20 int numberOfProcessors, int numberOfThreads, string ipAdresse, int memorySize, string operatingSystem) {21 DT.Client c = new DT.Client();22 c.ResourceID = Guid.NewGuid();23 c.Name = name;24 c.Description = description;25 //c.ResourceType = resourceType;26 c.ProcessorType = processorType;27 c.NumberOfProcessors = numberOfProcessors;28 c.NumberOfThreads = numberOfThreads;29 c.MemorySize = memorySize;30 c.IPAdresse = ipAdresse;31 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {32 if (cmdc.DatabaseExists()) {33 DA.Client clEntity = HLSA.Convert.ToEntity(c);34 cmdc.GetTable<DA.Resource>().InsertOnSubmit(clEntity);35 cmdc.SubmitChanges();36 return true;37 }38 return false;39 }40 }41 42 public static bool InsertGroup(string name, string description, string resourceType) {43 DT.ResourceGroup g = new DT.ResourceGroup();44 g.ResourceID = Guid.NewGuid();45 g.Name = name;46 g.Description = description;47 //g.ResourceType = resourceType;48 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {49 if (cmdc.DatabaseExists()) {50 DA.ResourceGroup gEntity = HLSA.Convert.ToEntity(g);51 cmdc.GetTable<DA.Resource>().InsertOnSubmit(gEntity);52 cmdc.SubmitChanges();53 return true;54 }55 return false;56 }57 }58 59 public static bool UpdateClient(string name, string description, string resourceType, string processorType,60 int numberOfProcessors, int numberOfThreads, string ipAdresse, int memorySize, string operatingSystem) {61 62 DT.Client uc = new DT.Client();63 uc.Name = name;64 uc.Description = description;65 //uc.ResourceType = resourceType;66 uc.ProcessorType = processorType;67 uc.NumberOfProcessors = numberOfProcessors;68 uc.NumberOfThreads = numberOfThreads;69 uc.MemorySize = memorySize;70 uc.IPAdresse = ipAdresse;71 72 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {73 if (cmdc.DatabaseExists()) {74 DA.Resource entity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.Name == uc.Name);75 if (entity != null) {76 uc.ResourceID = entity.ResourceID;77 uc.ResourceType = entity.ResourceType;78 HLSA.Convert.ToEntity(uc, (DA.Client)entity);79 cmdc.SubmitChanges();80 return true;81 }82 }83 }84 return false;85 }86 87 public static string DeleteResource(string name) {88 using (ClientManagmentDataContext cmdc = new ClientManagmentDataContext()) {89 string data = "deleted nothing";90 if (cmdc.DatabaseExists()) {91 DA.Resource entity = cmdc.GetTable<DA.Resource>().FirstOrDefault(x => x.Name == name);92 if (entity != null) {93 if (entity.ResourceType == "Client") {94 data = "deleted: ";95 data += (HLSA.Convert.ToDto((DA.Client)entity)).ToString();96 cmdc.GetTable<DA.Resource>().DeleteOnSubmit(entity);97 }98 else if (entity.ResourceType == "ResourceGroup") {99 data = "deleted: ";100 data += (HLSA.Convert.ToDto((DA.ResourceGroup)entity)).ToString();101 cmdc.GetTable<DA.Resource>().DeleteOnSubmit(entity);102 }103 else return data;104 cmdc.SubmitChanges();105 }106 }107 return data;108 }109 }110 3 111 4 5 //D:\Source\HL\ClientManagement\HeuristicLab.Services.Authentication\HeuristicLab.Services.Authentication.DataAccess\ClientManagment.designer.cs 6 /* 7 public ClientManagmentDataContext() : 8 base(global::HeuristicLab.Services.Authentication.DataAccess.Properties.Settings.Default.ClientManagementConnectionString, mappingSource) { 9 OnCreated(); 10 } 11 */ 12 13 namespace HeuristicLab.Services.Authentication.AdminMethods { 14 15 public class AdminMethods { 112 16 113 17 }
Note: See TracChangeset
for help on using the changeset viewer.