Beispiel #1
0
 public bool CloseProject(ProjectController exp)
 {
     Projects.Remove(exp);
     return(true);
 }
Beispiel #2
0
        public ProjectController OpenProject(string filePath)
        {
            try
            {
                //JsonSerializerSettings sett = new JsonSerializerSettings();
                //sett.NullValueHandling = NullValueHandling.Ignore;

                //var strJson = System.IO.File.ReadAllText(filePath);
                //var obj = JsonConvert.DeserializeObject(strJson, sett);
                //var d = ((dynamic)obj)["DataSet"] as Newtonsoft.Json.Linq.JObject;
                //var mods = ((dynamic)obj)["Models"] as Newtonsoft.Json.Linq.JArray;
                //var name = ((dynamic)obj)["Name"] as Newtonsoft.Json.Linq.JValue;
                //var projectInfo = ((dynamic)obj)["ProjectInfo"] as Newtonsoft.Json.Linq.JValue;


                ////create NET Project object from Json
                //var guid = Guid.NewGuid().ToString();
                //var pController = new ProjectController(guid);
                //pController.Project.Name = (string)name;

                //pController.Project.DataSet = d.ToObject<DataSet1>();
                //pController.Project.FilePath = filePath;
                //pController.Project.ProjectInfo = (string)projectInfo;

                ////
                ////de-serialize models
                //Model[] mod = mods.ToObject<Model[]>();
                //foreach (var m in mod)
                //{
                //    var g = Guid.NewGuid().ToString();
                //    var exp = new Data.Experiment(m.DataSet);

                //    var classes = exp.GetColumnsFromOutput()[0].Statistics.Categories;
                //    var label = exp.GetColumnsFromOutput()[0].Name;

                //    var mm = new ModelController(g, exp.GetOutputColumnType(), classes, label);
                //    mm.Model.Factory = m.Factory;
                //    mm.Model.Name = m.Name;
                //    mm.Model.DataSet = m.DataSet;
                //    mm.Model.ExpData = exp;
                //    mm.SetParent(pController);
                //    mm.InitPersistedModel();
                //    pController.Project.Models.Add(mm.Model);
                //    pController.Models.Add(mm);
                //}

                var guid        = Guid.NewGuid().ToString();
                var pController = new ProjectController(guid);
                var project     = Project.Open(filePath);
                foreach (var m in project.Models)
                {
                    var exp     = m.ExpData;
                    var g       = Guid.NewGuid().ToString();
                    var classes = exp.GetColumnsFromOutput()[0].Statistics.Categories;
                    var label   = exp.GetColumnsFromOutput()[0].Name;

                    var mm = new ModelController(g, exp.GetOutputColumnType(), classes, label);
                    mm.Model = m;
                    mm.SetParent(pController);
                    mm.InitPersistedModel();
                    pController.Project.Models.Add(mm.Model);
                    pController.Models.Add(mm);
                }

                //add project to app controller
                pController.Project = project;
                Projects.Add(pController);
                return(pController);
            }
            catch (Exception)
            {
                throw;
            }
        }