public DBConnector(string strConnectionString, DbConnectorSettings dbConnectorSettings, IMemoryCache cache, IHttpContextAccessor httpContextAccessor) { ThrowNotificationExceptions = true; ForceLocalCache = false; UpdateManyToMany = true; UpdateManyToOne = true; CacheData = true; CustomConnectionString = strConnectionString; DbConnectorSettings = dbConnectorSettings; CacheManager = new DbCacheManager(this, cache); FileSystem = new RealFileSystem(); DynamicImageCreator = new DynamicImageCreator(FileSystem); HttpContext = httpContextAccessor?.HttpContext; WithTransaction = true; }
public DBConnector(string strConnectionString, DbConnectorSettings dbConnectorSettings, IMemoryCache cache) { if (!string.IsNullOrWhiteSpace(dbConnectorSettings.ConnectionString)) { ConnectionString = dbConnectorSettings.ConnectionString; } ThrowNotificationExceptions = true; ForceLocalCache = false; UpdateManyToMany = true; UpdateManyToOne = true; CacheData = true; CustomConnectionString = strConnectionString; DbConnectorSettings = dbConnectorSettings; CacheManager = new DbCacheManager(this, cache); FileSystem = new RealFileSystem(); DynamicImageCreator = new DynamicImageCreator(FileSystem); WithTransaction = true; }
public DBConnector(string strConnectionString, DatabaseType dbType = DatabaseType.SqlServer) { ForceLocalCache = false; CacheData = true; UpdateManyToMany = true; UpdateManyToOne = true; ThrowNotificationExceptions = true; CustomConnectionString = strConnectionString; DbConnectorSettings = new DbConnectorSettings(ConfigurationManager.AppSettings) { ConnectionString = strConnectionString, DbType = dbType }; CacheManager = new DbCacheManager(this); FileSystem = new RealFileSystem(); DynamicImageCreator = new DynamicImageCreator(FileSystem); WithTransaction = true; }
private void CreateDynamicImages(Dictionary <string, string>[] arrValues, ContentAttribute[] fullAttrs) { foreach (var dynImageAttr in fullAttrs.Where(n => n.RelatedImageId.HasValue)) { if (dynImageAttr.RelatedImageId == null) { continue; } var imageAttr = fullAttrs.Single(n => n.Id == dynImageAttr.RelatedImageId.Value); var attrDir = GetDirectoryForFileAttribute(imageAttr.Id); var contentDir = GetContentLibraryDirectory(imageAttr.SiteId, imageAttr.ContentId); foreach (var article in arrValues) { if (article.TryGetValue(imageAttr.Name, out var image)) { var info = new DynamicImageInfo { ContentLibraryPath = contentDir, ImagePath = attrDir, ImageName = image, AttrId = dynImageAttr.Id, Width = dynImageAttr.DynamicImage.Width, Height = dynImageAttr.DynamicImage.Height, Quality = dynImageAttr.DynamicImage.Quality, FileType = dynImageAttr.DynamicImage.Type, MaxSize = dynImageAttr.DynamicImage.MaxSize }; DynamicImageCreator.CreateDynamicImage(info); article[dynImageAttr.Name] = DynamicImage.GetDynamicImageRelUrl(info?.ImageName, info.AttrId, info.FileType); } } } }