Ejemplo n.º 1
0
 protected WeakDistributedCache(IDistributedCache distributedCache)
     : base(distributedCache)
 {
     fCacheTable = new ConcurrentDictionary <string, WeakReference <DistributeData> >();
     TkDebug.ThrowIfNoGlobalVariable();
     fLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
 }
Ejemplo n.º 2
0
        private Expression(string expressionString)
        {
            TkDebug.AssertArgumentNullOrEmpty(expressionString, "expressionString", null);

            fParser = ExpressionParser.ParseExpression(expressionString);
            TkDebug.ThrowIfNoGlobalVariable();
            PlugInFactoryManager factories    = BaseGlobalVariable.Current.FactoryManager;
            BasePlugInFactory    paramFactory = factories.GetCodeFactory(
                ParamExpressionPlugInFactory.REG_NAME);
            BasePlugInFactory exprFactory = factories.GetCodeFactory(
                ExpressionPlugInFactory.REG_NAME);

            fExpressions = new List <BaseExpressionItem>();

            foreach (string item in fParser.ParamArray)
            {
                string             firstChar = item[0].ToString();
                BaseExpressionItem expressionItem;
                if (paramFactory.Contains(firstChar))
                {
                    IParamExpression expression = paramFactory.CreateInstance <IParamExpression>(firstChar);
                    string           parameter  = item.Substring(1);
                    expressionItem = new ParamExpressionItem(expression, parameter);
                }
                else
                {
                    IExpression expression = exprFactory.CreateInstance <IExpression>(item);
                    expressionItem = new ExpressionItem(expression, item);
                }
                fExpressions.Add(expressionItem);
            }
        }
Ejemplo n.º 3
0
        public static ISearch CreateSearch(string regName, bool throwIfNoRegName)
        {
            if (!throwIfNoRegName && string.IsNullOrEmpty(regName))
            {
                return(null);
            }

            TkDebug.AssertArgumentNullOrEmpty(regName, "regName", null);

            try
            {
                TkDebug.ThrowIfNoGlobalVariable();
                return(PlugInFactoryManager.CreateInstance <ISearch>(REG_NAME, regName));
            }
            catch (Exception ex)
            {
                if (throwIfNoRegName)
                {
                    throw ex;
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 4
0
        protected virtual IParamBuilder CreateAdditionCondition(TkDbContext context, IFieldInfoIndexer indexer)
        {
            TkDebug.AssertArgumentNull(context, "context", this);
            TkDebug.AssertArgumentNull(indexer, "indexer", this);

            ParamBuilderContainer result = new ParamBuilderContainer();

            if (FilterSql != null)
            {
                string sql = Expression.Execute(FilterSql, context, indexer);
                result.Add(sql);
            }
            if (DataRight != null)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                IUserInfo     userInfo = BaseGlobalVariable.Current.UserInfo;
                IParamBuilder builder  = DataRight.GetListSql(new ListDataRightEventArgs(context, userInfo, indexer));
                result.Add(builder);
            }
            if (ActiveData != null)
            {
                IParamBuilder builder = ActiveData.CreateParamBuilder(context, indexer);
                result.Add(builder);
            }
            if (result.IsEmpty)
            {
                return(null);
            }
            return(result);
        }
Ejemplo n.º 5
0
        protected virtual void CheckDataRight(IInputData input, DataRow row)
        {
            TkDebug.ThrowIfNoGlobalVariable();
            var args = new DataRightEventArgs(Context, BaseGlobalVariable.Current.UserInfo,
                                              MainResolver, input.Style, row);

            DataRight.Check(args);
        }
Ejemplo n.º 6
0
        internal PlugInManagerData()
        {
            TkDebug.ThrowIfNoGlobalVariable();
            PlugInFactoryManager manager = BaseGlobalVariable.Current.FactoryManager;

            CodeFactories = CreateList(manager.CodeFactories);
            XmlConfigs    = CreateList(manager.XmlConfigs);
        }
Ejemplo n.º 7
0
        public void AppStarted(object application, BaseAppSetting appsetting, BaseGlobalVariable globalVariable)
        {
            TkDebug.ThrowIfNoGlobalVariable();
            EvaluateAdditionPlugInFactory factory = BaseGlobalVariable.Current.FactoryManager.GetCodeFactory(
                EvaluateAdditionPlugInFactory.REG_NAME).Convert <EvaluateAdditionPlugInFactory>();

            factory.Initialize();
        }
Ejemplo n.º 8
0
        public static string GetSimpleDefaultValue(string keyName)
        {
            TkDebug.AssertArgumentNullOrEmpty(keyName, nameof(keyName), null);

            TkDebug.ThrowIfNoGlobalVariable();

            return(BaseGlobalVariable.Current.DefaultValue.GetSimpleDefaultValue(keyName));
        }
Ejemplo n.º 9
0
        private static object InternalReadConfig(string sectionName)
        {
            TkDebug.ThrowIfNoGlobalVariable();

            var result = BaseGlobalVariable.Current.Config.GetConfig(sectionName);

            return(result);
        }
Ejemplo n.º 10
0
        string IExpression.Execute()
        {
            TkDebug.ThrowIfNoGlobalVariable();

            object orgId = BaseGlobalVariable.Current.UserInfo.MainOrgId;

            return(orgId == null ? string.Empty : orgId.ToString());
        }
Ejemplo n.º 11
0
        private static int ReadDefaultBufferSize()
        {
            TkDebug.ThrowIfNoGlobalVariable();

            int buffer = BaseGlobalVariable.Current.DefaultValue.GetSimpleDefaultValue(
                "DefaultRazorBufferSize").Value <int>(DEFAULT_BUFFER_SIZE);

            return(buffer);
        }
Ejemplo n.º 12
0
        public static IModelCreator CreateModelCreator(string pageTemplate)
        {
            TkDebug.AssertArgumentNullOrEmpty(pageTemplate, "pageTemplate", null);

            TkDebug.ThrowIfNoGlobalVariable();
            PageTemplatePlugInFactory factory = BaseGlobalVariable.Current.FactoryManager
                                                .GetCodeFactory(REG_NAME).Convert <PageTemplatePlugInFactory>();
            IModelCreator creator = factory.InternalCreateModelCreator(pageTemplate);

            return(creator);
        }
Ejemplo n.º 13
0
        public static IEnumerable <OperatorConfig> SafeGetSubOperators(OperatorPage page, string functionKey)
        {
            TkDebug.ThrowIfNoGlobalVariable();
            UserFunctionRight functionRight = WebGlobalVariable.SessionGbl.AppRight.FunctionRight
                                              as UserFunctionRight;

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

            return(functionRight.GetSubOperators(page, functionKey));
        }
Ejemplo n.º 14
0
        public static IRazorEngine CreateRazorEngine(string engineName)
        {
            if (string.IsNullOrEmpty(engineName))
            {
                return(RazorUtil.ToolkitEngine);
            }

            TkDebug.ThrowIfNoGlobalVariable();
            RazorEnginePlugInFactory factory = BaseGlobalVariable.Current.FactoryManager
                                               .GetCodeFactory(REG_NAME).Convert <RazorEnginePlugInFactory>();
            IRazorEngine engine = factory.CreateInstance <IRazorEngine>(engineName);

            return(engine);
        }
Ejemplo n.º 15
0
        public static TypeTableScheme CreateTypeTableScheme(string regName)
        {
            TkDebug.AssertArgumentNullOrEmpty(regName, "regName", null);

            TkDebug.ThrowIfNoGlobalVariable();
            TypeSchemeTypeFactory factory = BaseGlobalVariable.Current.FactoryManager.
                                            GetCodeFactory(TypeSchemeTypeFactory.REG_NAME).Convert <TypeSchemeTypeFactory>();
            Type type = factory.GetType(regName);

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

            return(TypeTableScheme.Create(type));
        }
Ejemplo n.º 16
0
        public static BaseSendMessage Execute(Action <bool, string> processor, bool subscrible, string data)
        {
            TkDebug.ThrowIfNoAppSetting();
            TkDebug.ThrowIfNoGlobalVariable();

            if (BaseAppSetting.Current.UseWorkThread)
            {
                BaseGlobalVariable.Current.BeginInvoke(processor, subscrible, data);
            }
            else
            {
                processor(subscrible, data);
            }

            return(null);
        }
Ejemplo n.º 17
0
        internal void Log(ReceiveMessage message)
        {
            if (fLog != null)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                TkDebug.ThrowIfNoAppSetting();

                if (BaseAppSetting.Current.UseWorkThread)
                {
                    BaseGlobalVariable.Current.BeginInvoke(new Action <ReceiveMessage>(ExecuteLog), message);
                }
                else
                {
                    ExecuteLog(message);
                }
            }
        }
Ejemplo n.º 18
0
        public static DbContextConfig Create(string name, string sqlProvider,
                                             string dbProvider, string connectionString)
        {
            TkDebug.AssertArgumentNullOrEmpty(sqlProvider, "sqlProvider", null);
            TkDebug.AssertArgumentNullOrEmpty(dbProvider, "dbProvider", null);
            TkDebug.AssertArgumentNullOrEmpty(connectionString, "connectionString", null);

            TkDebug.ThrowIfNoGlobalVariable();

            DbContextConfig config = new DbContextConfig
            {
                Name             = name,
                SqlProvider      = sqlProvider,
                DbProvider       = dbProvider,
                ConnectionString = connectionString
            };

            return(config);
        }
Ejemplo n.º 19
0
        private IParamBuilder GetCustomParamBuilder(IParamBuilder builder)
        {
            IParamBuilder result = builder;

            if (DataRight != null)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                IUserInfo     userInfo  = BaseGlobalVariable.Current.UserInfo;
                IParamBuilder dataRight = DataRight.GetListSql(
                    new ListDataRightEventArgs(fSelector.Context, userInfo, fSelector));
                result = ParamBuilder.CreateParamBuilder(result, dataRight);
            }
            if (CustomCondition != null)
            {
                result = ParamBuilder.CreateParamBuilder(result, CustomCondition);
            }

            return(result);
        }
Ejemplo n.º 20
0
        public OutputData DoAction(IInputData input)
        {
            TkDebug.ThrowIfNoGlobalVariable();

            if (MetaDataUtil.Equals(input.Style, (PageStyleClass)"Code"))
            {
                string factoryName = input.QueryString["Name"];
                var    factory     = BaseGlobalVariable.Current.FactoryManager.GetCodeFactory(factoryName);
                return(OutputData.CreateToolkitObject(new PlugInFactoryData(factory)));
            }
            else if (MetaDataUtil.Equals(input.Style, (PageStyleClass)"Xml"))
            {
                string factoryName = input.QueryString["Name"];
                var    factory     = BaseGlobalVariable.Current.FactoryManager.GetConfigFactory(factoryName);
                return(OutputData.CreateToolkitObject(new ConfigFactoryData(factory)));
            }
            else
            {
                return(OutputData.CreateToolkitObject(new PlugInManagerData()));
            }
        }
Ejemplo n.º 21
0
        string IParamExpression.Execute(string parameter)
        {
            TkDebug.ThrowIfNoGlobalVariable();

            return(WebGlobalVariable.Request.Query[parameter]);
        }
Ejemplo n.º 22
0
        //public static void SetDefaultCacheCreator(ICacheCreator creator)
        //{
        //    TkDebug.AssertArgumentNull(creator, "creator", null);

        //    TkDebug.ThrowIfNoGlobalVariable();
        //    BaseGlobalVariable.Current.CacheManager.fDefaultCreator = creator;
        //}

        public static object GetItem(string cacheName, string key, params object[] args)
        {
            TkDebug.ThrowIfNoGlobalVariable();
            return(BaseGlobalVariable.Current.CacheManager.GetCacheItem(cacheName, key, args));
        }
Ejemplo n.º 23
0
 public static bool ContainsKey(string cacheName, string key)
 {
     TkDebug.ThrowIfNoGlobalVariable();
     return(BaseGlobalVariable.Current.CacheManager
            .Contains(cacheName, key));
 }
Ejemplo n.º 24
0
        string IExpression.Execute()
        {
            TkDebug.ThrowIfNoGlobalVariable();

            return(BaseGlobalVariable.Current.UserInfo.UserName ?? string.Empty);
        }
Ejemplo n.º 25
0
 public static void RemoveKey(string cacheName, string key)
 {
     TkDebug.ThrowIfNoGlobalVariable();
     BaseGlobalVariable.Current.CacheManager.Remove(cacheName, key);
 }
Ejemplo n.º 26
0
 public static void ClearCache(string cacheName)
 {
     TkDebug.ThrowIfNoGlobalVariable();
     BaseGlobalVariable.Current.CacheManager.Clear(cacheName);
 }
Ejemplo n.º 27
0
 public static void CleanCache()
 {
     TkDebug.ThrowIfNoGlobalVariable();
     BaseGlobalVariable.Current.CacheManager.Clean();
 }
Ejemplo n.º 28
0
        internal void WriteToken(JsonReader reader, int initialDepth)
        {
            do
            {
                switch (reader.TokenType)
                {
                case JsonToken.None:
                    // read to next
                    break;

                case JsonToken.StartObject:
                    WriteStartObject();
                    break;

                case JsonToken.StartArray:
                    WriteStartArray();
                    break;

                case JsonToken.StartConstructor:
                    string constructorName = reader.Value.ToString();
                    // write a JValue date when the constructor is for a date
                    if (string.Compare(constructorName, "Date", StringComparison.Ordinal) == 0)
                    {
                        WriteConstructorDate(reader);
                    }
                    else
                    {
                        WriteStartConstructor(reader.Value.ToString());
                    }
                    break;

                case JsonToken.PropertyName:
                    WritePropertyName(reader.Value.ToString());
                    break;

                case JsonToken.Comment:
                    WriteComment(reader.Value.ToString());
                    break;

                case JsonToken.Integer:
                    WriteValue((long)reader.Value);
                    break;

                case JsonToken.Float:
                    WriteValue((double)reader.Value);
                    break;

                case JsonToken.String:
                    WriteValue(reader.Value.ToString());
                    break;

                case JsonToken.Boolean:
                    WriteValue((bool)reader.Value);
                    break;

                case JsonToken.Null:
                    WriteNull();
                    break;

                case JsonToken.Undefined:
                    WriteUndefined();
                    break;

                case JsonToken.EndObject:
                    WriteEndObject();
                    break;

                case JsonToken.EndArray:
                    WriteEndArray();
                    break;

                case JsonToken.EndConstructor:
                    WriteEndConstructor();
                    break;

                case JsonToken.Date:
                    WriteValue((DateTime)reader.Value);
                    break;

                case JsonToken.Raw:
                    WriteRawValue((string)reader.Value);
                    break;

                case JsonToken.Bytes:
                    WriteValue((byte[])reader.Value);
                    break;

                default:
                    TkDebug.ThrowIfNoGlobalVariable();
                    break;
                }
            }while (
                initialDepth - 1 < reader.Depth - (IsEndToken(reader.TokenType) ? 1 : 0) &&
                reader.Read());
        }
Ejemplo n.º 29
0
 public SimpleCache(int capacity)
 {
     fCacheTable = new Dictionary <string, CacheData>(capacity);
     TkDebug.ThrowIfNoGlobalVariable();
     fLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);
 }