public void FillOpt(ref Gfs.UpLoadFileOption opt) { opt.AlreadyOpt = Option; opt.DirectorySeparatorChar = DirectorySeparatorChar; opt.FileNameOpt = Filename; opt.IgnoreSubFolder = IgnoreSubFolder; opt.TrimStart = TrimStart; }
/// <summary> /// Upload File /// </summary> private void UploadFileStripButton_Click(object sender, EventArgs e) { var upfile = new OpenFileDialog(); if (upfile.ShowDialog() == DialogResult.OK) { var opt = new Gfs.UpLoadFileOption(); var frm = new FrmGfsOption(); frm.ShowDialog(); opt.AlreadyOpt = frm.Option; opt.DirectorySeparatorChar = frm.DirectorySeparatorChar; opt.FileNameOpt = frm.Filename; opt.IgnoreSubFolder = frm.IgnoreSubFolder; Gfs.UpLoadFile(upfile.FileName, opt, RuntimeMongoDbContext.GetCurrentDataBase()); RefreshGui(); } }
/// <summary> /// 上传文件夹 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpLoadFolderStripButton_Click(object sender, EventArgs e) { var upfolder = new FolderBrowserDialog(); if (upfolder.ShowDialog() == DialogResult.OK) { var opt = new Gfs.UpLoadFileOption(); var frm = new FrmGfsOption(); frm.ShowDialog(); opt.AlreadyOpt = frm.Option; opt.DirectorySeparatorChar = frm.DirectorySeparatorChar; opt.FileNameOpt = frm.Filename; opt.IgnoreSubFolder = frm.IgnoreSubFolder; var uploadDir = new DirectoryInfo(upfolder.SelectedPath); var count = 0; UploadFolder(uploadDir, ref count, opt); MyMessageBox.ShowMessage("Upload", "Upload Completed! Upload Files Count: " + count); RefreshGui(); } }
/// <summary> /// </summary> /// <param name="uploadDir"></param> /// <param name="fileCount"></param> /// <param name="opt"></param> /// <returns>是否继续执行后续的所有操作</returns> private bool UploadFolder(DirectoryInfo uploadDir, ref int fileCount, Gfs.UpLoadFileOption opt) { foreach (var file in uploadDir.GetFiles()) { var rtn = Gfs.UpLoadFile(file.FullName, opt, RuntimeMongoDbContext.GetCurrentDataBase()); switch (rtn) { case Gfs.UploadResult.Complete: fileCount++; break; case Gfs.UploadResult.Skip: if (opt.AlreadyOpt == Gfs.EnumGfsAlready.Stop) { //这个操作返回为False,停止包括父亲过程在内的所有操作 return(false); } break; case Gfs.UploadResult.Exception: return(MyMessageBox.ShowConfirm("Upload Exception", "Is Continue?")); } } if (!opt.IgnoreSubFolder) { foreach (var dir in uploadDir.GetDirectories()) { //递归文件夹操作,如果下层有任何停止的意愿,则立刻停止,并且使上层也立刻停止 var isContinue = UploadFolder(dir, ref fileCount, opt); if (!isContinue) { return(false); } } } return(true); }
/// <summary> /// 拖曳终止 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstData_DragDrop(object sender, DragEventArgs e) { Array UploadfileList = (Array)e.Data.GetData(DataFormats.FileDrop); if (!MyMessageBox.ShowConfirm("UploadFile", "是否上传" + UploadfileList.Length + "个文件")) { return; } var opt = new Gfs.UpLoadFileOption(); var frm = new FrmGfsOption(); frm.ShowDialog(); opt.AlreadyOpt = frm.Option; opt.DirectorySeparatorChar = frm.DirectorySeparatorChar; opt.FileNameOpt = frm.Filename; opt.IgnoreSubFolder = frm.IgnoreSubFolder; var count = 0; foreach (string UploadFilename in UploadfileList) { if (File.Exists(UploadFilename)) { Gfs.UpLoadFile(UploadFilename, opt, RuntimeMongoDbContext.GetCurrentDataBase()); count++; } else { if (Directory.Exists(UploadFilename)) { var uploadDir = new DirectoryInfo(UploadFilename); UploadFolder(uploadDir, ref count, opt); } } } RefreshGui(); MyMessageBox.ShowMessage("Upload", "Upload Completed! Upload Files Count: " + count); }
/// <summary> /// 获得数据对象方法的注入 /// </summary> private static void GetInject() { //新建文档的文档获得方法注入 CtlDocumentView._getDocument = () => { var frmInsertDoc = new frmCreateDocument(); UIAssistant.OpenModalForm(frmInsertDoc, false, true); return(frmInsertDoc.mBsonDocument); }; ctlBsonValue.GetDocument = () => { var frmInsertDoc = new frmCreateDocument(); UIAssistant.OpenModalForm(frmInsertDoc, false, true); return(frmInsertDoc.mBsonDocument); }; ctlBsonValue.GetArray = () => { var frmInsertArray = new frmArrayCreator(); UIAssistant.OpenModalForm(frmInsertArray, false, true); return(frmInsertArray.mBsonArray); }; ctlBsonValue.GetGeoPoint = () => { var frmGeo = new frmCreateGeo(); UIAssistant.OpenModalForm(frmGeo, false, true); return(frmGeo.mBsonArray); }; frmGeoNear.GetGeo = () => { var frmGeo = new frmCreateGeo(); UIAssistant.OpenModalForm(frmGeo, false, true); return(frmGeo.mBsonArray); }; FrmServerMonitor.FreshTimeChanged = (time) => { SystemManager.SystemConfig.RefreshStatusTimer = time; SystemManager.SystemConfig.SaveSystemConfig(); }; FrmServerMonitor.MonitorItemsChanged = (items) => { SystemManager.SystemConfig.MonitorItems = items; SystemManager.SystemConfig.SaveSystemConfig(); }; RuntimeMongoDbContext.GetPassword = (username) => { var Password = MyMessageBox.ShowPasswordInput("Please Input Password of " + username, "Password"); return(Password); }; CtlUserView.OpenAddNewUserForm = (isAdmin) => { UIAssistant.OpenModalForm(new FrmUser(isAdmin), true, true); }; CtlUserView.OpenChangePasswordForm = (isAdmin, name) => { UIAssistant.OpenModalForm(new FrmUser(isAdmin, name), true, true); }; CtlDocumentView.ElementOp = (isUpdate, selectedNode, isElement) => { var f = new FrmElement(isUpdate, selectedNode, isElement); f.ShowDialog(); }; CtlGfsView.GetUploadFileOption = () => { var opt = new Gfs.UpLoadFileOption(); var frm = new FrmGfsOption(); frm.ShowDialog(); opt.AlreadyOpt = frm.Option; opt.DirectorySeparatorChar = frm.DirectorySeparatorChar; opt.FileNameOpt = frm.Filename; opt.IgnoreSubFolder = frm.IgnoreSubFolder; return(opt); }; }