/// <summary> /// Checks this instance. /// </summary> /// <param name="isExistenceChecked">Indicates whether the carrier existence is checked.</param> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <returns>Returns the check log.</returns> public override IBdoLog Check <T1>( bool isExistenceChecked = true, T1 item = default, string[] specificationAreas = null) { var log = new BdoLog(); if (item is BdoCarrierConfiguration configuration) { log.AddEvents(base.Check(isExistenceChecked, configuration, specificationAreas)); } return(log); }
/// <summary> /// Updates this instance. /// </summary> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <param name="updateModes">The update modes to consider.</param> /// <returns>Log of the operation.</returns> /// <remarks>Put reference collections as null if you do not want to repair this instance.</remarks> public override IBdoLog Update<T>( T item = default, string[] specificationAreas = null, UpdateModes[] updateModes = null) { var log = new BdoLog(); if (item is BdoConnectorConfiguration configuration) { log.AddEvents(Update(configuration, specificationAreas, updateModes)); } return log; }
/// <summary> /// Checks this instance. /// </summary> /// <param name="isExistenceChecked">Indicates whether the carrier existence is checked.</param> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <returns>Returns the check log.</returns> public override IBdoLog Check<T>( bool isExistenceChecked = true, T item = default, string[] specificationAreas = null) { var log = new BdoLog(); if (item is BdoConnectorConfiguration configuration) { log.AddEvents(Check(isExistenceChecked, configuration, specificationAreas)); } return log; }
// -------------------------------------------------- // CHECK, UPDATE, REPAIR // -------------------------------------------------- #region Check_Update_Repair /// <summary> /// Updates this instance. /// </summary> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <param name="updateModes">The update modes to consider.</param> /// <returns>Log of the operation.</returns> /// <remarks>Put reference collections as null if you do not want to repair this instance.</remarks> public override IBdoLog Update <T1>( T1 item = default, string[] specificationAreas = null, UpdateModes[] updateModes = null) { var log = new BdoLog(); if (item is BdoCarrierConfiguration configuration) { log.AddEvents(base.Update(configuration, specificationAreas, updateModes)); } return(log); }
/// <summary> /// Checks this instance. /// </summary> /// <param name="isExistenceChecked">Indicates whether the carrier existence is checked.</param> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <returns>Returns the check log.</returns> public override IBdoLog Check <T1>( bool isExistenceChecked = true, T1 item = default, string[] specificationAreas = null) { var log = new BdoLog(); if (specificationAreas == null) { specificationAreas = new[] { nameof(DataAreaKind.Any) } } ; base.Check <T1>(isExistenceChecked, item, specificationAreas); if (item is ITDataItemSet <DataElementSpec> referenceItem) { // we check that all the elements in this instance are in the specified item if (Items != null) { foreach (var currentSubItem in Items) { if (!referenceItem.Items.Any(p => p.KeyEquals(currentSubItem))) { log.AddError(string.Empty).ResultCode = "additionalItem:" + currentSubItem.Key(); } } } // we check that all the elements in specified collections are in this instance foreach (var referenceSubItem in referenceItem.Items) { var currentSubItem = Items.Find(p => p.KeyEquals(referenceSubItem)); if (currentSubItem == null) { log.AddError(string.Empty).ResultCode = "MISSINGATTRIBUTE:" + referenceSubItem.Key(); } else { log.AddEvents(currentSubItem.Check(isExistenceChecked, referenceSubItem, specificationAreas)); } } } return(log); }
/// <summary> /// Updates this instance. /// </summary> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <param name="updateModes">The update modes to consider.</param> /// <returns>Log of the operation.</returns> /// <remarks>Put reference collections as null if you do not want to repair this instance.</remarks> public override IBdoLog Update <T>( T item = default, string[] specificationAreas = null, UpdateModes[] updateModes = null) { var log = new BdoLog(); if (item is IAppModule) { IAppModule module = item as AppModule; log.AddEvents(Sections.Update( module.Sections, null, new[] { UpdateModes.Incremental_AddItemsMissingInTarget })); } return(log); }
// -------------------------------------------------- // UPDATE, CHECK, REPAIR // -------------------------------------------------- #region Update_Check_Repair /// <summary> /// Updates this instance. /// </summary> /// <typeparam name="T">The application configuration class to consider.</typeparam> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <param name="updateModes">The update modes to consider.</param> /// <returns>Log of the operation.</returns> /// <remarks>Put reference collections as null if you do not want to repair this instance.</remarks> public override IBdoLog Update <T>( T item = default, string[] specificationAreas = null, UpdateModes[] updateModes = null) { var log = new BdoLog(); if (item is BdoAppConfiguration configuration) { log.AddEvents(base.Update( configuration, specificationAreas, updateModes)); // we update the credentials if (configuration.Credentials != null) { Credentials = new List <ApplicationCredential>(); foreach (ApplicationCredential applicationCredential in configuration.Credentials) { Credentials.Add(applicationCredential.Clone() as ApplicationCredential); } } if (configuration.Datasources != null) { Datasources = new List <Datasource>(); foreach (Datasource dataSource in configuration.Datasources) { Datasources.Add(dataSource.Clone() as Datasource); } } } return(log); }
/// <summary> /// Repairs this instance with the specified definition. /// </summary> /// <param name="item">The item to consider.</param> /// <param name="specificationAreas">The specification areas to consider.</param> /// <param name="updateModes">The update modes to consider.</param> /// <returns>Log of the operation.</returns> public override IBdoLog Repair <T1>( T1 item = default, string[] specificationAreas = null, UpdateModes[] updateModes = null) { BdoLog log = null; if (specificationAreas == null) { specificationAreas = new[] { nameof(DataAreaKind.Any) } } ; if (updateModes == null) { updateModes = new[] { UpdateModes.Full } } ; base.Repair <T1>(item, specificationAreas, updateModes); if (item is ITDataItemSet <DataElementSpec> referenceItem) { // we check that all the elements in this instance are in the specified item if (updateModes.Has(UpdateModes.Incremental_RemoveItemsMissingInSource) || updateModes.Has(UpdateModes.Incremental_UpdateCommonItems)) { int i = 0; if (Items != null) { while (i < Items.Count) { var currentSubItem = Items[i]; var referenceSubItem = referenceItem.Items.Find(p => p.KeyEquals(currentSubItem)); if (referenceSubItem == null) { if (updateModes.Has(UpdateModes.Incremental_RemoveItemsMissingInSource)) { Items.RemoveAt(i); i--; } } else if (updateModes.Has(UpdateModes.Incremental_UpdateCommonItems)) { log.AddEvents(currentSubItem.Repair(referenceSubItem, specificationAreas)); } i++; } } } // we check that all the elements in specified item are in this instance if (updateModes.Has(UpdateModes.Incremental_AddItemsMissingInTarget)) { if (referenceItem.Items != null) { foreach (var referenceSubItem in referenceItem.Items) { var currentSubItem = Items.Find(p => p.KeyEquals(referenceSubItem)); //if (currentSubItem == null) // Add(ElementFactory.CreateFromSpec(referenceSubItem) as DataElement); } } } } return(log); }