Beispiel #1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            var property           = context.DataContext.GetProperties()[Salesforce_Marketing_Cloud_Scope.SalesForcePropertyTag];
            var salesForceProperty = property.GetValue(context.DataContext) as SalesForceProperty;

            String id = SubscriberID.Get(context);

            var task = (new CmdRestAPI(salesForceProperty.AuthToken, salesForceProperty.ServiceURL, salesForceProperty.SoapClient, null, "Subscriber", id, "", Type_of_Command.DeleteSubscriber)).ExecuteAsync();
            var tcs  = new TaskCompletionSource <CmdRestAPI>(state);

            task.ContinueWith(t =>
            {
                if (t.IsFaulted)
                {
                    tcs.TrySetException(t.Exception.InnerExceptions);
                }
                else if (t.IsCanceled)
                {
                    tcs.TrySetCanceled();
                }
                else
                {
                    tcs.TrySetResult(t.Result);
                }
                if (callback != null)
                {
                    callback(tcs.Task);
                }
            });

            return(tcs.Task);
        }
            /**
             *@brief unregister a class of type T with this system
             *@param[in] obj (T) refrence object to unregister
             *@remark the object must implement the sulphur.editor.ISubscribable else a compile error is thrown
             *@remark in order for e registered object to become eledagble for garbage collection it must be unregistered from this system
             */
            public static void Unregister <T>(T obj) where T : class, ISubscribeable
            {
                Subscription[] subs = obj.GetSubscriptions();
                SubscriberID   id   = new SubscriberID(id <T> .type_id_);

                systems_by_type_[id].Remove(obj);

                foreach (Subscription sub in subs)
                {
                    foreach (ISubscribeable entry in systems_by_type_[sub.target_id])
                    {
                        entry.notify_event -= sub.callback;
                    }
                }

                Dictionary <SubscriberID, List <ISubscribeable> > .Enumerator it = systems_by_type_.GetEnumerator();
                while (it.MoveNext() == true)
                {
                    Subscription[] subscriptions = it.Current.Value[0].GetSubscriptions();
                    if (subscriptions == null)
                    {
                        continue;
                    }

                    bool is_subscribed_to_obj = false;
                    uint index = 0;
                    foreach (Subscription sub in subscriptions)
                    {
                        if (sub.target_id == id)
                        {
                            is_subscribed_to_obj = true;
                            break;
                        }
                        ++index;
                    }

                    if (is_subscribed_to_obj == true)
                    {
                        foreach (ISubscribeable registered in it.Current.Value)
                        {
                            obj.notify_event -= registered.GetSubscriptions()[index].callback;
                        }
                    }
                }
            }
            /**
             *@brief register a class of type T with this system
             *@param[in] obj (T) refrence object to register
             *@remark the object must implement the sulphur.editor.ISubscribable else a compile error is thrown
             */
            public static void Register <T>(T obj) where T : class, ISubscribeable
            {
                ISubscribeable subscribable = obj;

                Subscription[] subs = subscribable.GetSubscriptions();
                SubscriberID   id   = new SubscriberID(id <T> .type_id_);

                if (systems_by_type_.ContainsKey(id) == false)
                {
                    systems_by_type_.Add(id, new List <ISubscribeable>());
                }

                systems_by_type_[id].Add(subscribable);

                if (subs != null)
                {
                    ProcessSubscriptions(subs);
                }
                SubscribeTo(ref obj);
            }
Beispiel #4
0
        public bool HaveColumn(string columnName, string columnValue, out bool retValueMatched)
        {
            bool ret          = false;
            bool valueMatched = false;

            if (columnName == "SubscriberID")
            {
                ret = true;
                if (SubscriberID.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "SubscriberGUID")
            {
                ret = true;
                if (SubscriberGUID.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "RevisionNo")
            {
                ret = true;
                if (RevisionNo.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "SubscriberMessage")
            {
                ret = true;
                if (SubscriberMessage.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "SubscriberEmail")
            {
                ret = true;
                if (SubscriberEmail.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "CreatedDate")
            {
                ret = true;
                if (CreatedDate.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "LastUpdateDate")
            {
                ret = true;
                if (LastUpdateDate.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            if (columnName == "IsDeleted")
            {
                ret = true;
                if (IsDeleted.ToString() == columnValue)
                {
                    valueMatched = true;
                }
            }
            retValueMatched = valueMatched;
            return(ret);
        }
 /**
  *@brief constructor that initializes the readonly values from this class.
  *@param[in] target_type_id (uint) type id of the system you want to subscribe to
  *@param[in] func (sulphur.editor.OnNotification) function to call when the system subscribed to gives a notification
  */
 public Subscription(uint target_type_id, OnNotification func)
 {
     target_id = new SubscriberID(target_type_id);
     callback  = func;
 }