Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Job"/> class.
        /// </summary>
        /// <param name="accountName">
        /// The account name.
        /// </param>
        /// <param name="Job">
        /// The Job.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Job(string accountName, WindowsAzure.Management.Automation.Models.Job job)
        {
            Requires.Argument("job", job).NotNull();
            Requires.Argument("accountName", accountName).NotNull();

            this.AutomationAccountName = accountName;

            if (job.Properties == null) return;

            this.Id = job.Properties.JobId;
            this.CreationTime = job.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = job.Properties.LastModifiedTime.ToLocalTime();
            this.StartTime = job.Properties.StartTime.HasValue ? job.Properties.StartTime.Value.ToLocalTime() : (DateTimeOffset?)null;
            this.Status = job.Properties.Status;
            this.StatusDetails = job.Properties.StatusDetails;
            this.RunbookName = job.Properties.Runbook.Name;
            this.Exception = job.Properties.Exception;
            this.EndTime = job.Properties.EndTime.HasValue ? job.Properties.EndTime.Value.ToLocalTime() : (DateTimeOffset?) null;
            this.LastStatusModifiedTime = job.Properties.LastStatusModifiedTime;
            this.HybridWorker = job.Properties.RunOn;
            this.JobParameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            foreach (var kvp in job.Properties.Parameters) 
            {
                if (0 != String.Compare(kvp.Key, Constants.JobStartedByParameterName, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase) && 
                    0 != String.Compare(kvp.Key, Constants.JobRunOnParameterName, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase))
                {
                    this.JobParameters.Add(kvp.Key, (object)PowerShellJsonConverter.Deserialize(kvp.Value));
                }
            }
        }
            public bool ShouldRetry(
                int currentRetryCount, 
                int statusCode, 
                Exception lastException, 
                out TimeSpan retryInterval, 
                WindowsAzure.Storage.OperationContext operationContext)
            {
                retryInterval = TimeSpan.FromMilliseconds(100);

                return _retryPolicy.ErrorDetectionStrategy.IsTransient(lastException) && _shouldRetry(currentRetryCount, lastException, out retryInterval);
            }
         /// <summary>
        /// Initializes a new instance of the <see cref="CredentialInfo"/> class.
        /// </summary>
        /// <param name="Credential">
        /// The Credential.
        /// </param>
        public CredentialInfo(string accountAcccountName, WindowsAzure.Management.Automation.Models.Credential credential)
        {
            Requires.Argument("credential", credential).NotNull();
            this.AutomationAccountName = accountAcccountName;
            this.Name = credential.Name;

            if (credential.Properties == null) return;

            this.Description = credential.Properties.Description;
            this.CreationTime = credential.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = credential.Properties.LastModifiedTime.ToLocalTime();
            this.UserName = credential.Properties.UserName;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="JobSchedule"/> class.
 /// </summary>
 /// <param name="jobSchedule">
 /// The job schedule.
 /// </param>
 public JobSchedule(string automationAccountName, WindowsAzure.Management.Automation.Models.JobSchedule jobSchedule)
 {
     Requires.Argument("jobSchedule", jobSchedule).NotNull();
     this.AutomationAccountName = automationAccountName;
     this.JobScheduleId = jobSchedule.Properties.Id;
     this.RunbookName = jobSchedule.Properties.Runbook.Name;
     this.ScheduleName = jobSchedule.Properties.Schedule.Name;
     this.Parameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
     foreach (var kvp in jobSchedule.Properties.Parameters.Where(kvp => 0 != String.Compare(kvp.Key, Constants.JobStartedByParameterName, CultureInfo.InvariantCulture,
         CompareOptions.IgnoreCase)))
     {
         this.Parameters.Add(kvp.Key, (object)PowerShellJsonConverter.Deserialize(kvp.Value));
     }
 }
         /// <summary>
        /// Initializes a new instance of the <see cref="CertificateInfo"/> class.
        /// </summary>
        /// <param name="accountAcccountName">
        /// The account name.
        /// </param>
        /// <param name="certificate">
        /// The connection.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public CertificateInfo(string accountAcccountName, WindowsAzure.Management.Automation.Models.Certificate certificate)
        {
            Requires.Argument("certificate", certificate).NotNull();
            this.AutomationAccountName = accountAcccountName;
            this.Name = certificate.Name;

            if (certificate.Properties == null) return;

            this.Description = certificate.Properties.Description;
            this.CreationTime = certificate.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = certificate.Properties.LastModifiedTime.ToLocalTime();
            this.ExpiryTime = certificate.Properties.ExpiryTime.ToLocalTime();
            this.Thumbprint = certificate.Properties.Thumbprint;
            this.Exportable = certificate.Properties.IsExportable;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Schedule"/> class.
 /// </summary>
 /// <param name="schedule">
 /// The schedule.
 /// </param>
 public Schedule(string automationAccountName, WindowsAzure.Management.Automation.Models.Schedule schedule)
 {
     Requires.Argument("schedule", schedule).NotNull();
     this.AutomationAccountName = automationAccountName;
     this.Name = schedule.Name;
     this.Description = schedule.Properties.Description;
     this.StartTime = schedule.Properties.StartTime.ToLocalTime();
     this.ExpiryTime = schedule.Properties.ExpiryTime.ToLocalTime();
     this.CreationTime = schedule.Properties.CreationTime.ToLocalTime();
     this.LastModifiedTime = schedule.Properties.LastModifiedTime.ToLocalTime();
     this.IsEnabled = schedule.Properties.IsEnabled;
     this.NextRun = schedule.Properties.NextRun.HasValue
                        ? schedule.Properties.NextRun.Value.ToLocalTime()
                        : this.NextRun;
     this.Interval = schedule.Properties.Interval.HasValue ? schedule.Properties.Interval.Value : this.Interval;
     this.Frequency = (ScheduleFrequency)Enum.Parse(typeof(ScheduleFrequency), schedule.Properties.Frequency, true);
 }
         /// <summary>
        /// Initializes a new instance of the <see cref="Connection"/> class.
        /// </summary>
        /// <param name="accountAcccountName">
        /// The account name.
        /// </param>
        /// <param name="connection">
        /// The connection.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Connection(string accountAcccountName, WindowsAzure.Management.Automation.Models.Connection connection)
        {
            Requires.Argument("connection", connection).NotNull();
            this.AutomationAccountName = accountAcccountName;
            this.Name = connection.Name;

            if (connection.Properties == null) return;

            this.Description = connection.Properties.Description;
            this.CreationTime = connection.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = connection.Properties.LastModifiedTime.ToLocalTime();
            this.ConnectionTypeName = connection.Properties.ConnectionType.Name;
            this.FieldDefinitionValues = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            foreach (var kvp in connection.Properties.FieldDefinitionValues)
            {
                this.FieldDefinitionValues.Add(kvp.Key, (object)PowerShellJsonConverter.Deserialize(kvp.Value));
            }
        }
         /// <summary>
        /// Initializes a new instance of the <see cref="Module"/> class.
        /// </summary>
        /// <param name="Module">
        /// The Module.
        /// </param>
        public Module(string automationAccountName, WindowsAzure.Management.Automation.Models.Module module)
        {
            Requires.Argument("module", module).NotNull();
            this.AutomationAccountName = automationAccountName;
            this.Name = module.Name;
            this.Location = module.Location;
            this.Tags = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            foreach (var kvp in module.Tags)
            {
                this.Tags.Add(kvp.Key, kvp.Value);
            }

            if (module.Properties == null) return;
            
            this.CreationTime = module.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = module.Properties.LastModifiedTime.ToLocalTime();
            this.IsGlobal = module.Properties.IsGlobal;
            this.Version = module.Properties.Version;
            this.ProvisioningState = module.Properties.ProvisioningState.ToString();
            this.ActivityCount = module.Properties.ActivityCount;
            this.SizeInBytes = module.Properties.SizeInBytes;
        }
 /// <summary>
 /// Set service properties
 /// </summary>
 /// <param name="account">Cloud storage account</param>
 /// <param name="type">Service type</param>
 /// <param name="properties">Service properties</param>
 /// <param name="options">Request options</param>
 /// <param name="operationContext">Operation context</param>
 public void SetStorageServiceProperties(StorageServiceType type, WindowsAzure.Storage.Shared.Protocol.ServiceProperties properties, IRequestOptions options, OperationContext operationContext)
 {
     throw new NotImplementedException("No need to cover this in unit test since there are no additional logics on this api");
 }