Example #1
0
        public static SaveOperation For(object toCreate)
        {
            List <DataProperty> data   = GetData(toCreate);
            SaveOperation       result = For <SaveOperation>(toCreate.GetType());

            result.Properties = data;
            return(result);
        }
        public override object Execute(IDistributedRepository destination)
        {
            ProxyFactory      _proxyFactory = new ProxyFactory();
            RepositoryService sourceRepo    = _proxyFactory.GetProxy <RepositoryService>(SourceHost, SourcePort, Log.Default);
            // get types
            // for each type load all and save each
            string lastCuid = FromCuid;

            foreach (string type in sourceRepo.GetTypes())
            {
                ReplicationOperation op = this.CopyAs <ReplicationOperation>();
                op.TypeName = type;
                op.FromCuid = lastCuid;
                List <object> values = sourceRepo.NextSet(op).ToList();
                Parallel.ForEach(values, (value) => destination.Save(SaveOperation.For(value)));
                values.Sort((x, y) => x.Property("Cuid").ToString().CompareTo(y.Property("Cuid")));
                lastCuid = values[values.Count - 1].Property("Cuid").ToString();
            }
            ;

            FromCuid = lastCuid;
            Status   = ReplicationStatus.Success;
            return(this);
        }
Example #3
0
 protected void Commit(IDistributedRepository repo, WriteEvent writeEvent)
 {
     repo.Save(SaveOperation.For(writeEvent));
 }