/// <summary> /// /// </summary> /// <param name="groupUpdateDto"></param> /// <returns></returns> public int UpdatePrivilegeGroupUpdate(PrivilegeGroupUpdateDto groupUpdateDto) { TPrivilegeGroupUpdate privilegeGroup = AutoMapperExtensions.MapTo <TPrivilegeGroupUpdate>(groupUpdateDto); privilegeGroup.UpdateTime = DateTime.Now; return(IocUnity.Get <RepositoryPrivilegeGroup>().Update(privilegeGroup)); }
public static void Init() { var builder = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json", false); var configuration = builder.Build(); var appSettingSetion = configuration.GetSection("AppSettingConfig"); var appSettingConfig = appSettingSetion.Get <AppSettingConfig>(); IocUnity.AddSingleton <AppSettingConfig>(appSettingConfig); var setion = configuration.GetSection("SimpleSocketConfig"); var simpleConfig = setion.Get <SimpleSocketConfig>(); IocUnity.AddSingleton <SimpleSocketConfig>(simpleConfig); var loggerSection = configuration.GetSection("LogConfig"); var logConfig = loggerSection.Get <LogConfig>(); logConfig.LogBaseDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logConfig.LogBaseDir); IocUnity.AddSingleton <LogConfig>(logConfig); InitAppSetting(); InitLog(); }
/// <summary> /// 手动加载插件,解决IL无法调试功能 /// </summary> /// <param name="services"></param> /// <param name="builder"></param> /// <param name="plugins"></param> /// <param name="pluginPath"></param> public static void InitWebApiPlug(this IServiceCollection services, IMvcBuilder builder, IList <IPlugin> plugins, string pluginPath) { ConfigHelper._PlugPath = pluginPath; IPluginFactory plugFactory = new DefaultWebApiPluginFactory(builder); Task.Factory.StartNew(() => { var dllPluginList = plugFactory.GetPluginList(pluginPath); if (plugins != null) { plugins.Foreach((item) => { if (item != null && !dllPluginList.Any(f => f.PluginID == item.PluginID)) { dllPluginList.Add(item); } }); } plugFactory.Load(dllPluginList); }).ContinueWith((obj) => { PluginManager.InitExcute(pluginPath, builder); }).ContinueWith((obj) => { IocUnity.AddSingleton <SessionManager>(new SessionManager(IocUnity.Get <ICache>())); }).Wait(); }
public SuperSocketService(IServiceProvider serviceProvider, IOptions <ServerOptions> serverOptions, IChannelCreatorFactory channelCreatorFactory) { var serverOptionsValue = IocUnity.Get <ServerOptions>(); _serverOptions = new ServerConfigOptions <ServerOptions>(serverOptionsValue); //_serverOptions = serverOptions; Name = serverOptions.Value.Name; _serviceProvider = serviceProvider; _pipelineFilterFactory = GetPipelineFilterFactory(); _channelCreatorFactory = channelCreatorFactory; _packageHandler = serviceProvider.GetService <IPackageHandler <TSessionData, TReceivePackageInfo> >(); _errorHandler = serviceProvider.GetService <Func <IAppSession <TSessionData>, PackageHandlingException <TReceivePackageInfo>, ValueTask <bool> > >(); _sessionHandlers = serviceProvider.GetService <SessionHandlers <TSessionData> >(); if (_errorHandler == null) { _errorHandler = OnSessionErrorAsync; } // initialize session factory _sessionFactory = serviceProvider.GetService <ISessionFactory <TSessionData> >(); if (_sessionFactory == null) { _sessionFactory = new DefaultSessionFactory <TSessionData>(); } InitializeMiddlewares(); }
/// <summary> /// /// </summary> /// <param name="passwordDto"></param> /// <param name="userId"></param> /// <returns></returns> public int UpdatePassword(UserUpdatePasswordNewDto passwordDto, string userId) { PagedList <UserInfoDto> pagedList = GetUsersOfInfo(new UserQueryPageDto { UserQuery = new UserQueryDto { Id = userId, Password = passwordDto.OldPassword, State = 1 }, Page = 1, Size = 1 }); if (pagedList.Total == 0) { return(-1); } TUserUpdatePassword updatePassword = new TUserUpdatePassword { Id = userId, Password = StringManage.EncryptPassword(passwordDto.NewPassword), UpdateTime = DateTime.Now }; return(IocUnity.Get <RepositoryUser>().Update(updatePassword)); }
protected static IOptions <ServerOptions> GetServerCfgOptions() { var serverOptionsValue = IocUnity.Get <ServerOptions>(); var serverOptions = new ServerConfigOptions <ServerOptions>(serverOptionsValue); return(serverOptions); }
/// <summary> /// 使用新模块创建权限 /// </summary> /// <param name="privilegeAdd"></param> /// <returns></returns> public int AddPrivilegeForNewGroup(PrivilegeAddForNewGroupDto privilegeAdd) { TPrivilegeGroup privilegeGroup = new TPrivilegeGroup { Id = IdentityHelper.NewSequentialGuid().ToString("N"), Name = privilegeAdd.GroupName, SystemId = privilegeAdd.SystemId }; string SystemCode = IocUnity.Get <RepositorySystem>().GetCode(privilegeAdd.SystemId); TPrivilege privilege = new TPrivilege { Id = IdentityHelper.NewSequentialGuid().ToString("N"), Code = $"{SystemCode}-{privilegeAdd.Code}", OriginalCode = privilegeAdd.Code, Name = privilegeAdd.Name, GroupId = privilegeGroup.Id, Instruction = privilegeAdd.Instruction }; int count = 0; IocUnity.Get <RepositoryPrivilege>().DapperRepository.ExcuteTransaction(tranc => { IocUnity.Get <RepositoryPrivilegeGroup>().Insert(privilegeGroup); count += IocUnity.Get <RepositoryPrivilege>().Insert(privilege); }); return(count); }
public override void InitWorkManager() { var organizerManager = new OrganizerManager(); IocUnity.RegisterInstance <IWorkManager>(typeof(OrganizerManager).Name, organizerManager); DicWorkManagers.Add(typeof(OrganizerManager).Name, (IWorkManager)organizerManager); var leagueManager = new LeagueManager(); IocUnity.RegisterInstance <IWorkManager>(typeof(LeagueManager).Name, leagueManager); DicWorkManagers.Add(typeof(LeagueManager).Name, (IWorkManager)leagueManager); var teamManager = new TeamManager(); IocUnity.RegisterInstance <IWorkManager>(typeof(TeamManager).Name, teamManager); DicWorkManagers.Add(typeof(TeamManager).Name, (IWorkManager)teamManager); var playerManager = new PlayerManager(); IocUnity.RegisterInstance <IWorkManager>(typeof(PlayerManager).Name, playerManager); DicWorkManagers.Add(typeof(PlayerManager).Name, (IWorkManager)playerManager); // 起始任务添加到OrganizerManager中 var indexUrl = "gismo.php?&html=1&id=1828&language=zh&clientid=4&child=1&ismenu=1&childnodeid=1819"; var param = new OrganizerParam() { HandleType = (int)RBHandleType.Organizer, IndexUrl = indexUrl }; organizerManager.AddOrUpdateParam(param); }
static void InitSocket() { var simpleCfg = IocUnity.Get <SimpleSocketConfig>(); Stopwatch startWatch = new Stopwatch(); startWatch.Start(); simpleCfg.Mode = CSuperSocket.SocketBase.SocketMode.Udp; var bootstrap = BootstrapFactory.CreateBootstrapFromServerCfg(simpleCfg); startWatch.Stop(); Console.WriteLine("CSpuerTcp初始化工厂耗时:{0}ms", startWatch.ElapsedMilliseconds); startWatch.Reset(); startWatch.Start(); var isSuccess = bootstrap.Initialize(); startWatch.Stop(); Console.WriteLine("CSpuerTcp启动耗时:{0}ms", startWatch.ElapsedMilliseconds); if (!isSuccess) { SetConsoleColor(ConsoleColor.Red); Console.WriteLine("Failed to initialize CSuperSocket ServiceEngine! Please check error log for more information!"); Console.ReadKey(); return; } _server = bootstrap.AppServers.ToList().FirstOrDefault() as Service; Console.WriteLine("Starting..."); var result = bootstrap.Start(); Console.WriteLine("监听端口:{0}", simpleCfg.Port); Console.WriteLine("-------------------------------------------------------------------"); SetConsoleColor(ConsoleColor.Green); //Console.WriteLine($"上位机唯一Id:{ConfigurationManager.AppSettings["Pid"].ToString()}"); }
/// <summary> /// /// </summary> /// <param name="userQueryDto"></param> /// <returns></returns> public PagedList <UserInfoDto> GetUsersOfInfo(UserQueryPageDto userQueryDto) { var q = Dynamic.Core.Runtime.SerializationUtility.ObjectToJson(userQueryDto); string password = userQueryDto.UserQuery.Password; if (userQueryDto.UserQuery.Password != null) { userQueryDto.UserQuery.Password = StringManage.EncryptPassword(password); } int?userType = userQueryDto.UserQuery.UserType; userQueryDto.UserQuery.UserType = null; var data = IocUnity.Get <RepositoryUser>().QueryInfo(userQueryDto.UserQuery, userQueryDto.Page, userQueryDto.Size); var d = Dynamic.Core.Runtime.SerializationUtility.ObjectToJson(data); if (userQueryDto.UserQuery.Password != null && data.DataList.Count == 0) { userQueryDto.UserQuery.Password = SecurityHelper.Md5(password); data = IocUnity.Get <RepositoryUser>().QueryInfo(userQueryDto.UserQuery, userQueryDto.Page, userQueryDto.Size); } if (userQueryDto.UserQuery.Password != null && data.DataList.Count == 0) { userQueryDto.UserQuery.Password = SecurityHelper.Encrypt(password); data = IocUnity.Get <RepositoryUser>().QueryInfo(userQueryDto.UserQuery, userQueryDto.Page, userQueryDto.Size); } if (userType != null && (userType == (int)UserTypeEnum.Factory || userType == (int)UserTypeEnum.Dealer) && data.DataList != null && data.DataList.Count == 1) { IocUnity.Get <RepositoryUser>().VerifyUser(data.DataList[0].Id, (int)userType); } return(data); }
/// <summary> /// /// </summary> /// <param name="jsonItemEdit"></param> /// <returns></returns> public int EditJsonItem(JsonItemEditDto jsonItemEdit) { TItemContent itemContent = jsonItemEdit.MapTo <TItemContent>(); itemContent.UpdateTime = DateTime.Now; return(IocUnity.Get <RepositoryItemContent>().Update(jsonItemEdit.MapTo <TItemContent>())); }
/// <summary> /// /// </summary> /// <param name="jsonItemEdit"></param> /// <returns></returns> public int AddJsonItem(JsonItemEditDto jsonItemEdit) { var r = IocUnity.Get <RepositoryItem>().IsItem(jsonItemEdit.ParentId); if (r) { var id = IdentityHelper.NewSequentialGuid().ToString("N"); TItemContent itemContent = jsonItemEdit.MapTo <TItemContent>(); itemContent.Id = id; itemContent.IsHasChildren = false; itemContent.CreateTime = DateTime.Now; itemContent.ParentId = null; itemContent.UpdateTime = null; itemContent.ItemId = jsonItemEdit.ParentId; return(IocUnity.Get <RepositoryItemContent>().Insert(itemContent)); } else { var id = IdentityHelper.NewSequentialGuid().ToString("N"); TItemContent itemContent = jsonItemEdit.MapTo <TItemContent>(); itemContent.Id = id; itemContent.CreateTime = DateTime.Now; itemContent.UpdateTime = null; itemContent.ParentId = jsonItemEdit.ParentId; itemContent.ItemId = null; int count = 0; IocUnity.Get <RepositoryItemContent>().DapperRepository.ExcuteTransaction(c => { count = IocUnity.Get <RepositoryItemContent>().Insert(itemContent); IocUnity.Get <RepositoryItemContent>() .Update("IsHasChildren", true, "Id", jsonItemEdit.ParentId); }); return(count); } }
/// <summary> /// 更新系统信息 /// </summary> /// <param name="systemUpdateDto"></param> /// <returns></returns> public int UpdateSystem(SystemUpdateDto systemUpdateDto) { TSystemUpdate system = AutoMapperExtensions.MapTo <TSystemUpdate>(systemUpdateDto); system.UpdateTime = DateTime.Now; return(IocUnity.Get <RepositorySystem>().Update(system)); }
/// <summary> /// /// </summary> /// <param name="roleUpdateDto"></param> /// <returns></returns> public int UpdateRole(RoleUpdateDto roleUpdateDto) { TRoleUpdate roleUpdate = AutoMapperExtensions.MapTo <TRoleUpdate>(roleUpdateDto); if (string.IsNullOrEmpty(roleUpdate.JsonItem)) { roleUpdate.JsonItem = "[]"; } roleUpdate.UpdateTime = DateTime.Now; var SystemCode = IocUnity.Get <RepositoryRole>().GetSystemCode(roleUpdate.Id); if (!string.IsNullOrEmpty(roleUpdateDto.Code)) { roleUpdate.OriginalCode = roleUpdateDto.Code; roleUpdate.Code = $"{SystemCode}-{roleUpdate.OriginalCode}"; } else { roleUpdate.Code = null; } int count = 0; IocUnity.Get <RepositoryRole>().DapperRepository.ExcuteTransaction(r => { count = IocUnity.Get <RepositoryRole>().Update(roleUpdate); IocUnity.Get <RepositoryRole>().UpdateCode(roleUpdate.Id, roleUpdate.Code); }); return(count); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="token"></param> /// <returns></returns> public static T GetSession <T>(string token) { if (_cache == null) { _cache = IocUnity.Get <ICache>(); } return(_cache.Get <T>(token)); }
/// <summary> /// /// </summary> /// <param name="token"></param> public static void RemoveSession(string token) { if (_cache == null) { _cache = IocUnity.Get <ICache>(); } _cache.Remove(token); }
/// <summary> /// /// </summary> /// <param name="passwordDto"></param> /// <returns></returns> public int UpdatePassword(UserUpdatePasswordDto passwordDto) { TUserUpdatePassword updatePassword = passwordDto.MapTo <TUserUpdatePassword>(); updatePassword.Id = passwordDto.UserId; updatePassword.UpdateTime = DateTime.Now; updatePassword.Password = StringManage.EncryptPassword(updatePassword.Password); return(IocUnity.Get <RepositoryUser>().Update(updatePassword)); }
public static void Init() { var builder = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json", false); var configuration = builder.Build(); //加载配置到全局 GlobalConfig.ConnetionString = configuration.GetValue <string>("DBConfig:ConnetionString"); GlobalConfig.NatPort = configuration.GetValue <int>("ServerConfig:NatPort"); GlobalConfig.ServerPort = configuration.GetValue <int>("ServerConfig:ServerPort"); GlobalConfig.DefaultUrl = configuration.GetValue <string>("ServerConfig:DefaultUrl"); GlobalConfig.RegRoleId = configuration.GetValue <string>("ServerConfig:RegRoleId"); Repository = LogManager.CreateRepository("NETCoreRepository"); XmlConfigurator.Configure(Repository, new FileInfo("log4net.config")); Log4netUtil.LogRepository = Repository;//类库中定义的静态变量 HandleLog.WriteLog += (log, isPrint) => { if (isPrint) { Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss,ffff} {log}"); } Log4netUtil.Info(log); }; Task.Run(() => { while (true) { //更新假在线的主机 using var bll = new ClientBll(); var res = bll.UpdateOfflineClient(); HandleLog.WriteLine(res.Message, false); Thread.Sleep(60000); } }); var appSettingSetion = configuration.GetSection("AppSettingConfig"); var appSettingConfig = appSettingSetion.Get <AppSettingConfig>(); IocUnity.AddSingleton <AppSettingConfig>(appSettingConfig); //var setion = configuration.GetSection("SimpleSocketConfig"); //var simpleConfig = setion.Get<SimpleSocketConfig>(); //IocUnity.AddSingleton<SimpleSocketConfig>(simpleConfig); var loggerSection = configuration.GetSection("LogConfig"); var logConfig = loggerSection.Get <LogConfig>(); logConfig.LogBaseDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logConfig.LogBaseDir); IocUnity.AddSingleton <LogConfig>(logConfig); InitAppSetting(); InitLog(); }
private void btnStart_Click(object sender, EventArgs e) { Console.SetOut(tw); Console.WriteLine("Beginning ..."); var type = ConfigSingleton.CreateInstance().GetAppConfig <string>("ReptileType"); reptile = IocUnity.GetService <IReptile>(type); reptile.Start(); }
/// <summary> /// /// </summary> /// <param name="userId"></param> /// <param name="privilegeId"></param> /// <param name="privilegeCode"></param> /// <returns></returns> public bool IsHasPrivilege(string userId, string privilegeId = null, string privilegeCode = null) { if (IocUnity.Get <RepositoryRelationUserPrivilege>().Count(userId, privilegeId, privilegeCode) == 0 && IocUnity.Get <RepositoryUser>().CountUserPrivilege(userId, privilegeId, privilegeCode) == 0 && IocUnity.Get <RepositoryRelationUserRole>().CountUserPrivilege(userId, privilegeId, privilegeCode) == 0) { return(false); } return(true); }
public void RegisterAssembly(Assembly dcpContractAssembly) { var defaultRegisterService = IocUnity.Get <DefaultRegisterService>(); if (defaultRegisterService == null) { defaultRegisterService = new DefaultRegisterService(); IocUnity.AddSingleton <DefaultRegisterService>(defaultRegisterService); } defaultRegisterService.RegisterAssembly(dcpContractAssembly); }
public void RegisterType(Type interfaceConstract, Type constractService) { var defaultRegisterService = IocUnity.Get <DefaultRegisterService>(); if (defaultRegisterService == null) { defaultRegisterService = new DefaultRegisterService(); IocUnity.AddSingleton <DefaultRegisterService>(defaultRegisterService); } defaultRegisterService.RegisterType(interfaceConstract, constractService); }
/// <summary> /// 使用已有模块添加权限 /// </summary> /// <param name="privilegeAddDto"></param> /// <returns></returns> public int AddPrivilege(PrivilegeAddDto privilegeAddDto) { TPrivilege privilege = AutoMapperExtensions.MapTo <TPrivilege>(privilegeAddDto); privilege.OriginalCode = privilegeAddDto.Code; string SystemCode = IocUnity.Get <RepositoryPrivilegeGroup>().GetSystemCode(privilegeAddDto.GroupId); privilege.Code = $"{SystemCode}-{privilege.OriginalCode}"; privilege.Id = IdentityHelper.NewSequentialGuid().ToString("N"); return(IocUnity.Get <RepositoryPrivilege>().Insert(privilege)); }
public static void InitLog() { LogConfig logConfig = IocUnity.Get <LogConfig>(); LoggerManager.InitLogger(logConfig); LoggerManager.GetLogger("LogInit").Error("Test日志组件初始化成功,当前系统运行平台:{0}", RuntimeInformation.OSDescription); AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; }
/// <summary> /// 添加权限组 /// </summary> /// <param name="privilegeGroupAddDto"></param> /// <returns></returns> public int AddPrivilegeGroup(PrivilegeGroupAddDto privilegeGroupAddDto) { TPrivilegeGroup privilegeGroup = new TPrivilegeGroup { Id = IdentityHelper.NewSequentialGuid().ToString("N"), Name = privilegeGroupAddDto.Name, SystemId = privilegeGroupAddDto.SystemId }; return(IocUnity.Get <RepositoryPrivilegeGroup>().Insert(privilegeGroup)); }
private Reptile() { var mem = new MatchEntityManager(); mem.Init(this); matchEntityManager = mem; IocUnity.RegisterInstance("MatchEntityManager", matchEntityManager); socket = new EventSocket(); socket.SocketSink = this; socket.ServerIP = ConfigSingleton.CreateInstance().GetAppConfig <string>("ServerIP"); socket.ServerPort = ConfigSingleton.CreateInstance().GetAppConfig <ushort>("ServerPort"); }
protected IWorkflowHost InitEngine() { lock (_lockObj) { IServiceCollection services = IocUnity.GetServices(DateTime.Now.ToString("yyyyMMddHHmm")); services.AddLogging(); services.AddWorkflow(); var host = IocUnity.Get <IWorkflowHost>(); this._Host = host; return(host); } }
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <summary> </summary> protected override void ConfigLoadAfter(IPluginConfig pluginConfig) { PolicyPrivilegeManageConfig policyPrivilegeConfig = pluginConfig as PolicyPrivilegeManageConfig; PrivilegeManageManager.Init(policyPrivilegeConfig.DbConfig); base.ConfigLoadAfter(pluginConfig); businessSystem = IocUnity.Get<BusinessSystem>(); businessUser = IocUnity.Get<BusinessUser>(); businessRole = IocUnity.Get<BusinessRole>(); businessPrivilege = IocUnity.Get<BusinessPrivilege>(); businessOrganization = IocUnity.Get<BusinessOrganization>(); businessItem = IocUnity.Get<BusinessItem>(); }
public SuperSocketHostBuilder <TSessionData, TReceivePackage> ConfigureSimpleConfig(SimpleSocketConfig simpleSocketConfig) { ServerOptions serverOptions = simpleSocketConfig.ToServerOptions(); return(this.ConfigureServices((hostCtx, services) => { services.AddOptions(); IocUnity.AddSingleton(serverOptions); IOptions <ServerOptions> options = new ServerConfigOptions <ServerOptions>(serverOptions); IocUnity.AddSingleton <IOptions <ServerOptions> >(options); }) as SuperSocketHostBuilder <TSessionData, TReceivePackage>); }
public async Task <DResult <UserInfoDto> > GetMyInfo() { try { UserSessionInfo session = IocUnity.Get <SessionManager>().GetSessionByRequest(Request); return(DResult.Succ(businessUser.GetMyInfo(session.id))); } catch (Exception ex) { Logger.Error(ex.ToString()); return(DResult.Error <UserInfoDto> (ex.Message, 500)); } }