Ejemplo n.º 1
0
        public string AddFileToWorkspace(FileModelDto fileModelDto)
        {
            var fileModel = mMapper.DtoToFileModel(fileModelDto);
            var createdId = mWorkspaceRepository.Create(fileModel);

            return(createdId);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 打开文件所在的文件夹
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dg_pageData.SelectedRows[0] as DataGridViewRow;
            FileModelDto    dto = row.DataBoundItem as FileModelDto;

            if (dto != null)
            {
                System.Diagnostics.Process.Start("explorer.exe", dto.DirectoryName);
            }
        }
        public async Task <IActionResult> AddFileToWorkspace(string id, [FromForm] FileModelDto fileModelDto)
        {
            fileModelDto.GroupId = id;

            fileModelDto.FileBytes = await fileModelDto.File.ToBytes();

            var createdId = mWorkspacesFacade.AddFileToWorkspace(fileModelDto);

            mAuditLogger.Debug(RetrieveUsername(), ActionEnum.UPLOAD, ControllerContext.ActionDescriptor.ActionName, HttpStatusCode.OK, createdId);
            return(CreatedAtRoute(new { id = createdId }, new { fileName = fileModelDto.FileName, id = createdId, groupId = fileModelDto.GroupId }));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 打开文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = this.dg_pageData.SelectedRows[0] as DataGridViewRow;
            FileModelDto    dto = row.DataBoundItem as FileModelDto;

            if (dto != null)
            {
                try
                {
                    System.Diagnostics.Process.Start(dto.FilePath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("暂不支持此文件格式", "提示");
                }
            }
        }
Ejemplo n.º 5
0
        public void UpdateWorkspaceFile(string workspaceId, string fileId, FileModelDto fileModelDto)
        {
            var fileModel = mMapper.DtoToFileModel(fileModelDto);

            mFileRepository.Update(fileId, fileModel);
        }
        public ActionResult <WorkspaceModelDto> UpdateFileFromWorkspace(string workspaceId, string fileId, [FromBody] FileModelDto fileModelDto)
        {
            if (fileId != fileModelDto.Id || workspaceId != fileModelDto.GroupId)
            {
                return(BadRequest());
            }
            ;

            mWorkspacesFacade.UpdateWorkspaceFile(workspaceId, fileId, fileModelDto);
            mAuditLogger.Debug(RetrieveUsername(), ActionEnum.UPDATE, ControllerContext.ActionDescriptor.ActionName, HttpStatusCode.OK, fileModelDto.FileName);
            return(NoContent());
        }
Ejemplo n.º 7
0
 public FileModel DtoToFileModel(FileModelDto dto)
 {
     return(mOurMapper.Map <FileModel>(dto));
 }
Ejemplo n.º 8
0
        public void PageData(string folderPath, QueryDto queryCondition)
        {
            string[]            supportSuffix = { ".txt", ".xml", ".cs" };
            List <FileModelDto> fmList        = new List <FileModelDto>();
            List <FileInfo>     fileList      = FolderUtil.FileHelper.GetAllFiles(folderPath);

            foreach (var fi in fileList)
            {
                //如果开启了内容搜索,则需要筛选文件的后缀
                if (queryCondition.OpenKey)
                {
                    FileModelDto fm = new FileModelDto();
                    fm.FileName      = fi.Name.ToLower();
                    fm.ShowName      = fi.Name;
                    fm.BizName       = fi.Directory.Name;
                    fm.DirectoryName = fi.DirectoryName;
                    fm.FilePath      = fi.FullName;
                    fm.Status        = (int)Model.TaskStatus.Watting;
                    fm.FileOn        = fi.CreationTime;
                    fm.FileSize      = System.Math.Ceiling(fi.Length / 1024.0) + " KB";
                    fm.Msg           = "等待中…";

                    string content = FolderUtil.FileHelper.ReadFile(fi.FullName);
                    if (content != null && content.Contains(queryCondition.ContentKey))
                    {
                        fmList.Add(fm);
                    }
                }
                else
                {
                    FileModelDto fm = new FileModelDto();
                    fm.FileName      = fi.Name.ToLower();
                    fm.ShowName      = fi.Name;
                    fm.BizName       = fi.Directory.Name;
                    fm.DirectoryName = fi.DirectoryName;
                    fm.FilePath      = fi.FullName;
                    fm.Status        = (int)Model.TaskStatus.Watting;
                    fm.FileOn        = fi.CreationTime;
                    fm.FileSize      = System.Math.Ceiling(fi.Length / 1024.0) + " KB";
                    fm.Msg           = "等待中…";

                    fmList.Add(fm);
                }
            }

            List <OrderByDto> orderbyItem = AddOrderbyCondition();
            //List<OrderByDto> orderbyItem = new List<OrderByDto>();
            DataCollection <FileModelDto> dc = FolderUtil.FileHelper.FileIntelligentSearch <FileModelDto, QueryDto>(fmList.AsQueryable <FileModelDto>(), queryCondition, orderbyItem.ToArray());

            this.dg_pageData.DataSource = dc.data as List <FileModelDto>;//pagelist

            pageDto.Page       = dc.Page;
            pageDto.PageSize   = dc.PageSize;
            pageDto.PageCount  = dc.PageCount;
            pageDto.TotalCount = dc.TotalCount;

            if (dc.data.Count > 0)
            {
                this.lb_page.Text = "第" + pageDto.Page + "页,共" + pageDto.PageCount + "页,记录总数为:" + pageDto.TotalCount;
            }
            else
            {
                this.lb_page.Text = "共有0条记录";
            }

            //按钮可用逻辑
            if (pageDto.PageCount == 0)
            {
                this.btn_home.Enabled     = false;
                this.btn_prePage.Enabled  = false;
                this.btn_nextPage.Enabled = false;
                this.btn_lastPage.Enabled = false;
            }
            else
            {
                if (pageDto.PageCount == pageDto.Page)
                {
                    if (pageDto.Page == 1)
                    {
                        this.btn_home.Enabled     = false;
                        this.btn_nextPage.Enabled = false;
                        this.btn_prePage.Enabled  = false;
                        this.btn_lastPage.Enabled = false;
                    }
                    else
                    {
                        this.btn_home.Enabled     = true;
                        this.btn_nextPage.Enabled = false;
                        this.btn_prePage.Enabled  = true;
                        this.btn_lastPage.Enabled = false;
                    }
                }
                else if (pageDto.PageCount > pageDto.Page)
                {
                    this.btn_nextPage.Enabled = true;
                    this.btn_lastPage.Enabled = true;
                    if (pageDto.Page == 1)
                    {
                        this.btn_prePage.Enabled = false;
                        this.btn_home.Enabled    = false;
                    }
                    else
                    {
                        this.btn_prePage.Enabled = true;
                        this.btn_home.Enabled    = true;
                    }
                }
                else
                {
                    this.btn_home.Enabled     = false;
                    this.btn_nextPage.Enabled = false;
                    this.btn_prePage.Enabled  = false;
                    this.btn_lastPage.Enabled = false;
                }
            }
        }