Пример #1
0
 /// <summary>
 /// 根据业务对象ID获取指定BO的父节点、下级节点、兄弟节点、相邻节点(父节点、兄弟节点和下级节点)和子树。返回的节点中不包括自己
 /// </summary>
 /// <param name="template">树模板</param>
 /// <returns></returns>
 public TreeBOCollection GetBOTree(BOTreeTemplate template)
 {
     return(ObjectCreate <BOCollection> .CreateIBO("BOBusiness").GetBOTree(template));;
 }
Пример #2
0
        /// <summary>
        /// 根据业务对象ID获取指定BO的父节点、下级节点、兄弟节点、相邻节点(父节点、兄弟节点和下级节点)和子树。返回的节点中不包括自己
        /// </summary>
        /// <param name="template">树模板</param>
        /// <returns></returns>
        public TreeBOCollection GetBOTree(BOTreeTemplate template)
        {
            TreeBOCollection list = new TreeBOCollection();

            foreach (var item in template)
            {
                string strBos = string.Empty;
                TreeBO treeBo = new TreeBO();
                if (item.BOs != null && item.BOs.Count() > 0)
                {
                    for (int i = 0; i < item.BOs.Count(); i++)
                    {
                        if (i == item.BOs.Count() - 1)
                        {
                            strBos += "'" + item.BOs[i].Trim() + "'";
                        }
                        else
                        {
                            strBos += "'" + item.BOs[i].Trim() + "',";
                        }
                    }
                }
                StringBuilder  strSql = new StringBuilder();
                SqlParameter[] parameters;
                strSql.Append(" SELECT T.BOID, T1.BOT, T.NAME, '' AS ParentBOID ");
                strSql.Append(" FROM BO T, OBJECTTYPE T1 ");

                //过滤条件
                #region
                if (!string.IsNullOrEmpty(item.Filter))
                {
                    strSql.Append(" ,PROPERTY PROPERTY  ");
                    strSql.Append(" WHERE PROPERTY.BOID = T.BOID ");
                    strSql.Append(" AND " + "(" + MongoJsonToSql.JsonToSql(item.Filter, item.BOT).ToString() + ")");
                    strSql.Append(" AND T.BOTID = T1.BOTID ");
                }
                else
                {
                    strSql.Append(" WHERE T.BOTID = T1.BOTID ");
                }
                #endregion
                if (item.BOs != null && item.BOs.Count() > 0)
                {
                    strSql.Append(string.Format(" AND T.NAME IN({0}) ", strBos));
                    strSql.Append(" AND T1.BOT =@BOT ");
                }
                else
                {
                    strSql.Append(" AND T1.BOT =@BOT ");
                }
                parameters = new SqlParameter[] {
                    new SqlParameter("BOT", SqlDbType.VarChar, 100)
                };
                parameters[0].Value = item.BOT;

                List <TreeBO> treeBOList = new List <TreeBO>();
                //父节点
                treeBOList = SqlServerDBHelper.ExecuteQueryText <TreeBO>(strSql.ToString(), parameters);
                list.AddRange(treeBOList);

                if (item.Children != null)
                {
                    foreach (BOTreeNodeTemplate nodeTemplate in item.Children)
                    {
                        list.AddRange(GetTreeBONode(nodeTemplate, treeBOList, item.Relation));
                    }
                }
            }
            return(list);
        }