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 | //***************************************Algorithm Class********************************************
|
---|
19 | //get all algorithm classes
|
---|
20 | private IList<AlgorithmClass> AlgorithmClassGetAll() {
|
---|
21 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
22 |
|
---|
23 | IList<AlgorithmClass> algorithmClassList = new List<AlgorithmClass>();
|
---|
24 |
|
---|
25 | if (adminClient != null) {
|
---|
26 | AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses();
|
---|
27 | foreach (AlgorithmClass ac in algorithmClasses) {
|
---|
28 | algorithmClassList.Add(ac);
|
---|
29 |
|
---|
30 | }
|
---|
31 | }//if (adminClient != null)
|
---|
32 |
|
---|
33 | return algorithmClassList;
|
---|
34 | }//AlgorithmClassGetAll
|
---|
35 |
|
---|
36 | private long AddAlgorithmClass(AlgorithmClass algorithmClass) {
|
---|
37 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
38 |
|
---|
39 | if (adminClient != null) {
|
---|
40 | return adminClient.AddAlgorithmClass(algorithmClass);
|
---|
41 | }
|
---|
42 |
|
---|
43 | return 0;
|
---|
44 | }//AddAlgorithmClass
|
---|
45 |
|
---|
46 | public void DeleteAlgorithmClass(long id) {
|
---|
47 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
48 |
|
---|
49 | if (adminClient != null) {
|
---|
50 | adminClient.DeleteAlgorithmClass(id);
|
---|
51 | }
|
---|
52 | }//DeleteAlgorithmClass
|
---|
53 |
|
---|
54 | public long SaveAlgorithmClass(AlgorithmClass algorithmClass) {
|
---|
55 | AdministrationServiceClient adminClient = Admin.GetClientFactory();
|
---|
56 |
|
---|
57 | if (adminClient != null) {
|
---|
58 | if (algorithmClass.Id == 0) {
|
---|
59 | return AddAlgorithmClass(algorithmClass);
|
---|
60 | }
|
---|
61 | else {
|
---|
62 | AlgorithmClass ac = adminClient.GetAlgorithmClass(algorithmClass.Id);
|
---|
63 |
|
---|
64 | if (ac != null) {
|
---|
65 | adminClient.UpdateAlgorithmClass(algorithmClass);
|
---|
66 | return algorithmClass.Id;
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | return 0;
|
---|
72 | }//SaveAlgorithmClass
|
---|
73 | }
|
---|
74 | } |
---|