Exemplo n.º 1
0
        protected override CmdRestAPI EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
        {
            CmdRestAPI temp = ((Task <CmdRestAPI>)result).Result;

            Response.Set(context, temp.Response);
            SubcriberKey.Set(context, temp.ID);
            ValidConnection.Set(context, temp.ValidConnection);
            return(temp);
        }
Exemplo n.º 2
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 = SubcriberKey.Get(context);

            var newDataTable = new System.Data.DataTable();

            newDataTable.TableName = "TableName";
            newDataTable.Columns.Add(new DataColumn("Parameter", typeof(string))
            {
                MaxLength = 200
            });
            newDataTable.Columns.Add(new DataColumn("Value", typeof(string))
            {
                MaxLength = 60000
            });
            newDataTable.Columns.Add(new DataColumn("isEnabled", typeof(Boolean))
            {
                DefaultValue = true
            });
            foreach (ParametersArgument item in Parameters)
            {
                var row = newDataTable.NewRow();
                row["Parameter"] = item.Parameter.Get(context);
                row["Value"]     = item.ValueData.Get(context);
                newDataTable.Rows.Add(row);
            }

            var task = (new CmdRestAPI(salesForceProperty.AuthToken, salesForceProperty.ServiceURL, salesForceProperty.SoapClient, newDataTable, "Keyword", id, "", cmdTYPE)).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);
        }