Beispiel #1
0
        /// <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   = GetUploadFileOption();
            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);
        }
Beispiel #2
0
 /// <summary>
 ///     Open File
 /// </summary>
 private void OpenFileStripButton_Click(object sender, EventArgs e)
 {
     if (lstData.SelectedItems.Count == 1)
     {
         var strFileName = lstData.SelectedItems[0].Text;
         Gfs.OpenFile(strFileName, null);
     }
 }
Beispiel #3
0
        /// <summary>
        ///     Upload File
        /// </summary>
        private void UploadFileStripButton_Click(object sender, EventArgs e)
        {
            var upfile = new OpenFileDialog();

            if (upfile.ShowDialog() == DialogResult.OK)
            {
                var opt = GetUploadFileOption();
                Gfs.UpLoadFile(upfile.FileName, opt, RuntimeMongoDbContext.GetCurrentDataBase());
                RefreshGui();
            }
        }
Beispiel #4
0
 /// <summary>
 ///     Open File
 /// </summary>
 private void OpenFileStripButton_Click(object sender, EventArgs e)
 {
     if (lstData.SelectedItems.Count == 1)
     {
         var strFileName = lstData.SelectedItems[0].Text;
         Gfs.OpenFile(strFileName, RuntimeMongoDbContext.GetCurrentDataBase());
     }
     else
     {
         MessageBox.Show("请选择一个文件");
     }
 }
Beispiel #5
0
        /// <summary>
        ///     Delete File
        /// </summary>
        public void DeleteFileStripButton_Click(object sender, EventArgs e)
        {
            var strTitle   = GuiConfig.GetText("Delete Files", "DropData");
            var strMessage = GuiConfig.GetText("Are you sure to delete selected File(s)?", "DropDataConfirm");

            if (MyMessageBox.ShowConfirm(strTitle, strMessage))
            {
                foreach (ListViewItem item in lstData.SelectedItems)
                {
                    Gfs.DelFile(item.Text, RuntimeMongoDbContext.GetCurrentDataBase());
                }
                RefreshGui();
            }
        }
Beispiel #6
0
        /// <summary>
        ///     DownLoad File
        /// </summary>
        public void DownloadFileStripButton_Click(object sender, EventArgs e)
        {
            var downfile    = new SaveFileDialog();
            var strFileName = lstData.SelectedItems[0].Text;

            //For Winodws,Linux user DirectorySeparatorChar Replace with @"\"
            downfile.FileName =
                strFileName.Split(Path.DirectorySeparatorChar)[strFileName.Split(Path.DirectorySeparatorChar).Length - 1
                ];
            if (downfile.ShowDialog() == DialogResult.OK)
            {
                Gfs.DownloadFile(downfile.FileName, strFileName, RuntimeMongoDbContext.GetCurrentDataBase());
            }
            RefreshGui();
        }
Beispiel #7
0
        /// <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();
            }
        }
Beispiel #8
0
        /// <summary>
        ///     Delete File
        /// </summary>
        public void DeleteFileStripButton_Click(object sender, EventArgs e)
        {
            var strTitle   = "Delete Files";
            var strMessage = "Are you sure to delete selected File(s)?";

            if (!GuiConfig.IsUseDefaultLanguage)
            {
                strTitle   = GuiConfig.GetText(TextType.DropData);
                strMessage = GuiConfig.GetText(TextType.DropDataConfirm);
            }
            if (MyMessageBox.ShowConfirm(strTitle, strMessage))
            {
                foreach (ListViewItem item in lstData.SelectedItems)
                {
                    Gfs.DelFile(item.Text, null);
                }
                RefreshGui();
            }
        }
Beispiel #9
0
        public async Task <Gfs> Add(Gfs gfs)
        {
            var dbRecord = await _dbContext.Gfses.FirstOrDefaultAsync(x => x.DimensionId == gfs.DimensionId &&
                                                                      x.Location == gfs.Location &&
                                                                      x.WindyTimeId == gfs.WindyTimeId);

            if (dbRecord == null)
            {
                _dbContext.Gfses.Add(gfs);
            }
            else
            {
                dbRecord.DataString   = gfs.DataString;
                dbRecord.RegisterDate = gfs.RegisterDate;
                gfs.Id = dbRecord.Id;
            }

            await _dbContext.SaveChangesAsync();

            return(gfs);
        }
Beispiel #10
0
        /// <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);
        }
Beispiel #11
0
 /// <summary>
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OpenDocInEditorDocStripButton_Click(object sender, EventArgs e)
 {
     Gfs.SaveAndOpenStringAsFile(txtData.Text);
 }
Beispiel #12
0
 /// <summary>
 ///     Open
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditDocStripButton_Click(object sender, EventArgs e)
 {
     Gfs.SaveAndOpenStringAsFile(txtJavaScript.Text);
 }