public void ShouldGetEmptyTagListByDefault() { var specInfo = SpecInfo.CreateBuilder() .AddTags("foo") .SetName("") .SetFileName("") .SetIsFailed(false) .Build(); var scenarioInfo = ScenarioInfo.CreateBuilder() .AddTags("bar") .SetName("") .SetIsFailed(false) .Build(); var currentScenario = ExecutionInfo.CreateBuilder() .SetCurrentScenario(scenarioInfo) .SetCurrentSpec(specInfo) .Build(); var currentExecutionInfo = ScenarioExecutionStartingRequest.CreateBuilder() .SetCurrentExecutionInfo(currentScenario) .Build(); var message = Message.CreateBuilder() .SetScenarioExecutionStartingRequest(currentExecutionInfo) .SetMessageType(Message.Types.MessageType.ScenarioExecutionStarting) .SetMessageId(0) .Build(); var tags = AssertEx.ExecuteProtectedMethod <ExecutionEndingProcessor>("GetApplicableTags", message); Assert.IsEmpty(tags); }
public void ShouldNotGetDuplicateTags() { var specInfo = SpecInfo.CreateBuilder() .AddTags("foo") .SetName("") .SetFileName("") .SetIsFailed(false) .Build(); var scenarioInfo = ScenarioInfo.CreateBuilder() .AddTags("foo") .SetName("") .SetIsFailed(false) .Build(); var currentScenario = ExecutionInfo.CreateBuilder() .SetCurrentScenario(scenarioInfo) .SetCurrentSpec(specInfo) .Build(); var currentExecutionInfo = ScenarioExecutionEndingRequest.CreateBuilder() .SetCurrentExecutionInfo(currentScenario) .Build(); var message = Message.CreateBuilder() .SetScenarioExecutionEndingRequest(currentExecutionInfo) .SetMessageType(Message.Types.MessageType.ScenarioExecutionEnding) .SetMessageId(0) .Build(); var tags = AssertEx.ExecuteProtectedMethod <ScenarioExecutionEndingProcessor>("GetApplicableTags", message).ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
public void ShouldGetTagListFromExecutionInfo() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var executionInfo = new ExecutionInfo { CurrentSpec = specInfo }; var currentExecutionInfo = new SpecExecutionEndingRequest { CurrentExecutionInfo = executionInfo }; var message = new Message { SpecExecutionEndingRequest = currentExecutionInfo, MessageType = Message.Types.MessageType.StepExecutionEnding, MessageId = 0 }; var tags = AssertEx.ExecuteProtectedMethod <SpecExecutionEndingProcessor>("GetApplicableTags", message) .ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
public void ShouldNotFetchDuplicateTags() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { Tags = { "foo" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo { CurrentSpec = specInfo, CurrentScenario = scenarioInfo }; var tags = AssertEx.ExecuteProtectedMethod <ScenarioExecutionStartingProcessor>("GetApplicableTags", currentScenario) .ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
public void ShouldGetTagListFromScenarioAndSpecAndIgnoreDuplicates() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { Tags = { "foo" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo { CurrentScenario = scenarioInfo, CurrentSpec = specInfo }; var currentExecutionInfo = new StepExecutionEndingRequest { CurrentExecutionInfo = currentScenario }; var tags = AssertEx.ExecuteProtectedMethod <StepExecutionEndingProcessor>("GetApplicableTags", currentScenario) .ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
private void SetInfo(SpecInfo data) { this.tdSpecName.Value = data.SpecName; this.tdBalancePrice.Value = data.BalancePrice == decimal.MinValue ? "" : data.BalancePrice.ToString(); this.tdColdPrice.Value = data.ColdPrice == decimal.MinValue ? "" : data.ColdPrice.ToString(); this.tdMovePrice.Value = data.MovePrice == decimal.MinValue ? "" : data.MovePrice.ToString(); }
private void btAutoCreate_Click(object sender, EventArgs e) { vm.Model.TempSetting = userControlTempSettting1.GetValue(); AppFramework.Context.LoadSubForm <FormSpecInfoModify_AutoCreate>(true, Size.Empty, Point.Empty, (obj, arg) => { var auto = obj as FormSpecInfoModify_AutoCreate; auto.Enabled = false; var specInfo = new SpecInfo() { SeqID = vm.Model.SeqID, SeqName = vm.Model.SeqName, StationID = vm.Model.StationID, ProductID = vm.Model.ProductID, CenterWavelenghs = vm.Model.CenterWavelenghs, WavelenghStart = vm.Model.WavelenghStart, WavelenghEnd = vm.Model.WavelenghEnd, WavelenghStep = vm.Model.WavelenghStep, TempSetting = vm.Model.TempSetting, SeqData = vm.Model.SeqData, CreateTime = DateTime.Now, UpdateTime = DateTime.Now, SeqVersion = 0, SeqStatus = 1, SpecItems = specItems }; auto.CreateTestSystemItemControls(classID, specInfo, new Action <List <SpecItem> >((items) => { specItems.Clear(); specItems.AddRange(items); LoadSpecItems(); })); auto.Enabled = true; }); }
public void ShouldGetEmptyTagListByDefault() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { Tags = { "bar" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo { CurrentScenario = scenarioInfo, CurrentSpec = specInfo }; var tags = AssertEx.ExecuteProtectedMethod <ExecutionStartingProcessor>("GetApplicableTags", currentScenario); Assert.IsEmpty(tags); }
public bool GetSingleBeam(int spectrometerIndex, ref SpecInfo SpInfo, bool isBKGrdFlag) { if (isBKGrdFlag) { this.SetParameters(Spectrometer.spectrometerIndex, IntegrationTimeBK); } else { this.SetParameters(Spectrometer.spectrometerIndex, IntegrationTime); } SpInfo.numPixls = this.wrapper.getNumberOfPixels(spectrometerIndex); try { SpInfo.WavelengthArray = this.wrapper.getWavelengths(spectrometerIndex); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } string str = DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss-fff"); SpInfo.DataA = new double[SpInfo.numPixls]; SpInfo.DataA = this.wrapper.getSpectrum(spectrometerIndex); string str2 = DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss-fff"); if ((SpInfo.WavelengthArray.Length > 10) && (SpInfo.DataA.Length > 10)) { SpInfo.DataX = SpInfo.WavelengthArray; return(true); } return(false); }
public void ShouldGetEmptyTagListByDefault() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { Tags = { "bar" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo { CurrentScenario = scenarioInfo, CurrentSpec = specInfo }; var currentExecutionInfo = new ScenarioExecutionStartingRequest { CurrentExecutionInfo = currentScenario }; var message = new Message { ScenarioExecutionStartingRequest = currentExecutionInfo, MessageType = Message.Types.MessageType.ScenarioExecutionStarting, MessageId = 0 }; var tags = AssertEx.ExecuteProtectedMethod <ExecutionStartingProcessor>("GetApplicableTags", message); Assert.IsEmpty(tags); }
private void SetInfo(WarehouseInOut data) { this.tdOrderNumber.Value = data.OrderNumber; this.tdInventoryInfo.Value = data.InventoryInfoID == int.MinValue ? "1" : data.InventoryInfoID.ToString(); this.tdBusiness.Value = data.BusinessID == int.MinValue ? "1" : data.BusinessID.ToString(); this.tdProduct.Value = data.ProductID == int.MinValue ? "1" : data.ProductID.ToString(); this.tdCount.Value = data.Count == int.MinValue ? "" : data.Count.ToString(); this.tdCarrier.Value = data.CarrierID == int.MinValue ? "1" : data.CarrierID.ToString(); this.tdSpec.Value = data.SpecInfoID == int.MinValue ? "1" : data.SpecInfoID.ToString(); if (data.SpecInfoID > 0) { var spec = SpecInfo.GetSpecInfo(data.SpecInfoID); this.tdColdPrice.Value = spec.ColdPrice == int.MinValue ? "0" : spec.ColdPrice.ToString(); this.tdMovePrice.Value = spec.MovePrice == int.MinValue ? "0" : spec.MovePrice.ToString(); this.hdMovePrice.Value = spec.MovePrice == int.MinValue ? "0" : spec.MovePrice.ToString(); this.tdMoveCost.Value = data.MoveCost.ToString(); } this.tdStartTime.Value = data.StartTime == DateTime.MinValue ? "" : data.StartTime.ToString("yyyy-MM-dd"); this.tdEndTime.Value = data.EndTime == DateTime.MinValue ? "" : data.EndTime.ToString("yyyy-MM-dd"); this.tdRemark.Value = data.Remark; this.tdColdCost.Value = data.ColdCost.ToString(); if (data.BusinessChargeStatus) { this.tdSave.Visible = false; } }
public ExecutionContext.Specification SpecificationFrom(SpecInfo currentSpec) { return currentSpec != null ? new ExecutionContext.Specification(currentSpec.Name, currentSpec.FileName, currentSpec.IsFailed, currentSpec.Tags.ToArray()) : new ExecutionContext.Specification(); }
private dynamic SpecificationFrom(SpecInfo currentSpec) { var executionContextSpecType = _executionContextType.GetNestedType("Specification"); return(currentSpec != null ? activatorWrapper.CreateInstance(executionContextSpecType, currentSpec.Name, currentSpec.FileName, currentSpec.IsFailed, currentSpec.Tags.ToArray()) : activatorWrapper.CreateInstance(executionContextSpecType)); }
public void GetSingleBeamOnly(int spectrometerIndex, ref SpecInfo SpInfo) { for (int i = 0; i < SpInfo.DataA.Length; i++) { SpInfo.DataA[i] = 0.0; } this.wrapper.setIntegrationTime(spectrometerIndex, IntegrationTime); SpInfo.DataA = this.wrapper.getSpectrum(spectrometerIndex); }
public void EnrichDescription(SpecInfo spec, MessageFormatter formatter) { foreach (var given in _given) given.DescribeTo(s => spec.ReportGivenStep(new StepInfo(s)), formatter); _when.DescribeTo(spec.ReportWhenStep, formatter); _expectations.DescribeTo(spec, formatter); }
private static void printSpec(DocX document, SpecInfo spec) { printName(document, spec); printSkipped(document, spec); printGiven(document, spec); printWhen(document, spec); printThen(document, spec); document.InsertParagraph(); }
public bool GetSpec(int spectrometerIndex, ref SpecInfo SpInfo, int WaitTime, BackgroundWorker bk) { int num; this.SetParameters(Spectrometer.spectrometerIndex, IntegrationTime); SpInfo.numPixls = this.wrapper.getNumberOfPixels(spectrometerIndex); SpInfo.WavelengthArray = this.wrapper.getWavelengths(spectrometerIndex); this.wrapper.setScansToAverage(spectrometerIndex, ScanTimes); for (num = 0; num < 5; num++) { Thread.Sleep(0x3e8); bk.ReportProgress(num); } SpInfo.DataA = this.wrapper.getSpectrum(spectrometerIndex); bk.ReportProgress(5); if ((SpInfo.WavelengthArray.Length > 10) && (SpInfo.DataA.Length > 10)) { SpInfo.DataX = SpInfo.WavelengthArray; if (SpInfo.DataAB.Length == SpInfo.DataA.Length) { SpInfo.DataY = new double[SpInfo.numPixls]; for (num = 0; num < SpInfo.DataA.Length; num++) { try { if (isClearDarks) { SpInfo.DataY[num] = Convert.ToDouble(Math.Log10(Math.Abs((double)((SpInfo.DataAB[num] - SpInfo.DataAD[num]) / (SpInfo.DataA[num] - SpInfo.DataAD[num]))))); } else { SpInfo.DataY[num] = Convert.ToDouble(Math.Log10(Math.Abs((double)(SpInfo.DataAB[num] / SpInfo.DataA[num])))); } } catch { if (num > 0) { SpInfo.DataY[num] = SpInfo.DataY[num - 1]; } else { SpInfo.DataY[num] = 0.0; } } } return(true); } return(false); } return(false); }
public void VerifyTo(object[] input, SpecInfo results, MessageFormatter formatter) { if (_count != input.Length) { results.ReportExpectationFail(string.Format("Expected {0} new messages, but found {1}.", _count, input.Length), new MessageCountMismatchException(_count, input, formatter)); } else { results.ReportExpectationPass(string.Format("The correct number of messages ({0}) were generated.", _count)); } }
public void ReadDK(ref SpecInfo SpInfo) { if (File.Exists(Application.StartupPath.ToString() + @"\dark")) { int num = this.DataIOmy.TXTReadData(Application.StartupPath.ToString() + @"\dark", ref SpInfo.DataX, ref SpInfo.DataAD, true); SpInfo.DataAD = new double[num]; this.DataIOmy.TXTReadData(Application.StartupPath.ToString() + @"\dark", ref SpInfo.DataX, ref SpInfo.DataAD, false); } else { MessageBox.Show("背景文件不存在,请先采集背景!"); } }
private static void printSkipped(DocX document, SpecInfo spec) { if (spec.Skipped.IsSkipped) { document.InsertParagraph() .Append(spec.Skipped.ToString()) .Font(new FontFamily("Cambria")) .FontSize(13) .Bold() .Color(Color.FromArgb(255, 255, 124, 0)) ; } }
private string FormatDefaultSetting(string setting, double[] wls, SpecInfo specInfo) { var newSetting = setting; var matchs = setting.Matches(@"\{([^{]*)\}"); foreach (System.Text.RegularExpressions.Match match in matchs) { var text = match.Groups[0].Value; var tag = match.Groups[1].Value; var value = MeasuringManager.GetFormatTag(tag, wls); newSetting = newSetting.Replace(text, value); } return(newSetting); }
protected void Page_Load(object sender, EventArgs e) { int ID = 0; int.TryParse(Request.QueryString["ID"], out ID); if (ID > 0) { var data = SpecInfo.GetSpecInfo(ID); if (data != null) { SetInfo(data); } } }
public ActionResult <string> SetData(SpecInfoModifyModel data, List <SpecItem> specItems) { var newData = new SpecInfo() { SeqID = data.SeqID, SeqName = data.SeqName, StationID = data.StationID, ProductID = data.ProductID, CenterWavelenghs = data.CenterWavelenghs, WavelenghStart = data.WavelenghStart, WavelenghEnd = data.WavelenghEnd, WavelenghStep = data.WavelenghStep, TempSetting = data.TempSetting, SeqData = data.SeqData, CreateTime = data.CreateTime, UpdateTime = data.UpdateTime, SeqVersion = data.SeqVersion, SeqStatus = data.SeqStatus, SpecItems = specItems }; if (newData.SeqVersion < 1 || newData.SeqStatus == 1) //稽核通过才有版本更新 { if (newData.SeqVersion < 1) { newData.CreateTime = DateTime.Now; } newData.SeqVersion += 1; //newData.SeqStatus = 0; } newData.UpdateTime = DateTime.Now; try { if (repository.SaveData(newData)) { return(ActionResult <string> .SetSuccess($"保存 {ItemName} 成功", "保存成功")); } else { return(ActionResult <string> .SetError($"{ItemName} 已经被删除", "保存失败")); } } catch (Exception ex) { return(ActionResult <string> .SetError(ex.Message, "保存失败")); } }
public void CreateTestSystemItemControls(Guid classID, SpecInfo specInfo, Action <List <SpecItem> > callback = null) { this.classID = classID; this.specInfo = specInfo; this.callback = callback; var tempSetting = specInfo.TempSetting.Split(","); var wls = specInfo.CenterWavelenghs.Split(",").Select(q => q.CastTo(double.MinValue)).ToArray(); var testSystemGroups = BaseSettingsManager.Get <SystemGroupSetting>().GetTestGroupByProductClass(classID); flowLayoutPanel1.Visible = false; flowLayoutPanel1.Controls.Clear(); flowLayoutPanel1.SuspendLayout(); foreach (var order in testSystemGroups) { foreach (var testSystem in BaseSettingsManager.Get <SystemGroupSetting>().GetTestItemByGroup(order.TestGroupID)) { var testSystemItem = new UserControlTestSystemItem() { Name = string.Format("testSystemItem_{0:N}", testSystem.SystemID) }; testSystemItem.SetTestSystem(tempSetting, testSystem); flowLayoutPanel1.Controls.Add(testSystemItem); testSystemItem.SendToBack(); if (specInfo.SpecItems.Count < 1) { var settingString = FormatDefaultSetting(testSystem.DefaultSetting, wls, specInfo); testSystemItem.SetSetting(settingString); continue; } var testSpecItems = specInfo.SpecItems.Where(q => q.SystemID == testSystem.SystemID).ToList(); foreach (var item in testSpecItems) { testSystemItem.SetSetting(item.TestInfo); testSystemItem.SetSpec(Array.IndexOf(tempSetting, item.TestTemp), item.ComputeSetting.FromJsonString <Dictionary <int, ComputeSettingItem> >()); } } } flowLayoutPanel1.ResumeLayout(); flowLayoutPanel1.Visible = true; }
private void SetInfo(WarehouseInOut data) { //this.tdOrderNumber.Value = data.OrderNumber; this.tdInventoryInfo.Value = data.InventoryInfoID == int.MinValue ? "1" : data.InventoryInfoID.ToString(); this.tdBusiness.Value = data.BusinessID == int.MinValue ? "1" : data.BusinessID.ToString(); this.tdProduct.Value = data.ProductID == int.MinValue ? "1" : data.ProductID.ToString(); this.tdCount.Value = data.Count == int.MinValue ? "" : data.Count.ToString(); this.tdCarrier.Value = data.CarrierID == int.MinValue ? "1" : data.CarrierID.ToString(); this.tdSpec.Value = data.SpecInfoID == int.MinValue ? "1" : data.SpecInfoID.ToString(); if (data.SpecInfoID > 0) { var spec = SpecInfo.GetSpecInfo(data.SpecInfoID); this.tdColdPrice.Value = spec.ColdPrice == int.MinValue ? "0" : spec.ColdPrice.ToString(); this.tdMovePrice.Value = spec.MovePrice == int.MinValue ? "0" : spec.MovePrice.ToString(); //this.tdMoveCost.Value = Math.Round((data.Count * spec.MovePrice), 2, MidpointRounding.AwayFromZero).ToString(); this.tdMoveCost.Value = "0"; this.hdMovePrice.Value = spec.MovePrice == int.MinValue ? "0" : spec.MovePrice.ToString(); } }
public void ShouldGetTagListFromExecutionInfo() { var specInfo = new SpecInfo { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var executionInfo = new ExecutionInfo { CurrentSpec = specInfo }; var tags = AssertEx.ExecuteProtectedMethod <SpecExecutionEndingProcessor>("GetApplicableTags", executionInfo) .ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(1, tags.Count); Assert.Contains("foo", tags); }
public void ShouldGetTagListFromScenarioAndSpec() { var specInfo = new SpecInfo() { Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo() { Tags = { "bar" }, Name = "", IsFailed = false }; var currentScenario = new ExecutionInfo() { CurrentScenario = scenarioInfo, CurrentSpec = specInfo }; var currentExecutionInfo = new StepExecutionStartingRequest() { CurrentExecutionInfo = currentScenario }; var message = new Message() { StepExecutionStartingRequest = currentExecutionInfo, MessageType = Message.Types.MessageType.ScenarioExecutionStarting, MessageId = 0 }; var tags = AssertEx.ExecuteProtectedMethod <StepExecutionStartingProcessor>("GetApplicableTags", message).ToList(); Assert.IsNotEmpty(tags); Assert.AreEqual(2, tags.Count); Assert.Contains("foo", tags); Assert.Contains("bar", tags); }
private static void printGiven(DocX document, SpecInfo spec) { if (spec.Givens.Length == 0) return; document.InsertParagraph() .Append("Given") .Font(new FontFamily("Cambria")) .FontSize(13) .Bold() .Color(Color.FromArgb(255, 79, 129, 189)) ; foreach (var given in spec.Givens) { var description = spec.HasExecutionBeenTriggered ? string.Format("{0} [{1}]", given.Description, given.Passed ? "Passed" : "Failed") : given.Description; var p = document.InsertParagraph() .Append(description) .Color(spec.HasExecutionBeenTriggered ? (given.Passed ? Color.Green : Color.Red) : Color.Black) .FontSize(12); p.IndentationBefore = 0.5f; } if (!spec.Givens.All(x => x.Passed) && spec.Exception != null) { document.InsertParagraph() .Append(spec.Exception.ToString()) .Color(Color.Black) .FontSize(12) .IndentationBefore = 0.5f; } }
private static void printThen(DocX document, SpecInfo spec) { document.InsertParagraph() .Append("Then") .Font(new FontFamily("Cambria")) .FontSize(13) .Bold() .Color(Color.FromArgb(255, 79, 129, 189)); foreach (var then in spec.Thens) { var description = spec.HasExecutionBeenTriggered ? string.Format("{0} [{1}]", then.Description, then.Passed ? "Passed" : "Failed") : then.Description; var p = document.InsertParagraph() .Append(description) .FontSize(12) .Color(spec.HasExecutionBeenTriggered ? (then.Passed ? Color.Green : Color.Red) : Color.Black); if (!then.Passed && then.Exception != null) p.AppendLine(then.Exception.ToString()); p.IndentationBefore = 0.5f; } }
public void DescribeTo(SpecInfo spec, MessageFormatter formatter) { spec.ReportExpectation(string.Format("There should be {0} new messages.", _count)); }
private string GetScenarioKey(ExecutionInfo executionInfo, SpecInfo specInfo, ScenarioInfo scenarioInfo) { return(System.Text.Json.JsonSerializer.Serialize(new { Spec = GetSpecKey(executionInfo, specInfo), ScenarioName = scenarioInfo.Name })); }
private void LoadInterface(Guid pSeqID, SpecInfo data) { //设置窗体标题 if (pSeqID == Guid.Empty) { this.Text = $"添加{ModifySpecInfo.ItemName}"; if (string.IsNullOrEmpty(data.TempSetting)) { data.TempSetting = "25,,"; } if (string.IsNullOrEmpty(data.CenterWavelenghs)) { data.CenterWavelenghs = "1526,1550,1566"; } data.WavelenghStart = 1260D; data.WavelenghEnd = 1350D; data.WavelenghStep = 0.1D; specItems = data.SpecItems; } else { this.Text = $"修改{ModifySpecInfo.ItemName} - {data.SeqName}"; comboBox3.Enabled = false; comboBox1.Enabled = false; comboBox2.Enabled = false; specItems = data.SpecItems; } dtSpecItem = new DataTable(); dtSpecItem.Columns.Add("TestItemID", Type.GetType("System.String")); dtSpecItem.Columns.Add("TestItemName", Type.GetType("System.String")); dtSpecItem.Columns.Add("TestItemTemp", Type.GetType("System.String")); dtSpecItem.Columns.Add("TestItemPort", Type.GetType("System.String")); dtSpecItem.Columns.Add("TestItemInfo", Type.GetType("System.String")); foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { dtSpecItem.Columns.Add(string.Format("TestItemCompute{0}", resultItem.ResultID), Type.GetType("System.String")); } dtSpecItem.Columns.Add("TestItemOrder", Type.GetType("System.String")); dgvSeq.DataSource = dtSpecItem; dgvSeq.Columns["TestItemID"].Visible = false; dgvSeq.Columns["TestItemName"].HeaderText = "测试项目"; dgvSeq.Columns["TestItemTemp"].HeaderText = "测试温度"; dgvSeq.Columns["TestItemPort"].HeaderText = "测试端口"; dgvSeq.Columns["TestItemInfo"].HeaderText = "测试设置"; foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { dgvSeq.Columns[string.Format("TestItemCompute{0}", resultItem.ResultID)].HeaderText = resultItem.ResultName; } dgvSeq.Columns["TestItemOrder"].HeaderText = "排序"; vm.Model.SeqID = data.SeqID; vm.Model.SeqName = data.SeqName; vm.Model.ProductID = data.ProductID; vm.Model.StationID = data.StationID; vm.Model.CenterWavelenghs = data.CenterWavelenghs; vm.Model.WavelenghStart = data.WavelenghStart; vm.Model.WavelenghEnd = data.WavelenghEnd; vm.Model.WavelenghStep = data.WavelenghStep; vm.Model.TempSetting = data.TempSetting; vm.Model.SeqData = data.SeqData; vm.Model.CreateTime = data.CreateTime; vm.Model.UpdateTime = data.UpdateTime; vm.Model.SeqVersion = data.SeqVersion; vm.Model.SeqStatus = data.SeqStatus; if (pSeqID == Guid.Empty) { vm.Model.TempSetting = "25,,"; } userControlTempSettting1.SetSetting(0, "常温", "低温", "高温"); userControlTempSettting1.SetValue(vm.Model.TempSetting); vm.LabelFor(label6, m => m.CenterWavelenghs); vm.EditorFor(textBox3, m => m.CenterWavelenghs, c => c.Text); vm.LabelFor(label5, m => m.WavelenghStart); vm.EditorFor(numericUpDown1, m => m.WavelenghStart, c => c.Value); vm.LabelFor(label7, m => m.WavelenghEnd); vm.EditorFor(numericUpDown2, m => m.WavelenghEnd, c => c.Value); vm.LabelFor(label8, m => m.WavelenghStep); vm.EditorFor(numericUpDown3, m => m.WavelenghStep, c => c.Value); LoadSpecItems(); if (!Framework.MeasurementSystemSetting.SystemData.Setting.Profile.EnabledAudit) { vm.Model.SeqStatus = 1; } else { vm.Model.SeqStatus = 0; } label4.Text = "产品类型"; var ds2 = new BindingList <KeyValuePair <Guid, string> >(); var ds3 = new BindingList <ProductInfo>(); comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; comboBox1.BindingDataSource(ds2); comboBox2.DropDownStyle = ComboBoxStyle.DropDownList; comboBox2.BindingDataSource(ds3, "ProductID", "ProductCode"); vm.LabelFor(label1, m => m.SeqName); vm.EditorFor(textBox1, m => m.SeqName, c => c.Text); vm.LabelFor(label2, m => m.StationID); vm.EditorFor(comboBox1, m => m.StationID, c => c.SelectedValue); vm.LabelFor(label3, m => m.ProductID); vm.EditorFor(comboBox2, m => m.ProductID, c => c.SelectedValue); vm.LabelFor(label3, m => m.ProductID); vm.EditorFor(comboBox2, m => m.ProductID, c => c.SelectedValue); if (pSeqID == Guid.Empty) { comboBox3.SelectedValueChanged += (s, e) => { var typeID = Guid.Empty; if (comboBox3.SelectedValue != null) { typeID = comboBox3.SelectedValue.CastTo(Guid.Empty); } LoadProudctInfo(typeID, Guid.Empty, Guid.Empty); LoadStation(typeID, Guid.Empty, Guid.Empty); }; comboBox2.SelectedValueChanged += (s, e) => { var productInfo = default(ProductInfo); if (comboBox2.SelectedItem != null) { productInfo = comboBox2.SelectedItem as ProductInfo; } if (productInfo == null) { textBox2.Text = ""; return; } textBox2.Text = productInfo.ProductName; classID = productInfo.ProductClassID; }; } LoadProductType(pSeqID, data.StationID, data.ProductID); }
public MeasurementJobSpec(SpecInfo specInfo, Guid classID) { SeqID = specInfo.SeqID; SeqName = specInfo.SeqName; CenterWavelenghs = specInfo.CenterWavelenghs.Split(',').Select(q => q.CastTo(1550D)).ToArray(); WavelenghStart = specInfo.WavelenghStart; WavelenghEnd = specInfo.WavelenghEnd; WavelenghStep = specInfo.WavelenghStep; TempSetting = specInfo.TempSetting.Split(','); SeqData = specInfo.SeqData; CreateTime = specInfo.CreateTime; UpdateTime = specInfo.UpdateTime; SeqVersion = specInfo.SeqVersion; WorkInfoSpecItems = new List <WorkInfoSpecItem>(); TestLists = new List <Dictionary <int, Dictionary <Guid, List <Guid> > > >(); var groupSetting = BaseSettingsManager.Get <SystemGroupSetting>(); TestSystemGroups = groupSetting.GetTestGroupByProductClass(classID).OrderBy(q => q.OrderID).ToList(); Ports = groupSetting.GetPorts(classID); foreach (var item in specInfo.SpecItems) { var systemItem = groupSetting.GetTestSystemItem(item.SystemID); if (systemItem == null) { continue; } var systemGroup = TestSystemGroups.FirstOrDefault(q => q.TestGroupID == systemItem.TestGroupID); if (systemGroup == null) { continue; } int tempIndex = Array.IndexOf(TempSetting, item.TestTemp); WorkInfoSpecItems.Add( new WorkInfoSpecItem() { SpecItemID = item.SpecItemID, TestGroupID = systemGroup.TestGroupID, TestGroupTestType = systemGroup.TestGroupTestType, SystemID = item.SystemID, SystemName = systemItem.SystemName, SystemTypeID = systemItem.SystemTypeID, PortSetting = systemItem.PortSetting, TemperatureSetting = systemItem.TemperatureSetting, ItemName = item.ItemName, TestTemp = item.TestTemp, TestTempOrder = tempIndex, TestSetting = item.TestInfo, ComputeSetting = item.ComputeSetting.FromJsonString <Dictionary <int, ComputeSettingItem> >(), OrderID = item.OrderID }); } WorkInfoSpecItems.Sort((a, b) => a.OrderID.CompareTo(b.OrderID)); var groups = SystemGroupSetting.GroupSystemByTempGroup(TestSystemGroups); foreach (var group in groups) { var groupItems = new Dictionary <int, Dictionary <Guid, List <Guid> > >(); for (int temp = 0; temp < TempSetting.Length; temp++) { var tempData = new Dictionary <Guid, List <Guid> >(); foreach (var systemGroup in group.Value) { var items = WorkInfoSpecItems.Where(q => q.TestGroupID == systemGroup.TestGroupID).ToList(); if (items.Count < 1) { continue; } var tempList = items.Where(q => q.TestTempOrder == temp).Select(q => q.SpecItemID).ToList(); if (tempList.Count < 1) { continue; } tempData[systemGroup.TestGroupID] = new List <Guid>(tempList); } if (tempData.Count > 0) { groupItems[temp] = tempData; } } if (groupItems.Count > 0) { TestLists.Add(groupItems); } } }
public SpecInfo Run(SpecInfo spec, MessageFormatter formatter) { var givenSteps = new StepInfo[_given.Count]; for (int i = 0; i < _given.Count; i++) { var given = _given[i]; int i1 = i; given.DescribeTo(s => { var stepInfo = new StepInfo(s); givenSteps[i1] = stepInfo; return spec.ReportGivenStep(stepInfo); }, formatter); } var prepareStep = new StepInfo("Setup completed"); spec.ReportGivenStep(prepareStep); _when.DescribeTo(spec.ReportWhenStep, formatter); var token = new CancellationTokenSource(); var events = new List<object>(); try { //wireup Action<object> sink = events.Add; var router = _wireup(sink); if (_given.Count == 0) { var step = new StepInfo("No history"); spec.ReportGivenStep(step); step.Pass(); } else for (int i = 0; i < _given.Count; i++) { var g = _given[i]; g.RunTo(router); givenSteps[i].Pass(); } events.Clear(); prepareStep.Pass(); //run when _when.RunTo(router); spec.When.Pass(); } catch { _expectations.DescribeTo(spec, formatter); throw; } finally { token.Cancel(); } //then _expectations.Verify(events.ToArray(), spec, formatter); return spec; }
private static void printName(DocX document, SpecInfo spec) { document.InsertParagraph() .Append(spec.Name) .Font(new FontFamily("Cambria")) .FontSize(13) .Bold() .Color(Color.FromArgb(255, 54, 95, 145)) ; }
private static bool shouldDisplayWhenException(SpecInfo spec) { return !spec.When.Passed && spec.Exception != null && spec.Givens.All(x =>x.Passed); }
private string GetSpecKey(ExecutionInfo executionInfo, SpecInfo specInfo) { return(System.Text.Json.JsonSerializer.Serialize(new { specInfo.Name, specInfo.FileName, executionInfo.RunnerId })); }
public SpecInfoWrapper(SpecInfo specInfo, string fileId) { _specInfo = specInfo; FileId = fileId; }
//更新信息 public static SpecInfo SpecInfoUpload(SpecInfo specInfo, List <string> specValues, out AlertMessage alertMessage) { //权限检查 if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (specInfo.ID == 0 ? "Create" : "Modify")).FirstOrDefault(), out string Message)) { alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning }; return(null); } //表单检查 if (string.IsNullOrWhiteSpace(specInfo.Name)) { alertMessage = new AlertMessage { Message = "规格代码不能为空。", Type = AlertType.warning }; return(null); } if (string.IsNullOrWhiteSpace(specInfo.Title)) { alertMessage = new AlertMessage { Message = "规格名称不能为空。", Type = AlertType.warning }; return(null); } using (var EF = new EF()) { //修改是否存在?规格代码、名称唯一? SpecInfo spec_exist = null; SpecInfo spec_name_exist = null; SpecInfo spec_title_exist = null; if (specInfo.ID == 0) { spec_name_exist = EF.SpecInfos.Where(i => i.Name == specInfo.Name).FirstOrDefault(); spec_title_exist = EF.SpecInfos.Where(i => i.Title == specInfo.Title).FirstOrDefault(); } else { spec_exist = EF.SpecInfos.Where(i => i.ID == specInfo.ID).FirstOrDefault(); if (spec_exist == null) { alertMessage = new AlertMessage { Message = string.Format("规格编号[{0}]不存在。", specInfo.ID), Type = AlertType.warning }; return(null); } spec_name_exist = EF.SpecInfos.Where(i => i.ID != specInfo.ID && i.Name == specInfo.Name).FirstOrDefault(); spec_title_exist = EF.SpecInfos.Where(i => i.ID != specInfo.ID && i.Title == specInfo.Title).FirstOrDefault(); } if (spec_name_exist != null && spec_name_exist.ID > 0) { alertMessage = new AlertMessage { Message = string.Format("规格代码[{0}]已被ID[{1}]使用。", specInfo.Name, spec_name_exist.ID), Type = AlertType.warning }; return(null); } if (spec_title_exist != null && spec_title_exist.ID > 0) { alertMessage = new AlertMessage { Message = string.Format("规格名称[{0}]已被ID[{1}]使用。", specInfo.Title, spec_title_exist.ID), Type = AlertType.warning }; return(null); } //数据保存 using (TransactionScope TS = new TransactionScope()) { //规格信息 if (specInfo.ID == 0) { spec_exist = EF.SpecInfos.Add(new SpecInfo { Enabled = true }); } spec_exist.Name = specInfo.Name; spec_exist.Title = specInfo.Title; spec_exist.IconFont = specInfo.IconFont; EF.SaveChanges(); //规格参数 foreach (var item in specValues) { var specValue_exist = EF.SpecValues.Where(i => i.SpecID == spec_exist.ID && i.Value == item).FirstOrDefault(); if (specValue_exist == null) { EF.SpecValues.Add(specValue_exist = new SpecValue { SpecID = spec_exist.ID, Value = item, Enabled = true }); } EF.SaveChanges(); } TS.Complete(); } //更新完成 alertMessage = null; return(spec_exist); } }
private string GetStepKey(ExecutionInfo executionInfo, SpecInfo specInfo, ScenarioInfo scenarioInfo, StepInfo stepInfo) { return(System.Text.Json.JsonSerializer.Serialize(new { Scenario = GetScenarioKey(executionInfo, specInfo, scenarioInfo), StepName = stepInfo.Step.ActualStepText })); }
private static void printWhen(DocX document, SpecInfo spec) { document.InsertParagraph() .Append("When") .Font(new FontFamily("Cambria")) .FontSize(13) .Bold() .Color(Color.FromArgb(255, 79, 129, 189)); var p = document.InsertParagraph() .Append(spec.HasExecutionBeenTriggered ? string.Format("{0} [{1}]", spec.When.Description, spec.When.Passed ? "Passed" : "Failed") : spec.When.Description) .Color(spec.HasExecutionBeenTriggered ? (spec.When.Passed ? Color.Green : Color.Red) : Color.Black) .FontSize(12); if (shouldDisplayWhenException(spec)) { p.AppendLine(spec.Exception.ToString()); p.AppendLine(spec.Exception.StackTrace); } p.IndentationBefore = 0.5f; }