Ejemplo n.º 1
0
        /*
         * public static byte[] GenerateImgThumbNail(Models.DocumentScanat _documentScanat, ThumbNailSizes s)
         * {
         *  MemoryStream ms = new MemoryStream(_documentScanat.FILE_CONTENT);
         *  Image image = Image.FromStream(ms);
         *  string tmp_file = "tmp_" + DateTime.Now.ToString("ddMMyyyyHHmmss");
         *  response r = SaveThumbNail(ThumbNailType.Custom.ToString(), CommonFunctions.GetScansFolder(), tmp_file, image, s.Width, s.Height);
         *  FileStream fs = new FileStream(Path.Combine(CommonFunctions.GetScansFolder(), r.Message), FileMode.Open, FileAccess.Read);
         *  byte[] b = new byte[fs.Length];
         *  fs.Read(b, 0, (int)fs.Length);
         *  fs.Dispose();
         *  try
         *  {
         *      File.Delete(Path.Combine(CommonFunctions.GetScansFolder(), tmp_file));
         *  }
         *  catch { }
         *  return b;
         * }
         */
        public static byte[] GenerateImgThumbNail(object _documentScanat, ThumbNailSizes s)
        {
            PropertyInfo pi       = _documentScanat.GetType().GetProperty("FILE_CONTENT");
            MemoryStream ms       = new MemoryStream((byte[])pi.GetValue(_documentScanat));
            Image        image    = Image.FromStream(ms);
            string       tmp_file = "tmp_" + DateTime.Now.ToString("ddMMyyyyHHmmss");
            response     r        = SaveThumbNail(ThumbNailType.Custom.ToString(), CommonFunctions.GetScansFolder(), tmp_file, image, s.Width, s.Height);
            FileStream   fs       = new FileStream(Path.Combine(CommonFunctions.GetScansFolder(), r.Message), FileMode.Open, FileAccess.Read);

            byte[] b = new byte[fs.Length];
            fs.Read(b, 0, (int)fs.Length);
            fs.Dispose();
            try
            {
                File.Delete(Path.Combine(CommonFunctions.GetScansFolder(), tmp_file));
            }
            catch { }
            return(b);
        }