Пример #1
0
        public override void Configure(Container container)
        {
            this.Plugins.Add((IPlugin) new SwaggerFeature());
            this.Plugins.Add((IPlugin) new RequestLogsFeature(new int?()));
            CorsFeature corsFeature = new CorsFeature("*", "GET, POST, PUT, DELETE, OPTIONS", "*", false, (string)null, new int?());

            this.PreRequestFilters.Add((Action <IRequest, IResponse>)((httpReq, httpRes) =>
            {
                if (!(httpReq.Verb == "OPTIONS"))
                {
                    return;
                }
                httpRes.StatusCode = 204;
            }));
            this.Plugins.Add((IPlugin)corsFeature);

            //container.Register<IDbConnectionFactory>((Func<Container, IDbConnectionFactory>)(c => (IDbConnectionFactory)new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["ICMS"].ConnectionString, HelperConnection.GetProvider(ConfigurationManager.ConnectionStrings["ICMS"].ProviderName))));

            this.Plugins.Add((IPlugin) new SessionFeature());
            container.Register <ICacheClient>(new MemoryCacheClient());

            this.SetConfig(new HostConfig()
            {
                DefaultContentType  = "charset=UTF-8;",
                WebHostPhysicalPath = MapProjectPath("~") //“~”表示Web 应用程序根目录,“/”也是表示根目录,“../”表示当前目录的上一级目录,“./”表示当前目录
                                                          //EmbeddedResourceSources = { typeof(RestAPIService).Assembly },
                                                          //EmbeddedResourceBaseTypes = { typeof(RestAPIService) }
            });
        }
Пример #2
0
        private void InitializePlugins(Container container)
        {
            Plugins.Add(new ValidationFeature());
            Plugins.Add(new PostmanFeature());
            Plugins.Add(new SwaggerFeature());
            var corsFeature = new CorsFeature(allowedHeaders: "X-Request-With, Content-Type, Authorization, Origin, Accept");

            Plugins.Add(corsFeature);
            Plugins.RemoveAll(x => x is NativeTypesFeature);
        }
Пример #3
0
        public override void Configure(Container container)
        {
            //ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; ! DO NOT USE THIS !
            //Feature disableFeatures = Feature.Xml | Feature.Jsv | Feature.Csv | Feature.Soap11 | Feature.Soap12 | Feature.Soap;
            SetConfig(new EndpointHostConfig
            {
                DebugMode = false,
                UseCustomMetadataTemplates = true,
                //DefaultContentType = ContentType.Json,
                //GlobalResponseHeaders = {
                //    { "Access-Control-Allow-Origin", "*" },
                //    { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
                //    { "Access-Control-Allow-Headers", "Content-Type, Signature" }
                //},
                EnableFeatures = Feature.Json | Feature.Metadata
                                 //ServiceStackHandlerFactoryPath  = "api"
            });
            CorsFeature cf = new CorsFeature(allowedOrigins: "*", allowedMethods: "GET, POST, PUT, DELETE, OPTIONS", allowedHeaders: "X-Requested-With, Content-Type, Signature", allowCredentials: false);

            this.Plugins.Add(cf);
            this.Plugins.Add(new SwaggerFeature());
            //DB
            var dbConnectionFactory = new OrmLiteConnectionFactory(GetConnectionString("Freight"), SqlServerDialect.Provider)
            {
                ConnectionFilter =
                    x =>
                    new ProfiledDbConnection(x, Profiler.Current)
            };

            container.Register <IDbConnectionFactory>(dbConnectionFactory);
            //
            var secretKey = new WebApi.ServiceModel.SecretKeyFactory(strSecretKey);

            container.Register <WebApi.ServiceModel.ISecretKey>(secretKey);
            //Auth
            container.RegisterAutoWired <WebApi.ServiceModel.Auth>();
            //Freight
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Freight_Login_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Saus_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Rcbp_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Smsa_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Smct_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Plvi_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Rcvy_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Jmjm_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.Tracking_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.ViewFile_Logic>();
            container.RegisterAutoWired <WebApi.ServiceModel.Freight.UploadFile_Logic>();
            //Utils
            container.RegisterAutoWired <WebApi.ServiceModel.Utils.QiniuToken_Logic>();
        }
Пример #4
0
        public override void Configure(Container container)
        {
            this.Plugins.Add((IPlugin) new SwaggerFeature());
            this.Plugins.Add((IPlugin) new RequestLogsFeature(new int?()));
            CorsFeature corsFeature = new CorsFeature("*", "GET, POST, PUT, DELETE, OPTIONS", "*", false, (string)null, new int?());

            this.PreRequestFilters.Add((Action <IRequest, IResponse>)((httpReq, httpRes) =>
            {
                if (!(httpReq.Verb == "OPTIONS"))
                {
                    return;
                }
                httpRes.StatusCode = 204;
            }));
            this.Plugins.Add((IPlugin)corsFeature);

            this.Plugins.Add((IPlugin) new SessionFeature());
            container.Register <ICacheClient>(new MemoryCacheClient());
        }
Пример #5
0
        public override void Configure(Container container)
        {
            //ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; ! DO NOT USE THIS !
            //Feature disableFeatures = Feature.Xml | Feature.Jsv | Feature.Csv | Feature.Soap11 | Feature.Soap12 | Feature.Soap;
            SetConfig(new EndpointHostConfig
            {
                DebugMode = false,
                UseCustomMetadataTemplates = true,
                DefaultContentType         = ContentType.Json,
                EnableFeatures             = Feature.Json | Feature.Metadata
                                             //ServiceStackHandlerFactoryPath  = "api"
            });
            CorsFeature cf = new CorsFeature(allowedOrigins: "*", allowedMethods: "GET, POST, PUT, DELETE", allowedHeaders: "Content-Type, Signature", allowCredentials: false);

            this.Plugins.Add(cf);

            string strConnectionString = GetConnectionString();
            var    dbConnectionFactory = new OrmLiteConnectionFactory(strConnectionString, SqlServerDialect.Provider)
            {
                ConnectionFilter =
                    x =>
                    new ProfiledDbConnection(x, Profiler.Current)
            };

            container.Register <IDbConnectionFactory>(dbConnectionFactory);

            var connectString = new TmsWS.ServiceModel.ConnectStringFactory(strConnectionString);

            container.Register <TmsWS.ServiceModel.IConnectString>(connectString);
            var secretKey = new TmsWS.ServiceModel.SecretKeyFactory(strSecretKey);

            container.Register <TmsWS.ServiceModel.ISecretKey>(secretKey);

            container.RegisterAutoWired <TmsWS.ServiceModel.Auth>();
            container.RegisterAutoWired <TmsWS.ServiceModel.Event.List_Login_Logic>();
            container.RegisterAutoWired <TmsWS.ServiceModel.Event.List_JobNo_Logic>();
            container.RegisterAutoWired <TmsWS.ServiceModel.Event.List_Container_Logic>();
            container.RegisterAutoWired <TmsWS.ServiceModel.Event.List_Jmjm6_Logic>();
            container.RegisterAutoWired <TmsWS.ServiceModel.Event.Update_Done_Logic>();
        }
Пример #6
0
        public override void Configure(Container container)
        {
            //ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; ! DO NOT USE THIS !
            //Feature disableFeatures = Feature.Xml | Feature.Jsv | Feature.Csv | Feature.Soap11 | Feature.Soap12 | Feature.Soap;
            SetConfig(new EndpointHostConfig
            {
                DebugMode = false,
                UseCustomMetadataTemplates = true,
                DefaultContentType = ContentType.Json,
                EnableFeatures = Feature.Json | Feature.Metadata
                //ServiceStackHandlerFactoryPath  = "api"
            });
            CorsFeature cf = new CorsFeature(allowedOrigins: "*", allowedMethods: "GET, POST, PUT, DELETE", allowedHeaders: "Content-Type, Signature", allowCredentials: false);
            this.Plugins.Add(cf);

            string strConnectionString = GetConnectionString();
            var dbConnectionFactory = new OrmLiteConnectionFactory(strConnectionString, SqlServerDialect.Provider)
            {
                ConnectionFilter =
                    x =>
                    new ProfiledDbConnection(x, Profiler.Current)
            };
            container.Register<IDbConnectionFactory>(dbConnectionFactory);

            var connectString = new TmsWS.ServiceModel.ConnectStringFactory(strConnectionString);
            container.Register<TmsWS.ServiceModel.IConnectString>(connectString);
            var secretKey = new TmsWS.ServiceModel.SecretKeyFactory(strSecretKey);
            container.Register<TmsWS.ServiceModel.ISecretKey>(secretKey);

            container.RegisterAutoWired<TmsWS.ServiceModel.Auth>();
            container.RegisterAutoWired<TmsWS.ServiceModel.Event.List_Login_Logic>();
            container.RegisterAutoWired<TmsWS.ServiceModel.Event.List_JobNo_Logic>();
            container.RegisterAutoWired<TmsWS.ServiceModel.Event.List_Container_Logic>();
            container.RegisterAutoWired<TmsWS.ServiceModel.Event.List_Jmjm6_Logic>();
            container.RegisterAutoWired<TmsWS.ServiceModel.Event.Update_Done_Logic>();
        }
        public override void Configure(Funq.Container container)
        {
            var appSettings = new AppSettings();

            var successRedirectUrlFilter = ConfigurationManager.AppSettings["SuccessRedirectUrlFilter"];
            var authServerUrl            = appSettings.GetString("oauth.auth0.OAuthServerUrl");

            Plugins.Add(new AuthFeature(() => new AuthUserSession(),            //Use your own typed Custom UserSession type
                                        new IAuthProvider[] {
                new CredentialsAuthProvider(),                                  //HTML Form post of UserName/Password credentials
                new TwitterAuthProvider(appSettings)
                {
                    SuccessRedirectUrlFilter = (authProvider, url) => successRedirectUrlFilter
                },                                                              //Sign-in with Twitter
                new FacebookAuthProvider(appSettings)
                {
                    SuccessRedirectUrlFilter = (authProvider, url) => successRedirectUrlFilter
                },                                                              //Sign-in with Facebook
                new DigestAuthProvider(appSettings),                            //Sign-in with Digest Auth
                new BasicAuthProvider(),                                        //Sign-in with Basic Auth
                new GoogleOAuth2Provider(appSettings),                          //Sign-in with Google OpenId
                new LinkedInOAuth2Provider(appSettings),
                new VkAuthProvider(appSettings)
                {
                    ApplicationId            = "5205626",
                    SecureKey                = "Vjbd20LrrW1stdaWONty",
                    SuccessRedirectUrlFilter = (authProvider, url) => successRedirectUrlFilter
                },
                new FourSquareOAuth2Provider(appSettings),
                new GithubAuthProvider(appSettings),
                new Auth0Provider(appSettings, authServerUrl)
            }));

            Plugins.Add(new SessionFeature());

            var allowDomainForCors = new List <string>(ConfigurationManager.AppSettings["allowDomainForCORS"].Split(new[] { ';' }));

            Plugins.Add(new RegistrationFeature());

            var cors = new CorsFeature(
                allowOriginWhitelist: allowDomainForCors,
                allowCredentials: true,
                allowedHeaders: "Content-Type, Allow, Authorization");

            Plugins.Add(cors);

            var connectionString = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;

            var dbConFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);

            container.Register <IDbConnectionFactory>(dbConFactory);

            container.Register <IUserAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve <IDbConnectionFactory>()));

            var authRepo = (OrmLiteAuthRepository)container.Resolve <IUserAuthRepository>();

            authRepo.InitSchema();
            CreateAdmine(authRepo);

            container.Register(new ProjectDbContext(connectionString));

            container.Register(c => new UnitOfWork(c.Resolve <ProjectDbContext>()));

            container.Register(c => new UserProfileRepository(c.Resolve <ProjectDbContext>()));

            container.Register(c => new UserProfileService(c.Resolve <UserProfileRepository>(), c.Resolve <UnitOfWork>()));
        }
Пример #8
0
        public override void Configure(Container container)
        {
            //ServiceStack.Text.JsConfig.EmitCamelCaseNames = true; ! DO NOT USE THIS !
            //Feature disableFeatures = Feature.Xml | Feature.Jsv | Feature.Csv | Feature.Soap11 | Feature.Soap12 | Feature.Soap;
            SetConfig(new EndpointHostConfig
            {
                DebugMode = false,
                UseCustomMetadataTemplates = true,
                //DefaultContentType = ContentType.Json,
																//GlobalResponseHeaders = {
                //    { "Access-Control-Allow-Origin", "*" },
                //    { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
                //    { "Access-Control-Allow-Headers", "Content-Type, Signature" }
                //},
                EnableFeatures = Feature.Json | Feature.Metadata
                //ServiceStackHandlerFactoryPath  = "api"                
            });
            CorsFeature cf = new CorsFeature(allowedOrigins: "*", allowedMethods: "GET, POST, PUT, DELETE, OPTIONS", allowedHeaders: "Content-Type, Signature", allowCredentials: false);
            this.Plugins.Add(cf);
            this.Plugins.Add(new SwaggerFeature());
            //DB
												var dbConnectionFactory = new OrmLiteConnectionFactory(GetConnectionString("Freight"), SqlServerDialect.Provider)
            {
                ConnectionFilter =
                    x =>
                    new ProfiledDbConnection(x, Profiler.Current)
            };
												dbConnectionFactory.RegisterConnection("TMS", GetConnectionString("TMS"), SqlServerDialect.Provider);
												dbConnectionFactory.RegisterConnection("WMS", GetConnectionString("WMS"), SqlServerDialect.Provider);
            container.Register<IDbConnectionFactory>(dbConnectionFactory);
												//
            var secretKey = new WebApi.ServiceModel.SecretKeyFactory(strSecretKey);
            container.Register<WebApi.ServiceModel.ISecretKey>(secretKey);
            //Auth
            container.RegisterAutoWired<WebApi.ServiceModel.Auth>();
            //WMS
												container.RegisterAutoWired<WebApi.ServiceModel.Wms.Wms_Login_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Rcbp1_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Imgr1_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Impr1_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Imgr2_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Imgi1_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Imgi2_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.List_Imsn1_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Wms.Confirm_Imgr1_Logic>();
												//TMS
												container.RegisterAutoWired<WebApi.ServiceModel.Tms.Jmjm_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Tms.Sibl_Logic>();
            //Event
            container.RegisterAutoWired<WebApi.ServiceModel.Event.Event_Login_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Event.List_Jmjm6_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Event.List_JobNo_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Event.Update_Done_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Event.List_Container_Logic>();
            //Freight
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Freight_Login_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Saus_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Rcbp_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Smsa_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Smct_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Plvi_Logic>();
            container.RegisterAutoWired<WebApi.ServiceModel.Freight.Rcvy_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.Tracking_Logic>();
												container.RegisterAutoWired<WebApi.ServiceModel.Freight.ViewPDF_Logic>();
        }