Exemplo n.º 1
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            options.LoginProviders.Remove(typeof(AzureActiveDirectoryLoginProvider));
            options.LoginProviders.Add(typeof(CustomLoginProvider));
            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            config.SetIsHosted(true);

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            //
            Database.SetInitializer(new dhcchardwareInitializer());

            //Lets never touch this again..
            //AutoMapper.Mapper.Initialize(cfg =>
            //{
            //    cfg.CreateMap<LoanItem, LoanItemDTO>()
            //        .ForMember(loanItemDTO => loanItemDTO.Item, map => map.MapFrom(loanItem => loanItem.Item));
            //    cfg.CreateMap<LoanItemDTO, LoanItem>()
            //        .ForMember(loanItem => loanItem.Item, map => map.MapFrom(loanItemDTO => loanItemDTO.Item));

            //    cfg.CreateMap<HardwareItem, HardwareItemDTO>();
            //    cfg.CreateMap<HardwareItemDTO, HardwareItem>();
            //});
        }
Exemplo n.º 2
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <TodoItem, TodoItemDTO>()
                .ForMember(todoItemDTO => todoItemDTO.Items,
                           map => map.MapFrom(todoItem => todoItem.Items));
                cfg.CreateMap <TodoItemDTO, TodoItem>()
                .ForMember(todoItem => todoItem.Items,
                           map => map.MapFrom(todoItemDTO => todoItemDTO.Items));

                cfg.CreateMap <Item, ItemDTO>();
                cfg.CreateMap <ItemDTO, Item>();
            });


            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new ServiceDBInitializer());
        }
Exemplo n.º 3
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options, (configuration, builder) =>
            {
                jiujitsutoolbox_apiContext context = new jiujitsutoolbox_apiContext();
                builder.RegisterInstance(context).As <jiujitsutoolbox_apiContext>().SingleInstance();
            }));

            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

            var matches = config.Formatters
                          .Where(f => f.SupportedMediaTypes
                                 .Where(m => m.MediaType.ToString() == "application/xml" || m.MediaType.ToString() == "text/xml").Count() > 0)
                          .ToList();

            foreach (var match in matches)
            {
                config.Formatters.Remove(match);
            }

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            var migrator = new DbMigrator(new Configuration());

            migrator.Update();
        }
Exemplo n.º 4
0
        static PushNotificationsService()
        {
            var options = new ConfigOptions();
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            Services = new ApiServices(config);
        }
Exemplo n.º 5
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            TwitterCredentials.ApplicationCredentials = TwitterCredentials.CreateCredentials(
                "3004124297-RR9ZNwofkwnt7ATF3fefQllHtDGgNH3u442QUWo",
                "0XymIsK4bTDvzmz2xw4snubmLlvHp9oHeZa8EapWEVL9S",
                "dQPcIhiNdtHAchfx7ZbsjeDAW",
                "V53RXnrRhpq6ReHa6qtRKi5J5IhLz5HzYCyXAJP031krCzreur");

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new powerpollInitializer());
            var task = new Task(() =>
                                MonitorTwitter.monitor(),
                                TaskCreationOptions.LongRunning
                                );

            task.Start();
        }
        static NotificationHelper()
        {
            ConfigOptions     options = new ConfigOptions();
            HttpConfiguration config  = ServiceConfig.Initialize(new ConfigBuilder(options));

            Services = new ApiServices(config);
        }
Exemplo n.º 7
0
        public static void Register()
        {
            ConfigOptions options = new ConfigOptions
            {
                PushAuthorization        = AuthorizationLevel.Application,
                DiagnosticsAuthorization = AuthorizationLevel.Anonymous,
            };

            options.LoginProviders.Remove(typeof(AzureActiveDirectoryLoginProvider));
            options.LoginProviders.Add(typeof(AzureActiveDirectoryExtendedLoginProvider));

            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // Now add any missing connection strings and app settings from the environment.
            // Any envrionment variables found with names that match existing connection
            // string and app setting names will be used to replace the value.
            // This allows the Web.config (which typically would contain secrets) to be
            // checked in, but requires people running the tests to config their environment.
            IServiceSettingsProvider  settingsProvider = config.DependencyResolver.GetServiceSettingsProvider();
            ServiceSettingsDictionary settings         = settingsProvider.GetServiceSettings();
            IDictionary environmentVariables           = Environment.GetEnvironmentVariables();

            foreach (var conKey in settings.Connections.Keys.ToArray())
            {
                var envKey = environmentVariables.Keys.OfType <string>().FirstOrDefault(p => p == conKey);
                if (!string.IsNullOrEmpty(envKey))
                {
                    settings.Connections[conKey].ConnectionString = (string)environmentVariables[envKey];
                }
            }

            foreach (var setKey in settings.Keys.ToArray())
            {
                var envKey = environmentVariables.Keys.OfType <string>().FirstOrDefault(p => p == setKey);
                if (!string.IsNullOrEmpty(envKey))
                {
                    settings[setKey] = (string)environmentVariables[envKey];
                }
            }

            // Emulate the auth behavior of the server: default is application unless explicitly set.
            config.Properties["MS_IsHosted"] = true;

            config.Formatters.JsonFormatter.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <IntIdRoundTripTableItem, IntIdRoundTripTableItemDto>()
                .ForMember(dto => dto.Id, map => map.MapFrom(db => MySqlFuncs.LTRIM(MySqlFuncs.StringConvert(db.Id))));
                cfg.CreateMap <IntIdRoundTripTableItemDto, IntIdRoundTripTableItem>()
                .ForMember(db => db.Id, map => map.MapFrom(dto => MySqlFuncs.LongParse(dto.Id)));

                cfg.CreateMap <IntIdMovie, IntIdMovieDto>()
                .ForMember(dto => dto.Id, map => map.MapFrom(db => MySqlFuncs.LTRIM(MySqlFuncs.StringConvert(db.Id))));
                cfg.CreateMap <IntIdMovieDto, IntIdMovie>()
                .ForMember(db => db.Id, map => map.MapFrom(dto => MySqlFuncs.LongParse(dto.Id)));
            });

            Database.SetInitializer(new DbInitializer());
        }
Exemplo n.º 8
0
        public void Initialize()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            //config.Formatters.Clear();
            //config.Formatters.Add(new JsonMediaTypeFormatter());

            //Read more about it
            // http://www.asp.net/web-api/overview/formats-and-model-binding/json-and-xml-serialization#handling_circular_object_references
            // to prevent cycle references
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling      = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;

            // this is the default and by default is used Json.net
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer = false;

            AutoMapperConfig();

            var migrator = new DbMigrator(new Configuration());

            migrator.Update();
        }
Exemplo n.º 9
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();
            //options.LoginProviders.Remove(typeof(GoogleLoginAuthenticationProvider));
            //options.LoginProviders.Add(typeof(GoogleLoginAuthenticationProvider));

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            bool isDemoMode;
            var  boolString = System.Configuration.ConfigurationManager.AppSettings["IsDemoMode"];

            if (bool.TryParse(boolString, out isDemoMode))
            {
                IsDemoMode = isDemoMode;
            }

            int maxCount;
            var intString = System.Configuration.ConfigurationManager.AppSettings["MaxLeagueMembershipCount"];

            if (int.TryParse(intString, out maxCount))
            {
                MaxLeagueMembershipCount = maxCount;
            }

            //config.SetIsHosted(true);
            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            //var migrator = new DbMigrator(new Configuration());
            //migrator.Update();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes the specified EntitySchemaQuery filters.
        /// </summary>
        /// <param name="userConnection">User connection.</param>
        /// <param name="processActivity">Process activity.</param>
        /// <param name="entitySchema">Entity schema.</param>
        /// <param name="esq">Instance of the EntitySchemaQuery class.</param>
        /// <param name="dataSourceFilters">Serialized filters.</param>
        public static void SpecifyESQFilters(UserConnection userConnection, ProcessActivity processActivity,
                                             EntitySchema entitySchema, EntitySchemaQuery esq, string dataSourceFilters)
        {
            userConnection.CheckArgumentNull("userConnection");
            processActivity.CheckArgumentNull("processActivity");
            entitySchema.CheckArgumentNull("entitySchema");
            esq.CheckArgumentNull("esq");
            if (string.IsNullOrEmpty(dataSourceFilters))
            {
                return;
            }
            IEntitySchemaQueryFilterItem esqFilter;
            var userConnectionArgument             = new ConstructorArgument("userConnection", userConnection);
            var processDataContractFilterConverter = ClassFactory
                                                     .Get <IProcessDataContractFilterConverter>(userConnectionArgument);

            if (processDataContractFilterConverter.GetIsDataContractFilter(dataSourceFilters))
            {
                ServiceConfig.Initialize();
                esqFilter = processDataContractFilterConverter.ConvertToEntitySchemaQueryFilterItem(esq,
                                                                                                    processActivity.Owner, dataSourceFilters);
            }
            else
            {
                DataSourceFilterCollection filterCollection = ConvertToProcessDataSourceFilterCollection(userConnection,
                                                                                                         entitySchema, processActivity, dataSourceFilters);
                esqFilter = filterCollection.ToEntitySchemaQueryFilterCollection(esq);
            }
            esq.Filters.Add(esqFilter);
        }
Exemplo n.º 11
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            options.LoginProviders.Add(typeof(helpsLoginProvider));

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            // Set default and null value handling to "Include" for Json Serializer
            config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling    = Newtonsoft.Json.NullValueHandling.Include;
            config.SetIsHosted(true);

            ExceptionlessClient.Default.RegisterWebApi(config);

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            Database.SetInitializer(new helpsInitializer());
            var migrator = new DbMigrator(new Configuration());
            //migrator.Update();
        }
Exemplo n.º 12
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            var options = new ConfigOptions();

            options.LoginProviders.Remove(typeof(AzureActiveDirectoryLoginProvider));
            options.LoginProviders.Add(typeof(AzureActiveDirectoryExtendedLoginProvider));
            options.LoginProviders.Add(typeof(FBLoginProvider));
            options.LoginProviders.Add(typeof(VKLoginProvider));
            // Use this class to set WebAPI configuration options
            var config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling       = DefaultValueHandling.Include;
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling          = NullValueHandling.Include;
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling      = ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling =
                PreserveReferencesHandling.Objects;
            config.MessageHandlers.Add(new ThrottlingHandler
            {
                Policy = new ThrottlePolicy(5)
                {
                    IpThrottling = true
                },
                Repository = new CacheRepository()
            });
            Mapper.Initialize(cfg => { DTOMapper.CreateMapping(cfg); });

            //var migrator = new DbMigrator(new Configuration());
            // migrator.Update();
            //  Database.SetInitializer(new appartmenthostInitializer());
        }
Exemplo n.º 13
0
        public static void Register()
        {
            //Fire-up SignalR
            SignalRExtensionConfig.Initialize();



            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();



            //Allow only users to use our SignalR-Hub
            options.SetRealtimeAuthorization(AuthorizationLevel.User);


            ConfigBuilder builder = new ConfigBuilder(options, (httpConfig, autofac) => {
                autofac.RegisterInstance(new TableLoggingService()).As <ILoggingService>();
            });


            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(builder);

            //Just a sample, on how to set the required options to get rid
            //of some of the sample page error-messages.
            //You can read more here: http://blogs.msdn.com/b/yaohuang1/archive/2012/10/13/asp-net-web-api-help-page-part-2-providing-custom-samples-on-the-help-page.aspx
            config.SetSampleForType(
                "Currently not used.",
                new MediaTypeHeaderValue("application/x-www-form-urlencoded"),
                typeof(OldSchoolArtist));

            //YOU CAN USE THE RESOURCE BROKER AFTER THE ASSEMBLIES FOR
            //THE MANAGED BACKEND USE THE LATEST WEB-API ASSEMBLIES

            //This is directly taken from the documenation about resource
            //Controllers on GitHub (created by the Azure Mobile Services Team)
            //https://github.com/Azure/azure-mobile-services-resourcebroker
            // Create a custom route mapping the resource type into the URI.
            //var resourcesRoute = config.Routes.CreateRoute(
            //                         routeTemplate: "api/resources/{type}",
            //                         defaults: new { controller = "resources" },
            //                         constraints: null);

            // Insert the ResourcesController route at the top of the collection to avoid conflicting with predefined routes.
            //config.Routes.Insert(0, "Resources", resourcesRoute);


            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new OldSchoolBeatsInitializer());

            //trigger migrations manually
            //var migrator = new DbMigrator(new Configuration());
            //migrator.Update();
        }
Exemplo n.º 14
0
        /// <summary>Method called by Azure Mobile Services</summary>
        public static HttpConfiguration Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            return(config);
        }
Exemplo n.º 15
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling      = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
        }
Exemplo n.º 16
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Restaurant, RestaurantDTO>()
                .ForMember(restaurantDTO => restaurantDTO.Feedback,
                           map => map.MapFrom(restaurant => restaurant.Feedback))
                .ForMember(restaurantDTO => restaurantDTO.Cuisine,
                           map => map.MapFrom(restaurant => restaurant.Cuisine))
                .ForMember(restaurantDTO => restaurantDTO.StoreTime,
                           map => map.MapFrom(restaurant => restaurant.StoreTime))
                .ForMember(restaurantDTO => restaurantDTO.Menu,
                           map => map.MapFrom(restaurant => restaurant.Menu));

                cfg.CreateMap <RestaurantDTO, Restaurant>()
                .ForMember(restaurant => restaurant.Feedback,
                           map => map.MapFrom(restaurantDTO => restaurantDTO.Feedback))
                .ForMember(restaurant => restaurant.Cuisine,
                           map => map.MapFrom(restaurantDTO => restaurantDTO.Cuisine))
                .ForMember(restaurant => restaurant.StoreTime,
                           map => map.MapFrom(restaurantDTO => restaurantDTO.StoreTime))
                .ForMember(restaurant => restaurant.Menu,
                           map => map.MapFrom(restaurantDTO => restaurantDTO.Menu));

                cfg.CreateMap <Admin, AdminDTO>()
                .ForMember(adminDTO => adminDTO.Restaurant,
                           map => map.MapFrom(admin => admin.Restaurant));

                cfg.CreateMap <AdminDTO, Admin>()
                .ForMember(admin => admin.Restaurant,
                           map => map.MapFrom(adminDTO => adminDTO.Restaurant));

                cfg.CreateMap <Feedback, FeedbackDTO>();
                cfg.CreateMap <FeedbackDTO, Feedback>();

                cfg.CreateMap <StoreTime, StoreTimeDTO>();
                cfg.CreateMap <StoreTimeDTO, StoreTime>();

                cfg.CreateMap <Menu, MenuDTO>();
                cfg.CreateMap <MenuDTO, Menu>();
            });

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new MobileServiceInitializer());
        }
Exemplo n.º 17
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
        }
Exemplo n.º 18
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

#if DEBUG
            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
#endif

            Database.SetInitializer(new MobileServiceInitializer());
        }
Exemplo n.º 19
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CustomContractResolver(config.Formatters.JsonFormatter);

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new MobileServiceInitializer());
        }
Exemplo n.º 20
0
        /// <summary>
        /// The register.
        /// </summary>
        public void Initialize()
        {
            // Use this class to set configuration options for your mobile service
            var options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            var migrator = new DbMigrator(new Configuration());

            migrator.Update();
        }
Exemplo n.º 21
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            options.LoginProviders.Add(typeof(LinkedInLoginProvider));

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new DotNetRuntimeAuthInitializer());
        }
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            var options = new ConfigOptions
            {
                CorsPolicy = new System.Web.Http.Cors.EnableCorsAttribute("*", "*", "*")
            };

            // Use this class to set WebAPI configuration options
            var config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new MobileServiceInitializer());
        }
Exemplo n.º 23
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            //config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            //var formatters = config.Formatters;
            //var jsonFormatter = formatters.JsonFormatter;
            //var settings = jsonFormatter.SerializerSettings;
            //settings.Formatting = Formatting.Indented;
            //settings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            // Elastic Scale must ensure data consistency
            //Database.SetInitializer(new mpbdmInitializer());

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Groups, MobileGroup>().ReverseMap();
                cfg.CreateMap <Favorites, MobileFavorites>().ReverseMap();
            });


            // sharding GLOBAL
            ShardingObj = new Sharding();


            //ShardingObj.RegisterNewShard(server, shard1, connectionString, company1);
            //ShardingObj.RegisterNewShard(server, shard2, connectionString, company2);

            // Register the mapping of the tenant to the shard in the shard map.
            // After this step, DDR on the shard map can be used

            /*
             * PointMapping<int> mapping;
             * if (!this.ShardMap.TryGetMappingForKey(key, out mapping))
             * {
             *  this.ShardMap.CreatePointMapping(key, shard);
             * }
             * //*/
        }
Exemplo n.º 24
0
        public static void Register()
        {
            AppServiceExtensionConfig.Initialize();

            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // always send JSON values, even if they have the default value for that type
            config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
        }
Exemplo n.º 25
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // TODO: comment out again
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            // Set default and null value handling to "Include" for Json Serializer
            config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling    = Newtonsoft.Json.NullValueHandling.Include;

            // Map data transfer objects to models
            // using AutoMapper: https://github.com/AutoMapper/AutoMapper/wiki/Getting-started
            Mapper.Initialize(cfg =>
            {
                //Type on the left is source type, type on the right is destination type,
                //thereofre CreateMap<BpCurrentRating, BusinessPartner> allows to map
                //from an instance to the DTO BpCurrentRating to a new instance of
                //the model BusinessPartner
                cfg.CreateMap <MobileBusinessPartner, Rating>();
                //This call to ForMember maps from BpCurrentRating.BusinessPartnerId
                //to BusinessParnter.Id
                //e.g.
                //.ForMember(dst => dst.RatingId, map => map.MapFrom(x => x.RatingId));
                cfg.CreateMap <Rating, MobileBusinessPartner>()
                .ForMember(dst => dst.RatingBpId, map => map.MapFrom(x => x.BusinessPartner.Id))
                .ForMember(dst => dst.ShortName, map => map.MapFrom(x => x.BusinessPartner.ShortName))
                .ForMember(dst => dst.BusinessPartnerId, map => map.MapFrom(x => x.BusinessPartner.BusinessPartnerId));

                cfg.CreateMap <MobileRatingSheet, RatingSheetSection>()
                .ForMember(dst => dst.PartialRatingsInSection, map => map.MapFrom(x => x.PartialRatingsInSection));
                cfg.CreateMap <RatingSheetSection, MobileRatingSheet>()
                .ForMember(dst => dst.PartialRatingsInSection, map => map.MapFrom(x => x.PartialRatingsInSection))
                .ForMember(dst => dst.RatingGuid, map => map.MapFrom(x => x.Rating.Id));
                cfg.CreateMap <MobilePartialRating, PartialRating>();
                cfg.CreateMap <PartialRating, MobilePartialRating>();
            });

            Database.SetInitializer(new ratingtoolInitializer());
        }
Exemplo n.º 26
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            config.SetIsHosted(true);

            Database.SetInitializer(new alltheairgeadInitializer());

            // Configure automapper to map class elements between EntityFramework model and model used in database
            AutoMapper.Mapper.Initialize(cfg =>
            {
                /*********************************************/
                /* Mapping from database type to client type */
                /*********************************************/
                // Map ExpenseId from database to Id for EntityData
                cfg.CreateMap <Expense, ExpenseDto>()
                .ForMember(dst => dst.Id, map => map.MapFrom(src => MySqlFuncs.LTRIM(MySqlFuncs.StringConvert(src.ExpenseId))));
                // Map priority stored as a short in the database to byte in the mobile service
                cfg.CreateMap <Expense, ExpenseDto>()
                .ForMember(dst => dst.Priority, map => map.MapFrom(src => (short)src.Priority));
                // Map category name used in database to id string from EntityFramework
                cfg.CreateMap <Catagory, CategoryDto>()
                .ForMember(dst => dst.Id, map => map.MapFrom(src => src.CategoryName));

                /*********************************************/
                /* Mapping from client type to database type */
                /*********************************************/
                // Map Id from EntityData to ExpenseId for database
                cfg.CreateMap <ExpenseDto, Expense>()
                .ForMember(dst => dst.ExpenseId, map => map.MapFrom(src => MySqlFuncs.LongParse(src.Id)));
                // Map to minimum date for smalldatetime SQL type
                cfg.CreateMap <ExpenseDto, Expense>()
                .ForMember(dst => dst.Time, map => map.MapFrom(src => new DateTime(1900, 1, 1) + ((DateTime)src.Time).TimeOfDay));
                // Map priority stored as a byte in the mobile service to a short in the database
                cfg.CreateMap <ExpenseDto, Expense>()
                .ForMember(dst => dst.Priority, map => map.MapFrom(src => (Byte)src.Priority));
                // Map category id string from EntityFramework to category name used in database
                cfg.CreateMap <CategoryDto, Catagory>()
                .ForMember(dst => dst.CategoryName, map => map.MapFrom(src => src.Id));
            });
        }
Exemplo n.º 27
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            // Set default and null value handling to "Include" for Json Serializer
            config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling    = Newtonsoft.Json.NullValueHandling.Include;

            Database.SetInitializer(new rangermobileInitializer());
        }
Exemplo n.º 28
0
        public static void Register()
        {
            AppServiceExtensionConfig.Initialize();

            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // Enable CORS
            config.EnableCors(new EnableCorsAttribute("*", "*", "*"));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new mobileHOLInitializer());
        }
Exemplo n.º 29
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            options.LoginProviders.Remove(typeof(AzureActiveDirectoryLoginProvider));
            options.LoginProviders.Add(typeof(AzureActiveDirectoryExtendedLoginProvider));

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            //config.SetIsHosted(true); // jeust if we want to debug locally

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new baassiInitializer());
        }
Exemplo n.º 30
0
        public static void Register()
        {
            // Use this class to set configuration options for your mobile service
            ConfigOptions options = new ConfigOptions();

            // Use this class to set WebAPI configuration options
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

            // To display errors in the browser during development, uncomment the following
            // line. Comment it out again when you deploy your service for production use.
            // config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            Database.SetInitializer(new talkerInitializer());

            //Sample Generating in scenarios where there are referencing loops
            //Shuran: http://stackoverflow.com/questions/15029576/samples-not-working-for-web-api-help-page-when-using-an-entity-framework-complex
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling      = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
        }