예제 #1
0
 protected BaseController()
 {
     NewsService                = new NewsRepository();
     NewsGroupService           = new NewsGroupRepository();
     AccountService             = new AccountRepository();
     ContactService             = new ContactRepository();
     ProductTypeService         = new Respository.ProductTypeRepository();
     SiteConfigService          = new SiteConfigRespository();
     EmailConfigService         = new EmailConfigRepository();
     MenuConfigService          = new MenuConfigRespository();
     ProductBrandService        = new ProductBrandRespository();
     ProductManufacturerService = new ProductManufacturerRespository();
     ProductDistributorService  = new ProductDistributorRespository();
     ProductStoreService        = new StoreRespository();
     UnitService                = new UnitRespository();
     ColorService               = new ColorRespository();
     CountryService             = new CountryRespository();
     SizeService                = new SizeRespository();
     ProductAttributeService    = new ProductAttributeRespository();
     ProductImageService        = new ProductImageRespository();
     UserService                = new UserRespository();
     RoleService                = new RoleRespository();
     PermissionService          = new PermissionRespository();
     ProductSizeService         = new ProductSizeRespository();
     ProductColorService        = new ProductColorRespository();
     ProductSaleOffService      = new ProductSaleOffRespository();
     ProductService             = new ProductRespository();
     AdminAccountService        = new AdminRespository();
     BannerService              = new BannerRespository();
 }
        private EmailServiceConfiguration LoadConfiguration()
        {
            var repo          = new EmailConfigRepository();
            var config        = repo.ReadEmailServiceConfiguration();
            var configuration = Component.Mappers.ConfigurationMapper.Map(config);

            return(configuration);
        }
        public static bool CreateServiceStatusEmail(ServiceInfo info, ILog log = null)
        {
            bool   result     = false;
            string methodName = MethodBase.GetCurrentMethod().Name;

            try
            {
                var repo     = new EmailConfigRepository();
                var template = repo.GetEmailTemplate(SERVICE_STATUS);
                var list     = new List <string>();
                if (template != null)
                {
                    if (template.Subscribers != null)
                    {
                        foreach (var subscriber in template.Subscribers)
                        {
                            if (!string.IsNullOrEmpty(subscriber.EmailAddress))
                            {
                                list.Add(subscriber.EmailAddress);
                            }
                        }
                    }
                    EmailFileTemplate fileTemplate = new EmailFileTemplate();

                    fileTemplate.EmailSubject = template.TemplateSubject
                                                .Replace("{{SERVICE_NAME}}", info.ServiceName)
                                                .Replace("{{SERVICE_STATUS}}", info.ServiceStatus.ToString());

                    fileTemplate.EmailMessage = template.TemplateMessage.Replace("\\n", "\n")
                                                .Replace("{{DATETIME}}", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"))
                                                .Replace("{{SERVICE_NAME}}", info.ServiceName)
                                                .Replace("{{SERVICE_STATUS}}", info.ServiceStatus.ToString());

                    fileTemplate.BccEmailAddresses = list;

                    if (fileTemplate != null)
                    {
                        var json = JsonConvert.SerializeObject(fileTemplate);
                        var file = string.Format(@"{0}\Gateway_{1}.json", EmailManager.Instance.Configurations.EmailFolderPath,
                                                 DateTime.UtcNow.ToString("yyyyMMddHHmmss"));

                        FileHelper.WriteAllText(file, json);
                        result = true;
                    }
                }
            }
            catch (Exception ex)
            {
                log?.Error(className, methodName, ex.ToString());
                result = false;
            }
            return(result);
        }
예제 #4
0
        private static void SetLastTimeEmailWasChecked()
        {
            try
            {
                var getDbContext    = new GetDbContext();
                var context         = getDbContext.ReturnDbContext();
                var emailConfigRepo = new EmailConfigRepository(context, null);

                emailConfigRepo.SetLastLoadDate(DateTime.Now);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to get GetLastTimeEmailWasChecked!" + ex.Message);
            }
        }
예제 #5
0
        private static string GetLastTimeEmailWasChecked()
        {
            try
            {
                var getDbContext    = new GetDbContext();
                var context         = getDbContext.ReturnDbContext();
                var emailConfigRepo = new EmailConfigRepository(context, null);

                string lastLoad = emailConfigRepo.GetLastLoadDate().ToString("yyyy-MM-dd");

                return(lastLoad);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to get GetLastTimeEmailWasChecked!" + ex.Message);
                return(null);
            }
        }
예제 #6
0
 public void GetServiceStatusEmail()
 {
     var repo = new EmailConfigRepository();
     var res  = repo.GetEmailTemplate("SERVICE_STATUS");
 }
예제 #7
0
 public void GetNoChannelConnectedEmail()
 {
     var repo = new EmailConfigRepository();
     var res  = repo.GetEmailTemplate("NO_CHANNEL_CONNECTED");
 }