Example #1
0
        /// <summary>
        /// 获取更新信息
        /// </summary>
        /// <returns></returns>
        public static FileUpdateInfo GetUpdateInfo(SeatManageSubsystem system)
        {
            IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService();
            bool isError = false;

            try
            {
                return(seatService.GetUpdateInfo(system));
            }
            catch (Exception ex)
            {
                isError = true;
                WriteLog.Write(string.Format("更新出错,获取更新信息失败:{0}", ex.Message));
                throw ex;
            }
            finally
            {
                ICommunicationObject ICommObjectService = seatService as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
        /// <summary>
        /// 文件上传断点续传
        /// </summary>
        /// <param name="fileName">文件名称</param>
        /// <param name="fileByte">文件流</param>
        /// <param name="Length">文件大小</param>
        /// <param name="Offset">偏移量</param>
        /// <returns></returns>
        public static bool FileDelete(string file, SeatManageSubsystem system)
        {
            IFileTransportService fileTransport = WcfAccessProxy.ServiceProxy.CreateChannelFileTransportService();
            bool isError = false;

            try
            {
                return(fileTransport.DeleteFile(file, system));
            }
            catch (Exception ex)
            {
                isError = true;
                WriteLog.Write(string.Format("文件删除出错,异常信息:{0}", ex.Message));
                return(false);
            }
            finally
            {
                ICommunicationObject ICommObjectService = fileTransport as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
        /// <summary>
        /// 获取文件片段信息
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static FileSliceInfo GetFileInfo(string fileName, SeatManageSubsystem system)
        {
            IFileTransportService fileTransport = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateChannelFileTransportService();
            bool isError = false;

            try
            {
                return(fileTransport.GetFileInfo(fileName, system));
            }
            catch (Exception ex)
            {
                isError = true;
                WriteLog.Write(string.Format("获取文件片段信息失败,异常信息:{0}", ex.Message));
                throw ex;
            }
            finally
            {
                ICommunicationObject ICommObjectService = fileTransport as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
Example #4
0
        public static List <FileSimpleInfo> GetFilesInfo(List <string> filesName, SeatManageSubsystem system)
        {
            IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService();
            bool isError = false;

            try
            {
                return(seatService.GetFilesInfo(filesName, system));
            }
            catch (Exception ex)
            {
                isError = true;
                WriteLog.Write(string.Format("更新出错,获取文件信息失败:{0}", ex.Message));
                return(new List <FileSimpleInfo>());
            }
            finally
            {
                ICommunicationObject ICommObjectService = seatService as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
Example #5
0
 /// <summary>
 /// 获取文件片段信息
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="system"></param>
 /// <returns></returns>
 public FileSliceInfo GetFileSliceInfo(string fileName, SeatManageSubsystem system)
 {
     try
     {
         //fileName = fileName.Substring(fileName.IndexOf("\\"));
         string        filepath = uploadFolder + string.Format(@"{0}\", system.ToString()) + fileName;
         FileSliceInfo file     = new FileSliceInfo();
         file.Name   = fileName;
         file.Length = 0;
         file.Offset = 0;
         file.Data   = null;
         if (System.IO.File.Exists(filepath + ".tz"))
         {
             System.IO.FileInfo fi = new System.IO.FileInfo(filepath + ".tz");
             file.Length = fi.Length;
             file.Offset = fi.Length;//返回追加数据后的文件位置
             fi          = null;
             return(file);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #6
0
        /// <summary>
        /// 获取包含Md5的信息
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static FileSliceInfo_Md5 GetFilesSlice_Md5Info(string fileName, SeatManageSubsystem system)
        {
            IFileTransportService fileTransport = WcfAccessProxy.ServiceProxy.CreateChannelFileTransportService();

            try
            {
                return(fileTransport.GetFilesSlice_Md5Info(fileName, system));
            }
            catch (Exception ex)
            {
                WriteLog.Write(string.Format("获取包含Md5的文件片段信息失败,异常信息:{0}", ex.Message));
                throw ex;
            }
            finally
            {
                ICommunicationObject ICommObjectService = fileTransport as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
Example #7
0
 /// <summary>
 /// 文件下载,可以进行断点续传
 /// </summary>
 /// <param name="fileName">需要下载的文件名称</param>
 /// <param name="Offset">需要下载的文件起始位置</param>
 /// <returns></returns>
 public byte[] FileDownLoad(string fileName, long Offset, SeatManageSubsystem system)
 {
     try
     {
         FileTransport filetransport = new FileTransport();
         return(filetransport.FileDownLoad(fileName, Offset, system));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #8
0
 /// <summary>
 /// 获取文件片段信息
 /// </summary>
 /// <param name="filesName"></param>
 /// <param name="system"></param>
 /// <returns></returns>
 public FileSliceInfo GetFilesSliceInfo(string filesName, SeatManageSubsystem system)
 {
     try
     {
         FileTransport filetransport = new FileTransport();
         return(filetransport.GetFileSliceInfo(filesName, system));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Example #9
0
 /// <summary>
 /// 删除文件
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="system"></param>
 /// <returns></returns>
 public bool DeleteFile(string fileName, SeatManageSubsystem system)
 {
     try
     {
         FileTransport filetransport = new FileTransport();
         return(filetransport.DeleteFile(fileName, system));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="fullPath">文件完整路径</param>
        /// <param name="relativePath">相对路径</param>
        /// <param name="system">系统类型</param>
        /// <returns></returns>
        public bool UpdateFile(string fullPath, string relativePath, SeatManageSubsystem system)
        {
            //上传出错重试,每次重试50次,每次上传成功,初始化重试次数  2013-9-4 王随
            for (int i = 0; i < 50; i++)
            {
                try
                {
                    string     fileName = relativePath; // fullPath.Substring(fullPath.LastIndexOf(@"\") + 1);
                    int        maxSiz   = 1024 * 1000;  //设置每次传100k
                    FileStream stream   = System.IO.File.OpenRead(fullPath);
                    //读取本地文件
                    FileSliceInfo file = FileTransportBll.GetFileSliceInfo(fileName, system); //更加文件名,查询服务中是否存在该文件
                    if (file == null)                                                         //表示文件不存在
                    {
                        file        = new FileSliceInfo();
                        file.Offset = 0; //设置文件从开始位置进行数据传递
                    }
                    file.Length = stream.Length;
                    if (file.Length == file.Offset)
                    //如果文件的长度等于文件的偏移量,说明文件已经上传完成 ,重新上传
                    {
                        file.Offset = 0; //设置文件从开始位置进行数据传递
                    }
                    file.Name = fileName;
                    while (file.Length != file.Offset)                                                                        //循环的读取文件,上传,直到文件的长度等于文件的偏移量
                    {
                        file.Data       = new byte[file.Length - file.Offset <= maxSiz ? file.Length - file.Offset : maxSiz]; //设置传递的数据的大小
                        stream.Position = file.Offset;                                                                        //设置本地文件数据的读取位置
                        stream.Read(file.Data, 0, file.Data.Length);                                                          //把数据写入到file.Data中
                        file = FileTransportBll.FileUpLoad(file, system);                                                     //上传
                        i    = 0;                                                                                             //初始化重试次数
                        if (HandleProgress != null)
                        {
                            int progress = (int)((double)file.Offset / (double)file.Length * 100);
                            HandleProgress(progress);
                        }
                    }

                    stream.Close();
                    stream.Dispose();
                    stream = null;

                    return(true);
                }
                catch
                {
                }
            }
            return(false);
        }
Example #11
0
        public bool DeleteFile(string fileName, SeatManageSubsystem system)
        {
            try
            {
                //fileName = fileName.Substring(fileName.IndexOf("\\"));
                string filepath = uploadFolder + string.Format(@"{0}\", system.ToString()) + fileName;

                if (System.IO.File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #12
0
        public byte[] FileDownLoad(String fileName, Int64 Offset, SeatManageSubsystem system)
        {
            try
            {
                int    maxSiz   = 1024 * bufferLen; //设置每次传100k
                string filePath = "";
                if (fileName.IndexOf(@"\") == 0)    //如果\第一次出现的位置为1,则不用加斜杠
                {
                    filePath = string.Format("{0}{1}{2}", uploadFolder, system.ToString(), fileName);
                }
                else
                {
                    filePath = string.Format(@"{0}{1}\{2}", uploadFolder, system.ToString(), fileName);
                }


                // string filePath = uploadFolder + string.Format(@"{0}", system.ToString()) + fileName;
                //获得客户端信息
                OperationContext              context           = OperationContext.Current;
                MessageProperties             messageProperties = context.IncomingMessageProperties;
                RemoteEndpointMessageProperty endpointProperty  = (RemoteEndpointMessageProperty)messageProperties[RemoteEndpointMessageProperty.Name];
                lock (downloadObject)
                {
                    Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                    Int64  Length = stream.Length;
                    if (Offset == Length)
                    {
                        return(null);
                    }
                    byte[] ReData = new byte[Length - Offset <= maxSiz ? stream.Length - Offset : maxSiz]; //设置传递的数据的大小
                    stream.Position = Offset;                                                              //设置本地文件数据的读取位置
                    stream.Read(ReData, 0, ReData.Length);                                                 //把数据写入到file.Data中
                    stream.Close();
                    return(ReData);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取更新信息
        /// </summary>
        /// <returns></returns>
        public FileUpdateInfo GetUpdateInfo(SeatManageSubsystem system)
        {
            StringBuilder strWhere = new StringBuilder();

            strWhere.Append(string.Format(" Application ={0}", (int)system));
            try
            {
                DataSet ds = updaterDal.GetList(strWhere.ToString(), null);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    return(DataRowToFileUpdaterInfo(ds.Tables[0].Rows[0]));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #14
0
 internal FileSliceInfo_Md5 GetFilesSlice_Md5Info(string fileName, SeatManageSubsystem system)
 {
     try
     {
         string filepath = "";
         if (fileName.IndexOf(@"\") == 0)//如果\第一次出现的位置为1,则不用加斜杠
         {
             filepath = string.Format("{0}{1}{2}", uploadFolder, system.ToString(), fileName);
         }
         else
         {
             filepath = string.Format(@"{0}{1}\{2}", uploadFolder, system.ToString(), fileName);
         }
         FileSliceInfo_Md5 file = new FileSliceInfo_Md5();
         file.Name   = fileName;
         file.Length = 0;
         file.Offset = 0;
         file.Data   = null;
         if (System.IO.File.Exists(filepath))
         {
             //文件已经存在
             System.IO.FileInfo fi = new System.IO.FileInfo(filepath);
             file.Md5    = SeatManage.SeatManageComm.SeatComm.GetMD5HashFromFile(filepath);
             file.Length = fi.Length;
             file.Offset = fi.Length;//返回追加数据后的文件位置
             fi          = null;
             return(file);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #15
0
        /// <summary>
        /// 文件下载断点续传
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="Offset"></param>
        /// <returns></returns>
        public static FileSliceInfo FileDownLoad(FileSliceInfo file, SeatManageSubsystem system)
        {
            IFileTransportService fileTransport = WcfAccessProxy.ServiceProxy.CreateChannelFileTransportService();
            bool isError = false;

            try
            {
                file.Data = fileTransport.FileDownLoad(file.Name, file.Offset, system);
                return(file);
            }
            catch (Exception ex)
            {
                isError = true;
                WriteLog.Write(string.Format("文件下载出错,异常信息:{0}", ex.Message));
                throw ex;
            }
            finally
            {
                ICommunicationObject ICommObjectService = fileTransport as ICommunicationObject;
                try
                {
                    if (ICommObjectService.State == CommunicationState.Faulted)
                    {
                        ICommObjectService.Abort();
                    }
                    else
                    {
                        ICommObjectService.Close();
                    }
                }
                catch
                {
                    ICommObjectService.Abort();
                }
            }
        }
Example #16
0
 /// <summary>
 /// 文件上传,可进行断点续传
 /// </summary>
 /// <param name="fileName">文件名称</param>
 /// <param name="fileByte">文件二进制流</param>
 /// <param name="Length">文件长度</param>
 /// <param name="Offset">文件起始位置</param>
 /// <returns></returns>
 public long FileUpLoad(string fileName, byte[] fileByte, long Length, long Offset, SeatManageSubsystem system)
 {
     try
     {
         FileTransport filetransport = new FileTransport();
         return(filetransport.FileUpLoad(fileName, fileByte, Length, Offset, system));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 获取参数中包含的文件信息
 /// </summary>
 /// <param name="FilesName">文件名称</param>
 /// <returns></returns>
 public List <FileSimpleInfo> GetFilesInfo(List <string> filesName, SeatManageSubsystem system)
 {
     throw new NotImplementedException();
 }
Example #18
0
        public Int64 FileUpLoad(String fileName, Byte[] fileByte, Int64 Length, Int64 Offset, SeatManageSubsystem system)
        {
            Int64 ReturnOffset = 0;
            //uploadFolder + string.Format(@"{0}\", system.ToString()) + fileName;
            string filePath = "";

            if (fileName.IndexOf(@"\") == 0)//如果\第一次出现的位置为1,则不用加斜杠
            {
                filePath = string.Format("{0}{1}{2}", uploadFolder, system.ToString(), fileName);
            }
            else
            {
                filePath = string.Format(@"{0}{1}\{2}", uploadFolder, system.ToString(), fileName);
            }
            string directoryPath = filePath.Substring(0, filePath.LastIndexOf("\\"));

            //获取文件的路径,已经保存的文件名
            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }
            try
            {
                lock (UploadObj)
                {
                    FileStream fs = new FileStream(filePath + ".tz", FileMode.OpenOrCreate);
                    if (fs == null)
                    {
                        fs = new FileStream(filePath, FileMode.OpenOrCreate);
                    }
                    if (fs.Length == Length)
                    {
                        if (File.Exists(filePath + ".tz"))
                        {
                            File.Move(filePath + ".tz", filePath);
                        }
                        fs.Close();
                    }
                    try
                    {
                        //文件偏移位置,表示从这个位置开始进行后面的数据添加
                        BinaryWriter writer = new BinaryWriter(fs);//初始化文件写入器
                        if (Offset >= int.MaxValue)
                        {
                            writer.Seek(int.MaxValue, SeekOrigin.Begin);
                            Offset = Offset - int.MaxValue;
                            while (Offset > 0)//判断Offset是否大于int类型所能表示的最大值
                            {
                                if (Offset >= int.MaxValue)
                                {
                                    writer.Seek(int.MaxValue, SeekOrigin.Current);
                                    Offset = Offset - int.MaxValue;
                                }
                                else
                                {
                                    writer.Seek(int.Parse(Offset.ToString()), SeekOrigin.Current);
                                    Offset = 0;
                                }
                            }
                        }
                        else
                        {
                            writer.Seek(Int32.Parse(Offset.ToString()), SeekOrigin.Begin); //设置文件的写入位置
                        }
                        writer.Write(fileByte);                                            //写入数据
                        ReturnOffset = fs.Length;                                          //返回追加数据后的文件位置
                        fileByte     = null;
                        writer.Close();
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                        fs.Close();
                        throw ex;
                    }
                    if (ReturnOffset == Length)
                    {
                        if (File.Exists(filePath + ".tz"))
                        {
                            if (File.Exists(filePath))
                            {
                                bool isDel = false;
                                while (!isDel)
                                {
                                    try
                                    {
                                        File.Delete(filePath);
                                        isDel = true;
                                    }
                                    catch (Exception ex)
                                    {
                                        isDel = false;
                                        System.Threading.Thread.Sleep(500);
                                    }
                                }
                            }
                            File.Move(filePath + ".tz", filePath);
                        }
                    }
                }
                return(ReturnOffset);
            }
            catch (Exception ex)
            {
                throw new Exception("锁定的代码内出错:" + ex.Message);
            }
            //try
            //{

            //}
            //catch (Exception ex)
            //{
            //    throw new Exception("出错在删除临时文件:" + ex.Message);
            //}
        }
Example #19
0
        /// <summary>
        /// 下载文件
        /// 每次下载遇到错误重试50次
        /// </summary>
        /// <param name="filePath">文件的完整</param>
        /// <param name="relativePath">文件的相对路径</param>
        /// <param name="system">系统名称</param>
        /// <returns></returns>
        public string FileDownLoad(string filePath, string relativePath, SeatManageSubsystem system)
        {
            //添加下载错误自动断点下载,每次出错重试50次。 2013-9-4 作者:王随
            for (int i = 0; i < 50; i++)
            {
                //获取文件的路径,已经保存的文件名
                FileStream   fs     = null;
                BinaryWriter writer = null;
                try
                {
                    string        fileName = relativePath;// filePath.Substring(filePath.LastIndexOf(@"\") + 1);
                    string        dirPath  = filePath.Substring(0, filePath.LastIndexOf(@"\") + 1);
                    FileSliceInfo file2    = FileTransportBll.GetFileInfo(fileName, system);
                    if (file2 == null)
                    {
                        if (DownloadError != null)
                        {
                            DownloadError(string.Format("文件{0}下载失败。", fileName));
                        }
                        return(string.Format("文件{0}下载失败。", fileName));
                    }
                    file2.Name   = fileName;
                    file2.Offset = 0;

                    //如果文件目录不存在,创建文件所存放的目录.
                    if (!Directory.Exists(dirPath))
                    {
                        Directory.CreateDirectory(dirPath);
                    }


                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }
                    fs = new FileStream(filePath + ".tz", FileMode.OpenOrCreate);

                    file2.Offset = fs.Length;
                    if (file2.Offset != file2.Length)
                    {
                        //文件偏移位置,表示从这个位置开始进行后面的数据添加
                        writer = new BinaryWriter(fs); //初始化文件写入器
                        file2  = FileTransportBll.FileDownLoad(file2, system);
                        i      = 0;                    //下载成功,把重试次数初始化
                        while (file2.Data != null)
                        {
                            //打开文件
                            long Offset = file2.Offset; //file.Offset

                            if (Offset >= int.MaxValue)
                            {
                                writer.Seek(int.MaxValue, SeekOrigin.Begin);
                                Offset = Offset - int.MaxValue;
                                while (Offset > 0)
                                {
                                    if (Offset >= int.MaxValue)
                                    {
                                        writer.Seek(int.MaxValue, SeekOrigin.Current);
                                        Offset = Offset - int.MaxValue;
                                    }
                                    else
                                    {
                                        writer.Seek(int.Parse(Offset.ToString()), SeekOrigin.Current);
                                        Offset = 0;
                                    }
                                }
                            }
                            else
                            {
                                writer.Seek(Int32.Parse(Offset.ToString()), SeekOrigin.Begin);//设置文件的写入位置
                            }

                            writer.Write(file2.Data); //写入数据
                            file2.Offset = fs.Length; //返回追加数据后的文件位置
                            file2.Data   = null;
                            file2        = FileTransportBll.FileDownLoad(file2, system);
                            i            = 0;
                            if (HandleProgress != null)
                            {
                                int progress = (int)(((double)file2.Offset / (double)((long)file2.Length)) * 100);
                                HandleProgress(progress);
                            }
                        }
                        writer.Close();
                        fs.Close();

                        if (File.Exists(filePath + ".tz"))
                        {
                            File.Move(filePath + ".tz", filePath);
                        }
                    }
                    return("");
                }
                catch (Exception ex)
                {
                    if (writer != null)
                    {
                        writer.Close();
                    }
                    if (fs != null)
                    {
                        fs.Close();
                    }
                    // result = false;
                }
            }
            return("下载失败!");
        }
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="filePath">文件的完整</param>
        /// <param name="relativePath">文件的相对路径</param>
        /// <param name="system">系统名称</param>
        /// <returns></returns>
        public bool FileDownLoad(string filePath, string relativePath, SeatManageSubsystem system)
        {
            for (int i = 0; i < 50; i++)
            {
                //获取文件的路径,已经保存的文件名
                FileStream   fs     = null;
                BinaryWriter writer = null;//初始化文件写入器
                try
                {
                    string            fileName = relativePath;// filePath.Substring(filePath.LastIndexOf(@"\") + 1);
                    string            dirPath  = filePath.Substring(0, filePath.LastIndexOf(@"\") + 1);
                    FileSliceInfo     file2    = FileTransportBll.GetFilesSlice_Md5Info(fileName, system);
                    FileSliceInfo_Md5 f        = file2 as FileSliceInfo_Md5;
                    if (file2 == null)
                    {
                        if (DownloadError != null)
                        {
                            DownloadError(string.Format("文件{0}下载失败。", fileName));
                        }
                        return(false);
                    }
                    else if (File.Exists(filePath))
                    {
                        //先设置文件只读属性,然后再删除,不然无法删除文件
                        File.SetAttributes(filePath, System.IO.FileAttributes.Normal);
                        if (f.Md5 == SeatManageComm.SeatComm.GetMD5HashFromFile(filePath))
                        {
                            return(true);
                        }
                    }
                    file2.Name   = fileName;
                    file2.Offset = 0;

                    //如果文件目录不存在,创建文件所存放的目录.
                    if (!Directory.Exists(dirPath))
                    {
                        Directory.CreateDirectory(dirPath);
                    }

                    //文件先下载,下载完成后再删除
                    fs = new FileStream(filePath + ".tz", FileMode.OpenOrCreate);

                    file2.Offset = fs.Length;
                    if (file2.Offset != file2.Length)
                    {
                        //文件偏移位置,表示从这个位置开始进行后面的数据添加
                        writer = new BinaryWriter(fs);//初始化文件写入器
                        file2  = FileTransportBll.FileDownLoad(file2, system);
                        i      = 0;
                        while (file2.Data != null)
                        {
                            //打开文件
                            long Offset = file2.Offset; //file.Offset

                            if (Offset >= int.MaxValue)
                            {
                                writer.Seek(int.MaxValue, SeekOrigin.Begin);
                                Offset = Offset - int.MaxValue;
                                while (Offset > 0)
                                {
                                    if (Offset >= int.MaxValue)
                                    {
                                        writer.Seek(int.MaxValue, SeekOrigin.Current);
                                        Offset = Offset - int.MaxValue;
                                    }
                                    else
                                    {
                                        writer.Seek(int.Parse(Offset.ToString()), SeekOrigin.Current);
                                        Offset = 0;
                                    }
                                }
                            }
                            else
                            {
                                writer.Seek(Int32.Parse(Offset.ToString()), SeekOrigin.Begin);//设置文件的写入位置
                            }

                            writer.Write(file2.Data); //写入数据
                            file2.Offset = fs.Length; //返回追加数据后的文件位置
                            file2.Data   = null;
                            file2        = FileTransportBll.FileDownLoad(file2, system);
                            i            = 0;
                            if (HandleProgress != null)
                            {
                                int progress = (int)(((double)file2.Offset / (double)((long)file2.Length)) * 100);
                                HandleProgress(progress);
                            }
                        }
                        writer.Close();
                        fs.Close();
                    }
                    else//否则文件已经下载完成,只是还没有更改后缀,则关闭文件流
                    {
                        fs.Close();
                    }
                    if (File.Exists(filePath + ".tz"))
                    {
                        if (File.Exists(filePath))
                        {
                            File.Delete(filePath);
                        }
                        File.Move(filePath + ".tz", filePath);
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    if (writer != null)
                    {
                        writer.Close();
                    }
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }
            }
            return(false);
        }