Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();
            services.AddAutoMapperServices();
            services.AddOAuthServices();
            services.AddDemoServices(app);

            IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);

            app.UseOsharpMvc(mvcIocBuilder);
            IIocBuilder apiIocBuilder = new WebApiAutofacIocBuilder(services);

            app.UseOsharpWebApi(apiIocBuilder);
            //app.UseOsharpSignalR(new SignalRAutofacIocBuilder(services));

            app.ConfigureOAuth(apiIocBuilder.ServiceProvider);
            app.ConfigureWebApi();
            //app.ConfigureSignalR();
        }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();
            services.AddAutoMapperServices();
            services.AddOAuthServices();

            services.AddDemoServices(app);

            IIocBuilder IocBuilder = new WebFormAutofacIocBuilder(services);

            app.UseOsharpWebForm(IocBuilder);

            //IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);
            //app.UseOsharpMvc(mvcIocBuilder);
            //IIocBuilder apiIocBuilder = new WebApiAutofacIocBuilder(services);
            //app.UseOsharpWebApi(apiIocBuilder);
            //app.UseOsharpSignalR(new SignalRAutofacIocBuilder(services));

            //app.ConfigureOAuth(apiIocBuilder.ServiceProvider);
            //app.ConfigureWebApi();
            //app.ConfigureSignalR();
        }
Exemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();

            IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);

            app.UseTomNetMvc(mvcIocBuilder);
            IIocBuilder apiIocBuilder = new WebApiAutofacIocBuilder(services);

            app.UseTomNetWebApi(apiIocBuilder);
            app.UseTomNetSignalR(new SignalRAutofacIocBuilder(services));

            app.ConfigureWebApi();
            app.ConfigureSignalR();

            IIocBuilder hangfireBuilder = new HangfireAutofacIocBuilder(services);

            app.UseTomNetHangfile(hangfireBuilder);
            GlobalConfiguration.Configuration.UseMemoryStorage();
            app.UseHangfireDashboard();
            app.UseHangfireServer(new BackgroundJobServerOptions()
            {
                WorkerCount = 1
            });
        }
Exemplo n.º 4
0
        private static void Initialize()
        {
            Log4NetLoggerAdapter adapter = new Log4NetLoggerAdapter();

            LogManager.AddLoggerAdapter(adapter);

            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder builder = new ServicesBuilder();

            try
            {
                IServiceCollection services = builder.Build();

                services.AddLog4NetServices();
                services.AddDataServices();
                services.AddImplementServices();
                services.AddMdSmsServices();
                //services.AddJPushServices();


                IFrameworkInitializer initializer = new FrameworkInitializer();
                initializer.Initialize(new MvcAutofacIocBuilder(services));
                initializer.Initialize(new WebApiAutofacIocBuilder(services));
                //initializer.Initialize(new SignalRAutofacIocBuilder(services));
            }

            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();
            services.AddAutoMapperServices();
            services.AddOAuthServices();
            services.AddSolutionServices(app);
            //services.AddCommunicationService();

            IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);

            app.UseOsharpMvc(mvcIocBuilder);
            IIocBuilder apiIocBuilder = new WebApiAutofacIocBuilder(services);

            app.UseOsharpWebApi(apiIocBuilder);
            //app.UseOsharpSignalR(new SignalRAutofacIocBuilder(services));

            app.ConfigureOAuth(apiIocBuilder.ServiceProvider);
            app.ConfigureWebApi();
            //app.ConfigureSignalR();

            //IIocBuilder hangfireBuilder = new HangfireAutofacIocBuilder(services);
            //app.UseOSharpHangfile(hangfireBuilder);
            //GlobalConfiguration.Configuration.UseMemoryStorage();
            //app.UseHangfireDashboard();
            //app.UseHangfireServer(new BackgroundJobServerOptions() { WorkerCount = 1 });
            //HangfireJobsRunner.Start();

            //启动Communication服务
            IServiceProvider       serviceProvider        = apiIocBuilder.Build();
            ICommunicationContract communicationContracts = serviceProvider.GetService <ICommunicationContract>();

            if (communicationContracts != null)
            {
                communicationContracts.Initialize();
            }

            //启动AgvControlContract服务
            //Solution.Agv.ControlService.IAgvControlContract agvControlContract = serviceProvider.GetService<Solution.Agv.ControlService.IAgvControlContract>();
            //if (agvControlContract != null)
            //{
            //    agvControlContract.Initialize();
            //}

            //启动DispatchingControlContract服务
            Solution.DispatchingControlCenterService.IDispatchingControlContract dispatchingControlContract = serviceProvider.GetService <Solution.DispatchingControlCenterService.IDispatchingControlContract>();
            if (dispatchingControlContract != null)
            {
                dispatchingControlContract.Initialize();
            }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddDataServices();
            IFrameworkInitializer initializer = new FrameworkInitializer();

            initializer.Initialize(new MvcAutofacIocBuilder(services));
        }
Exemplo n.º 7
0
        public void Configuration(IAppBuilder app)
        {
            //获取服务列表
            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);

            app.UseSixComMvc(mvcIocBuilder);
        }
Exemplo n.º 8
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888

            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder(new ServiceBuildOptions());
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();

            app.UseOSkyMvc(services, new MvcAutofacIocBuilder());
            app.UseOSkyWebApi(services, new WebApiAutofacIocBuilder());
            app.UseOSkySignalR(services, new SignalRAutofacIocBuilder());

            ConfigurationWebApi(app);
            ConfigureSignalR(app);

            // 使应用程序可以使用 Cookie 来存储已登录用户的信息
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath          = new PathString("/Admin/Login/Index"),
                ExpireTimeSpan     = TimeSpan.FromMinutes(20), //20分钟过期
                SlidingExpiration  = true
            });

            //// Use a cookie to temporarily store information about a user logging in with a third party login provider
            //app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            //// 取消注释以下行可允许使用第三方登录提供程序登录
            //app.UseMicrosoftAccountAuthentication(
            //    clientId: "",
            //    clientSecret: "");

            //app.UseTwitterAuthentication(
            //   consumerKey: "",
            //   consumerSecret: "");

            //app.UseFacebookAuthentication(
            //   appId: "",
            //   appSecret: "");

            // 支持使用 google 账户登录
            //app.UseGoogleAuthentication();
        }
Exemplo n.º 9
0
        private static void Initialize()
        {
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();

            IFrameworkInitializer initializer = new FrameworkInitializer();

            initializer.Initialize(new MvcAutofacIocBuilder(services));
            initializer.Initialize(new WebApiAutofacIocBuilder(services));
            //initializer.Initialize(new SignalRAutofacIocBuilder(services));
        }
Exemplo n.º 10
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddDataServices();//注册数据上下文

            IIocBuilder           iocBuilder  = new MvcAutofacIocBuilder(services);
            IFrameworkInitializer initializer = new FrameworkInitializer();

            initializer.Initialize(iocBuilder);
        }
Exemplo n.º 11
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();
            services.AddAutoMapperServices();
            services.AddOAuthServices();

            //加载TG.UBP的接口服务,主要包括基础设施层、领域层和应用层
            services.AddUBPUtilityServices(app);
            services.AddUBPCoreServices(app);
            //services.AddUBPApplicationServices(app);

            IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);

            app.UseOsharpMvc(mvcIocBuilder);
            IIocBuilder apiIocBuilder = new WebApiAutofacIocBuilder(services);

            app.UseOsharpWebApi(apiIocBuilder);
            //app.UseOsharpSignalR(new SignalRAutofacIocBuilder(services));

            app.ConfigureOAuth(apiIocBuilder.ServiceProvider);
            app.ConfigureWebApi();
            //app.ConfigureSignalR();

            IIocBuilder hangfireBuilder = new HangfireAutofacIocBuilder(services);

            app.UseOSharpHangfile(hangfireBuilder);
            GlobalConfiguration.Configuration.UseMemoryStorage();
            app.UseHangfireDashboard();
            app.UseHangfireServer(new BackgroundJobServerOptions()
            {
                WorkerCount = 1
            });
            HangfireJobsRunner.Start();
        }
Exemplo n.º 12
0
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888

            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder(new ServiceBuildOptions());
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();

            app.UseMvcInitialize(services, new MvcAutofacIocBuilder());
            app.UseWebApiInitialize(services, new WebApiAutofacIocBuilder());

            ConfigurationWebApi(app);
            ConfigureSignalR(app);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 启动初始化配置
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions());

            // 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder   builder  = new ServicesBuilder();
            IServiceCollection services = builder.Build();

            services.AddLog4NetServices();
            services.AddDataServices();
            services.AddAutoMapperServices();

            IIocBuilder mvcIocBuilder = new MvcAutofacIocBuilder(services);

            app.UseShineMvc(mvcIocBuilder);
            IIocBuilder apiIocBuilder = new WebApiAutofacIocBuilder(services);

            app.UseShineWebApi(apiIocBuilder);
            app.ConfigureWebApi();

            //手动创建映射
            Mapper.CreateMap <UserPageOutDto, UserPageIn>();
            Mapper.CreateMap <UserPageIn, UserLogin>();
            Mapper.CreateMap <UserPageView, UserPageOutDto>();
            Mapper.CreateMap <Organize, OrganizePageOutDto>();
            Mapper.CreateMap <OrganizeIn, Organize>();
            Mapper.CreateMap <Host, HostPageOutDto>()
            .ForMember(m => m.DataItemDetailName, opt => { opt.MapFrom(m => m.DataItemDetailOne.FullName); })
            .ForMember(m => m.OrganizeName, opt => { opt.MapFrom(m => m.OrganizeOne.FullName); })
            .ForMember(m => m.OrganId, opt => { opt.MapFrom(m => m.OrganizeOne.Id); })
            .ForMember(m => m.DataItemDetailIndex, opt => { opt.MapFrom(m => m.DataItemDetailOne.Index); });
            Mapper.CreateMap <HostLogin, HostLoginPageOutDto>()
            .ForMember(m => m.HostRegPacket, opt => { opt.MapFrom(m => m.HostOne.RegPackage); })
            .ForMember(m => m.HostName, opt => { opt.MapFrom(m => m.HostOne.FullName); });
            Mapper.CreateMap <HostParameter, HostParameterPageOutDto>()
            .ForMember(m => m.HostRegPacket, opt => { opt.MapFrom(m => m.HostOne.RegPackage); })
            .ForMember(m => m.HostName, opt => { opt.MapFrom(m => m.HostOne.FullName); });
            Mapper.CreateMap <HostPolicy, HostPolicyPageOutDto>()
            .ForMember(m => m.HostRegPacket, opt => { opt.MapFrom(m => m.HostOne.RegPackage); })
            .ForMember(m => m.HostName, opt => { opt.MapFrom(m => m.HostOne.FullName); });
            Mapper.CreateMap <HostPolicyLogView, HostPolicyLogOutDto>();
            Mapper.CreateMap <DataItem, DataItemPageOutDto>();
            Mapper.CreateMap <BlackListView, BlackListPageOutDto>();
            Mapper.CreateMap <LightPoleView, LightPolePageOutDto>();
            Mapper.CreateMap <SubControlView, SubControlPageOutDto>();
            Mapper.CreateMap <LightPlanView, LightPlanPageOutDto>();
            Mapper.CreateMap <GroupView, GroupPageOutDto>();
            Mapper.CreateMap <HostReadTimeDataView, HTDPageOutDto>();
            Mapper.CreateMap <SubReadTimeDataView, SRTDPageOutDto>();
            Mapper.CreateMap <SubControl, SubControlView>();
            Mapper.CreateMap <Information, InformationOutDto>()
            .ForMember(m => m.TypeName, opt => { opt.MapFrom(m => m.DataItemDetailOne.FullName); })
            .ForMember(m => m.TypeIndex, opt => { opt.MapFrom(m => m.DataItemDetailOne.Index); });
            Mapper.CreateMap <InformationView, InformationPageOut>();
            Mapper.CreateMap <SubRealTimeData_0x16_In, SubRealTimeData>();
            Mapper.CreateMap <GroupControl_0x18_In, GroupControl>()
            .ForSourceMember(m => m.RegPackage, opt => { opt.Ignore(); });
            Mapper.CreateMap <LightPlan_0x54_In, LightPlan>()
            .ForSourceMember(m => m.RegPackage, opt => { opt.Ignore(); });
            Mapper.CreateMap <LightPlan_0x59_In, LightPlan>()
            .ForSourceMember(m => m.RegPackage, opt => { opt.Ignore(); });
            Mapper.CreateMap <HostParameter_0x25_In, HostParameter>()
            .ForSourceMember(m => m.RegPackage, opt => { opt.Ignore(); });
            Mapper.CreateMap <HostLogin_0x44_In, HostLogin>()
            .ForSourceMember(m => m.RegPackage, opt => { opt.Ignore(); });
            Mapper.CreateMap <HostPolicy_0x5B_In, HostPolicy>()
            .ForSourceMember(m => m.RegPackage, opt => { opt.Ignore(); });
            Mapper.CreateMap <UpgradeLog, UpgradeLogOutDto>()
            .ForMember(m => m.OrganizeName, opt => { opt.MapFrom(m => m.OrganizeOne.FullName); });
        }
Exemplo n.º 14
0
        private static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("正在初始化,请稍候……");
                Stopwatch watch = Stopwatch.StartNew();

                IServicesBuilder   builder  = new ServicesBuilder(new ServiceBuildOptions());
                IServiceCollection services = builder.Build();
                services.AddLog4NetServices();
                services.AddDataServices();
                services.AddAutoMapperServices();
                IIocBuilder           iocBuilder  = new LocalAutofacIocBuilder(services);
                IFrameworkInitializer initializer = new FrameworkInitializer();
                initializer.Initialize(iocBuilder);

                _program = iocBuilder.ServiceProvider.GetService <Program>();
                watch.Stop();
                Console.WriteLine("程序初始化完毕并启动成功,耗时:{0}", watch.Elapsed);
            }
            catch (ReflectionTypeLoadException e)
            {
                Console.WriteLine(e);
                Console.WriteLine("LoaderExceptions:");
                Exception[] exs = e.LoaderExceptions;
                foreach (Exception ex in exs)
                {
                    Console.WriteLine(ex);
                }
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadLine();
                return;
            }
            bool exit = false;

            while (true)
            {
                try
                {
                    Console.WriteLine(@"请输入命令:0; 退出程序,功能命令:1 - n");
                    string input = Console.ReadLine();
                    if (input == null)
                    {
                        continue;
                    }
                    switch (input.ToLower())
                    {
                    case "0":
                        exit = true;
                        break;

                    case "1":
                        Method01();
                        break;

                    case "2":
                        Method02();
                        break;

                    case "3":
                        Method03();
                        break;

                    case "4":
                        Method04();
                        break;

                    case "5":
                        Method05();
                        break;

                    case "6":
                        Method06();
                        break;

                    case "7":
                        Method07();
                        break;

                    case "8":
                        Method08();
                        break;

                    case "9":
                        Method09();
                        break;

                    case "10":
                        Method10();
                        break;

                    case "11":
                        Method11();
                        break;

                    case "12":
                        Method12();
                        break;

                    case "13":
                        Method13();
                        break;

                    case "14":
                        Method14();
                        break;

                    case "15":
                        Method15();
                        break;

                    case "16":
                        Method16();
                        break;

                    case "17":
                        Method17();
                        break;

                    case "18":
                        Method18();
                        break;
                    }
                    if (exit)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.FormatMessage());
                }
            }
        }