Пример #1
0
 public static int Revoke(string teacher, FuncEntry funcEntry)
 {
     using (AppBLL bll = new AppBLL())
     {
         Revoke(bll, teacher, funcEntry);
     }
     return(1);
 }
Пример #2
0
        private static void BuildChild(FuncEntry func, IList <FuncEntry> funcs)
        {
            var functions = from v in funcs where v.Parent == func.FuncID select v;

            foreach (var entry in functions)
            {
                func.Children.Add(entry);
                BuildChild(entry, funcs);
            }
        }
Пример #3
0
 private static void Revoke(AppBLL bll, string teacher, FuncEntry funcEntry)
 {
     if (funcEntry.Kind > 0)
     {
         var sql = "Delete from s_tb_rights Where TeacherID=@UserID and FuncID=@FuncID and SYSNO=2";
         bll.ExecuteNonQueryByText(sql, new { UserID = teacher, FuncID = funcEntry.FuncID });
     }
     if (funcEntry.Children.Any())
     {
         foreach (var func in funcEntry.Children)
         {
             Revoke(bll, teacher, func);
         }
     }
 }
Пример #4
0
 private static void BuildFuncTree(FuncEntry root, IList <FuncEntry> funcs)
 {
     try
     {
         var children = from v in funcs where v.Parent == root.FuncID select v;
         foreach (var child in children)
         {
             root.Children.Add(child);
             BuildFuncTree(child, funcs);
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #5
0
        public bool RunFunction(string fname, out string output)
        {
            FuncEntry fe = FindFunction(fname.ToLower());       // function names are case insensitive

            if (fe != null)
            {
                if (paras.Count < fe.numberparasmin)
                {
                    output = "Too few parameters";
                }
                else if (paras.Count > fe.numberparasmax)
                {
                    output = "Too many parameters";
                }
                else
                {
                    for (int i = 0; i < paras.Count; i++)
                    {
                        if (paras[i].isstring)
                        {
                            if (((fe.allowstringmap >> i) & 1) == 0)
                            {
                                output = "Strings are not allowed in parameter " + (i + 1).ToString(ct);
                                return(false);
                            }
                        }
                        else if (((fe.checkvarmap >> i) & 1) == 1 && !vars.Exists(paras[i].value))
                        {
                            output = "Variable " + paras[i].value + " does not exist in parameter " + (i + 1).ToString(ct);
                            return(false);
                        }
                    }

                    System.Reflection.MethodInfo mi = GetType().GetMethod(fe.fname, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    func fptr = (func)Delegate.CreateDelegate(typeof(func), this, mi);      // need a delegate which is attached to this instance..
                    return(fptr(out output));
                }
            }
            else
            {
                output = "Does not exist";
            }

            return(false);
        }
Пример #6
0
        /// <summary>
        /// 获取用户功能树(菜单)
        /// </summary>
        /// <returns></returns>
        public static FuncEntry GetUserFuncs(string teacher)
        {
            try
            {
                using (AppBLL bll = new AppBLL())
                {
                    //var sql = "select FuncId, FuncName, Description, FuncType, FuncID0 As Parent, SysNo, 1 as Kind from s_tb_FunctionNew where CAST(FuncID as Int) in ";
                    //sql += " (SELECT cast(a.FuncID as Int) FROM  tbGroupInfo b INNER JOIN tbUserGroupInfo c ON b.TeacherID = c.TeacherID INNER JOIN s_tb_Rights a ON b.GroupID = a.TeacherID ";
                    //sql += " where c.TeacherID=@teacher and a.SYSNO = 2) ";
                    //sql += " union all ";
                    //sql += " select FuncId, FuncName, Description, FuncType, FuncID0 As Parent, SysNo, 2 as Kind from s_tb_FunctionNew where CAST(FuncID as Int) in";
                    //sql += " (SELECT cast(a.FuncId as Int) from s_tb_Rights a, tbUserGroupInfo b ";
                    //sql += " where a.TeacherID=@teacher and a.TeacherID=b.TeacherID and SYSNO = 2)";

                    var sql = "select FuncId, FuncName, Description, FuncType, FuncID0 As Parent, SysNo, 2 as Kind"
                              + " from s_tb_FunctionNew "
                              + " where CAST(FuncID as Int) in ("
                              + " SELECT cast(a.FuncId as Int) from s_tb_Rights a, tbUserGroupInfo b  "
                              + " where a.TeacherID=@teacher and a.TeacherID=b.TeacherID and SYSNO = 2)";

                    //sql += " union all select FuncId, FuncName, Description, FuncType, FuncID0 As Parent, SysNo, 2 as Kind " +
                    //       " from s_tb_FunctionNew where FuncID in (1701, 1707,1801,1809)";
                    IList <FuncEntry> funcs = bll.FillListByText <FuncEntry>(sql, new { teacher = teacher });

                    var roots = from v in funcs where v.Parent == -1 select v;
                    if (!roots.Any())
                    {
                        return(null);
                    }
                    FuncEntry root = roots.First();
                    BuildFuncTree(root, funcs);
                    return(root);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #7
0
        /// <summary>
        /// 获取功能树(菜单)
        /// </summary>
        /// <returns></returns>
        public static FuncEntry GetFunc()
        {
            try
            {
                using (AppBLL bll = new AppBLL())
                {
                    var sql = "Select FuncId, FuncName, Description, FuncType, FuncID0 As Parent, SysNo from s_tb_FunctionNew order by FuncID";
                    IList <FuncEntry> funcs = bll.FillListByText <FuncEntry>(sql, null);

                    var roots = from v in funcs where v.Parent == -1 select v;
                    if (!roots.Any())
                    {
                        return(null);
                    }
                    FuncEntry root = roots.First();
                    BuildFuncTree(root, funcs);
                    return(root);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }