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 |
|
---|
8 | namespace HLWebPluginHost.Models {
|
---|
9 | public class AlgorithmClassModel {
|
---|
10 |
|
---|
11 | public int NumOfClasses { get; set; }
|
---|
12 | public List<OKBService.AlgorithmClass> AlgorithmClassList { get; set; }
|
---|
13 |
|
---|
14 | public List<OKBService.AlgorithmClass> AlgorithmClassGetAll() {
|
---|
15 | //returns list of algorithm classes
|
---|
16 | OKBService.OKBServiceClient sc = new OKBService.OKBServiceClient();
|
---|
17 | sc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;
|
---|
18 | sc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();
|
---|
19 | sc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
|
---|
20 |
|
---|
21 | var agcList = new List<OKBService.AlgorithmClass>();
|
---|
22 |
|
---|
23 | OKBService.AlgorithmClass[] ac = sc.GetAlgorithmClasses();
|
---|
24 | foreach (OKBService.AlgorithmClass a in ac) {
|
---|
25 | agcList.Add(a);
|
---|
26 |
|
---|
27 | }//foreach
|
---|
28 |
|
---|
29 | return agcList;
|
---|
30 | }//AlgorithmClassGetAll
|
---|
31 |
|
---|
32 | //Add AlgorithmClass table entry
|
---|
33 | public bool AddAlgorithmClass(string name, string description) {
|
---|
34 | long retValue;
|
---|
35 | //get service client
|
---|
36 | OKBService.OKBServiceClient sc = new OKBService.OKBServiceClient();
|
---|
37 | sc.ClientCredentials.UserName.UserName = Membership.GetUser().UserName;
|
---|
38 | sc.ClientCredentials.UserName.Password = HttpContext.Current.Session["pwd"].ToString();
|
---|
39 | sc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
|
---|
40 |
|
---|
41 | OKBService.AlgorithmClass ac = new OKBService.AlgorithmClass();
|
---|
42 | //test
|
---|
43 | //ac.Id = 8;
|
---|
44 | ac.Name = name;
|
---|
45 | ac.Description = description;
|
---|
46 | retValue = sc.AddAlgorithmClass(ac);
|
---|
47 |
|
---|
48 | return true;
|
---|
49 | }//AddAlgorithmClass
|
---|
50 | }
|
---|
51 | } |
---|