Example #1
0
        public static void Init()
        {
            //开启框架跟踪消息输出,建议只在测试环境启用
            TraceLogSwitchManager.EnableFrameworkTrace();

            //对象转换映射
            MapperFactory.CreateMapper();

            //数据库配置
            DbConfig.Init();

            //mvc配置
            MvcConfig.Config();

            //缓存配置
            CacheConfig.Init();
        }
Example #2
0
        /// <summary>
        /// Build command
        /// </summary>
        void BuildCommand()
        {
            //resolve records
            ResolveActivationRecord();
            bool allowTraceLog = TraceLogSwitchManager.ShouldTraceFramework();
            var  recordIds     = activationMaxRecordIds.Values.OrderBy(c => c);

            commandEngineGroups          = new Dictionary <string, Tuple <ICommandEngine, List <ICommand> > >(activationMaxRecordIds.Count);
            commandCollection            = new List <ICommand>(activationMaxRecordIds.Count);
            allowEmptyResultCommandCount = 0;
            foreach (var recordId in recordIds)
            {
                if (activationRecordValues.TryGetValue(recordId, out var record) && record != null)
                {
                    var command = record.GetExecuteCommand();
                    if (command?.IsObsolete ?? true)
                    {
                        if (allowTraceLog)
                        {
                            LogManager.LogInformation <DefaultWork>($"Execution command created based on the activity record {record.IdentityValue} are null or obsolete");
                        }
                        continue;
                    }

                    //trigger command executing event
                    var eventResult = command.TriggerStartingEvent();
                    if (!(eventResult?.AllowExecuteCommand ?? true))
                    {
                        if (allowTraceLog)
                        {
                            LogManager.LogInformation <DefaultWork>($"The execution command created by active record {record.IdentityValue} is blocked by the event handler");
                        }
                    }

                    commandCollection.Add(command);
                    if (!command.MustReturnValueOnSuccess)
                    {
                        allowEmptyResultCommandCount += 1;
                    }
                    var commandEngines = CommandExecuteManager.GetCommandEngines(command);
                    if (commandEngines.IsNullOrEmpty())
                    {
                        continue;
                    }
                    foreach (var engine in commandEngines)
                    {
                        if (engine == null)
                        {
                            continue;
                        }
                        var engineKey = engine.IdentityKey;
                        if (!commandEngineGroups.TryGetValue(engineKey, out Tuple <ICommandEngine, List <ICommand> > engineValues))
                        {
                            engineValues = new Tuple <ICommandEngine, List <ICommand> >(engine, new List <ICommand>(activationRecordValues.Count));
                        }
                        engineValues.Item2.Add(command);
                        commandEngineGroups[engineKey] = engineValues;
                    }
                }
            }
        }
Example #3
0
 static MySqlFactory()
 {
     EnableTraceLog = TraceLogSwitchManager.ShouldTraceFramework();
 }