예제 #1
0
        public bool AreEqual(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            string srcValue    = (srcValues[mapping.SourceProperty] as string ?? string.Empty);
            string targetValue = (string)targetObj.Properties[mapping.TargetProperty].StringValue ?? string.Empty;

            return(srcValue.Equals(targetValue));
        }
예제 #2
0
 public NameObjectCollection(NameObjectCollection source)
     : base(source.Count)
 {
     for (int i = 0; i < source.Count; i++)
     {
         this.BaseAdd(source.BaseGetKey(i), source.BaseGet(i));
     }
 }
예제 #3
0
        private int FetchToBuffer(List <NameObjectCollection> buffer, DataProviderBase dataSource, int size)
        {
            int count = 0;

            while (count < size && dataSource.MoveNext())
            {
                count++;
                NameObjectCollection data = new NameObjectCollection(dataSource.CurrentData);
                buffer.Add(data);
            }

            return(count);
        }
예제 #4
0
        private void CompareAndChange(SyncSession session, NameObjectCollection currentData, PropertyMapping[] mappings, SchemaObjectBase scObj)
        {
            if (scObj != null && scObj.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal)
            {
                PropertyMapping mapping;
                bool            hasChange = false;
                bool            propertyChanged;

                for (int i = 0; i < mappings.Length; i++)
                {
                    mapping         = mappings[i];
                    propertyChanged = HasPropertyChange(session, session.Comparers[mapping.ComparerKey], mapping, currentData, scObj);
                    hasChange      |= propertyChanged;
                    if (propertyChanged)
                    {
                        MakeChange(session, session.Setters[mapping.SetterKey], mapping, currentData, scObj);
                    }
                }

                if (hasChange)
                {
                    //完成
                    try
                    {
                        PC.Adapters.SchemaObjectAdapter.Instance.Update(scObj);
                        session.NumerOfUpdated++;
                        session.WriteUpdateLog(scObj);
                    }
                    catch (Exception ex)
                    {
                        session.NumerOfErrors++;
                        session.WriteErrorLog(scObj, ex);
                    }
                }
            }
        }
예제 #5
0
 private bool HasPropertyChange(SyncSession session, IPropertyComparer comparer, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
 {
     return(comparer.AreEqual(session, mapping, srcValues, targetObj) == false);
 }
예제 #6
0
 private void MakeChange(SyncSession session, IPropertySetter setter, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
 {
     setter.SetValue(session, mapping, srcValues, targetObj);
 }
예제 #7
0
        public void SetValue(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
        {
            string srcValue = srcValues[mapping.SourceProperty] as string ?? string.Empty;

            targetObj.Properties[mapping.TargetProperty].StringValue = srcValue;
        }
예제 #8
0
 private bool HasPropertyChange(SyncSession session, IPropertyComparer comparer, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
 {
     return comparer.AreEqual(session, mapping, srcValues, targetObj) == false;
 }
예제 #9
0
 private void MakeChange(SyncSession session, IPropertySetter setter, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
 {
     setter.SetValue(session, mapping, srcValues, targetObj);
 }
예제 #10
0
        private void CompareAndChange(SyncSession session, NameObjectCollection currentData, PropertyMapping[] mappings, SchemaObjectBase scObj)
        {
            if (scObj != null && scObj.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal)
            {
                PropertyMapping mapping;
                bool hasChange = false;
                bool propertyChanged;

                for (int i = 0; i < mappings.Length; i++)
                {
                    mapping = mappings[i];
                    propertyChanged = HasPropertyChange(session, session.Comparers[mapping.ComparerKey], mapping, currentData, scObj);
                    hasChange |= propertyChanged;
                    if (propertyChanged)
                    {
                        MakeChange(session, session.Setters[mapping.SetterKey], mapping, currentData, scObj);
                    }
                }

                if (hasChange)
                {
                    //完成
                    try
                    {
                        PC.Adapters.SchemaObjectAdapter.Instance.Update(scObj);
                        session.NumerOfUpdated++;
                        session.WriteUpdateLog(scObj);

                    }
                    catch (Exception ex)
                    {
                        session.NumerOfErrors++;
                        session.WriteErrorLog(scObj, ex);
                    }
                }
            }
        }
예제 #11
0
        private int FetchToBuffer(List<NameObjectCollection> buffer, DataProviderBase dataSource, int size)
        {
            int count = 0;
            while (count < size && dataSource.MoveNext())
            {
                count++;
                NameObjectCollection data = new NameObjectCollection(dataSource.CurrentData);
                buffer.Add(data);
            }

            return count;
        }
 public void SetValue(SyncSession session, PropertyMapping mapping, NameObjectCollection srcValues, SchemaObjectBase targetObj)
 {
     string srcValue = srcValues[mapping.SourceProperty] as string ?? string.Empty;
     targetObj.Properties[mapping.TargetProperty].StringValue = srcValue;
 }