コード例 #1
0
        public VirtualMachine(AzureConnection connection, SystemMessageContainer container = null, VirtualMachineSizeTypes vmSize = null)
        {
            azureConnection = connection;
            if (vmSize == null)
            {
                vmSize = VirtualMachineSizeTypes.BasicA1;
            }

            this.vmSize = vmSize;

            messageContainer = (container == null ? new SystemMessageContainer() : container);
        }
コード例 #2
0
        public AzureConnection(String credentialsFile = null, SystemMessageContainer messageContainer = null)
        {
            if (credentialsFile == null)
            {
                throw new NullReferenceException("Please provide a valid credentials file to connecting to Azure");
            }

            azureConnection = Azure.Configure()
                              .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                              .Authenticate(SdkContext.AzureCredentialsFactory.FromFile(credentialsFile))
                              .WithDefaultSubscription();

            this.messageContainer = (messageContainer == null ? new SystemMessageContainer() : messageContainer);

            CreateResourceGroupIfNotExists();
        }
コード例 #3
0
        public BlobStorage(String connectionString = null, SystemMessageContainer container = null)
        {
            if (connectionString == null)
            {
                throw new NullReferenceException("Please provide a connection string for creating blob storage on Azure");
            }

            messageContainer = (container == null ? new SystemMessageContainer() : container);

            if (CloudStorageAccount.TryParse(connectionString, out storageAccount))
            {
                messageContainer.AddInformationMessage("Successfully connected to storage account");
            }
            else //Failure - alert user in a friendly manner
            {
                messageContainer.AddErrorMessage("An error occurred in connecting to the storage account", "Attempted to use connection string: " + connectionString);
            }
        }
コード例 #4
0
        protected void Convert(object sender, EventArgs e)
        {
            bool isTest = ((Control)sender).ID.Equals(TestButtonId);

            try
            {
                IContent content = null;

                if (!Recursive.Checked)
                {
                    content = (IContent)ContentRepository.Get <BlockData>(new ContentReference(int.Parse(PageRoot.Text)));
                }
                else
                {
                    content = ContentRepository.Get <PageData>(ContentReference.RootPage);
                }

                if (isTest)
                {
                    SystemMessageContainer messageContainer = SystemMessageContainer;
                    messageContainer.Message = messageContainer.Message + "<strong>" + Translate("/admin/convertblocktype/istesting") + "</strong><br/>";
                }
                VerifyFormsValues(isTest);
                SystemMessageContainer.Message += HttpUtility.HtmlEncode(BlockTypeConverter.Convert(content.ContentLink, Properties.FromBlockType as BlockType, Properties.ToBlockType as BlockType, Properties.GetMappingsForProperties(), Recursive.Checked, isTest)).Replace("\n", "<br/>");
                foreach (string str in GetEffectedMirorringChannelsByConvertingPage(content.ContentLink, Recursive.Checked))
                {
                    SystemMessageContainer messageContainer = SystemMessageContainer;
                    messageContainer.Message = messageContainer.Message + "<br/>" + string.Format(CultureInfo.InvariantCulture, TranslateFallback("/admin/convertblocktype/haseffectonmirroring", "Convert page has effect on mirroring channel {0}."), str);
                }
            }
            catch (EPiServerException ex)
            {
                SystemMessageContainer messageContainer = SystemMessageContainer;
                messageContainer.Message = messageContainer.Message + Translate("/admin/convertblocktype/converterror") + ex.Message;
            }
            catch (Exception ex)
            {
                SystemMessageContainer messageContainer = SystemMessageContainer;
                messageContainer.Message = messageContainer.Message + Translate("/admin/convertblocktype/converterror") + ex.Message + "\n" + ex.StackTrace.Replace("\n", "<br/>");
            }
        }
コード例 #5
0
        public AzureBatchClient(String accountName = null, String accountKey = null, String accountURL = null, BlobStorage storage = null, String poolID = null, String jobID = null, int poolNodeCount = 2, String poolVMSize = null, SystemMessageContainer container = null)
        {
            if (accountName == null)
            {
                throw new NullReferenceException("Please provide a valid batch account name");
            }
            if (accountKey == null)
            {
                throw new NullReferenceException("Please provide a valid batch account key");
            }
            if (accountURL == null)
            {
                throw new NullReferenceException("Please provide a valid batch account URL");
            }
            if (storage == null)
            {
                throw new NullReferenceException("Please provide a valid blob storange reference");
            }

            batchAccountName = accountName;
            batchAccountKey  = accountKey;
            batchAccountURL  = accountURL;
            blobStorage      = storage;

            poolID     = (poolID == null ? AzureConnectionUtility.BuildProjectNameReference() + "-pool" : poolID);
            jobID      = (jobID == null ? AzureConnectionUtility.BuildProjectNameReference() + "-job" : jobID);
            poolVMSize = (poolVMSize == null ? "Basic_A1" : poolVMSize);

            messageContainer = (container == null ? new SystemMessageContainer() : container);

            messageContainer.AddInformationMessage("Creating batch client...");

            batchClient = BatchClient.Open(new BatchSharedKeyCredentials(batchAccountURL, batchAccountName, batchAccountKey));
            messageContainer.AddInformationMessage("Batch client created...");

            //Create the pool if it doesn't exist
            pool = CreatePoolIfNotExists(poolID, poolVMSize, poolNodeCount);
            job  = CreateJobIfNotExists(jobID, pool.Id);
        }