/// <summary>
        /// 修改属性
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                FileBll         fileBll   = new FileBll();
                Model.FileModel fileModel = fileBll.GetModel(this.file.ID);

                if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name))
                {
                    MessageBoxEx.Show("该文件的信息异常!");
                    return;
                }

                FileVersionBll verBll = new FileVersionBll();

                var fileVer = new BLL.FileVersionBll().GetModel(this.fileLog.FileVerID);
                var content = verBll.GetContent(fileVer.ID);

                // 获取文件信息
                this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);;
                this.saveFileDialog1.ShowDialog();
                string fileSavePath = this.saveFileDialog1.FileName;

                if (string.IsNullOrEmpty(fileSavePath))
                {
                    return;
                }

                //文件存放路径
                string newPath = fileSavePath.EndsWith(fileModel.File_Ext) ? fileSavePath : fileSavePath + fileModel.File_Ext;
                FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time);
                MessageBoxEx.Show("保存成功!");
            }
            catch (Exception ee)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                MessageBoxEx.Show("存储失败!" + ee.Message);
            }
        }
        /// <summary>
        /// 版本历史记录单元格事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void skinDataGridView_history_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex >= 80)
            {
                try
                {
                    #region 文件下载和同步处理
                    int             fileID    = int.Parse(this.skinDataGridView_history.Rows[e.RowIndex].Cells[10].Value.ToString());
                    int             verID     = int.Parse(this.skinDataGridView_history.Rows[e.RowIndex].Cells[0].Value.ToString());
                    FileBll         fileBll   = new FileBll();
                    Model.FileModel fileModel = fileBll.GetModel(fileID);

                    if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name))
                    {
                        MessageBoxEx.Show("该文件的信息异常!");
                        return;
                    }

                    FileVersionBll verBll  = new FileVersionBll();
                    var            content = verBll.GetContent(verID);
                    var            fileVer = verBll.GetModel(verID);

                    //同步
                    if (e.ColumnIndex == 8)
                    {
                        if (string.IsNullOrEmpty(fileModel.ClientPath))
                        {
                            MessageBoxEx.Show("该文件的客户端路径不正确!");
                            return;
                        }

                        FileWinexploer.CreateFile(content, fileModel.ClientPath, fileVer.File_Modify_Time);
                        MessageBoxEx.Show("同步到客户端成功!");
                        return;
                    }

                    //另存为
                    if (e.ColumnIndex == 9)
                    {
                        //获取文件信息
                        this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);;
                        this.saveFileDialog1.ShowDialog();
                        string fileSavePath = this.saveFileDialog1.FileName;

                        if (string.IsNullOrEmpty(fileSavePath))
                        {
                            return;
                        }

                        //文件存放路径
                        string newPath = fileSavePath.EndsWith(fileModel.File_Ext)?fileSavePath: fileSavePath + fileModel.File_Ext;
                        FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show(ex.Message);
                }
            }
        }
示例#3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                Model.UserProjectModel curProject = null;
                Model.UserModel        user       = Bll.SystemBll.UserInfo;
                if (user == null || user.Projects == null || user.Projects.Count == 0)
                {
                    MessageBox.Show("账号信息不正确,请联系管理员处理!");
                    return;
                }

                foreach (var item in user.Projects)
                {
                    if (item.MonitoringSoftwareName == softwareName)
                    {
                        curProject = item;
                        break;
                    }
                }

                if (curProject == null)
                {
                    MessageBox.Show("工程信息绑定不正确,请联系管理员处理!");
                    return;
                    //curProject = user.Projects[0];
                }

                if (curProject == null || string.IsNullOrEmpty(curProject.MonitoringPath))
                {
                    MessageBox.Show("服务器配置路径不正确,请联系管理员处理!");
                    return;
                }

                //监控绑定路径
                string dirPath = curProject.MonitoringPath;
                if (!Directory.Exists(dirPath))
                {
                    MessageBox.Show("服务器配置路径不正确,请联系管理员处理!");
                    return;
                }

                //此处查询出所有文件内容
                DirectoryInfo  rootDirInfo = new DirectoryInfo(dirPath);
                FileWinexploer upload      = new FileWinexploer();

                //上传之前开启文件受影响检查
                user.CurProject = curProject;
                this.curProject = curProject;

                #region 20151104修改上传动画效果&初次上传大量文件卡死现象--删除
                //upload.CheckFolderUploadToDb(dirPath, user);
                //if (FileWinexploer.NeedAddOrMordifyFiles == null || FileWinexploer.NeedAddOrMordifyFiles.Count == 0)
                //{
                //    MessageBox.Show("没有可更新文件,不需要操作!");
                //    return;
                //}
                //else
                //{
                //    if (MessageBox.Show(
                //     string.Format("此次上传文件数量为:{0},是否继续上传!", FileWinexploer.NeedAddOrMordifyFiles.Count),
                //      "一键上传文件",
                //       MessageBoxButtons.OKCancel) == DialogResult.OK)
                //    {
                //        //检查通过开始异步上传
                //        FolderUploadHandler handler = new FolderUploadHandler(upload.FolderUploadToDb);
                //        handler.BeginInvoke(dirPath, user, IAsyncMenthod, null);

                //        ///异步日志
                //        ActionLog(string.Empty, ActionType.ALLUPLOAD);

                //        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                //        return;

                //        //动态上传进度
                //        FrmFileTransferNew frmTransfer = new FrmFileTransferNew(0);
                //        frmTransfer.Show();
                //    }
                //}
                #endregion

                #region 20151104修改上传动画效果&初次上传大量文件卡死现象--修改

                // 提示是否上传|取消|上传差异
                string        tip        = FileWinexploer.ConstructUploadTip();
                FrmMessageBox messageBox = new FrmMessageBox(tip, 0);
                var           result     = messageBox.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                // 替换检查界面[8.5wjh]
                FrmWait      frmCheckFile       = new FrmWait(dirPath, user, 0);
                DialogResult frmCheckFileResult = frmCheckFile.ShowDialog();
                if (frmCheckFileResult != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                if (FileWinexploer.NeedAddOrMordifyFiles == null || FileWinexploer.NeedAddOrMordifyFiles.Count == 0)
                {
                    MessageBox.Show("上传完成!");
                    return;
                }
                else
                {
                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        FileWinexploer.SetUploadCache();
                    }

                    // 0909 上传王君海修改
                    //FrmFileProgressBar frmTransfer = new FrmFileProgressBar(0);

                    //检查通过开始异步上传
                    FolderUploadHandler handler = new FolderUploadHandler(upload.FolderUploadToDb);
                    handler.BeginInvoke(dirPath, user, IAsyncMenthod, null);

                    ///异步日志
                    ActionLog(string.Empty, ActionType.ALLUPLOAD);

                    //frmTransfer.Activate();
                    //frmTransfer.Show();
                }
                #endregion

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }