void loadData() { startYear = global.instances.Min(p => p.year); endYear = global.instances.Max(p => p.year); //重构所有实例信息,载入指标数据 foreach (InstanceData inst in global.instances) { YearData yeardata = null; if (!years.TryGetValue(inst.year, out yeardata)) { yeardata = new YearData() { year = inst.year }; years.Add(inst.year, yeardata); } ProjectData pd = new ProjectData() { prjid = inst.instanceID, year = inst.year, name = inst.instanceName, note = inst.note }; loadindex(pd); //载入指标 yeardata.projects.Add(pd); } gauge.nowPrj = years[years.Min(p => p.Key)].projects[0]; //初始化仪表为现状年 //----- 创建方案集合视图 foreach (var item in years.Values) { PAllYearPorjects prjview = new PAllYearPorjects(item) { Margin = new Thickness(20, 0, 0, 50) }; item.view = prjview; prjview.projectChanged += new EventHandler(prjview_projectChanged); } // 填写方案增量设备引用 foreach (var yeardata in years) { if (yeardata.Value.year == startYear) { continue; } foreach (var prj in yeardata.Value.projects) { prj.addobjs = global.getParentAdditionObjects(prj.prjid).Values.ToList(); foreach (var item in prj.addobjs) //若无增量设备的生效日期,则强制赋于为当年7.1日 { if ((item.busiAccount as DistNetLibrary.AcntDistBase).runDate.Year < prj.year) { (item.busiAccount as DistNetLibrary.AcntDistBase).runDate = new DateTime(prj.year, 7, 1); } } } } }
void simData() { startYear = 2017; endYear = 2030; int id = 0; YearData year = new YearData() { year = startYear }; ProjectData pd; pd = new ProjectData() { prjid = id, year = year.year, name = " 配网现状", note = "配网现状情况。" }; simindex(pd, (1.0 * year.year - startYear) / (endYear - startYear)); year.projects.Add(pd); years.Add(startYear, year); gauge.nowPrj = pd; //填写现状数据 year = new YearData() { year = endYear }; pd = new ProjectData() { prjid = id, year = year.year, name = " 规划方案" + id, note = string.Format(" 规划方案{0}。", id) }; simindex(pd, (1.0 * year.year - startYear) / (endYear - startYear)); year.projects.Add(pd); years.Add(endYear, year); for (int i = 0; i < 10 + rd.Next(7); i++) { id++; int tmp = startYear + rd.Next(endYear - startYear); if (tmp == startYear) { continue; } if (!years.TryGetValue(tmp, out year)) { year = new YearData() { year = tmp }; years.Add(tmp, year); } pd = new ProjectData() { prjid = id, year = year.year, name = " 规划方案" + id, note = string.Format(" 规划方案{0}。", id) }; simindex(pd, (1.0 * year.year - startYear) / (endYear - startYear)); year.projects.Add(pd); } id++; //----- 创建方案集合视图 foreach (var item in years.Values) { PAllYearPorjects prjview = new PAllYearPorjects(item) { Margin = new Thickness(20, 0, 0, 50) }; item.view = prjview; prjview.projectChanged += new EventHandler(prjview_projectChanged); } //----- 模拟投退运,仅设施、主配变、连接线路 IEnumerable <WpfEarthLibrary.PowerBasicObject> tmpobjs; IEnumerable <WpfEarthLibrary.PowerBasicObject> objs = distnet.getAllObjListByCategory(DistNetLibrary.EObjectCategory.变电设施类); tmpobjs = distnet.getAllObjListByCategory(DistNetLibrary.EObjectCategory.开关设施类); objs = objs.Union(tmpobjs); objs = distnet.getAllObjListByCategory(DistNetLibrary.EObjectCategory.导线类); objs = objs.Union(tmpobjs); tmpobjs = distnet.getAllObjListByCategory(DistNetLibrary.EObjectCategory.变压器类); objs = objs.Union(tmpobjs); List <WpfEarthLibrary.PowerBasicObject> allobjs = objs.ToList(); var allprjs = from e0 in years.Values from e1 in e0.projects select e1; foreach (ProjectData prj in allprjs.OrderBy(p => p.year)) { if (prj.year == startYear) { continue; //跳过现状年 } for (int i = 0; i < 2 + rd.Next(3); i++) { WpfEarthLibrary.PowerBasicObject obj = allobjs[rd.Next(allobjs.Count)]; if (obj.busiAccount is DistNetLibrary.AcntDistBase) { (obj.busiAccount as DistNetLibrary.AcntDistBase).runDate = new DateTime(prj.year, 1 + rd.Next(12), 1); //模拟增加投运日期 prj.addobjs.Add(obj); //加该设备为方案增量设备 obj.logicVisibility = false; //初始设定该增量设备不可见 } } } }