Пример #1
0
        public static void SetTranslation(String moduleName, String languagePair, String trnKey, TranslationContract contract)
        {
            if (String.IsNullOrWhiteSpace(moduleName))
            {
                throw new ArgumentNullException("moduleName");
            }

            if (String.IsNullOrWhiteSpace(trnKey))
            {
                throw new ArgumentNullException("trnKey");
            }

            if (String.IsNullOrWhiteSpace(languagePair))
            {
                throw new ArgumentNullException("languagePair");
            }

            if (contract == null)
            {
                throw new ArgumentNullException("contract");
            }

            var session = Hb8Factory.InitSession();

            var entity = (from n in session.Query <CD_Translation>()
                          where n.DateDeleted == null &&
                          n.TrnKey.ToLower() == trnKey.ToLower() &&
                          n.LanguagePair.ToLower() == languagePair.ToLower() &&
                          n.ModuleName.ToLower() == moduleName.ToLower()
                          select n).SingleOrDefault();

            if (entity == null)
            {
                entity = new CD_Translation
                {
                    ID          = Guid.NewGuid(),
                    DateCreated = DateTime.Now
                };

                entity.TrnKey         = trnKey;
                entity.ModuleName     = moduleName;
                entity.LanguagePair   = languagePair;
                entity.DefaultText    = contract.DefaultText;
                entity.TranslatedText = contract.TranslatedText;

                session.SubmitChanges(entity);
            }
            else
            {
                TranslationCache.SetTranslatedText(moduleName, languagePair, trnKey, contract.TranslatedText);
            }
        }
Пример #2
0
        public static void SetTranslatedText(String moduleName, String languagePair, String trnKey, String translatedText)
        {
            if (String.IsNullOrWhiteSpace(moduleName))
            {
                throw new ArgumentNullException("moduleName");
            }

            if (String.IsNullOrWhiteSpace(trnKey))
            {
                throw new ArgumentNullException("trnKey");
            }

            if (String.IsNullOrWhiteSpace(languagePair))
            {
                throw new ArgumentNullException("languagePair");
            }

            TranslationCache.SetTranslatedText(moduleName, languagePair, trnKey, translatedText);
        }