Пример #1
0
        public void TestXmlReadSequenceGroup()
        {
            SequenceGroup sequenceGroup = XmlReaderHelper.ReadSequenceGroup(SequenceGroupPath);

            Assert.AreEqual(sequenceGroup.Name, "SequenceGroup1");
            Assert.AreEqual(sequenceGroup.Info.Version, "1.0.0");
//            Assert.AreEqual(sequenceGroup.Info.SequenceGroupFile, SequenceGroupPath);
//            Assert.AreEqual(sequenceGroup.Info.SequenceParamFile, ParameterPath);
            Assert.AreEqual(sequenceGroup.TypeDatas.Count, 3);
            Assert.AreEqual(sequenceGroup.TypeDatas[0].AssemblyName, "TestAssemblyName");
            Assert.AreEqual(sequenceGroup.TypeDatas[1].Name, "Int32");
            Assert.AreEqual(sequenceGroup.Sequences.Count, 3);
            Assert.AreEqual(sequenceGroup.Sequences[0].Name, "Sequence1");
            Assert.AreEqual(sequenceGroup.Sequences[0].Variables.Count, 4);
            Assert.AreEqual(sequenceGroup.Sequences[0].Variables[0].VariableType, VariableType.Value);
            Assert.AreEqual(sequenceGroup.Sequences[0].Variables[1].Name, "Variable2");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps.Count, 3);
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Name, "SequenceStep1");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].HasSubSteps, false);
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Function.Type, FunctionType.InstanceFunction);
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Function.Instance, "Variable1");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Function.Return, "Variable3");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Function.MethodName, "Add");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Function.ParameterType.Count, 2);
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].Function.ParameterType[0].Name, "addSource");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[2].LoopCounter.Name, "LoopCounterDemo");
            Assert.AreEqual(sequenceGroup.Sequences[0].Steps[0].RetryCounter.Name, "RetryCounterDemo");
        }
        /// <summary>
        /// The edit.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SequenceGroup sequenceGroup = await db.SequenceGroup.FindAsync(id);

            if (sequenceGroup == null)
            {
                return(HttpNotFound());
            }

            using (var db = new LibiadaWebEntities())
            {
                var viewDataHelper   = new ViewDataHelper(db);
                var viewData         = viewDataHelper.FillViewData(1, int.MaxValue);
                var matterRepository = new MatterRepository(db);
                var matterIds        = sequenceGroup.Matters.Select(m => m.Id);
                bool Selected(Matter m) => matterIds.Contains(m.Id);

                viewData["matters"]            = matterRepository.GetMatterSelectList(db.Matter, Selected);
                viewData["sequenceGroupTypes"] = EnumExtensions.ToArray <SequenceGroupType>().ToSelectListWithNature();
                ViewBag.data = JsonConvert.SerializeObject(viewData);
            }

            return(View(sequenceGroup));
        }
Пример #3
0
        public void LoadParameter(ISequenceGroup sequenceGroup, bool forceLoad, params string[] param)
        {
            SequenceGroup sequenceGroupObj = sequenceGroup as SequenceGroup;

            sequenceGroupObj.RefreshSignature();
            SequenceDeserializer.LoadParameter(sequenceGroupObj, param[0], forceLoad);
        }
 public void ShouldNotFailIfTryingToRemoveNotExistingSequence()
 {
     var group = new SequenceGroup();
     group.Add(new Sequence());
     group.Add(new Sequence());
     group.Remove(new Sequence());
 }
Пример #5
0
        public ISequenceGroup LoadSequenceGroup(SerializationTarget source, params string[] param)
        {
            bool forceLoad = false;

            if (param.Length > 1 && null != param[1])
            {
                bool.TryParse(param[1], out forceLoad);
            }
            switch (source)
            {
            case SerializationTarget.File:
                SequenceGroup sequenceGroup = SequenceDeserializer.LoadSequenceGroup(param[0], forceLoad, this.ConfigData);
                ModuleUtils.ValidateParent(sequenceGroup, null);
                _directoryHelper.SetToAbsolutePath(sequenceGroup);
                return(sequenceGroup);

                break;

            case SerializationTarget.DataBase:
                throw new NotImplementedException();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(source), source, null);
            }
        }
Пример #6
0
        public static SequenceGroup LoadSequenceGroup(string seqFilePath, bool forceLoad, IModuleConfigData envInfo)
        {
            seqFilePath = ModuleUtils.GetAbsolutePath(seqFilePath, Directory.GetCurrentDirectory());

            if (!seqFilePath.EndsWith($".{CommonConst.SequenceFileExtension}"))
            {
                I18N i18N = I18N.GetInstance(Constants.I18nName);
                throw new TestflowDataException(ModuleErrorCode.InvalidFileType, i18N.GetStr("InvalidFileType"));
            }
            SequenceGroup sequenceGroup = XmlReaderHelper.ReadSequenceGroup(seqFilePath);


            // 需要单独配置Setup和TearDown的索引号
            sequenceGroup.SetUp.Index    = CommonConst.SetupIndex;
            sequenceGroup.TearDown.Index = CommonConst.TeardownIndex;

            string paramFilePath             = ModuleUtils.GetAbsolutePath(sequenceGroup.Info.SequenceParamFile, seqFilePath);
            SequenceGroupParameter parameter =
                XmlReaderHelper.ReadSequenceGroupParameter(paramFilePath);

            if (!forceLoad && !sequenceGroup.Info.Hash.Equals(parameter.Info.Hash))
            {
                I18N i18N = I18N.GetInstance(Constants.I18nName);
                throw new TestflowDataException(ModuleErrorCode.UnmatchedFileHash, i18N.GetStr("UnmatchedHash"));
            }
            sequenceGroup.Parameters = parameter;
            SetParameterToSequenceData(sequenceGroup, parameter);
            ValidateTypeDatas(sequenceGroup);

            sequenceGroup.Info.SequenceGroupFile = seqFilePath;
            sequenceGroup.Info.SequenceParamFile = paramFilePath;
            return(sequenceGroup);
        }
Пример #7
0
        public static void Serialize(string filePath, SequenceGroup sequenceGroup)
        {
            filePath = ModuleUtils.GetAbsolutePath(filePath, Directory.GetCurrentDirectory());

            VerifySequenceData(sequenceGroup);
            sequenceGroup.Info.SequenceGroupFile = filePath;
            sequenceGroup.Info.SequenceParamFile = ModuleUtils.GetParameterFilePath(filePath);

            SequenceGroupParameter parameter = new SequenceGroupParameter();

            parameter.Initialize(sequenceGroup);
            // 将SequeneGroup配置的参数写入ParameterData中,用以序列化
            FillParameterDataToSequenceData(sequenceGroup, parameter);

            List <string> serialziedFileList = new List <string>(20);

            try
            {
                serialziedFileList.Add(filePath);
                XmlWriterHelper.Write(sequenceGroup, sequenceGroup.Info.SequenceGroupFile);

                serialziedFileList.Add(sequenceGroup.Info.SequenceParamFile);
                XmlWriterHelper.Write(parameter, sequenceGroup.Info.SequenceParamFile);
            }
            catch (IOException ex)
            {
                RollBackFilesIfFailed(serialziedFileList);
                throw new TestflowRuntimeException(ModuleErrorCode.SerializeFailed, ex.Message, ex);
            }
            catch (ApplicationException)
            {
                RollBackFilesIfFailed(serialziedFileList);
                throw;
            }
        }
Пример #8
0
        public ISequenceGroup CreateSequenceGroup()
        {
            SequenceGroup sequenceGroup = new SequenceGroup();

            sequenceGroup.Info.Version = Version;
            return(sequenceGroup);
        }
Пример #9
0
    public void ShouldNotFailIfTryingToRemoveNotExistingSequence()
    {
        var group = new SequenceGroup();

        group.Add(new Sequence());
        group.Add(new Sequence());
        group.Remove(new Sequence());
    }
Пример #10
0
        public void Should_Not_Fail_If_Trying_To_Remove_NotExisting_Sequence()
        {
            var group = new SequenceGroup();

            group.Add(new Sequence());
            group.Add(new Sequence());
            group.Remove(new Sequence());
        }
Пример #11
0
    public void ShouldAddOneSequenceToGroup()
    {
        var sequence      = new Sequence(7L);
        var sequenceGroup = new SequenceGroup();

        sequenceGroup.Add(sequence);

        Assert.AreEqual(sequence.Value, sequenceGroup.Value);
    }
        public void ShouldAddOneSequenceToGroup()
        {
            var sequence = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequence);

            Assert.AreEqual(sequence.Value, sequenceGroup.Value);
        }
Пример #13
0
        public void ShouldReportSizeOfGroup()
        {
            var sequenceGroup = new SequenceGroup();
            sequenceGroup.Add(new Sequence());
            sequenceGroup.Add(new Sequence());
            sequenceGroup.Add(new Sequence());

            Assert.AreEqual(3, sequenceGroup.Size);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            SequenceGroup sequenceGroup = await db.SequenceGroup.FindAsync(id);

            db.SequenceGroup.Remove(sequenceGroup);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #15
0
        public static SequenceGroup LoadSequenceGroupFromJson(string jsonStr)
        {
            SequenceJsonConvertor convertor     = new SequenceJsonConvertor();
            SequenceGroup         sequenceGroup = JsonConvert.DeserializeObject <SequenceGroup>(jsonStr, convertor);

            ValidateTypeDatas(sequenceGroup);
            ModuleUtils.ValidateParent(sequenceGroup, null);
            return(sequenceGroup);
        }
Пример #16
0
        public static string ToJson(SequenceGroup sequenceGroup)
        {
            VerifySequenceData(sequenceGroup);
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            return(JsonConvert.SerializeObject(sequenceGroup, settings));
        }
Пример #17
0
    public void ShouldReportSizeOfGroup()
    {
        var sequenceGroup = new SequenceGroup();

        sequenceGroup.Add(new Sequence());
        sequenceGroup.Add(new Sequence());
        sequenceGroup.Add(new Sequence());

        Assert.AreEqual(3, sequenceGroup.Size);
    }
Пример #18
0
        public void Should_Report_Size_Of_Group()
        {
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(new Sequence());
            sequenceGroup.Add(new Sequence());
            sequenceGroup.Add(new Sequence());

            Assert.Equal(3, sequenceGroup.Size());
        }
Пример #19
0
    public void ShouldReportTheMinimumSequenceForGroupOfTwo()
    {
        var sequenceThree = new Sequence(3L);
        var sequenceSeven = new Sequence(7L);
        var sequenceGroup = new SequenceGroup();

        sequenceGroup.Add(sequenceSeven);
        sequenceGroup.Add(sequenceThree);

        Assert.AreEqual(sequenceThree.Value, sequenceGroup.Value);
    }
Пример #20
0
        public void ShouldReportTheMinimumSequenceForGroupOfTwo()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);

            Assert.AreEqual(sequenceThree.Value, sequenceGroup.Value);
        }
Пример #21
0
        public void Should_Report_The_Minimum_Sequence_For_GroupOfTwo()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);

            var group = new SequenceGroup();

            group.Add(sequenceThree);
            group.Add(sequenceSeven);

            Assert.Equal(sequenceThree.GetValue(), group.GetMinimumSequence());
        }
Пример #22
0
        public void TestXmlReadSequenceGroupParameter()
        {
            SequenceGroup          sequenceGroup = XmlReaderHelper.ReadSequenceGroup(SequenceGroupPath);
            SequenceGroupParameter parameter     = XmlReaderHelper.ReadSequenceGroupParameter(ParameterPath);

            Assert.AreEqual(parameter.Info.Version, "1.0.0");
            Assert.AreEqual(parameter.Info.Hash, sequenceGroup.Info.Hash);
            Assert.AreEqual(parameter.SequenceParameters.Count, 3);
            Assert.AreEqual(parameter.SequenceParameters[0].StepParameters.Count, 3);
            Assert.AreEqual(parameter.SequenceParameters[0].StepParameters[0].Instance, "Variable1");
            Assert.AreEqual(parameter.SequenceParameters[0].StepParameters[0].Return, "Variable3");
        }
Пример #23
0
        public static void LoadParameter(SequenceGroup sequenceGroup, string filePath, bool forceLoad)
        {
            filePath = ModuleUtils.GetAbsolutePath(filePath, Directory.GetCurrentDirectory());
            SequenceGroupParameter parameter = XmlReaderHelper.ReadSequenceGroupParameter(filePath);

            if (!forceLoad && !sequenceGroup.Info.Hash.Equals(parameter.Info.Hash))
            {
                I18N i18N = I18N.GetInstance(Constants.I18nName);
                throw new TestflowDataException(ModuleErrorCode.UnmatchedFileHash, i18N.GetStr("UnmatchedHash"));
            }
            sequenceGroup.Parameters = parameter;
            SetParameterToSequenceData(sequenceGroup, parameter);
            ValidateTypeDatas(sequenceGroup);
        }
Пример #24
0
        public void ShouldRemoveSequenceFromGroup()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);

            Assert.AreEqual(sequenceThree.Value, sequenceGroup.Value);
            Assert.True(sequenceGroup.remove(sequenceThree));
            Assert.AreEqual(sequenceSeven.Value, sequenceGroup.Value);
            Assert.AreEqual(1, sequenceGroup.Size);
        }
        public void ShouldRemoveSequenceFromGroup()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);

            Assert.AreEqual(sequenceThree.Value, sequenceGroup.Value);

            Assert.IsTrue(sequenceGroup.Remove(sequenceThree));
            Assert.AreEqual(sequenceSeven.Value, sequenceGroup.Value);
            Assert.AreEqual(1, sequenceGroup.Size);
        }
Пример #26
0
        public void ShouldSetGroupSequenceToSameValue()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);
            var expectedSequence = 11L;

            sequenceGroup.Value = expectedSequence;

            Assert.AreEqual(expectedSequence, sequenceThree.Value);
            Assert.AreEqual(expectedSequence, sequenceSeven.Value);
        }
Пример #27
0
        public void ShouldSetGroupSequenceToSameValue()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);

            const long expectedSequence = 11L;
            sequenceGroup.Value = expectedSequence;

            Assert.AreEqual(expectedSequence, sequenceThree.Value);
            Assert.AreEqual(expectedSequence, sequenceSeven.Value);
        }
Пример #28
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;
            }
        }
        public void ShouldAddWhileRunning()
        {
            var ringBuffer = RingBuffer<TestEvent>.CreateSingleProducer(()=>new TestEvent(), 32);
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();
            sequenceGroup.Add(sequenceSeven);

            for (var i = 0; i < 11; i++)
            {
                ringBuffer.Publish(ringBuffer.Next());
            }

            sequenceGroup.AddWhileRunning(ringBuffer, sequenceThree);
            Assert.That(sequenceThree.Value, Is.EqualTo(10L));
        }
Пример #30
0
    public void ShouldRemoveSequenceFromGroupWhereItBeenAddedMultipleTimes()
    {
        var sequenceThree = new Sequence(3L);
        var sequenceSeven = new Sequence(7L);
        var sequenceGroup = new SequenceGroup();

        sequenceGroup.Add(sequenceThree);
        sequenceGroup.Add(sequenceSeven);
        sequenceGroup.Add(sequenceThree);

        Assert.AreEqual(sequenceThree.Value, sequenceGroup.Value);

        Assert.IsTrue(sequenceGroup.Remove(sequenceThree));
        Assert.AreEqual(sequenceSeven.Value, sequenceGroup.Value);
        Assert.AreEqual(1, sequenceGroup.Size);
    }
Пример #31
0
        public void Should_Set_Group_Sequence_To_Same_Value()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);

            var expectedSequence = 11L;

            sequenceGroup.SetValue(expectedSequence);

            Assert.Equal(expectedSequence, sequenceThree.GetValue());
            Assert.Equal(expectedSequence, sequenceSeven.GetValue());
        }
        /// <summary>
        /// The details.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SequenceGroup sequenceGroup = await db.SequenceGroup.FindAsync(id);

            if (sequenceGroup == null)
            {
                return(HttpNotFound());
            }

            return(View(sequenceGroup));
        }
Пример #33
0
        public void Should_Remove_Sequence_From_Group_Where_It_Been_Added_Multiple_Times()
        {
            var sequenceThree = new Sequence(3L);
            var sequenceSeven = new Sequence(7L);
            var sequenceGroup = new SequenceGroup();

            sequenceGroup.Add(sequenceThree);
            sequenceGroup.Add(sequenceSeven);
            sequenceGroup.Add(sequenceThree);

            Assert.Equal(sequenceThree.GetValue(), sequenceGroup.GetMinimumSequence());

            Assert.True(sequenceGroup.Remove(sequenceThree));
            Assert.Equal(sequenceSeven.GetValue(), sequenceGroup.GetMinimumSequence());
            Assert.Equal(1, sequenceGroup.Size());
        }
Пример #34
0
        public static TestProject LoadTestProject(string filePath, bool forceLoad, IModuleConfigData envInfo)
        {
            filePath = ModuleUtils.GetAbsolutePath(filePath, Directory.GetCurrentDirectory());

            if (!filePath.EndsWith($".{CommonConst.TestGroupFileExtension}"))
            {
                I18N i18N = I18N.GetInstance(Constants.I18nName);
                throw new TestflowRuntimeException(ModuleErrorCode.InvalidFileType, i18N.GetStr("InvalidFileType"));
            }
            TestProject testProject = null;

            testProject = XmlReaderHelper.ReadTestProject(filePath);

            // 需要单独配置Setup和TearDown的索引号
            testProject.SetUp.Index    = CommonConst.SetupIndex;
            testProject.TearDown.Index = CommonConst.TeardownIndex;

            CheckModelVersion(testProject.ModelVersion, envInfo);
            foreach (ISequenceGroup sequenceGroup in testProject.SequenceGroups)
            {
                CheckModelVersion(sequenceGroup.Info.Version, envInfo);
            }
            foreach (SequenceGroupLocationInfo sequenceGroupLocation in testProject.SequenceGroupLocations)
            {
                SequenceGroup sequenceGroup = null;

                string sequenceGroupFile = ModuleUtils.GetAbsolutePath(sequenceGroupLocation.SequenceFilePath, filePath);
                if (File.Exists(sequenceGroupFile))
                {
                    sequenceGroup        = LoadSequenceGroup(sequenceGroupFile, forceLoad, envInfo);
                    sequenceGroup.Parent = testProject;
                }
                else
                {
                    ILogService logService = TestflowRunner.GetInstance().LogService;
                    logService.Print(LogLevel.Warn, CommonConst.PlatformLogSession, 0, "Sequence group file not exist.");
                    sequenceGroup = new SequenceGroup();
                    sequenceGroup.Initialize(testProject);
                    sequenceGroup.Info.SequenceGroupFile = sequenceGroupFile;
                    sequenceGroup.Available = false;
                }
                testProject.SequenceGroups.Add(sequenceGroup);
            }
            ValidateTypeDatas(testProject);

            return(testProject);
        }
Пример #35
0
 private static void VerifySequenceData(SequenceGroup sequenceGroup)
 {
     foreach (IVariable variable in sequenceGroup.Variables)
     {
         VerifyTypeIndexes(sequenceGroup.TypeDatas, variable as Variable);
     }
     foreach (IArgument argument in sequenceGroup.Arguments)
     {
         VerifyTypeIndexes(sequenceGroup.TypeDatas, argument as Argument);
     }
     VerifySequenceData(sequenceGroup.TypeDatas, sequenceGroup.SetUp);
     VerifySequenceData(sequenceGroup.TypeDatas, sequenceGroup.TearDown);
     foreach (ISequence sequence in sequenceGroup.Sequences)
     {
         VerifySequenceData(sequenceGroup.TypeDatas, sequence);
     }
 }
Пример #36
0
        public static SequenceGroup ReadSequenceGroup(string filePath)
        {
            if (!filePath.EndsWith($".{CommonConst.SequenceFileExtension}"))
            {
                I18N i18N = I18N.GetInstance(Constants.I18nName);
                throw new TestflowDataException(ModuleErrorCode.InvalidFileType, i18N.GetStr("InvalidFileType"));
            }
            XmlReader reader = null;

            try
            {
                reader = CreateXmlReader(filePath);
                Dictionary <string, Type> typeMapping = GetTypeMapping();
                // 找到TestProject节点后跳出
                while (reader.Read())
                {
                    if (XmlNodeType.Element != reader.NodeType)
                    {
                        continue;
                    }
                    if (typeof(SequenceGroup).Name.Equals(reader.Name))
                    {
                        break;
                    }
                }
                SequenceGroup sequenceGroup = new SequenceGroup();
                FillDataToObject(reader, sequenceGroup, typeMapping);
                return(sequenceGroup);
            }
            catch (ArgumentException ex)
            {
                ILogService logService = TestflowRunner.GetInstance().LogService;
                logService.Print(LogLevel.Error, CommonConst.PlatformLogSession, 0, ex);
                throw new TestflowDataException(ModuleErrorCode.DeSerializeFailed, ex.Message, ex);
            }
            catch (IOException ex)
            {
                ILogService logService = TestflowRunner.GetInstance().LogService;
                logService.Print(LogLevel.Error, CommonConst.PlatformLogSession, 0, ex);
                throw new TestflowRuntimeException(ModuleErrorCode.DeSerializeFailed, ex.Message, ex);
            }
            finally
            {
                reader?.Close();
            }
        }
Пример #37
0
 public ActionResult New(SequenceGroup sequenceGroup)
 {
     if (ModelState.IsValid)
     {
         if (base.genericMgr.FindAll<long>(duiplicateVerifyStatement, new object[] { sequenceGroup.Code })[0] > 0)
         {
             SaveErrorMessage(Resources.SCM.SequenceGroup.Errors_ExistingSequenceGroup, sequenceGroup.Code);
         }
         else
         {
             base.genericMgr.Create(sequenceGroup);
             SaveSuccessMessage(Resources.SCM.SequenceGroup.SequenceGroup_Added);
             return RedirectToAction("Edit", new { code = sequenceGroup.Code });
         }
     }
     return View(sequenceGroup);
 }
Пример #38
0
    public void ShouldAddWhileRunning()
    {
        var ringBuffer = RingBuffer <TestEvent> .CreateSingleProducer(() => new TestEvent(), 32);

        var sequenceThree = new Sequence(3L);
        var sequenceSeven = new Sequence(7L);
        var sequenceGroup = new SequenceGroup();

        sequenceGroup.Add(sequenceSeven);

        for (var i = 0; i < 11; i++)
        {
            ringBuffer.Publish(ringBuffer.Next());
        }

        sequenceGroup.AddWhileRunning(ringBuffer, sequenceThree);
        Assert.That(sequenceThree.Value, Is.EqualTo(10L));
    }
 public void ShouldReturnMaxSequenceWhenEmptyGroup()
 {
     var sequenceGroup = new SequenceGroup();
     Assert.AreEqual(long.MaxValue, sequenceGroup.Value);
 }
Пример #40
0
        public ActionResult Edit(SequenceGroup sequenceGroup)
        {
            ViewBag.HaveEditPrevTraceCode = CurrentUser.Permissions.Where(p => p.PermissionCode == "Url_SequenceGroup_EditPrevTraceCode").Count() > 0;
            if (ModelState.IsValid)
            {
                bool noenError = true;
                if (!ViewBag.HaveEditPrevTraceCode && !string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                {
                    SaveErrorMessage("您没有修改前个Van号的权限。");
                    noenError = false;
                }
                if (sequenceGroup.IsActive && string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                {
                    SaveErrorMessage("排序组有效的情况下,前面Van号不能为空。");
                     noenError = false;
                }
                IList<OrderSeq> orderSeqs = new List<OrderSeq>();
                if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                {
                     orderSeqs = this.genericMgr.FindAll<OrderSeq>("select o from OrderSeq as o where o.ProductLine=? and o.TraceCode=?", new object[] { sequenceGroup.ProductLine, sequenceGroup.PreviousTraceCode });
                    if (orderSeqs == null || orderSeqs.Count == 0)
                    {
                        SaveErrorMessage(string.Format("生产线{0}前面Van号{1}找不到有效的数据。", sequenceGroup.ProductLine, sequenceGroup.PreviousTraceCode));
                        noenError = false;
                    }
                }
                if (!string.IsNullOrWhiteSpace(sequenceGroup.OpReference))
                {
                    try
                    {
                        sequenceGroup.OpReference.Split('|');
                    }
                    catch (Exception)
                    {
                        SaveErrorMessage(string.Format("工位{0}填写有误,正确的格式为{1}。", sequenceGroup.OpReference, Resources.SCM.SequenceGroup.SequenceGroup_OpRefRemark));
                        noenError = false;
                    }
                }
                if (noenError)
                {
                    var dbSsequenceGroup = base.genericMgr.FindById<SequenceGroup>(sequenceGroup.Code);
                    //dbSsequenceGroup.SequenceBatch = sequenceGroup.SequenceBatch;
                    //dbSsequenceGroup.OpReference = sequenceGroup.OpReference;
                    //dbSsequenceGroup.IsActive = sequenceGroup.IsActive;
                    //if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                    //{
                    //    dbSsequenceGroup.PreviousTraceCode = sequenceGroup.PreviousTraceCode;
                    //    dbSsequenceGroup.PreviousOrderNo = orderSeqs.First().OrderNo;
                    //    dbSsequenceGroup.PreviousSeq = orderSeqs.First().Sequence;
                    //    dbSsequenceGroup.PreviousSubSeq = orderSeqs.First().SubSequence;
                    //}
                    //base.genericMgr.Update(dbSsequenceGroup);
                    string updateSql = "update SCM_SeqGroup set Version=Version+1,IsActive=?,SeqBatch=? ";
                    IList<object> parems = new List<object>();
                    parems.Add(sequenceGroup.IsActive);
                    parems.Add(sequenceGroup.SequenceBatch);
                    if (!string.IsNullOrWhiteSpace(sequenceGroup.OpReference))
                    {
                        updateSql += " ,OpRef=? ";
                        parems.Add(sequenceGroup.OpReference);
                    }
                    if (!string.IsNullOrWhiteSpace(sequenceGroup.PreviousTraceCode))
                    {
                        updateSql += ",PrevTraceCode=?,PrevOrderNo=?,PrevSeq=?,PrevSubSeq=? ";
                        parems.Add(sequenceGroup.PreviousTraceCode);
                        parems.Add(orderSeqs.First().OrderNo);
                        parems.Add(orderSeqs.First().Sequence);
                        parems.Add(orderSeqs.First().SubSequence);
                    }
                    updateSql += "  where Code=? and Version=? ";
                    parems.Add(sequenceGroup.Code);
                    parems.Add(sequenceGroup.Version);
                    this.genericMgr.UpdateWithNativeQuery(updateSql, parems.ToArray());
                    SaveSuccessMessage(Resources.SCM.SequenceGroup.SequenceGroup_Updated);
                    return View(dbSsequenceGroup);
                }
            }

            return View(sequenceGroup);
        }