public void ChangeItem(object objDr)
        {
            DataRow            dr     = (DataRow)objDr;
            string             fileId = dr["fileId"].ToString();
            ItemUploadFile     item   = (ItemUploadFile)dr["item"];
            UploadFileDelegate ufd    = UploadFile;

            ufd.BeginInvoke(dr, this.Complete, dr);
            while (true)
            {
                if (dr != null && dr.RowState != DataRowState.Detached && dr.RowState != DataRowState.Deleted)
                {
                    long fileSize    = 0;
                    long currentSize = 0;
                    try
                    {
                        fileSize    = Convert.ToInt64(dr["FileSize"]);
                        currentSize = Convert.ToInt64(dr["UploadSize"]);
                    }
                    catch (Exception ex)
                    {
                        Thread.Sleep(50);
                        fileSize    = Convert.ToInt64(dr["FileSize"]);
                        currentSize = Convert.ToInt64(dr["UploadSize"]);
                    }

                    int value = (int)((currentSize * 100) / fileSize);
                    item.Invoke(new Action(() =>
                    {
                        item.value = value;
                        item.Invalidate();
                        //item.Invalidate();
                    }));
                    if (value >= 100)
                    {
                        this.sendMessage.Invoke(item.File);
                        RemoveItem.Invoke(item.File);
                        this.addFileMessage(item.File);
                        lock (dtMission)
                        {
                            dtMission.Rows.Remove(dr);
                        }
                        break;
                    }
                }
                else
                {
                    break;
                }
                Thread.Sleep(500);
            }
        }
        public void UploadFile(DataRow dr)
        {
            //DataRow dr = (DataRow)objDr;
            string         fileId   = dr["fileId"].ToString();
            long           fileSize = Convert.ToInt64(dr["FileSize"]);
            ItemUploadFile item     = (ItemUploadFile)dr["item"];
            //dr["FileSize"] = item.File.FileSize;
            Dictionary <string, string> dictParams = new Dictionary <string, string>();

            dictParams["FILENAME"] = item.File.SaveFileName;
            dictParams["FILEID"]   = item.File.FileId;
            string url = SysParams.FileServer + "tempFile" + ".file";

            lock (dr.Table)
            {
                dr["Status"] = 1;
            }
            int operation = Convert.ToInt16(dr["operation"]);

            switch (operation)
            {
            case (int)OperationType.Download:    //下载操作
                Common.DownLoad_OffLine(fileId, item.File.SaveFileName, item.File.ReceiveSaveFileName, item.File.ReceiveDir, SysParams.Limit_UpData, dr);
                sqlHelper.DeletedMission(item.File.FileId);
                if (!string.IsNullOrEmpty(SysParams.tmpDownLoadName))
                {
                    try
                    {
                        File.Move(item.File.ReceivePath + SysParams.tmpDownLoadName, item.File.ReceivePath);
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                }
                break;

            case (int)OperationType.UpLoad:    //上传操作
                Common.UpLoadFile_OffLine(item.File.FileName, url, SysParams.Limit_UpData, 0, dictParams, dr);
                break;
            }

            //完成后修改回正确文件名


            lock (dr.Table)
            {
                dr["Status"] = 2;
            }
            //this.threadList.Remove(fileId);
        }
 /// <summary>
 /// 添加上传任务方法
 /// </summary>
 /// <param name="file"></param>
 public void dtMissionAdd(FileClass file, ItemUploadFile item, string fromUser, string toUser)
 {
     lock (this.dtMission)
     {
         DataRow dr = dtMission.NewRow();
         dr["fileId"]    = item.File.FileId;
         dr["FileSize"]  = item.File.FileSize;
         dr["item"]      = item;
         dr["Operation"] = (int)file.Operation;
         dtMission.Rows.Add(dr);
         if (file.Operation == OperationType.Download && !file.IsContinue)
         {
             sqlHelper.AddMission(item.File.FileId, item.File.SaveFileName, item.File.ReceivePath,
                                  item.File.FileSize.ToString(), 0, (int)file.Operation, fromUser, toUser);
         }
     }
 }