public abstract void CommitSiteChanges(SiteInfo site);
Exemple #2
0
        public static SiteInfo CreateNew()
        {
            SiteInfo site = new SiteInfo();
            site.SetState(State.Added);

            return site;
        }
Exemple #3
0
        /// <summary>
        /// Gets the <see cref="ManagedFusion.Site.SiteInfo">SiteInfo</see> according to the
        /// host of the current URL request.
        /// </summary>
        /// <returns>Returns the site information from the database.</returns>
        /// <exception cref="ManagedFusion.SiteNotFoundException">Thrown when the current host is not found in sites.</exception>
        public static SiteInfo GetSiteForHost(string host)
        {
            // make sure the host is lowercase
            host = host.ToLower();

            // sets the portal key used for cache
            string siteKey = host;

            // see if portal is in cache
            if (Common.Cache.IsCached(siteKey, String.Empty) == true)
                return (SiteInfo)Common.Cache[siteKey, String.Empty];

            // get host parts
            string[] parts = host.Split('.');

            // get portal information
            string domain = String.Empty;
            string subDomain = "*";

            // get domain and subdomain
            switch (parts.Length)
            {
                case 3:		// in the form of subDomain.domain.com
                    domain = String.Format("{0}.{1}", parts[1], parts[2]);
                    subDomain = parts[0];
                    break;
                case 4:
                    domain = String.Concat(parts[1], ".", parts[2], ".", parts[3]);
                    subDomain = parts[0];
                    break;
                default:
                    domain = host;
                    break;
            }

            // get all site combinations
            SiteInfo[] sites = new SiteInfo[4];

            sites[0] = SiteInfo.Collection[subDomain + "." + domain];
            sites[1] = SiteInfo.Collection["*." + domain];
            sites[2] = SiteInfo.Collection[subDomain + ".*"];
            sites[3] = SiteInfo.Collection["*.*"];

            // create site info object
            SiteInfo cacheValue = null;

            foreach (SiteInfo site in sites)
                if (site != null)
                {
                    cacheValue = site;
                    break;
                }

            if (cacheValue == null)
                throw new ApplicationException("A site matching '" + host + "' could not be found.");

            // adds the portal to the cache
            Common.Cache.Add(siteKey, String.Empty, cacheValue);

            return cacheValue;
        }
 public override void CommitSiteChanges(SiteInfo site)
 {
     switch (site.State)
     {
         case State.Added :		// insert
             Site.Insert((Site)site);
             break;
         case State.Changed :	// commit changes
             Site.Update((Site)site);
             break;
         case State.Deleted :	// remove
             Site.Delete((Site)site);
             break;
     }
 }