Example #1
0
        public void LoadParameter(ISequenceGroup sequenceGroup, bool forceLoad, params string[] param)
        {
            SequenceGroup sequenceGroupObj = sequenceGroup as SequenceGroup;

            sequenceGroupObj.RefreshSignature();
            SequenceDeserializer.LoadParameter(sequenceGroupObj, param[0], forceLoad);
        }
Example #2
0
        public static void Serialize(string seqFilePath, SequenceGroup sequenceGroup)
        {
            VerifySequenceData(sequenceGroup);

            string paramFilePath = ModuleUtils.GetParameterFilePath(seqFilePath);

            SequenceGroupParameter parameter = new SequenceGroupParameter();

            parameter.Initialize(sequenceGroup);
            // 将SequeneGroup配置的参数写入ParameterData中,用以序列化
            FillParameterDataToSequenceData(sequenceGroup, parameter);
            sequenceGroup.RefreshSignature();
            parameter.RefreshSignature(sequenceGroup);
            List <string> serializedFileList = new List <string>(20);

            try
            {
                // 暂时修改序列组文件路径为相对路径
                sequenceGroup.Info.SequenceGroupFile = ModuleUtils.GetFileName(seqFilePath);
                sequenceGroup.Info.SequenceParamFile = ModuleUtils.GetRelativePath(paramFilePath, seqFilePath);

                BackupExistFile(seqFilePath, paramFilePath);

                serializedFileList.Add(seqFilePath);
                XmlWriterHelper.Write(sequenceGroup, seqFilePath);

                serializedFileList.Add(paramFilePath);
                XmlWriterHelper.Write(parameter, paramFilePath);

                DeleteBackupFile(seqFilePath, paramFilePath);
            }
            catch (IOException ex)
            {
                RollBackFilesIfFailed(serializedFileList);
                throw new TestflowRuntimeException(ModuleErrorCode.SerializeFailed, ex.Message, ex);
            }
            catch (ApplicationException)
            {
                RollBackFilesIfFailed(serializedFileList);
                throw;
            }
            finally
            {
                // 恢复序列文件的绝对路径
                sequenceGroup.Info.SequenceGroupFile = seqFilePath;
                sequenceGroup.Info.SequenceParamFile = paramFilePath;
            }
        }
Example #3
0
        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;
            }
        }