public void Sync(ObjectClass objClass, SyncToken token,
                         SyncResultsHandler handler,
                         OperationOptions options)
        {
            int remaining = _config.numResults;

            for (int i = 0; i < _config.numResults; i++)
            {
                ConnectorObjectBuilder obuilder =
                    new ConnectorObjectBuilder();
                obuilder.SetUid(i.ToString());
                obuilder.SetName(i.ToString());
                obuilder.ObjectClass = (objClass);

                SyncDeltaBuilder builder =
                    new SyncDeltaBuilder();
                builder.Object    = (obuilder.Build());
                builder.DeltaType = (SyncDeltaType.CREATE_OR_UPDATE);
                builder.Token     = (new SyncToken("mytoken"));
                SyncDelta rv = builder.Build();
                if (handler.Handle(rv))
                {
                    remaining--;
                }
                else
                {
                    break;;
                }
            }
            if (handler is SyncTokenResultsHandler)
            {
                ((SyncTokenResultsHandler)handler).HandleResult(new SyncToken(remaining));
            }
        }
Exemple #2
0
        public virtual void Sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler handler,
                                 OperationOptions options)
        {
            if (ObjectClass.ALL.Equals(objectClass))
            {
                //
            }
            else if (ObjectClass.ACCOUNT.Equals(objectClass))
            {
                var builder = new ConnectorObjectBuilder();
                builder.SetUid("3f50eca0-f5e9-11e3-a3ac-0800200c9a66");
                builder.SetName("Foo");
                builder.AddAttribute(ConnectorAttributeBuilder.BuildEnabled(true));

                var deltaBuilder = new SyncDeltaBuilder
                {
                    Object    = builder.Build(),
                    DeltaType = SyncDeltaType.CREATE,
                    Token     = new SyncToken(10)
                };

                foreach (SyncDelta connectorObject in CollectionUtil.NewSet(deltaBuilder.Build()))
                {
                    if (!handler.Handle(connectorObject))
                    {
                        // Stop iterating because the handler stopped processing
                        break;
                    }
                }
            }
            else
            {
                Trace.TraceWarning("Sync of type {0} is not supported",
                                   _configuration.ConnectorMessages.Format(objectClass.GetDisplayNameKey(),
                                                                           objectClass.GetObjectClassValue()));
                throw new NotSupportedException("Sync of type" + objectClass.GetObjectClassValue() + " is not supported");
            }
            ((SyncTokenResultsHandler)handler).HandleResult(new SyncToken(10));
        }
Exemple #3
0
 public void Sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler handler, OperationOptions options)
 {
     Assert.IsNotNull(objectClass);
     Assert.IsNotNull(token);
     Assert.IsNotNull(handler);
     Assert.IsNotNull(options);
     AddCall("Sync", objectClass, token, handler, options);
     if (ObjectClass.ALL.Equals(objectClass))
     {
         if (null != CollectionUtil.GetValue(options.Options, "FAIL_DELETE", null))
         {
             //Require ObjectClass when delta is 'delete'
             var builder = new SyncDeltaBuilder();
             builder.DeltaType = SyncDeltaType.DELETE;
             builder.Uid       = new Uid("DELETED");
             builder.Token     = new SyncToken(99);
             handler.Handle(builder.Build());
         }
         else
         {
             ((SyncTokenResultsHandler)handler).HandleResult(new SyncToken(100));
         }
     }
 }
Exemple #4
0
 /// <summary>
 /// Process/handle the SyncDelta result
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 public Object Process(SyncDelta result)
 {
     return(_handler.Handle(result));
 }