示例#1
0
        /// <summary>
        /// 执行数据镜像
        /// </summary>
        /// <param name="task">任务</param>
        /// <param name="mirror">镜像源信息</param>
        /// <param name="asyn">异步通知</param>
        public void Execute(SPFTask task, Mirror mirror, IAsyncTaskProgress asyn)
        {
            //生成保存目录
            FileHelper.CreateExitsDirectorySafe(mirror.Target);

            //镜像
            MirrorService = SingleWrapperHelper <MirrorServiceFactory> .GetInstance().GetInstance(mirror);

            MirrorService.Execute(mirror, asyn);

            if (FileHelper.IsValid(mirror.Local))
            {//镜像成功
                mirror.VerifyCode = FileHelper.MD5FromFileUpper(mirror.Local);

                //生成MD5文件
                var md5File = mirror.Local.TrimEnd(SPFTask.EXT_MIRROR) + SPFTask.EXT_VERIFYCODE_FILE;
                FileHelper.CreateFile(md5File, mirror.VerifyCode, Encoding.UTF8);

                //生成设备信息文件
                var deviceFile = mirror.Local.TrimEnd(SPFTask.EXT_MIRROR) + SPFTask.EXT_DEVICE;
                Serializer.SerializeToBinary(task.Device, deviceFile);

                task.TaskMirrorFilePath = mirror.Local;
                task.VerifyCodes.Add(new FileVerifyCode()
                {
                    FilePath = mirror.Local, VerifyCode = mirror.VerifyCode
                });
            }
        }