public override bool Match(DataRow dr, FormatterConfig formatterConfig) { //bool isAppendUpdateMode = Engine.CurrentSheetConfig.Mode == Constants.SHEET_MODE_Append; //bool isMatch = isAppendUpdateMode && IsSmiliarDataRowExistsInExcel(dr, formatterConfig); bool isMatch = IsSmiliarDataRowExistsInExcel(dr, formatterConfig); return isMatch; }
public override bool Match(DataRow dr, FormatterConfig formatterConfig) { if (Engine.CurrentSheetConfig.Mode == Constants.SHEET_MODE_Refresh) return false; bool isAppendUpdateMode = Engine.CurrentSheetConfig.Mode == Constants.SHEET_MODE_Append; bool isDataRowExistsInExcel = (Engine.IsDataRowExistsOrExpires(dr) != DataRowExistsOrExpires.NotExists); bool isMatch = isAppendUpdateMode && !isDataRowExistsInExcel; return isMatch; }
/// <summary> /// Specifies how the ASP.NET application will respond to individual HTTP request. /// </summary> /// <param name="app">Instance of <see cref="IAppBuilder"/>.</param> public void Configuration(IAppBuilder app) { CorsConfig.ConfigureCors(ConfigurationManager.AppSettings["cors"]); app.UseCors(CorsConfig.Options); var configuration = new HttpConfiguration(); AutofacConfig.Configure(configuration); app.UseAutofacMiddleware(AutofacConfig.Container); FormatterConfig.Configure(configuration); RouteConfig.Configure(configuration); ServiceConfig.Configure(configuration); app.UseWebApi(configuration); }
public override bool Match(DataRow dr, FormatterConfig formatterConfig) { string source = Utility.GetDataRowContent(dr, formatterConfig.ExtractFrom); string oper = Rule.Split(':')[0]; string num = Rule.Split(':')[1]; long n = long.Parse(num); if (oper.Trim() == "less_than") return long.Parse(source) < n; else if (oper.Trim() == "greater_than") return long.Parse(source) > n; else if (oper.Trim() == "equal") return long.Parse(source) == n; throw new ArgumentException(string.Format("Not recognized operator {0} ...", oper)); }
protected void Application_Start() { var formatters = GlobalConfiguration.Configuration.Formatters; var jsonFormatter = formatters.JsonFormatter; var settings = jsonFormatter.SerializerSettings; settings.Formatting = Formatting.Indented; settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); FormatterConfig.RegisterFormatters(GlobalConfiguration.Configuration.Formatters); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Slapper.AutoMapper.Configuration.IdentifierConventions.Add(type => type.Name + "_Id"); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); FormatterConfig.RegisterFormatters(GlobalConfiguration.Configuration.Formatters); GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.IsoDateFormat, DateTimeZoneHandling = DateTimeZoneHandling.Local, }; GlobalData.InitSessionDictionary(); //GlobalConfiguration.Configuration.MessageHandlers.Add(new CorsHandler()); }
protected void Application_Start(object sender, EventArgs e) { GlobalConfiguration.Configure(config => { RouterConfig.Configure(config); /* GlobalConfiguration.Configure(configuration => * { * configuration.Routes.MapHttpRoute( * name: "DefaulApi", * routeTemplate: "api/{controller}/{id}", * defaults: new { id = RouteParameter.Optional }); * * }); */ FormatterConfig.Configure(config); }); }
protected void Application_Start() { //AreaRegistration.RegisterAllAreas(); //GlobalConfiguration.Configure(WebApiConfig.Register); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //RouteConfig.RegisterRoutes(RouteTable.Routes); //Http Client Protocol Settings System.Net.ServicePointManager.Expect100Continue = false; System.Net.ServicePointManager.MaxServicePointIdleTime = 60 * 60 * 1000;//60 Minutes ServicePointManager.DefaultConnectionLimit = 132; FileInfo fi = new FileInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\web.config"); log4net.Config.XmlConfigurator.ConfigureAndWatch(fi); Assembly assem = Assembly.GetExecutingAssembly(); AssemblyName assemName = assem.GetName(); AggieGlobalLogManager.Info("================================================================="); AggieGlobalLogManager.Info("Starting SKYSITE-Web-API-Service v{0}", assemName.Version); AggieGlobalLogManager.Info("================================================================="); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); FilterConfig.RegisterHttpFilters(GlobalConfiguration.Configuration.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); FormatterConfig.RegisterFormatters(GlobalConfiguration.Configuration.Formatters); HandlerConfig.RegisterHandlers(GlobalConfiguration.Configuration.MessageHandlers); //Instnatiate the one & only instance of GlobalApp - facade design pattern to Provide an unified interface to a set of interfaces to deal with business functions if (_theGlobalApp == null) { string dbConnectionStringName = "AggieGlobalDB"; GlobalApp.Initialize(dbConnectionStringName); _theGlobalApp = GlobalApp.Instance; } }
/// <summary> /// This code configures Web API. /// The TestWebApiStartup class is specified as a type parameter in the WebApp.Start method. /// </summary> /// <param name="appBuilder">The application builder.</param> public void NorthwindConfiguration(IAppBuilder appBuilder) { var config = new HttpConfiguration { IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always }; var server = new HttpServer(config); WebApiConfig.Register(config); appBuilder.UseWebApi(server); config .EnableSwagger(c => { // Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to // hold additional metadata for an API. Version and title are required but you can also provide // additional fields by chaining methods off SingleApiVersion. // c.SingleApiVersion("v1", "A title for your API"); // Wrap the default SwaggerGenerator with additional behavior (e.g. caching) or provide an // alternative implementation for ISwaggerProvider with the CustomProvider option. // c.CustomProvider(defaultProvider => new ODataSwaggerProvider(defaultProvider, c, config)); }) .EnableSwaggerUi(); FormatterConfig.Register(config); config.Services.Replace(typeof(IHttpControllerSelector), new RestierControllerSelector(config)); #if Restier var customSwaggerRoute = await config.MapRestierRoute <EntityFrameworkApi <NorthwindContext> >("RESTierRoute", "restier", new RestierBatchHandler(server)); config.AddCustomSwaggerRoute(customSwaggerRoute, "/Customers({CustomerId})/Orders({OrderId})") .Operation(HttpMethod.Get) .PathParameter <string>("CustomerId") .PathParameter <int>("OrderId"); #endif config.EnsureInitialized(); }
private bool IsSmiliarDataRowExistsInExcel(DataRow dr, FormatterConfig fc) { string rowMode = (string)dr[Constants.COLUMN_RowMode]; if (rowMode == Constants.ROW_MODE_Append) { string newOne = (string)dr[fc.ExtractFrom]; if (string.IsNullOrEmpty(newOne)) return false; foreach (DataRow row in Engine.ExcelSet.Tables[Engine.CurrentSheetConfig.Name].Rows) { string oldOne = row[fc.ExtractFrom].ToString(); if (string.IsNullOrEmpty(oldOne)) continue; if (Regex.IsMatch(newOne, oldOne) || Regex.IsMatch(oldOne, newOne)) return true; } } else if (rowMode == Constants.ROW_MODE_Refresh) { string newOne = (string)dr[fc.ExtractFrom]; if (string.IsNullOrEmpty(newOne)) return false; foreach (DataRow row in Engine.MetadataSet.Tables[Engine.CurrentSheetConfig.Name].Rows) { if (row == dr) continue; string oldOne = row[fc.ExtractFrom].ToString(); if (string.IsNullOrEmpty(oldOne)) continue; if (Regex.IsMatch(newOne, oldOne) || Regex.IsMatch(oldOne, newOne)) return true; } } return false; }
public override bool Match(DataRow dr, FormatterConfig formatterConfig) { string source = Utility.GetDataRowContent(dr, formatterConfig.ExtractFrom); string oper = Rule.Split(':')[0]; string datetime = Rule.Split(':')[1]; DateTime n = DateTime.MinValue; if (datetime.Trim() == "{%now%}") n = DateTime.Now; else n = DateTime.Parse(datetime); if (oper.Trim() == "less_than") return DateTime.Parse(source) < n; else if (oper.Trim() == "greater_than") return DateTime.Parse(source) > n; else if (oper.Trim() == "equal") return DateTime.Parse(source) == n; throw new ArgumentException(string.Format("Not recognized operator {0} ...", oper)); }
public static void Configuration(IAppBuilder appBuilder) { HttpConfiguration config = new HttpConfiguration(); PhysicalFileSystem physicalFileSystem = new PhysicalFileSystem(@".\wwwroot"); FileServerOptions fileOptions = new FileServerOptions(); fileOptions.EnableDefaultFiles = true; fileOptions.RequestPath = PathString.Empty; fileOptions.FileSystem = physicalFileSystem; fileOptions.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" }; fileOptions.StaticFileOptions.FileSystem = fileOptions.FileSystem = physicalFileSystem; fileOptions.StaticFileOptions.ServeUnknownFileTypes = true; fileOptions.EnableDirectoryBrowsing = true; FormatterConfig.ConfigureFormatters(config.Formatters); config.MapHttpAttributeRoutes(); appBuilder.UseWebApi(config); appBuilder.UseFileServer(fileOptions); }
/// <summary> /// Specifies how the ASP.NET application will respond to individual HTTP request. /// </summary> /// <param name="app">Instance of <see cref="IAppBuilder"/>.</param> public void Configuration(IAppBuilder app) { CorsConfig.ConfigureCors(ConfigurationManager.AppSettings["cors"]); app.UseCors(CorsConfig.Options); var configuration = new HttpConfiguration(); AutofacConfig.Configure(configuration); app.UseAutofacMiddleware(AutofacConfig.Container); FormatterConfig.Configure(configuration); RouteConfig.Configure(configuration); ServiceConfig.Configure(configuration); SwaggerConfig.Configure(configuration); app.Use((context, next) => { context.Response.Headers.Remove("Server"); return(next.Invoke()); }); app.UseWebApi(configuration); }
public static HttpConfiguration ConfigureHttpConfig(this IAppBuilder appBuilder, HttpConfiguration config, Action <SwaggerDocsConfig> swaggerDocsConfig, Action <ODataSwaggerDocsConfig> odataSwaggerDocsConfig, params Type[] targetControllers) { var server = new HttpServer(config); appBuilder.UseWebApi(server); config.EnableSwagger(c => { // Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to // hold additional metadata for an API. Version and title are required but you can also provide // additional fields by chaining methods off SingleApiVersion. // c.SingleApiVersion("v1", "A title for your API"); // Wrap the default SwaggerGenerator with additional behavior (e.g. caching) or provide an // alternative implementation for ISwaggerProvider with the CustomProvider option. // c.CustomProvider(defaultProvider => new ODataSwaggerProvider(defaultProvider, c, config).Configure(odataSwaggerDocsConfig)); //Add the xml comments File var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var commentsFileName = "SwashbuckleODataSample.XML"; var commentsFile = Path.Combine(baseDirectory, commentsFileName); if (File.Exists(commentsFile)) { c.IncludeXmlComments(commentsFile); } // Apply test-specific configs swaggerDocsConfig?.Invoke(c); }).EnableSwaggerUi(); FormatterConfig.Register(config); config.Services.Replace(typeof(IHttpControllerSelector), new UnitTestControllerSelector(config, targetControllers)); return(config); }
public abstract bool Match(DataRow dr, FormatterConfig formatterConfig);
public override bool Match(DataRow dr, FormatterConfig formatterConfig) { return Engine.CurrentSheetConfig.Mode == Constants.SHEET_MODE_Refresh; }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); FormatterConfig.RegisterFormatters(GlobalConfiguration.Configuration.Formatters); }