public PSBasicAuthenticationJobDetail (PSHttpJobDetail jobDetail) { foreach(PropertyInfo prop in jobDetail.GetType().GetProperties()) { GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(jobDetail, null), null); } }
public PSAADOAuthenticationJobDetail(PSHttpJobDetail jobDetail) { foreach (PropertyInfo prop in jobDetail.GetType().GetProperties()) { GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(jobDetail, null), null); } }
public PSJobDetail GetJobDetail(string jobCollection, string job, string cloudService) { CloudServiceGetResponse csDetails = csmClient.CloudServices.Get(cloudService); foreach (CloudServiceGetResponse.Resource csRes in csDetails.Resources) { if (csRes.ResourceProviderNamespace.Equals(Constants.SchedulerRPNameProvider, StringComparison.OrdinalIgnoreCase) && csRes.Name.Equals(jobCollection, StringComparison.OrdinalIgnoreCase)) { SchedulerClient schedClient = AzureSession.ClientFactory.CreateCustomClient<SchedulerClient>(cloudService, jobCollection, csmClient.Credentials, schedulerManagementClient.BaseUri); JobListResponse jobs = schedClient.Jobs.List(new JobListParameters { Skip = 0, }); foreach (Job j in jobs) { if (j.Id.ToLower().Equals(job.ToLower())) { if (Enum.GetName(typeof(JobActionType), j.Action.Type).Contains("Http")) { PSHttpJobDetail jobDetail = new PSHttpJobDetail(); jobDetail.JobName = j.Id; jobDetail.JobCollectionName = jobCollection; jobDetail.CloudService = cloudService; jobDetail.ActionType = Enum.GetName(typeof(JobActionType), j.Action.Type); jobDetail.Uri = j.Action.Request.Uri; jobDetail.Method = j.Action.Request.Method; jobDetail.Body = j.Action.Request.Body; jobDetail.Headers = j.Action.Request.Headers; jobDetail.Status = j.State.ToString(); jobDetail.StartTime = j.StartTime; jobDetail.EndSchedule = GetEndTime(j); jobDetail.Recurrence = j.Recurrence == null ? string.Empty : j.Recurrence.Interval.ToString() + " (" + j.Recurrence.Frequency.ToString() + "s)"; if (j.Status != null) { jobDetail.Failures = j.Status.FailureCount; jobDetail.Faults = j.Status.FaultedCount; jobDetail.Executions = j.Status.ExecutionCount; jobDetail.Lastrun = j.Status.LastExecutionTime; jobDetail.Nextrun = j.Status.NextExecutionTime; } if (j.Action.Request.Authentication != null) { switch(j.Action.Request.Authentication.Type) { case HttpAuthenticationType.ClientCertificate: PSClientCertAuthenticationJobDetail ClientCertJobDetail = new PSClientCertAuthenticationJobDetail(jobDetail); ClientCertJobDetail.ClientCertExpiryDate = ((j.Action.Request.Authentication) as ClientCertAuthentication).CertificateExpiration.ToString(); ClientCertJobDetail.ClientCertSubjectName = ((j.Action.Request.Authentication) as ClientCertAuthentication).CertificateSubjectName; ClientCertJobDetail.ClientCertThumbprint = ((j.Action.Request.Authentication) as ClientCertAuthentication).CertificateThumbprint; return ClientCertJobDetail; case HttpAuthenticationType.ActiveDirectoryOAuth: PSAADOAuthenticationJobDetail AADOAuthJobDetail = new PSAADOAuthenticationJobDetail(jobDetail); AADOAuthJobDetail.Audience = ((j.Action.Request.Authentication) as AADOAuthAuthentication).Audience; AADOAuthJobDetail.ClientId = ((j.Action.Request.Authentication) as AADOAuthAuthentication).ClientId; AADOAuthJobDetail.Tenant = ((j.Action.Request.Authentication) as AADOAuthAuthentication).Tenant; return AADOAuthJobDetail; case HttpAuthenticationType.Basic: PSBasicAuthenticationJobDetail BasicAuthJobDetail = new PSBasicAuthenticationJobDetail(jobDetail); BasicAuthJobDetail.Username = ((j.Action.Request.Authentication) as BasicAuthentication).Username; return BasicAuthJobDetail; } } return jobDetail; } else { return new PSStorageQueueJobDetail { JobName = j.Id, JobCollectionName = jobCollection, CloudService = cloudService, ActionType = Enum.GetName(typeof(JobActionType), j.Action.Type), StorageAccountName = j.Action.QueueMessage.StorageAccountName, StorageQueueName = j.Action.QueueMessage.QueueName, SasToken = j.Action.QueueMessage.SasToken, QueueMessage = j.Action.QueueMessage.Message, Status = j.State.ToString(), EndSchedule = GetEndTime(j), StartTime = j.StartTime, Recurrence = j.Recurrence == null ? string.Empty : j.Recurrence.Interval.ToString() + " (" + j.Recurrence.Frequency.ToString() + "s)", Failures = j.Status == null ? default(int?) : j.Status.FailureCount, Faults = j.Status == null ? default(int?) : j.Status.FaultedCount, Executions = j.Status == null ? default(int?) : j.Status.ExecutionCount, Lastrun = j.Status == null ? null : j.Status.LastExecutionTime, Nextrun = j.Status == null ? null : j.Status.NextExecutionTime }; } } } } } return null; }