Beispiel #1
0
 internal SubFunctionKey CreateParser(FunctionItem parent)
 {
     Parser = Tk55Parser.Create(parent, this);
     if (Parser != null)
     {
         return(new SubFunctionKey(Parser.Style, Parser.Source));
     }
     return(null);
 }
Beispiel #2
0
        private void SetDataSet(object userId)
        {
            fDataSet = new DataSet {
                Locale = CultureInfo.CurrentCulture
            };
            TkDbContext context = DbContextUtil.CreateDefault();

            using (context)
            {
                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, "USER_ID", TkDataType.String, userId);
                fAdmin = DbUtil.ExecuteScalar("SELECT USER_ADMIN FROM UR_USERS", context, builder).ToString() == "1";
                SqlSelector selector = new SqlSelector(context, fDataSet);
                using (selector)
                {
                    string userIdName = context.GetSqlParamName("USER_ID");
                    string sql        = string.Format(ObjectUtil.SysCulture, FUNC_SQL, userIdName,
                                                      context.ContextConfig.GetFunction("LENGTH", "FN_TREE_LAYER"));
                    selector.Select("SYS_FUNCTION", sql, builder.Parameters);

                    Dictionary <int, FunctionItem> idFunctions = new Dictionary <int, FunctionItem>();

                    DataTable table = fDataSet.Tables["SYS_FUNCTION"];
                    foreach (DataRow row in table.Rows)
                    {
                        FunctionItem item = new FunctionItem(row);
                        if (item.IsLeaf)
                        {
                            try
                            {
                                idFunctions.Add(item.Id, item);
                                fFunctions.Add(item.Key, item);
                            }
                            catch
                            {
                            }
                        }
                    }

                    sql = string.Format(ObjectUtil.SysCulture, SUB_FUNC_SQL, userIdName);
                    selector.Select("SYS_SUB_FUNC", sql, builder.Parameters);
                    table = fDataSet.Tables["SYS_SUB_FUNC"];
                    var group = from item in table.AsEnumerable()
                                group item by item.Field <int>("FnId");

                    foreach (var groupItem in group)
                    {
                        FunctionItem item;
                        if (idFunctions.TryGetValue(groupItem.Key, out item))
                        {
                            item.AddSubFunctions(groupItem);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public IEnumerable <OperatorConfig> GetSubOperators(OperatorPage page, string functionKey)
        {
            if (string.IsNullOrEmpty(functionKey))
            {
                return(null);
            }

            FunctionItem item = ObjectUtil.TryGetValue(fFunctions, functionKey);

            if (item == null)
            {
                return(null);
            }

            return(item.GetOperators(page));
        }
Beispiel #4
0
 internal static Tk55Parser Create(FunctionItem function, SubFuncClass subFunc)
 {
     if (string.IsNullOrEmpty(subFunc.Content))
     {
         if (function.Parser == null)
         {
             return(null);
         }
         IPageStyle style = subFunc.NameId.Value <PageStyleClass>();
         return(new Tk55Parser(function.Parser.Parser, function.Parser.ModuleCreator,
                               style, function.Parser.Source));
     }
     else
     {
         return(Parse(subFunc.Content));
     }
 }
        private void SetDataSet(object userId)
        {
            fDataSet = new DataSet { Locale = CultureInfo.CurrentCulture };
            TkDbContext context = DbContextUtil.CreateDefault();
            using (context)
            {

                IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, "USER_ID", TkDataType.String, userId);
                fAdmin = DbUtil.ExecuteScalar("SELECT USER_ADMIN FROM UR_USERS", context, builder).ToString() == "1";
                SqlSelector selector = new SqlSelector(context, fDataSet);
                using (selector)
                {
                    string userIdName = context.GetSqlParamName("USER_ID");
                    string sql = string.Format(ObjectUtil.SysCulture, FUNC_SQL, userIdName,
                        context.ContextConfig.GetFunction("LENGTH", "FN_TREE_LAYER"));
                    selector.Select("SYS_FUNCTION", sql, builder.Parameters);

                    Dictionary<int, FunctionItem> idFunctions = new Dictionary<int, FunctionItem>();

                    DataTable table = fDataSet.Tables["SYS_FUNCTION"];
                    foreach (DataRow row in table.Rows)
                    {
                        FunctionItem item = new FunctionItem(row);
                        if (item.IsLeaf)
                        {
                            try
                            {
                                idFunctions.Add(item.Id, item);
                                fFunctions.Add(item.Key, item);
                            }
                            catch
                            {
                            }
                        }
                    }

                    sql = string.Format(ObjectUtil.SysCulture, SUB_FUNC_SQL, userIdName);
                    selector.Select("SYS_SUB_FUNC", sql, builder.Parameters);
                    table = fDataSet.Tables["SYS_SUB_FUNC"];
                    var group = from item in table.AsEnumerable()
                                group item by item.Field<int>("SF_FN_ID");
                    foreach (var groupItem in group)
                    {
                        FunctionItem item;
                        if (idFunctions.TryGetValue(groupItem.Key, out item))
                            item.AddSubFunctions(groupItem);
                    }
                }
            }
        }