private void btnAddFile_Click(object sender, EventArgs e) { DocUtils.InitFTPTK(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = true; if (ofd.ShowDialog() == DialogResult.OK) { using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang up file lên server!")) { foreach (string filePath in ofd.FileNames) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { MisMatchImageModel errorImageModel; bool isAdd = true; if (!MisMatchImageBO.Instance.CheckExist("FileName", Path.GetFileName(filePath))) { errorImageModel = new MisMatchImageModel(); } else { errorImageModel = (MisMatchImageModel)MisMatchImageBO.Instance.FindByAttribute("FileName", Path.GetFileName(filePath))[0]; isAdd = false; } FileInfo fInfo = new FileInfo(filePath); string ftpFolderPath = "Modules\\KPHImage\\" + MisMatch.Code; errorImageModel.CreatedDate = TextUtils.GetSystemDate(); errorImageModel.CreatedBy = Global.LoginName; errorImageModel.FileName = Path.GetFileName(filePath); errorImageModel.Size = fInfo.Length; errorImageModel.FilePath = ftpFolderPath + "\\" + errorImageModel.FileName; errorImageModel.MisMatchID = MisMatch.ID; if (isAdd) { errorImageModel.ID = (int)pt.Insert(errorImageModel); } else { pt.Update(errorImageModel); } if (!DocUtils.CheckExits(ftpFolderPath)) { DocUtils.MakeDir(ftpFolderPath); } DocUtils.UploadFile(filePath, ftpFolderPath); pt.CommitTransaction(); } catch (Exception) { } finally { pt.CloseConnection(); } } loadGridImage(); } } }
protected MisMatchImageFacade(MisMatchImageModel model) : base(model) { }