Пример #1
0
        static void Main(string[] args)
        {
            using (var bootstrapper = new AbpBootstrapper())
            {
                bootstrapper.Initialize();

                var address       = ConfigurationManager.AppSettings["BrokerAddress"];
                var brokerAddress = string.IsNullOrEmpty(address) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(address);
                var clientCount   = int.Parse(ConfigurationManager.AppSettings["ClientCount"]);
                var setting       = new ConsumerSetting
                {
                    ConsumeFromWhere   = ConsumeFromWhere.FirstOffset,
                    MessageHandleMode  = MessageHandleMode.Parallel,
                    BrokerAddress      = new IPEndPoint(brokerAddress, 5001),
                    BrokerAdminAddress = new IPEndPoint(brokerAddress, 5002)
                };
                var messageHandler = new MessageHandler();
                for (var i = 1; i <= clientCount; i++)
                {
                    new BodeAbp.Queue.Clients.Consumers.Consumer(ConfigurationManager.AppSettings["ConsumerGroup"], setting)
                    .Subscribe(ConfigurationManager.AppSettings["Topic"])
                    .SetMessageHandler(messageHandler)
                    .Start();
                }
                Console.ReadLine();
            }
        }
        /// <summary>
        /// This method is called by ASP.NET system on web application's startup.
        /// </summary>
        protected virtual void Application_Start(object sender, EventArgs e)
        {
            IocManager.Instance.IocContainer.Register(Component.For <IAssemblyFinder>().ImplementedBy <WebAssemblyFinder>());

            AbpBootstrapper = new AbpBootstrapper();
            AbpBootstrapper.Initialize();
        }
Пример #3
0
 static void Main(string[] args)
 {
     _bootstrapper = AbpBootstrapper.Create <SmartSystemCNCHostModule>();
     _bootstrapper.IocManager.IocContainer.AddFacility <LoggingFacility>(
         f => f.UseAbpLog4Net().WithConfig("log4net.config"));
     _bootstrapper.Initialize();
     Logger = _bootstrapper.IocManager.Resolve <ILogger>();
     StartWorker();
     Task.Factory.StartNew(StartSignalr);
     Task.Factory.StartNew(() =>
     {
         while (true)
         {
             try
             {
                 cncHandler.Execute();
             }
             catch (Exception ex)
             {
                 // Console.WriteLine($"【Worker Error】-【{DateTime.Now.ToString("HH:mm:ss")}】" + ex.Message + " " + ex.InnerException?.Message);
             }
             Thread.Sleep(100);
         }
     });
     while (true)
     {
         Console.ReadLine();
     }
 }
Пример #4
0
        /// <summary>
        /// This method is called by ASP.NET system on web application's startup.
        /// </summary>
        protected virtual void Application_Start(object sender, EventArgs e)
        {
            IocManager.Instance.IocContainer.Register(Component.For<IAssemblyFinder>().ImplementedBy<WebAssemblyFinder>());

            AbpBootstrapper = new AbpBootstrapper();
            AbpBootstrapper.Initialize();
        }
Пример #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _bootstrapper.Initialize();

            _mainWindow = _bootstrapper.IocManager.Resolve <MainWindow>();
            _mainWindow.Show();
        }
Пример #6
0
        static void Main(string[] args)
        {
            #region MyRegion
            AbpBootstrapper abpBootstrapper = new AbpBootstrapper();
            abpBootstrapper.Initialize();
            var logCfg = new FileInfo(System.AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
            XmlConfigurator.ConfigureAndWatch(logCfg);
            //定时时间多久执行一次
            var interval = int.Parse(ConfigurationManager.AppSettings["interval"] ?? (1 * 60 * 1000).ToString());

            Topshelf.HostFactory.Run(x =>    //1.我们用HostFactory.Run来设置一个宿主主机。我们初始化一个新的lambda表达式X,来显示这个宿主主机的全部配置。
            {
                x.Service <IAppService>(s => //2.告诉Topshelf ,有一个类型为“IAppService服务”,通过定义的lambda 表达式的方式,配置相关的参数。
                {
                    //依赖注入
                    s.ConstructUsing(name => IocManager.Instance.Resolve <GetOrderBatchService>(new { interval = interval }));
                    //直接new 配置一个完全定制的服务,对Topshelf没有依赖关系。常用的方式。
                    //3.告诉Topshelf如何创建这个服务的实例,目前的方式是通过new 的方式,但是也可以通过Ioc 容器的方式:getInstance<towncrier>()。
                    //s.ConstructUsing(name=>new GetOrderBatchService(interval));
                    //4.开始 Topshelf 服务。
                    s.WhenStarted(tc => tc.Start());
                    //5.停止 Topshelf 服务。
                    s.WhenStopped(tc => tc.Stop());
                });
                //服务使用NETWORK_SERVICE内置帐户运行。身份标识,有好几种方式,如:x.RunAs("username", "password"); x.RunAsPrompt(); x.RunAsNetworkService(); 等
                x.RunAsLocalSystem();           //服务使用NETWORK_SERVICE内置帐户运行

                x.SetDescription("订单同步");       //服务的描述
                x.SetDisplayName("订单同步");       //显示名称
                x.SetServiceName("SYNC_ORDER"); //服务名称
            });


            #endregion
        }
Пример #7
0
        public static void InitHostAbpSetting(this AbpBootstrapper @this)
        {
            // Abp Log
            //IocManager.Instance.IocContainer.AddFacility<LoggingFacility>(f => f.UseAbpYibanLog(
            //   ServerConfigManager.Instance.GetConfigValue("PrintProxy", "AppName", "核心服务")
            //   , ""
            //   , ServerConfigManager.Instance.GetConfigValue("PrintProxy", "LoggerLevel", "Info").AsTargetType(YiBan.LogClient.Enums.Loglevel.Info)
            //   , ServerConfigManager.Instance.GetConfigValue("LoggerServer", "Host", "127.0.0.1")
            //   , ServerConfigManager.Instance.GetConfigValue("LoggerServer", "Port", "55000").AsTargetType<int>(55000)
            //   , ServerConfigManager.Instance.GetConfigValue("PrintProxy", "UploadInterval", "60").AsTargetType<int>(10)
            //));

            IocManager.Instance.IocContainer.AddFacility <LoggingFacility>(
                f => f.UseAbpLog4Net().WithConfig("log4net.config")
                );

            // 创建插件目录
            var pluginsFolder = AppDomain.CurrentDomain.BaseDirectory + @"Plugins";

            if (!Directory.Exists(pluginsFolder))
            {
                Directory.CreateDirectory(pluginsFolder);
            }

            @this.PlugInSources.AddFolder(pluginsFolder, SearchOption.AllDirectories);
            @this.Initialize();
        }
        public void Service_Created_With_Abp_IocManager()
        {
            using (var bootstrapper = new AbpBootstrapper())
            {
                bootstrapper.Initialize();

                bool hasStarted = false;

                var host = HostFactory.New(cfg =>
                {
                    cfg.UseTestHost();
                    cfg.UseAbp(bootstrapper);
                    cfg.Service <TestService>(svc =>
                    {
                        svc.ConstructUsingAbp();
                        svc.WhenStarted(s => hasStarted = s.Start());
                        svc.WhenStopped(s => s.Stop());
                    });
                });

                var exitCode = host.Run();
                Assert.AreEqual(TopshelfExitCode.Ok, exitCode);
                Assert.IsTrue(hasStarted);
            }
        }
Пример #9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);

            // now set the Green accent and dark theme
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent("Red"),
                                        appStyle.Item1); // or appStyle.Item1

            _synchronizationContext = DispatcherSynchronizationContext.Current;
            _bootstrapper.Initialize();

            _loginWindow = _bootstrapper.IocManager.Resolve <LoginWindow>();



            var isLogin = _loginWindow.ShowDialog();

            if (isLogin.HasValue && isLogin.Value)
            {
                _mainWindow = _bootstrapper.IocManager.Resolve <MainWindow>();

                _mainWindow.Show();

                _loginWindow.Close();
            }
        }
Пример #10
0
        protected override void OnStartup(StartupEventArgs e)
        {
            this.DispatcherUnhandledException += App_DispatcherUnhandledException;
            _bootstrapper.Initialize();

            #region 主题颜色
            // get the current app style (theme and accent) from the application
            // you can then use the current theme and custom accent instead set a new theme
            Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);

            // now set the Green accent and dark theme
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent("Green"),
                                        ThemeManager.GetAppTheme("BaseLight"));                                         // or appStyle.Item1
            #endregion

            //将LoginView设为主窗体
            LoginView loginView = _bootstrapper.IocManager.Resolve <LoginView>();
            MainWindow = loginView;
            MainWindow.Show();

            //注册消息,返回true为登录成功
            Messenger.Default.Register <bool?>(this, "Login", m =>
            {
                if (m.Value == true)
                {
                    MainWindow = _bootstrapper.IocManager.Resolve <MainWindow>();
                    loginView.Close();
                    MainWindow.Show();
                }
            });
        }
Пример #11
0
        static void Main(string[] args)
        {
            using (var bootstrapper = new AbpBootstrapper())
            {
                bootstrapper.Initialize();

                var setting = new BrokerSetting(
                    bool.Parse(ConfigurationManager.AppSettings["isMemoryMode"]),
                    ConfigurationManager.AppSettings["fileStoreRootPath"],
                    chunkCacheMaxPercent: 95,
                    chunkFlushInterval: int.Parse(ConfigurationManager.AppSettings["flushInterval"]),
                    messageChunkDataSize: int.Parse(ConfigurationManager.AppSettings["chunkSize"]) * 1024 * 1024,
                    chunkWriteBuffer: int.Parse(ConfigurationManager.AppSettings["chunkWriteBuffer"]) * 1024,
                    enableCache: bool.Parse(ConfigurationManager.AppSettings["enableCache"]),
                    chunkCacheMinPercent: int.Parse(ConfigurationManager.AppSettings["chunkCacheMinPercent"]),
                    syncFlush: bool.Parse(ConfigurationManager.AppSettings["syncFlush"]),
                    messageChunkLocalCacheSize: 30 * 10000,
                    queueChunkLocalCacheSize: 10000)
                {
                    NotifyWhenMessageArrived   = bool.Parse(ConfigurationManager.AppSettings["notifyWhenMessageArrived"]),
                    MessageWriteQueueThreshold = int.Parse(ConfigurationManager.AppSettings["messageWriteQueueThreshold"])
                };
                BrokerController.Create(setting).Start();
                Console.ReadLine();
            }
        }
Пример #12
0
        public static void Main(string[] args)
        {
            ParseArgs(args);

            using (AbpBootstrapper bootstrapper = AbpBootstrapper.Create <WebShopMigratorModule>())
            {
                bootstrapper.IocManager.IocContainer
                .AddFacility <LoggingFacility>(
                    f => f.UseAbpLog4Net().WithConfig("log4net.config")
                    );

                bootstrapper.Initialize();

                using (IDisposableDependencyObjectWrapper <MultiTenantMigrateExecuter> migrateExecuter = bootstrapper.IocManager.ResolveAsDisposable <MultiTenantMigrateExecuter>())
                {
                    bool migrationSucceeded = migrateExecuter.Object.Run(_quietMode);

                    if (_quietMode)
                    {
                        // exit clean (with exit code 0) if migration is a success, otherwise exit with code 1
                        int exitCode = Convert.ToInt32(!migrationSucceeded);
                        Environment.Exit(exitCode);
                    }
                    else
                    {
                        Console.WriteLine("Press ENTER to exit...");
                        Console.ReadLine();
                    }
                }
            }
        }
Пример #13
0
        IBusControl ConfigureBus()
        {
            using (_abpBootstrapper = AbpBootstrapper.Create <FishFourmWinServiceModule>())
            {
                _abpBootstrapper.Initialize();
                return(Bus.Factory.CreateUsingRabbitMq(cfg =>
                {
                    var host = cfg.Host(new Uri("rabbitmq://localhost"), h =>
                    {
                        h.Username("guest");
                        h.Password("guest");
                    });

                    var service = _abpBootstrapper.IocManager.Resolve <IUserAppService>();

                    cfg.ReceiveEndpoint(host, "userRegisted_queue", e =>
                    {
                        //每隔5秒尝试消费一次
                        e.UseRetry(retryConfig => retryConfig.Interval(5, TimeSpan.FromSeconds(5)));
                        e.Consumer <UserRegistedComsumer>(() => new UserRegistedComsumer(service));
                        e.Consumer <UserUpdatedConsumer>(() => new UserUpdatedConsumer(service));
                    });

                    //cfg.ReceiveEndpoint(host, "userUpdated_queue", e =>
                    //{
                    //    //每隔5秒尝试消费一次
                    //    e.UseRetry(retryConfig => retryConfig.Interval(5, TimeSpan.FromSeconds(5)));
                    //    e.Consumer<UserUpdatedConsumer>(() => new UserUpdatedConsumer(service));
                    //});
                }));
            }
        }
Пример #14
0
 protected void Configure()
 {
     if (_bootstrapper == null)
     {
         _bootstrapper = AbpBootstrapper.Create <DCServicesModule>();
         _bootstrapper.Initialize();
     }
 }
        public JsonAndXmlSourceMixing_Tests()
        {
            LocalIocManager.Register<ILanguageManager, LanguageManager>();
            LocalIocManager.Register<ILanguageProvider, DefaultLanguageProvider>();

            _bootstrapper = AbpBootstrapper.Create<MyLangModule>(LocalIocManager);
            _bootstrapper.Initialize();
        }
Пример #16
0
        public JsonAndXmlSourceMixing_Tests()
        {
            LocalIocManager.Register <ILanguageManager, LanguageManager>();
            LocalIocManager.Register <ILanguageProvider, DefaultLanguageProvider>();

            _bootstrapper = AbpBootstrapper.Create <MyLangModule>(LocalIocManager);
            _bootstrapper.Initialize();
        }
Пример #17
0
 static void AbpBootStrapper()
 {
     _bootstrapper = AbpBootstrapper.Create <CoundFlareModule>();
     _bootstrapper.IocManager.IocContainer
     .AddFacility <LoggingFacility>(f => f.UseAbpLog4Net()
                                    .WithConfig("log4net.config")
                                    );
     _bootstrapper.Initialize();
 }
Пример #18
0
        private static void SearchClubs()
        {
            AbpBootstrapper bootstrapper = new AbpBootstrapper();

            bootstrapper.Initialize();

            IClubAppService clubService = bootstrapper.IocManager.Resolve <IClubAppService>();
            //var result = clubService.SearchClubs(new CatchApp.Geodata.GeoPoint(46.599550, 14.270328));
        }
Пример #19
0
        static void Main(string[] args)
        {
            try
            {
                using (var bootstrapper = new AbpBootstrapper())
                {
                    bootstrapper.Initialize();

                    using (var client = bootstrapper.IocManager.ResolveAsDisposable <MyTestClient>())
                    {
                        Console.Write("Enter tenancy (demo) name: ");
                        client.Object.TenancyName = Console.ReadLine();
                        if (client.Object.TenancyName.IsNullOrWhiteSpace())
                        {
                            return;
                        }

                        Console.Write("Enter username: "******"Enter password: "******"Logging in...");

                        client.Object.Login();

                        Console.WriteLine("Getting roles...");

                        var roles = AsyncHelper.RunSync(() => client.Object.GetRolesAsync());

                        Console.WriteLine(roles.Items.Count + " roles found:");
                        foreach (var role in roles.Items)
                        {
                            Console.WriteLine("Role: Id=" + role.Id + ", DisplayName=" + role.DisplayName + ", IsDefault=" + role.IsDefault);
                        }
                    }
                }
            }
            catch (AbpRemoteCallException ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine();
            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
        }
Пример #20
0
        public static void Initialize()
        {
            if (_bootstrapper != null)
            {
                return;
            }

            _bootstrapper = AbpBootstrapper.Create<AbpWebApiTestModule>();
            _bootstrapper.Initialize();
        }
Пример #21
0
 public static void Initialize()
 {
     if (_bootstrapper != null)
     {
         return;
     }
     
     _bootstrapper = new AbpBootstrapper();
     _bootstrapper.Initialize();
 }
        public JsonAndXmlSourceMixing_Tests()
        {
            LocalIocManager.Register<IModuleFinder, MyTestModuleFinder>();

            LocalIocManager.Register<ILanguageManager, LanguageManager>();
            LocalIocManager.Register<ILanguageProvider, DefaultLanguageProvider>();

            _bootstrapper = new AbpBootstrapper(LocalIocManager);
            _bootstrapper.Initialize();
        }
Пример #23
0
        public JsonAndXmlSourceMixing_Tests()
        {
            LocalIocManager.Register <IModuleFinder, MyTestModuleFinder>();

            LocalIocManager.Register <ILanguageManager, LanguageManager>();
            LocalIocManager.Register <ILanguageProvider, DefaultLanguageProvider>();

            _bootstrapper = new AbpBootstrapper(LocalIocManager);
            _bootstrapper.Initialize();
        }
Пример #24
0
        public static void Initialize()
        {
            if (_bootstrapper != null)
            {
                return;
            }

            _bootstrapper = new AbpBootstrapper <TTenantId, TUserId>();
            _bootstrapper.Initialize();
        }
Пример #25
0
        public static void Initialize()
        {
            if (_bootstrapper != null)
            {
                return;
            }

            _bootstrapper = new AbpBootstrapper();
            _bootstrapper.Initialize();
        }
        public static void Initialize()
        {
            if (_bootstrapper != null)
            {
                return;
            }

            _bootstrapper = AbpBootstrapper.Create <AbpWebApiTestModule>();
            _bootstrapper.Initialize();
        }
Пример #27
0
        static void Main(string[] args)
        {
            using (var bootstrapper = new AbpBootstrapper())
            {
                bootstrapper.Initialize();

                new SocketRemotingServer().RegisterRequestHandler(100, new RequestHandler()).Start();
                Console.ReadLine();
            }
        }
        protected void InitializeAbp()
        {
            LocalIocManager.Register <IAbpSession, TestAbpSession>();

            PreInitialize();

            AbpBootstrapper.Initialize();

            AbpSession = LocalIocManager.Resolve <TestAbpSession>();
        }
Пример #29
0
        static void Main(string[] args)
        {
            using (var bootstrapper = new AbpBootstrapper())
            {
                bootstrapper.Initialize();

                var test = IocManager.Instance.Resolve <IUserService>();
                test.GetAllUsers();
            }
        }
Пример #30
0
        private static void InitAbp(AbpBootstrapper bootstrapper)
        {
            bootstrapper.IocManager.IocContainer
            .AddFacility <LoggingFacility>(f => f.UseAbpLog4Net()
                                           .WithConfig("log4net.config")
                                           );
            // 可以注入 _appConfiguration

            bootstrapper.Initialize();
            iocManager = bootstrapper.IocManager;
        }
Пример #31
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");

            _bootstrapper.PlugInSources.AddFolder(path);
            _bootstrapper.Initialize();
            DispatcherHelper.Initialize();
            LoadPluginAssemblies();

            _bootstrapper.IocManager.Resolve <MainWindow>().Show();
        }
Пример #32
0
 private void Form1_Load(object sender, EventArgs e)
 {
     using (var abpBootstrapper = new AbpBootstrapper())
     {
         Assembly.GetAssembly(typeof(IPSPApplicationModule)).GetTypes().Where(t => t.IsInterface && typeof(IApplicationService).IsAssignableFrom(t)).ToList().ForEach(t =>
         {
             abpBootstrapper.Initialize();
             var serviceHost = new ServiceHost(abpBootstrapper.IocManager.IocContainer.Resolve(t));
             serviceHost.Open();
         });
     }
 }
Пример #33
0
        protected override void OnStartup(StartupEventArgs eventArgs)
        {
            _bootstrapper.Initialize();

            _bootstrapper.IocManager.Register <IGrowlNotifications, GrowlNotifications>();

            HandleExceptionsOrNothing();

            ConfigureMemoryCache();

            base.OnStartup(eventArgs);
        }
        /// <summary>
        /// This method is called by ASP.NET system on web application's startup.
        /// </summary>
        protected virtual void Application_Start(object sender, EventArgs e)
        {
            //TODO: Use AbpBootstrapper.IocManager
            IocManager.Instance.IocContainer.Register(Component.For<IAssemblyFinder>().ImplementedBy<WebAssemblyFinder>());

            //TODO: Use AbpBootstrapper.IocManager
            //TODO: Move to AbpWebModule?
            IocManager.Instance.IocContainer.Register(Component.For<ICurrentUnitOfWorkProvider>().ImplementedBy<HttpContextCurrentUnitOfWorkProvider>());

            AbpBootstrapper = new AbpBootstrapper();
            AbpBootstrapper.Initialize();
        }
Пример #35
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _bootstrapper.Initialize();

            // 注册View供DocumentService使用
            ViewLocator.Default = new BaseViewLocator(new List <Assembly>()
            {
                typeof(App).Assembly,
            });

            base.OnStartup(e);
        }
Пример #36
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _bootstrapper.Initialize();

            ViewModelLocator locator = _bootstrapper.IocManager.Resolve <ViewModelLocator>();

            this.Resources.Add("Locator", locator);

            _mainWindow = _bootstrapper.IocManager.Resolve <MainWindow>();
            _mainWindow.Show();
            base.OnStartup(e);
        }
Пример #37
0
 /// <summary>
 /// This method is called by ASP.NET system on web application's startup.
 /// </summary>
 protected virtual void Application_Start(object sender, EventArgs e)
 {
     AbpBootstrapper = new AbpBootstrapper();
     AbpBootstrapper.Initialize();
 }