public async Task <bool> AddAsync(ModifyLog log)
        {
            _dbContext.ModifyLogs.Add(log);
            int x = await _dbContext.SaveChangesAsync();

            return(x > 0);
        }
Esempio n. 2
0
        public async Task AddAsyncTest()
        {
            var id     = Guid.NewGuid().ToString();
            var source = new ModifyLog
            {
                Id         = id,
                ConfigId   = "123",
                Group      = "0",
                Key        = "k",
                Value      = "v",
                ModifyTime = DateTime.Now
            };

            var result = await service.AddAsync(source);

            Assert.IsTrue(result);

            var log = fsq.Select <ModifyLog>(new {
                Id = id
            }).ToOne();

            Assert.IsNotNull(log);

            Assert.AreEqual(source.Id, log.Id);
            Assert.AreEqual(source.ConfigId, log.ConfigId);
            Assert.AreEqual(source.Group, log.Group);
            Assert.AreEqual(source.Key, log.Key);
            Assert.AreEqual(source.Value, log.Value);
            //Assert.AreEqual(source.ModifyTime, log.ModifyTime);
        }
Esempio n. 3
0
        public async Task SearchTest()
        {
            fsq.Delete <ModifyLog>().Where("1=1").ExecuteAffrows();

            var id     = Guid.NewGuid().ToString();
            var source = new ModifyLog
            {
                Id         = id,
                ConfigId   = "123",
                Group      = "0",
                Key        = "k",
                Value      = "v",
                ModifyTime = DateTime.Now
            };
            var id1     = Guid.NewGuid().ToString();
            var source1 = new ModifyLog
            {
                Id         = id1,
                ConfigId   = "123",
                Group      = "0",
                Key        = "k",
                Value      = "v",
                ModifyTime = DateTime.Now
            };
            var id2     = Guid.NewGuid().ToString();
            var source2 = new ModifyLog
            {
                Id         = id2,
                ConfigId   = "1234",
                Group      = "0",
                Key        = "k",
                Value      = "v",
                ModifyTime = DateTime.Now
            };
            var result = await service.AddRangAsync(new List <ModifyLog> {
                source,
                source1,
                source2
            });

            Assert.IsTrue(result);

            var configs = await service.Search("123");

            Assert.IsNotNull(configs);

            Assert.AreEqual(2, configs.Count);
        }
Esempio n. 4
0
        //SaveChanges() ile dbcontext içerinde değişen tablolar bulunur ve değiştiği alanların ilk ve son halleri kaydedilir.
        public override int SaveChanges()
        {
            try
            {
                var modifiedUnit = ChangeTracker.Entries().Where(p => p.State == EntityState.Modified).ToList();
                var logTime      = System.DateTime.UtcNow;

                foreach (var units in modifiedUnit)
                {
                    var entityName        = units.Entity.GetType().Name;
                    var primaryKeyColName = units.OriginalValues.Properties.FirstOrDefault(prop => prop.IsPrimaryKey() == true).Name;

                    foreach (IProperty prop in units.OriginalValues.Properties)
                    {
                        var originVal = units.OriginalValues[prop.Name].ToString();
                        var currVal   = units.CurrentValues[prop.Name].ToString();

                        if (originVal != currVal)  //değişen var mı?
                        {
                            ModifyLog log = new ModifyLog()
                            {
                                EntityName           = entityName,
                                PrimaryKeyColNameVal = int.Parse(units.OriginalValues[primaryKeyColName].ToString()),
                                PropertyName         = prop.Name,
                                OriginVal            = originVal,
                                NewVal  = currVal,
                                LogDate = logTime,
                                State   = EnumLogState.Update
                            };
                            //log elasticsearh'e aktarılır.
                            ElasticSearchStrike.CheckExistsAndInsert(log);
                        }
                    }
                }
                return(base.SaveChanges());
            }
            catch (Exception ex)
            {
                var error = ex.Message;
                return(0);
            }
        }
Esempio n. 5
0
        public static void CheckExistsAndInsert(ModifyLog log)
        {
            if (!elasticClient.IndexExists("change_log").Exists)
            {
                var indexSettings = new IndexSettings();
                indexSettings.NumberOfReplicas = 1;
                indexSettings.NumberOfShards   = 3;


                var createIndexDescriptor = new CreateIndexDescriptor("modify-log-index")
                                            .Mappings(ms => ms.Map <ModifyLog>(m => m.AutoMap()))
                                            .InitializeUsing(new IndexState()
                {
                    Settings = indexSettings
                })
                                            .Aliases(a => a.Alias("change_log"));

                var response = elasticClient.CreateIndex(createIndexDescriptor);
            }
            elasticClient.Index <ModifyLog>(log, idx => idx.Index("modify-log-index"));
        }
Esempio n. 6
0
        /// <summary>
        /// 注册添加系统日志事件
        /// </summary>
        private void RegisterAddSysLog()
        {
            TinyEventBus.Instance.Regist(EventKeys.ADMIN_LOGIN_SUCCESS, (parm) =>
            {
                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"管理员登录成功"
                };
                _sysLogService.AddSysLogAsync(log);
            });

            TinyEventBus.Instance.Regist(EventKeys.INIT_ADMIN_PASSWORD_SUCCESS, (parm) =>
            {
                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"管理员密码初始化成功"
                };
                _sysLogService.AddSysLogAsync(log);
            });

            TinyEventBus.Instance.Regist(EventKeys.RESET_ADMIN_PASSWORD_SUCCESS, (parm) =>
            {
                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"修改管理员密码成功"
                };
                _sysLogService.AddSysLogAsync(log);
            });

            TinyEventBus.Instance.Regist(EventKeys.ADD_APP_SUCCESS, (param) =>
            {
                var app = param as App;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"新增应用【AppId:{app.Id}】【AppName:{app.Name}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });

            // app
            TinyEventBus.Instance.Regist(EventKeys.EDIT_APP_SUCCESS, (param) =>
            {
                var app = param as App;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"编辑应用【AppId:{app.Id}】【AppName:{app.Name}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DISABLE_OR_ENABLE_APP_SUCCESS, (param) =>
            {
                var app = param as App;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"{(app.Enabled ? "启用" : "禁用")}应用【AppId:{app.Id}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DELETE_APP_SUCCESS, (param) =>
            {
                var app = param as App;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"删除应用【AppId:{app.Id}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DELETE_APP_SUCCESS, (param) =>
            {
                var app = param as App;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"删除应用【AppId:{app.Id}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });
            //config
            TinyEventBus.Instance.Regist(EventKeys.ADD_CONFIG_SUCCESS, (param) =>
            {
                var config = param as Config;
                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"新增配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    _sysLogService.AddSysLogAsync(log);

                    _modifyLogService.AddAsync(new ModifyLog
                    {
                        Id         = Guid.NewGuid().ToString("N"),
                        ConfigId   = config.Id,
                        Key        = config.Key,
                        Group      = config.Group,
                        Value      = config.Value,
                        ModifyTime = config.CreateTime
                    });
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.EDIT_CONFIG_SUCCESS, (param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"编辑配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    _sysLogService.AddSysLogAsync(log);

                    _modifyLogService.AddAsync(new ModifyLog
                    {
                        Id         = Guid.NewGuid().ToString("N"),
                        ConfigId   = config.Id,
                        Key        = config.Key,
                        Group      = config.Group,
                        Value      = config.Value,
                        ModifyTime = config.UpdateTime.Value
                    });
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.EDIT_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;

                if (config != null)
                {
                    if (config.OnlineStatus == OnlineStatus.Online)
                    {
                        //notice clients
                        var action = new WebsocketAction
                        {
                            Action = ActionConst.Update,
                            Item   = new ConfigItem {
                                group = config.Group, key = config.Key, value = config.Value
                            },
                            OldItem = new ConfigItem {
                                group = oldConfig.Group, key = oldConfig.Key, value = oldConfig.Value
                            }
                        };
                        var nodes = await _serverNodeService.GetAllNodesAsync();
                        foreach (var node in nodes)
                        {
                            if (node.Status == NodeStatus.Offline)
                            {
                                continue;
                            }
                            await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, config.AppId, action);
                        }
                    }
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DELETE_CONFIG_SUCCESS, (param) =>
            {
                var config = param as Config;
                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"删除配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.DELETE_CONFIG_SUCCESS, async(param) =>
            {
                var config = param as Config;
                if (config != null)
                {
                    var action = await CreateRemoveWebsocketAction(config, config.AppId);
                    var nodes  = await _serverNodeService.GetAllNodesAsync();
                    foreach (var node in nodes)
                    {
                        if (node.Status == NodeStatus.Offline)
                        {
                            continue;
                        }
                        await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, config.AppId, action);
                    }
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.OFFLINE_CONFIG_SUCCESS, (param) =>
            {
                var config = param as Config;
                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"下线配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.OFFLINE_CONFIG_SUCCESS, async(param) =>
            {
                var config = param as Config;
                if (config != null)
                {
                    //notice clients the config item is offline
                    var action = new WebsocketAction {
                        Action = ActionConst.Remove, Item = new ConfigItem {
                            group = config.Group, key = config.Key, value = config.Value
                        }
                    };
                    var nodes = await _serverNodeService.GetAllNodesAsync();
                    foreach (var node in nodes)
                    {
                        if (node.Status == NodeStatus.Offline)
                        {
                            continue;
                        }
                        await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, config.AppId, action);
                    }
                }
            });


            TinyEventBus.Instance.Regist(EventKeys.PUBLISH_CONFIG_SUCCESS, (param) =>
            {
                Config config = param as Config;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"上线配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    _sysLogService.AddSysLogAsync(log);
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.PUBLISH_CONFIG_SUCCESS, async(param) =>
            {
                Config config = param as Config;

                if (config != null)
                {
                    if (config != null && config.OnlineStatus == OnlineStatus.Online)
                    {
                        //notice clients config item is published
                        var action = new WebsocketAction
                        {
                            Action = ActionConst.Add,
                            Item   = new ConfigItem {
                                group = config.Group, key = config.Key, value = config.Value
                            }
                        };
                        var nodes = await _serverNodeService.GetAllNodesAsync();
                        foreach (var node in nodes)
                        {
                            if (node.Status == NodeStatus.Offline)
                            {
                                continue;
                            }
                            await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, config.AppId, action);
                        }
                    }
                }
            });


            TinyEventBus.Instance.Regist(EventKeys.ROLLBACK_CONFIG_SUCCESS, (param) =>
            {
                dynamic param_dy    = param;
                Config config       = param_dy.config;
                ModifyLog modifyLog = param_dy.modifyLog;

                if (config != null && modifyLog != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"回滚配置【Key:{config.Key}】 【Group:{config.Group}】 【AppId:{config.AppId}】至历史记录:{modifyLog.Id}"
                    };
                    _sysLogService.AddSysLogAsync(log);

                    _modifyLogService.AddAsync(new ModifyLog
                    {
                        Id         = Guid.NewGuid().ToString("N"),
                        ConfigId   = config.Id,
                        Key        = config.Key,
                        Group      = config.Group,
                        Value      = config.Value,
                        ModifyTime = config.UpdateTime.Value
                    });
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.ROLLBACK_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;

                ModifyLog modifyLog = param_dy.modifyLog;

                if (config != null && oldConfig != null)
                {
                    if (config.OnlineStatus == OnlineStatus.Online)
                    {
                        //notice clients
                        var action = new WebsocketAction
                        {
                            Action = ActionConst.Update,
                            Item   = new ConfigItem {
                                group = config.Group, key = config.Key, value = config.Value
                            },
                            OldItem = new ConfigItem {
                                group = oldConfig.Group, key = oldConfig.Key, value = oldConfig.Value
                            }
                        };
                        var nodes = await _serverNodeService.GetAllNodesAsync();
                        foreach (var node in nodes)
                        {
                            if (node.Status == NodeStatus.Offline)
                            {
                                continue;
                            }
                            await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, config.AppId, action);
                        }
                    }
                }
            });
        }
Esempio n. 7
0
        private void RegisterWebsocketAction()
        {
            TinyEventBus.Instance.Regist(EventKeys.EDIT_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;

                if (config != null)
                {
                    if (config.OnlineStatus == OnlineStatus.Online)
                    {
                        //notice clients
                        var action = new WebsocketAction
                        {
                            Action = ActionConst.Update,
                            Item   = new ConfigItem {
                                group = config.Group, key = config.Key, value = config.Value
                            },
                            OldItem = new ConfigItem {
                                group = oldConfig.Group, key = oldConfig.Key, value = oldConfig.Value
                            }
                        };
                        using (var serverNodeService = GetServerNodeService())
                        {
                            var nodes      = await serverNodeService.GetAllNodesAsync();
                            var noticeApps = await GetNeedNoticeInheritancedFromAppsAction(config);
                            noticeApps.Add(config.AppId, action);

                            foreach (var node in nodes)
                            {
                                if (node.Status == NodeStatus.Offline)
                                {
                                    continue;
                                }
                                foreach (var kv in noticeApps)
                                {
                                    await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, kv.Key, kv.Value);
                                }
                            }
                        }
                    }
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.DELETE_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;
                if (config != null)
                {
                    var action = await CreateRemoveWebsocketAction(config, config.AppId);
                    using (var serverNodeService = GetServerNodeService())
                    {
                        var nodes      = await serverNodeService.GetAllNodesAsync();
                        var noticeApps = await GetNeedNoticeInheritancedFromAppsAction(config);
                        noticeApps.Add(config.AppId, await CreateRemoveWebsocketAction(oldConfig, config.AppId));

                        foreach (var node in nodes)
                        {
                            if (node.Status == NodeStatus.Offline)
                            {
                                continue;
                            }
                            foreach (var kv in noticeApps)
                            {
                                await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, kv.Key, kv.Value);
                            }
                        }
                    }
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.OFFLINE_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;
                if (config != null)
                {
                    //notice clients the config item is offline
                    using (var serverNodeService = GetServerNodeService())
                    {
                        var nodes      = await serverNodeService.GetAllNodesAsync();
                        var noticeApps = await GetNeedNoticeInheritancedFromAppsAction(config);
                        noticeApps.Add(config.AppId, await CreateRemoveWebsocketAction(oldConfig, config.AppId));

                        foreach (var node in nodes)
                        {
                            if (node.Status == NodeStatus.Offline)
                            {
                                continue;
                            }
                            foreach (var kv in noticeApps)
                            {
                                await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, kv.Key, kv.Value);
                            }
                        }
                    }
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.PUBLISH_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;

                if (config != null)
                {
                    if (config.OnlineStatus == OnlineStatus.Online)
                    {
                        //notice clients config item is published
                        var action = new WebsocketAction
                        {
                            Action = ActionConst.Add,
                            Item   = new ConfigItem {
                                group = config.Group, key = config.Key, value = config.Value
                            }
                        };
                        using (var serverNodeService = GetServerNodeService())
                        {
                            var nodes      = await serverNodeService.GetAllNodesAsync();
                            var noticeApps = await GetNeedNoticeInheritancedFromAppsAction(config);
                            noticeApps.Add(config.AppId, action);

                            foreach (var node in nodes)
                            {
                                if (node.Status == NodeStatus.Offline)
                                {
                                    continue;
                                }
                                foreach (var item in noticeApps)
                                {
                                    await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, item.Key, item.Value);
                                }
                            }
                        }
                    }
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.ROLLBACK_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;

                ModifyLog modifyLog = param_dy.modifyLog;

                if (config != null && oldConfig != null)
                {
                    if (config.OnlineStatus == OnlineStatus.Online)
                    {
                        //notice clients
                        var action = new WebsocketAction
                        {
                            Action = ActionConst.Update,
                            Item   = new ConfigItem {
                                group = config.Group, key = config.Key, value = config.Value
                            },
                            OldItem = new ConfigItem {
                                group = oldConfig.Group, key = oldConfig.Key, value = oldConfig.Value
                            }
                        };
                        using (var serverNodeService = GetServerNodeService())
                        {
                            var nodes      = await serverNodeService.GetAllNodesAsync();
                            var noticeApps = await GetNeedNoticeInheritancedFromAppsAction(config);
                            noticeApps.Add(config.AppId, action);

                            foreach (var node in nodes)
                            {
                                if (node.Status == NodeStatus.Offline)
                                {
                                    continue;
                                }
                                foreach (var item in noticeApps)
                                {
                                    await _remoteServerNodeProxy.AppClientsDoActionAsync(node.Address, item.Key, item.Value);
                                }
                            }
                        }
                    }
                }
            });
        }
Esempio n. 8
0
        /// <summary>
        /// 注册添加系统日志事件
        /// </summary>
        private void RegisterAddSysLog()
        {
            TinyEventBus.Instance.Regist(EventKeys.USER_LOGIN_SUCCESS, async(param) =>
            {
                dynamic param_dy = param as dynamic;
                string userName  = param_dy.userName;
                var log          = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"{userName} 登录成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.INIT_SUPERADMIN_PASSWORD_SUCCESS, async(parm) =>
            {
                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"超级管理员密码初始化成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.RESET_USER_PASSWORD_SUCCESS, async(param) =>
            {
                dynamic param_dy = param as dynamic;
                User user        = param_dy.user;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"用户 {userName} 重置 {user.UserName} 的密码为默认密码 "
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.CHANGE_USER_PASSWORD_SUCCESS, async(param) =>
            {
                dynamic param_dy = param as dynamic;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"修改用户 {userName} 的密码成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.ADD_APP_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                App app          = param_dy.app;
                string userName  = param_dy.userName;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"用户:{userName} 新增应用【AppId:{app.Id}】【AppName:{app.Name}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });

            // app
            TinyEventBus.Instance.Regist(EventKeys.EDIT_APP_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                App app          = param_dy.app;
                string userName  = param_dy.userName;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"用户:{userName} 编辑应用【AppId:{app.Id}】【AppName:{app.Name}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DISABLE_OR_ENABLE_APP_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                App app          = param_dy.app;
                string userName  = param_dy.userName;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        LogText = $"用户:{userName} {(app.Enabled ? "启用" : "禁用")}应用【AppId:{app.Id}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DELETE_APP_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                App app          = param_dy.app;
                string userName  = param_dy.userName;
                if (app != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Warn,
                        LogText = $"用户:{userName} 删除应用【AppId:{app.Id}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });

            //config
            TinyEventBus.Instance.Regist(EventKeys.ADD_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                string userName  = param_dy.userName;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"用户:{userName} 新增配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }

                    using (var modifyLogService = GetModifyLogService())
                    {
                        await modifyLogService.AddAsync(new ModifyLog
                        {
                            Id         = Guid.NewGuid().ToString("N"),
                            ConfigId   = config.Id,
                            Key        = config.Key,
                            Group      = config.Group,
                            Value      = config.Value,
                            ModifyTime = config.CreateTime
                        });
                    }
                }
            });
            TinyEventBus.Instance.Regist(EventKeys.EDIT_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                Config oldConfig = param_dy.oldConfig;
                string userName  = param_dy.userName;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"用户:{userName} 编辑配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }

                    using (var modifyLogService = GetModifyLogService())
                    {
                        await modifyLogService.AddAsync(new ModifyLog
                        {
                            Id         = Guid.NewGuid().ToString("N"),
                            ConfigId   = config.Id,
                            Key        = config.Key,
                            Group      = config.Group,
                            Value      = config.Value,
                            ModifyTime = config.UpdateTime.Value
                        });
                    }
                }
            });



            TinyEventBus.Instance.Regist(EventKeys.DELETE_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                string userName  = param_dy.userName;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Warn,
                        AppId   = config.AppId,
                        LogText = $"用户:{userName} 删除配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });


            TinyEventBus.Instance.Regist(EventKeys.OFFLINE_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                string userName  = param_dy.userName;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Warn,
                        AppId   = config.AppId,
                        LogText = $"用户:{userName} 下线配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });



            TinyEventBus.Instance.Regist(EventKeys.PUBLISH_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                Config config    = param_dy.config;
                string userName  = param_dy.userName;

                if (config != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Normal,
                        AppId   = config.AppId,
                        LogText = $"用户:{userName} 上线配置【Key:{config.Key}】【Value:{config.Value}】【Group:{config.Group}】【AppId:{config.AppId}】"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }
                }
            });



            TinyEventBus.Instance.Regist(EventKeys.ROLLBACK_CONFIG_SUCCESS, async(param) =>
            {
                dynamic param_dy    = param;
                Config config       = param_dy.config;
                ModifyLog modifyLog = param_dy.modifyLog;
                string userName     = param_dy.userName;

                if (config != null && modifyLog != null)
                {
                    var log = new SysLog
                    {
                        LogTime = DateTime.Now,
                        LogType = SysLogType.Warn,
                        AppId   = config.AppId,
                        LogText = $"用户:{userName} 回滚配置【Key:{config.Key}】 【Group:{config.Group}】 【AppId:{config.AppId}】至历史记录:{modifyLog.Id}"
                    };
                    using (var syslogService = GetSysLogService())
                    {
                        await syslogService.AddSysLogAsync(log);
                    }

                    using (var modifyLogService = GetModifyLogService())
                    {
                        await modifyLogService.AddAsync(new ModifyLog
                        {
                            Id         = Guid.NewGuid().ToString("N"),
                            ConfigId   = config.Id,
                            Key        = config.Key,
                            Group      = config.Group,
                            Value      = config.Value,
                            ModifyTime = config.UpdateTime.Value
                        });
                    }
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.ADD_NODE_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                ServerNode node  = param_dy.node;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"用户:{userName} 添加节点:{node.Address}"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DELETE_NODE_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                ServerNode node  = param_dy.node;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Warn,
                    LogText = $"用户:{userName} 删除节点:{node.Address}"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.ADD_USER_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                User user        = param_dy.user;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"用户:{userName} 添加用户:{user.UserName} 成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.EDIT_USER_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                User user        = param_dy.user;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Normal,
                    LogText = $"用户:{userName} 编辑用户:{user.UserName} 成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DELETE_USER_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                User user        = param_dy.user;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Warn,
                    LogText = $"用户:{userName} 删除用户:{user.UserName} 成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });

            TinyEventBus.Instance.Regist(EventKeys.DISCONNECT_CLIENT_SUCCESS, async(param) =>
            {
                dynamic param_dy = param;
                string clientId  = param_dy.clientId;
                string userName  = param_dy.userName;

                var log = new SysLog
                {
                    LogTime = DateTime.Now,
                    LogType = SysLogType.Warn,
                    LogText = $"用户:{userName} 断开客户端 {clientId} 成功"
                };
                using (var syslogService = GetSysLogService())
                {
                    await syslogService.AddSysLogAsync(log);
                }
            });
        }