using System; using System.Collections.Generic; using System.Linq; using System.Web; using HLWebOKBAdminPlugin.OKBAdministrationService; using HLWebOKBAdminPlugin.Helpers; namespace HLWebOKBAdminPlugin.Models { public class AlgorithmModel { public String SelectedSubMenu { get; set; } public IList Algorithms { get { return AlgorithmGetAll(); } set { ;} } public IList AlgorithmClasses { get { return AlgorithmClassGetAll(); } } public IList Platforms { get { return PlatformsGetAll(); } } public Algorithm Algorithm { get; set; } public AlgorithmModel() { Algorithm = new Algorithm(); }//AlgorithmModel //***************************************Algorithms*************************************************** private IList PlatformsGetAll() { AdministrationServiceClient adminClient = Admin.GetClientFactory(); IList platformList = new List(); if (adminClient != null) { Platform[] platforms = adminClient.GetPlatforms(); foreach (Platform pl in platforms) { platformList.Add(pl); } }//if (adminClient != null) return platformList; }//AlgorithmClassGetAll private IList AlgorithmClassGetAll() { AdministrationServiceClient adminClient = Admin.GetClientFactory(); IList algorithmClassList = new List(); if (adminClient != null) { AlgorithmClass[] algorithmClasses = adminClient.GetAlgorithmClasses(); foreach(AlgorithmClass ac in algorithmClasses) { algorithmClassList.Add(ac); } }//if (adminClient != null) return algorithmClassList; }//AlgorithmClassGetAll private IList AlgorithmGetAll() { AdministrationServiceClient adminClient = Admin.GetClientFactory(); IList algorithmList = new List(); if (adminClient != null) { Algorithm[] algorithm = adminClient.GetAlgorithms(); foreach(Algorithm alg in algorithm) { algorithmList.Add(alg); } }//if (adminClient != null) return algorithmList; }//AlgorithmGetAll private long AddAlgorithm(Algorithm algorithm) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { return adminClient.AddAlgorithm(algorithm); } return 0; }//AddAlgorithm public void DeleteAlgorithm(long id) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { adminClient.DeleteAlgorithm(id); } }//DeleteAlgorithm public long SaveAlgorithm(Algorithm algorithm) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { if (algorithm.Id == 0) { return AddAlgorithm(algorithm); } else { Algorithm alg = adminClient.GetAlgorithm(algorithm.Id); if (alg != null) { adminClient.UpdateAlgorithm(algorithm); return algorithm.Id; } } } return 0; }//SaveAlgorithm public void UpdateAlgorithmData(long id, byte[] data) { AdministrationServiceClient adminClient = Admin.GetClientFactory(); if (adminClient != null) { adminClient.UpdateAlgorithmData(id, data); } }//UpdateProblemData } }