public static void Delete(CMSImageDataContext db, int?id) { if (id.HasValue) { db.ExecuteCommand("DELETE dbo.Image WHERE Id = {0}", id); } }
public static Image NewImageFromBits(byte[] bits, int w, int h, CMSImageDataContext db) { var i = new Image(); i.LoadResizeFromBits(bits, w, h); InsertImage(db, i); return(i); }
public Image CreateNewTinyImage(CMSImageDataContext db) { var i = new Image(); i.LoadResizeFromBits(Bits, 50, 50); InsertImage(db, i); return(i); }
public static Image CreateImageFromType(byte[] bits, string type, CMSImageDataContext db) { var i = new Image(); i.LoadFromBits(bits, type); InsertImage(db, i); return(i); }
public static void DbDispose() { if (InternalDb != null) { InternalDb.Dispose(); InternalDb = null; } }
public static Image NewImageFromBits(byte[] bits, CMSImageDataContext db, bool isPublic = false) { var i = new Image(); i.LoadImageFromBits(bits); i.IsPublic = isPublic; InsertImage(db, i); return(i); }
public static Image NewTextFromString(string s, CMSImageDataContext db) { var i = new Image(); i.Mimetype = "text/plain"; i.Bits = Encoding.ASCII.GetBytes(s); i.Length = i.Bits.Length; InsertImage(db, i); return(i); }
public static CMSImageDataContext Create(HttpContextBase currentHttpContext) { var host = currentHttpContext.Request.Url.Authority.Split('.', ':')[0]; var cs = ConfigurationManager.ConnectionStrings["CMS"]; var cb = new SqlConnectionStringBuilder(cs.ConnectionString); cb.InitialCatalog = $"CMSi_{host}"; cb.PersistSecurityInfo = true; var connectionString = cb.ConnectionString; return(CMSImageDataContext.Create(connectionString)); }
private static Image GetImageFromFile(CMSImageDataContext db, HttpPostedFileBase file) { byte[] data; using (Stream inputStream = file.InputStream) { MemoryStream memoryStream = inputStream as MemoryStream; if (memoryStream == null) { memoryStream = new MemoryStream(); inputStream.CopyTo(memoryStream); } data = memoryStream.ToArray(); } var mimetype = UtilityExtensions.MimeTypes.ShortTypeFromMimeType(MimeMapping.GetMimeMapping(file.FileName)); return(Image.CreateImageFromType(data, mimetype, db)); }
public static CMSImageDataContext Create(HttpContextBase currentHttpContext) { var host = UtilityExtensions.Util.PickFirst(ConfigurationManager.AppSettings["host"], currentHttpContext.Request.Url.Authority.Split('.', ':')[0]); return(CMSImageDataContext.Create(host)); }
public static int StoreImageFromDocument(CMSImageDataContext db, HttpPostedFileBase file) { Image i = GetImageFromFile(db, file); return(i.Id); }
public static Image ImageFromId(CMSImageDataContext db, int?id) { return(db.Images.SingleOrDefault(ii => ii.Id == id)); }
private static void InsertImage(CMSImageDataContext db, Image i) { db.Images.InsertOnSubmit(i); db.SubmitChanges(); }
public static Image NewImageFromBits(byte[] bits, string type, CMSImageDataContext db) { var image = CreateImageFromType(bits, type, db); return(image); }
public static CMSImageDataContext Create(HttpContextBase currentHttpContext) { var host = ConfigurationManager.AppSettings["host"] ?? currentHttpContext.Request.Url.Authority.Split('.', ':')[0]; return(CMSImageDataContext.Create(host)); }