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