private void DoRealImport(string uri, IImageRepository repo, IImageCollection coll) { if (!CanImportUri(uri)) { throw new InvalidOperationException(); } DirectoryInfo sourcedir = new DirectoryInfo(uri); FileInfo[] finfos = sourcedir.GetFiles(); if (coll != null) { coll.FreezeUpdates(); } foreach (FileInfo fi in finfos) { string lf = fi.FullName.ToLower(); if (lf.EndsWith(".jpg") || lf.EndsWith(".jpeg") || lf.EndsWith(".png") || lf.EndsWith(".gif") || lf.EndsWith(".tif") || lf.EndsWith(".tiff")) { // int[] wh = GetImageDimensions (fi.FullName); ImageItem.ImageInfo iinfo = new ImageItem.ImageInfo(); // iinfo.width = wh[0]; // iinfo.height = wh[1]; iinfo.width = 0; iinfo.height = 0; iinfo.filesize = (int)fi.Length; iinfo.dirname = uri; iinfo.filename = fi.Name; ImageItem iitem = new ImageItem(iinfo); iitem = repo.AddImage(iitem); if (coll != null) { coll.AddItem(iitem); } } } if (coll != null) { coll.ThawUpdates(); } }
public ImageItem GetImage(int i_id) { if (!images_hash.Contains(i_id)) { ImageItem.ImageInfo iinfo; IDbCommand cmd = db_conn.CreateCommand(); cmd.CommandText = DbProvider.SqlHelper.sqlDbGetImageInfo(i_id); IDataReader r = cmd.ExecuteReader(); if (r == null) { throw new InvalidOperationException(); } r.Read(); iinfo = new ImageItem.ImageInfo(); iinfo.repo = this; if (DbProvider.DbUsesStrings(r, 0)) { iinfo.imageid = (string)r.GetValue(0); iinfo.filename = (string)r.GetValue(1); iinfo.dirname = (string)r.GetValue(2); iinfo.width = Convert.ToInt32((string)r.GetValue(3)); iinfo.height = Convert.ToInt32((string)r.GetValue(4)); iinfo.caption = (string)r.GetValue(5); // iinfo.public = (bool) r.GetValue (6); iinfo.filesize = Convert.ToInt32((string)r.GetValue(7)); } else { iinfo.imageid = (string)r.GetValue(0); iinfo.filename = (string)r.GetValue(1); iinfo.dirname = (string)r.GetValue(2); iinfo.width = (int)r.GetValue(3); iinfo.height = (int)r.GetValue(4); iinfo.caption = (string)r.GetValue(5); // iinfo.public = (bool) r.GetValue (6); iinfo.filesize = (int)r.GetValue(7); } r.Close(); images_hash.Add(i_id, new ImageItem(iinfo)); } return((ImageItem)images_hash[i_id]); }
public ImageItem GetImage (string imageid) { if (!i_hash.Contains (imageid)) { FileInfo finfo = new FileInfo (imageid); ImageItem.ImageInfo iinfo = new ImageItem.ImageInfo (); iinfo.repo = this; iinfo.imageid = imageid; iinfo.filename = finfo.Name; iinfo.dirname = finfo.DirectoryName; iinfo.width = 0; iinfo.height = 0; iinfo.filesize = (int) finfo.Length; i_hash.Add (imageid, new ImageItem (iinfo)); } return (ImageItem) i_hash[imageid]; }
private void DoRealImport (string uri, IImageRepository repo, IImageCollection coll) { if (!CanImportUri (uri)) { throw new InvalidOperationException (); } DirectoryInfo sourcedir = new DirectoryInfo (uri); FileInfo[] finfos = sourcedir.GetFiles (); if (coll != null) coll.FreezeUpdates (); foreach (FileInfo fi in finfos) { string lf = fi.FullName.ToLower (); if (lf.EndsWith (".jpg") || lf.EndsWith (".jpeg") || lf.EndsWith (".png") || lf.EndsWith (".gif") || lf.EndsWith (".tif") || lf.EndsWith (".tiff")) { // int[] wh = GetImageDimensions (fi.FullName); ImageItem.ImageInfo iinfo = new ImageItem.ImageInfo (); // iinfo.width = wh[0]; // iinfo.height = wh[1]; iinfo.width = 0; iinfo.height = 0; iinfo.filesize = (int) fi.Length; iinfo.dirname = uri; iinfo.filename = fi.Name; ImageItem iitem = new ImageItem (iinfo); iitem = repo.AddImage (iitem); if (coll != null) coll.AddItem (iitem); } } if (coll != null) coll.ThawUpdates (); }
public ImageItem GetImage(string imageid) { if (!i_hash.Contains(imageid)) { FileInfo finfo = new FileInfo(imageid); ImageItem.ImageInfo iinfo = new ImageItem.ImageInfo(); iinfo.repo = this; iinfo.imageid = imageid; iinfo.filename = finfo.Name; iinfo.dirname = finfo.DirectoryName; iinfo.width = 0; iinfo.height = 0; iinfo.filesize = (int)finfo.Length; i_hash.Add(imageid, new ImageItem(iinfo)); } return((ImageItem)i_hash[imageid]); }
public ImageItem GetImage (int i_id) { if (!images_hash.Contains (i_id)) { ImageItem.ImageInfo iinfo; IDbCommand cmd = db_conn.CreateCommand (); cmd.CommandText = DbProvider.SqlHelper.sqlDbGetImageInfo (i_id); IDataReader r = cmd.ExecuteReader (); if (r == null) throw new InvalidOperationException (); r.Read (); iinfo = new ImageItem.ImageInfo (); iinfo.repo = this; if (DbProvider.DbUsesStrings (r, 0)) { iinfo.imageid = (string) r.GetValue (0); iinfo.filename = (string) r.GetValue (1); iinfo.dirname = (string) r.GetValue (2); iinfo.width = Convert.ToInt32 ((string) r.GetValue (3)); iinfo.height = Convert.ToInt32 ((string) r.GetValue (4)); iinfo.caption = (string) r.GetValue (5); // iinfo.public = (bool) r.GetValue (6); iinfo.filesize = Convert.ToInt32 ((string) r.GetValue (7)); } else { iinfo.imageid = (string) r.GetValue (0); iinfo.filename = (string) r.GetValue (1); iinfo.dirname = (string) r.GetValue (2); iinfo.width = (int) r.GetValue (3); iinfo.height = (int) r.GetValue (4); iinfo.caption = (string) r.GetValue (5); // iinfo.public = (bool) r.GetValue (6); iinfo.filesize = (int) r.GetValue (7); } r.Close (); images_hash.Add (i_id, new ImageItem (iinfo)); } return (ImageItem) images_hash[i_id]; }