Ejemplo n.º 1
0
 public OperationResult Get()
 {
     var siteUrl = Request.GetQueryNameValuePairs().FirstOrDefault(p => p.Key == "siteUrl").Value;
     var ret = new OperationResult()
     {
         IsSuccess = true
     };
     UsingTenantContext(context => {                
         try
         {
             var tenant = new Tenant(context);
             tenant.SetSiteLockState(siteUrl, SiteLockState.Unlock, wait: true);
         }
         catch (Exception e)
         {
             ret.IsSuccess = false;
             ret.Message = e.Message;
             return;
         }
     });
     if (ret.IsSuccess)
     {
         DbRepository.UsingContext(dbContext => {
             var site = dbContext.GetSite(siteUrl);
             if (site != null)
                 site.ComplianceState.IsLocked = false;
             dbContext.SaveChanges();
         });
     }
     return ret;
 }
Ejemplo n.º 2
0
 public OperationResult Post(SiteInformation data)
 {
     var result = new OperationResult();
     try
     {
         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
             {
                 site.AudienceScope = data.AudienceScope;
                 var status = site.ComplianceState;     
                 if (data.NeedExtend)
                 {                                                   
                     var now = GovernanceWorkflowHelper.GetCurrentBusinessTime();
                     var lockDate = now.AddDays(GovernanceWorkflowHelper.FirstLockNotificationDays);
                     if (status.ExpireDate > lockDate || 
                         status.ExpireDate == DateTime.MinValue)
                         status.ExpireDate = lockDate;
                     if (status.LockedDate > lockDate || 
                         status.LockedDate == DateTime.MinValue)
                         status.LockedDate = lockDate;
                 }
                 else if (data.IsExtend)
                 {
                     status.ExpireDate = data.ExtendDate;
                 }
                 dbContext.SaveChanges();
                 result.IsSuccess = true;
             }
         });
     }
     catch (Exception e)
     {
         result.IsSuccess = false;
         result.Message = e.Message;
     }
     return result;
 }