示例#1
0
        /// <summary>
        /// Updates our zonelist screen with required info
        /// </summary>
        /// <param name="msg">Incoming message</param>
        public void UpdateList(Lidgren.Network.NetIncomingMessage msg)
        {
            if (Zones.Count > 0)
            {
                foreach (string zname in Zones.Keys)
                {
                    oldZones.Add(zname);
                }
            }
            Zones.Clear();

            int count = msg.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                ZoneSettings _zone = new ZoneSettings();
                _zone.ID          = msg.ReadInt64();
                _zone.Name        = msg.ReadString();
                _zone.Description = msg.ReadString();
                _zone.Address     = msg.ReadIPEndPoint();

                //Add it to our dictionary
                Zones.Add(_zone.Name, _zone);

                //Remove it from our old list
                if (oldZones.Contains(_zone.Name))
                {
                    oldZones.Remove(_zone.Name);
                }
            }

            UpdateButtons();
        }
        public static ZoneSettings ByModuleKey(ObjectKey moduleKey)
        {
            var zoneCacheKey = ZONE_CACHE_BY_KEY_PREFIX + moduleKey;

            if (RuntimeCache.Instance.Get(new CacheKey(zoneCacheKey)) is ZoneSettings settings)
            {
                return(settings);
            }

            string       zoneAddress;
            ZoneSettings zoneSettings;
            int          moduleId;

            using (var tran = DatabaseAccess.ForRuntimeDatabase.GetReadOnlyTransaction()) {
                DBRuntimePlatform.Instance.GetModuleNameAndIdByKey(tran, moduleKey, out string moduleName, out moduleId);

                zoneSettings = DBRuntimePlatform.Instance.GetDeploymentZoneAddressByModuleKey(tran, moduleKey);
            }

            zoneAddress = zoneSettings.Address;
            if (zoneAddress != null)
            {
                if (zoneAddress.IsEmpty())
                {
                    zoneAddress = RuntimePlatformSettings.Misc.InternalAddress.GetValue();
                }

                zoneSettings = new ZoneSettings(zoneSettings.EnableHttps, zoneAddress);
                InsertCache(zoneCacheKey, zoneSettings, moduleId);
                return(zoneSettings);
            }

            return(new ZoneSettings(false, RuntimePlatformSettings.Misc.InternalAddress.GetValue()));
        }
 public ZoneNode(
     ZoneSettings settings,
     Action <ZoneSettings> saveSettings,
     ProjectNode parent)
     : base(
         settings.ZoneId,
         IconIndex,
         settings,
         changedSettings => saveSettings((ZoneSettings)changedSettings),
         parent)
 {
 }
示例#4
0
    public virtual Collider[] ReturnHitObjects(ZoneSettings zoneSettings)
    {
        if (zoneSettings.zoneShape == ZONE_SHAPE.BOX)
        {
            Collider[] hitObjects = Physics.OverlapBox(transform.position, zoneSettings.zoneSize / 2, Quaternion.Euler(zoneSettings.zoneRotation), zoneSettings.zoneCollisionMask);

            return(hitObjects);
        }
        else
        {
            Collider[] hitObjects = Physics.OverlapSphere(transform.position, zoneSettings.zoneRadius, zoneSettings.zoneCollisionMask);

            return(hitObjects);
        }
    }
示例#5
0
        /// <summary>
        /// Loads all listed files that contains folder information
        /// </summary>
        protected override void Load()
        {
            ZoneSettings section = (ZoneSettings)ConfigurationManager.GetSection("Saga.Factory.Zones");

            if (section != null)
            {
                foreach (FactoryFileElement element in section.FolderItems)
                {
                    WriteLine("ZoneFactory", "Loading zone information from: {0} using format {1}", element.Path, element.Reader);
                    LoadParameterizedStreamContent(Saga.Structures.Server.SecurePath(element.Path), element.Reader);
                }
            }
            else
            {
                WriteWarning("XmlSections", "Section {0} was not found", "Saga.Factory.Zones");
            }
        }
示例#6
0
        /// <summary>
        /// Queries configuration file for configurable settings
        /// </summary>
        protected override void QuerySettings()
        {
            ZoneSettings section = (ZoneSettings)ConfigurationManager.GetSection("Saga.Factory.Zones");

            if (section != null)
            {
                if (section.Directory.Length == 0)
                {
                    WriteError("ZoneFactory", "Heightmap directory is not configured");
                }
                else
                {
                    dirHeightmap = Saga.Structures.Server.SecurePath(section.Directory);
                }
            }
            else
            {
                WriteWarning("XmlSections", "Section {0} was not found", "Saga.Factory.Zones");
            }
        }
示例#7
0
        private static void FirstRunConfiguration()
        {
            IPAddress     gatewayip           = IPAddress.Loopback;
            int           gatewayport         = 64003;
            IPAddress     mapip               = IPAddress.Loopback;
            byte          worldid             = 0;
            int           mapport             = 64002;
            int           playerlimit         = 60;
            string        databaseusername    = "******";
            string        databasepassword    = "******";
            uint          dbport              = 3306;
            int           cexprates           = 1;
            int           jexprates           = 1;
            int           wexprates           = 1;
            int           droprates           = 1;
            string        databasename        = "saga_world";
            string        dbhost              = "localhost";
            string        dbprovider          = "Saga.Map.Data.Mysql.dll, Saga.Map.Data.Mysql.MysqlProvider";
            string        proof               = "c4ca4238a0b923820dcc509a6f75849b";
            string        questplugin         = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.LuaQuestProvider";
            string        scenarioquestplugin = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.ScenarioLuaQuest";
            string        worldspawn          = "Saga.Map.Plugins.dll, Saga.Map.Plugins.MultifileSpawnWorldObjects";
            string        multiworldspawn     = "Saga.Map.Plugins.dll, Saga.Map.Plugins.MultifileSpawnMultiWorldObjects";
            string        eventprovider       = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.EventInfo";
            ConsoleReader reader              = new ConsoleReader();

            reader.Clear(null);

            System.Configuration.Configuration b = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (CheckConfigExists() == false)
            {
                Console.WriteLine("First time run-configuration");
                char key;

                #region Always Configure

                ConfigureRequired("What is the world id of this server?");
                while (!byte.TryParse(Console.ReadLine(), out worldid))
                {
                    Console.WriteLine("Incorrect value please use an number between 0–255");
                }

                ConfigureRequired("What is the player limit of this server?");
                while (!int.TryParse(Console.ReadLine(), out playerlimit))
                {
                    Console.WriteLine("Incorrect value please use an valid number");
                }

                ConfigureRequired("What is the authentication proof of this server?");
                MD5           md5      = MD5.Create();
                byte[]        block    = Encoding.UTF8.GetBytes(Console.ReadLine());
                byte[]        md5block = md5.ComputeHash(block);
                StringBuilder builder  = new StringBuilder();
                foreach (byte c in md5block)
                {
                    builder.AppendFormat("{0:X2}", c);
                }
                proof = builder.ToString();

                ConfigureRequired("What are the cexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out cexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                cexprates = Math.Min(20, Math.Max(cexprates, 1));

                ConfigureRequired("What are the jexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out jexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                jexprates = Math.Min(20, Math.Max(jexprates, 1));

                ConfigureRequired("What are the wexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out wexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                wexprates = Math.Min(20, Math.Max(wexprates, 1));

                ConfigureRequired("What are the item drop-rates?");
                while (!int.TryParse(Console.ReadLine(), out droprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                droprates = Math.Min(20, Math.Max(droprates, 1));

                ConfigureRequired("Detect database plugin");
                dbprovider = FindPlugin(typeof(IDatabase), dbprovider);

                ConfigureRequired("Detect quest plugin");
                questplugin = FindPlugin(typeof(Saga.Quests.IQuest), questplugin);

                ConfigureRequired("Detect scenarion quest plugin");
                scenarioquestplugin = FindPlugin(typeof(Saga.Quests.ISceneraioQuest), scenarioquestplugin);

                ConfigureRequired("Detect npc & map spawn plugin");
                worldspawn = FindPlugin(typeof(Saga.Factory.SpawnWorldObjects), worldspawn);

                ConfigureRequired("Detect mob spawn plugin");
                multiworldspawn = FindPlugin(typeof(Saga.Factory.SpawnMultiWorldObjects), multiworldspawn);

                ConfigureRequired("Detect event plugin");
                eventprovider = FindPlugin(typeof(Saga.Factory.EventManager.BaseEventInfo), eventprovider);

                #endregion Always Configure

                #region Network Settings

ConfigureGatewayNetwork:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Do you wan to configure the gateway-map network settings? Y/N");
                Console.ResetColor();
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the gateway-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out gatewayip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("What port should the gateway-map server listen to?");
                    while (!int.TryParse(Console.ReadLine(), out gatewayport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64003");
                    }
                }
                else if (key != 'n')
                {
                    goto ConfigureGatewayNetwork;
                }

ConfigureWorldNetwork:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Do you wan to configure the authentication-map network settings? Y/N");
                Console.ResetColor();
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the authentication-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out mapip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("On what port is the authentication server listening");
                    while (!int.TryParse(Console.ReadLine(), out mapport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64002");
                    }
                }
                else if (key != 'n')
                {
                    goto ConfigureWorldNetwork;
                }

                #endregion Network Settings

                #region Database Settings

DatabaseName:
                ConfigureOptional("Do you want to configure the database settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    ConfigureRequired("What is the database name?");
                    databasename = Console.ReadLine();

                    ConfigureRequired("What is the database username?");
                    databaseusername = Console.ReadLine();

                    ConfigureRequired("What is the database password?");
                    databasepassword = Console.ReadLine();

                    ConfigureRequired("What is the database port?");
                    while (!uint.TryParse(Console.ReadLine(), out dbport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 3306");
                    }

                    ConfigureRequired("What is the database host?");
                    dbhost = Console.ReadLine();
                }
                else if (key != 'n')
                {
                    goto DatabaseName;
                }

                #endregion Database Settings



                #region Plugin detection

PluginDetection:
                ConfigureOptional("Do you want to dectect other plugins?");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("no plugins detected");
                }
                else if (key != 'n')
                {
                    goto PluginDetection;
                }

                #endregion Plugin detection

                //CONFIGURE SERVER SETTINGS
                ServerVars serverVarsConfiguration = new ServerVars();
                serverVarsConfiguration.DataDirectory = "../Data/";
                b.Sections.Add("Saga.ServerVars", serverVarsConfiguration);

                //CONFIGURE NETWORK SETTINGS
                NetworkSettings       networkSettings = new NetworkSettings();
                NetworkFileCollection collection      = networkSettings.Connections;
                collection["public"]   = new NetworkElement("public", gatewayip.ToString(), gatewayport);
                collection["internal"] = new NetworkElement("internal", mapip.ToString(), mapport);
                b.Sections.Remove("Saga.Manager.NetworkSettings");
                b.Sections.Add("Saga.Manager.NetworkSettings", networkSettings);
                networkSettings.WorldId     = worldid;
                networkSettings.Proof       = proof;
                networkSettings.PlayerLimit = playerlimit;

                //CONFIGURE CONSOLE SETTING
                ConsoleSettings consoleSettings = new ConsoleSettings();
                consoleSettings.CommandPrefix = "@";
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Broadcast"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Position"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ChatMute"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GmWarptomap"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.PlayerJump"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.PlayerCall"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Speed"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GarbageCollector"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ClearNpc"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.KickAll"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Kick"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Time"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ShowMaintenance"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ScheduleMaintenance"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.SetGmLevel"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Spawn"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Unspawn"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GiveItem"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.QStart"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Kill"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Worldload"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Gmgo"));
                b.Sections.Add("Saga.Manager.ConsoleSettings", consoleSettings);

                //PORTALS
                PortalSettings portalSettings = new PortalSettings();
                portalSettings.FolderItems.Add(new FactoryFileElement("~/portal_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Portals");
                b.Sections.Add("Saga.Factory.Portals", portalSettings);

                //CHARACTERCONFIGURATION
                CharacterConfigurationSettings characterconfigurationSettings = new CharacterConfigurationSettings();
                characterconfigurationSettings.FolderItems.Add(new FactoryFileElement("~/character-template.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.CharacterConfiguration");
                b.Sections.Add("Saga.Factory.CharacterConfiguration", characterconfigurationSettings);

                //ADDITION
                AdditionSettings additionSettings = new AdditionSettings();
                additionSettings.FolderItems.Add(new FactoryFileElement("~/Addition_t.xml", "text/xml"));
                additionSettings.Reference = "~/addition_reference.csv";
                b.Sections.Remove("Saga.Factory.Addition");
                b.Sections.Add("Saga.Factory.Addition", additionSettings);

                //SPELLS
                SpellSettings spellSettings = new SpellSettings();
                spellSettings.FolderItems.Add(new FactoryFileElement("~/spell_data.xml", "text/xml"));
                spellSettings.Reference = "~/skill_reference.csv";
                b.Sections.Remove("Saga.Factory.Spells");
                b.Sections.Add("Saga.Factory.Spells", spellSettings);

                //STATUSBYLEVEL
                StatusByLevelSettings statusbylevelSettings = new StatusByLevelSettings();
                statusbylevelSettings.FolderItems.Add(new FactoryFileElement("~/experience.csv", "text/csv"));
                statusbylevelSettings.Cexp     = cexprates;
                statusbylevelSettings.Jexp     = jexprates;
                statusbylevelSettings.Wexp     = wexprates;
                statusbylevelSettings.Droprate = droprates;

                b.Sections.Remove("Saga.Factory.StatusByLevel");
                b.Sections.Add("Saga.Factory.StatusByLevel", statusbylevelSettings);

                //WARPSETTINGS
                WarpSettings warpSettings = new WarpSettings();
                warpSettings.FolderItems.Add(new FactoryFileElement("~/warp_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Warps");
                b.Sections.Add("Saga.Factory.Warps", warpSettings);

                //ZONES
                ZoneSettings zoneSettings = new ZoneSettings();
                zoneSettings.FolderItems.Add(new FactoryFileElement("~/zone_data.csv", "text/csv"));
                zoneSettings.Directory = "../Data/heightmaps";
                b.Sections.Remove("Saga.Factory.Zones");
                b.Sections.Add("Saga.Factory.Zones", zoneSettings);

                //ITEMS
                ItemSettings itemSettings = new ItemSettings();
                itemSettings.FolderItems.Add(new FactoryFileElement("~/item_data.xml", "text/xml"));
                b.Sections.Remove("Saga.Factory.Items");
                b.Sections.Add("Saga.Factory.Items", itemSettings);

                //WEAPONARY
                WeaponarySettings weaponarySettings = new WeaponarySettings();
                weaponarySettings.FolderItems.Add(new FactoryFileElement("~/weapon_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Weaponary");
                b.Sections.Add("Saga.Factory.Weaponary", weaponarySettings);

                //SPAWNTEMPLATE
                SpawntemplateSettings spawntemplateSettings = new SpawntemplateSettings();
                spawntemplateSettings.FolderItems.Add(new FactoryFileElement("~/npc_templates.csv", "text/csv"));
                spawntemplateSettings.FolderItems.Add(new FactoryFileElement("~/item_templates.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.SpawnTemplate");
                b.Sections.Add("Saga.Factory.SpawnTemplate", spawntemplateSettings);

                //SPAWNS NPC & MAP
                SpawnWorldObjectSettings spawnworldobjectSettings = new SpawnWorldObjectSettings();
                spawnworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/npc-spawns/", "text/csv"));
                spawnworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/item-spawns/", "text/csv"));
                spawnworldobjectSettings.DerivedType = worldspawn;
                b.Sections.Remove("Saga.Factory.SpawnWorldObjects");
                b.Sections.Add("Saga.Factory.SpawnWorldObjects", spawnworldobjectSettings);

                //SPAWNS MOBS
                SpawnMultiWorldObjectSettings spawnmultiworldobjectSettings = new SpawnMultiWorldObjectSettings();
                spawnmultiworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/mob-spawns/", "text/csv"));
                spawnmultiworldobjectSettings.DerivedType = multiworldspawn;
                b.Sections.Remove("Saga.Factory.SpawnMultiWorldObjects");
                b.Sections.Add("Saga.Factory.SpawnMultiWorldObjects", spawnmultiworldobjectSettings);

                //SCRIPTING
                ScriptingSettings scriptingSettings = new ScriptingSettings();
                scriptingSettings.Directory = "../Saga.Scripting";
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.dll", "text/csv"));
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.Data.dll", "text/csv"));
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.Xml.dll", "text/csv"));
                b.Sections.Remove("Saga.Manager.Scripting");
                b.Sections.Add("Saga.Manager.Scripting", scriptingSettings);

                //EVENTS
                EventSettings eventSettings = new EventSettings();
                eventSettings.FolderItems.Add(new FactoryFileElement("~/eventlist.csv", "text/csv"));
                eventSettings.Provider = eventprovider;
                b.Sections.Remove("Saga.Factory.Events");
                b.Sections.Add("Saga.Factory.Events", eventSettings);

                //QUUESTS
                QuestSettings questSettings = new QuestSettings();
                questSettings.Directory        = "../Quests/";
                questSettings.SDirectory       = "~/Scenario.Quests/";
                questSettings.Provider         = questplugin;
                questSettings.ScenarioProvider = scenarioquestplugin;
                b.Sections.Remove("Saga.Manager.Quest");
                b.Sections.Add("Saga.Manager.Quest", questSettings);

                //DATABASE SETTINGS
                DatabaseSettings databaseSettings = new DatabaseSettings();
                databaseSettings.Database = databasename;
                databaseSettings.Username = databaseusername;
                databaseSettings.Password = databasepassword;
                databaseSettings.Port     = dbport;
                databaseSettings.Host     = dbhost;
                databaseSettings.DBType   = dbprovider;
                b.Sections.Remove("Saga.Manager.Database");
                b.Sections.Add("Saga.Manager.Database", databaseSettings);

                //SAVE CONFIGURATION AND REFRESH ALL SECTIONS
                b.Save();

                //REFRESH ALL SECTIONS
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnMultiWorldObjects");
                ConfigurationManager.RefreshSection("Saga.Manager.Database");
                ConfigurationManager.RefreshSection("Saga.Manager.Quest");
                ConfigurationManager.RefreshSection("Saga.Manager.Scripting");
                ConfigurationManager.RefreshSection("Saga.Factory.Events");
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnWorldObject");
                ConfigurationManager.RefreshSection("Saga.ServerVars");
                ConfigurationManager.RefreshSection("Saga.Manager.NetworkSettings");
                ConfigurationManager.RefreshSection("Saga.Manager.ConsoleSettings");
                ConfigurationManager.RefreshSection("Saga.Factory.Portals");
                ConfigurationManager.RefreshSection("Saga.Factory.CharacterConfiguration");
                ConfigurationManager.RefreshSection("Saga.Factory.Addition");
                ConfigurationManager.RefreshSection("Saga.Factory.Spells");
                ConfigurationManager.RefreshSection("Saga.Factory.StatusByLevel");
                ConfigurationManager.RefreshSection("Saga.Factory.Warps");
                ConfigurationManager.RefreshSection("Saga.Factory.Zones");
                ConfigurationManager.RefreshSection("Saga.Factory.Items");
                ConfigurationManager.RefreshSection("Saga.Factory.Weaponary");
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnTemplate");

                Console.WriteLine("Everything configured");
            }
        }
示例#8
0
 public IZoneNoiseSettings GetZoneNoiseSettings(ZoneRatio influence)
 {
     return(ZoneSettings.Lerp(_zoneSettings, influence));
 }
示例#9
0
 private static JObject GetZoneSetting(string setting)
 => ZoneSettings.Cast <JObject>().Single(s => s["id"].Value <string>() == setting);
 public void SetZoneSettings(string projectId, ZoneSettings settings)
 {
     Set <ZoneSettings>(new[] { projectId, ZonePrefix + settings.ZoneId }, settings);
 }
示例#11
0
        private static void IndexItem(CanhCam.Business.News news)
        {
            if (WebConfigSettings.DisableSearchIndex)
            {
                return;
            }

            if (news == null)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("news object passed to NewsIndexBuilderProvider.IndexItem was null");
                }
                return;
            }

            Guid             newsFeatureGuid = CanhCam.Business.News.FeatureGuid;
            ModuleDefinition newsFeature     = new ModuleDefinition(newsFeatureGuid);

            List <ContentAttribute> listAttribute = new List <ContentAttribute>();
            // Language
            List <Language> listLanguages  = LanguageHelper.GetPublishedLanguages();
            string          defaultCulture = WebConfigSettings.DefaultLanguageCultureForContent;
            // End Language

            ZoneSettings zoneSettings = new ZoneSettings(news.SiteId, news.ZoneID);

            //don't index pending/unpublished pages
            if (!zoneSettings.IsPublished)
            {
                return;
            }

            foreach (Language lang in listLanguages)
            {
                CanhCam.SearchIndex.IndexItem indexItem = new CanhCam.SearchIndex.IndexItem();
                if (news.SearchIndexPath.Length > 0)
                {
                    indexItem.IndexPath = news.SearchIndexPath;
                }
                indexItem.SiteId        = news.SiteId;
                indexItem.ZoneId        = zoneSettings.ZoneId;
                indexItem.ZoneName      = zoneSettings.Name;
                indexItem.ViewRoles     = zoneSettings.ViewRoles;
                indexItem.ZoneViewRoles = zoneSettings.ViewRoles;

                indexItem.PageMetaDescription = news.MetaDescription;
                indexItem.PageMetaKeywords    = news.MetaKeywords;
                indexItem.ItemGuid            = news.NewsGuid;
                indexItem.Title               = news.Title;
                indexItem.Content             = news.FullContent;
                indexItem.ContentAbstract     = news.BriefContent;
                indexItem.FeatureId           = newsFeatureGuid.ToString();
                indexItem.FeatureName         = newsFeature.FeatureName;
                indexItem.FeatureResourceFile = newsFeature.ResourceFile;

                //indexItem.OtherContent = stringBuilder.ToString();
                indexItem.IsPublished      = news.IsPublished;
                indexItem.PublishBeginDate = news.StartDate;
                indexItem.PublishEndDate   = news.EndDate;

                indexItem.CreatedUtc = news.StartDate;
                indexItem.LastModUtc = news.LastModUtc;

                if (news.Url.Length > 0)
                {
                    if (news.Url.StartsWith("http"))
                    {
                        indexItem.ViewPage = news.Url;
                    }
                    else
                    {
                        indexItem.ViewPage = news.Url.Replace("~/", string.Empty);
                    }
                }
                else
                {
                    indexItem.ViewPage = "News/NewsDetail.aspx?zoneid="
                                         + indexItem.ZoneId.ToInvariantString()
                                         + "&NewsID=" + news.NewsID.ToInvariantString()
                    ;
                }

                indexItem.UseQueryStringParams = false;

                // Language
                string listGuid = zoneSettings.ZoneGuid.ToString()
                                  + ";" + news.NewsGuid.ToString();
                List <ContentLanguage> listContent = ContentLanguage.GetByListContent(listGuid);
                indexItem.LanguageCode = defaultCulture;
                if (lang.LanguageCode.ToLower() != defaultCulture.ToLower())
                {
                    indexItem.LanguageCode = lang.LanguageCode;
                    indexItem.RemoveOnly   = true;

                    foreach (ContentLanguage ct in listContent)
                    {
                        if (lang.LanguageID == ct.LanguageId)
                        {
                            if (ct.ContentGuid == zoneSettings.PageGuid)
                            {
                                indexItem.ZoneName = ct.Title;
                            }
                            else if (ct.ContentGuid == news.NewsGuid)
                            {
                                indexItem.PageMetaDescription = ct.MetaDescription;
                                indexItem.PageMetaKeywords    = ct.MetaKeywords;
                                indexItem.Title           = ct.Title;
                                indexItem.Content         = SecurityHelper.RemoveMarkup(ct.FullContent);
                                indexItem.ContentAbstract = SecurityHelper.RemoveMarkup(ct.BriefContent);

                                indexItem.ViewPage   = ct.Url.Replace("~/", string.Empty);
                                indexItem.RemoveOnly = false;
                            }
                        }
                    }

                    listAttribute = ContentAttribute.GetByContentAsc(news.NewsGuid, lang.LanguageID);
                }
                else
                {
                    listAttribute = ContentAttribute.GetByContentAsc(news.NewsGuid);
                }
                // End Language

                foreach (ContentAttribute attribute in listAttribute)
                {
                    indexItem.Content += " " + attribute.Title + " " + SecurityHelper.RemoveMarkup(attribute.ContentText);
                }

                if (news.IsDeleted)
                {
                    indexItem.RemoveOnly = true;
                }

                CanhCam.SearchIndex.IndexHelper.RebuildIndex(indexItem);
            }

            if (debugLog)
            {
                log.Debug("Indexed " + news.Title);
            }
        }
示例#12
0
        public override void RebuildIndex(
            ZoneSettings zoneSettings,
            string indexPath)
        {
            if (WebConfigSettings.DisableSearchIndex)
            {
                return;
            }

            if (zoneSettings == null)
            {
                log.Error("zoneSettings object passed to NewsIndexBuilderProvider.RebuildIndex was null");
                return;
            }

            //don't index pending/unpublished zones
            if (!zoneSettings.IsPublished)
            {
                return;
            }

            log.Info("NewsIndexBuilderProvider indexing zone - " + zoneSettings.Name);

            //try
            //{
            Guid             newsFeatureGuid = CanhCam.Business.News.FeatureGuid;
            ModuleDefinition newsFeature     = new ModuleDefinition(newsFeatureGuid);

            List <CanhCam.Business.News> lstNews = CanhCam.Business.News.GetByZone(zoneSettings.SiteId, zoneSettings.ZoneId);

            // Language
            string listGuid     = zoneSettings.ZoneGuid.ToString();
            string listNewsGuid = string.Empty;

            foreach (CanhCam.Business.News news in lstNews)
            {
                if (!listGuid.Contains(news.NewsGuid.ToString()))
                {
                    listGuid     += ";" + news.NewsGuid.ToString();
                    listNewsGuid += ";" + news.NewsGuid.ToString();
                }
            }

            List <ContentLanguage> listContent   = ContentLanguage.GetByListContent(listGuid);
            List <Language>        listLanguages = LanguageHelper.GetPublishedLanguages();
            string defaultCulture = WebConfigSettings.DefaultLanguageCultureForContent;
            // End Language

            List <ContentAttribute> listAttribute = new List <ContentAttribute>();

            foreach (Language lang in listLanguages)
            {
                if (lang.LanguageCode.ToLower() != defaultCulture.ToLower())
                {
                    listAttribute = ContentAttribute.GetByListContent(listNewsGuid, lang.LanguageID);
                }
                else
                {
                    listAttribute = ContentAttribute.GetByListContent(listNewsGuid);
                }

                foreach (CanhCam.Business.News news in lstNews)
                {
                    CanhCam.SearchIndex.IndexItem indexItem = new CanhCam.SearchIndex.IndexItem();
                    indexItem.SiteId              = zoneSettings.SiteId;
                    indexItem.ZoneId              = zoneSettings.ZoneId;
                    indexItem.ZoneName            = zoneSettings.Name;
                    indexItem.ViewRoles           = zoneSettings.ViewRoles;
                    indexItem.ZoneViewRoles       = zoneSettings.ViewRoles;
                    indexItem.FeatureId           = newsFeatureGuid.ToString();
                    indexItem.FeatureName         = newsFeature.FeatureName;
                    indexItem.FeatureResourceFile = newsFeature.ResourceFile;

                    indexItem.ItemGuid = news.NewsGuid;
                    indexItem.Title    = news.Title;

                    string url = news.Url;
                    if (url.Length > 0)
                    {
                        if (url.StartsWith("http"))
                        {
                            indexItem.ViewPage = url;
                        }
                        else
                        {
                            indexItem.ViewPage = url.Replace("~/", string.Empty);
                        }
                    }
                    else
                    {
                        indexItem.ViewPage = "News/NewsDetail.aspx?zoneid="
                                             + indexItem.ZoneId.ToInvariantString()
                                             + "&NewsID=" + news.NewsID.ToString();
                    }

                    indexItem.PageMetaDescription = news.MetaDescription;
                    indexItem.PageMetaKeywords    = news.MetaKeywords;

                    indexItem.CreatedUtc = news.StartDate;
                    indexItem.LastModUtc = news.LastModUtc;

                    //if (indexItem.ViewPage.Length > 0)
                    //{
                    indexItem.UseQueryStringParams = false;
                    //}
                    //else
                    //{
                    //    indexItem.ViewPage = "News/NewsDetail.aspx";
                    //}
                    indexItem.Content         = SecurityHelper.RemoveMarkup(news.FullContent);
                    indexItem.ContentAbstract = SecurityHelper.RemoveMarkup(news.BriefContent);

                    indexItem.IsPublished      = news.IsPublished;
                    indexItem.PublishBeginDate = news.StartDate;
                    indexItem.PublishEndDate   = news.EndDate;

                    // Language
                    indexItem.LanguageCode = defaultCulture;
                    if (lang.LanguageCode.ToLower() != defaultCulture.ToLower())
                    {
                        indexItem.ZoneName     = string.Empty;
                        indexItem.LanguageCode = lang.LanguageCode;
                        indexItem.RemoveOnly   = true;

                        foreach (ContentLanguage ct in listContent)
                        {
                            if (lang.LanguageID == ct.LanguageId)
                            {
                                if (ct.ContentGuid == zoneSettings.ZoneGuid)
                                {
                                    indexItem.ZoneName = ct.Title;
                                }
                                else if (ct.ContentGuid == news.NewsGuid)
                                {
                                    indexItem.PageMetaDescription = ct.MetaDescription;
                                    indexItem.PageMetaKeywords    = ct.MetaKeywords;
                                    indexItem.Title           = ct.Title;
                                    indexItem.Content         = SecurityHelper.RemoveMarkup(ct.FullContent);
                                    indexItem.ContentAbstract = SecurityHelper.RemoveMarkup(ct.BriefContent);

                                    indexItem.ViewPage   = ct.Url.Replace("~/", string.Empty);
                                    indexItem.RemoveOnly = false;
                                }
                            }
                        }
                    }
                    // End Language

                    foreach (ContentAttribute attribute in listAttribute)
                    {
                        if (attribute.ContentGuid == news.NewsGuid)
                        {
                            indexItem.Content += " " + attribute.Title + " " + SecurityHelper.RemoveMarkup(attribute.ContentText);
                        }
                    }

                    CanhCam.SearchIndex.IndexHelper.RebuildIndex(indexItem, indexPath);

                    if (debugLog)
                    {
                        log.Debug("Indexed " + indexItem.Title);
                    }
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    log.Error(ex);
            //}
        }
示例#13
0
        private void SetupMetaTags()
        {
            string title = news.Title;

            if (news.MetaTitle.Length > 0)
            {
                basePage.Title = news.MetaTitle;
                title          = news.MetaTitle;
            }
            else
            {
                basePage.Title = SiteUtils.FormatPageTitle(basePage.SiteInfo, news.Title);
            }

            if (news.MetaKeywords.Length > 0)
            {
                basePage.MetaKeywordCsv = news.MetaKeywords;
            }
            else if (basePage.SiteInfo.MetaKeyWords.Length > 0)
            {
                basePage.MetaKeywordCsv = basePage.SiteInfo.GetMetaKeyWords(WorkingCulture.LanguageId);
            }

            if (news.MetaDescription.Length > 0)
            {
                basePage.MetaDescription = news.MetaDescription;
            }
            else if (news.BriefContent.Length > 0)
            {
                basePage.MetaDescription = UIHelper.CreateExcerpt(news.BriefContent, 156);
            }
            else if (news.FullContent.Length > 0)
            {
                basePage.MetaDescription = UIHelper.CreateExcerpt(news.FullContent, 156);
            }

            if (title.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta property=\"og:title\" content=\"" + title + "\" />";
            }
            if (basePage.MetaDescription.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta property=\"og:description\" content=\"" + basePage.MetaDescription + "\" />";
            }

            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:url\" content=\"" + NewsHelper.FormatNewsUrl(news.Url, news.NewsID, news.ZoneID) + "\" />";
            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:site_name\" content=\"" + basePage.SiteInfo.SiteName + "\" />";
            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:type\" content=\"article\" />";

            if (title.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"name\" content=\"" + title + "\" />";
            }
            if (basePage.MetaDescription.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"description\" content=\"" + basePage.MetaDescription + "\" />";
            }

            ZoneSettings currentZone = CacheHelper.GetCurrentZone();

            if (basePage.SiteInfo.MetaAdditional.Length > 0)
            {
                basePage.AdditionalMetaMarkup = basePage.SiteInfo.MetaAdditional;
            }
            if (currentZone.AdditionalMetaTags.Length > 0)
            {
                basePage.AdditionalMetaMarkup += currentZone.AdditionalMetaTags;
            }
            if (news.AdditionalMetaTags.Length > 0)
            {
                basePage.AdditionalMetaMarkup += news.AdditionalMetaTags;
            }
        }
示例#14
0
        private void SetupMetaTags()
        {
            string title = product.Title;

            if (product.MetaTitle.Length > 0)
            {
                basePage.Title = product.MetaTitle;
                title          = product.MetaTitle;
            }
            else
            {
                basePage.Title = SiteUtils.FormatPageTitle(basePage.SiteInfo, product.Title);
            }

            if (product.MetaKeywords.Length > 0)
            {
                basePage.MetaKeywordCsv = product.MetaKeywords;
            }

            if (product.MetaDescription.Length > 0)
            {
                basePage.MetaDescription = product.MetaDescription;
            }
            else if (product.BriefContent.Length > 0)
            {
                basePage.MetaDescription = UIHelper.CreateExcerpt(product.BriefContent, 156);
            }
            else if (product.FullContent.Length > 0)
            {
                basePage.MetaDescription = UIHelper.CreateExcerpt(product.FullContent, 156);
            }

            if (title.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta property=\"og:title\" content=\"" + title + "\" />";
            }
            if (basePage.MetaDescription.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta property=\"og:description\" content=\"" + basePage.MetaDescription + "\" />";
            }

            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:url\" content=\"" + ProductHelper.FormatProductUrl(product.Url,
                                                                                                                       product.ProductId, product.ZoneId) + "\" />";
            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:site_name\" content=\"" + basePage.SiteInfo.SiteName + "\" />";
            basePage.AdditionalMetaMarkup += "\n<meta property=\"og:type\" content=\"product\" />";

            if (title.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"name\" content=\"" + title + "\" />";
            }
            if (basePage.MetaDescription.Length > 0)
            {
                basePage.AdditionalMetaMarkup += "\n<meta itemprop=\"description\" content=\"" + basePage.MetaDescription + "\" />";
            }

            ZoneSettings currentZone = CacheHelper.GetCurrentZone();

            if (basePage.SiteInfo.MetaAdditional.Length > 0)
            {
                basePage.AdditionalMetaMarkup = basePage.SiteInfo.MetaAdditional;
            }
            if (currentZone.AdditionalMetaTags.Length > 0)
            {
                basePage.AdditionalMetaMarkup += currentZone.AdditionalMetaTags;
            }
            if (product.AdditionalMetaTags.Length > 0)
            {
                basePage.AdditionalMetaMarkup += product.AdditionalMetaTags;
            }
        }
示例#15
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ProductPermission.CanDelete)
                {
                    SiteUtils.RedirectToEditAccessDeniedPage();
                    return;
                }

                bool isDeleted = false;

                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int     productId = Convert.ToInt32(data.GetDataKeyValue("ProductId"));
                    Product product   = new Product(siteSettings.SiteId, productId);

                    if (product != null && product.ProductId != -1 && !product.IsDeleted)
                    {
                        if (product.ZoneId.ToString() != ddZones.SelectedValue && ddZones.SelectedValue != "-1")
                        {
                            ZoneSettings objZone = new ZoneSettings(siteSettings.SiteId, Convert.ToInt32(ddZones.SelectedValue));
                            if (objZone != null && objZone.ZoneId > 0)
                            {
                                ZoneItem zoneNews = new ZoneItem(objZone.ZoneGuid, product.ProductGuid);
                                ZoneItem.Delete(zoneNews.ZoneGuid, zoneNews.ItemGuid);
                            }
                        }
                        else
                        {
                            ContentDeleted.Create(siteSettings.SiteId, product.Title, "Product", typeof(ProductDeleted).AssemblyQualifiedName, product.ProductId.ToString(), Page.User.Identity.Name);

                            product.IsDeleted = true;

                            product.ContentChanged += new ContentChangedEventHandler(product_ContentChanged);

                            product.SaveDeleted();
                            LogActivity.Write("Delete product", product.Title);
                        }

                        //ContentDeleted.Create(siteSettings.SiteId, product.Title, "Product", typeof(ProductDeleted).AssemblyQualifiedName, product.ProductId.ToString(), Page.User.Identity.Name);

                        //product.IsDeleted = true;

                        //product.ContentChanged += new ContentChangedEventHandler(product_ContentChanged);

                        //product.SaveDeleted();
                        //LogActivity.Write("Delete product", product.Title);

                        isDeleted = true;
                    }
                }

                if (isDeleted)
                {
                    SiteUtils.QueueIndexing();
                    grid.Rebind();

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }