Example #1
0
        protected override void Execute(CodeActivityContext context)
        {
            console = ActivityConsole.GetDefaultOrNew(context);

            string machineName = MachineName.Get(context);

            machineName = (string.IsNullOrEmpty(machineName) ? "." : machineName);

            bool throwOnError         = ThrowOnError.Get(context);
            bool treatExistsAsSuccess = TreatExistAsSuccess.Get(context);

            string errorMessage = "An unknown error has occurred.";
            bool   created      = CreateLogSource(machineName, EventLogName.Get(context), EventLogSource.Get(context), out errorMessage, treatExistsAsSuccess);

            if (created)
            {
                console.WriteLine(string.Format("Successfully created or verified event log and source : {0} - {1}", EventLogName.Get(context), EventLogSource.Get(context)));
            }
            else
            {
                if (throwOnError)
                {
                    throw new ArgumentException(errorMessage);
                }
                else
                {
                    console.WriteLine(string.Format("Error : {0}", errorMessage));
                }
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            CloudBlobContainer blobContainer = new CloudBlobContainer(GetBlobStorageUri(context, Container.Get(context), string.Empty), GetCredentials(context));
            bool   result       = false;
            string errorMessage = "Unknown error.";

            try
            {
                result = blobContainer.CreateIfNotExists();
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
            if (ThrowOnError.Get(context))
            {
                throw new ArgumentException(string.Format("Could not create blob container '{0}' : {1}", Container.Get(context), errorMessage));
            }
            Success.Set(context, result);
        }
Example #3
0
        protected override void Execute(CodeActivityContext context)
        {
            CloudBlobContainer blobContainer = new CloudBlobContainer(GetBlobStorageUri(context, Container.Get(context), Path.Get(context)), GetCredentials(context));
            var    result       = new List <CloudBlob>();
            string errorMessage = "Unknown error.";

            try
            {
                result = blobContainer.ListBlobs(Prefix.Get(context), true, BlobListingDetails.Metadata | BlobListingDetails.Copy).Select(b => (CloudBlob)b).ToList();
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
            if (ThrowOnError.Get(context))
            {
                throw new ArgumentException(string.Format("Could not query blob container '{0}' : {1}", Container.Get(context), errorMessage));
            }
            Result.Set(context, result);
        }