Пример #1
0
        public Result <JObject> TriggerReplication(ReplicationOptions aReplicationOptions, Result <JObject> aResult)
        {
            if (aReplicationOptions == null)
            {
                throw new ArgumentNullException("aReplicationOptions");
            }
            if (aResult == null)
            {
                throw new ArgumentNullException("aResult");
            }

            Plug p = BasePlug.At(Constants.REPLICATE);

            string json = aReplicationOptions.ToString();

            p.Post(DreamMessage.Ok(MimeType.JSON, json), new Result <DreamMessage>()).WhenDone(
                a =>
            {
                if ((a.Status == DreamStatus.Accepted) ||
                    (a.Status == DreamStatus.Ok))
                {
                    aResult.Return(JObject.Parse(a.ToText()));
                }
                else
                {
                    aResult.Throw(new CouchException(a));
                }
            },
                aResult.Throw
                );

            return(aResult);
        }
Пример #2
0
 /// <summary>
 /// Triggers one way replication from the source to target.  If bidirection is needed call this method twice with the source and target args reversed.
 /// </summary>
 /// <param name="aReplicationOptions">Replication options</param>
 /// <returns></returns>
 public JObject TriggerReplication(ReplicationOptions aReplicationOptions)
 {
     return TriggerReplication(aReplicationOptions, new Result<JObject>()).Wait();
 }
Пример #3
0
        public Result<JObject> TriggerReplication(ReplicationOptions aReplicationOptions, Result<JObject> aResult)
        {
            if (aReplicationOptions == null)
                throw new ArgumentNullException("aReplicationOptions");
            if (aResult == null)
                throw new ArgumentNullException("aResult");

            Plug p = BasePlug.At(Constants.REPLICATE);

            string json = aReplicationOptions.ToString();
            p.Post(DreamMessage.Ok(MimeType.JSON, json), new Result<DreamMessage>()).WhenDone(
                a =>
                {
                    if((a.Status == DreamStatus.Accepted)||
                       (a.Status == DreamStatus.Ok))
                    {
                        aResult.Return(JObject.Parse(a.ToText()));
                    }
                    else
                    {
                        aResult.Throw(new CouchException(a));
                    }
                },
                aResult.Throw
            );

            return aResult;
        }
Пример #4
0
 /// <summary>
 /// Triggers one way replication from the source to target.  If bidirection is needed call this method twice with the source and target args reversed.
 /// </summary>
 /// <param name="aReplicationOptions">Replication options</param>
 /// <returns></returns>
 public JObject TriggerReplication(ReplicationOptions aReplicationOptions)
 {
     return(TriggerReplication(aReplicationOptions, new Result <JObject>()).Wait());
 }