Example #1
0
        private void DoOneByOneExecute(SyncSession session)
        {
            DataProviderBase provider = session.SourceProvider;

            provider.Reset();

            while (provider.MoveNext())
            {
                string key = (string)provider.CurrentData[session.Mappings.SourceKeyProperty];
                if (string.IsNullOrWhiteSpace(key))
                {
                    throw new SyncException("数据源提供的对象的ID为空");
                }

                SchemaObjectBase scObj = LoadSchemaObject(key);
                CompareAndChange(session, provider.CurrentData, session.Mappings.AllObjectValues, scObj);
            }
        }
Example #2
0
        private void DoBatchExecute(SyncSession session)
        {
            DataProviderBase provider = session.SourceProvider;

            provider.Reset();

            List <NameObjectCollection> buffer = new List <NameObjectCollection>(session.BatchSize);
            int len;

            do
            {
                buffer.Clear();
                len = FetchToBuffer(buffer, provider, session.BatchSize);
                if (len > 0)
                {
                    string[] keys = new string[len];
                    for (int i = buffer.Count - 1; i >= 0; i--)
                    {
                        keys[i] = (string)buffer[i][session.Mappings.SourceKeyProperty];
                        if (string.IsNullOrWhiteSpace(keys[i]))
                        {
                            throw new SyncException("数据源提供的对象的ID为空");
                        }
                    }

                    SchemaObjectCollection scObjs = LoadSchemaObjects(keys);

                    foreach (NameObjectCollection item in buffer)
                    {
                        string           id    = (string)item[session.Mappings.SourceKeyProperty];
                        SchemaObjectBase scObj = scObjs[id];
                        if (scObjs != null)
                        {
                            CompareAndChange(session, item, session.Mappings.AllObjectValues, scObj);
                        }
                    }
                }
            } while (len > 0 && len != session.BatchSize);
        }