当前位置: 首页>>代码示例>>C#>>正文


C# Messages.MessageTemplate类代码示例

本文整理汇总了C#中Nop.Core.Domain.Messages.MessageTemplate的典型用法代码示例。如果您正苦于以下问题:C# MessageTemplate类的具体用法?C# MessageTemplate怎么用?C# MessageTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageTemplate类属于Nop.Core.Domain.Messages命名空间,在下文中一共展示了MessageTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_save_and_load_messageTemplate

        public void Can_save_and_load_messageTemplate()
        {
            var mt = new MessageTemplate
            {
                Name = "Template1",
                BccEmailAddresses = "Bcc",
                Subject = "Subj",
                Body = "Some text",
                IsActive = true,
                AttachedDownloadId = 3,
                EmailAccountId = 1,
                LimitedToStores = true,
            };

            var fromDb = SaveAndLoadEntity(mt);
            fromDb.ShouldNotBeNull();
            fromDb.Name.ShouldEqual("Template1");
            fromDb.BccEmailAddresses.ShouldEqual("Bcc");
            fromDb.Subject.ShouldEqual("Subj");
            fromDb.Body.ShouldEqual("Some text");
            fromDb.IsActive.ShouldBeTrue();
            fromDb.AttachedDownloadId.ShouldEqual(3);
            fromDb.LimitedToStores.ShouldBeTrue();

            fromDb.EmailAccountId.ShouldEqual(1);
        }
开发者ID:mmSource,项目名称:nopCommerce,代码行数:26,代码来源:MessageTemplatePersistenceTests.cs

示例2: UpdateLocales

        protected virtual void UpdateLocales(MessageTemplate mt, MessageTemplateModel model)
        {
            foreach (var localized in model.Locales)
            {
                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.BccEmailAddresses,
                                                           localized.BccEmailAddresses,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.Subject,
                                                           localized.Subject,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.Body,
                                                           localized.Body,
                                                           localized.LanguageId);

                _localizedEntityService.SaveLocalizedValue(mt,
                                                           x => x.EmailAccountId,
                                                           localized.EmailAccountId,
                                                           localized.LanguageId);
            }
        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:25,代码来源:MessageTemplateController.cs

示例3: SendNotification

        protected int SendNotification(MessageTemplate messageTemplate,
                                     EmailAccount emailAccount, int languageId, IEnumerable<Token> tokens,
                                     string toEmailAddress, string toName)
        {
            //retrieve localized message template data
            var bcc = messageTemplate.GetLocalized((mt) => mt.BccEmailAddresses, languageId);
            var subject = messageTemplate.GetLocalized((mt) => mt.Subject, languageId);
            var body = messageTemplate.GetLocalized((mt) => mt.Body, languageId);

            //Replace subject and body tokens 
            var subjectReplaced = _tokenizer.Replace(subject, tokens, false);
            var bodyReplaced = _tokenizer.Replace(body, tokens, false);

            var email = new QueuedEmail() {
                Priority = QueuedEmailPriority.High,
                From = emailAccount.Email,
                FromName = emailAccount.DisplayName,
                To = toEmailAddress,
                ToName = toName,
                CC = string.Empty,
                Bcc = bcc,
                Subject = subjectReplaced,
                Body = bodyReplaced,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id
            };

            _queuedEmailService.InsertQueuedEmail(email);
            return email.Id;
        }
开发者ID:mobsoftware,项目名称:mob.core,代码行数:30,代码来源:BaseMessageService.cs

示例4: UpdateMessageTemplate

        /// <summary>
        /// Updates a message template
        /// </summary>
        /// <param name="messageTemplate">Message template</param>
        public virtual void UpdateMessageTemplate(MessageTemplate messageTemplate)
        {
            if (messageTemplate == null)
                throw new ArgumentNullException("messageTemplate");

            _messageTemplateRepository.Update(messageTemplate);

            _cacheManager.RemoveByPattern(MESSAGETEMPLATES_PATTERN_KEY);

            //event notification
            _eventPublisher.EntityUpdated(messageTemplate);
        }
开发者ID:philipengland,项目名称:albionextrusions.co.uk,代码行数:16,代码来源:MessageTemplateService.cs

示例5: CopyMessageTemplate

        /// <summary>
        /// Create a copy of message template with all depended data
        /// </summary>
        /// <param name="messageTemplate">Message template</param>
        /// <returns>Message template copy</returns>
        public virtual MessageTemplate CopyMessageTemplate(MessageTemplate messageTemplate)
        {
            if (messageTemplate == null)
                throw new ArgumentNullException("messageTemplate");

            var mtCopy = new MessageTemplate()
                             {
                                 Name = messageTemplate.Name,
                                 BccEmailAddresses = messageTemplate.BccEmailAddresses,
                                 Subject = messageTemplate.Subject,
                                 Body = messageTemplate.Body,
                                 IsActive = messageTemplate.IsActive,
                                 EmailAccountId = messageTemplate.EmailAccountId,
                                 LimitedToStores = messageTemplate.LimitedToStores,
                             };

            InsertMessageTemplate(mtCopy);

            var languages = _languageService.GetAllLanguages(true);

            //localization
            foreach (var lang in languages)
            {
                var bccEmailAddresses = messageTemplate.GetLocalized(x => x.BccEmailAddresses, lang.Id, false, false);
                if (!String.IsNullOrEmpty(bccEmailAddresses))
                    _localizedEntityService.SaveLocalizedValue(mtCopy, x => x.BccEmailAddresses, bccEmailAddresses, lang.Id);

                var subject = messageTemplate.GetLocalized(x => x.Subject, lang.Id, false, false);
                if (!String.IsNullOrEmpty(subject))
                    _localizedEntityService.SaveLocalizedValue(mtCopy, x => x.Subject, subject, lang.Id);

                var body = messageTemplate.GetLocalized(x => x.Body, lang.Id, false, false);
                if (!String.IsNullOrEmpty(body))
                    _localizedEntityService.SaveLocalizedValue(mtCopy, x => x.Body, subject, lang.Id);

                var emailAccountId = messageTemplate.GetLocalized(x => x.EmailAccountId, lang.Id, false, false);
                if (emailAccountId > 0)
                    _localizedEntityService.SaveLocalizedValue(mtCopy, x => x.EmailAccountId, emailAccountId, lang.Id);
            }

            //store mapping
            var selectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(messageTemplate);
            foreach (var id in selectedStoreIds)
            {
                _storeMappingService.InsertStoreMapping(mtCopy, id);
            }

            return mtCopy;
        }
开发者ID:kramerica-industries,项目名称:eCommerce,代码行数:54,代码来源:MessageTemplateService.cs

示例6: SendNotification

        protected virtual int SendNotification(MessageTemplate messageTemplate, 
            EmailAccount emailAccount, int languageId, IEnumerable<Token> tokens,
            string toEmailAddress, string toName,
            string attachmentFilePath = null, string attachmentFileName = null,
            string replyToEmailAddress = null, string replyToName = null)
        {
            if (messageTemplate == null)
                throw new ArgumentNullException("messageTemplate");
            if (emailAccount == null)
                throw new ArgumentNullException("emailAccount");

            //retrieve localized message template data
            var bcc = messageTemplate.GetLocalized(mt => mt.BccEmailAddresses, languageId);
            var subject = messageTemplate.GetLocalized(mt => mt.Subject, languageId);
            var body = messageTemplate.GetLocalized(mt => mt.Body, languageId);

            //Replace subject and body tokens 
            var subjectReplaced = _tokenizer.Replace(subject, tokens, false);
            var bodyReplaced = _tokenizer.Replace(body, tokens, true);

            //limit name length
            toName = CommonHelper.EnsureMaximumLength(toName, 300);
            
            var email = new QueuedEmail
            {
                Priority = QueuedEmailPriority.High,
                From = emailAccount.Email,
                FromName = emailAccount.DisplayName,
                To = toEmailAddress,
                ToName = toName,
                ReplyTo = replyToEmailAddress,
                ReplyToName = replyToName,
                CC = string.Empty,
                Bcc = bcc,
                Subject = subjectReplaced,
                Body = bodyReplaced,
                AttachmentFilePath = attachmentFilePath,
                AttachmentFileName = attachmentFileName,
                AttachedDownloadId = messageTemplate.AttachedDownloadId,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id,
                DontSendBeforeDateUtc = !messageTemplate.DelayBeforeSend.HasValue ? null
                    : (DateTime?)(DateTime.UtcNow + TimeSpan.FromHours(messageTemplate.DelayPeriod.ToHours(messageTemplate.DelayBeforeSend.Value)))
            };

            _queuedEmailService.InsertQueuedEmail(email);
            return email.Id;
        }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:48,代码来源:WorkflowMessageService.cs

示例7: SendNotification

        protected virtual int SendNotification(MessageTemplate messageTemplate, 
            EmailAccount emailAccount, int languageId, IEnumerable<Token> tokens,
            string toEmailAddress, string toName,
            string attachmentFilePath = null, string attachmentFileName = null,
            string replyToEmailAddress = null, string replyToName = null)
        {
            //retrieve localized message template data
            var bcc = messageTemplate.GetLocalized(mt => mt.BccEmailAddresses, languageId);
            var subject = messageTemplate.GetLocalized(mt => mt.Subject, languageId);
            var body = messageTemplate.GetLocalized(mt => mt.Body, languageId);

            //Replace subject and body tokens 
            var subjectReplaced = _tokenizer.Replace(subject, tokens, false);
            var bodyReplaced = _tokenizer.Replace(body, tokens, true);
            
            var email = new QueuedEmail
            {
                Priority = 5,
                From = emailAccount.Email,
                FromName = emailAccount.DisplayName,
                To = toEmailAddress,
                ToName = toName,
                ReplyTo = replyToEmailAddress,
                ReplyToName = replyToName,
                CC = string.Empty,
                Bcc = bcc,
                Subject = subjectReplaced,
                Body = bodyReplaced,
                AttachmentFilePath = attachmentFilePath,
                AttachmentFileName = attachmentFileName,
                AttachedDownloadId = messageTemplate.AttachedDownloadId,
                CreatedOnUtc = DateTime.UtcNow,
                EmailAccountId = emailAccount.Id
            };

            _queuedEmailService.InsertQueuedEmail(email);
            return email.Id;
        }
开发者ID:LaOrigin,项目名称:Leorigin,代码行数:38,代码来源:WorkflowMessageService.cs

示例8: SaveStoreMappings

 protected virtual void SaveStoreMappings(MessageTemplate messageTemplate, MessageTemplateModel model)
 {
     var existingStoreMappings = _storeMappingService.GetStoreMappings(messageTemplate);
     var allStores = _storeService.GetAllStores();
     foreach (var store in allStores)
     {
         if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.ID))
         {
             //new store
             if (existingStoreMappings.Count(sm => sm.StoreId == store.ID) == 0)
                 _storeMappingService.InsertStoreMapping(messageTemplate, store.ID);
         }
         else
         {
             //remove store
             var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.ID);
             if (storeMappingToDelete != null)
                 _storeMappingService.DeleteStoreMapping(storeMappingToDelete);
         }
     }
 }
开发者ID:jasonholloway,项目名称:brigita,代码行数:21,代码来源:MessageTemplateController.cs

示例9: PrepareStoresMappingModel

        protected virtual void PrepareStoresMappingModel(MessageTemplateModel model, MessageTemplate messageTemplate, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            model.AvailableStores = _storeService
                .GetAllStores()
                .Select(s => s.ToModel())
                .ToList();
            if (!excludeProperties)
            {
                if (messageTemplate != null)
                {
                    model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(messageTemplate);
                }
            }
        }
开发者ID:jasonholloway,项目名称:brigita,代码行数:17,代码来源:MessageTemplateController.cs

示例10: GetEmailAccountOfMessageTemplate

 private EmailAccount GetEmailAccountOfMessageTemplate(MessageTemplate messageTemplate, int languageId)
 {
     var emailAccounId = messageTemplate.GetLocalized(mt => mt.EmailAccountId, languageId);
     var emailAccount = _emailAccountService.GetEmailAccountById(emailAccounId);
     if (emailAccount == null)
         emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
     if (emailAccount == null)
         emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
     return emailAccount;
 }
开发者ID:btolbert,项目名称:test-commerce,代码行数:10,代码来源:WorkflowMessageService.cs

示例11: ToEntity

 public static MessageTemplate ToEntity(this MessageTemplateModel model, MessageTemplate destination)
 {
     return Mapper.Map(model, destination);
 }
开发者ID:nguyentu1982,项目名称:quancu,代码行数:4,代码来源:MappingExtensions.cs

示例12: GetEmailAccountOfMessageTemplate

        protected virtual EmailAccount GetEmailAccountOfMessageTemplate(MessageTemplate messageTemplate, int languageId)
        {
            var emailAccountId = messageTemplate.GetLocalized(mt => mt.EmailAccountId, languageId);
            //some 0 validation (for localizable "Email account" dropdownlist which saves 0 if "Standard" value is chosen)
            if (emailAccountId == 0)
                emailAccountId = messageTemplate.EmailAccountId;

            var emailAccount = _emailAccountService.GetEmailAccountById(emailAccountId);
            if (emailAccount == null)
                emailAccount = _emailAccountService.GetEmailAccountById(_emailAccountSettings.DefaultEmailAccountId);
            if (emailAccount == null)
                emailAccount = _emailAccountService.GetAllEmailAccounts().FirstOrDefault();
            return emailAccount;

        }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:15,代码来源:WorkflowMessageService.cs

示例13: Install

        public override void Install()
        {
            MessageTemplate template1 =
                _messageTemplateService.GetMessageTemplateByName("OrderFreeSample.Form");

            MessageTemplate template2 =
                _messageTemplateService.GetMessageTemplateByName("HomeInstallationQuote.Form");

            MessageTemplate template3 =
                _messageTemplateService.GetMessageTemplateByName("SupplyDeliveryQuote.Form");

            if (template1 == null)
                template1 = new MessageTemplate()
                {
                    Name = "OrderFreeSample.Form",
                    Subject = "New Free Sample Order",
                    Body = GetMessageTemplateBody1(),
                    IsActive = true
                };

            if (template2 == null)
                template2 = new MessageTemplate()
                {
                    Name = "HomeInstallationQuote.Form",
                    Subject = "New Home Installation Quote",
                    Body = GetMessageTemplateBody2(),
                    IsActive = true
                };

            if (template3 == null)
                template3 = new MessageTemplate()
                {
                    Name = "SupplyDeliveryQuote.Form",
                    Subject = "New Supply and Delivery Quote",
                    Body = GetMessageTemplateBody3(),
                    IsActive = true
                };
            _messageTemplateService.InsertMessageTemplate(template1);
            _messageTemplateService.InsertMessageTemplate(template2);
            _messageTemplateService.InsertMessageTemplate(template3);

            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.OrderForm",
                "Order Free Sample Form");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.HomeInstallationQuote",
                "Home Installation Quote Form");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.SupplyDeliveryQuote",
                "Supply and Delivery Quote Form");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.ProductName",
                "Product Name");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Name",
                "Name");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Company",
                "Company");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Address",
                "Address");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.PostCode",
                "PostCode");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Phone",
                "Tel No");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Email",
                "E-mail");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Rooms",
                "Number of Rooms");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Flooring",
                "Area of Flooring in M2");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.ProjectStageId",
                "Stage of Project");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.AdditionalInfo",
                "Please provide any additional information using the space below");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.FreeCredit",
               "Interest Free Credit?");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.CommentEnquiry",
                "Please provide any additional comment or enquiry using the space below");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.Submit",
                "Submit");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.ErrorOccured",
                "Error occured. Please try again");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.SubmitFormSuccessful",
                "Thank you, your order has been submitted.");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.HomeInstallationQuoteSuccessful",
                "Thank you, your request for home installation quote has been submitted.");
            this.AddOrUpdatePluginLocaleResource("Plugin.Misc.FreeSample.SupplyDeliveryQuoteSuccessful",
                "Thank you, your request for Supply and Deliver quote has been submitted.");

            base.Install();
        }
开发者ID:ventil8,项目名称:Nop.Plugin.Misc.FreeSample,代码行数:86,代码来源:FreeSamplePlugin.cs

示例14: UpdateLocales

        protected virtual List<LocalizedProperty> UpdateLocales(MessageTemplate mt, MessageTemplateModel model)
        {
            List<LocalizedProperty> localized = new List<LocalizedProperty>();
            foreach (var local in model.Locales)
            {
                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "BccEmailAddresses",
                    LocaleValue = local.BccEmailAddresses
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "Subject",
                    LocaleValue = local.Subject
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "Body",
                    LocaleValue = local.Body
                });

                localized.Add(new LocalizedProperty()
                {
                    LanguageId = local.LanguageId,
                    LocaleKey = "EmailAccountId",
                    LocaleValue = local.EmailAccountId.ToString()
                });

            }
            return localized;
        }
开发者ID:powareverb,项目名称:grandnode,代码行数:36,代码来源:MessageTemplateController.cs

示例15: PrepareStoresMappingModel

        protected virtual void PrepareStoresMappingModel(MessageTemplateModel model, MessageTemplate messageTemplate, bool excludeProperties)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            if (!excludeProperties && messageTemplate != null)
                model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(messageTemplate).ToList();

            var allStores = _storeService.GetAllStores();
            foreach (var store in allStores)
            {
                model.AvailableStores.Add(new SelectListItem
                {
                    Text = store.Name,
                    Value = store.Id.ToString(),
                    Selected = model.SelectedStoreIds.Contains(store.Id)
                });
            }
        }
开发者ID:RobinHoody,项目名称:nopCommerce,代码行数:19,代码来源:MessageTemplateController.cs


注:本文中的Nop.Core.Domain.Messages.MessageTemplate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。