Beispiel #1
0
        private bool CheckForExistingPhrase(IDictataPhrase newPhrase)
        {
            //Check for existing phrases with the same word set
            IEnumerable <IDictataPhrase> maybePhrases = ConfigDataCache.GetAll <IDictataPhrase>();

            return(maybePhrases.Any(phrase => phrase.Words.All(word => newPhrase.Words.Any(newWord => newWord.Equals(word)))));
        }
Beispiel #2
0
        /// <summary>
        /// Get the lexeme for this word
        /// </summary>
        /// <returns>the lexeme</returns>
        public ILexeme GetLexeme()
        {
            ILexeme lex = ConfigDataCache.Get <ILexeme>(string.Format("{0}_{1}_{2}", ConfigDataType.Dictionary, Language.Name, Name));

            if (lex != null)
            {
                if (!lex.WordForms.Any(form => form == this))
                {
                    lex.AddNewForm(this);
                    lex.SystemSave();
                    lex.PersistToCache();
                }
            }
            else
            {
                lex = new Lexeme()
                {
                    Name     = Name,
                    Language = Language
                };

                lex.SystemSave();
                lex.PersistToCache();

                lex.AddNewForm(this);
            }

            return(lex);
        }
        public ActionResult Edit(string id, AddEditDictionaryViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme obj = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), id, ConfigDataType.Dictionary));
            string message;
            if (obj == null)
            {
                message = "That does not exist";
                return RedirectToAction("Index", new { Message = message });
            }

            obj.Name = vModel.DataObject.Name;
            obj.Language = vModel.DataObject.Language;

            if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - EditLexeme[" + obj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Beispiel #4
0
        public ActionResult Languages(string SearchTerm = "")
        {
            try
            {
                IEnumerable <ILanguage> validEntries = ConfigDataCache.GetAll <ILanguage>();
                ApplicationUser         user         = null;
                string searcher = SearchTerm.Trim().ToLower();

                if (User.Identity.IsAuthenticated)
                {
                    user = UserManager.FindById(User.Identity.GetUserId());
                    StaffRank userRank = user.GetStaffRank(User);
                }

                LanguagesViewModel vModel = new LanguagesViewModel(validEntries.Where(item => item.Name.ToLower().Contains(searcher)))
                {
                    AuthedUser = user,
                    SearchTerm = SearchTerm,
                };

                return(View(vModel));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(View());
        }
        public ActionResult AddDictata(string lexemeId, AddEditDictataViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            ILexeme lex = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), lexemeId, ConfigDataType.Dictionary));
            if (lex == null)
            {
                return RedirectToAction("Index", new { Message = "That does not exist" });
            }

            IDictata newObj = vModel.DataObject;

            lex.AddNewForm(newObj);

            string message;
            if (lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddDictata[" + newObj.UniqueKey + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }
            else
            {
                message = "Error; Creation failed.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Beispiel #6
0
        /// <summary>
        /// Verify the dictionary has this word already
        /// </summary>
        /// <param name="lexeme">dictata to check</param>
        public static ILexeme VerifyLexeme(ILexeme lexeme)
        {
            if (lexeme == null || string.IsNullOrWhiteSpace(lexeme.Name) || lexeme.Name.IsNumeric())
            {
                return(null);
            }

            //Set the language to default if it is absent and save it, if it has a language it already exists
            if (lexeme.Language == null)
            {
                IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld));

                if (globalConfig.BaseLanguage != null)
                {
                    lexeme.Language = globalConfig.BaseLanguage;
                }
            }

            ConfigDataCacheKey cacheKey = new ConfigDataCacheKey(lexeme);

            ILexeme maybeLexeme = ConfigDataCache.Get <ILexeme>(cacheKey);

            if (maybeLexeme != null)
            {
                lexeme = maybeLexeme;
            }

            lexeme.IsSynMapped = false;
            lexeme.MapSynNet();
            lexeme.FillLanguages();

            return(lexeme);
        }
Beispiel #7
0
        /// <summary>
        /// Remove this object from the db permenantly
        /// </summary>
        /// <returns>success status</returns>
        public virtual bool Remove(IAccount remover, StaffRank rank)
        {
            DataAccess.FileSystem.ConfigData accessor = new DataAccess.FileSystem.ConfigData();

            try
            {
                //Not allowed to remove stuff you didn't make unless you're an admin, TODO: Make this more nuanced for guilds
                if (rank < StaffRank.Admin && !remover.Equals(Creator))
                {
                    return(false);
                }

                //Remove from cache first
                ConfigDataCache.Remove(new ConfigDataCacheKey(this));

                //Remove it from the file system.
                accessor.RemoveEntity(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
Beispiel #8
0
        public ActionResult GossipConfig(DashboardViewModel vModel)
        {
            ApplicationUser authedUser   = UserManager.FindById(User.Identity.GetUserId());
            IGossipConfig   gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));

            gossipConfig.GossipActive             = vModel.GossipActive;
            gossipConfig.ClientId                 = vModel.ClientId;
            gossipConfig.ClientName               = vModel.ClientName;
            gossipConfig.ClientSecret             = vModel.ClientSecret;
            gossipConfig.SuspendMultiplierMaximum = vModel.SuspendMultiplierMaximum;
            gossipConfig.SuspendMultiplier        = vModel.SuspendMultiplier;
            gossipConfig.SupportedChannels        = vModel.SupportedChannels;
            gossipConfig.SupportedFeatures        = vModel.SupportedFeatures;

            string message;

            if (gossipConfig.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - EditGossipConfig[" + gossipConfig.UniqueKey.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Beispiel #9
0
        private void GetNotifications(DataAccess.FileSystem.ConfigData dataAccessor, DirectoryInfo charDirectory)
        {
            try
            {
                IEnumerable <FileInfo> files = charDirectory.EnumerateFiles("*.PlayerMessage", SearchOption.TopDirectoryOnly);

                List <IPlayerMessage> dataList = new List <IPlayerMessage>();
                foreach (FileInfo file in files)
                {
                    if (file == null)
                    {
                        continue;
                    }

                    IPlayerMessage newMessage = (IPlayerMessage)dataAccessor.ReadEntity(file, typeof(IPlayerMessage));

                    if (newMessage != null)
                    {
                        ConfigDataCache.Add(newMessage);
                        dataList.Add(newMessage);
                    }
                }

                Notifications = dataList;
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                //Let it keep going
            }
        }
Beispiel #10
0
        public ActionResult Index()
        {
            ApplicationUser user    = UserManager.FindById(User.Identity.GetUserId());
            Account         account = user.GameAccount;

            ManageAccountViewModel model = new ManageAccountViewModel
            {
                AuthedUser           = user,
                DataObject           = account,
                GlobalIdentityHandle = account.GlobalIdentityHandle,
                ComboCount           = account.Config.Combos.Count(),
                FightingArtCount     = TemplateCache.GetAll <IFightingArt>().Count(art => art.CreatorHandle == user.GlobalIdentityHandle),
                UIModuleCount        = TemplateCache.GetAll <IUIModule>(true).Count(uimod => uimod.CreatorHandle.Equals(account.GlobalIdentityHandle)),
                NotificationCount    = ConfigDataCache.GetAll <IPlayerMessage>().Count(msg => msg.RecipientAccount == account),
                UITutorialMode       = account.Config.UITutorialMode,
                GossipSubscriber     = account.Config.GossipSubscriber,
                PermanentlyMuteMusic = account.Config.MusicMuted,
                PermanentlyMuteSound = account.Config.SoundMuted,
                UILanguage           = account.Config.UILanguage,
                ChosenRole           = user.GetStaffRank(User),
                ValidRoles           = (StaffRank[])Enum.GetValues(typeof(StaffRank)),
                ValidLanguages       = ConfigDataCache.GetAll <ILanguage>().Where(lang => lang.SuitableForUse && lang.UIOnly)
            };

            return(View(model));
        }
Beispiel #11
0
 public AddEditLanguageViewModel(string archivePath, ILanguage item) : base(archivePath, ConfigDataType.Language, item)
 {
     ValidWords     = ConfigDataCache.GetAll <IDictata>().Where(word => word.Language == item).OrderBy(word => word.Name);
     ValidPhrases   = ConfigDataCache.GetAll <IDictataPhrase>().OrderBy(word => word.Language.Name).ThenBy(word => word.Name);
     ValidLanguages = ConfigDataCache.GetAll <ILanguage>();
     DataObject     = (Language)item;
 }
        public ActionResult Remove(string removeId = "", string authorizeRemove = "")
        {
            string message;
            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                ILexeme obj = ConfigDataCache.Get<ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), removeId, ConfigDataType.Dictionary));

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveConstants[" + removeId + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Delete Successful.";
                }
                else
                {
                    message = "Error; Removal failed.";
                }
            }
            else
            {
                message = "You must check the proper remove or unapprove authorization radio button first.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Beispiel #13
0
 public AddEditDictataViewModel(ILexeme parent, IDictata obj)
 {
     ParentObject   = (Lexeme)parent;
     ValidLanguages = ConfigDataCache.GetAll <ILanguage>();
     DataObject     = (Dictata)obj;
     ValidWords     = ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.Language == parent.Language && lex != parent).SelectMany(lex => lex.WordForms).OrderBy(form => form.Name);
 }
Beispiel #14
0
 public AddEditLanguageViewModel() : base("", ConfigDataType.Language)
 {
     ValidWords     = ConfigDataCache.GetAll <IDictata>().OrderBy(word => word.Language.Name).ThenBy(word => word.Name);
     ValidPhrases   = ConfigDataCache.GetAll <IDictataPhrase>().OrderBy(word => word.Language.Name).ThenBy(word => word.Name);
     ValidLanguages = ConfigDataCache.GetAll <ILanguage>();
     DataObject     = new Language();
 }
Beispiel #15
0
        public ActionResult MarkAsReadNotification(string id, AddViewNotificationViewModel vModel)
        {
            string          message    = string.Empty;
            string          userId     = User.Identity.GetUserId();
            ApplicationUser authedUser = UserManager.FindById(userId);

            try
            {
                if (!string.IsNullOrWhiteSpace(id))
                {
                    IPlayerMessage notification = ConfigDataCache.Get <IPlayerMessage>(id);

                    if (notification != null)
                    {
                        notification.Read = true;
                        notification.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    }
                }
                else
                {
                    message = "Invalid message.";
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, LogChannels.SystemWarnings);
            }

            return(RedirectToAction("Notifications", new { Message = message }));
        }
Beispiel #16
0
        public ActionResult RestartGossipServer()
        {
            IEnumerable <WebSocket> gossipServers = LiveCache.GetAll <WebSocket>();

            foreach (WebSocket server in gossipServers)
            {
                server.Abort();
            }

            IGossipConfig   gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));
            Func <Member[]> playerList   = () => LiveCache.GetAll <IPlayer>()
                                           .Where(player => player.Descriptor != null && player.Template <IPlayerTemplate>().Account.Config.GossipSubscriber)
                                           .Select(player => new Member()
            {
                Name           = player.AccountHandle,
                WriteTo        = (message) => player.WriteTo(new string[] { message }),
                BlockedMembers = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => !acq.IsFriend).Select(acq => acq.PersonHandle),
                Friends        = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => acq.IsFriend).Select(acq => acq.PersonHandle)
            }).ToArray();

            void exceptionLogger(Exception ex) => LoggingUtility.LogError(ex);
            void activityLogger(string message) => LoggingUtility.Log(message, LogChannels.GossipServer);

            GossipClient gossipServer = new GossipClient(gossipConfig, exceptionLogger, activityLogger, playerList);

            Task.Run(() => gossipServer.Launch());

            LiveCache.Add(gossipServer, "GossipWebClient");

            return(RedirectToAction("Index", new { Message = "Gossip Server Restarted" }));
        }
        public ActionResult RemoveDictata(string removeId = "", string authorizeRemove = "")
        {
            string message;
            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                ILexeme lex = ConfigDataCache.Get<ILexeme>(removeId.Substring(0, removeId.LastIndexOf("_") - 1));
                IDictata obj = lex?.WordForms?.FirstOrDefault(form => form.UniqueKey == removeId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else 
                {
                    HashSet<IDictata> wordForms = lex.WordForms.ToHashSet();
                    wordForms.RemoveWhere(form => form.UniqueKey == removeId);
                    lex.WordForms = wordForms.ToArray();

                    lex.Save(authedUser.GameAccount, authedUser.GetStaffRank(User));
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveConstants[" + removeId + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Delete Successful.";
                }
            }
            else
            {
                message = "You must check the proper remove or unapprove authorization radio button first.";
            }

            return RedirectToAction("Index", new { Message = message });
        }
Beispiel #18
0
        /// <summary>
        /// Remove this object from the db permenantly
        /// </summary>
        /// <returns>success status</returns>
        public override bool SystemRemove()
        {
            bool removalState = base.SystemRemove();

            if (removalState)
            {
                IEnumerable <IDictata> synonyms = WordForms.SelectMany(dict =>
                                                                       ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.SuitableForUse && lex.GetForm(dict.WordType) != null &&
                                                                                                                lex.GetForm(dict.WordType).Synonyms.Any(syn => syn != null && syn.Equals(dict))).Select(lex => lex.GetForm(dict.WordType)));
                IEnumerable <IDictata> antonyms = WordForms.SelectMany(dict =>
                                                                       ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.SuitableForUse && lex.GetForm(dict.WordType) != null &&
                                                                                                                lex.GetForm(dict.WordType).Antonyms.Any(syn => syn != null && syn.Equals(dict))).Select(lex => lex.GetForm(dict.WordType)));

                foreach (IDictata word in synonyms)
                {
                    HashSet <IDictata> syns = new HashSet <IDictata>(word.Synonyms);
                    syns.RemoveWhere(syn => syn.Equals(this));
                    word.Synonyms = syns;
                }

                foreach (IDictata word in antonyms)
                {
                    HashSet <IDictata> ants = new HashSet <IDictata>(word.Antonyms);
                    ants.RemoveWhere(syn => syn.Equals(this));
                    word.Antonyms = ants;
                }
            }

            return(removalState);
        }
Beispiel #19
0
        public AccountConfig(IAccount account)
        {
            _account = account;

            Acquaintences = new List <IAcquaintence>();
            Notifications = new List <IPlayerMessage>();
            Playlists     = new HashSet <IPlaylist>();
            Combos        = Enumerable.Empty <IFightingArtCombination>();
            UIModules     = Enumerable.Empty <Tuple <IUIModule, int> >();

            if (string.IsNullOrWhiteSpace(Name))
            {
                Name = _account.GlobalIdentityHandle;
            }

            IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld));

            if (globalConfig != null)
            {
                UILanguage = globalConfig.BaseLanguage;
            }

            UITutorialMode   = true;
            MusicMuted       = true;
            GossipSubscriber = true;
        }
Beispiel #20
0
        /// <summary>
        /// Dumps everything of a single type into the cache from the filesystem for BackingData
        /// </summary>
        /// <typeparam name="T">the type to get and store</typeparam>
        /// <returns>full or partial success</returns>
        public static bool LoadAllToCache(Type objectType)
        {
            if (!objectType.GetInterfaces().Contains(typeof(IConfigData)))
            {
                return(false);
            }

            DataAccess.FileSystem.ConfigData fileAccessor = new DataAccess.FileSystem.ConfigData();
            string typeDirectory = fileAccessor.GetCurrentDirectoryForType(objectType);

            if (!fileAccessor.VerifyDirectory(typeDirectory, false))
            {
                return(false);
            }

            DirectoryInfo filesDirectory = new DirectoryInfo(typeDirectory);

            foreach (FileInfo file in filesDirectory.EnumerateFiles("*." + objectType.Name))
            {
                try
                {
                    ConfigDataCache.Add(fileAccessor.ReadEntity(file, objectType));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                    //Let it keep going
                }
            }

            return(true);
        }
Beispiel #21
0
        public ActionResult GlobalConfig(DashboardViewModel vModel)
        {
            ApplicationUser authedUser   = UserManager.FindById(User.Identity.GetUserId());
            IGlobalConfig   globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld));

            globalConfig.WebsocketPortalActive = vModel.WebsocketPortalActive;
            globalConfig.AdminsOnly            = vModel.AdminsOnly;
            globalConfig.UserCreationActive    = vModel.UserCreationActive;
            globalConfig.BaseLanguage          = vModel.BaseLanguage;

            globalConfig.AzureTranslationKey = vModel.AzureTranslationKey;
            globalConfig.TranslationActive   = vModel.TranslationActive;

            globalConfig.DeepLexActive        = vModel.DeepLexActive;
            globalConfig.MirriamDictionaryKey = vModel.MirriamDictionaryKey;
            globalConfig.MirriamThesaurusKey  = vModel.MirriamThesaurusKey;

            string message;

            if (globalConfig.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - EditGlobalConfig[" + globalConfig.UniqueKey.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Beispiel #22
0
        //
        // GET: /Enter/

        public ActionResult Index()
        {
            ConfigDataCache Cache = EnterPageInitialize.CreateInstance(EnterPageInitialize.ConfigProviderCreate());

            #region 动态字段初始化
            ViewBag.Title = Cache.Map_ConfigData["Title"];
            ViewBag.MenuNameForPhoneSize       = Cache.Map_ConfigData["MenuNameForPhoneSize"];
            ViewBag.EnterNoticName             = Cache.Map_ConfigData["EnterNoticName"];
            ViewBag.FirstNav                   = Cache.Map_ConfigData["FirstNav"];
            ViewBag.SecondNav                  = Cache.Map_ConfigData["SecondNav"];
            ViewBag.ThirdNav                   = Cache.Map_ConfigData["ThirdNav"];
            ViewBag.EnterNoticContentTitle     = Cache.Map_ConfigData["EnterNoticContentTitle"];
            ViewBag.EnterNoticContent          = Cache.Map_ConfigData["EnterNoticContent"];
            ViewBag.FooterFirstTitle           = Cache.Map_ConfigData["FooterFirstTitle"];
            ViewBag.FooterFirstContent         = Cache.Map_ConfigData["FooterFirstContent"];
            ViewBag.TableDownloadContent_left  = Cache.Map_ConfigData["TableDownloadContent_left"];
            ViewBag.TableDownloadContent_right = Cache.Map_ConfigData["TableDownloadContent_right"];
            ViewBag.FirstNav_Title             = Cache.Map_ConfigData["FirstNav_Title"];
            ViewBag.SecondNav_Title            = Cache.Map_ConfigData["SecondNav_Title"];
            ViewBag.ThirdNav_Title             = Cache.Map_ConfigData["ThirdNav_Title"];
            ViewBag.TableDownloadFileName      = Cache.Map_ConfigData["TableDownloadFileName"];
            ViewBag.TableDownloadLink          = Cache.Map_ConfigData["TableDownloadLink"];
            ViewBag.FourthNav                  = Cache.Map_ConfigData["FourthNav"];
            #endregion
            #region portfolios初始化
            int              portfolioModalSum = Convert.ToInt32(Cache.Map_ConfigData["portfolioModalSum"]);
            portfolioModal   portfolio         = new portfolioModal();
            portfolioModal[] portfolios        = new portfolioModal[portfolioModalSum];
            for (int i = 1; i <= portfolioModalSum; i++)
            {
                portfolio.Name              = "portfolioModal" + i.ToString();
                portfolio.ImgSrc            = Cache.Map_ConfigData["portfolioImgSrc" + i.ToString()];
                portfolio.TitleInside       = Cache.Map_ConfigData["portfolioTitleInside" + i.ToString()];
                portfolio.ImgSrcInside      = Cache.Map_ConfigData["portfolioImgSrcInside" + i.ToString()];
                portfolio.paragraphInside   = Cache.Map_ConfigData["portfolioparagraphInside" + i.ToString()];
                portfolio.LinkNameInside    = Cache.Map_ConfigData["portfolioLinkNameInside" + i.ToString()];
                portfolio.LinkContentInside = Cache.Map_ConfigData["portfolioLinkContentInside" + i.ToString()];
                portfolio.LinkInside        = Cache.Map_ConfigData["portfolioLinkInside" + i.ToString()];
                portfolios[i - 1]           = DeepCopy <portfolioModal>(portfolio);//这里必须深拷贝
            }
            ViewBag.portfolios = portfolios;
            #endregion
            #region EnterForm初始化
            int EnterFormFieldSum = Convert.ToInt32(Cache.Map_ConfigData["EnterFormFieldSum"]);
            EnterFormFieldModul   EnterFormField  = new EnterFormFieldModul();
            EnterFormFieldModul[] EnterFormFields = new EnterFormFieldModul[EnterFormFieldSum];
            for (int a = 1; a <= EnterFormFieldSum; a++)
            {
                EnterFormField.LabelName         = "EnterFormField" + a.ToString();
                EnterFormField.TypeName          = Cache.Map_ConfigData["EnterFormFieldTypeName" + a.ToString()];
                EnterFormField.PlaceholderString = Cache.Map_ConfigData["EnterFormFieldPlaceholderString" + a.ToString()];
                EnterFormField.Attribute         = Cache.Map_ConfigData["EnterFormAttribute" + a.ToString()];
                EnterFormField.DisplayName       = Cache.Map_ConfigData["EnterFormDisplayName" + a.ToString()];
                EnterFormFields[a - 1]           = DeepCopy <EnterFormFieldModul>(EnterFormField);//这里必须深拷贝
            }
            ViewBag.EnterFormFields = EnterFormFields;
            #endregion
            return(View());
        }
Beispiel #23
0
 public AddEditDictataViewModel(ILexeme parent)
 {
     ParentObject   = (Lexeme)parent;
     ValidPhrases   = ConfigDataCache.GetAll <IDictataPhrase>().OrderBy(word => word.Language.Name).ThenBy(word => word.Name);
     ValidLanguages = ConfigDataCache.GetAll <ILanguage>();
     DataObject     = new Dictata();
     ValidWords     = ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.Language == parent.Language && lex != parent).SelectMany(lex => lex.WordForms).OrderBy(form => form.Name);
 }
Beispiel #24
0
 public AddEditDictionaryViewModel() : base(Enumerable.Empty <IDictata>())
 {
     CurrentPageNumber = 1;
     ItemsPerPage      = 20;
     ValidWords        = ConfigDataCache.GetAll <ILexeme>();
     ValidLanguages    = ConfigDataCache.GetAll <ILanguage>();
     DataObject        = new Lexeme();
 }
Beispiel #25
0
        /// <summary>
        /// Make a dictata from a lexica
        /// </summary>
        /// <param name="lexica">the incoming lexica phrase</param>
        public Dictata(ILexica lexica)
        {
            Name           = "";
            Antonyms       = new HashSet <IDictata>();
            Synonyms       = new HashSet <IDictata>();
            PhraseAntonyms = new HashSet <IDictataPhrase>();
            PhraseSynonyms = new HashSet <IDictataPhrase>();
            Semantics      = new HashSet <string>();

            IGlobalConfig globalConfig = ConfigDataCache.Get <IGlobalConfig>(new ConfigDataCacheKey(typeof(IGlobalConfig), "LiveSettings", ConfigDataType.GameWorld));

            if (lexica.Context?.Language == null)
            {
                if (globalConfig?.BaseLanguage == null)
                {
                    Language = ConfigDataCache.GetAll <ILanguage>().FirstOrDefault();
                }
                else
                {
                    Language = globalConfig.BaseLanguage;
                }
            }
            else
            {
                Language = lexica.Context.Language;
            }

            ILexeme maybeLex = ConfigDataCache.Get <ILexeme>(
                new ConfigDataCacheKey(typeof(ILexeme), string.Format("{0}_{1}", Language.Name, lexica.Phrase), ConfigDataType.Dictionary));

            if (maybeLex == null)
            {
                Name     = lexica.Phrase;
                WordType = lexica.Type;
            }
            else if (maybeLex.WordForms.Any(form => form.WordType == lexica.Type))
            {
                IDictata wordForm = maybeLex.WordForms.FirstOrDefault(form => form.WordType == lexica.Type);

                Name           = lexica.Phrase;
                WordType       = lexica.Type;
                Synonyms       = wordForm.Synonyms;
                Antonyms       = wordForm.Antonyms;
                PhraseSynonyms = wordForm.PhraseSynonyms;
                PhraseAntonyms = wordForm.PhraseAntonyms;
                Determinant    = wordForm.Determinant;
                Elegance       = wordForm.Elegance;
                Feminine       = wordForm.Feminine;
                Perspective    = wordForm.Perspective;
                Plural         = wordForm.Plural;
                Positional     = wordForm.Positional;
                Possessive     = wordForm.Possessive;
                Quality        = wordForm.Quality;
                Semantics      = wordForm.Semantics;
                Severity       = wordForm.Severity;
                Tense          = wordForm.Tense;
            }
        }
Beispiel #26
0
        public GlobalConfig()
        {
            Name = "LiveSettings";
            WebsocketPortalActive = true;
            AdminsOnly            = false;
            UserCreationActive    = true;

            BaseLanguage = ConfigDataCache.GetAll <ILanguage>().FirstOrDefault();
        }
        public ActionResult Purge()
        {
            System.Collections.Generic.IEnumerable <IDictataPhrase> dictionary = ConfigDataCache.GetAll <IDictataPhrase>();

            foreach (IDictataPhrase dict in dictionary)
            {
                dict.SystemRemove();
            }

            return(RedirectToAction("Index", new { Message = "By fire, it is purged." }));
        }
Beispiel #28
0
 public static ConfigDataCache CreateInstance(ConfigDataProvider datas)
 {
     if (_instance == null || datas.IsEditFlag)
     {
         lock (lockHelper)
         {
             _instance = new ConfigDataCache(datas);
         }
     }
     return(_instance);
 }
        public ActionResult Purge()
        {
            IEnumerable<ILexeme> dictionary = ConfigDataCache.GetAll<ILexeme>();

            foreach(ILexeme dict in dictionary)
            {
                dict.SystemRemove();
            }

            return RedirectToAction("Index", new { Message = "By fire, it is purged." });
        }
Beispiel #30
0
        /// <summary>
        /// Get the dictata from this lexica
        /// </summary>
        /// <returns>A dictata</returns>
        public IDictata GetDictata()
        {
            ILexeme  lex  = ConfigDataCache.Get <ILexeme>(new ConfigDataCacheKey(typeof(ILexeme), string.Format("{0}_{1}", Context?.Language?.Name, Phrase), ConfigDataType.Dictionary));
            IDictata dict = lex?.GetForm(Type);

            if (dict == null)
            {
                dict = GenerateDictata();
            }

            return(dict);
        }