public Module1ServiceProvider(ILogging logging, IModule2Update module2Proxy, IModule1DataAdapting dataAdapter, IListDescription listDescription, IModule1DatabaseManagement databaseManager) { this.logging = logging; this.module2Proxy = module2Proxy; this.dataAdapter = dataAdapter; this.listDescription = listDescription; this.databaseManager = databaseManager; }
public Module1ServiceProvider(ILogging logging, IModule2Update module2Proxy) { this.logging = logging; this.module2Proxy = module2Proxy; this.dataAdapter = new Module1DataAdapter(logging); this.listDescription = new ListDescription(logging); this.databaseManager = new Module1DatabaseManager(logging, databaseName); }
/// /// <param name="listDescription">List description from module 1</param> public List <ICollectionDescription> RepackToCollectionDescriptionArray(IListDescription listDescription) { logger.LogNewInfo("Repacking List description to Collection description array"); List <ICollectionDescription> collectionDescriptions = new List <ICollectionDescription>(); foreach (IDescription description in listDescription.Descriptions) { collectionDescriptions.Add(RepackToCollectionDescription(description)); } logger.LogNewInfo("Repacking List description to Collection description array completed"); return(collectionDescriptions); }
/// /// <param name="property">List description form module1</param> public bool UpdateDatabase(IListDescription property) { logger.LogNewInfo("New list description arrived. Performing update on database.."); IModule2Property lastProperty = null; List<ICollectionDescription> collectionDescriptions = null; try { collectionDescriptions = dataAdapter.RepackToCollectionDescriptionArray(property); }catch(ArgumentException) { logger.LogNewWarning("Argument exception thrown by data adapter, aborting all operations."); return false; }catch(Exception) { logger.LogNewWarning("Unknown exception thrown by data adapter, aborting all operations."); return false; } List<IModule2Property> allProperties = new List<IModule2Property>(); foreach(ICollectionDescription cd in collectionDescriptions) { allProperties.AddRange(cd.Collection.Properties); } foreach(IModule2Property module2property in allProperties) { lastProperty = databaseManager.ReadLastByCode(module2property.Code); if(lastProperty == null) { logger.LogNewInfo(string.Format("No property found in database for signal code {0}. Writing directly without deadband checking..", module2property.Code)); databaseManager.WriteProperty(module2property); } else if(IsDeadbandSatisfied(lastProperty, module2property, deadbandPercentage)) { databaseManager.WriteProperty(module2property); } } return true; }
public void RepackToCollectionDescriptionArray_RegularParameters_AssertListLength(int listLength) { IListDescription listDescription = MockRegularListDescription(listLength); Assert.AreEqual(listLength, listDescription.Descriptions.Count); }