Ejemplo n.º 1
0
        public int BatchCreate(string langName, string batchText)
        {
            int n = 0;

            if ((langName ?? "").Length > 0 && (batchText ?? "").Length > 0)
            {
                string[] lines = batchText.Split('\n', StringSplitOptions.RemoveEmptyEntries);
                foreach (var x in lines)
                {
                    string langKey   = x.Substring(0, x.IndexOf(",")).Trim();
                    string langValue = x.Substring(x.IndexOf(",") + 1).Replace("\r", "").Trim();
                    ApplicationLanguageText langText = new ApplicationLanguageText();
                    langText.Source        = GinkgoConsts.LocalizationSourceName;
                    langText.TenantId      = AbpSession.TenantId;
                    langText.LanguageName  = langName;
                    langText.Key           = langKey;
                    langText.Value         = langValue;
                    langText.CreationTime  = Abp.Timing.Clock.Now;
                    langText.CreatorUserId = AbpSession.UserId;
                    _repository.Insert(langText);
                    n += 1;
                }
            }
            return(n);
        }
Ejemplo n.º 2
0
        private void AddLanguageTextIfNotExists(ApplicationLanguageText language)
        {
            if (_context.LanguageTexts.IgnoreQueryFilters().Any(l => l.TenantId == language.TenantId && l.LanguageName == language.LanguageName && l.Source == language.Source && l.Key == language.Key))
            {
                return;
            }

            _context.LanguageTexts.Add(language);
            _context.SaveChanges();
        }