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;
|
---|
7 | using HLWebOKBAdminPlugin.OKBAdministrationService;
|
---|
8 | using HLWebOKBAdminPlugin.Helpers;
|
---|
9 |
|
---|
10 | namespace HLWebOKBAdminPlugin.Models {
|
---|
11 | public class AlgorithmClassModel {
|
---|
12 |
|
---|
13 | public String SelectedSubMenu { get; set; }
|
---|
14 | public IList<AlgorithmClass> AlgorithmClasses { get { return AlgorithmClassGetAll(); } }
|
---|
15 |
|
---|
16 | public AlgorithmClass AlgorithmClass { get; set; }
|
---|
17 |
|
---|
18 | public AlgorithmClassModel() {
|
---|
19 | AlgorithmClass = new AlgorithmClass();
|
---|
20 | }//AlgorithmClassModel
|
---|
21 |
|
---|
22 | //***************************************Algorithm Class********************************************
|
---|
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 |
|
---|
53 | //get all algorithm classes
|
---|
54 | private IList<AlgorithmClass> AlgorithmClassGetAll() {
|
---|
55 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
56 |
|
---|
57 | IList<AlgorithmClass> algorithmClassList = new List<AlgorithmClass>();
|
---|
58 |
|
---|
59 | if (adminClient != null) {
|
---|
60 | AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
|
---|
61 | foreach (AlgorithmClass ac in algorithmClasses) {
|
---|
62 | algorithmClassList.Add(ac);
|
---|
63 |
|
---|
64 | }
|
---|
65 | }//if (adminClient != null)
|
---|
66 |
|
---|
67 | return algorithmClassList;
|
---|
68 | }//AlgorithmClassGetAll
|
---|
69 |
|
---|
70 | private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
|
---|
71 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
72 |
|
---|
73 | if (adminClient != null) {
|
---|
74 | return adminClient.AddAlgorithmClass(algorithmClass);
|
---|
75 | }
|
---|
76 |
|
---|
77 | return 0;
|
---|
78 | }//AddAlgorithmClass
|
---|
79 |
|
---|
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
|
---|
107 | }
|
---|
108 | } |
---|