Esempio n. 1
0
        ///<summary>
        ///根据dbopkey取得的数据库描述定义,批量创建对象载入到distnet中,同时读入台账数据和拓扑数据。
        ///以对象的大类名为层名
        ///若同层同ID对象已存在,则忽略
        ///addwhere为附加到selectAll的附加过滤语句
        ///layername为创建对象时可指定层名称,若为空则以对象所属大类为类名称
        ///返回创建对象列表,供附加其它设置
        ///</summary>
        public List <PowerBasicObject> batchCreateDNObjects(DistNet distnet, string addwhere = "", string layername = null)
        {
            MyBaseControls.Screen.ScreenProgress.info = string.Format("载入{0}...", this.key);

            DataLayer.DataProvider.curDataSourceName = dbdesc.datasourceName;

            List <PowerBasicObject> result = new List <PowerBasicObject>();

            PowerBasicObject obj;
            pLayer           player;
            string           s  = acntSelectAll + " " + addwhere;
            DataTable        dt = DataLayer.DataProvider.getDataTableFromSQL(s);

            if (dt.Rows.Count > 0)
            {
                if (string.IsNullOrWhiteSpace(layername))
                {
                    pLayer tmplayer = new pLayer(null);
                    obj    = createDNObject(tmplayer);
                    player = distnet.addLayer((obj.busiDesc as DescData).objCategory.ToString());
                }
                else
                {
                    player = distnet.addLayer(layername);
                }

                //批量创建对象
                foreach (DataRow dr in dt.Rows)
                {
                    //string zid = dr.getString(this.acntTableRelation.mainTable.keyFieldName);
                    string zid = dr.getString(this.keypdesces.FirstOrDefault(p => p.propertyname == "ID").fieldname);
                    if (string.IsNullOrWhiteSpace(zid))
                    {
                        MyBaseControls.StatusBarTool.StatusBarTool.reportInfo.showInfo("存在设备ID为空的对象,这些对象未被创建,请检查数据来源!", 30);
                        MyBaseControls.LogTool.Log.addLog(string.Format("{1}存在设备ID为空的对象,这些对象未被创建。({0})", this, this.key), MyBaseControls.LogTool.ELogType.告警);
                        continue;  //若设备id为空,不创建对象
                    }

                    bool isExist = false;
                    foreach (pLayer lay in player.parent.zLayers.Values)
                    {
                        isExist = lay.pModels.ContainsKey(zid);
                        if (isExist)
                        {
                            MyBaseControls.StatusBarTool.StatusBarTool.reportInfo.showInfo("存在相同ID的对象,只创建第一个对象,请检查数据来源!", 30);
                            MyBaseControls.LogTool.Log.addLog(string.Format("{1}存在相同ID的对象,只创建第一个对象,请检查数据来源。({0})", this, this.key), MyBaseControls.LogTool.ELogType.告警);
                            break;
                        }
                    }
                    if (!isExist)  //没有同ID对象,才创建
                    {
                        obj         = createDNObject(player);
                        obj.DBOPKey = key;
                        loadKeyAcnt(dr, obj);
                        player.AddObject(obj);
                        result.Add(obj);
                    }
                }
                loadExTopo(result); //载入扩展拓扑
            }
            return(result);
        }
Esempio n. 2
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     distnet.scene.EditObjectSelected += new EventHandler <Earth.PickEventArgs>(scene_EditObjectSelected);
     distnet.scene.EditObjectMove     += new EventHandler <Earth.PickEventArgs>(scene_EditObjectMove);
     elayer = distnet.addLayer("编辑图层");
 }