public static void Serialize(string filePath, TestProject testProject) { filePath = ModuleUtils.GetAbsolutePath(filePath, Directory.GetCurrentDirectory()); VerifySequenceData(testProject); List <string> serialziedFileList = new List <string>(10); try { // 初始化各个SequenceGroup的文件位置信息 InitSequenceGroupLocations(testProject, filePath); serialziedFileList.Add(filePath); XmlWriterHelper.Write(testProject, filePath); // 将testProject当前配置的数据信息写入ParameterData中 FillParameterDataToSequenceData(testProject); for (int i = 0; i < testProject.SequenceGroups.Count; i++) { SequenceGroup sequenceGroup = testProject.SequenceGroups[i] as SequenceGroup; string sequenceGroupPath = ModuleUtils.GetAbsolutePath(sequenceGroup.Info.SequenceGroupFile, filePath); string parameterFilePath = ModuleUtils.GetAbsolutePath(sequenceGroup.Info.SequenceParamFile, sequenceGroupPath);; if (!ModuleUtils.IsValidFilePath(sequenceGroupPath)) { sequenceGroupPath = ModuleUtils.GetSequenceGroupPath(filePath, i); sequenceGroup.Info.SequenceGroupFile = ModuleUtils.GetRelativePath(sequenceGroupPath, filePath); parameterFilePath = ModuleUtils.GetParameterFilePath(sequenceGroupPath); sequenceGroup.Info.SequenceParamFile = ModuleUtils.GetRelativePath(parameterFilePath, sequenceGroupPath); } else if (!ModuleUtils.IsValidFilePath(parameterFilePath)) { parameterFilePath = ModuleUtils.GetParameterFilePath(sequenceGroupPath); sequenceGroup.Info.SequenceParamFile = ModuleUtils.GetRelativePath(parameterFilePath, sequenceGroupPath); } SequenceGroupParameter parameter = new SequenceGroupParameter(); parameter.Initialize(sequenceGroup); // 将SequeneGroup配置的参数写入ParameterData中,用以序列化 FillParameterDataToSequenceData(sequenceGroup, parameter); sequenceGroup.RefreshSignature(); parameter.RefreshSignature(sequenceGroup); // 创建sequenceGroupd的文件夹 string directory = ModuleUtils.GetSequenceGroupDirectory(sequenceGroupPath); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } serialziedFileList.Add(sequenceGroupPath); XmlWriterHelper.Write(sequenceGroup, sequenceGroupPath); serialziedFileList.Add(parameterFilePath); XmlWriterHelper.Write(parameter, parameterFilePath); } } catch (IOException ex) { RollBackFilesIfFailed(serialziedFileList); throw new TestflowRuntimeException(ModuleErrorCode.SerializeFailed, ex.Message, ex); } catch (ApplicationException) { RollBackFilesIfFailed(serialziedFileList); throw; } }