Ejemplo n.º 1
0
 /// <summary>
 /// 根据数据库类型名称和数据库名称,在工程树图中获取节点
 /// </summary>
 /// <param name="sDBtype">数据库类型</param>
 /// <param name="sDBName">数据库名称</param>
 /// <param name="ex">输出:错误信息</param>
 /// <returns>AdvTree.Node</returns>
 public static DevComponents.AdvTree.Node GetProjectNode(string sDBtype, string sDBName, out Exception ex)
 {
     ex = null;
     DevComponents.AdvTree.Node           DBTypeNode    = null;
     DevComponents.AdvTree.Node           DBProjectNode = null;
     DevComponents.AdvTree.NodeCollection rootnodes     = ModuleData.v_AppDBIntegra.ProjectTree.Nodes;
     //////////获取数据库类型的节点////////
     if (rootnodes == null)
     {
         ex = new Exception("工程树获取节点失败");
         return(null);
     }
     for (int i = 0; i < rootnodes.Count; i++)
     {
         DevComponents.AdvTree.Node getnode = rootnodes[i];
         if (getnode.Text == "数据库管理工具")
         {
             DevComponents.AdvTree.NodeCollection DesNodes = getnode.Nodes;
             if (DesNodes == null)
             {
                 ex = new Exception("工程树获取节点失败"); return(null);
             }
             for (int j = 0; j < DesNodes.Count; j++)
             {
                 if (DesNodes[j].Text == sDBtype)
                 {
                     DBTypeNode = DesNodes[j];
                     break;
                 }
             }
         }
     }
     //////////获取数据库工程的节点///////
     if (DBTypeNode == null)
     {
         ex = new Exception("获取数据库类型节点失败"); return(null);
     }
     for (int i = 0; i < DBTypeNode.Nodes.Count; i++)
     {
         DevComponents.AdvTree.Node getnode = DBTypeNode.Nodes[i];
         if (getnode.Text == sDBName)
         {
             DBProjectNode = getnode;
             break;
         }
     }
     if (DBProjectNode == null)
     {
         ex = new Exception("找不到名称为:" + sDBName + " 的数据库节点");
         return(null);
     }
     else
     {
         return(DBProjectNode);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Æ´½Ó¸½ÊôÕï¶ÏµÄ×Ö·û´®
 /// </summary>
 /// <param name="strv"></param>
 private void SrtChildDiagnosis(ref string strv, DevComponents.AdvTree.NodeCollection nodes, string kg)
 {
     for (int i = 0; i < nodes.Count; i++)
     {
         strv = strv + "\n" + kg + nodes[i].Text;
         if (nodes[i].Nodes.Count > 0)
         {
             SrtChildDiagnosis(ref strv, nodes[i].Nodes, kg + "  ");
         }
     }
 }
Ejemplo n.º 3
0
 private bool createNode(string idname)
 {
     if (idname == "")
     {
         return(false);
     }
     if (idname.Split(' ').Length == 1)
     {
         DevComponents.AdvTree.Node addnode = new DevComponents.AdvTree.Node();
         addnode.Text = idname;
         advTree1.Nodes.Add(addnode);
     }
     else
     {
         string id = idname.Split(' ')[0];
         DevComponents.AdvTree.NodeCollection nodes = null;
         DevComponents.AdvTree.Node           node  = null;
         if (id.Split('.').Length == 1)
         {
             nodes = advTree1.Nodes;
         }
         else
         {
             int i = 0;
             foreach (string num in id.Split('.'))
             {
                 if (i == 0)
                 {
                     node = advTree1.Nodes[advTree1.Nodes.Count - 1];
                 }
                 else if (i == id.Split('.').Length - 1)
                 {
                     nodes = node.Nodes;
                 }
                 else
                 {
                     node = node.Nodes[node.Nodes.Count - 1];
                 }
                 i++;
             }
         }
         DevComponents.AdvTree.Node addnode = new DevComponents.AdvTree.Node();
         addnode.Text = idname;
         nodes.Add(addnode);
     }
     return(false);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 树图中获取数据库所属的父节点  cyf  20110614 :modify
        /// </summary>
        /// <param name="sDBType">数据库类型</param>
        /// <param name="ex">输出:错误信息</param>
        /// <returns></returns>
        private DevComponents.AdvTree.Node getDbTreeNode(string sDBType, out Exception ex)
        {
            ex = null;
            string NodeName = string.Empty;

            //cyf 20110614 modify:
            NodeName = sDBType;
            //if (sDBType==enumInterDBType.成果文件数据库.ToString()) NodeName=enumInterDBType.成果文件数据库.ToString();//"添加文件成果数据库";
            //else if (sDBType == enumInterDBType.地理编码数据库.ToString()) NodeName =enumInterDBType.地理编码数据库.ToString();// "添加地理编码数据库";
            //else if (sDBType == enumInterDBType.地名数据库.ToString()) NodeName =enumInterDBType.地名数据库.ToString();// "添加地名数据库";
            //else if (sDBType == enumInterDBType.高程数据库.ToString()) NodeName =enumInterDBType.高程数据库.ToString();// "添加高程数据库";
            //else if (sDBType == enumInterDBType.框架要素数据库.ToString()) NodeName = enumInterDBType.框架要素数据库.ToString();//"添加框架要素数据库";
            //else if (sDBType == enumInterDBType.影像数据库.ToString()) NodeName = enumInterDBType.影像数据库.ToString();//"添加影像数据库";
            //else
            //{
            //    ex = new Exception("不支持的数据库类型");
            //    return null;
            //}
            //end
            ////////在工程树中找到这个节点//////
            DevComponents.AdvTree.NodeCollection rootnodes = ModuleData.v_AppDBIntegra.ProjectTree.Nodes;
            if (rootnodes == null)
            {
                ex = new Exception("工程树获取节点失败");
                return(null);
            }
            for (int i = 0; i < rootnodes.Count; i++)
            {
                DevComponents.AdvTree.Node getnode = rootnodes[i];
                if (getnode.Text == "数据库管理工具")
                {
                    DevComponents.AdvTree.NodeCollection DesNodes = getnode.Nodes;
                    if (DesNodes == null)
                    {
                        ex = new Exception("工程树获取节点失败"); return(null);
                    }
                    for (int j = 0; j < DesNodes.Count; j++)
                    {
                        if (DesNodes[j].Text == NodeName)
                        {
                            return(DesNodes[j]);
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
 private void FindDiff(ref List <string> addRoleID, DevComponents.AdvTree.NodeCollection aNode)
 {
     foreach (DevComponents.AdvTree.Node node in aNode)
     {
         if (node.Tag.ToString() == "")//顶节点
         {
             continue;
         }
         if (node.Checked)
         {
             addRoleID.Add(node.Tag.ToString());
         }
         if (node.Nodes.Count > 0)
         {
             FindDiff(ref addRoleID, node.Nodes);
         }
     }
 }
Ejemplo n.º 6
0
 private DevComponents.AdvTree.Node DoFindNode(DevComponents.AdvTree.NodeCollection nodes, decimal id)
 {
     foreach (DevComponents.AdvTree.Node item in nodes)
     {
         var dept = (Maticsoft.Model.SMT_ORG_INFO)item.Tag;
         if (dept.ID == id)
         {
             return(item);
         }
         else
         {
             var nn = DoFindNode(item.Nodes, id);
             if (nn != null)
             {
                 return(nn);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
 private DevComponents.AdvTree.Node DoFindNode(DevComponents.AdvTree.NodeCollection nodes, decimal id)
 {
     foreach (DevComponents.AdvTree.Node item in nodes)
     {
         var area = item.Tag as Maticsoft.Model.SMT_CONTROLLER_ZONE;
         if (area != null && area.ID == id)
         {
             return(item);
         }
         else
         {
             var nn = DoFindNode(item.Nodes, id);
             if (nn != null)
             {
                 return(nn);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 8
0
        //创建树图节点
        private DevComponents.AdvTree.Node CreateAdvTreeNode(DevComponents.AdvTree.NodeCollection nodeCol, string strText, string strName, Image pImage, bool bExpand)
        {
            DevComponents.AdvTree.Node node = new DevComponents.AdvTree.Node();
            node.Text  = strText;
            node.Image = pImage;
            if (strName != null)
            {
                node.Name = strName;
            }

            if (bExpand == true)
            {
                node.Expand();
            }
            //添加树图列节点
            DevComponents.AdvTree.Cell aCell = new DevComponents.AdvTree.Cell();
            aCell.Images.Image = null;
            node.Cells.Add(aCell);
            nodeCol.Add(node);
            return(node);
        }
Ejemplo n.º 9
0
 //根据权限iD树形树打勾
 private void isChecked(List <string> listID, DevComponents.AdvTree.NodeCollection aNode)
 {
     foreach (DevComponents.AdvTree.Node node in aNode)
     {
         if (node.Tag.ToString() == "")//顶节点
         {
             continue;
         }
         if (listID.Contains(node.Tag.ToString()))
         {
             node.Checked = true;
         }
         else
         {
             node.Checked = false;
         }
         if (node.Nodes.Count > 0)
         {
             isChecked(listID, node.Nodes);
         }
     }
 }
Ejemplo n.º 10
0
 private DevComponents.AdvTree.Node SelectNode(List <string> selectPath, int level, DevComponents.AdvTree.NodeCollection nodeCollection)
 {
     foreach (var item in nodeCollection)
     {
         if (item is DevComponents.AdvTree.Node)
         {
             var node = (DevComponents.AdvTree.Node)item;
             if (node.Text == selectPath[level])
             {
                 if (selectPath.Count - 1 == level)
                 {
                     return(node);
                 }
                 else
                 {
                     var childNode = SelectNode(selectPath, level + 1, node.Nodes);
                     if (childNode == null)
                     {
                         return(node);
                     }
                     else
                     {
                         return(childNode);
                     }
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// cyf 20110602 modify:刷新界面主函数  ,刷新数据库工程节点,刷新xml配置文件,刷新combobox列表
        /// </summary>
        /// <param name="lDBid">数据库ID</param>
        /// <param name="lDBTypeID">数据库类型ID</param>
        /// <param name="lDBFormatID">数据库平台ID</param>
        /// <param name="DNStateID">数据库状态ID</param>
        /// <param name="sDBName">数据库名称</param>
        /// <param name="sDbConnetInfo">数据库连接信息</param>
        /// <param name="lScale">比例尺 cyf 20110623 比例尺字段类型变成字符串类型</param>
        /// <param name="ProjectNode">输出:刷新后的数据库工程树节点</param>
        /// <param name="ex">输出:错误信息</param>
        private void RefurbishFrm(long lDBid, long lDBTypeID, long lDBFormatID, long DNStateID, string sDBName, string sDbConnetInfo, string lScale, string pParaDB, out DevComponents.AdvTree.Node ProjectNode, out Exception ex)
        {
            ex          = null;
            ProjectNode = null;
            /////////获取数据库类型、平台、状态文本//////
            string    sDBType   = string.Empty;
            string    sDBFormat = string.Empty;
            string    sDBState  = string.Empty;
            string    sDbpara   = string.Empty;
            string    sql       = string.Empty;
            IQueryDef pQueryDes = (ModuleData.TempWks as IFeatureWorkspace).CreateQueryDef();

            try
            {
                //cyf 20110602
                ////数据库类型
                pQueryDes.Tables      = "DATABASETYPEMD";
                pQueryDes.SubFields   = "DATABASETYPE";
                pQueryDes.WhereClause = "ID=" + lDBTypeID.ToString();
                ICursor pCursor = null;
                pCursor = pQueryDes.Evaluate();
                if (pCursor == null)
                {
                    return;
                }
                IRow pRow = pCursor.NextRow();
                if (pRow != null)
                {
                    sDBType = pRow.get_Value(0).ToString().Trim();
                }

                //sql = "SELECT DATABASETYPE  FROM DATABASETYPEMD WHERE ID=" + lDBTypeID.ToString();
                //DataTable gettable = this.m_DBOper.GetSQLTable(sql, out ex);
                //sDBType = gettable.Rows[0][0].ToString().Trim();
                //end

                //cyf 20110602
                ////数据库平台
                pQueryDes.Tables      = "DATABASEFORMATMD";
                pQueryDes.SubFields   = "DATABASEFORMAT";
                pQueryDes.WhereClause = "ID=" + lDBFormatID.ToString();
                pCursor = pQueryDes.Evaluate();
                if (pCursor == null)
                {
                    return;
                }
                pRow = pCursor.NextRow();
                if (pRow != null)
                {
                    sDBFormat = pRow.get_Value(0).ToString().Trim();
                }
                //sql = "SELECT DATABASEFORMAT  FROM DATABASEFORMATMD WHERE ID=" + lDBFormatID.ToString();
                //gettable = this.m_DBOper.GetSQLTable(sql, out ex);
                //sDBFormat = gettable.Rows[0][0].ToString().Trim();
                //end

                //cyf 20110602
                ////数据库状态
                pQueryDes.Tables      = "DATABASESTATEMD";
                pQueryDes.SubFields   = "DATABASESTATE";
                pQueryDes.WhereClause = "ID=" + DNStateID.ToString();
                pCursor = pQueryDes.Evaluate();
                if (pCursor == null)
                {
                    return;
                }
                pRow = pCursor.NextRow();
                if (pRow != null)
                {
                    sDBState = pRow.get_Value(0).ToString().Trim();
                }
                //sql = "SELECT DATABASESTATE  FROM DATABASESTATEMD WHERE ID=" + DNStateID.ToString();
                //gettable = this.m_DBOper.GetSQLTable(sql, out ex);
                //sDBState = gettable.Rows[0][0].ToString().Trim();
                //end

                //cyf 20110602
                ////数据库参数
                pQueryDes.Tables      = "DATABASEMD";
                pQueryDes.SubFields   = "DBPARA";
                pQueryDes.WhereClause = "ID=" + lDBid.ToString();
                pCursor = pQueryDes.Evaluate();
                if (pCursor == null)
                {
                    return;
                }
                pRow = pCursor.NextRow();
                if (pRow != null)
                {
                    sDbpara = pRow.get_Value(0).ToString().Trim();
                }
                //sql = "SELECT DBPARA FROM DATABASEMD WHERE ID=" + lDBid.ToString();
                //gettable = this.m_DBOper.GetSQLTable(sql, out ex);
                //sDbpara = gettable.Rows[0][0].ToString().Trim();
                //end
            }
            catch
            {
                sDBType   = "";
                sDBFormat = "";
                sDBState  = "";
                sDbpara   = "";
            }
            /////////将信息更新到界面上//////
            DevComponents.AdvTree.Node CtrlDBTreeNode = null;
            CtrlDBTreeNode = getDbTreeNode(sDBType, out ex);
            //cyf 20110614 add
            if (CtrlDBTreeNode == null)
            {
                ex = new Exception("工程树获取节点失败,\n请检查在系统维护库中是否定义该类型的数据库");
                return;
            }
            //end
            //////更新树节点///////
            DevComponents.AdvTree.Node DbNode = null;  //cyf 20110614 数据库工程根节点 modify
            //获取数据库工程根节点
            DevComponents.AdvTree.NodeCollection nodes = CtrlDBTreeNode.Nodes;
            if (nodes == null)
            {
                return;
            }
            else
            {
                for (int i = 0; i < nodes.Count; i++)
                {
                    DevComponents.AdvTree.Node getNode = nodes[i];
                    if (getNode.Text == sDBName)
                    {
                        DbNode = getNode;
                        break;
                    }
                }
            }

            /////////////////////构建挂接信息//////////////////
            XmlDocument  XmlDoc      = new XmlDocument();
            XmlNode      XmlInfoNode = XmlDoc.CreateNode(XmlNodeType.Element, "数据库信息", null);
            XmlAttribute addAttr     = null;

            ////
            addAttr       = XmlDoc.CreateAttribute("数据库工程名");
            addAttr.Value = sDBName;
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库ID");
            addAttr.Value = lDBid.ToString();
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库连接信息");
            addAttr.Value = sDbConnetInfo;
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////cyf 20110628
            addAttr       = XmlDoc.CreateAttribute("数据库平台ID");
            addAttr.Value = lDBFormatID.ToString();
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库状态ID");
            addAttr.Value = DNStateID.ToString();
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库类型ID");
            addAttr.Value = lDBTypeID.ToString();
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            //end
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库平台");
            addAttr.Value = sDBFormat;
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库状态");
            addAttr.Value = sDBState;
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库类型");
            addAttr.Value = sDBType;
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr = XmlDoc.CreateAttribute("比例尺");
            //cyf 20110623 modify
            //string strScale = "";
            //if (lScale != "")
            //{
            //    strScale = lScale.ToString();
            //}
            addAttr.Value = lScale.ToString();
            //end
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            ////
            addAttr       = XmlDoc.CreateAttribute("数据库参数");
            addAttr.Value = sDbpara;
            XmlInfoNode.Attributes.SetNamedItem(addAttr);
            /////////////////////////////////////////////////////
            if (DbNode == null)/////没有则插入新的节点
            {
                DbNode         = new DevComponents.AdvTree.Node();
                DbNode.Text    = sDBName;////数据库名称
                DbNode.Tag     = XmlInfoNode as XmlElement;
                DbNode.DataKey = lDBid;
                DbNode.Image   = ModuleData.v_AppDBIntegra.ProjectTree.ImageList.Images[2]; //cyf 20110711 添加图标
                CtrlDBTreeNode.Nodes.Add(DbNode);
            }
            else//////有则更新
            {
                DbNode.Text    = sDBName;////数据库名称
                DbNode.Tag     = XmlInfoNode as XmlElement;
                DbNode.DataKey = lDBid;
            }
            ProjectNode = DbNode;
            ///////////////////////////刷新combox//////////////
            // UpDataComBox(sDBType, out ex);

            //cyf 20110624 delete:没有必要刷新xml,进入子系统时会自动读取数据库刷新xml;
            //刷新子系统xml  陈亚飞添加 20101009
            //ModDBOperate.RefeshXml(lDBTypeID, lDBid.ToString(), sDBName, lScale, sDBFormat, sDbConnetInfo, pParaDB, out ex);
            //if (ex != null)
            //{
            //    return;
            //}
            //end
            /////////////////刷新按钮////////////////
            //cyf 20110614 modify
            XmlElement DBConnectInfo = null;// GetDBConInfoEle(lDBTypeID, lDBid);   //cyf 20110627 从xml获取连接信息,并将其瓜子啊树节点上

            UpDataButton(lDBid, sDBName, lDBTypeID, lDBFormatID, sDBType, sDBFormat, XmlInfoNode as XmlElement, DBConnectInfo);
        }