コード例 #1
0
ファイル: Thumbnail.cs プロジェクト: yuexiaoyun/EF
        private void ThumbnailFile(string newfile, int width, int height)
        {
            this.width  = width;
            this.height = height;
            if (IsthumbnailImage)
            {
                this.file = newfile;
            }
            else
            {
                this._newfile = newfile;
            }

            if (!string.IsNullOrEmpty(file))
            {
                if (IsthumbnailImage)
                {
                    this._newfile = IOFiles.Combine(IOFiles.GetFolderName(file), this.thumbnailImage);
                    IOFiles.CreatedFolder(this._newfile);
                }
                Thread trd = new Thread(new ThreadStart(TimedProgress));
                trd.Start();

                //TimedProgress();
            }
        }
コード例 #2
0
ファイル: ExcelHelper.cs プロジェクト: yuexiaoyun/EF
        public static DataTable ReadFile(string excelPath, string sheetName = "sheet1")
        {
            var          dtGbPatient   = new DataTable();
            var          filepath      = IOFiles.GetFileMapPath(excelPath);
            const string strConn       = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='{0}';Extended Properties='Excel 8.0;HDR=YES;IMEX=1';";
            string       strConnection = string.Format(strConn, filepath);
            var          conn          = new OleDbConnection(strConnection);

            conn.Open();
            var oada = new OleDbDataAdapter("select * from [" + sheetName + "$]", strConnection);

            dtGbPatient.TableName = "gbPatientInfo";
            oada.Fill(dtGbPatient);//获得datatable
            conn.Close();
            return(dtGbPatient);
        }
コード例 #3
0
ファイル: SafeCheck.cs プロジェクト: yuexiaoyun/EF
 /// <summary>
 /// 文件验证
 /// </summary>
 /// <param name="Files">文件名</param>
 /// <param name="ext">扩展名</param>
 /// <returns></returns>
 private static bool IsStr(string Files, string ext)
 {
     try
     {
         string namex = ext;
         string ex    = (IOFiles.GetExtension(Files)).ToLower();
         foreach (string extname in namex.ToString().Split('|'))
         {
             if (ex == extname)
             {
                 return(true);
             }
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: Thumbnail.cs プロジェクト: yuexiaoyun/EF
        //根据原图片,缩微图大小等比例缩放 文件
        private void TimedProgress()
        {
            ImageCodecInfo icf = ImageHelper.GetImageCodecInfo(ImageFormat.Jpeg);

            Image  image, thumbnailImage;
            string thumbnailImageFilename;

            if (SafeCheck.IsJPGstr(file))
            {
                string extension;
                extension = IOFiles.GetExtension(file);
                try
                {
                    using (image = Image.FromFile(file))
                    {
                        Size imageSize = GetImageSize(image);

                        using (thumbnailImage = ImageHelper.GetThumbnailImage(image, imageSize.Width, imageSize.Height))
                        {
                            if (IsthumbnailImage)
                            {
                                thumbnailImageFilename = IOFiles.Combine(thumbnailPath, IOFiles.GetFileNameWithoutExtension(file) + extension);
                            }
                            else
                            {
                                thumbnailImageFilename = this._newfile;
                            }

                            ImageHelper.SaveImage(thumbnailImage, thumbnailImageFilename, icf);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string em = ex.Message;
                }
            }
        }