示例#1
0
        public void GetDayLengthWithNullThis()
        {
            var e = Assert.Throws <ArgumentNullException>(() =>
                                                          TimeZoneInfoExtensions.GetDayLength(null, DateTime.MinValue));

            Assert.Equal("tz", e.ParamName);
        }
示例#2
0
 public static void Test()
 {
     //Test System.TimeZoneInfo.GetTimeZoneString()
     printf("********* TimeZoneInfo Testing *********", ConsoleColor.Green);
     printf(System.TimeZoneInfo.FindSystemTimeZoneById(
                TimeZoneInfoExtensions.GetTimeZoneString(
                    Constants.TimeZone.CentralStandardTime)));
 }
示例#3
0
        public void FromOlsonToTimeZoneIdTest()
        {
            string[] tests = new[]
            {
                "US/Alaska", "Alaskan Standard Time",
                "US/Pacific", "Pacific Standard Time",
            };

            for (int i = 0; i < tests.Length; i += 2)
            {
                string expected = tests[i + 1];
                string actual   = TimeZoneInfoExtensions.FromOlsonToTimeZoneId(tests[i]);
                Assert.AreEqual(expected, actual);
            }
        }
示例#4
0
        public void FromOlsonToTimeZoneInfoTest()
        {
            string[] tests = new[]
            {
                "US/Alaska", "Alaskan Standard Time",
                "US/Pacific", "Pacific Standard Time",
            };

            for (int i = 0; i < tests.Length; i += 2)
            {
                string expected = tests[i + 1];
                var    tzi      = TimeZoneInfoExtensions.FromOlsonToTimeZoneInfo(tests[i]);
                Assert.IsNotNull(tzi);
                Assert.AreEqual(expected, tzi.Id);
            }
        }
        protected override void ProcessRecord()
        {
            if (string.IsNullOrWhiteSpace(Timezone))
            {
                Timezone = TimeZoneInfoExtensions.GetOlsonTimeZone();
            }

            if (!string.IsNullOrWhiteSpace(PolicyName))
            {
                var policy = RestApiCommon.GetPolicyByName(Session.ApiClient, PolicyName);
                PolicyId = policy.Id;
            }

            if (!string.IsNullOrWhiteSpace(StorageDomainName))
            {
                var domain = RestApiCommon.GetStorageDomainByName(Session.ApiClient, StorageDomainName);
                StorageDomainId = (long)domain.Id;
            }

            var newProtectionJob = new Model.ProtectionJob(name: Name, policyId: PolicyId, viewBoxId: StorageDomainId)
            {
                Timezone  = Timezone,
                StartTime = new TimeOfDay(ScheduleStartTime.Hour, ScheduleStartTime.Minute)
            };

            if (ParentSourceId.HasValue)
            {
                newProtectionJob.ParentSourceId = ParentSourceId;
            }

            if (SourceIds != null && SourceIds.Any())
            {
                newProtectionJob.SourceIds = SourceIds.ToList();
            }

            if (ExcludeSourceIds != null && ExcludeSourceIds.Any())
            {
                newProtectionJob.ExcludeSourceIds = ExcludeSourceIds.ToList();
            }

            if (VmTagIds != null && VmTagIds.Any())
            {
                var vmTagIdsList = VmTagIds.ToList();
                newProtectionJob.VmTagIds = new List <List <long> >();
                foreach (var vmTagIds in vmTagIdsList)
                {
                    newProtectionJob.VmTagIds.Add(new List <long> {
                        vmTagIds
                    });
                }
            }

            if (ExcludeVmTagIds != null && ExcludeVmTagIds.Any())
            {
                var excludeVmTagIdsList = ExcludeVmTagIds.ToList();
                newProtectionJob.ExcludeVmTagIds = new List <List <long> >();
                foreach (var excludeVmTagIds in excludeVmTagIdsList)
                {
                    newProtectionJob.ExcludeVmTagIds.Add(new List <long> {
                        excludeVmTagIds
                    });
                }
            }

            if (!string.IsNullOrWhiteSpace(ViewName))
            {
                newProtectionJob.ViewName = ViewName;
            }

            newProtectionJob.Environment = Environment != null ? Environment : Model.ProtectionJob.EnvironmentEnum.KView;

            if (FullSLATimeInMinutes != null)
            {
                newProtectionJob.FullProtectionSlaTimeMins = FullSLATimeInMinutes;
            }

            if (IncrementalSLATimeInMinutes != null)
            {
                newProtectionJob.IncrementalProtectionSlaTimeMins = IncrementalSLATimeInMinutes;
            }

            if (SourceSpecialParameters != null && SourceSpecialParameters.Any())
            {
                newProtectionJob.SourceSpecialParameters = SourceSpecialParameters.ToList();
            }

            var preparedUrl = $"/public/protectionJobs";
            var result      = Session.ApiClient.Post <Model.ProtectionJob>(preparedUrl, newProtectionJob);

            WriteObject(result);
        }