コード例 #1
0
        public string GetMappedValueWithExceptionThrower(string fieldToUpdateDescription,
                                                         SyncSide syncSideToUpdate, string nonUpdateSideValue)
        {
            try
            {
                if (syncSideToUpdate == SyncSide.Source)
                {
                    return(GetMappedValue(null, nonUpdateSideValue, syncSideToUpdate));
                }
                else if (syncSideToUpdate == SyncSide.Target)
                {
                    return(GetMappedValue(nonUpdateSideValue, null, syncSideToUpdate));
                }
                else
                {
                    throw new EnumValueNotImplementedException <SyncSide>(syncSideToUpdate);
                }
            }
            catch (UnmappedValueException ex)
            {
                UnmappedValueExceptionHandler.ThrowException(fieldToUpdateDescription, ex);
            }

            return(null);
        }
コード例 #2
0
 public static bool HasManualGeneratedPrimaryKey(DataMap map, SyncSide syncSide)
 {
     if (GetEntityDefinition(map, syncSide).PrimaryKeyGenerationType == PrimaryKeyGenerationType.Manual)
     {
         return(true);
     }
     return(false);
 }
コード例 #3
0
 public void AddDataSources(IEnumerable <DataSource> dataSources, SyncSide side)
 {
     if (dataSources != null)
     {
         foreach (var dataSource in dataSources)
         {
             AddDataSource(dataSource, side);
         }
     }
 }
コード例 #4
0
        protected void AddCustomSetField(SyncSide syncSide, string fieldToCompare, string fieldToUpdate, Func <DataRow, object> customSetMethod, SyncOperation appliesTo, bool onlyApplyWithOtherChanges)
        {
            if (_customSetFields.Exists(d => (appliesTo.HasFlag(SyncOperation.Inserts) || appliesTo.HasFlag(SyncOperation.All)) &&
                                        (d.AppliesTo.HasFlag(SyncOperation.Inserts) || d.AppliesTo.HasFlag(SyncOperation.All)) &&
                                        d.SyncSide == syncSide &&
                                        string.Equals(d.FieldNameToUpdate, fieldToUpdate, StringComparison.OrdinalIgnoreCase)))
            {
                throw new Exception(string.Format("Field '{0}' already exists for operation '{1}' and sync side '{2}'.",
                                                  fieldToUpdate, Enum.GetName(typeof(SyncOperation), SyncOperation.Inserts), Enum.GetName(typeof(SyncSide), syncSide)));
            }

            if (_customSetFields.Exists(d => (appliesTo.HasFlag(SyncOperation.Updates) || appliesTo.HasFlag(SyncOperation.All)) &&
                                        (d.AppliesTo.HasFlag(SyncOperation.Updates) || d.AppliesTo.HasFlag(SyncOperation.All)) &&
                                        d.SyncSide == syncSide &&
                                        string.Equals(d.FieldNameToUpdate, fieldToUpdate, StringComparison.OrdinalIgnoreCase)))
            {
                throw new Exception(string.Format("Field '{0}' already exists for operation '{1}' and sync side '{2}'.",
                                                  fieldToUpdate, Enum.GetName(typeof(SyncOperation), SyncOperation.Updates), Enum.GetName(typeof(SyncSide), syncSide)));
            }

            if (_customSetFields.Exists(d => (appliesTo.HasFlag(SyncOperation.Deletes) || appliesTo.HasFlag(SyncOperation.All)) &&
                                        (d.AppliesTo.HasFlag(SyncOperation.Deletes) || d.AppliesTo.HasFlag(SyncOperation.All)) &&
                                        d.SyncSide == syncSide &&
                                        string.Equals(d.FieldNameToUpdate, fieldToUpdate, StringComparison.OrdinalIgnoreCase)))
            {
                throw new Exception(string.Format("Field '{0}' already exists for operation '{1}' and sync side '{2}'.",
                                                  fieldToUpdate, Enum.GetName(typeof(SyncOperation), SyncOperation.Deletes), Enum.GetName(typeof(SyncSide), syncSide)));
            }

            switch (syncSide)
            {
            case SyncSide.Source:

                if (!_addedSourceFields.Contains(fieldToUpdate, StringComparer.OrdinalIgnoreCase))
                {
                    AddToSyncSideFieldsList(syncSide, fieldToUpdate);
                }

                break;

            case SyncSide.Target:

                if (!_addedTargetFields.Contains(fieldToUpdate, StringComparer.OrdinalIgnoreCase))
                {
                    AddToSyncSideFieldsList(syncSide, fieldToUpdate);
                }

                break;

            default:
                throw new EnumValueNotImplementedException <SyncSide>(syncSide);
            }

            _customSetFields.Add(new CustomSetField(syncSide, fieldToCompare, fieldToUpdate, customSetMethod, appliesTo, onlyApplyWithOtherChanges));
        }
コード例 #5
0
        public List <DataSource> GetJobDataSourcesByJobId(Guid jobId, SyncSide syncSide)
        {
            try
            {
                return(configurator.GetJobDataSourcesByJobId(jobId, syncSide));
            }
            catch (Exception ex)
            {
                SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE);

                throw;
            }
        }
コード例 #6
0
        public bool JobDataSourceExists(Guid jobId, Guid dataSourceId, SyncSide syncSide)
        {
            try
            {
                return(configurator.JobDataSourceExists(jobId, dataSourceId, syncSide));
            }
            catch (Exception ex)
            {
                SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE);

                throw;
            }
        }
コード例 #7
0
        public JobDataSource(SyncSide syncSide, DataSource dataSource, RunHistory history)
        {
            if (dataSource == null)
            {
                throw new Exception("Data source can not be null.");
            }

            DataSource = dataSource;

            SyncSide = syncSide;

            History = history;
        }
コード例 #8
0
        public JobBatch ProcessBatchByDataSourceId(Guid dataSourceId, SyncSide syncSide, List <EntityBatch> entityBatches)
        {
            try
            {
                var dataSource = GetDataSource(dataSourceId);

                return(ProcessJobBatch(syncSide, dataSource, entityBatches));
            }
            catch (Exception ex)
            {
                SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE);

                throw;
            }
        }
コード例 #9
0
        public void DeleteJobDataSources(Guid jobId, SyncSide syncSide)
        {
            try
            {
                configurator.DeleteJobDataSources(jobId, syncSide);

                scheduledJobManager.QueueScheduledJobs(clearExistingScheduledJobInstancesFromWaitingQueue: true);
            }
            catch (Exception ex)
            {
                SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE);

                throw;
            }
        }
コード例 #10
0
        private JobBatch ProcessJobBatch(SyncSide syncSide, DataSource dataSource, List <EntityBatch> entityBatches)
        {
            var jobDataSource = new JobDataSource(syncSide, dataSource);

            var jobBatch = new JobBatch(syncSide, jobDataSource);

            foreach (var entityBatch in entityBatches)
            {
                jobBatch.EntityBatches.Add(entityBatch);
            }

            dataSource.ProcessBatch(jobBatch);

            return(jobBatch);
        }
コード例 #11
0
ファイル: DataTableHelper.cs プロジェクト: cburriss/SyncObjX
 public static string GetDuplicateRowsExceptionMessage(SyncSide syncSide, string tableName, List <string> uniqueKeyColumnNames, HashSet <RecordKeyCombo> duplicateKeys)
 {
     if (uniqueKeyColumnNames.Count == 1)
     {
         return(string.Format("The {0}-side data with table name '{1}' has one or more duplicate key value(s) for column '{2}' and value(s): '{3}'.",
                              Enum.GetName(typeof(SyncSide), syncSide).ToLower(), tableName, uniqueKeyColumnNames[0],
                              StringHelper.GetDelimitedString(duplicateKeys.Select(d => d.Key1), "', '")));
     }
     else
     {
         return(string.Format("The {0}-side data with table name '{1}' has one or more duplicate key value(s) for columns '{2}' and value(s): ({3}).",
                              Enum.GetName(typeof(SyncSide), syncSide).ToLower(), tableName,
                              StringHelper.GetDelimitedString(uniqueKeyColumnNames),
                              StringHelper.GetDelimitedString(duplicateKeys, "), (")));
     }
 }
コード例 #12
0
ファイル: JobFilter.cs プロジェクト: cburriss/SyncObjX
        public JobFilter(SyncSide syncSide, string fieldName, JobFilterOperator @operator, object value, bool encloseValueInSingleQuotes = true)
        {
            if (String.IsNullOrWhiteSpace(fieldName))
            {
                throw new Exception("Field name is missing or empty.");
            }

            SyncSide = syncSide;

            FieldName = fieldName;

            Operator = @operator;

            Value = value;

            EncloseValueInSingleQuotes = encloseValueInSingleQuotes;
        }
コード例 #13
0
        protected void AddToSyncSideFieldsList(SyncSide syncSide, string fieldName)
        {
            if (String.IsNullOrWhiteSpace(fieldName))
            {
                throw new Exception("Field name is missing or empty.");
            }

            fieldName = fieldName.Trim();

            switch (syncSide)
            {
            case SyncSide.Source:

                if (_addedSourceFields.Exists(d => d.Equals(fieldName, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new Exception(string.Format("Source-side field already exists with name '{0}'.", fieldName));
                }
                else
                {
                    _addedSourceFields.Add(fieldName.Trim());
                }

                break;

            case SyncSide.Target:

                if (_addedTargetFields.Exists(d => d.Equals(fieldName, StringComparison.OrdinalIgnoreCase)))
                {
                    throw new Exception(string.Format("Target-side field already exists with name '{0}'.", fieldName));
                }
                else
                {
                    _addedTargetFields.Add(fieldName);
                }

                break;

            default:
                throw new EnumValueNotImplementedException <SyncSide>(syncSide);
            }
        }
コード例 #14
0
ファイル: CustomSetField.cs プロジェクト: cburriss/SyncObjX
        public CustomSetField(SyncSide syncSide, string fieldNameToCompare, string fieldNameToUpdate, Func <DataRow, Object> customSetMethod, SyncOperation appliesTo, bool onlyApplyWithOtherChanges = false)
        {
            if (String.IsNullOrWhiteSpace(fieldNameToCompare))
            {
                throw new Exception("Field name to compare is missing or empty.");
            }

            if (String.IsNullOrWhiteSpace(fieldNameToUpdate))
            {
                throw new Exception("Field name to update is missing or empty.");
            }

            if (customSetMethod == null)
            {
                throw new Exception("Custom method can not be null.");
            }

            SyncSide = syncSide;

            FieldNameToCompare = fieldNameToCompare;

            FieldNameToUpdate = fieldNameToUpdate;

            if (SyncSide == Core.SyncSide.Source)
            {
                FieldNameToCompareWithPrefix = DataTableHelper.SOURCE_PREFIX + fieldNameToCompare;
                FieldNameToUpdateWithPrefix  = DataTableHelper.SOURCE_PREFIX + fieldNameToUpdate;
            }
            else
            {
                FieldNameToCompareWithPrefix = DataTableHelper.TARGET_PREFIX + fieldNameToCompare;
                FieldNameToUpdateWithPrefix  = DataTableHelper.TARGET_PREFIX + fieldNameToUpdate;
            }

            CustomSetMethod = customSetMethod;

            AppliesTo = appliesTo;

            OnlyApplyWithOtherChanges = onlyApplyWithOtherChanges;
        }
コード例 #15
0
        private static EntityToUpdateDefinition GetEntityDefinition(DataMap map, SyncSide syncSide)
        {
            EntityToUpdateDefinition entityDefinition = null;

            if (map is OneWayDataMap)
            {
                var oneWayMap = (OneWayDataMap)map;

                entityDefinition = oneWayMap.EntityToUpdateDefinition;
            }
            else if (map is OneToMany_OneWayDataMap)
            {
                var oneToManyMap = (OneToMany_OneWayDataMap)map;

                entityDefinition = oneToManyMap.EntityToUpdateDefinition;
            }
            else if (map is TwoWayDataMap)
            {
                var twoWayMap = (TwoWayDataMap)map;

                if (syncSide == SyncSide.Source)
                {
                    entityDefinition = twoWayMap.SourceDefinition;
                }
                else if (syncSide == SyncSide.Target)
                {
                    entityDefinition = twoWayMap.TargetDefinition;
                }
                else
                {
                    throw new EnumValueNotImplementedException <SyncSide>(syncSide);
                }
            }
            else
            {
                throw new DerivedClassNotImplementedException <OneToOneDataMap>(map);
            }

            return(entityDefinition);
        }
コード例 #16
0
        public void AddDataSource(SyncSide syncSide, string name, Type adapterType, Dictionary <string, string> properties)
        {
            if (adapterType.BaseType != typeof(AdapterInstance))
            {
                throw new Exception(string.Format("Type '{0}' is not a valid adapter. Class must derive from base class '{1}'.",
                                                  adapterType.FullName, typeof(AdapterInstance).FullName));
            }

            var adapter = new Adapter(Guid.NewGuid(), adapterType.Name, adapterType.Assembly.Location, adapterType.FullName);

            if (syncSide == SyncSide.Source)
            {
                if (_sourceSideDataSource != null)
                {
                    throw new Exception("A source-side data source already exists.");
                }
                else
                {
                    _sourceSideDataSource = new DataSource(Guid.NewGuid(), name, adapter);
                    _sourceSideDataSource.ExtendedProperties = properties;
                }
            }
            else if (syncSide == SyncSide.Target)
            {
                if (_targetSideDataSource != null)
                {
                    throw new Exception("A target-side data source already exists.");
                }
                else
                {
                    _targetSideDataSource = new DataSource(Guid.NewGuid(), name, adapter);
                    _targetSideDataSource.ExtendedProperties = properties;
                }
            }
            else
            {
                throw new EnumValueNotImplementedException <SyncSide>(syncSide);
            }
        }
コード例 #17
0
        public void AddDataSource(DataSource dataSource, SyncSide side)
        {
            switch (side)
            {
            case SyncSide.Source:

                if (dataSource == null)
                {
                    throw new Exception("Source-side data source can not be null.");
                }
                else if (SourceDataSources.Keys.Where(d => d.ToLower() == dataSource.Name.ToLower()).Count() > 0)
                {
                    throw new Exception(string.Format("A source-side data source with name '{0}' already exists.", dataSource.Name));
                }
                else
                {
                    _sourceDataSources.Add(dataSource.Name, dataSource);
                }

                break;

            case SyncSide.Target:

                if (dataSource == null)
                {
                    throw new Exception("Target-side data source can not be null.");
                }
                else
                {
                    _targetDataSource = dataSource;
                }

                break;

            default:
                throw new EnumValueNotImplementedException <SyncSide>(side);
            }
        }
コード例 #18
0
        public static bool AreEqual(string fieldToUpdate, string sourceValue, string targetValue, FieldMap fieldMap, SyncSide syncSideToUpdate, ref string newValue)
        {
            string oldValue;

            if (syncSideToUpdate == SyncSide.Target)
            {
                newValue = fieldMap.GetMappedValueWithExceptionThrower(fieldToUpdate, syncSideToUpdate, sourceValue, targetValue);
                oldValue = targetValue;
            }
            else
            {
                newValue = fieldMap.GetMappedValueWithExceptionThrower(fieldToUpdate, syncSideToUpdate, targetValue, sourceValue);
                oldValue = sourceValue;
            }

            if (oldValue == newValue)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #19
0
ファイル: DataTableHelper.cs プロジェクト: cburriss/SyncObjX
        private static object[] GetKeyValues(DataRow row, JoinFieldCollection joinKeysCollection, SyncSide syncSide, string joinSidePrefix)
        {
            var keyValues = new object[joinKeysCollection.Count];

            for (int i = 0; i < joinKeysCollection.Count; i++)
            {
                if (syncSide == SyncSide.Source)
                {
                    keyValues[i] = row[joinSidePrefix + joinKeysCollection.JoinFields[i].SourceJoinField];
                }
                else if (syncSide == SyncSide.Target)
                {
                    keyValues[i] = row[joinSidePrefix + joinKeysCollection.JoinFields[i].TargetJoinField];
                }
                else
                {
                    throw new EnumValueNotImplementedException <SyncSide>(syncSide);
                }
            }

            return(keyValues);
        }
コード例 #20
0
ファイル: DataTableHelper.cs プロジェクト: cburriss/SyncObjX
        private static void SetCombinedPrimaryKeys(DataTable combinedTable, JoinFieldCollection joinKeysCollection, SyncSide syncSide, string joinSidePrefix)
        {
            var combinedJoinKeys = new DataColumn[joinKeysCollection.Count];

            for (int i = 0; i < joinKeysCollection.Count; i++)
            {
                if (syncSide == SyncSide.Source)
                {
                    combinedJoinKeys[i] = combinedTable.Columns[joinSidePrefix + joinKeysCollection.JoinFields[i].SourceJoinField];
                }
                else if (syncSide == SyncSide.Target)
                {
                    combinedJoinKeys[i] = combinedTable.Columns[joinSidePrefix + joinKeysCollection.JoinFields[i].TargetJoinField];
                }
                else
                {
                    throw new EnumValueNotImplementedException <SyncSide>(syncSide);
                }
            }

            try
            {
                combinedTable.PrimaryKey = combinedJoinKeys;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("The {0}-side data has one or more duplicate primary key value(s) for column(s) '{1}'.",
                                                  Enum.GetName(typeof(SyncSide), syncSide).ToLower(),
                                                  StringHelper.GetDelimitedString(joinKeysCollection.JoinFields.Select(d => d.SourceJoinField))), ex);
            }

            // set the key to allow Nulls (otherwise, inserting target data w/o a matching source record will error)
            foreach (DataColumn col in combinedTable.PrimaryKey)
            {
                col.AllowDBNull = true;
            }
        }
コード例 #21
0
ファイル: TwoWayDataMap.cs プロジェクト: cburriss/SyncObjX
 public void AddAutoSetField(SyncSide syncSide, string fieldToCompare, string fieldToUpdate, object value, SyncOperation appliesTo, bool onlyApplyWithOtherChanges = false)
 {
     base.AddCustomSetField(syncSide, fieldToCompare, fieldToUpdate, (row) => { return(value); }, appliesTo, onlyApplyWithOtherChanges);
 }
コード例 #22
0
        public EntityToUpdateDefinition(SyncSide syncSide, string technicalEntityName, List <string> primaryKeyColumnNames, PrimaryKeyGenerationType primaryKeyGenerationType, object customCommand)
        {
            SyncSide = syncSide;

            if (!(primaryKeyGenerationType == Data.PrimaryKeyGenerationType.AutoGenerate ||
                  primaryKeyGenerationType == Data.PrimaryKeyGenerationType.Manual ||
                  primaryKeyGenerationType == Data.PrimaryKeyGenerationType.Custom))
            {
                throw new EnumValueNotImplementedException <PrimaryKeyGenerationType>(primaryKeyGenerationType);
            }

            if (primaryKeyColumnNames == null || primaryKeyColumnNames.Count == 0)
            {
                throw new Exception("One or more primary key columns names are required.");
            }

            foreach (var primaryKeyColumnName in primaryKeyColumnNames)
            {
                if (String.IsNullOrWhiteSpace(primaryKeyColumnName))
                {
                    throw new Exception("Primary key column name is missing or empty.");
                }
            }

            TechnicalEntityName = technicalEntityName.Trim();

            primaryKeyColumnNames.ForEach(d => d.Trim());
            PrimaryKeyColumnNames = primaryKeyColumnNames;

            PrimaryKeyGenerationType = primaryKeyGenerationType;

            CustomCommand = customCommand;

            if (PrimaryKeyGenerationType == PrimaryKeyGenerationType.Manual)
            {
                foreach (var primaryKeyColumnName in PrimaryKeyColumnNames)
                {
                    DataOnlyFields.Add(new DataOnlyField(primaryKeyColumnName));
                }
            }

            switch (syncSide)
            {
            case SyncSide.Source:

                foreach (var primaryKeyColumnName in PrimaryKeyColumnNames)
                {
                    PrimaryKeyColumnNamesWithPrefix.Add(DataTableHelper.SOURCE_PREFIX + primaryKeyColumnName);
                }

                break;

            case SyncSide.Target:

                foreach (var primaryKeyColumnName in PrimaryKeyColumnNames)
                {
                    PrimaryKeyColumnNamesWithPrefix.Add(DataTableHelper.TARGET_PREFIX + primaryKeyColumnName);
                }

                break;

            default:
                throw new EnumValueNotImplementedException <SyncSide>(syncSide);
            }

            // validate added secondary key and add as data only field
            SecondaryKeyColumnNames.ListChanged += new ListChangedEventHandler((sender, args) =>
            {
                if (args.ListChangedType == ListChangedType.ItemAdded)
                {
                    if (String.IsNullOrWhiteSpace(SecondaryKeyColumnNames[args.NewIndex]))
                    {
                        throw new Exception("Secondary key column name is missing or empty.");
                    }

                    DataOnlyFields.Add(new DataOnlyField(SecondaryKeyColumnNames[args.NewIndex], false));
                }
            });

            // validate added data only field
            DataOnlyFields.ListChanged += new ListChangedEventHandler((sender, args) =>
            {
                if (args.ListChangedType == ListChangedType.ItemAdded)
                {
                    if (String.IsNullOrWhiteSpace(DataOnlyFields[args.NewIndex].FieldName))
                    {
                        throw new Exception("Data only field name is missing or empty.");
                    }

                    // remove if a duplicate value
                    if (DataOnlyFields.Where(d => d.FieldName.Equals(DataOnlyFields[args.NewIndex].FieldName, StringComparison.OrdinalIgnoreCase)).Count() > 1)
                    {
                        var newItem = DataOnlyFields[args.NewIndex];

                        var existingItem = DataOnlyFields.Where(d => d.FieldName.Equals(DataOnlyFields[args.NewIndex].FieldName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                        // override the mapped field if a Func is specified to populate the value
                        if (existingItem.MethodToPopulateValue != null && newItem.MethodToPopulateValue == null)
                        {
                            newItem.MethodToPopulateValue = existingItem.MethodToPopulateValue;
                        }

                        if (existingItem.IsRequiredByJobBatch)
                        {
                            newItem.IsRequiredByJobBatch = true;
                        }

                        // remove the old instance now that the new one is updated
                        DataOnlyFields.Remove(existingItem);
                    }
                }
            });

            // validate added data only field
            TransposeDataOnlyFields.ListChanged += new ListChangedEventHandler((sender, args) =>
            {
                if (args.ListChangedType == ListChangedType.ItemAdded)
                {
                    if (String.IsNullOrWhiteSpace(TransposeDataOnlyFields[args.NewIndex].FieldName))
                    {
                        throw new Exception("Transpose data only field name is missing or empty.");
                    }

                    // remove if a duplicate value
                    if (TransposeDataOnlyFields.Where(d => d.FieldName.Equals(TransposeDataOnlyFields[args.NewIndex].FieldName, StringComparison.OrdinalIgnoreCase)).Count() > 1)
                    {
                        var newItem = DataOnlyFields[args.NewIndex];

                        var existingItem = TransposeDataOnlyFields.Where(d => d.FieldName.Equals(TransposeDataOnlyFields[args.NewIndex].FieldName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                        // remove the old instance now that the new one is updated
                        TransposeDataOnlyFields.Remove(existingItem);
                    }
                }
            });
        }
コード例 #23
0
 public EntityToUpdateDefinition(SyncSide syncSide, string technicalEntityName, string primaryKeyColumnName, PrimaryKeyGenerationType primaryKeyGenerationType, object customCommand)
     : this(syncSide, technicalEntityName, new List <string> {
     primaryKeyColumnName
 }, primaryKeyGenerationType, customCommand)
 {
 }
コード例 #24
0
 public EntityToUpdateDefinition(SyncSide syncSide, string technicalEntityName, List <string> primaryKeyColumnNames, object customCommand)
     : this(syncSide, technicalEntityName, primaryKeyColumnNames, PrimaryKeyGenerationType.Custom, customCommand)
 {
 }
コード例 #25
0
 public EntityToUpdateDefinition(SyncSide syncSide, string technicalEntityName, List <string> primaryKeyColumnNames, PrimaryKeyGenerationType primaryKeyGenerationType)
     : this(syncSide, technicalEntityName, primaryKeyColumnNames, primaryKeyGenerationType, null)
 {
 }
コード例 #26
0
 public EntityToUpdateDefinition(SyncSide syncSide, string technicalEntityName, string primaryKeyColumnName)
     : this(syncSide, technicalEntityName, primaryKeyColumnName, PrimaryKeyGenerationType.Manual)
 {
 }
コード例 #27
0
ファイル: TwoWayDataMap.cs プロジェクト: cburriss/SyncObjX
        public override HashSet <string> GetMappedDataFieldNames(SyncSide syncSide, DataMapFieldType includedFieldTypes = DataMapFieldType.All, string prefix = "")
        {
            HashSet <string> dataFields = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            if (syncSide == SyncSide.Source)
            {
                if (includedFieldTypes.HasFlag(DataMapFieldType.PrimaryKey) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var primaryKey in SourceDefinition.PrimaryKeyColumnNames)
                    {
                        dataFields.Add(prefix + primaryKey);
                    }
                }

                if (includedFieldTypes.HasFlag(DataMapFieldType.SecondaryKey) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var secondaryKey in SourceDefinition.SecondaryKeyColumnNames)
                    {
                        dataFields.Add(prefix + secondaryKey);
                    }
                }

                if (includedFieldTypes.HasFlag(DataMapFieldType.CompareField) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var compareField in CompareFields)
                    {
                        dataFields.Add(prefix + compareField.SourceFieldToCompare);
                    }
                }

                if (includedFieldTypes.HasFlag(DataMapFieldType.DataOnlyField) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var dataOnlyField in SourceDefinition.DataOnlyFields)
                    {
                        dataFields.Add(prefix + dataOnlyField.FieldName);
                    }
                }
            }
            else if (syncSide == SyncSide.Target)
            {
                if (includedFieldTypes.HasFlag(DataMapFieldType.PrimaryKey) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var primaryKey in TargetDefinition.PrimaryKeyColumnNames)
                    {
                        dataFields.Add(prefix + primaryKey);
                    }
                }

                if (includedFieldTypes.HasFlag(DataMapFieldType.SecondaryKey) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var secondaryKey in TargetDefinition.SecondaryKeyColumnNames)
                    {
                        dataFields.Add(prefix + secondaryKey);
                    }
                }

                if (includedFieldTypes.HasFlag(DataMapFieldType.CompareField) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var compareField in CompareFields)
                    {
                        dataFields.Add(prefix + compareField.TargetFieldToCompare);
                    }
                }

                if (includedFieldTypes.HasFlag(DataMapFieldType.DataOnlyField) || includedFieldTypes.HasFlag(DataMapFieldType.All))
                {
                    foreach (var dataOnlyField in TargetDefinition.DataOnlyFields)
                    {
                        dataFields.Add(prefix + dataOnlyField.FieldName);
                    }
                }
            }
            else
            {
                throw new EnumValueNotImplementedException <SyncSide>(syncSide);
            }

            if (includedFieldTypes.HasFlag(DataMapFieldType.CustomSetField) || includedFieldTypes.HasFlag(DataMapFieldType.All))
            {
                foreach (var customSetField in CustomSetFields.Where(d => d.SyncSide == syncSide))
                {
                    dataFields.Add(prefix + customSetField.FieldNameToCompare);
                }
            }

            return(dataFields);
        }
コード例 #28
0
        public List <DataSource> GetJobDataSourcesByJobName(string integrationName, string jobName, SyncSide syncSide)
        {
            try
            {
                return(configurator.GetJobDataSourcesByJobName(integrationName, jobName, syncSide));
            }
            catch (Exception ex)
            {
                SyncEngineLogger.WriteExceptionToLog(ex, WEB_SERVICE_EXCEPTION_MESSAGE);

                throw;
            }
        }
コード例 #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sourceValue"></param>
        /// <param name="targetValue"></param>
        /// <param name="syncDirection"></param>
        /// <returns>Returns the new value.  The return value will be equal to the old value if no changes were applied.</returns>
        public string GetMappedValue(string sourceValue, string targetValue, SyncSide syncSideToUpdate)
        {
            if (sourceValue != null)
            {
                sourceValue = sourceValue.Trim();
            }

            if (targetValue != null)
            {
                targetValue = targetValue.Trim();
            }

            foreach (FieldMapPair fmp in Maps)
            {
                if (syncSideToUpdate == SyncSide.Target)
                {
                    if (string.Equals(sourceValue, fmp.SourceValue, ComparisonType))
                    {
                        return(GetAppliedFieldMapValue(targetValue, fmp.TargetValue));
                    }
                }
                else if (syncSideToUpdate == SyncSide.Source)
                {
                    if (string.Equals(targetValue, fmp.TargetValue, ComparisonType))
                    {
                        return(GetAppliedFieldMapValue(sourceValue, fmp.SourceValue));
                    }
                }
                else
                {
                    throw new EnumValueNotImplementedException <SyncSide>(syncSideToUpdate);
                }
            }

            if (syncSideToUpdate == SyncSide.Target)
            {
                // the source value was not found in the fied map, so apply unmapped behavior
                switch (TargetSideUnmappedValueBehavior)
                {
                case UnmappedValueBehavior.DoNotUpdate:
                    // As DoNotUpdate is configured, return the old target value if the source key wasn't found
                    return(targetValue);

                case UnmappedValueBehavior.PassThrough:
                    // if the source value wasn't found in the map, "pass through" the source value to target as is
                    return(sourceValue);

                case UnmappedValueBehavior.UseDefaultValue:
                    // if the source value wasn't found in the map, return the configured default value
                    return(TargetSideDefaultValue);

                case UnmappedValueBehavior.ThrowException:
                    throw new UnmappedValueException(SyncDirection.SourceToTarget, sourceValue);

                default:
                    throw new EnumValueNotImplementedException <UnmappedValueBehavior>(TargetSideUnmappedValueBehavior);
                }
            }
            else if (syncSideToUpdate == SyncSide.Source)
            {
                // the source value was not found in the fied map, so apply unmapped behavior
                switch (SourceSideUnmappedValueBehavior)
                {
                case UnmappedValueBehavior.DoNotUpdate:
                    // As DoNotUpdate is configured, return the old target value if the source key wasn't found
                    return(sourceValue);

                case UnmappedValueBehavior.PassThrough:
                    // if the source value wasn't found in the map, "pass through" the source value to target as is
                    return(targetValue);

                case UnmappedValueBehavior.UseDefaultValue:
                    // if the source value wasn't found in the map, return the configured default value
                    return(SourceSideDefaultValue);

                case UnmappedValueBehavior.ThrowException:
                    throw new UnmappedValueException(SyncDirection.TargetToSource, targetValue);

                default:
                    throw new EnumValueNotImplementedException <UnmappedValueBehavior>(TargetSideUnmappedValueBehavior);
                }
            }
            else
            {
                throw new EnumValueNotImplementedException <SyncSide>(syncSideToUpdate);
            }
        }
コード例 #30
0
 public abstract HashSet <string> GetMappedDataFieldNames(SyncSide syncSide, DataMapFieldType includedFieldTypes, string prefix = "");