public static FunctionTree BuildFunctionTree(Guid userId,Language language)
        {
            FunctionTree tree = new FunctionTree();
            using (SqlConnection sqlConnection = DataAccess.GetSqlConnection())
            {
                SqlCommand command = sqlConnection.CreateCommand();
                command.CommandText = "[dbo].[FunctionTree_GetData]";
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("@userId", userId));
                command.Parameters.Add(new SqlParameter("@language", language.ToString()));
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Category category = new Category();
                    category.CategoryType = (ModuleCategoryType)reader.GetValue(0);
                    category.CategoryDescription = reader.GetValue(1).ToString();
                    tree.Categories.Add(category);

                }
                reader.NextResult();
                while (reader.Read())
                {
                    Module module = new Module();
                    module.Type = (ModuleType)reader.GetValue(0);
                    module.ModuleDescription = reader.GetValue(1).ToString();
                    module.Category = (ModuleCategoryType)reader.GetValue(2);
                    tree.Modules.Add(module);
                }
            }
            return tree;
        }
 public static FunctionTree BuildFunctionTree(Guid userId, Language language)
 {
     FunctionTree tree = new FunctionTree();
     try
     {
         using (SqlConnection sqlConnection = DataAccess.GetInstance().GetSqlConnection())
         {
             SqlCommand command = sqlConnection.CreateCommand();
             command.CommandText = "[dbo].[FunctionTree_GetData]";
             command.CommandType = System.Data.CommandType.StoredProcedure;
             command.Parameters.Add(new SqlParameter("@userId", userId));
             command.Parameters.Add(new SqlParameter("@language", language.ToString()));
             SqlDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 Category category = new Category();
                 category.CategoryType = (ModuleCategoryType)Enum.Parse(typeof(ModuleCategoryType), reader["CategoryCode"].ToString());
                 category.CategoryDescription = reader["Description"].ToString();
                 tree.Categories.Add(category);
             }
             reader.NextResult();
             while (reader.Read())
             {
                 Module module = new Module();
                 module.Type = (ModuleType)Enum.Parse(typeof(ModuleType), reader["ModuleCode"].ToString());
                 module.ModuleDescription = reader["Description"].ToString();
                 module.Category = (ModuleCategoryType)Enum.Parse(typeof(ModuleCategoryType), reader["parentCode"].ToString());
                 tree.Modules.Add(module);
             }
         }
         return tree;
     }
     catch (Exception ex)
     {
         Logger.AddEvent(TraceEventType.Error, "UserDataAccess.BuildFunctionTree error:\r\n{0}", ex.ToString());
         return tree;
     }
 }