Esempio n. 1
0
        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);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        void showindexcompare()
        {
            //创建表
            DataTable  dt = new DataTable();
            DataColumn dc;

            dc = new DataColumn("分类", typeof(string)); dt.Columns.Add(dc);
            dc = new DataColumn("指标", typeof(string)); dt.Columns.Add(dc);
            YearData yd = years[timeline.selYear];

            foreach (var item in yd.projects)
            {
                dc = new DataColumn(item.name, typeof(string)); dt.Columns.Add(dc);
            }
            //DataTable dtidx = DataLayer.DataProvider.getDataTableFromSQL("select cast(ID as nvarchar(100)) id, sort1,sort2,ord,indexname, definition,IMPORTANT,format,VALUE,UNIT,VALUENOTE,REFER1,REFER2,REFERTYPE,refernote from d_index where SORT0='863' order by ord,IMPORTANT");

            DataTable dtidx = DataLayer.DataProvider.getDataTableFromSQL("select cast(ID as nvarchar(100)) id, sort1,sort2,ord,indexname, definition,IMPORTANT,format,VALUE,UNIT,VALUENOTE,REFER1,REFER2,REFERTYPE,refernote from Dic_Index where Category='863' order by ord,IMPORTANT");
            //创建树的枝记录
            DataRow adddr;
            var     tmp = from e0 in dtidx.AsEnumerable() group e0 by e0["sort2"];

            foreach (var ee in tmp)
            {
                adddr    = dt.NewRow();
                adddr[1] = ee.Key;
                dt.Rows.Add(adddr);
            }

            //读指标
            foreach (DataRow dr in dtidx.Rows)
            {
                adddr    = dt.NewRow();
                adddr[0] = dr["sort2"].ToString();
                adddr[1] = String.Format("{0}({1})", dr["indexname"], dr["unit"]);
                if (adddr[0].ToString() == adddr[1].ToString())
                {
                    adddr[1] = dr["indexname"].ToString() + "指标";
                }
                int idx = 2;
                foreach (var item in yd.projects)
                {
                    adddr[idx] = String.Format("{0}{1}", (double.Parse(dr["value"].ToString()) * (0.9 + 0.2 * rd.NextDouble())).ToString(dr["format"].ToString()), dr["unit"]);
                    idx++;
                }
                dt.Rows.Add(adddr);
            }
            gridIndexCompare.ItemsSource = null;
            gridIndexCompare.ItemsSource = dt;

            aniidx.To = 1;
            gridIndexCompare.BeginAnimation(Grid.OpacityProperty, aniidx);
            anidistnet.To = 0.4;
            distnet.scene.BeginAnimation(UserControl.OpacityProperty, anidistnet);
            gridIndexCompare.IsHitTestVisible = true;
        }
Esempio n. 3
0
 public PAllYearPorjects(YearData Year)
 {
     year = Year;
     InitializeComponent();
     buildview();
 }
Esempio n. 4
0
        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;                                                                           //初始设定该增量设备不可见
                    }
                }
            }
        }
Esempio n. 5
0
        void showindexcompare()
        {
            //创建表
            DataTable  dt = new DataTable();
            DataColumn dc;

            dc = new DataColumn("分类", typeof(string)); dt.Columns.Add(dc);
            dc = new DataColumn("指标", typeof(string)); dt.Columns.Add(dc);
            YearData yd = years[timeline.selYear];

            foreach (var item in yd.projects)
            {
                dc = new DataColumn(item.name, typeof(string)); dt.Columns.Add(dc);
            }

            string sql = string.Format("select cast(ID as nvarchar(100)) id, sort1,sort2,ord,indexname, definition,IMPORTANT,format,UNIT,VALUENOTE,REFER1,REFER2,REFERTYPE,refernote from  Dic_Index t1 where Category='求实' order by ord,IMPORTANT");

            DataTable dtidx = DataLayer.DataProvider.getDataTableFromSQL(sql);
            //创建树的枝记录
            DataRow adddr;
            var     tmp = from e0 in dtidx.AsEnumerable() group e0 by e0["sort2"];

            foreach (var ee in tmp)
            {
                adddr    = dt.NewRow();
                adddr[1] = ee.Key;
                dt.Rows.Add(adddr);
            }

            //======读指标
            //构建读指标值语句
            string filter = "";
            int    tmpi   = 0;

            foreach (var item in yd.projects)
            {
                if (tmpi == 0)
                {
                    filter += string.Format("instanceid={0}", item.prjid);
                }
                else
                {
                    filter += string.Format(" or instanceid={0}", item.prjid);
                }
                tmpi++;
            }
            sql = string.Format("select * from anal_index where flag='规划指标评估报表' and ({0})", filter);
            DataTable dtvalue = DataLayer.DataProvider.getDataTableFromSQL(sql);


            foreach (DataRow dr in dtidx.Rows)
            {
                adddr    = dt.NewRow();
                adddr[0] = dr["sort2"].ToString();
                if (dr["format"].ToString().Contains("p"))
                {
                    adddr[1] = String.Format("{0}(%)", dr["indexname"]);
                }
                else
                {
                    adddr[1] = String.Format("{0}({1})", dr["indexname"], dr["unit"]);
                }
                if (adddr[0].ToString() == adddr[1].ToString())
                {
                    adddr[1] = dr["indexname"].ToString() + "指标";
                }
                int idx = 2;
                foreach (var item in yd.projects)
                {
                    DataRow vdr   = dtvalue.AsEnumerable().FirstOrDefault(p => p.getInt("instanceid") == item.prjid && p.getInt("indexid") == dr.getInt("id"));
                    double  value = vdr == null ? 0 : vdr.getDouble("value");

                    adddr[idx] = String.Format("{0}{1}", value.ToString(dr["format"].ToString()), dr["unit"]);
                    idx++;
                }
                dt.Rows.Add(adddr);
            }
            gridIndexCompare.ItemsSource = null;
            gridIndexCompare.ItemsSource = dt;

            aniidx.To = 1;
            gridIndexCompare.BeginAnimation(Grid.OpacityProperty, aniidx);
            anidistnet.To = 0.4;
            distnet.scene.BeginAnimation(UserControl.OpacityProperty, anidistnet);
            gridIndexCompare.IsHitTestVisible = true;
        }