Ejemplo n.º 1
0
        protected override void Execute(NativeActivityContext context)
        {
            this._context = ContextName.Get(context);
            string aFolder = "";

            if (Retries == null || Retries.Get(context) <= 0)
            {
                throw new Exception("Retries cannot be zero or negative.");
            }

            if (InputFolder != null)
            {
                aFolder = InputFolder.Get(context);
            }

            Dictionary <string, string> aArguments = new Dictionary <string, string>();

            aArguments["Folder"]  = aFolder;
            aArguments["Retries"] = Retries.Get(context).ToString();

            try
            {
                aContext = new ContextClient(ContextType, this._context, aArguments, this.Debug);

                aContext.CreateClient();
                if (ContextType == contextType.File && this.ClearContext)
                {
                    aContext.ClearAll();
                }

                if (Body != null)
                {
                    //scheduling the execution of the child activities
                    // and passing the value of the delegate argument
                    context.ScheduleAction(Body, aContext, OnCompleted, OnFaulted);
                }
            }
            catch (Exception exception)
            {
                if (this.Debug)
                {
                    Console.WriteLine("[SharedContext Scope] There is an error!!");
                    Console.WriteLine(exception.Message);
                }
                CleanupContext();
                throw;
            }
        }