Beispiel #1
0
        public static void CreateCultureInfo()
        {
            using (Transaction tr = new Transaction())
            {
                var en = new CultureInfoEntity(CultureInfo.GetCultureInfo("en")).Save();
                var es = new CultureInfoEntity(CultureInfo.GetCultureInfo("es")).Save();

                new ApplicationConfigurationEntity
                {
                    Environment = "Development",
                    Email = new EmailConfigurationEntity
                    {
                        SendEmails = true,
                        DefaultCulture = en,
                        UrlLeft = "http://localhost/Southwind"
                    },
                    SmtpConfiguration = new SmtpConfigurationEntity
                    {
                        Name = "localhost",
                        Network = new SmtpNetworkDeliveryEntity
                        {
                            Host = "localhost"
                        }
                    }, //Email
                    Sms = new SMSConfigurationEntity
                    {
                        DefaultCulture = en,
                    } //Sms
                }.Save();

                tr.Commit();
            }
        }
        public static void AssignTranslatedFullEntity(this EntityHelpEntity entity, CultureInfoEntity fromCulture)
        {
            var fromEntity = Database.Query<EntityHelpEntity>().SingleOrDefaultEx(e => e.Type == entity.Type && e.Culture == fromCulture);

            if(fromEntity != null)
            {
                AssignTranslatedEntity(entity, fromEntity);
            }

            var queries = HelpLogic.TypeToQuery.Value.TryGetC(entity.Type.ToType()).EmptyIfNull().Select(QueryLogic.GetQueryEntity).ToList();

            foreach (var q in queries)
            {
                var fromQuery = Database.Query<QueryHelpEntity>().SingleOrDefaultEx(e => e.Query == q && e.Culture == fromCulture);

                if (fromQuery != null)
                {
                    var query = Database.Query<QueryHelpEntity>().SingleOrDefaultEx(e => e.Query == q && e.Culture == entity.Culture) ??
                        new QueryHelpEntity { Culture = entity.Culture, Query = q };

                    AsignTranslatedQuery(query, fromQuery);
                }
            }

            var operations = OperationLogic.GetAllOperationInfos(entity.Type.ToType()).Select(o=>o.OperationSymbol).ToList();

            foreach (var oper in operations)
            {
                var fromOper = Database.Query<OperationHelpEntity>().SingleOrDefaultEx(e => e.Operation == oper && e.Culture == fromCulture);

                if (fromOper != null)
                {
                    var operation = Database.Query<OperationHelpEntity>().SingleOrDefaultEx(e => e.Operation == oper && e.Culture == entity.Culture) ??
                        new OperationHelpEntity { Culture = entity.Culture, Operation = oper };

                    AsignTranslatedOperation(operation, fromOper);
                }
            }
        }
        public static void AsignTranslatedAppendix(this AppendixHelpEntity appendix, CultureInfoEntity fromCulture)
        {
            var fromAppendix = Database.Query<AppendixHelpEntity>().SingleEx(n => n.UniqueName == appendix.UniqueName && n.Culture == fromCulture);

            HashSet<string> toTranslate = new HashSet<string>();
            if (!appendix.Title.HasText() && fromAppendix.Title.HasText())
                toTranslate.Add(fromAppendix.Title);

            if (!appendix.Description.HasText() && fromAppendix.Description.HasText())
                toTranslate.Add(fromAppendix.Description);

            Dictionary<string, string> dic = Translate(toTranslate, fromAppendix.Culture.Name, appendix.Culture.Name);

            if (!appendix.Title.HasText() && fromAppendix.Title.HasText())
                appendix.Title = dic.GetOrThrow(fromAppendix.Title);

            if (!appendix.Description.HasText() && fromAppendix.Description.HasText())
                appendix.Description = dic.GetOrThrow(fromAppendix.Description);

            appendix.Execute(AppendixHelpOperation.Save);
        }
        public static void AsignTranslatedNamespace(this NamespaceHelpEntity @namespace, CultureInfoEntity fromCulture)
        {
            var fromNamespace = Database.Query<NamespaceHelpEntity>().SingleEx(n => n.Name == @namespace.Name && n.Culture == fromCulture);

            HashSet<string> toTranslate = new HashSet<string>();
            if ([email protected]() && fromNamespace.Description.HasText())
                toTranslate.Add(fromNamespace.Description);

            Dictionary<string, string> dic = Translate(toTranslate, fromNamespace.Culture.Name, @namespace.Culture.Name);
            if ([email protected]() && fromNamespace.Description.HasText())
                @namespace.Description = dic.GetOrThrow(fromNamespace.Description);

            @namespace.Execute(NamespaceHelpOperation.Save);
        }
 public EmailMasterTemplateMessageEntity(CultureInfoEntity culture)
 {
     this.CultureInfo = culture;
 }
Beispiel #6
0
 public SMSTemplateMessageEntity(CultureInfoEntity culture)
 {
     this.CultureInfo = culture;
 }
 internal static void LoadBasics()
 {
     var en = new CultureInfoEntity(CultureInfo.GetCultureInfo("en")).Save();
     var es = new CultureInfoEntity(CultureInfo.GetCultureInfo("es")).Save();
 }