/// <summary> /// Default Constructor /// </summary> /// <param name="config">Configuration Values</param> public Synchronizer(IConfigValues config) { if (null == config) { throw new ArgumentNullException("config"); } var sqlSchemaReader = new SchemaReader(config.SqlConnection); var executor = new Executor(new SqlConnection(config.SqlConnection)); this.direction = config.Direction; switch (config.Direction) { case Direction.TableToSql: this.tableReader = new TableStorageReader(new AzureStorageResources(config.StorageAccountConnection), config.StorageTableName); this.sqlWriter = new SqlDataWriter(sqlSchemaReader, executor, config.SqlTableName); break; case Direction.SqlToTable: this.sqlReader = new SqlDataReader(executor, sqlSchemaReader, new DynamicLoader(), config.SqlTableName); this.tableWriter = new TableStorageWriter(new TableStorage(config.StorageTableName, config.StorageAccountConnection)); break; default: throw new ArgumentException("Invalid Direction."); } }
public void LoadLastFetchedConfig() { IConfigValues configValues = AGCRemoteConfig.LoadLastFetched(); if (configValues.ContainKey("IsEnglish") || configValues.ContainKey("Region") || configValues.ContainKey("Food_Preference") || configValues.ContainKey("Color_Preference")) { AGCRemoteConfig.Apply(configValues); } ShowAllValues(); ShowLogOnSuccess = false; Fetch(); }
public void OnSuccess(Java.Lang.Object result) { if (result == null) { Context.Logger("result is null", MainActivity.TAG); return; } Context.Logger("Fetch Success", MainActivity.TAG); IConfigValues configValues = (IConfigValues)result; MainActivity.AGCRemoteConfig.Apply(configValues); if (MainActivity.ShowLogOnSuccess) { Context.ShowAllValues(); } ISharedPreferences sharedPreferences = Context.GetSharedPreferences("Remote_Config", FileCreationMode.Private); ISharedPreferencesEditor editor = sharedPreferences.Edit(); editor.PutBoolean("DATA_OLD", false).Apply(); }
private Groups loadGroups( IGroupDataAccess groupDataAccess, ILogger log, IConfigValues config, ICaching cache, CacheItem cachedGroup) { Groups group = null; try { group = new Groups(groupDataAccess, log); cache.Insert(GROUP_CACHE_KEY, group); } catch (Exception exception) { log.Write( "An error occurred trying to load the GROUP information. " + "Likely this is because of a corrupted data in the file. " + (config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile ? "This request will fail, and it's likely that all other requests " + "will as well. Please have someone look at this as soon as possible." : "The service is configured to use the cached data, so the service will " + "continue to work as normal (just without the changes made to the file. " + "Someone will need to address the file issue soon, as GROUP data will get stale."), LogEntrySeverityEnum.Error, exception); if (null == cachedGroup || null == cachedGroup.Obj || config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile) { throw; } group = (Groups)cachedGroup.Obj; } return(group); }
private DateTime getGroupLastModified( IGroupDataAccess groupDataAccess, ILogger log, IConfigValues config) { // Just preset to something in the past. DateTime date = DateTime.UtcNow.AddDays(-1); try { date = groupDataAccess.LastUpdatedUTC; } catch (Exception exception) { log.Write( "An error occurred trying to load the GROUP LAST MODIFIED (LastUpdatedUTC) information. " + "Likely this is because of a corrupted data in the file. " + (config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile ? "This request will fail, and it's likely that all other requests " + "will as well. Please have someone look at this as soon as possible." : "The service is configured to use the cached data, so the service will " + "continue to work as normal (just without the changes made to the file. " + "Someone will need to address the file issue soon, as GROUP data will get stale." + "It is possible there is some BLIP that is causing the file to not be accessible too. " + "If this error is repeating please escalate ASAP. If it's not, that would indicate a short " + "term connectivity/permissions issue that was likely self corrected."), LogEntrySeverityEnum.Error, exception); if (config.FailBehavior == FailBehaviorEnum.FailWithCorruptedFile) { throw; } } return(date); }
public PasswdProvider( IUserDataAccess userDataAccess, IGroupDataAccess groupDataAccess, ICaching cache, ILogger log, IConfigValues config) { _cache = cache; _log = log; _config = config; CacheItem cachedUser = _cache.Get(USER_CACHE_KEY); CacheItem cachedGroup = _cache.Get(GROUP_CACHE_KEY); if (null == cachedUser || null == cachedUser.Obj || cachedUser.TimeAddedUTC < getUsersLastModified(userDataAccess, log, config)) { _users = loadUsers(userDataAccess, log, config, cache, cachedUser); } else { _users = (Users)cachedUser.Obj; } if (null == cachedGroup || null == cachedGroup.Obj || cachedGroup.TimeAddedUTC < getGroupLastModified(groupDataAccess, log, config)) { _groups = loadGroups(groupDataAccess, log, config, cache, cachedGroup); } else { _groups = (Groups)cachedGroup.Obj; } }
/// <summary> /// Default Constructor /// </summary> /// <param name="config">Configuration Values</param> public Synchronizer(IConfigValues config) { if (null == config) { throw new ArgumentNullException("config"); } if (null == config.Source) { throw new ArgumentNullException("source"); } if (null == config.Destination) { throw new ArgumentNullException("destination"); } if (Direction.Unknown == config.Direction) { throw new ArgumentException("Invalid Direction."); } switch (config.Direction) { case Direction.BlobToBlob: this.lister = new BlobReader(config.Source.ContainerName, config.Source.ConnectionString); this.writer = new BlobWriter(config.Destination.ContainerName, config.Destination.ConnectionString, config.CreateSnapshot); break; case Direction.BlobToFolder: this.lister = new BlobReader(config.Source.ContainerName, config.Source.ConnectionString); this.writer = new FolderWriter(config.Destination.Folder); break; case Direction.FolderToFolder: this.lister = new FolderReader(config.Source.Folder); this.writer = new FolderWriter(config.Destination.Folder); break; case Direction.FolderToBlob: this.lister = new FolderReader(config.Source.Folder); this.writer = new BlobWriter(config.Destination.ContainerName, config.Destination.ConnectionString); break; } if (config.Echo) { IDataLister echoLister = null; switch (config.Direction) { case Direction.FolderToBlob: case Direction.BlobToBlob: echoLister = new BlobReader(config.Destination.ContainerName, config.Destination.ConnectionString); break; case Direction.FolderToFolder: case Direction.BlobToFolder: echoLister = new FolderReader(config.Destination.Folder); break; } this.echoer = new Echoer(echoLister); } }
public SurveyContext(IConfigValues config) { _config = config; _db = new MongoClient(_config.GetMongoConnection()) .GetDatabase(_config.GetRefugeDB()); }
public ConfigValuesController(IConfigValues ConfigValuesService) { this.ConfigValuesService = ConfigValuesService; }
public void OnSuccess(Java.Lang.Object result) { IConfigValues configValues = (IConfigValues)result; String greeting = configValues.GetValueAsString("Greeting"); }