Пример #1
0
        private void btntran_Click(object sender, RoutedEventArgs e)
        {
            string sql = @"
                    select t1.name,t2.value cname from
                    (select * from sysobjects t1 where xtype='U') t1 left join
                    (select * from sys.extended_properties   where minor_id=0 and name='MS_Description') t2 on t1.id=t2.major_id order by name
                    ";
            DataTable dt = DataLayer.DataProvider.getDataTableFromSQL(sql);
            foreach (DataRow dr in dt.Rows)
            {
                string tname = dr.Field<string>("name").ToLower();

                // **************** 不处理以前的t_打头的表  ******************
                if (tname.Substring(0, 2) == "t_") continue;

                sql = @"
                    SELECT syscolumns.name,systypes.name ftype,t3.value cname
                    FROM syscolumns join systypes on syscolumns.xusertype = systypes.xusertype
                        left join sys.extended_properties t3 on syscolumns.id=t3.major_id and syscolumns.colorder=t3.minor_id
                    WHERE syscolumns.id = object_id('{0}') order by name
            ";
                DataTable dt2 = DataLayer.DataProvider.getDataTableFromSQL(String.Format(sql, tname));
                List<string> fields = new List<string>();
                foreach (DataRow item in dt2.Rows)
                {
                    fields.Add(item.Field<string>("name").ToLower());
                }

                DataTable dt3 = DataLayer.DataProvider.getDataTableFromSQL("select * from " + dr.Field<string>("name"));
                if (fields.Contains("f_id") && dt3.Rows.Count > 0) //有主键字段且有数据
                {
                    sqls.Clear();
                    string ename, gname;
                    ename = "f_ex"; gname = "f_gx";
                    if (fields.Contains(ename) && fields.Contains(gname))
                        filltwo(dt3, ename, gname, tname);
                    ename = "f_ey"; gname = "f_gy";
                    if (fields.Contains(ename) && fields.Contains(gname))
                        filltwo(dt3, ename, gname, tname);
                    ename = "f_ezbch"; gname = "f_gzbch";
                    if (fields.Contains(ename) && fields.Contains(gname))
                        filltwo(dt3, ename, gname, tname);
                    DataLayer.DataProvider.bacthExecute(sqls);
                    //======================
                    sqls.Clear();
                    dt3 = DataLayer.DataProvider.getDataTableFromSQL("select * from " + dr.Field<string>("name"));
                    transCood(dt3, fields, tname);
                    DataLayer.DataProvider.bacthExecute(sqls);
                }
            }

            infos.Insert(0, "*************** 处理完毕 **************");
        }
Пример #2
0
        ///<summary>产生线路数据</summary>
        static void genline(DistNet dn)
        {
            foreach (DNACLineBase item in dn.getAllObjListByObjType(EObjectType.输电线路))
            {
                RunDataACLineBase rundata = item.busiRunData as RunDataACLineBase;
                AcntACLineBase    acnt    = item.busiAccount as AcntACLineBase;
                if (acnt.cap == 0)
                {
                    acnt.cap = rd.Next(50);
                }
                rundata.activePower = acnt.cap * (0.4 + 0.5 * rd.NextDouble());
                //rundata.powerFactor = 0.8 + 0.2 * rd.NextDouble();
                //rundata.apparentPower = rundata.activePower / rundata.powerFactor;
                rundata.reactivePower = Math.Sqrt(Math.Pow(rundata.apparentPower, 2) - Math.Pow(rundata.activePower, 2));
                //rundata.rateOfLoad = rundata.apparentPower / acnt.cap;

                if (rd.NextDouble() < 0.01)
                {
                    if (events.Count > 50)
                    {
                        events.Remove(events.Last());
                    }
                    events.Insert(0, new EventData()
                    {
                        eObjID = item.id, startTime = DateTime.Now, eType = (EventData.EEventType)rd.Next(2), eTitle = item.name + "事件.", eContent = DateTime.Now.ToShortDateString() + item.name + "事件描述......"
                    });
                }



                if (item is DNACLine)
                {
                    if (rundata.lstApparentPower.Count == 0) //初始模拟50条
                    {
                        for (int i = 50; i > 0; i--)
                        {
                            rundata.lstApparentPower.Add(new MyClassLibrary.DevShare.ChartDataPoint()
                            {
                                argudate = DateTime.Now.AddMinutes(i), value = acnt.cap * (0.4 + 0.5 * rd.NextDouble())
                            });
                        }
                    }
                    //rundata.addApparentPower(rundata.apparentPower);
                    rundata.refresh();
                }
            }
        }