Exemplo n.º 1
0
        /// <summary>
        /// 文件操作日志
        /// </summary>
        /// <param name="logType"></param>
        /// <param name="fileModel"></param>
        public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, ActionType logType)
        {
            if (fileVerModel == null && fileModel == null)
            {
                return;
            }
            string remark = string.Empty;

            if (logType == ActionType.RENAME)
            {
                remark    = string.Format("文件:{0}重命名为:", fileModel.File_Name);
                fileModel = new BLL.FileBll().GetModel(fileModel.ID);
                remark    = remark + fileModel.File_Name;
            }

            if (fileModel == null && fileVerModel != null)
            {
                fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id);
            }

            if (fileModel != null && fileVerModel == null)
            {
                FileBll fileBll = new FileBll();
                fileVerModel = fileBll.GetFileLastVer(fileModel.ID);
            }

            ActionLogAsyn(fileVerModel, fileModel, remark, string.Empty, logType);
        }
 public async Task <IHttpActionResult> Process(string pPath, string pType)
 {
     using (var bll = new FileBll())
     {
         return(Ok(await bll.Process(pPath, pType)));
     }
 }
Exemplo n.º 3
0
        public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, string actionCode, ActionType logType)
        {
            if (fileVerModel == null && fileModel == null)
            {
                return;
            }
            string remark = string.Empty;

            Model.UserModel UserInfo = SystemBll.UserInfo;

            if (logType == ActionType.RENAME)
            {
                remark    = string.Format("{0}({1})重命名文件:{2}为==>:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name);
                fileModel = new BLL.FileBll().GetModel(fileModel.ID);
                remark    = remark + fileModel.File_Name;
            }

            if (logType == ActionType.ONEDELFILE)
            {
                remark = string.Format("{0}({1})删除文件:{2}:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name);
            }

            if (fileModel == null && fileVerModel != null)
            {
                fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id);
            }

            if (fileModel != null && fileVerModel == null)
            {
                FileBll fileBll = new FileBll();
                fileVerModel = fileBll.GetFileLastVer(fileModel.ID);
            }

            ActionLogAsyn(fileVerModel, fileModel, remark, actionCode, logType);
        }
Exemplo n.º 4
0
 public ProjectController(ProjectBll projectBll, FileBll fileBll, IssueBll issueBll, UserBll userBll, LinkBll linkBll, ScheduleBll scheduleBll, UserModule.Bll.UserBll userModuleUserBll, LogBll logBll)
 {
     _projectBll        = projectBll;
     _fileBll           = fileBll;
     _issueBll          = issueBll;
     _userBll           = userBll;
     _linkBll           = linkBll;
     _scheduleBll       = scheduleBll;
     _userModuleUserBll = userModuleUserBll;
     _logBll            = logBll;
 }
Exemplo n.º 5
0
 private async void btnRun_Click(object sender, EventArgs e)
 {
     using (var bll = new FileBll())
     {
         if (await bll.Process(txtPath.Text, selectedType))
         {
             MessageBox.Show("Arquivo processado com sucesso!", "SUCESSO!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("Algo não funcionou no processamento do arquivo", "OPS", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 递归检查文件夹和文件
        /// </summary>
        /// <param name="dirInfo"></param>
        /// <param name="parentId"></param>
        /// <param name="user"></param>
        private void CheckFolderDownloadAllFromDb_OtherUser(DirectoryInfo dirInfo, int parentId, string userName, int projectId)
        {
            //开始从文件夹获取子文件夹和文件列表
            ForderBll forderBll = new ForderBll();
            FileBll   fileBll   = new FileBll();
            var       subFiles  = forderBll.GetSubFiles(parentId, projectId, string.Empty);
            var       files     = subFiles;

            //文件下载
            foreach (var item in files)
            {
                Application.DoEvents();

                var verModel = fileBll.GetFileLastVer(item.ID);
                if (verModel == null || verModel.Ver <= 0)
                {
                    continue;
                }
                string   fileClientPath = string.Format("{0}\\{1}", dirInfo.FullName, item.File_Name);
                FileInfo clientFileInfo = new FileInfo(fileClientPath);
                item.ActionNum = 1;
                AddFileToCache(fileClientPath, item);
                AddNeedAllDownloadFilesToCache(fileClientPath, item);
            }

            var subForders = forderBll.GetSubForders(parentId, projectId);

            if (subForders != null && subForders.Count > 0)
            {
                foreach (var item in subForders)
                {
                    Application.DoEvents();

                    string forderPath = string.Format("{0}\\{1}", dirInfo.FullName, item.Title);

                    //文件夹不存在,全部新增
                    List <Model.FileModel> fileLists = GetAllServerFiles_OtherUser(item);
                    foreach (var subFileItem in fileLists)
                    {
                        AddFileToCache(subFileItem.ClientPath, subFileItem);
                        AddNeedAllUploadFilesToCache(subFileItem.ClientPath, subFileItem);
                    }
                    DirectoryInfo dirItemInfo = new DirectoryInfo(forderPath);
                    //判断文件夹操作
                    CheckFolderDownloadAllFromDb_OtherUser(dirItemInfo, item.ID, userName, projectId);
                }
            }
        }
Exemplo n.º 7
0
        /// <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);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 递归检查文件夹和文件
        /// </summary>
        /// <param name="dirInfo"></param>
        /// <param name="parentId"></param>
        /// <param name="user"></param>
        private void CheckFolderDownloadAllFromDb(DirectoryInfo dirInfo, int parentId, string userName, int projectId)
        {
            //开始从文件夹获取子文件夹和文件列表
            ForderBll forderBll = new ForderBll();
            FileBll   fileBll   = new FileBll();
            var       subFiles  = forderBll.GetSubFiles(parentId, projectId, string.Empty);
            var       files     = subFiles;

            //文件下载
            foreach (var item in files)
            {
                Application.DoEvents();

                var verModel = fileBll.GetFileLastVer(item.ID);
                if (verModel == null || verModel.Ver <= 0)
                {
                    continue;
                }
                string   fileClientPath = string.Format("{0}\\{1}", dirInfo.FullName, item.File_Name);
                FileInfo clientFileInfo = new FileInfo(fileClientPath);

                if (clientFileInfo.Exists)
                {
                    if (clientFileInfo.LastAccessTime.Ticks == verModel.File_Modify_Time)
                    {
                        continue;
                    }
                }

                //if (clientFileInfo.Exists && clientFileInfo.LastAccessTime.Ticks == item.File_Modify_Time)
                //{
                //    continue;
                //}

                if (clientFileInfo.Exists)
                {
                    item.ActionNum = 2;
                    if (verModel.File_Modify_Time == clientFileInfo.LastWriteTime.Ticks)
                    {
                        continue;
                    }

                    AddFileToCache(fileClientPath, item);
                    //服务器文件最新
                    if (verModel.File_Modify_Time > clientFileInfo.LastWriteTime.Ticks)
                    {
                        AddNeedAllDownloadFilesToCache(fileClientPath, item);
                    }
                }
                else
                {
                    item.ActionNum = 1;
                    AddFileToCache(fileClientPath, item);
                    AddNeedAllDownloadFilesToCache(fileClientPath, item);
                }
            }

            var subForders = forderBll.GetSubForders(parentId, projectId);

            if (subForders != null && subForders.Count > 0)
            {
                foreach (var item in subForders)
                {
                    Application.DoEvents();

                    string forderPath = string.Format("{0}\\{1}", dirInfo.FullName, item.Title);

                    if (!Directory.Exists(forderPath))
                    {
                        //文件夹不存在,全部新增
                        List <Model.FileModel> fileLists = GetAllServerFiles(item);
                        foreach (var subFileItem in fileLists)
                        {
                            AddFileToCache(subFileItem.ClientPath, subFileItem);
                            AddNeedAllUploadFilesToCache(subFileItem.ClientPath, subFileItem);
                        }

                        //Directory.CreateDirectory(forderPath);
                    }
                    DirectoryInfo dirItemInfo = new DirectoryInfo(forderPath);
                    //判断文件夹操作
                    CheckFolderDownloadAllFromDb(dirItemInfo, item.ID, userName, projectId);
                }
            }
        }