コード例 #1
0
        public void SaveAndPublish() {
            var languageId = Language.CurrentLanguageId;

            using (var context = new DataContext())
            {
                var siteEntity = context.Sites.SingleOrDefault(x => x.SiteId == SiteId);

                if (siteEntity == null) {
                    siteEntity = new SiteEntity {
                        SiteId = SiteId
                    };

                    context.Add(siteEntity);
                    context.SaveChanges();
                }

                siteEntity.Author = HttpContext.Current.User.Identity.Name;
                siteEntity.ChildSortDirection = ChildSortDirection;
                siteEntity.ChildSortOrder = ChildSortOrder;
                siteEntity.Name = Name;
                siteEntity.UpdateDate = DateTime.Now.ToUniversalTime();

                context.SaveChanges();

                // ---------------

                var propertiesForSite = context.SiteProperties.Where(x => x.SiteId == SiteId && x.LanguageId == languageId).ToList();

                foreach (var propertyItem in Property) {
                    var propertyEntity = propertiesForSite.Find(c => c.PropertyId == propertyItem.PropertyId);

                    if (propertyEntity == null) {
                        propertyEntity = new SitePropertyEntity {
                            LanguageId = languageId,
                            SiteId = SiteId,
                            PropertyId = propertyItem.PropertyId
                        };
                        context.Add(propertyEntity);
                        propertiesForSite.Add(propertyEntity);
                    }

                    propertyEntity.SiteData = GetSerializedPropertyValue(propertyItem);
                }

                context.SaveChanges();
            }

            SiteFactory.UpdateSite(this);
            CacheManager.RemoveRelated(SiteId);


            SiteFactory.RaiseSitePublished(SiteId, languageId);
        }
コード例 #2
0
ファイル: SiteData.cs プロジェクト: KalikoCMS/KalikoCMS.Core
 private static SiteEntity AddStandardSite(DataContext context) {
     var site = new SiteEntity {
         SiteId = Guid.Empty,
         Name = "Site",
         ChildSortDirection = CmsSite.DefaultChildSortDirection,
         ChildSortOrder = CmsSite.DefaultChildSortOrder,
         UpdateDate = DateTime.Now.ToUniversalTime()
     };
     context.AttachCopy(site);
     context.SaveChanges();
     
     return site;
 }
コード例 #3
0
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            if (SiteEntity != null && SiteEntity != Civ)
            {
                eventString += SiteEntity.ToLink(link, pov, this) + " of ";
            }

            eventString += Civ.ToLink(link, pov, this) + " abandoned the settlement at " + Site.ToLink(link, pov, this);
            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
コード例 #4
0
        public ImageUploader(OAuthToken token)
        {
            _oauthToken = token;

            var site = new SiteEntity(_oauthToken);
            var user = site.GetAuthenticatedUserAsync().Result;

            var templates = user.GetAlbumTemplatesAsync().Result;

            _noBuyTemplate   = templates.Single(t => t.Name == "NoBuy");
            _defaultTemplate = templates.Single(t => t.Name == "KHainePhotography");
            _rootNode        = user.GetRootNodeAsync().Result;
            CustomersFolder  = _rootNode.GetChildrenAsync(type: TypeEnum.Folder).Result.Single(f => f.Name == "Customers");
        }
コード例 #5
0
        public ReclaimSite(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "civ_id": Civ = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "site_civ_id": SiteEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "unretire": Unretired = true; property.Known = true; break;
                }
            }

            if (SiteEntity != null && SiteEntity != Civ)
            {
                SiteEntity.Parent = Civ;
            }

            //Make sure period was lost by an event, otherwise unknown loss
            if (Site.OwnerHistory.Count == 0)
            {
                Site.OwnerHistory.Add(new OwnerPeriod(Site, null, -1, "founded"));
            }
            if (Site.OwnerHistory.Last().EndYear == -1)
            {
                Site.OwnerHistory.Last().EndCause = "abandoned";
                Site.OwnerHistory.Last().EndYear  = Year - 1 == 0 ? -1 : Year - 1;
            }
            if (Unretired)
            {
                Site.OwnerHistory.Add(new OwnerPeriod(Site, SiteEntity, Year, "unretired"));
            }
            else
            {
                Site.OwnerHistory.Add(new OwnerPeriod(Site, SiteEntity, Year, "reclaimed"));
            }

            Civ.AddEvent(this);
            if (SiteEntity != Civ)
            {
                SiteEntity.AddEvent(this);
            }

            Site.AddEvent(this);
        }
コード例 #6
0
        /// <summary>
        /// Returns all site collections in the current Tenant based on a startIndex. IncludeDetail adds additional properties to the SPSite object.
        /// </summary>
        /// <param name="tenant">Tenant object to operate against</param>
        /// <param name="startIndex">Not relevant anymore</param>
        /// <param name="endIndex">Not relevant anymore</param>
        /// <param name="includeDetail">Option to return a limited set of data</param>
        /// <param name="includeOD4BSites">Also return the OD4B sites</param>
        /// <returns>An IList of SiteEntity objects</returns>
        public static IList <SiteEntity> GetSiteCollections(this Tenant tenant, int startIndex = 0, int endIndex = 500000, bool includeDetail = true, bool includeOD4BSites = false)
        {
            var sites = new List <SiteEntity>();
            SPOSitePropertiesEnumerable props = null;

            while (props == null || props.NextStartIndexFromSharePoint != null)
            {
                // approach to be used as of Feb 2017
                SPOSitePropertiesEnumerableFilter filter = new SPOSitePropertiesEnumerableFilter()
                {
                    IncludePersonalSite = includeOD4BSites ? PersonalSiteFilter.Include : PersonalSiteFilter.UseServerDefault,
                    StartIndex          = props == null ? null : props.NextStartIndexFromSharePoint,
                    IncludeDetail       = includeDetail
                };
                props = tenant.GetSitePropertiesFromSharePointByFilters(filter);

                // Previous approach, being replaced by GetSitePropertiesFromSharePointByFilters which also allows to fetch OD4B sites
                //props = tenant.GetSitePropertiesFromSharePoint(props == null ? null : props.NextStartIndexFromSharePoint, includeDetail);
                tenant.Context.Load(props);
                tenant.Context.ExecuteQueryRetry();

                foreach (var prop in props)
                {
                    var siteEntity = new SiteEntity();
                    siteEntity.Lcid                = prop.Lcid;
                    siteEntity.SiteOwnerLogin      = prop.Owner;
                    siteEntity.StorageMaximumLevel = prop.StorageMaximumLevel;
                    siteEntity.StorageWarningLevel = prop.StorageWarningLevel;
                    siteEntity.Template            = prop.Template;
                    siteEntity.TimeZoneId          = prop.TimeZoneId;
                    siteEntity.Title               = prop.Title;
                    siteEntity.Url = prop.Url;
                    siteEntity.UserCodeMaximumLevel    = prop.UserCodeMaximumLevel;
                    siteEntity.UserCodeWarningLevel    = prop.UserCodeWarningLevel;
                    siteEntity.CurrentResourceUsage    = prop.CurrentResourceUsage;
                    siteEntity.LastContentModifiedDate = prop.LastContentModifiedDate;
                    siteEntity.StorageUsage            = prop.StorageUsage;
                    siteEntity.WebsCount = prop.WebsCount;
                    SiteLockState lockState;
                    if (Enum.TryParse(prop.LockState, out lockState))
                    {
                        siteEntity.LockState = lockState;
                    }
                    sites.Add(siteEntity);
                }
            }

            return(sites);
        }
コード例 #7
0
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            eventString += SiteEntity != null?SiteEntity.ToLink(link, pov, this) : "UNKNOWN ENTITY";

            eventString += " of ";
            eventString += Civ != null?Civ.ToLink(link, pov, this) : "UNKNOWN CIV";

            eventString += " at the settlement of ";
            eventString += Site != null?Site.ToLink(link, pov, this) : "UNKNOWN SITE";

            eventString += " regained their senses after an initial period of questionable judgment.";
            return(eventString);
        }
コード例 #8
0
        private static SiteEntity AddStandardSite(DataContext context)
        {
            var site = new SiteEntity {
                SiteId             = Guid.Empty,
                Name               = "Site",
                ChildSortDirection = CmsSite.DefaultChildSortDirection,
                ChildSortOrder     = CmsSite.DefaultChildSortOrder,
                UpdateDate         = DateTime.Now.ToUniversalTime()
            };

            context.AttachCopy(site);
            context.SaveChanges();

            return(site);
        }
コード例 #9
0
        public bool SiteWithADVerified(Guid IdSite, AzureADSiteValidation Properties)
        {
            bool       result  = false;
            SiteEntity site    = GetSiteById(IdSite.ToString());
            string     SiteUrl = site.URL;
            string     Token   = string.Empty;

            Token = ADManager.GetToken(Properties.TenantId, Properties.ClientAppId, Properties.AppKey);
            if (Token != string.Empty)
            {
                CreateIfNotExist(IdSite, Properties);
                result = ADManager.ValidateSite(SiteUrl, Token, Properties.SubscriptionId);
            }
            return(result);
        }
コード例 #10
0
        public DestroyedSite(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "site_civ_id": SiteEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "attacker_civ_id": Attacker = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "defender_civ_id": Defender = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "no_defeat_mention":
                    NoDefeatMention = true;
                    property.Known  = true;
                    break;
                }
            }

            if (Site.OwnerHistory.Count == 0)
            {
                if (SiteEntity != null && SiteEntity != Defender)
                {
                    SiteEntity.Parent = Defender;
                    Site.OwnerHistory.Add(new OwnerPeriod(Site, SiteEntity, -1, "founded"));
                }
                else
                {
                    Site.OwnerHistory.Add(new OwnerPeriod(Site, Defender, -1, "founded"));
                }
            }

            Site.OwnerHistory.Last().EndCause = "destroyed";
            Site.OwnerHistory.Last().EndYear  = Year;
            Site.OwnerHistory.Last().Ender    = Attacker;

            Site.AddEvent(this);
            if (SiteEntity != Defender)
            {
                SiteEntity.AddEvent(this);
            }

            Attacker.AddEvent(this);
            Defender.AddEvent(this);
        }
コード例 #11
0
        public async Task <ActionResult <SiteDto> > PostAsync(CreateSiteDto createSiteDto)
        {
            var site = new SiteEntity
            {
                SiteID      = createSiteDto.SiteID,
                CustomerCID = createSiteDto.CustomerCID,
                SiteName    = createSiteDto.SiteName,
                Distance    = createSiteDto.Distance
            };

            await _siteRepository.CreateAsync(site);

            await _publishEndpoint.Publish(new SiteCreated(site.SiteID, site.CustomerCID, site.SiteName, site.Distance));

            return(CreatedAtAction(nameof(GetByIDAsync), new { id = site.SiteID }, site));
        }
コード例 #12
0
        private string CreateTestSiteCollection(Tenant tenant, string sitecollectionName)
        {
            string     devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
            string     siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
            SiteEntity siteToCreate    = new SiteEntity()
            {
                Url            = siteToCreateUrl,
                Template       = "STS#0",
                Title          = "Test",
                Description    = "Test site collection",
                SiteOwnerLogin = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["OnPremDomain"], ConfigurationManager.AppSettings["OnPremUserName"]),
            };

            tenant.CreateSiteCollection(siteToCreate);
            return(siteToCreateUrl);
        }
コード例 #13
0
        public bool DeleteSite(Guid IdSite)
        {
            Boolean    result = true;
            SiteEntity site   = GetSiteById(IdSite.ToString());

            if (site.PRODUCTs.Any())
            {
                result = false;
            }
            else
            {
                site.IsActive = false;
                UpdateSingleSite(site);
            }
            return(result);
        }
コード例 #14
0
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime() + SiteEntity.PrintEntity(link, pov);

            if (Abandoned)
            {
                eventString += " abandoned the settlement of " + Site.ToLink(link, pov);
            }
            else
            {
                eventString += " settlement of " + Site.ToLink(link, pov) + " withered";
            }
            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
コード例 #15
0
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            eventString += SiteEntity?.ToLink(link, pov, this);
            eventString += " of ";
            eventString += Defender?.ToLink(link, pov, this);
            eventString += " surrendered ";
            eventString += Site?.ToLink(link, pov, this);
            eventString += " to ";
            eventString += Attacker?.ToLink(link, pov, this);
            eventString += ".";
            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
コード例 #16
0
        private string CreateTestSiteCollection(Tenant tenant, string sitecollectionName)
        {
            string     devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
            string     siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
            SiteEntity siteToCreate    = new SiteEntity()
            {
                Url            = siteToCreateUrl,
                Template       = "STS#0",
                Title          = "Test",
                Description    = "Test site collection",
                SiteOwnerLogin = ConfigurationManager.AppSettings["SPOUserName"],
            };

            tenant.CreateSiteCollection(siteToCreate, false, true);
            return(siteToCreateUrl);
        }
コード例 #17
0
        public string CreateToken(SiteEntity site)
        {
            string token = string.Empty;
            //Todo
            SiteToken siteToken = new SiteToken
            {
                Name   = site.Name,
                Url    = site.URL,
                SiteId = site.IdSite
            };

            string siteTokenRow = JsonConvert.SerializeObject(siteToken);

            token = Security.GetSha256(siteTokenRow);
            return(token);
        }
コード例 #18
0
        protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.UpdateGlobal);
            var gvRow = gvSites.Rows[e.RowIndex];
            var site  = new SiteEntity
            {
                Id             = Convert.ToInt32(gvSites.DataKeys[e.RowIndex].Values[0]),
                Name           = ((TextBox)gvRow.FindControl("txtName")).Text,
                ClusterGroupId = Convert.ToInt32(((DropDownList)gvRow.FindControl("ddlDp")).SelectedValue)
            };

            Call.SiteApi.Put(site.Id, site);

            gvSites.EditIndex = -1;
            this.BindGrid();
        }
コード例 #19
0
ファイル: BasicTests.cs プロジェクト: RimuTec/RimuTec.Piranha
        public async Task Page()
        {
            var siteTypeId = $"MySiteType-{Guid.NewGuid():N}";
            var pageTypeId = $"MyPageType-{Guid.NewGuid():N}";

            using ISession session = _sessionFactory.OpenSession();
            using ITransaction txn = session.BeginTransaction();

            var siteType = new SiteTypeEntity()
            {
                Id           = siteTypeId,
                Created      = DateTime.Now,
                LastModified = DateTime.Now
            };
            var site = new SiteEntity
            {
                Culture     = "en-NZ",
                Description = "My site",
                Hostnames   = "example.org",
                InternalId  = $"{Guid.NewGuid():N}",
                SiteTypeId  = siteTypeId,
                Title       = "Welcome to Example.org"
            };
            var pageType = new PageTypeEntity
            {
                Id           = pageTypeId,
                Created      = DateTime.Now,
                LastModified = DateTime.Now
            };
            var page = new PageEntity {
                Created      = DateTime.Now,
                LastModified = DateTime.Now,
                Title        = "Home page",
                PageType     = pageType,
                Site         = site,
                ContentType  = "Page"
            };
            var retrievedSiteTypeId = await session.SaveAsync(siteType).ConfigureAwait(false);

            var siteId = await session.SaveAsync(site).ConfigureAwait(false);

            var retrievedPageTypeId = await session.SaveAsync(pageType).ConfigureAwait(false);

            var pageId = await session.SaveAsync(page).ConfigureAwait(false);

            await txn.CommitAsync().ConfigureAwait(false);
        }
コード例 #20
0
        public void CanGetWebNameOfSubWebTest()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                string     subWebUrl   = "Test_SubWebUrl";
                SiteEntity subSiteInfo = new SiteEntity()
                {
                    Title    = "Test_Site Title",
                    Url      = subWebUrl,
                    Template = "STS#0"
                };
                Web subSite = ctx.Web.CreateWeb(subSiteInfo);

                string subWebName = subSite.GetName();
                Assert.AreEqual(subWebUrl, subWebName);
            }
        }
コード例 #21
0
        private Result ResultForSitesCommandAutoComplete(string actionKeyword, SiteEntity site)
        {
            const string seperater = Plugin.Query.TermSeperater;
            var          result    = new Result
            {
                Title    = site.Name,
                IcoPath  = site.IconPath,
                SubTitle = string.IsNullOrWhiteSpace(site.Description) ? $"{site.CommandKey}" : $"{site.CommandKey} - {site.Description}",
                Action   = e =>
                {
                    _context.API.ChangeQuery($"{actionKeyword}{seperater}{site.CommandKey}{seperater}");
                    return(false);
                }
            };

            return(result);
        }
コード例 #22
0
        /// <summary>
        /// Returns all site collections in the current Tenant based on a startIndex. IncludeDetail adds additional properties to the SPSite object. EndIndex is the maximum number based on chunkcs of 300.
        /// </summary>
        /// <param name="tenant">Tenant object to operate against</param>
        /// <param name="startIndex">Start getting site collections from this index. Defaults to 0</param>
        /// <param name="endIndex">The index of the last site. Defaults to 100.000</param>
        /// <param name="includeDetail">Option to return a limited set of data</param>
        /// <returns>An IList of SiteEntity objects</returns>
        public static IList <SiteEntity> GetSiteCollections(this Tenant tenant, int startIndex = 0, int endIndex = 100000, bool includeDetail = true)
        {
            var sites = new List <SiteEntity>();

            // O365 Tenant Site Collection limit is 500.000 (https://support.office.com/en-us/article/SharePoint-Online-software-boundaries-and-limits-8f34ff47-b749-408b-abc0-b605e1f6d498?CTT=1&CorrelationId=1928c530-fc12-4134-ada5-8ed2c2ec01fc&ui=en-US&rs=en-US&ad=US),
            // but let's limit to 100.000. Note that GetSiteProperties returns 300 per request.
            for (int i = startIndex; i < endIndex; i += 300)
            {
                var props = tenant.GetSiteProperties(i, includeDetail);
                tenant.Context.Load(props);
                tenant.Context.ExecuteQueryRetry();

                foreach (var prop in props)
                {
                    var siteEntity = new SiteEntity();
                    siteEntity.Lcid                = prop.Lcid;
                    siteEntity.SiteOwnerLogin      = prop.Owner;
                    siteEntity.StorageMaximumLevel = prop.StorageMaximumLevel;
                    siteEntity.StorageWarningLevel = prop.StorageWarningLevel;
                    siteEntity.Template            = prop.Template;
                    siteEntity.TimeZoneId          = prop.TimeZoneId;
                    siteEntity.Title               = prop.Title;
                    siteEntity.Url = prop.Url;
                    siteEntity.UserCodeMaximumLevel    = prop.UserCodeMaximumLevel;
                    siteEntity.UserCodeWarningLevel    = prop.UserCodeWarningLevel;
                    siteEntity.CurrentResourceUsage    = prop.CurrentResourceUsage;
                    siteEntity.LastContentModifiedDate = prop.LastContentModifiedDate;
                    siteEntity.StorageUsage            = prop.StorageUsage;
                    siteEntity.WebsCount = prop.WebsCount;
                    var lockState = SiteLockState.Unlock;
                    if (Enum.TryParse(prop.LockState, out lockState))
                    {
                        siteEntity.LockState = lockState;
                    }
                    sites.Add(siteEntity);
                }

                if (props.Count < 300)
                {
                    break;                    //exit for loop if there are no more site collections
                }
            }

            return(sites);
        }
コード例 #23
0
        public SiteEntity Site(Domain.Model.File.Type type)
        {
            var siteEntity = new SiteEntity();


            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(_url);

            req.Method    = "GET";
            req.UserAgent = "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))";
            req.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";
            req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
            string sourceTaken;

            using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
            {
                sourceTaken = reader.ReadToEnd();
            }

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(sourceTaken);

            Trace.WriteLine(doc.DocumentNode.ChildNodes.Descendants("video").Count());
            var descendantsList = type == File.Type.Image ? doc.DocumentNode.Descendants("img") : doc.DocumentNode.Descendants("video");

            // For every tag in the HTML containing the node img.
            foreach (var link in descendantsList
                     .Select(i => !string.IsNullOrEmpty(i.Attributes["src"].Value) ? i.Attributes["src"] : i.Attributes["source"]))
            {
                // Storing all links found in an array.
                // You can declare this however you want.
                var editedUrl = link.Value;
                if (!IsAbsoluteUrl(link.Value))
                {
                    var removeString = _url.Split("/")[_url.Split("/").Length - 1];
                    editedUrl  = _url;
                    editedUrl  = editedUrl.Replace(removeString, "");
                    editedUrl += link.Value;
                }

                var file = new FileEntity(editedUrl, null, type);
                siteEntity.FileEntitys.Add(file);
            }

            return(siteEntity);
        }
コード例 #24
0
        /// <summary>
        /// Adds a SiteEntity by launching site collection creation and waits for the creation to finish
        /// </summary>
        /// <param name="tenant">A tenant object pointing to the context of a Tenant Administration site</param>
        /// <param name="properties">Describes the site collection to be created</param>
        /// <param name="removeFromRecycleBin">It true and site is present in recycle bin, it will be removed first from the recycle bin</param>
        /// <param name="wait">If true, processing will halt until the site collection has been created</param>
        /// <returns>Guid of the created site collection and Guid.Empty is the wait parameter is specified as false</returns>
        public static Guid CreateSiteCollection(this Tenant tenant, SiteEntity properties, bool removeFromRecycleBin = false, bool wait = true)
        {
            if (removeFromRecycleBin)
            {
                if (tenant.CheckIfSiteExists(properties.Url, SITE_STATUS_RECYCLED))
                {
                    tenant.DeleteSiteCollectionFromRecycleBin(properties.Url);
                }
            }

            SiteCreationProperties newsite = new SiteCreationProperties();

            newsite.Url                  = properties.Url;
            newsite.Owner                = properties.SiteOwnerLogin;
            newsite.Template             = properties.Template;
            newsite.Title                = properties.Title;
            newsite.StorageMaximumLevel  = properties.StorageMaximumLevel;
            newsite.StorageWarningLevel  = properties.StorageWarningLevel;
            newsite.TimeZoneId           = properties.TimeZoneId;
            newsite.UserCodeMaximumLevel = properties.UserCodeMaximumLevel;
            newsite.UserCodeWarningLevel = properties.UserCodeWarningLevel;
            newsite.Lcid                 = properties.Lcid;

            SpoOperation op = tenant.CreateSite(newsite);

            tenant.Context.Load(tenant);
            tenant.Context.Load(op, i => i.IsComplete, i => i.PollingInterval);
            tenant.Context.ExecuteQueryRetry();

            // Get site guid and return. If we create the site asynchronously, return an empty guid as we cannot retrieve the site by URL yet.
            Guid siteGuid = Guid.Empty;

            if (wait)
            {
                // Let's poll for site collection creation completion
                WaitForIsComplete(tenant, op);

                // Add delay to avoid race conditions
                Thread.Sleep(30 * 1000);

                // Return site guid of created site collection
                siteGuid = tenant.GetSiteGuidByUrl(new Uri(properties.Url));
            }
            return(siteGuid);
        }
コード例 #25
0
        protected override void ExecuteCmdlet()
        {
            bool shouldContinue = true;

            if (!Url.ToLower().StartsWith("https://") && !Url.ToLower().StartsWith("http://"))
            {
                Uri uri = BaseUri;
                Url = $"{uri.ToString().TrimEnd('/')}/{Url.TrimStart('/')}";
                if (!Force)
                {
                    shouldContinue = ShouldContinue(string.Format(Resources.CreateSiteWithUrl0, Url), Resources.Confirm);
                }
            }
            if (shouldContinue)
            {
#if ONPREMISES
                var entity = new SiteEntity();
                entity.Url                  = Url;
                entity.Title                = Title;
                entity.SiteOwnerLogin       = Owner;
                entity.Template             = Template;
                entity.StorageMaximumLevel  = StorageQuota;
                entity.StorageWarningLevel  = StorageQuotaWarningLevel;
                entity.TimeZoneId           = TimeZone;
                entity.UserCodeMaximumLevel = ResourceQuota;
                entity.UserCodeWarningLevel = ResourceQuotaWarningLevel;
                entity.Lcid                 = Lcid;
                Tenant.CreateSiteCollection(entity);
#else
                Func <TenantOperationMessage, bool> timeoutFunction = TimeoutFunction;

#pragma warning disable CS0618 // Type or member is obsolete
                if (ParameterSpecified(nameof(Description)))
#pragma warning restore CS0618 // Type or member is obsolete
                {
                    // We have to fall back to synchronous behaviour as we have to wait for the site to be present in order to set the description.
                    Wait = true;
                }

                Tenant.CreateSiteCollection(Url, Title, Owner, Template, (int)StorageQuota,
                                            (int)StorageQuotaWarningLevel, TimeZone, (int)ResourceQuota, (int)ResourceQuotaWarningLevel, Lcid,
                                            RemoveDeletedSite, Wait, Wait == true ? timeoutFunction : null);
#endif
            }
        }
コード例 #26
0
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            eventString += SiteEntity.ToLink(link, pov, this);
            eventString += " of ";
            eventString += CivEntity.ToLink(link, pov, this);
            eventString += " breached ";
            eventString += UndergroundRegion.ToLink(link, pov, this);
            if (Site != null)
            {
                eventString += " at ";
                eventString += Site.ToLink(link, pov, this);
            }
            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
コード例 #27
0
        public string GetGoogleTagManagerToken(string IdSite)
        {
            string         Token      = string.Empty;
            SiteRepository repository = new SiteRepository();
            SiteEntity     site       = repository.FindById(new Guid(IdSite));

            if (site.Token == null)
            {
                Token      = CreateToken(site);
                site.Token = Token;
            }
            else
            {
                Token = site.Token;
            }

            return(Token);
        }
コード例 #28
0
        internal static string CreateTestSiteCollection(Tenant tenant, string sitecollectionName, bool isNoScriptSite = false)
        {
            try
            {
                string devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                string siteOwnerLogin = ConfigurationManager.AppSettings["SPOUserName"];
                if (TestCommon.AppOnlyTesting())
                {
                    using (var clientContext = TestCommon.CreateClientContext())
                    {
                        List <UserEntity> admins = clientContext.Web.GetAdministrators();
                        siteOwnerLogin = admins[0].LoginName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)[2];
                    }
                }

                SiteEntity siteToCreate = new SiteEntity()
                {
                    Url                  = siteToCreateUrl,
                    Template             = "STS#0",
                    Title                = "Test",
                    Description          = "Test site collection",
                    SiteOwnerLogin       = siteOwnerLogin,
                    Lcid                 = 1033,
                    StorageMaximumLevel  = 100,
                    UserCodeMaximumLevel = 0
                };

                tenant.CreateSiteCollection(siteToCreate, false, true);

                if (isNoScriptSite)
                {
                    tenant.SetSiteProperties(siteToCreateUrl, noScriptSite: true);
                }

                return(siteToCreateUrl);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToDetailedString());
                throw;
            }
        }
コード例 #29
0
        /// <summary>
        /// This function is used to update an SiteEntity.
        /// </summary>
        /// <param name="uid">Unique Site ID</param>
        /// <param name="name">Name</param>
        /// <param name="siteguid">Site GUID</param>
        /// <param name="ownerguid">Owner GUID</param>
        /// <param name="referrerguid">Referrer GUID</param>
        /// <param name="description">Description</param>
        /// <param name="sitetypeuid">Site Type UID</param>
        /// <param name="parentsiteuid">Parent Site UID</param>
        /// <param name="inheritusers">Inherit Users</param>
        /// <param name="inheritsecurity">Inherit Security</param>
        /// <param name="issitelocked">Is Site Locked Flag</param>
        /// <param name="isenabled">Is Enabled Flag</param>
        /// <param name="createtime">Create Time</param>
        /// <param name="createuseruid">Create User UID</param>
        /// <param name="edittime">Edit Time</param>
        /// <param name="edituseruid">Edit User UID</param>
        /// <param name="owneruid">Owner UID</param>
        /// <returns>True on success, False on fail</returns>
        /// <remarks>
        /// The Domain Name field is deprecated and will be changed in the future.
        /// </remarks>
        public static bool Update(
            int uid,
            string name,
            Guid siteguid,
            Guid ownerguid,
            Guid referrerguid,
            string description,
            int sitetypeuid,
            int parentsiteuid,
            bool inheritusers,
            bool inheritsecurity,
            string feedbackemail,
            bool issitelocked,
            bool isenabled,
            DateTime createtime,
            int createuseruid,
            DateTime edittime,
            int edituseruid,
            int owneruid)
        {
            //DEPRECATED: Domain Name field will be changed in a near future.
            SiteEntity site = new SiteEntity(uid);

            site.IsNew           = false;
            site.Name            = name;
            site.SiteGUID        = siteguid;
            site.OwnerGUID       = ownerguid;
            site.ReferrerGUID    = referrerguid;
            site.Description     = description;
            site.SiteTypeUID     = sitetypeuid;
            site.ParentSiteUID   = parentsiteuid;
            site.InheritUsers    = inheritusers;
            site.InheritSecurity = inheritsecurity;
            site.IsSiteLocked    = issitelocked;
            site.IsEnabled       = isenabled;
            site.CreateTime      = createtime;
            site.CreateUserUID   = createuseruid;
            site.EditTime        = edittime;
            site.EditUserUID     = edituseruid;
            site.OwnerUID        = owneruid;
            DataAccessAdapter ds = new DataAccessAdapter();

            return(ds.SaveEntity(site));
        }
コード例 #30
0
        public SiteDied(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "civ_id": Civ = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "site_civ_id": SiteEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "abandoned":
                    property.Known = true;
                    Abandoned      = true;
                    break;
                }
            }

            string endCause = "withered";

            if (Abandoned)
            {
                endCause = "abandoned";
            }

            Site.OwnerHistory.Last().EndYear  = Year;
            Site.OwnerHistory.Last().EndCause = endCause;
            if (SiteEntity != null)
            {
                SiteEntity.SiteHistory.Last(s => s.Site == Site).EndYear  = Year;
                SiteEntity.SiteHistory.Last(s => s.Site == Site).EndCause = endCause;
            }
            Civ.SiteHistory.Last(s => s.Site == Site).EndYear  = Year;
            Civ.SiteHistory.Last(s => s.Site == Site).EndCause = endCause;

            Civ.AddEvent(this);
            SiteEntity.AddEvent(this);
            Site.AddEvent(this);

            world.AddPlayerRelatedDwarfObjects(SiteEntity);
            world.AddPlayerRelatedDwarfObjects(Site);
        }
コード例 #31
0
        public void SubSiteExistsTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var    tenant          = new Tenant(tenantContext);
                string devSiteUrl      = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                string subSiteUrlGood  = "";
                string subSiteUrlWrong = "";

                Site site = tenant.GetSiteByUrl(siteToCreateUrl);
                tenant.Context.Load(site);
                tenant.Context.ExecuteQueryRetry();
                Web web = site.RootWeb;
                web.Context.Load(web);
                web.Context.ExecuteQueryRetry();

                //Create sub site
                SiteEntity sub = new SiteEntity()
                {
                    Title = "Test Sub", Url = "sub", Description = "Test"
                };
                web.CreateWeb(sub);
                siteToCreateUrl = UrlUtility.EnsureTrailingSlash(siteToCreateUrl);
                subSiteUrlGood  = String.Format("{0}{1}", siteToCreateUrl, sub.Url);
                subSiteUrlWrong = String.Format("{0}{1}", siteToCreateUrl, "8988980");

                // Check real sub site
                bool subSiteExists = tenant.SubSiteExists(subSiteUrlGood);
                Assert.IsTrue(subSiteExists);

                // check non existing sub site
                bool subSiteExists2 = tenant.SubSiteExists(subSiteUrlWrong);
                Assert.IsFalse(subSiteExists2);

                // check root site (= site collection). Will return true when existing
                bool subSiteExists3 = tenant.SubSiteExists(siteToCreateUrl);
                Assert.IsTrue(subSiteExists3);

                // check root site (= site collection) that does not exist. Will return false when non-existant
                bool subSiteExists4 = tenant.SubSiteExists(siteToCreateUrl + "8808809808");
                Assert.IsFalse(subSiteExists4);
            }
        }
コード例 #32
0
        public CreatedWorldConstruction(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "civ_id": Civ = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "site_civ_id": SiteEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "site_id1": Site1 = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "site_id2": Site2 = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "wcid": WorldConstruction = world.GetWorldConstruction(Convert.ToInt32(property.Value)); break;

                case "master_wcid": MasterWorldConstruction = world.GetWorldConstruction(Convert.ToInt32(property.Value)); break;
                }
            }

            Civ.AddEvent(this);
            SiteEntity.AddEvent(this);

            WorldConstruction.AddEvent(this);
            MasterWorldConstruction.AddEvent(this);

            Site1.AddEvent(this);
            Site2.AddEvent(this);

            Site1.AddConnection(Site2);
            Site2.AddConnection(Site1);

            if (WorldConstruction != null)
            {
                WorldConstruction.Site1 = Site1;
                WorldConstruction.Site2 = Site2;
                if (MasterWorldConstruction != null)
                {
                    MasterWorldConstruction.Sections.Add(WorldConstruction);
                    WorldConstruction.MasterConstruction = MasterWorldConstruction;
                }
            }
        }
コード例 #33
0
ファイル: Site.cs プロジェクト: neozhu/MrCMS
 public virtual bool IsValidForSite(SiteEntity entity)
 {
     if (entity.GetType().GetCustomAttributes(typeof(AdminUISiteAgnosticAttribute), true).Any())
         return true;
     return entity.Site != null && entity.Site.Id == Id;
 }