public static void GetView_FewQueries_ViewIsCached() { var operatorManager = new OperatorManager( new List <Operator> { new Operator("a", new TransitDb(0), null, 1000, new[] { "altA", "altAA" }, new[] { "tag", "tag0" }), new Operator("b", new TransitDb(1), null, 5000, new[] { "altB", "altBB" }, new[] { "tag", "tag0" }), new Operator("c", new TransitDb(2), null, 10000, new[] { "altC", "altCC" }, new[] { "tag", "tag1" }), new Operator("d", new TransitDb(3), null, 1000, new[] { "altD", "altDD" }, new[] { "tag", "tag1" }) } ); var a0 = operatorManager.GetView("a"); var a1 = operatorManager.GetView("altA"); // Important: we use '==' to check for REFERENCE equality, not for content equality // It has to be the same object! Assert.True(a0 == a1); a0 = operatorManager.GetView("a"); a1 = operatorManager.GetView("altA;nonExisting"); Assert.True(a0 == a1); var tag0 = operatorManager.GetView("tag0"); var ab = operatorManager.GetView("a;b"); Assert.True(tag0 == ab); }
void Start() { instance = GetComponent <OperatorManager>(); Vector2 offset = tile.GetComponent <SpriteRenderer>().bounds.size; CreateBoard(offset.x, offset.y); }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { var pu = value as ProfileUser; if (pu != null) { return(OperatorManager.GetByGuId(pu.User_ID)); } return(null); }
public void GetOperator_WhenCalledWithGreaterThan_ReturnsExpectedClass() { // Arrange var mgr = new OperatorManager(); // Act var sut = mgr.GetOperator("GreaterThan"); // Assert sut.Should().NotBeNull("the object should be properly set up to be returned from the OperatorManager"); }
// name of this method MUST match the naming: Get{PropertyName} public static Operator GetUser(UIElement element) { var dtx = element.DataContext as ProfileUser; if (dtx == null) { return(null); } return(OperatorManager.GetByGuId(dtx.User_ID)); // this is it! }
public void GetOperator_WhenAskedForSomethingThatDoesNotExist_ReturnsNull() { // Arrange var sut = new OperatorManager(); // Act var res = sut.GetOperator("Magne Hoseth"); // Assert res.Should().BeNull("we entered an invalid operator name"); }
public void GetOperator_WhenAskedForValidOperator_ReturnsExpectedObject() { // Arrange var sut = new OperatorManager(); // Act var res = sut.GetOperator("Equals"); // Assert res.Should().NotBeNull("we should get a valid object back"); res.Should().BeOfType <EqualsOperator>("that is the operator we asked for"); }
public void GetOperatorNames_WhenCalled_ReturnsListOfOperators() { // Arrange var sut = new OperatorManager(); // Act var res = sut.GetOperatorNames().ToList(); // Assert res.Should().NotBeNull("we should get a valid sequence back"); res.Count.Should().BeGreaterThan(0, "we should have more than zero operators"); res.Contains("Equals").Should().BeTrue("the list should contain the Equals operator"); }
public static void GetView_FewQueries_ReturnsOperators() { var operatorManager = new OperatorManager( new List <Operator> { new Operator("a", new TransitDb(0), null, 1000, new[] { "altA", "altAA" }, new[] { "tag", "tag0" }), new Operator("b", new TransitDb(1), null, 5000, new[] { "altB", "altBB" }, new[] { "tag", "tag0" }), new Operator("c", new TransitDb(2), null, 10000, new[] { "altC", "altCC" }, new[] { "tag", "tag1" }), new Operator("d", new TransitDb(3), null, 1000, new[] { "altD", "altDD" }, new[] { "tag", "tag1" }) } ); var all = operatorManager.GetFullView(); Assert.Equal(4, all.Operators.Count); var a = operatorManager.GetView("a"); Assert.Single(a.Operators); Assert.Equal("a", a.Operators[0].Name); a = operatorManager.GetView("A"); // Upper case Assert.Single(a.Operators); Assert.Equal("a", a.Operators[0].Name); a = operatorManager.GetView("altA"); // Alt name Assert.Single(a.Operators); Assert.Equal("a", a.Operators[0].Name); var cd = operatorManager.GetView("tag1"); Assert.Equal(2, cd.Operators.Count); Assert.Equal("c", cd.Operators[0].Name); Assert.Equal("d", cd.Operators[1].Name); var bcd = operatorManager.GetView("b;tag1"); Assert.Equal(3, bcd.Operators.Count); Assert.Equal("b", bcd.Operators[0].Name); Assert.Equal("c", bcd.Operators[1].Name); Assert.Equal("d", bcd.Operators[2].Name); }
private void btSave_Click(object sender, EventArgs e) { var computeSetting = new Dictionary <int, ComputeSettingItem>(); var sign = cbSpec.SelectedValue; if (sign == null) { AppFramework.Context.ShowError("请选择规格符号!"); return; } foreach (var item in tbSpecs) { var value = item.Value.Text; var specCompute = OperatorManager.GetOperator(sign.ToString()); if (!specCompute.Validation(value)) { AppFramework.Context.ShowError("规格设置格式错误,请检查。"); return; } computeSetting[item.Key] = new ComputeSettingItem() { ComputeSign = sign.ToString(), ComputeValue = value }; } vm.Model.ComputeSetting = computeSetting.ToJsonString(); var testSystem = BaseSettingsManager.Get <SystemGroupSetting>().GetTestSystemItem(vm.Model.SystemID); if (testSystem == null) { AppFramework.Context.ShowError("测试系统不存在!"); return; } var errroString = ""; if (!MeasuringManager.CheckSetting(testSystem.SystemTypeID, vm.Model.TestInfo, out errroString)) { AppFramework.Context.ShowError(errroString); return; } vm.Model.ItemName = MeasuringManager.GetSettingItemName(testSystem.DisplayName, vm.Model.TestInfo, testSystem.PortSetting); var validate = vm.Validate(); if (validate.HasError) { validate.ShowErrorMessage("保存失败"); return; } var specitem = new SpecItem(); specitem.SpecItemID = vm.Model.SpecItemID; specitem.SeqID = vm.Model.SeqID; specitem.SystemID = vm.Model.SystemID; specitem.ItemName = vm.Model.ItemName; specitem.TestTemp = vm.Model.TestTemp; specitem.TestInfo = vm.Model.TestInfo; specitem.ComputeSetting = vm.Model.ComputeSetting; specitem.OrderID = vm.Model.OrderID; AppFramework.Context.ShowAlert("更新成功", "更新项目"); callback?.Invoke(specitem); this.Close(); }
public SpreadsheetTokenizerMock(params Token[] tokens) { _tokens = tokens; _index = 0; OperatorManager = OperatorManager.Default; }
public void LoadData(Guid pSystemID, Guid pTestGroupID, Action cback = null) { this.GetService <ModifyTestSystem>().ExecuteAsync( c => c.GetData(pSystemID), (result) => { if (!result.Status) { AppFramework.Context.ShowError(result.Message); this.Close(); return; } callback = cback; vm.Model.SystemID = result.Data.SystemID; vm.Model.SystemName = result.Data.SystemName; vm.Model.DisplayName = result.Data.DisplayName; vm.Model.DefaultSetting = result.Data.DefaultSetting; vm.Model.PortSetting = result.Data.PortSetting; vm.Model.OrderID = result.Data.OrderID; //设置窗体标题 if (pSystemID == Guid.Empty) { result.Data.TestGroupID = pTestGroupID; this.Text = "添加测试项"; } else { pTestGroupID = result.Data.TestGroupID; this.Text = $"修改测试项 - {result.Data.SystemName}"; } vm.Render(panelContent, new Padding(0, 15, 15, 0), "30%", true, (name, control) => { if (name == "OrderID") { (control as NumericUpDown).Maximum = 10000; } }, (name, control) => { switch (name) { case "SystemTypeID": (control as ComboBox).UpdateDataSource(MeasuringManager.GetCalculateDataSource(), result.Data.SystemTypeID, (value) => { vm.Model.SystemTypeID = value; }); break; case "DefaultComputeSign": (control as ComboBox).UpdateDataSource(OperatorManager.GetComputeDataSource(), result.Data.DefaultComputeSign, (value) => { vm.Model.DefaultComputeSign = value; }); break; case "TestGroupID": var cb = (control as ComboBox); this.GetService <ModifyTestSystem>().ExecuteAsync(c => c.GetTestGroupDataSource(pTestGroupID) , (source) => { if (!source.Status) { return; } cb.UpdateDataSource(source.Data, result.Data.TestGroupID, (value) => { vm.Model.TestGroupID = value; }); }); break; case "TemperatureSetting": var ds4 = new BindingList <KeyValuePair <int, string> >(); ds4.Add(new KeyValuePair <int, string>(0, "多温度测试")); ds4.Add(new KeyValuePair <int, string>(1, "常温测试")); (control as ComboBox).UpdateDataSource(ds4, result.Data.TemperatureSetting, (value) => { vm.Model.TemperatureSetting = value; }); break; } }); }); }
public void LoadData(Guid pSpecItemID, SpecItem specitem, string tempSetting, Action <SpecItem> cback) { callback = cback; vm.Model.SpecItemID = specitem.SpecItemID; vm.Model.SeqID = specitem.SeqID; vm.Model.SystemID = specitem.SystemID; vm.Model.ItemName = specitem.ItemName; vm.Model.TestTemp = specitem.TestTemp; vm.Model.TestInfo = specitem.TestInfo; vm.Model.ComputeSetting = specitem.ComputeSetting; vm.Model.OrderID = specitem.OrderID; //设置窗体标题 if (pSpecItemID == Guid.Empty) { this.Text = $"添加{ModifySpecItem.ItemName}"; } else { this.Text = $"修改{ModifySpecItem.ItemName} - {specitem.ItemName}"; } var temps = tempSetting.Split(","); vm.Render(panelContent, new Padding(0, 15, 15, 0), "100%", true, (name, control) => { switch (name) { case "TestTemp": var ds1 = (control as ComboBox).DataSource as BindingList <KeyValuePair <string, string> >; foreach (var temp in temps) { if (string.IsNullOrEmpty(temp)) { continue; } ds1.Add(new KeyValuePair <string, string>(temp, temp)); } break; case "ItemName": control.Enabled = false; break; case "ComputeSetting": var data = vm.Model.ComputeSetting.FromJsonString <Dictionary <int, ComputeSettingItem> >(); if (data == null) { return; } control.Visible = false; var left = control.Left; var top = control.Top; cbSpec = new ComboBox() { FormattingEnabled = true, Location = new Point(left, top), Name = "cbSpec", Size = new Size(76, 20), ValueMember = "Key", DisplayMember = "Value", DataSource = new BindingCollection <KeyValuePair <string, string> >(OperatorManager.GetComputeDataSource()) }; panelContent.Controls.Add(cbSpec); top += 30; var r = 0; foreach (var resultitem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { var lbSpec = new Label() { Name = string.Format("lbSpec{0}", resultitem.ResultID), AutoSize = true, Location = new Point(left, top + 5 + 30 * r), Text = resultitem.ResultName }; var tbSpec = new TextBox() { Name = string.Format("tbSpec{0}", resultitem.ResultID), Size = new Size(100, 21), Location = new Point(left + 115, top + 30 * r), }; panelContent.Controls.Add(lbSpec); panelContent.Controls.Add(tbSpec); tbSpecs[resultitem.ResultID] = tbSpec; r++; } foreach (var item in data) { cbSpec.Text = item.Value.ComputeSign; if (tbSpecs.ContainsKey(item.Key)) { tbSpecs[item.Key].Text = item.Value.ComputeValue; } } break; } }, null); }
public void AddTestInfoRow(WorkInfoSpecItem specItem) { var row = testItem.NewRow(); row["TestItemID"] = specItem.SpecItemID; row["TestItemName"] = specItem.ItemName; foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { if (!specItem.ComputeSetting.ContainsKey(resultItem.ResultID)) { row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = "N/A"; } else { var computeItem = specItem.ComputeSetting[resultItem.ResultID]; row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = string.IsNullOrEmpty(computeItem.ComputeValue) ? "未设置" : OperatorManager.GetOperator(computeItem.ComputeSign).GetDisplayString(computeItem.ComputeValue); } } row["TestItemPortSetting"] = MeasurementController.GetPortName(specItem.PortSetting); if (string.IsNullOrEmpty("specItem.TestTemp") || !specItem.TestTemp.IsNumeric()) { row["TestItemTemp"] = ""; } else { row["TestItemTemp"] = $"{specItem.TestTemp}℃"; } row["TestItemValue"] = ""; row["TestItemMaxValue"] = ""; row["TestItemMinValue"] = ""; row["TestItemLastValue"] = "-999"; row["TestItemStatus"] = -10; testItem.Rows.Add(row); var resultInfo = new ResultInfo() { TestInfoDataRow = row }; testReslut[specItem.SpecItemID] = resultInfo; var dgvResult = default(DataGridView); if (!dgvResults.TryGetValue(specItem.TestTemp, out dgvResult)) { return; } if (!specItem.TestSetting.IsDouble()) { return; } var wl = specItem.TestSetting.CastTo(1550D); var names = specItem.ItemName.Split(":"); var name = names.Length > 1 ? names[1] : names[0]; names = name.Split("@"); name = names[0]; var setting = TestPortSetting.Get(specItem.PortSetting); if (setting.ChannelID < 1 && name == "UL") { name = "IL"; } if (!dgvResult.Columns.Contains(name)) { dgvResult.Columns.Add(name, name); dgvResult.Columns[name].SortMode = DataGridViewColumnSortMode.NotSortable; } foreach (DataGridViewRow dataRow in dgvResult.Rows) { if (dataRow.Cells["Wavelength"].Value.ToString() == wl.ToString("F3") && dataRow.Cells["Port"].Value.ToString() == specItem.PortSetting.ToString()) { resultInfo.ResultViewCell = dataRow.Cells[name]; } } }
public SpreadsheetStreamTokenizer(TextReader stream, OperatorManager operatorManager = null) { _charReader = new StreamReaderWithPeekSupport(stream); OperatorManager = operatorManager ?? OperatorManager.Default; }
public Dictionary <int, ComputeSettingItem> GetSpec(int temp) { var result = new Dictionary <int, ComputeSettingItem>(); if (temp < 0 || temp > TempSetting.Length) { throw new Exception("温度设置错误"); } var tempString = TempSetting[temp]; if (string.IsNullOrEmpty(tempString)) { return(result); } if (cbNoCheck.Checked) { foreach (var resultitem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { var tbSpec = GetSpecTextBox(resultitem.ResultID, temp); result[resultitem.ResultID] = new ComputeSettingItem() { ComputeSign = "≥,≤", ComputeValue = "-10086,10086" }; } return(result); } foreach (var resultitem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { var tbSpec = GetSpecTextBox(resultitem.ResultID, temp); if (resultitem.ResultType == 1 && (tbSpec == null || string.IsNullOrEmpty(tbSpec.Text))) { return(new Dictionary <int, ComputeSettingItem>()); } var spec = cbSpec.SelectedValue; if (spec == null) { cbSpec.Focus(); throw new Exception("请选择计算符号"); } if (tbSpec != null && !string.IsNullOrEmpty(tbSpec.Text)) { var specCompute = OperatorManager.GetOperator(spec.ToString()); if (!specCompute.Validation(tbSpec.Text)) { tbSpec.Focus(); throw new Exception(string.Format("{0} 规格设置 {1} 格式错误,请检查。", BindingTestSystem.SystemName, tbSpec.Text)); } } result[resultitem.ResultID] = new ComputeSettingItem() { ComputeSign = spec.ToString(), ComputeValue = tbSpec == null ? "" : tbSpec.Text }; } return(result); }
private MeasurementTestResult Calculate(Guid specItemID, out WorkInfoSpecItem item) { item = MeasurementJob.SpecData.WorkInfoSpecItems.FirstOrDefault(q => q.SpecItemID == specItemID); if (item == null) { return(new MeasurementTestResult() { Result = -1, Message = "规格异常", Data = 0D }); } var testResult = MeasuringManager.Calculate( MeasurementJob.ReferenceData, TestData, item.SystemTypeID, item.TestGroupTestType, item.TestTemp, item.PortSetting, item.TestSetting ); if (testResult.Result < 1) { return(testResult); } if (testResult.Data == double.MinValue) { testResult.Result = -1; testResult.Message = "计算结果出错"; return(testResult); } testResult.Result = 0; foreach (var resultSetting in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult.OrderBy(q => q.ResultID)) { ComputeSettingItem computeItem = default(ComputeSettingItem); if (!item.ComputeSetting.TryGetValue(resultSetting.ResultID, out computeItem)) { testResult.Result = -1; testResult.Message = "规格判断标准设置错误"; return(testResult); } if (string.IsNullOrEmpty(computeItem.ComputeValue)) { continue; } if (OperatorManager.GetOperator(computeItem.ComputeSign).GetComputeResult(computeItem.ComputeValue, testResult.Data)) { testResult.Result = resultSetting.ResultID; testResult.Message = $"{item.ItemName} 通过"; } else { testResult.Message = "结果不符合规格"; } } return(testResult); }
public Control CreateControl(MetroWindow metroWindow, ClsLoginModel clsLogin, string menuId) { var control = new Control(); switch (menuId) { case "顶部菜单管理": control = new TopMenuManager(metroWindow, clsLogin, menuId); break; case "左侧菜单管理": control = new LeftMenuManager(metroWindow, clsLogin, menuId); break; case "功能组管理": control = new NavBarGroupManager(metroWindow, clsLogin, menuId); break; case "登陆主题设置": control = new LoginThemeManager(); break; case "权限管理": control = new RolesManager(metroWindow, clsLogin, menuId); break; case "用户管理": control = new UserManager(metroWindow, clsLogin, menuId); break; case "部门管理": control = new DeptManager(metroWindow, clsLogin, menuId); break; case "登陆日志管理": control = new LoginLogManager(metroWindow, clsLogin, menuId); break; case "操作员管理": control = new OperatorManager(metroWindow, clsLogin, menuId); break; case "公司信息设置": control = new CompanyEdit(clsLogin, menuId) { Owner = metroWindow }; break; case "修改密码": control = new ModifyPassword(clsLogin) { Owner = metroWindow }; break; case "系统初始化": control = new SystemInit(clsLogin) { Owner = metroWindow }; break; case "Banner 设置": control = new BannerManager(metroWindow, clsLogin, menuId); break; case "Banner 默认": control = new BannerDefault(metroWindow); break; } return(control); }
private void CreateTestItemsData(DataTable ds) { ds.Columns.Add("TestItemID", Type.GetType("System.String")); ds.Columns.Add("TestID", Type.GetType("System.String")); ds.Columns.Add("SystemID", Type.GetType("System.String")); ds.Columns.Add("ItemName", Type.GetType("System.String")); ds.Columns.Add("TestTemp", Type.GetType("System.String")); ds.Columns.Add("TestSetting", Type.GetType("System.String")); foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { ds.Columns.Add(string.Format("TestItemCompute{0}", resultItem.ResultID), Type.GetType("System.String")); } ds.Columns.Add("ItemValue", Type.GetType("System.String")); ds.Columns.Add("ItemResult", Type.GetType("System.String")); ds.Columns.Add("ItemResultString", Type.GetType("System.String")); ds.Columns.Add("OrderID", Type.GetType("System.String")); foreach (var testItem in testData.TestInfo.TestItems) { var row = ds.NewRow(); row["TestItemID"] = testItem.TestItemID; row["TestID"] = testItem.TestID; row["SystemID"] = testItem.SystemID; row["ItemName"] = testItem.ItemName; row["TestTemp"] = testItem.TestTemp; row["TestSetting"] = testItem.TestInfo; var computeSetting = testItem.ComputeSetting.FromJsonString <Dictionary <int, BusinessLogic.Model.ComputeSettingItem> >(); foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { if (!computeSetting.ContainsKey(resultItem.ResultID)) { row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = "N/A"; } else { var computeItem = computeSetting[resultItem.ResultID]; row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = string.IsNullOrEmpty(computeItem.ComputeValue) ? "未设置" : OperatorManager.GetOperator(computeItem.ComputeSign).GetDisplayString(computeItem.ComputeValue); } } row["ItemValue"] = testItem.ItemValue; row["ItemResult"] = testItem.ItemResult; row["ItemResultString"] = BaseSettingsManager.Get <ResultSettings>()[testItem.ItemResult].ResultText; row["OrderID"] = testItem.OrderID; ds.Rows.Add(row); } }
public void SetTestSystem(string[] temps, BusinessLogic.DomainModel.TestSystem testSystem) { TempSetting = temps; BindingTestSystem = testSystem; if (TempSetting == null || BindingTestSystem == null) { return; } gbPanel.Text = $"{BindingTestSystem.SystemName}设置"; if (BindingTestSystem.PortSetting > 0) { gbPanel.Text += $" (Port{BindingTestSystem.PortSetting})"; } else if (BindingTestSystem.PortSetting < 0) { gbPanel.Text += $" (In{-1 * BindingTestSystem.PortSetting})"; } cbSpec.ValueMember = "Key"; cbSpec.DisplayMember = "Value"; cbSpec.DataSource = new BindingCollection <KeyValuePair <string, string> >(OperatorManager.GetComputeDataSource()); cbSpec.Text = BindingTestSystem.DefaultComputeSign; //tbSetting.Text = BindingTestSystem.DefaultSetting; CreateTestSystemItemEditor(); }
public SpreadsheetStreamTokenizer(Stream stream, OperatorManager operatorManager = null) : this(new StreamReader(stream), operatorManager) { }
private void LoadSpecItems() { if (!this.IsNormalState()) { AppFramework.Context.ShowError("规格编辑窗体已经关闭"); return; } int index = 0; if (dgvSeq.SelectedRows.Count > 0) { index = dgvSeq.SelectedRows[0].Index; } dtSpecItem.Rows.Clear(); foreach (var item in specItems) { var testSystem = BaseSettingsManager.Get <SystemGroupSetting>().GetTestSystemItem(item.SystemID); if (testSystem == null) { continue; } var row = dtSpecItem.NewRow(); row["TestItemID"] = item.SpecItemID; row["TestItemName"] = item.ItemName; row["TestItemTemp"] = item.TestTemp; row["TestItemInfo"] = item.TestInfo; row["TestItemPort"] = testSystem.PortSetting; foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { var computeSetting = item.ComputeSetting.FromJsonString <Dictionary <int, ComputeSettingItem> >(); if (!computeSetting.ContainsKey(resultItem.ResultID)) { row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = "N/A"; } else { var computeItem = computeSetting[resultItem.ResultID]; row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = string.IsNullOrEmpty(computeItem.ComputeValue) ? "未设置" : OperatorManager.GetOperator(computeItem.ComputeSign).GetDisplayString(computeItem.ComputeValue); } } row["TestItemOrder"] = item.OrderID; dtSpecItem.Rows.Add(row); } if (dgvSeq.Rows.Count > 0) { if (index >= dgvSeq.Rows.Count) { index = dgvSeq.Rows.Count - 1; } dgvSeq.CurrentCell = dgvSeq.Rows[index].Cells[3]; } }