private void btnDownLoad_Click(object sender, EventArgs e)
        {
            try
            {
                if (customDataGridView1.CurrentRow == null)
                {
                    return;
                }

                string filePath = customDataGridView1.CurrentRow.Cells["FilePath"].Value.ToString();

                if (GeneralFunction.IsNullOrEmpty(filePath))
                {
                    throw new Exception("无附件下载");
                }

                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    string[] tempArray = filePath.Split(',');

                    for (int i = 0; i < tempArray.Length; i++)
                    {
                        FileOperationService.File_DownLoad(new Guid(tempArray[i]),
                                                           folderBrowserDialog1.SelectedPath + "\\" + txtFileName.Text + "_" + i.ToString(),
                                                           GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            FM_FileList fileInfo = m_serverBasicInfo.GetFile((int)dataGridView1.CurrentRow.Cells["文件ID"].Value);

            FileOperationService.File_Look(fileInfo.FileUnique,
                                           GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
        }
Esempio n. 3
0
        private void LinkLable_Look_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                List <LinkLabel> lstllb = GetListLinkLabel(sender as Control);

                LinkLabel lbUpLoad   = lstllb[0];
                LinkLabel lbLook     = lstllb[1];
                LinkLabel lbDownLoad = lstllb[2];

                if (lbLook.Tag == null || lbLook.Tag.ToString().Length == 0)
                {
                    throw new Exception("无附件查看");
                }

                string[] tempArray = lbLook.Tag.ToString().Split(',');

                for (int i = 0; i < tempArray.Length; i++)
                {
                    FileOperationService.File_Look(new Guid(tempArray[i]),
                                                   GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
        private void lbDLLName_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string fileName = openFileDialog1.SafeFileName.Substring(0, openFileDialog1.SafeFileName.LastIndexOf("."));

                    if (!Regex.IsMatch(fileName, @"^" + txtCarModelNo.Text.Substring(0, 2) + @"\d{3}$"))
                    {
                        throw new Exception("文件名不匹配,无法上传");
                    }

                    Guid guid = Guid.NewGuid();
                    FileOperationService.File_UpLoad(guid, openFileDialog1.FileName,
                                                     GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));

                    MessageDialog.ShowPromptMessage("上传成功");

                    lbDLLName.Tag  = guid.ToString();
                    lbDLLName.Text = fileName;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 通用操作方式
        /// </summary>
        /// <param name="guid">唯一编码</param>
        void ShowOrDownLoad(string guid)
        {
            FM_FilePath lnqTemp = m_serverFileBasicInfo.GetFilePathInfo(new Guid(guid));
            操作方式        frm     = new 操作方式(ProcessType.发布);

            frm.ShowDialog();

            if (frm.OperatorFlag == CE_FileOperatorType.在线阅读)
            {
                FileOperationService.File_Look(new Guid(guid),
                                               GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
            }
            else if (frm.OperatorFlag == CE_FileOperatorType.载)
            {
                saveFileDialog1.Filter   = "All files (*.*)|*.*";
                saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-");

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName);

                    if (GetError())
                    {
                        MessageDialog.ShowPromptMessage("下载成功");
                    }
                }
            }
        }
Esempio n. 6
0
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid guid = Guid.NewGuid();
                    FileOperationService.File_UpLoad(guid, openFileDialog1.FileName,
                                                     GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>
                                                         (BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));

                    HR_Train_Courseware ware = new HR_Train_Courseware();

                    ware.CourseID       = _CourseInfo.ID;
                    ware.CoursewareName = txtCoursewareName.Text;
                    ware.FileUnique     = guid;
                    _ServiceBasicInfo.Operation_Courseware(ware);

                    MessageDialog.ShowPromptMessage("添加成功");
                    dgv_Courseware.DataSource = _ServiceBasicInfo.GetTable_Ware(_CourseInfo.ID);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 7
0
        void FileDownLoad(Button bt, Program_Report pr)
        {
            try
            {
                if (bt.Tag == null || bt.Tag.ToString().Length == 0)
                {
                    MessageDialog.ShowPromptMessage("无附件下载");
                    return;
                }

                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (pr == Program_Report.Program)
                    {
                        FileOperationService.File_DownLoad(new Guid(bt.Tag.ToString()),
                                                           folderBrowserDialog1.SelectedPath + "\\TCU程序(" + txtCarModelNo.Text.ToUpper() + cmbVersionType.Text + txtVersion.Text.Trim().ToLower() + ")",
                                                           GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));

                        _ServiceTCU.WriteTxtFile(txtBillNo.Text, folderBrowserDialog1.SelectedPath);
                    }
                    else
                    {
                        FileOperationService.File_DownLoad(new Guid(bt.Tag.ToString()),
                                                           folderBrowserDialog1.SelectedPath + "\\" + txtBillNo.Text + "_测试报告",
                                                           GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));
                    }

                    MessageDialog.ShowPromptMessage("下载成功");
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 8
0
        public void FileOpen()
        {
            FileSourceFactory    fileSourceFactory    = new FileSourceFactory();
            ImageSourceService   imageSourceManager   = new ImageSourceService(fileSourceFactory);
            FileOperationService fileOperationService = new FileOperationService(imageSourceManager);
            ApplicationLogic     applicationLogic     = new ApplicationLogic();

            FileOperationController fileOperationController = new FileOperationController(fileOperationService, applicationLogic);

            string[] files = new string[3] {
                "ValidFile", "InvalidFile", "ValidFile"
            };

            // IList<IFileSource> imageSourceControllers = null;
            fileOperationController.OpenFiles(files);

            // Assert.AreEqual(2, imageSourceControllers.Count);
            // Assert.AreEqual(files[0], imageSourceControllers[0].Filename);

            // imageSourceControllers.Clear();
            files = null;

            // Make sure it doesn't crash with these parameters
            fileOperationController.OpenFiles(files);

            // Assert.AreEqual(0, imageSourceControllers.Count);
            files = Array.Empty <string>();

            // Make sure it doesn't crash with these parameters
            fileOperationController.OpenFiles(files);

            // Assert.AreEqual(0, imageSourceControllers.Count);
        }
Esempio n. 9
0
        public void FileOperationService_InValidFilePath_ThrowsFileNotFoundException()
        {
            var service = new FileOperationService();

            // should throw exception
            var text = service.ReadAllText(@"C:\filethatdoesntexist.txt");
        }
Esempio n. 10
0
        private void btn_ReportFile_Up_Click(object sender, EventArgs e)
        {
            try
            {
                if (lbReportFile.Tag != null && lbReportFile.Tag.ToString().Length > 0)
                {
                    foreach (string fileItem in lbReportFile.Tag.ToString().Split(','))
                    {
                        UniversalControlLibrary.FileOperationService.File_Delete(new Guid(fileItem),
                                                                                 GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                    }
                }

                string strFilePath = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    foreach (string filePath in openFileDialog1.FileNames)
                    {
                        Guid guid = Guid.NewGuid();
                        FileOperationService.File_UpLoad(guid, filePath,
                                                         GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        strFilePath += guid.ToString() + ",";
                    }

                    lbReportFile.Tag = strFilePath.Substring(0, strFilePath.Length - 1);
                    m_serviceIsolation.UpdateFilePath(txtBillNo.Text, lbReportFile.Tag.ToString());
                    MessageDialog.ShowPromptMessage("上传成功");
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 11
0
        private void LinkLable_DownLoad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                List <LinkLabel> lstllb = GetListLinkLabel(sender as Control);

                LinkLabel lbUpLoad   = lstllb[0];
                LinkLabel lbLook     = lstllb[1];
                LinkLabel lbDownLoad = lstllb[2];

                if (lbLook.Tag == null || lbLook.Tag.ToString().Length == 0)
                {
                    throw new Exception("无附件下载");
                }

                if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                {
                    string[] tempArray = lbLook.Tag.ToString().Split(',');

                    for (int i = 0; i < tempArray.Length; i++)
                    {
                        FileOperationService.File_DownLoad(new Guid(tempArray[i]),
                                                           folderBrowserDialog1.SelectedPath + "\\" + txtBillNo.Text + "_" + i.ToString(),
                                                           GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                    }

                    MessageDialog.ShowPromptMessage("下载成功");
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 12
0
        public void FileOperationService_ValidFilePath_LoadsFile()
        {
            var service = new FileOperationService();

            var text = service.ReadAllText(TestHelpers.GetFullPath("samplefile.txt"));

            Assert.IsNotNull(text);
        }
Esempio n. 13
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            string path     = dataGridView1.CurrentRow.Cells["路径"].Value.ToString();
            string tempPath = path.Substring(path.LastIndexOf('/') + 1, path.Length - path.LastIndexOf('/') - 1);

            FileOperationService.File_Look(new Guid(tempPath),
                                           GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
        }
Esempio n. 14
0
        public void Constructor()
        {
            FileSourceFactory    fileSourceFactory    = new FileSourceFactory();
            ImageSourceService   imageSourceManager   = new ImageSourceService(fileSourceFactory);
            FileOperationService fileOperationService = new FileOperationService(imageSourceManager);
            ApplicationLogic     applicationLogic     = new ApplicationLogic();

            FileOperationController fileOperationController = new FileOperationController(fileOperationService, applicationLogic);
        }
        private void btnUpLoad_Click(object sender, EventArgs e)
        {
            try
            {
                if (GeneralFunction.IsNullOrEmpty(txtFileName.Text))
                {
                    throw new Exception("请填写【文件名】");
                }

                if (GeneralFunction.IsNullOrEmpty(cmbFileType.Text))
                {
                    throw new Exception("请选择【文件类型】");
                }

                if (dtpFileDate.Value.Date > ServerTime.Time.Date)
                {
                    throw new Exception("【文件日期】不能大于当前时间");
                }

                string strFilePath = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    foreach (string filePath in openFileDialog1.FileNames)
                    {
                        Guid guid = Guid.NewGuid();
                        FileOperationService.File_UpLoad(guid, filePath,
                                                         GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));
                        strFilePath += guid.ToString() + ",";
                    }

                    btnUpLoad.Tag = strFilePath.Substring(0, strFilePath.Length - 1);

                    Bus_Gauge_Files fileInfo = new Bus_Gauge_Files();

                    fileInfo.F_Id      = Guid.NewGuid().ToString();
                    fileInfo.FileDate  = dtpFileDate.Value;
                    fileInfo.FileName  = txtFileName.Text;
                    fileInfo.FilePath  = btnUpLoad.Tag.ToString();
                    fileInfo.FileType  = cmbFileType.Text;
                    fileInfo.GaugeCode = _GaugeCode;

                    _Service_Gauge.UpLoadFileInfo(fileInfo);
                    throw new Exception("上传成功");
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
            finally
            {
                DataGridViewShow();
            }
        }
Esempio n. 16
0
        private void dgv_Courseware_DoubleClick(object sender, EventArgs e)
        {
            if (dgv_Courseware.CurrentRow == null)
            {
                return;
            }

            FileOperationService.File_Look(new Guid(dgv_Courseware.CurrentRow.Cells["文件唯一编码"].Value.ToString()),
                                           GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>
                                               (BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
        }
Esempio n. 17
0
        public static async void TestCopy()
        {
            string path                = "H:\\New folder\\A";
            string targetPath          = "H:\\New folder\\B\\sadasd";
            IList <FileItemInfo> items = new List <FileItemInfo>();

            try
            {
                DirectoryInfo directory = new DirectoryInfo(path);
                var           dirs      = directory.EnumerateDirectories();
                foreach (var dir in dirs)
                {
                    items.Add(new FileItemInfo
                    {
                        FullName    = dir.FullName,
                        Name        = dir.Name,
                        IsDirectory = true
                    });
                }
                var files = directory.EnumerateFiles();
                foreach (var file in files)
                {
                    items.Add(new FileItemInfo
                    {
                        FullName    = file.FullName,
                        Name        = file.Name,
                        IsDirectory = false
                    });
                }
                FileOperationService service = new FileOperationService();
                var result = await service.CopyFileItem(items, targetPath, true);

                foreach (var r in result)
                {
                    Console.WriteLine($"{r.SourceName}\t{r.TargetName}\t{r.IsDirectory}");
                }
                Console.WriteLine("============================");
                result = await service.UndoCopy(result);

                foreach (var r in result)
                {
                    Console.WriteLine($"{r.SourceName}\t{r.TargetName}\t{r.IsDirectory}");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        private void customDataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (customDataGridView1.CurrentRow == null)
            {
                return;
            }

            string[] tempArray = customDataGridView1.CurrentRow.Cells["FilePath"].Value.ToString().Split(',');

            for (int i = 0; i < tempArray.Length; i++)
            {
                FileOperationService.File_Look(new Guid(tempArray[i]),
                                               GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));
            }
        }
        void FileLook(LinkLabel lbLink)
        {
            if (lbLink.Tag == null || lbLink.Tag.ToString().Length == 0)
            {
                MessageDialog.ShowPromptMessage("无附件查看");
                return;
            }

            string[] tempArray = lbLink.Tag.ToString().Split(',');

            for (int i = 0; i < tempArray.Length; i++)
            {
                FileOperationService.File_Look(new Guid(tempArray[i]),
                                               GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
            }
        }
Esempio n. 20
0
        void FileUpLoad(Button bt, Program_Report pr)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (bt.Tag != null && bt.Tag.ToString().Length > 0)
                    {
                        UniversalControlLibrary.FileOperationService.File_Delete(new Guid(bt.Tag.ToString()),
                                                                                 GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));
                    }

                    Guid guid = Guid.NewGuid();
                    FileOperationService.File_UpLoad(guid, openFileDialog1.FileName,
                                                     GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));

                    bt.Tag = guid.ToString();
                    _ServiceTCU.UpdateFilePath(txtBillNo.Text, guid, pr);
                    MessageDialog.ShowPromptMessage("上传成功");

                    if (bt.Name == btnDownload_TCUSoft.Name)
                    {
                        toolTip1.SetToolTip(btnUpload_TCUSoft, openFileDialog1.FileName);
                    }
                    else if (bt.Name == btnDownload_TestReport.Name)
                    {
                        toolTip1.SetToolTip(btnUpload_TestReport, openFileDialog1.FileName);
                    }
                }

                if (btnDownload_TCUSoft.Tag != null && btnDownload_TCUSoft.Tag.ToString().Length > 0)
                {
                    btnDownload_TCUSoft.Enabled = true;
                }

                if (btnDownload_TestReport.Tag != null && btnDownload_TestReport.Tag.ToString().Length > 0)
                {
                    btnDownload_TestReport.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
        public void DeleteFile(int fileId)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            var varData = from a in ctx.FM_FileList
                          where a.FileID == fileId
                          select a;

            if (varData.Count() != 1)
            {
                throw new Exception("数据不唯一");
            }

            FileOperationService.File_Delete(varData.Single().FileUnique, CE_CommunicationMode.FTP);

            ctx.FM_FileList.DeleteAllOnSubmit(varData);
            ctx.SubmitChanges();
        }
Esempio n. 22
0
        private void LinkLable_UpLoad_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                List <LinkLabel> lstllb = GetListLinkLabel(sender as Control);

                LinkLabel lbUpLoad   = lstllb[0];
                LinkLabel lbLook     = lstllb[1];
                LinkLabel lbDownLoad = lstllb[2];

                string strFilePath = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (lbLook.Tag != null && lbLook.Tag.ToString().Length > 0)
                    {
                        foreach (string fileItem in lbLook.Tag.ToString().Split(','))
                        {
                            UniversalControlLibrary.FileOperationService.File_Delete(new Guid(fileItem),
                                                                                     GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        }
                    }

                    foreach (string filePath in openFileDialog1.FileNames)
                    {
                        Guid guid = Guid.NewGuid();
                        FileOperationService.File_UpLoad(guid, filePath,
                                                         GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        strFilePath += guid.ToString() + ",";
                    }

                    lbLook.Tag = strFilePath.Substring(0, strFilePath.Length - 1);
                    _Service_EightDReport.UpdateFilePath(txtBillNo.Text, lbLook.Tag.ToString(), lbLook.Name.Contains("D1") ? "D1" : "D5");
                    MessageDialog.ShowPromptMessage("上传成功");
                    lbDownLoad.Enabled = true;
                    lbLook.Enabled     = true;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 通用操作方式
        /// </summary>
        /// <param name="guid">唯一编码</param>
        void ShowOrDownLoad(string guid)
        {
            try
            {
                FM_FilePath lnqTemp = m_serverFileBasic.GetFilePathInfo(new Guid(guid));

                操作方式 frm = new 操作方式(ProcessType.发布);
                frm.ShowDialog();

                if (frm.OperatorFlag == CE_FileOperatorType.在线阅读)
                {
                    FileOperationService.File_Look(new Guid(guid),
                                                   GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                }
                else if (frm.OperatorFlag == CE_FileOperatorType.载)
                {
                    saveFileDialog1.Filter   = "All files (*.*)|*.*";
                    saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-");

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        BackgroundWorker worker = BackgroundWorkerTools.GetWorker("下载文件");
                        worker.RunWorkerAsync();

                        m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName);

                        worker.CancelAsync();

                        if (GetError())
                        {
                            MessageDialog.ShowPromptMessage("下载成功");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return;
            }
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            if ((args?.Length ?? 0) == 0 ||
                args.FirstOrDefault(x => x.Equals(CommandArgs.PathCommand, StringComparison.OrdinalIgnoreCase)) == null ||
                (
                    args.FirstOrDefault(x => x.Equals(CommandArgs.OutputDirectoryCommand, StringComparison.OrdinalIgnoreCase)) == null &&
                    args.FirstOrDefault(x => x.Equals(CommandArgs.MergedFileFullNameCommand, StringComparison.OrdinalIgnoreCase)) == null
                )
                )
            {
                Console.WriteLine($"RemoveHtmlTags.exe -p . -px *.* -i 0 -m aaa.txt");
                Console.WriteLine($"{CommandArgs.PathCommand} is required. the files in the path to process.");
                Console.WriteLine($"{CommandArgs.PatternFilterCommand} is required. the filter to pick up the files. default is *.* ");
                Console.WriteLine($"{CommandArgs.BeginIndexCommand} process the files index that bigger than the value. it can be null or missed, if it is null or missed, the filter will be inactive.");
                Console.WriteLine($"{CommandArgs.OutputDirectoryCommand} the folder to Save Each processed file.");
                Console.WriteLine($"{CommandArgs.MergedFileFullNameCommand} the merged file that cotained all the processed files.");

                Console.WriteLine($"{CommandArgs.OutputDirectoryCommand} and {CommandArgs.MergedFileFullNameCommand} cannot be empty at same time.");
                return;
            }

            cmdArgs     = new ReadCommandArgsService().ReadFromCommandArgs(args);
            AppSettings = new ReadAppConfigurationService().ReadAppConfig();

            var fileService = new FileOperationService();
            var files       = fileService.GetFilesToProcess(cmdArgs);

            try
            {
                fileService.WriteOutputFile(files, cmdArgs, AppSettings);
                Console.WriteLine($"The listed files are processed!");
                Console.WriteLine($"{string.Join(";", files.Select(x => Path.GetFileName(x.FullFileName)))}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
            }
        }
        private void lbUpLoadFile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LinkLabel lbLink = (LinkLabel)sender;

            try
            {
                string strFilePath = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (lbLink.Tag != null && lbLink.ToString().Length > 0)
                    {
                        foreach (string fileItem in lbLink.Tag.ToString().Split(','))
                        {
                            UniversalControlLibrary.FileOperationService.File_Delete(new Guid(fileItem),
                                                                                     GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        }
                    }

                    foreach (string filePath in openFileDialog1.FileNames)
                    {
                        Guid guid = Guid.NewGuid();
                        FileOperationService.File_UpLoad(guid, filePath,
                                                         GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        strFilePath += guid.ToString() + ",";
                    }

                    lbLink.Tag         = strFilePath.Substring(0, strFilePath.Length - 1);
                    lbLookFile.Visible = true;
                    m_serverMkPlan.UpdateFilePath(txtDJH.Text, lbLink.Tag.ToString());
                    MessageDialog.ShowPromptMessage("上传成功");
                    lbLink.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 26
0
        private void btn_ReportFile_Down_Click(object sender, EventArgs e)
        {
            if (lbReportFile.Tag == null || lbReportFile.Tag.ToString().Length == 0)
            {
                MessageDialog.ShowPromptMessage("无附件下载");
                return;
            }

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string[] tempArray = lbReportFile.Tag.ToString().Split(',');

                for (int i = 0; i < tempArray.Length; i++)
                {
                    FileOperationService.File_DownLoad(new Guid(tempArray[i]),
                                                       folderBrowserDialog1.SelectedPath + "\\" + txtBillNo.Text + "_" + i.ToString(),
                                                       GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                }

                MessageDialog.ShowPromptMessage("下载成功");
            }
        }
        void FileUp(LinkLabel lbLink)
        {
            try
            {
                string strFilePath = "";

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (lbLink.Tag != null && lbLink.ToString().Length > 0)
                    {
                        foreach (string fileItem in lbLink.Tag.ToString().Split(','))
                        {
                            UniversalControlLibrary.FileOperationService.File_Delete(new Guid(fileItem),
                                                                                     GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        }
                    }

                    foreach (string filePath in openFileDialog1.FileNames)
                    {
                        Guid guid = Guid.NewGuid();
                        FileOperationService.File_UpLoad(guid, filePath,
                                                         GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                        strFilePath += guid.ToString() + ",";
                    }

                    lbLink.Tag = strFilePath.Substring(0, strFilePath.Length - 1);
                    m_mainService.UpdateFilePath(txtBillNo.Text, lbLink.Tag.ToString(),
                                                 lbLink.Name.Contains(SelfSimpleEnum_CreativeePersentation.Before.ToString()) ?
                                                 SelfSimpleEnum_CreativeePersentation.Before : SelfSimpleEnum_CreativeePersentation.After);
                    MessageDialog.ShowPromptMessage("上传成功");
                    lbLink.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowPromptMessage(ex.Message);
            }
        }
Esempio n. 28
0
        public void CloseAllFiles()
        {
            FileSourceFactory    fileSourceFactory    = new FileSourceFactory();
            ImageSourceService   imageSourceManager   = new ImageSourceService(fileSourceFactory);
            FileOperationService fileOperationService = new FileOperationService(imageSourceManager);
            ApplicationLogic     applicationLogic     = new ApplicationLogic();

            FileOperationController fileOperationController = new FileOperationController(fileOperationService, applicationLogic);

            string[] files = new string[1] {
                "ValidFile"
            };
            List <IFileSource> imageSourceControllers = new List <IFileSource>();

            // bool fileClosed = false;

            ////fileOperationController.OpenFile += (sender, eventArgs) => { imageSourceControllers.AddRange(eventArgs.ImageSourceControllers); };
            ////fileOperationController.CloseAllFiles += (sender, eventArgs) => { fileClosed = true; };

            fileOperationController.OpenFiles(files);
            ////fileOperationController.CloseFiles();

            // Assert.IsTrue(fileClosed);
        }
Esempio n. 29
0
 public FileOperationController(FileOperationService fileOperationService, IApplicationLogic applicationLogic)
 {
     this.fileOperationService = fileOperationService;
     this.applicationLogic     = applicationLogic;
 }
        /// <summary>
        /// 通用操作方式
        /// </summary>
        /// <param name="guid">唯一编码</param>
        void ShowOrDownLoad(string guid)
        {
            try
            {
                FM_FilePath lnqTemp = m_serverFileBasicInfo.GetFilePathInfo(new Guid(guid));

                操作方式 frm = new 操作方式(ProcessType.审查);
                frm.ShowDialog();

                if (frm.OperatorFlag == CE_FileOperatorType.在线阅读)
                {
                    FileOperationService.File_Look(new Guid(guid),
                                                   GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式]));
                }
                else if (frm.OperatorFlag == CE_FileOperatorType.载)
                {
                    saveFileDialog1.Filter   = "All files (*.*)|*.*";
                    saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-");

                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        BackgroundWorker worker = BackgroundWorkerTools.GetWorker("下载文件");
                        worker.RunWorkerAsync();

                        m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName);

                        worker.CancelAsync();

                        if (GetError())
                        {
                            MessageDialog.ShowPromptMessage("下载成功");
                        }
                    }
                }
                else if (frm.OperatorFlag == CE_FileOperatorType.在线编辑)
                {
                    string filePath = "C:\\temp" + lnqTemp.FileType;

                    m_serverFTP.Download(lnqTemp.FilePath, filePath);
                    System.Diagnostics.Process myProcess = new System.Diagnostics.Process();

                    //设置启动进程的初始目录 
                    myProcess.StartInfo.WorkingDirectory = Application.StartupPath;
                    //设置启动进程的应用程序或文档名 
                    myProcess.StartInfo.FileName = filePath;
                    //设置启动进程的参数 
                    myProcess.StartInfo.Arguments = "";

                    myProcess.Start();
                    myProcess.WaitForExit();

                    bool   flag             = false;
                    Guid   guidTemp         = new Guid();
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(filePath))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    if (btnAdd.Visible)
                    {
                        ConditionUpdateFile(llbProposerDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        llbProposerUpLoad.Tag    = guidTemp;
                        llbProposerDownLoad.Tag  = guidTemp;
                        llbProposerDownLoad.Text = BasicInfo.LoginName + "的文件";
                    }
                    else if (btnAudit.Visible)
                    {
                        ConditionUpdateFile(llbAuditorDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        llbAuditorUpLoad.Tag    = guidTemp;
                        llbAuditorDownLoad.Tag  = guidTemp;
                        llbAuditorDownLoad.Text = BasicInfo.LoginName + "的文件";
                    }
                    else if (btnPointAffirm.Visible)
                    {
                        ConditionUpdateFile(llbPointDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        m_serverReviewProcess.PointUpLoadFile(guidTemp, m_strSDBNo);

                        dataGridView1.DataSource = m_serverReviewProcess.GetListInfoTable(txtSDBNo.Text);
                        PositioningRecord(BasicInfo.LoginID);
                    }
                    else if (btnJudge.Visible)
                    {
                        ConditionUpdateFile(llbJudgeDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改);

                        flag = true;
                        llbJudgeUpLoad.Tag    = guidTemp;
                        llbJudgeDownLoad.Tag  = guidTemp;
                        llbJudgeDownLoad.Text = BasicInfo.LoginName + "的文件";
                    }

                    if (flag)
                    {
                        CursorControl.SetWaitCursor(this);
                        m_serverFileBasicInfo.FileUpLoad(filePath, strFtpServerPath, guidTemp.ToString(), lnqTemp.FileType);
                        this.Cursor = System.Windows.Forms.Cursors.Arrow;
                    }

                    File.Delete(filePath);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return;
            }
        }