Esempio n. 1
0
        public bool SelfSync()
        {
            var websitesManaged = _websiteRepository.FindAll().Where(x => x.Accounts != null && x.Accounts.Any(y => y.AccountId == this.AccountId)).Select(x => x.Id).ToList();

            if (IsExits())
            {
                EwhLogger.Common.Info("SeftSync start");

                //var newStaggings = this.Stagging.Where(x=>x.Id==)
                var newWebsiteManaged    = this.Websites.Where(x => !websitesManaged.Contains(x.WebsiteId)).ToList();
                var removeWebsiteManaged = websitesManaged.Where(x => !(this.Websites.Select(y => y.WebsiteId).ToList()).Contains(x)).ToList();
                foreach (var item in newWebsiteManaged)
                {
                    var website = websiteManager.GetEwhWebsite(item.WebsiteId);
                    if (website != null)
                    {
                        website.AddAccount(new AddWebsiteAccountDto()
                        {
                            AccessLevels = item.AccessLevels, AccountId = this.AccountId
                        });
                    }
                }
                foreach (var id in removeWebsiteManaged)
                {
                    var website = websiteManager.GetEwhWebsite(id);
                    if (website != null)
                    {
                        website.RemoveAccount(this.AccountId);
                    }
                }
                EwhLogger.Common.Info("SeftSync end");
            }
            return(true);
        }
Esempio n. 2
0
 public bool Save()
 {
     if (_website == null)
     {
         _website = new Website();
     }
     ewhMapper.ToEntity(_website, this);
     _website.Name = StringUtils.GetSeName(_website.Name);
     if (!IsExits() || string.IsNullOrEmpty(_website.RepositoryName))
     {
         _website.RepositoryName = string.Empty;
         var owner = this.Accounts.FirstOrDefault(x => x.AccessLevels != null && x.AccessLevels.Contains(AccessLevels.Owner.ToString()));
         if (owner != null)
         {
             var ownerAcc = _accountRepository.Get(owner.AccountId);
             if (ownerAcc != null)
             {
                 _website.RepositoryName = _website.Name;
             }
             var checkExitsRepo = _websiteRepository.FindAll().Any(x => x.RepositoryName.ToLower() == _website.RepositoryName.ToLower());
             int i = 1;
             while (checkExitsRepo)
             {
                 _website.RepositoryName = string.Format("{0}-{1}", _website.Name, i);
                 i++;
                 checkExitsRepo = _websiteRepository.FindAll().Any(x => x.RepositoryName.ToLower() == _website.RepositoryName.ToLower());
             }
         }
         else
         {
             this.EwhStatus = GlobalStatus.HaveNoAnOwner;
             return(false);
         }
     }
     _websiteRepository.AddOrUpdate(_website);
     MapFrom(_website);
     return(true);
 }
Esempio n. 3
0
 public List <EwhWebsite> GetListEwhWebsite()
 {
     return(ewhMapper.ToEwhWebsites(_websiteRepository.FindAll().OrderByDescending(x => x.CreatedDate).ToList()));
 }