예제 #1
0
        /// <summary>
        /// 新建文件夹
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbNewForlder_Click(object sender, EventArgs e)
        {
            TDataInfoDTO dto = new TDataInfoDTO();

            dto.BaseInfoId     = _baseInfoId;
            dto.CreateTime     = DateTime.Now;
            dto.DataName       = "新建文件夹";
            dto.UploadPeople   = CommonData.LoginInfo.EmployeeName;
            dto.IsForlder      = true;
            dto.DownloadTimes  = 0;
            dto.LastModifyTime = DateTime.Now;
            dto.MetaDataId     = Guid.NewGuid().ToString();
            dto.ParentId       = _currentId;
            bool result = _client.TDataInfoAdd(dto);

            if (result)
            {
                CreateViewItem(dto, LvDataContent.Items.Count, true);
                //LvDataContent.Items[LvDataContent.Items.Count - 1].BeginEdit();
            }
        }
예제 #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string       filePath = e.Argument.ToString();
            TDataInfoDTO result   = new TDataInfoDTO();

            result.MetaDataId = Guid.NewGuid().ToString();
            result.DataName   = Path.GetFileName(filePath);
            // result.DataDescription = txtDescription.Text;
            byte[] total = IOHelper.GetStreamBuffer(filePath);
            result.DownloadTimes  = 0;
            result.LastModifyTime = DateTime.Now;
            result.CreateTime     = DateTime.Now;
            result.BaseInfoId     = _id;
            result.UploadPeople   = _uploadBy;
            result.FileSize       = total.Length.ToString();

            bool success = _client.TDataInfoAdd(result);

            if (success)
            {
                byte[] buffer  = new byte[4096000]; //4M
                int    percent = total.Length / buffer.Length;
                for (long index = 0; index < percent; index++)
                {
                    buffer = total.Skip((int)index * buffer.Length).Take(buffer.Length).ToArray();
                    bool upSuccess = _client.TDataInfoUploadFile(buffer, result.MetaDataId, (int)(index * buffer.Length / 40960000));
                    if (upSuccess == false)
                    {
                        e.Result = false;
                        return;
                    }
                    backgroundWorker1.ReportProgress((int)((index + 1) * buffer.Length * 100 / total.Length));
                    manualReset.WaitOne();
                }
                int left = total.Length % buffer.Length;
                if (left > 0)
                {
                    byte[] leftBuffer = total.Skip(percent * buffer.Length).Take(left).ToArray();
                    bool   upSuccess  = _client.TDataInfoUploadFile(leftBuffer, result.MetaDataId, total.Length / 40960000);
                    if (upSuccess == false)
                    {
                        e.Result = false;
                        return;
                    }
                    manualReset.WaitOne();
                    backgroundWorker1.ReportProgress(100);
                }
                e.Result = true;
            }
        }
예제 #3
0
 public void UploadFile(string filePath, string parentId, ImageList lstImage)
 {
     _saveHistory = filePath;
     try
     {
         TDataInfoDTO uploadDTO = new TDataInfoDTO();
         uploadDTO.MetaDataId     = Guid.NewGuid().ToString();
         uploadDTO.DataName       = Path.GetFileName(filePath);
         uploadDTO.DownloadTimes  = 0;
         uploadDTO.LastModifyTime = DateTime.Now;
         uploadDTO.CreateTime     = DateTime.Now;
         uploadDTO.BaseInfoId     = _baseId;
         uploadDTO.UploadPeople   = CommonData.LoginInfo.EmployeeName;
         FileInfo info = new FileInfo(filePath);
         uploadDTO.FileSize  = info.Length.ToString();
         uploadDTO.IsForlder = false;
         uploadDTO.ParentId  = parentId;
         bool success = _client.TDataInfoAdd(uploadDTO);
         if (success && !_bgwork.IsBusy)
         {
             this.ToolTipText = string.Format("文件名称:{0}\r\n文件大小:{1}M\r\n上传时间:{2}\r\n上传人:{3}\r\n修改时间:{4}\r\n下载次数:{5}\r\n文件描述:{6}", uploadDTO.DataName, CommomHelper.ParseMB(uploadDTO.FileSize), uploadDTO.CreateTime, uploadDTO.UploadPeople, uploadDTO.LastModifyTime, uploadDTO.DownloadTimes, uploadDTO.DataDescription);
             this.SubItems.Add(uploadDTO.DataName);
             this.SubItems.Add(CommomHelper.ParseMB(uploadDTO.FileSize) + "M");
             this.SubItems.Add(uploadDTO.LastModifyTime.Value.ToString());
             this.SubItems.Add(uploadDTO.UploadPeople);
             this.ImageIndex = CommomHelper.GetImageIndex(filePath, uploadDTO.MetaDataId, lstImage);
             ItemData        = uploadDTO;
             byte[] buffer = IOHelper.GetStreamBuffer(filePath);
             OpareteType = OpareteTypeEnum.Upload;
             ShowProgressBar();
             _bgwork.RunWorkerAsync(new object[] { buffer, uploadDTO.MetaDataId });
         }
     }
     catch (Exception)
     {
         throw;
     }
 }