Exemple #1
0
        public CultureGroupDetailsViewModel GetModules(string culture)
        {
            var model = new CultureGroupDetailsViewModel {
                Culture = culture
            };
            var session = _sessionLocator.For(typeof(LocalizableStringRecord));
            // haal alle mogelijke strings, en hun vertaling in deze culture uit db
            var paths = session.CreateSQLQuery(
                string.Format(@"  SELECT Localizable.Path,
                        COUNT(Localizable.Id) AS TotalCount,
                        COUNT(Translation.Id) AS TranslatedCount
                    FROM {0}Q42_DbTranslations_LocalizableStringRecord AS Localizable
                    LEFT OUTER JOIN {0}Q42_DbTranslations_TranslationRecord AS Translation
                        ON Localizable.Id = Translation.LocalizableStringRecord_id
                        AND Translation.Culture = :culture
                    GROUP BY Localizable.Path
                    ORDER BY Localizable.Path", DataTablePrefix()))
                        .AddScalar("Path", NHibernateUtil.String)
                        .AddScalar("TotalCount", NHibernateUtil.Int32)
                        .AddScalar("TranslatedCount", NHibernateUtil.Int32)
                        .SetParameter("culture", culture);

            model.Groups = paths.List <object[]>()
                           .Select(t => new CultureGroupDetailsViewModel.TranslationGroup {
                Path             = (string)t[0],
                TotalCount       = (int)t[1],
                TranslationCount = (int)t[2],
            }).ToList();
            return(model);
        }
Exemple #2
0
        public CultureGroupDetailsViewModel Search(string culture, string querystring)
        {
            var model = new CultureGroupDetailsViewModel {
                Culture = culture
            };

            var wc = _wca.GetContext();
            {
                var _sessionLocator = wc.Resolve <ISessionLocator>();
                using (var session = _sessionLocator.For(typeof(LocalizableStringRecord)))
                {
                    // haalt alle mogelijke strings en description en hun vertaling in culture op
                    var paths = session.CreateSQLQuery(
                        string.Format(@"  SELECT Localizable.Id,
              Localizable.StringKey,
              Localizable.Context,
              Localizable.OriginalLanguageString,
              Translation.Value,
              Localizable.Path
          FROM {0}Q42_DbTranslations_LocalizableStringRecord AS Localizable
          LEFT OUTER JOIN {0}Q42_DbTranslations_TranslationRecord AS Translation
              ON Localizable.Id = Translation.LocalizableStringRecord_id
              AND Translation.Culture = :culture
          WHERE Localizable.OriginalLanguageString LIKE :query 
              OR Translation.Value LIKE :query", DataTablePrefix()))
                                .AddScalar("Id", NHibernateUtil.Int32)
                                .AddScalar("StringKey", NHibernateUtil.String)
                                .AddScalar("Context", NHibernateUtil.String)
                                .AddScalar("OriginalLanguageString", NHibernateUtil.String)
                                .AddScalar("Value", NHibernateUtil.String)
                                .AddScalar("Path", NHibernateUtil.String)
                                .SetParameter("culture", culture)
                                .SetParameter("query", "%" + querystring + "%");
                    model.CurrentGroupTranslations = paths.List <object[]>()
                                                     .Select(t => new CultureGroupDetailsViewModel.TranslationViewModel
                    {
                        Id             = (int)t[0],
                        GroupPath      = (string)t[5],
                        Key            = (string)t[1],
                        Context        = (string)t[2],
                        OriginalString = (string)t[3],
                        LocalString    = (string)t[4]
                    }).ToList().GroupBy(t => t.Context);
                }
                return(model);
            }
        }