protected void Application_Start(object sender, EventArgs e) { String l_strDataSource = OAConfig.GetConfig("数据库", "DataSource"); String l_strDatabase = OAConfig.GetConfig("数据库", "DataBase"); String l_strUserId = OAConfig.GetConfig("数据库", "uid"); String l_strPassword = OAConfig.GetConfig("数据库", "pwd"); //初始化数据库连接 if (!Entity.InitDB(ConstString.Miscellaneous.DATA_BASE_TYPE, l_strDataSource, l_strDatabase, l_strUserId, l_strPassword, 30)) { throw new Exception("数据库连接错误"); } SQLHelper.InitDB1(OAConfig.GetConfig("数据库", "ADIMSqlServer")); SQLHelper.InitDB2(OAConfig.GetConfig("数据库", "AgilePointSqlServer")); //自动阅知 AutoRead.Instance.TimerStart(); //自动迁移旧数据 AutoBackup.Instance.TimerStart(); //把XML文件加载到缓存中 string strPath = AppDomain.CurrentDomain.BaseDirectory + @"Config\SelectGroup.xml"; if (!string.IsNullOrEmpty(strPath)) { XmlDocument doc = new XmlDocument(); doc.Load(strPath); DataCache cache = new DataCache(); cache.ExpireTime = 1440; cache.CacheName = "SelectGroup"; cache.CacheItemName = "SelectGroupItem"; cache.SetCache(doc); } }
public static DataCache GetCache() { if (_cache != null) return _cache; //Define Array for 1 Cache Host List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>(1); //Specify Cache Host Details // Parameter 1 = host name // Parameter 2 = cache port number servers.Add(new DataCacheServerEndpoint("192.168.1.31", 22233)); //Create cache configuration DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration(); //Set the cache host(s) configuration.Servers = servers; //Set default properties for local cache (local cache disabled) configuration.LocalCacheProperties = new DataCacheLocalCacheProperties(); //Disable tracing to avoid informational/verbose messages on the web page DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off); //Pass configuration settings to cacheFactory constructor _factory = new DataCacheFactory(configuration); //Get reference to named cache called "default" _cache = _factory.GetCache("default"); return _cache; }
public override void Run() { DataCache dataCache = null; var roleInstanceId = RoleEnvironment.CurrentRoleInstance.Id; while (true) { if (dataCache == null) { try { dataCache = new DataCache("default"); } catch (DataCacheException) { Thread.Sleep(1000); continue; } } var value = dataCache.Get("Tim"); if (value != null) { EventLog.WriteEntry( string.Concat("AzureCache ", roleInstanceId), string.Concat("Tim = ", (string)value)); // Uncomment for Azure testing. // dataCache.Put("Tim", string.Concat((string)value, RoleEnvironment.CurrentRoleInstance.Id)); } Thread.Sleep(2000); } }
public static DataCache GetCache() { if (_cache != null) { return _cache; } //Define Array for 1 Cache Host var servers = new List<DataCacheServerEndpoint>(1); //Specify Cache Host Details // Parameter 1 = host name // Parameter 2 = cache port number servers.Add(new DataCacheServerEndpoint("DevMongoDB2", 22233)); //Create cache configuration var configuration = new DataCacheFactoryConfiguration { Servers = servers, LocalCacheProperties = new DataCacheLocalCacheProperties() }; //Disable tracing to avoid informational/verbose messages on the web page DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off); //Pass configuration settings to cacheFactory constructor //_factory = new DataCacheFactory(configuration); _factory = new DataCacheFactory(configuration: configuration); //Get reference to named cache called "default" _cache = _factory.GetCache("default"); return _cache; }
public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder) { var region = shellSettings.Name; // Azure Cache supports only alphanumeric strings for regions, but Orchard supports some // non-alphanumeric characters in tenant names. Remove all non-alphanumering characters // from the region, and append the hash code of the original string to mitigate the risk // of two distinct original region strings yielding the same transformed region string. _regionAlphaNumeric = new String(Array.FindAll(region.ToCharArray(), Char.IsLetterOrDigit)) + region.GetHashCode().ToString(CultureInfo.InvariantCulture); _cache = cacheHolder.TryGetDataCache(() => { CacheClientConfiguration cacheConfig; try { cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix); cacheConfig.Validate(); } catch (Exception ex) { throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex); } var cache = cacheConfig.CreateCache(); cache.CreateRegion(_regionAlphaNumeric); return cache; }); }
//static FillAppFabricCache() //{ // DataCacheFactory factory = new DataCacheFactory(); // _cache = factory.GetCache("default"); // //Debug.Assert(_cache == null); //} public FillAppFabricCache(CancellationToken ct, DataCache cache, byte[] probeTemplate, ArrayList fingerList) { _ct = ct; _cache = cache; _probeTemplate = probeTemplate; _fingerList = fingerList; }
internal static void Main(string[] args) { DataCache svr = new DataCache(); svr.Init(args); svr.Loop(); svr.Release(); }
public async Task<Video> CreateVideoAsync(string title, string description, string name, string type, Stream dataStream) { // Create an instance of the CloudMediaContext var mediaContext = new CloudMediaContext( CloudConfigurationManager.GetSetting("MediaServicesAccountName"), CloudConfigurationManager.GetSetting("MediaServicesAccountKey")); // Create the Media Services asset from the uploaded video var asset = mediaContext.CreateAssetFromStream(name, title, type, dataStream); // Get the Media Services asset URL var videoUrl = mediaContext.GetAssetVideoUrl(asset); // Launch the smooth streaming encoding job and store its ID var jobId = mediaContext.ConvertAssetToSmoothStreaming(asset, true); var video = new Video { Title = title, Description = description, SourceVideoUrl = videoUrl, JobId = jobId }; this.context.Videos.Add(video); await this.context.SaveChangesAsync(); var cache = new DataCache(); cache.Remove("videoList"); return video; }
public static IDependencyResolver UseAppFabric(this IDependencyResolver resolver, String eventKey, TimeSpan cacheRecycle, DataCache dc) { var bus = new Lazy<AppFabricMessageBus>(() => new AppFabricMessageBus(resolver, eventKey, cacheRecycle, dc)); resolver.Register(typeof(IMessageBus), () => bus.Value); return resolver; }
internal DistributeCache(DataCache dataCache, string cacheName, string regionName) { this.dataCache = dataCache; this.cacheName = cacheName; this.regionName = regionName; this.asyncUpdateInterval = CacheSettings.Instance.GetAsyncUpdateInterval(cacheName, regionName); }
public AzureCacheStore(DataCache cache, string cacheRegion) { _cacheRegion = cacheRegion; _cache = cache; if (!string.IsNullOrEmpty(_cacheRegion)) _cache.CreateRegion(_cacheRegion); }
public void ShouldReturnNotNullInstances() { var cache = new DataCache(); Assert.NotNull(cache.Empty); Assert.NotNull(cache.MonitorConfigs); Assert.NotNull(cache.MonitorInfo); }
public void TestGetInvalid () { RunAsync (async delegate { var cache = new DataCache (); var data = await cache.GetAsync<WorkspaceData> (Guid.NewGuid ()); Assert.IsNull (data); }); }
public void TestTryGetInvalid () { var cache = new DataCache (); WorkspaceData data; var success = cache.TryGetCached (Guid.NewGuid (), out data); Assert.IsFalse (success); Assert.IsNull (data); }
public LookUp(ArrayList fingerList, int gender, byte[] probeTemplate, DataCache cache, CancellationToken ct) { _fingerList = fingerList; _gender = gender; _probeTemplate = probeTemplate; _cache = cache; _ct = ct; }
public DataCache TryGetDataCache(Func<DataCache> builder) { lock (_synLock) { if (_dataCache != null) { return _dataCache; } return _dataCache = builder(); } }
public RealTest(string title, List<string> headers, UserCache userCache) { this.title = title; this.headers = headers; UserCache = userCache; DataCache = new DataCache(); testResults = new List<RowResult>(); ChildInstructions = new List<IInstruction>(); }
protected override void InitialiseInternal() { if (_cache == null) { var cacheName = CacheConfiguration.Current.DefaultCacheName.Replace(".", "-"); Log.Debug("AppFabricCache.Initialise - initialising with cache name: {0}", cacheName); _factory = new DataCacheFactory(); _cache = _factory.GetCache(cacheName); } }
private static DataCache GetCache() { if (_cache != null) return _cache; var configuration = new DataCacheFactoryConfiguration(); _factory = new DataCacheFactory(configuration); _cache = _factory.GetCache("default"); return _cache; }
public FillAppFabricCache(BlockingCollection<int> bc, SendOrPostCallback callback, ArrayList fingerList, int maxPoolSize, CancellationToken ct, DataCache cache) { _bc = bc; _callback = callback; _fingerList = fingerList; _maxPoolSize = maxPoolSize; _ct = ct; _cache = cache; //_context = context; }
public AzureDataCacheIndexInput(string name, string cacheRegion, DataCache persistantCache) { _persistantCache = persistantCache; _name = name; _cacheRegion = cacheRegion; var data = _persistantCache.Get(name, _cacheRegion); byte[] streamData = data == null ? new byte[] { } : (byte[])data; _stream = new MemoryStream(streamData, false); }
public AzureDataCacheIndexOutput(string name, string sizeName, string cacheRegion, string modifiedName, DataCacheTag modifiedTag, DataCache persistantCache) { _name = name; _sizeName = sizeName; _persistantCache = persistantCache; _cacheRegion = cacheRegion; _modifiedName = modifiedName; _modifiedTag = modifiedTag; _stream = new MemoryStream(); }
Tweets getTweets(string name) { DataCache cache = new DataCache(); Tweets entries = cache.Get(name) as Tweets; if (entries == null) { entries = TwitterFeed.GetTweets(name); cache.Add(name, entries); } return entries; }
public void AddInfo(DataCache _cache, string key, string value) { try { _cache.Add(key, value); } catch (Exception) { throw new Exception("Ocorreu uma exceção inesperada"); } }
/// <summary> /// Creates an instance of the class. /// </summary> /// <param name="regionName">The name of the NHibernate region the adapter is for.</param> protected AppFabricCacheAdapter(string regionName) { RegionName = regionName; if (!string.IsNullOrEmpty(AppFabricProviderSettings.Settings.SerializationProvider)) _serializationProvider = Activator.CreateInstance(ReflectHelper.ClassForName(AppFabricProviderSettings.Settings.SerializationProvider)) as ISerializationProvider; else { _serializationProvider = null; } _lockHandles = new Dictionary<string, DataCacheLockHandle>(); _locksCache = AppFabricCacheFactory.Instance.GetCache(LocksRegionName, true); }
public UserProfile GetUserByIDIncludeEntidade(int id) { m_cache = CacheUtil.GetCache(); DataCacheItemVersion version = null; UserProfile result = (UserProfile)m_cache.Get("UserProfileGetUserByIDIncludeEntidade_" + id, out version); if (result == null) { result = context.UserProfiles.Include("entidade").Single(u => u.UserId == id); m_cache.Put("UserProfileGetUserByIDIncludeEntidade_" + id, result); } return result; }
public static void TestSetUp() { var config = new DataCacheFactoryConfiguration { Servers = new List<DataCacheServerEndpoint> { new DataCacheServerEndpoint("C012A4700", 22233) } }; var factory = new DataCacheFactory(config); cache = factory.GetCache(CacheName); }
public void TestTryGetMiss () { RunAsync (async delegate { var data = await DataStore.PutAsync (new WorkspaceData () { Name = "Testing", }); var pk = data.Id; var cache = new DataCache (); var success = cache.TryGetCached (pk, out data); Assert.IsFalse (success); Assert.IsNull (data); }); }
// Use this for initialization void Start() { runnable = false; changeable = true; triggered = false; virgin = true; touched = false; objMesh = gameObject.GetComponent<Renderer>().material; gameObject.layer = 14; TactileText = GameObject.FindGameObjectWithTag("DynamicText"); t = TactileText.GetComponent<WindowTextController>(); dCache = GameObject.FindGameObjectWithTag("DataCache").GetComponent<DataCache>(); }
Tweets getTweets(string name) { DataCache cache = new DataCache(); Tweets entries = Tweets.FromObject(cache.Get(name)); if (entries == null) { entries = TwitterFeed.GetTweets(name); cache.Add(name, entries.GetBytes()); } return entries; }
public void ClearVocabularyCache() { DataCache.RemoveCache(_CacheKey); }
public void DeleteModuleSetting(int ModuleId, string SettingName) { DataProvider.Instance().DeleteModuleSetting(ModuleId, SettingName); DataCache.RemoveCache("GetModuleSettings" + ModuleId); }