/// <summary> /// Fill untranslated resource. /// </summary> /// <param name="defaultResource"></param> /// <param name="localeResources"></param> /// <param name="locale"></param> protected static void FillResource(Canon.Data.Localization defaultResource, List <Canon.Data.Localization> localeResources, string locale) { var localeResource = from lr in localeResources where lr.ResourceSet == defaultResource.ResourceSet && lr.ResourceId == defaultResource.ResourceId select lr; if (localeResource.Count() == 0) { Canon.Data.Localization localization = new Canon.Data.Localization(); localization.ResourceId = defaultResource.ResourceId; localization.Value = defaultResource.Value; localization.LocaleId = locale; localization.ResourceSet = defaultResource.ResourceSet; localization.Type = defaultResource.Type; localization.BinFile = defaultResource.BinFile; localization.TextFile = defaultResource.TextFile; localization.Filename = defaultResource.Filename; InsertLocalization(localization); } else { Canon.Data.Localization localization = localeResource.First(); if (localization.Value != String.Empty) { return; } localization.Value = defaultResource.Value; UpdateLocalization(localization); } }
/// <summary> /// Insert new localization. /// </summary> /// <param name="localization"></param> protected static void InsertLocalization(Canon.Data.Localization localization) { CanonDataContext db = Cdb.Instance; db.Localizations.InsertOnSubmit(localization); db.SubmitChanges(); }
/// <summary> /// Update localization. /// </summary> /// <param name="localization"></param> protected static void UpdateLocalization(Canon.Data.Localization localization) { CanonDataContext db = Cdb.Instance; if (db.Localizations.GetOriginalEntityState(localization) == null) { db.Localizations.Attach(localization, false); db.Refresh(RefreshMode.KeepCurrentValues, localization); } db.SubmitChanges(); }
/// <summary> /// Fill untranslated resource. /// </summary> /// <param name="defaultResource"></param> /// <param name="localeResources"></param> /// <param name="locale"></param> protected static void FillResource(Canon.Data.Localization defaultResource, List<Canon.Data.Localization> localeResources, string locale) { var localeResource = from lr in localeResources where lr.ResourceSet == defaultResource.ResourceSet && lr.ResourceId == defaultResource.ResourceId select lr; if (localeResource.Count() == 0) { Canon.Data.Localization localization = new Canon.Data.Localization(); localization.ResourceId = defaultResource.ResourceId; localization.Value = defaultResource.Value; localization.LocaleId = locale; localization.ResourceSet = defaultResource.ResourceSet; localization.Type = defaultResource.Type; localization.BinFile = defaultResource.BinFile; localization.TextFile = defaultResource.TextFile; localization.Filename = defaultResource.Filename; InsertLocalization(localization); } else { Canon.Data.Localization localization = localeResource.First(); if (localization.Value != String.Empty) { return; } localization.Value = defaultResource.Value; UpdateLocalization(localization); } }