Пример #1
0
        public SiteInformation Get()
        {
            var result  = new SiteInformation();
            var siteUrl = Request.GetQueryNameValuePairs().FirstOrDefault(p => p.Key == "siteUrl").Value;

            DbRepository.UsingContext(dbContext =>
            {
                var site = dbContext.GetSite(siteUrl);
                if (site == null)
                {
                    result.IsSuccess = false;
                    result.Message   = string.Format(UxResources.SiteRecordNotFound, siteUrl);
                }
                else
                {
                    ILifeCycleHelper helper = new LifeCyclePolicy();
                    result.AudienceScope    = site.AudienceScope;
                    result.ExpireDate       = site.ComplianceState.ExpireDate;
                    result.NeedExtend       = GovernanceWorkflowHelper.NeedExtend(
                        helper.GetExpiredDate(site));
                    result.CanDecommission =
                        site.ComplianceState.IsCompliant &&
                        !result.NeedExtend;

                    DateTime tmp = site.ComplianceState.ExpireDate;
                    site.ComplianceState.ExpireDate = DateTime.MinValue;
                    var extendDate = helper.GetExpiredDate(site);
                    site.ComplianceState.ExpireDate = tmp;

                    result.IsSuccess = true;
                }
            });
            return(result);
        }
Пример #2
0
        public void LifeCyclePolicyIsCompliantTest()
        {
            var lifeCyclePolicy = new LifeCyclePolicy();
            var site            = GetMockUpSiteInformation();

            Assert.IsFalse(lifeCyclePolicy.IsCompliant(site));
            site.ComplianceState.ExpireDate = DateTime.UtcNow.AddDays(30);
            Assert.IsFalse(lifeCyclePolicy.IsCompliant(site));
            site.ComplianceState.ExpireDate = DateTime.UtcNow.AddDays(31);
            Assert.IsTrue(lifeCyclePolicy.IsCompliant(site));
            site.ComplianceState.ExpireDate = DateTime.UtcNow.AddDays(29);
            Assert.IsFalse(lifeCyclePolicy.IsCompliant(site));
        }
Пример #3
0
        public void LifeCyclePolicyProcessTest()
        {
            var lifeCyclePolicy = new LifeCyclePolicy();
            var site            = GetMockUpSiteInformation();

            lifeCyclePolicy.Process(site);
            Assert.IsTrue(site.ComplianceState.LockedDate == site.ComplianceState.ExpireDate);
            site.ComplianceState.LockedDate = DateTime.MinValue;
            lifeCyclePolicy.Process(site);
            Assert.IsTrue(site.ComplianceState.LockedDate == site.ComplianceState.ExpireDate);
            site.ComplianceState.LockedDate  = DateTime.MinValue;
            site.ComplianceState.IsCompliant = true;
            lifeCyclePolicy.Process(site);
            Assert.IsTrue(site.ComplianceState.LockedDate == DateTime.MinValue);
            site.ComplianceState.ExpireDate = DateTime.MinValue;
            site.ComplianceState.LockedDate = DateTime.MinValue;
            lifeCyclePolicy.Process(site);
            Assert.IsTrue(site.ComplianceState.ExpireDate == site.CreatedDate.AddMonths(6));
        }