[4985] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Web;
|
---|
| 5 | using System.ServiceModel.Security;
|
---|
| 6 | using System.Web.Security;
|
---|
[5700] | 7 | using HLWebOKBAdminPlugin.OKBAdministrationService;
|
---|
[6143] | 8 | using HLWebOKBAdminPlugin.Helpers;
|
---|
[4985] | 9 |
|
---|
[6144] | 10 | namespace HLWebOKBAdminPlugin.Models {
|
---|
[6143] | 11 | public class AlgorithmClassModel {
|
---|
[4985] | 12 |
|
---|
[6143] | 13 | public String SelectedSubMenu { get; set; }
|
---|
| 14 | public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } }
|
---|
[5700] | 15 |
|
---|
[6144] | 16 | public AlgorithmClass AlgorithmClass { get; set; }
|
---|
[5700] | 17 |
|
---|
[6161] | 18 | public AlgorithmClassModel() {
|
---|
| 19 | AlgorithmClass = new AlgorithmClass();
|
---|
| 20 | }//AlgorithmClassModel
|
---|
| 21 |
|
---|
[6143] | 22 | //***************************************Algorithm Class********************************************
|
---|
[6161] | 23 | private IList<Platform> PlatformsGetAll() {
|
---|
| 24 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
| 25 |
|
---|
| 26 | IList<Platform> platformList = new List<Platform>();
|
---|
| 27 |
|
---|
| 28 | if (adminClient != null) {
|
---|
| 29 | Platform[] platforms = adminClient.GetPlatforms();
|
---|
| 30 | foreach (Platform pl in platforms) {
|
---|
| 31 | platformList.Add(pl);
|
---|
| 32 | }
|
---|
| 33 | }//if (adminClient != null)
|
---|
| 34 |
|
---|
| 35 | return platformList;
|
---|
| 36 | }//ProblemClassGetAll
|
---|
| 37 |
|
---|
| 38 | private IList<ProblemClass> ProblemClassGetAll() {
|
---|
| 39 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
| 40 |
|
---|
| 41 | IList<ProblemClass> problemClassList = new List<ProblemClass>();
|
---|
| 42 |
|
---|
| 43 | if (adminClient != null) {
|
---|
| 44 | ProblemClass[] problemClasses = adminClient.GetProblemClasses();
|
---|
| 45 | foreach (ProblemClass pc in problemClasses) {
|
---|
| 46 | problemClassList.Add(pc);
|
---|
| 47 | }
|
---|
| 48 | }//if (adminClient != null)
|
---|
| 49 |
|
---|
| 50 | return problemClassList;
|
---|
| 51 | }//ProblemClassGetAll
|
---|
| 52 |
|
---|
[6143] | 53 | //get all algorithm classes
|
---|
| 54 | private IList<AlgorithmClass> AlgorithmClassGetAll() {
|
---|
| 55 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
[5700] | 56 |
|
---|
[6143] | 57 | IList<AlgorithmClass> algorithmClassList = new List<AlgorithmClass>();
|
---|
[4985] | 58 |
|
---|
[6143] | 59 | if (adminClient != null) {
|
---|
| 60 | AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
|
---|
| 61 | foreach (AlgorithmClass ac in algorithmClasses) {
|
---|
| 62 | algorithmClassList.Add(ac);
|
---|
[4985] | 63 |
|
---|
[6143] | 64 | }
|
---|
| 65 | }//if (adminClient != null)
|
---|
[4985] | 66 |
|
---|
[6143] | 67 | return algorithmClassList;
|
---|
| 68 | }//AlgorithmClassGetAll
|
---|
[4985] | 69 |
|
---|
[6143] | 70 | private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
|
---|
| 71 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
[4985] | 72 |
|
---|
[6143] | 73 | if (adminClient != null) {
|
---|
| 74 | return adminClient.AddAlgorithmClass(algorithmClass);
|
---|
| 75 | }
|
---|
[4985] | 76 |
|
---|
[6143] | 77 | return 0;
|
---|
| 78 | }//AddAlgorithmClass
|
---|
[4985] | 79 |
|
---|
[6143] | 80 | public void DeleteAlgorithmClass(long id) {
|
---|
| 81 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
| 82 |
|
---|
| 83 | if (adminClient != null) {
|
---|
| 84 | adminClient.DeleteAlgorithmClass(id);
|
---|
| 85 | }
|
---|
| 86 | }//DeleteAlgorithmClass
|
---|
| 87 |
|
---|
| 88 | public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
|
---|
| 89 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
| 90 |
|
---|
| 91 | if (adminClient != null) {
|
---|
| 92 | if (algorithmClass.Id == 0) {
|
---|
| 93 | return AddAlgorithmClass(algorithmClass);
|
---|
| 94 | }
|
---|
| 95 | else {
|
---|
| 96 | AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
|
---|
| 97 |
|
---|
| 98 | if (ac != null) {
|
---|
| 99 | adminClient.UpdateAlgorithmClass(algorithmClass);
|
---|
| 100 | return algorithmClass.Id;
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | return 0;
|
---|
| 106 | }//SaveAlgorithmClass
|
---|
[4985] | 107 | }
|
---|
| 108 | } |
---|