Changeset 6143 for branches/WebApplication/MVC2
- Timestamp:
- 05/07/11 13:51:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/AlgorithmClassModel.cs
r5700 r6143 6 6 using System.Web.Security; 7 7 using HLWebOKBAdminPlugin.OKBAdministrationService; 8 using HLWebOKBAdminPlugin.Helpers; 8 9 9 10 namespace HLWebPluginHost.Models { 10 public class AlgorithmClassModel { 11 public class AlgorithmClassModel { 11 12 12 p rivate AdministrationServiceClient CertificateValidator() {13 AdministrationServiceClient asc = new AdministrationServiceClient();13 public String SelectedSubMenu { get; set; } 14 public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } } 14 15 15 asc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;16 asc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();17 asc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;18 16 19 return asc; 20 }//CertificateValidator 17 //***************************************Algorithm Class******************************************** 18 //get all algorithm classes 19 private IList<AlgorithmClass> AlgorithmClassGetAll() { 20 AdministrationServiceClient adminClient = Admin.GetClientFactory(); 21 21 22 public int NumOfClasses { get; set; } 23 public List<AlgorithmClass> AlgorithmClassList { get; set; } 22 IList<AlgorithmClass> algorithmClassList = new List<AlgorithmClass>(); 24 23 25 public List<AlgorithmClass> AlgorithmClassGetAll() { 26 //returns list of algorithm classes 27 AdministrationServiceClient asc = CertificateValidator(); 24 if (adminClient != null) { 25 AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses(); 26 foreach (AlgorithmClass ac in algorithmClasses) { 27 algorithmClassList.Add(ac); 28 28 29 var agcList = new List<AlgorithmClass>(); 29 } 30 }//if (adminClient != null) 30 31 31 AlgorithmClass[] ac = asc.GetAlgorithmClasses(); 32 foreach (AlgorithmClass a in ac) { 33 agcList.Add(a); 34 35 }//foreach 36 37 return agcList; 32 return algorithmClassList; 38 33 }//AlgorithmClassGetAll 39 34 40 //Add AlgorithmClass table entry 41 public bool AddAlgorithmClass(string name, string description) { 42 long retValue; 43 //get service client 44 AdministrationServiceClient asc = CertificateValidator(); 35 private long AddAlgorithmClass(AlgorithmClass algorithmClass) { 36 AdministrationServiceClient adminClient = Admin.GetClientFactory(); 45 37 46 AlgorithmClass ac = new AlgorithmClass(); 47 //test 48 //ac.Id = 8; 49 ac.Name = name; 50 ac.Description = description; 51 retValue = asc.AddAlgorithmClass(ac); 52 53 return true; 38 if (adminClient != null) { 39 return adminClient.AddAlgorithmClass(algorithmClass); 40 } 41 42 return 0; 54 43 }//AddAlgorithmClass 44 45 public void DeleteAlgorithmClass(long id) { 46 AdministrationServiceClient adminClient = Admin.GetClientFactory(); 47 48 if (adminClient != null) { 49 adminClient.DeleteAlgorithmClass(id); 50 } 51 }//DeleteAlgorithmClass 52 53 public long SaveAlgorithmClass(AlgorithmClass algorithmClass) { 54 AdministrationServiceClient adminClient = Admin.GetClientFactory(); 55 56 if (adminClient != null) { 57 if (algorithmClass.Id == 0) { 58 return AddAlgorithmClass(algorithmClass); 59 } 60 else { 61 AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id); 62 63 if (ac != null) { 64 adminClient.UpdateAlgorithmClass(algorithmClass); 65 return algorithmClass.Id; 66 } 67 } 68 } 69 70 return 0; 71 }//SaveAlgorithmClass 55 72 } 56 73 }
Note: See TracChangeset
for help on using the changeset viewer.