using Core.Mes.Client.Comm; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public class QcmFile { // 123 IShellView public static string FlileUpload(string sFileName) { List list = new List(); string[] slist = new string[100]; FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Filter = "图片文件(*.jpg);(*.gif);(*.png);(*.bmp)|*.jpg;*.gif;*.png;*.bmp"; file.Multiselect = false; string path = ""; //file.RES if (file.ShowDialog() == DialogResult.OK) { bean = new FileBean(); string fileType = file.FileName.Split('.')[file.FileName.Split('.').Length - 1]; string fileName = DateTime.Now.ToString("yyyyMMddHHmmss.") + fileType; bean.setFileName(fileName); bean.setPathName(sFileName); bean.setFile(FileHelper.FileToArray(file.FileName)); list.Add(bean); path = sFileName + "/" + fileName; bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { MessageUtil.ShowTips("上传成功!"); } else { throw new MESException("服务端处理失败!"); } return path; } else { return ""; } } public static Bitmap FileDownLoad(string path) { if (path == "") return null; try { List bean = FileHelper.Download(path); if (bean.Count == 0) return null; return FileHelper.BytesToBitmap(bean[0].getFile()); } catch (Exception ex) { return null; } } } }