Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Runbook"/> class.
        /// </summary>
        /// <param name="accountName">
        /// The account name.
        /// </param>
        /// <param name="runbook">
        /// The runbook.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Runbook(string accountName, AutomationManagement.Models.Runbook runbook)
        {
            Requires.Argument("runbook", runbook).NotNull();
            Requires.Argument("accountName", accountName).NotNull();

            this.AutomationAccountName = accountName;
            this.Name = runbook.Name;
            this.Location = runbook.Location;
            this.Type = runbook.Type;
            this.Tags = runbook.Tags ?? new Dictionary<string, string>();

            if (runbook.Properties == null) return;

            this.CreationTime = runbook.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = runbook.Properties.LastModifiedTime.ToLocalTime();
            this.Description = runbook.Properties.Description;

            this.LogVerbose = runbook.Properties.LogVerbose;
            this.LogProgress = runbook.Properties.LogProgress;
            this.State = runbook.Properties.State;
            this.JobCount = runbook.Properties.JobCount;
            this.RunbookType = runbook.Properties.RunbookType;

            this.Parameters = runbook.Properties.Parameters ?? new Dictionary<string, RunbookParameter>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AutomationAccount"/> class.
        /// </summary>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <param name="automationAccount">
        /// The automation account.
        /// </param>
        public AutomationAccount(string resourceGroupName, AutomationManagement.Models.AutomationAccount automationAccount)
        {
            Requires.Argument("AutomationAccount", automationAccount).NotNull();


            if (!string.IsNullOrEmpty(resourceGroupName))
            {
                this.ResourceGroupName = resourceGroupName;
            }
            else
            {
                this.ResourceGroupName = automationAccount.Id.Substring(1).Split(Convert.ToChar("/"))[3];
            }

            this.SubscriptionId = automationAccount.Id.Substring(1).Split(Convert.ToChar("/"))[1];

            this.AutomationAccountName = automationAccount.Name;
            this.Location = automationAccount.Location;

            this.Tags = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            foreach (var kvp in automationAccount.Tags)
            {
                this.Tags.Add(kvp.Key, kvp.Value);
            }

            if (automationAccount.Properties == null) return;

            this.Plan = automationAccount.Properties.Sku != null ? automationAccount.Properties.Sku.Name : null;
            this.CreationTime = automationAccount.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = automationAccount.Properties.LastModifiedTime.ToLocalTime();
            this.State = automationAccount.Properties.State;
            this.LastModifiedBy = automationAccount.Properties.LastModifiedBy;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Runbook"/> class.
        /// </summary>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <param name="accountName">
        /// The account name.
        /// </param>
        /// <param name="runbook">
        /// The runbook.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Runbook(string resourceGroupName, string accountName, AutomationManagement.Models.Runbook runbook)
        {
            Requires.Argument("runbook", runbook).NotNull();
            Requires.Argument("accountName", accountName).NotNull();

            this.ResourceGroupName = resourceGroupName;
            this.AutomationAccountName = accountName;
            this.Name = runbook.Name;
            this.Location = runbook.Location;

            if (runbook.Properties == null) return;

            this.CreationTime = runbook.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = runbook.Properties.LastModifiedTime.ToLocalTime();
            this.Description = runbook.Properties.Description;

            this.LogVerbose = runbook.Properties.LogVerbose;
            this.LogProgress = runbook.Properties.LogProgress;
            this.State = runbook.Properties.State;
            this.JobCount = runbook.Properties.JobCount;
            this.RunbookType = runbook.Properties.RunbookType;
            this.LastModifiedBy = runbook.Properties.LastModifiedBy;
            this.Tags = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            foreach (var kvp in runbook.Tags)
            {
                this.Tags.Add(kvp.Key, kvp.Value);
            }

            this.Parameters = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            foreach (var kvp in runbook.Properties.Parameters)
            {
                this.Parameters.Add(kvp.Key, (object)kvp.Value);
            }
        }
        public void Test_LoadConfig()
        {
            AutomationAction action = new AutomationAction();

            action.Type = "Mouse";

            AutomationAction childAction = new AutomationAction();

            childAction.Type = "Mouse";
            action.AddChild(childAction);

            AutomationStep step = new AutomationStep();

            step.Name        = "First";
            step.Description = "test";
            step.Add(action);

            WebAutomationConfig config = new WebAutomationConfig();

            config.Add(step);

            AutomationManagement manager = new AutomationManagement();

            manager.LoadConfig(config);
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Runbook"/> class.
        /// </summary>
        /// <param name="runbook">
        /// The runbook.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Runbook(AutomationManagement.Models.Runbook runbook)
        {
            Requires.Argument("runbook", runbook).NotNull();
            if (runbook.Schedules == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidRunbookModel));
            }

            this.AccountId = new Guid(runbook.AccountId);
            this.Id = new Guid(runbook.Id);
            this.Name = runbook.Name;
            this.CreationTime = DateTime.SpecifyKind(runbook.CreationTime, DateTimeKind.Utc).ToLocalTime();
            this.LastModifiedTime = DateTime.SpecifyKind(runbook.LastModifiedTime, DateTimeKind.Utc).ToLocalTime();
            this.LastModifiedBy = runbook.LastModifiedBy;
            this.Description = runbook.Description;
            this.IsApiOnly = runbook.IsApiOnly;
            this.IsGlobal = runbook.IsGlobal;

            if (runbook.PublishedRunbookVersionId != null)
            {
                this.PublishedRunbookVersionId = new Guid(runbook.PublishedRunbookVersionId);
            }

            if (runbook.DraftRunbookVersionId != null)
            {
                this.DraftRunbookVersionId = new Guid(runbook.DraftRunbookVersionId);
            }

            this.Tags = runbook.Tags != null ? runbook.Tags.Split(Constants.RunbookTagsSeparatorChar) : new string[] { };
            this.LogDebug = runbook.LogDebug;
            this.LogVerbose = runbook.LogVerbose;
            this.LogProgress = runbook.LogProgress;
            this.ScheduleNames = from schedule in runbook.Schedules where (schedule.NextRun != null) select schedule.Name;
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Job"/> class.
        /// </summary>
        /// <param name="job">The job</param>
        /// The resource.
        /// <summary>
        /// Initializes a new instance of the <see cref="Job"/> class.
        /// </summary>
        public Job(AutomationManagement.Models.Job job)
        {
            Requires.Argument("job", job).NotNull();

            if (job.Context == null || job.Context.RunbookVersion == null || job.Context.RunbookVersion.Runbook == null || job.Context.JobParameters == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidJobModel));
            }

            this.Id = new Guid(job.Id);
            this.AccountId = new Guid(job.AccountId);
            this.Exception = job.Exception;
            this.CreationTime = DateTime.SpecifyKind(job.CreationTime, DateTimeKind.Utc).ToLocalTime();
            this.LastModifiedTime = DateTime.SpecifyKind(job.LastModifiedTime, DateTimeKind.Utc).ToLocalTime();
            this.StartTime = job.StartTime.HasValue
                                 ? DateTime.SpecifyKind(job.StartTime.Value, DateTimeKind.Utc).ToLocalTime()
                                 : this.StartTime;
            this.EndTime = job.EndTime.HasValue
                                 ? DateTime.SpecifyKind(job.EndTime.Value, DateTimeKind.Utc).ToLocalTime()
                                 : this.EndTime;
            this.LastStatusModifiedTime = DateTime.SpecifyKind(job.LastStatusModifiedTime, DateTimeKind.Utc).ToLocalTime();
            this.Status = job.Status;
            this.StatusDetails = job.StatusDetails;
            this.RunbookId = new Guid(job.Context.RunbookVersion.Runbook.Id);
            this.RunbookName = job.Context.RunbookVersion.Runbook.Name;
            this.ScheduleName = job.Context.Schedule != null ? job.Context.Schedule.Name : string.Empty;
            this.JobParameters = from jobParameter in job.Context.JobParameters where jobParameter.Name != Constants.JobStartedByParameterName select new JobParameter(jobParameter);
        }
        public AutomationClient(AzureSubscription subscription,
            AutomationManagement.IAutomationManagementClient automationManagementClient)
        {
            Requires.Argument("automationManagementClient", automationManagementClient).NotNull();

            this.Subscription = subscription;
            this.automationManagementClient = automationManagementClient;
        }
Beispiel #8
0
        public ScrollTask(AutomationManagement manager)
            : base(manager)
        {
            timer = new System.Threading.Timer(new TimerCallback(timer_Tick));
            timer.Change(Timeout.Infinite, Timeout.Infinite);

            random = new Random();
        }
Beispiel #9
0
        public ScrollTask(AutomationManagement manager)
            : base(manager)
        {
            timer = new System.Threading.Timer(new TimerCallback(timer_Tick));
            timer.Change(Timeout.Infinite, Timeout.Infinite);

            random = new Random();
        }
 public RunbookParameter(AutomationManagement.Models.RunbookParameter runbookParameter)
 {
     this.RunbookVersionId = new Guid(runbookParameter.RunbookVersionId);
     this.Name = runbookParameter.Name;
     this.Type = runbookParameter.Type;
     this.IsMandatory = runbookParameter.IsMandatory;
     this.Position = runbookParameter.Position;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DscOnboardingMetaconfig"/> class.
        /// </summary>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <param name="automationAccountName">
        /// The automation account.
        /// </param>
        /// <param name="dscOnboardingMetaConfig">
        /// The dsc onboarding meta configuration.
        /// </param>/// 
        public DscOnboardingMetaconfig(string resourceGroupName, string automationAccountName, AutomationManagement.Models.AgentRegistration dscOnboardingMetaConfig)
        {
            Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
            Requires.Argument("AutomationAccountName", automationAccountName).NotNull();

            this.ResourceGroupName = resourceGroupName;
            this.AutomationAccountName = automationAccountName;
            this.DscMetaConfiguration = dscOnboardingMetaConfig.DscMetaConfiguration;
        }
Beispiel #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobStream"/> class.
        /// </summary>
        /// <param name="jobStream">
        /// The job stream.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public JobStream(AutomationManagement.Models.JobStream jobStream)
        {
            Requires.Argument("jobStream", jobStream).NotNull();

            this.StreamId = jobStream.Properties.StreamId;
            this.StreamType = jobStream.Properties.StreamType;
            this.Summary = jobStream.Properties.Summary;
            this.Time = jobStream.Properties.Time.ToLocalTime();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JobStreamItem"/> class.
        /// </summary>
        /// <param name="jobStreamItem">
        /// The job stream item.
        /// </param>
        public JobStreamItem(AutomationManagement.Models.JobStreamItem jobStreamItem)
        {
            Requires.Argument("jobStreamItem", jobStreamItem).NotNull();

            this.AccountId = new Guid(jobStreamItem.AccountId);
            this.JobId = new Guid(jobStreamItem.JobId);
            this.RunbookVersionId = new Guid(jobStreamItem.RunbookVersionId);
            this.Text = jobStreamItem.Text;
            this.Time = DateTime.SpecifyKind(jobStreamItem.Time, DateTimeKind.Utc).ToLocalTime();
            this.Type = jobStreamItem.Type;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JobStream"/> class.
        /// </summary>
        /// <param name="jobStream">
        /// The job stream.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public JobStream(AutomationManagement.Models.JobStream jobStream, string automationAccountName, Guid jobId )
        {
            Requires.Argument("jobStream", jobStream).NotNull();

            this.JobStreamId = jobStream.Properties.JobStreamId;
            this.Type = jobStream.Properties.StreamType;
            this.Text = jobStream.Properties.Summary;
            this.Time = jobStream.Properties.Time;
            this.AutomationAccountName = automationAccountName;
            this.Id = jobId;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RunbookVersion"/> class.
        /// </summary>
        /// <param name="runbookVersion">
        /// The runbook version.
        /// </param>
        public RunbookVersion(AutomationManagement.Models.RunbookVersion runbookVersion)
        {
            Requires.Argument("runbookVersion", runbookVersion).NotNull();

            this.AccountId = new Guid(runbookVersion.AccountId);
            this.Id = new Guid(runbookVersion.Id);
            this.RunbookId = new Guid(runbookVersion.RunbookId);
            this.VersionNumber = runbookVersion.VersionNumber;
            this.IsDraft = runbookVersion.IsDraft;
            this.CreationTime = DateTime.SpecifyKind(runbookVersion.CreationTime, DateTimeKind.Utc).ToLocalTime();
            this.LastModifiedTime = DateTime.SpecifyKind(runbookVersion.LastModifiedTime, DateTimeKind.Utc).ToLocalTime();
        }
Beispiel #16
0
        // <summary>
        /// Initializes a new instance of the <see cref="Variable"/> class.
        /// </summary>
        /// <param name="variable">
        /// The variable.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Variable(AutomationManagement.Models.EncryptedVariable variable, string automationAccountName)
        {
            Requires.Argument("variable", variable).NotNull();

            this.Name = variable.Name;
            this.CreationTime = variable.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = variable.Properties.LastModifiedTime.ToLocalTime();
            this.Value = null;
            this.Description = variable.Properties.Description;
            this.Encrypted = true;
            this.AutomationAccountName = automationAccountName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RunbookDefinition"/> class.
        /// </summary>
        /// <param name="accountName">
        /// The runbook version.
        /// </param>
        /// <param name="runbook">
        /// The runbook version.
        /// </param>
        /// <param name="content">
        /// The content.
        /// </param>
        /// <param name="slot">
        /// Slot published or draft.
        /// </param>
        public RunbookDefinition(string accountName, AutomationManagement.Models.Runbook runbook, string content, string slot)
        {
            Requires.Argument("runbook", runbook).NotNull();
            Requires.Argument("accountName", accountName).NotNull();
            Requires.Argument("slot", slot).NotNull();

            this.AutomationAccountName = accountName;
            this.Name = runbook.Name;
            this.Content = content;

            if (runbook.Properties == null) return;

            this.CreationTime = runbook.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = runbook.Properties.LastModifiedTime.ToLocalTime();
            this.Slot = slot;
            this.RunbookType = runbook.Properties.RunbookType;
            
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Variable"/> class.
        /// </summary>
        /// <param name="variable">
        /// The varaiable.
        /// </param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public Variable(AutomationManagement.Models.Variable variable, string automationAccoutName)
        {
            Requires.Argument("variable", variable).NotNull();

            this.Name = variable.Name;
            this.CreationTime = variable.Properties.CreationTime.ToLocalTime();
            this.LastModifiedTime = variable.Properties.LastModifiedTime.ToLocalTime();

            if (variable.Properties.Value == null || variable.Properties.IsEncrypted)
            {
                this.Value = null;
            }
            else
            {
                this.Value = PowerShellJsonConverter.Deserialize(variable.Properties.Value);
            }

            this.Description = variable.Properties.Description;
            this.Encrypted = variable.Properties.IsEncrypted;
            this.AutomationAccountName = automationAccoutName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AutomationAccount"/> class.
        /// </summary>
        /// <param name="cloudService">
        /// The cloud service.
        /// </param>
        /// <param name="resource">
        /// The resource.
        /// </param>
        public AutomationAccount(AutomationManagement.Models.CloudService cloudService, AutomationManagement.Models.AutomationResource resource)
        {
            Requires.Argument("cloudService", cloudService).NotNull();
            Requires.Argument("resource", resource).NotNull();

            this.AutomationAccountName = resource.Name;
            this.Location = cloudService.GeoRegion;
            switch (resource.State)
            {
                case AutomationManagement.Models.AutomationResourceState.Started:
                    this.State = Constants.AutomationAccountState.Ready;
                    break;
                case AutomationManagement.Models.AutomationResourceState.Stopped:
                    this.State = Constants.AutomationAccountState.Suspended;
                    break;
                default:
                    this.State = resource.State;
                    break;
            }

            if (resource.IntrinsicSettings != null) this.Plan = resource.IntrinsicSettings.SubscriptionPlan;
        }
Beispiel #20
0
 public AttributeTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #21
0
 public CommonTask(AutomationManagement manager)
 {
     this.webBrowser = (WebBrowserEx)manager.Browser;
     this.manager    = manager;
 }
Beispiel #22
0
 public ClickTask(AutomationManagement manager)
     : base(manager)
 {
 }
        private Variable CreateVariableFromVariableModel(AutomationManagement.Models.Variable variable, string automationAccountName)
        {
            Requires.Argument("variable", variable).NotNull();

            return new Variable(variable, automationAccountName);
        }
        private JobSchedule CreateJobScheduleFromJobScheduleModel(string automationAccountName, AutomationManagement.Models.JobSchedule jobSchedule)
        {
            Requires.Argument("jobSchedule", jobSchedule).NotNull();

            return new JobSchedule(automationAccountName, jobSchedule);
        }
Beispiel #25
0
 public AttributeTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #26
0
 public ClearDataTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #27
0
 public PageTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #28
0
 public KeyboardTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #29
0
 public ConditionTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #30
0
 public TimerTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #31
0
 public BrowserTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #32
0
 public WaitTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #33
0
 public TextTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #34
0
 public BrowserTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #35
0
 public SendKeyTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #36
0
 public FindTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #37
0
 public BrowserFactory(AutomationManagement manager)
 {
     this.manager = manager;
 }
Beispiel #38
0
 public ClearHistoryTask(AutomationManagement manager)
     : base(manager)
 {
 }
        private Schedule CreateScheduleFromScheduleModel(string automationAccountName, AutomationManagement.Models.Schedule schedule)
        {
            Requires.Argument("schedule", schedule).NotNull();

            return new Schedule(automationAccountName, schedule);
        }
Beispiel #40
0
 public FindTask(AutomationManagement manager)
     : base(manager)
 {
 }
 private JobStream CreateJobStreamFromJobStreamModel(AutomationManagement.Models.JobStream jobStream, string automationAccountName, Guid jobId)
 {
     Requires.Argument("jobStream", jobStream).NotNull();
     Requires.Argument("automationAccountName", automationAccountName).NotNull();
     Requires.Argument("jobId", jobId).NotNull();
     return new JobStream(jobStream, automationAccountName, jobId);
 }
Beispiel #42
0
 public SendKeyTask(AutomationManagement manager)
     : base(manager)
 {
 }
        private Credential CreateCredentialFromCredentialModel(AutomationManagement.Models.Credential credential)
        {
            Requires.Argument("credential", credential).NotNull();

            return new Credential(null, credential);
        }
Beispiel #44
0
 public PackageTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #45
0
 public ScriptTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #46
0
 public MouseTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #47
0
 public ClearDataTask(AutomationManagement manager)
     : base(manager)
 {
 }
Beispiel #48
0
 public KeyboardTask(AutomationManagement manager)
     : base(manager)
 {
 }