private void Application_Start(Object sender, EventArgs e) { var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath); var configurer = new InMemoryConfigurer().MainFile(wurflDataFile); var manager = WURFLManagerBuilder.Build(configurer); HttpContext.Current.Cache[WurflManagerCacheKey] = manager; }
public static void Register() { var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath); //var wurflPatchFile = HttpContext.Current.Server.MapPath(WurflPatchFilePath); var configurer = new InMemoryConfigurer() .MainFile(wurflDataFile); //.PatchFile(wurflPatchFile); var manager = WURFLManagerBuilder.Build(configurer); //HttpContext.Current.Cache[WurflManagerCacheKey] = manager; }
/// <summary> /// Initializes the WURFL manager loading any required data and returns the instance. /// </summary> /// <param name="context">HTTP context</param> /// <param name="wurflDataPath">Relative WURFL data path</param> /// <param name="wurflPatchFilePath">Relative WURFL patch file path</param> /// <returns>IWURFLManager</returns> private static IWURFLManager InitializeWurflManager(HttpContext context, String wurflDataPath, String wurflPatchFilePath) { // Get the absolute path of required data files var wurflDataFile = context.Server.MapPath(wurflDataPath); var wurflPatchFile = context.Server.MapPath(wurflPatchFilePath); // Initializes the WURFL infrastructure var configurer = new InMemoryConfigurer() .MainFile(wurflDataFile) .PatchFile(wurflPatchFile); var manager = WURFLManagerBuilder.Build(configurer); // Cache manager (and managed data) for later use context.Cache[WurflManagerCacheKey] = manager; return(manager); }
protected void Application_Start() { RegisterUnityContainer(); AutoMapperSettings.RegisterControllerAutoMappers(); AutoMapperSettings.RegisterServiceAutoMappers(); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //DateTime time = DateTime.Now; var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath); var configurer = new InMemoryConfigurer() .MainFile(wurflDataFile); WURFLManagerBuilder.Build(configurer); //DateTime time2 = DateTime.Now; //var wurfltime = time.Millisecond - time2.Millisecond; //var breakhere = true; }
public void Initial() { string wurflDataFile = HttpContext.Current.Server.MapPath(Constants.WurflDataFilePath); string wurflPatchFile = HttpContext.Current.Server.MapPath(Constants.WurflPatchFilePath); InMemoryConfigurer configurer = new InMemoryConfigurer().MainFile(wurflDataFile).PatchFile(wurflPatchFile); IWURFLManager manager = WURFLManagerBuilder.Build(configurer); AppCtx.Cache.AddObject(Constants.WurflManagerCacheKey, manager); #region 初始化所有的设备组实现类 if (deviceGroups == null) { deviceGroups = new List <IDeviceGroup>(); } if (deviceGroups.Count == 0) { GeneralConfigInfo si = GeneralConfigs.GetConfig(); if (string.IsNullOrEmpty(si.DeviceGroups)) { Exception ex = new Exception("请配置IDeviceGroup设备组接口的实现类,在general.config里配置。"); Framework.LogHelper.WriteLog(GetType(), ex); throw ex; } string[] DeviceGroups = si.DeviceGroups.Split(';'); foreach (string s in DeviceGroups) { Assembly assembly = Assembly.Load(s.Split(',')[1]); string className = s.Split(',')[0]; IDeviceGroup gGroup = (IDeviceGroup)assembly.CreateInstance(className, true); gGroup.Initial(); deviceGroups.Add(gGroup); } deviceGroups.Sort(new DeviceGroupComparer()); deviceGroups.Reverse(); } #endregion }
public DeviceInfoHelper() { try { string wurflDataFile; if (HttpContext.Current != null) wurflDataFile = HttpContext.Current.Server.MapPath("~/App_Data/"); else wurflDataFile = "../../app_data/"; DirectoryInfo directory = new DirectoryInfo(wurflDataFile); if (!directory.Exists) directory.Create(); wurflDataFile += "wurfl-latest.zip"; Assembly asm = Assembly.GetExecutingAssembly(); //will loop tru all assembly files string wurflLatest = asm.GetManifestResourceNames().FirstOrDefault(n => n.Contains("wurfl-latest.zip")); if (wurflLatest != null) { Stream stream = asm.GetManifestResourceStream(wurflLatest); using (FileStream fileStream = new FileStream(wurflDataFile, FileMode.Create)) stream?.CopyTo(fileStream); } //string wurflPatchFile = HttpContext.Current.Server.MapPath("~/App_Data/web_browsers_patch.xml"); IWURFLConfigurer configurer = new InMemoryConfigurer().MainFile(wurflDataFile); //.PatchFile(wurflPatchFile); WURFLManagerBuilder.Build(configurer); } catch (Exception) { // There was an issue creating the table. Probably because the tables has aspnet_ attached to the tables names // Just rolling back } }