public AllEventsViewModel(/*EventService eventService*/ ProgramServiceClass programService, ProjectServiceClass projectService, ProgramTypeServiceClass programTypeService, BatteryServiceClass batteryService, TesterServiceClass testerService, ChannelServiceClass channelService, ChamberServiceClass chamberService, BatteryTypeServiceClass batteryTypeService) { _programService = programService; _projectService = projectService; _programTypeService = programTypeService; _batteryService = batteryService; _testerService = testerService; _channelService = channelService; _chamberService = chamberService; _batteryTypeService = batteryTypeService; //_eventService = eventService; //this.CreateAllEvents(_eventService.Items); //_eventService.Items.CollectionChanged += Items_CollectionChanged; this.CreateAllEvents(EventService.Items); EventService.Items.CollectionChanged += Items_CollectionChanged; }
private static ProgramType GetProgramTypeFromNode(string value, ProgramTypeServiceClass programTypeService) { return(programTypeService.Items.SingleOrDefault(o => o.Name == value)); }
private static Program BuildProgramFromPseudocode(XElement xmlProgram, ProgramServiceClass programService, ProjectServiceClass projectService, ProgramTypeServiceClass programTypeService, RecipeTemplateServiceClass recipeTemplateService) { var program = new Program(); try { program.Name = xmlProgram.Attribute("Name").Value; program.Type = GetProgramTypeFromNode(xmlProgram.Attribute("Type").Value, programTypeService); program.Project = GetProjectFromNode(xmlProgram.Attribute("Project").Value, projectService); program.Requester = xmlProgram.Attribute("Requester").Value; program.RequestTime = DateTime.Parse(xmlProgram.Attribute("RequestDate").Value); var xmlTemperatures = xmlProgram.Descendants("Temperatures").Elements(); if (xmlTemperatures != null) { foreach (var xmlT in xmlTemperatures) { program.Temperatures.Add(Convert.ToInt32(xmlT.Value)); } } var xmlRecipes = xmlProgram.Descendants("Recipes").Elements(); if (xmlRecipes != null) { var dic = new Dictionary <int, int>(); //recipe template id, count foreach (var xmlRec in xmlRecipes) { if (xmlRec.Attribute("Template") == null) { continue; } var recTid = xmlRec.Attribute("Template").Value; if (recTid == string.Empty) { continue; } var Tid = Convert.ToInt32(recTid); var recT = recipeTemplateService.Items.SingleOrDefault(o => o.Id == Tid); if (recT == null) { MessageBox.Show($@"No such recipe template:{recTid}"); continue; } program.RecipeTemplates.Add(recT.Name); var count = GetIntergerFromNode(xmlRec, "Count"); if (count == 0) { count = 1; } dic.Add(recT.Id, count); } program.BuildRecipes(recipeTemplateService.Items.ToList(), dic); } } catch (Exception e) { MessageBox.Show(e.Message); } return(program); }
private static List <Program> BuildProgramsFromPseudocode(string fileName, ProgramServiceClass programService, ProjectServiceClass projectService, ProgramTypeServiceClass programTypeService, RecipeTemplateServiceClass recipeTemplateService) { List <Program> output = new List <Program>(); if (File.Exists(fileName)) { XDocument xd = new XDocument(); xd = XDocument.Load(fileName); var xmlPrograms = xd.Descendants("Programs").Elements(); foreach (var xmlProgram in xmlPrograms) { output.Add(BuildProgramFromPseudocode(xmlProgram, programService, projectService, programTypeService, recipeTemplateService)); } } if (output.Count != 0) { return(output); } else { return(null); } }
internal static void Load(string fileName, RecipeTemplateServiceClass recipeTemplateService, ProgramServiceClass programService, ProjectServiceClass projectService, ProgramTypeServiceClass programTypeService) { List <RecipeTemplate> recipeTemplates = BuildRecipeTemplatesFromPseudocode(fileName, recipeTemplateService); if (recipeTemplates != null) { foreach (var rt in recipeTemplates) { recipeTemplateService.SuperAdd(rt); } } List <Program> programs = BuildProgramsFromPseudocode(fileName, programService, projectService, programTypeService, recipeTemplateService); if (programs != null) { foreach (var prog in programs) { programService.SuperAdd(prog); //programService.FixTemplates(prog); //不管用 } } }
public AllProgramTypesViewModel(ProgramTypeServiceClass programTypeService) { _programTypeService = programTypeService; this.CreateAllProgramTypes(_programTypeService.Items); _programTypeService.Items.CollectionChanged += Items_CollectionChanged; }