public void PerformQuery_AsteriksSymbolWithCondition_ShouldReturnValidRecords(string query) { var database = new Database(); new CreateService(database).PerformQuery("CREATE TABLE users (email text, phoneNumber int, isAdult boolean);"); new InsertService(database).PerformQuery("INSERT INTO users (email, phoneNumber, isAdult) VALUES (\"[email protected]\", 703503, true);"); new InsertService(database).PerformQuery("INSERT INTO users (isAdult, email, phoneNumber ) VALUES (false, \"[email protected]\", 141505);"); var actual = new SelectService(database).PerformQuery(query); var expected = new Models.Table.Record[] { new Models.Table.Record(new List <string>() { "email", "phoneNumber", "isAdult" }, new List <object>() { "*****@*****.**", 703503, true }) }; for (var i = 0; i < actual.Length; i++) { Assert.Equal(actual[0].ColumnNames, expected[0].ColumnNames); Assert.Equal(actual[0].Values, expected[0].Values); } }
public async Task <IActionResult> GET() { using (SqlConnection conn = Connection) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = @" SELECT Id, Service FROM Services" ; SqlDataReader reader = cmd.ExecuteReader(); var services = new List <SelectService>(); while (reader.Read()) { var service = new SelectService { Id = reader.GetInt32(reader.GetOrdinal("Id")), Service = reader.GetString(reader.GetOrdinal("Service")) }; services.Add(service); } reader.Close(); return(Ok(services)); } } }
private bool SelectService() { bool result; try { this.btnCancel.IsEnabled = false; this.btnNext.IsEnabled = false; base.IsEnabled = false; AGSConnection aGSConnection = this.lbConnections.SelectedItem as AGSConnection; if (aGSConnection.ConnectionFailed) { this.RefreshConnection(aGSConnection); } if (!aGSConnection.ConnectionFailed) { if (this.PopulateConnection(aGSConnection)) { base.Close(); SelectService selectService = new SelectService(aGSConnection); if (selectService.IsValid) { this.ClearProgressBar(); Application.ShowModelessWindow(selectService); base.Close(); result = true; return(result); } } else { this.btnCancel.IsEnabled = true; this.btnNext.IsEnabled = true; base.IsEnabled = true; SelectConnection.WindowOpen = false; string text = aGSConnection.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = "Populating Connection failed"; } ErrorReport.ShowErrorMessage(text); aGSConnection.ErrorMessage = ""; } } result = false; } catch { result = false; } return(result); }
/// <summary> /// 重置面板 /// </summary> internal void reset() { Children.Clear(); flowList.Clear(); //m_Connection.Clear(); m_Leftest_X = float.Epsilon; m_LstEntrys.Clear(); m_LstNodes.Clear(); m_Nodes.Clear(); pointList.Clear(); SerialNumber.Clear(); SelectedItems.Clear(); SelectService.ClearSelection(); m_LayOutCount = 0; value = 0; }
/// <summary> /// 鼠标按下的事件 /// </summary> /// <param name="e"></param> protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (e.Source == this) { this.Focus(); //获取鼠标在容器点击的位置坐标 this.rubberbandSelectionStartPoint = new Point?(e.GetPosition(this)); SelectService.ClearSelection(); //如果直接点击画布,取消选中的元素 foreach (ISelectable item in SelectedItems) { item.IsSelected = false; } selectedItems.Clear(); } e.Handled = true; }
/// <summary> /// 删除当前选中集合 /// </summary> public void Delete() { foreach (DesignerItem item in SelectService.CurrentSelection.OfType <DesignerItem>()) { if (item.CurrentSerialNumber == "0") { MessageBox.Show("不能删除头结点,请使用清空"); item.IsSelected = false; SelectedItems.Clear(); SelectService.ClearSelection(); return; } var result = true; var cd = item.Template.FindName("PART_ConnectorDecorator", item) as Control; var connectors = new List <Connector>(); GetConnectors(cd, connectors); foreach (Connector connector in connectors) { if (result) { foreach (Connection con in connector.Connections) { this.Children.Remove(con); } } } if (result) { this.Children.Remove(item); } } foreach (Connection connection in SelectService.CurrentSelection.OfType <Connection>()) { this.Children.Remove(connection); } SelectService.ClearSelection(); UpdateZIndex(); }
/// <summary> /// 键盘按键触发的事件 /// </summary> /// <param name="e"></param> protected override void OnPreviewKeyDown(KeyEventArgs e) { base.OnPreviewKeyDown(e); if (e.Key == Key.Delete) { MessageBoxResult result = MessageBox.Show("确认删除选中的组件吗?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { if (SelectService.CurrentSelection.Count < 1) { this.SelectedItems.ForEach(x => { SelectService.AddToSelection(x); }); } this.Delete(); } } if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.A) { this.SelectAll(); } e.Handled = false; }
private void Next_Click(object sender, RoutedEventArgs e) { base.Visibility = Visibility.Collapsed; this.tbServerName.Text = AGSConnection.FixName(this.tbServerName.Text); AGSConnection aGSConnection = null; try { aGSConnection = new AGSConnection(this.tbServerName.Text, this.tbServerURL.Text); } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorConnectingToServer); base.Visibility = Visibility.Visible; this.Succeeded = false; } if (aGSConnection != null && !aGSConnection.ConnectionFailed) { aGSConnection.UserName = this.tbUserName.Text; aGSConnection.Password = this.tbPassword.Password; Mouse.OverrideCursor = Cursors.Wait; if (!aGSConnection.LoadConnectionProperties()) { Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(aGSConnection.ErrorMessage); base.Visibility = Visibility.Visible; this.Succeeded = false; return; } Mouse.OverrideCursor = null; base.Close(); Mouse.OverrideCursor = Cursors.Wait; if (!aGSConnection.LoadChildren()) { Mouse.OverrideCursor = null; string text = aGSConnection.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = AfaStrings.ErrorConnectingToServer; } ErrorReport.ShowErrorMessage(text); return; } Mouse.OverrideCursor = null; if (aGSConnection.FoldersLoaded && !aGSConnection.ConnectionFailed) { this.Succeeded = true; aGSConnection.SaveToFile(); App.Connections.Add(aGSConnection); SelectService selectService = new SelectService(aGSConnection); if (selectService.IsValid) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowModalWindow(selectService); if (selectService.DialogResult.HasValue) { bool arg_165_0 = selectService.DialogResult.Value; } } } } }
/// <summary> /// 打开流程 /// </summary> /// <param name="tradeFlowListEntity">交易流程实体层</param> /// <param name="typeList">组件类型列表</param> /// <param name="subRelListEntity">映射关系实体层</param> public void Open(List <T_plt_tradeFlowEntity> tradeFlowListEntity, List <Label> typeList, List <T_plt_subrelEntity> subRelListEntity) { #region 初始化 flowList = new List <TradeFlow>(); //流程实例列表 var sublist = new List <SubRel>(); //参数关系列表 //List<string> connectionOverList = new List<string>();//零时序号列表 if (SerialNumber != null) { SerialNumber.Clear(); //清空序号 } Children.Clear(); //清空画布 SelectService.ClearSelection(); //清空画布引用关系 #endregion #region 实体转换 if (tradeFlowListEntity != null) { if (tradeFlowListEntity.Count() > 0) { tradeFlowListEntity.ForEach(x5 => { var flow = new TradeFlow(); flow.TradeCode = x5.TxCode.Trim(); flow.CompCode = x5.CompCode.Trim(); flow.Trade_Flow = x5.TradeFlow.Trim(); flow.FlowCode = x5.FlowCode.Trim(); flowList.Add(flow); }); } } if (subRelListEntity != null) { if (subRelListEntity.Count() > 0) { subRelListEntity.ForEach(x => { var rel = new SubRel(); rel.TradeCode = x.tx_code.Trim(); rel.CompCode = x.comp_code.Trim(); rel.OutData = x.out_data.Trim(); rel.InType = x.in_data_type.Trim() == "1"?TypeOpt.常量:TypeOpt.表达式; rel.InData = x.in_data.Trim(); rel.Memo = x.memo.Trim(); rel.SerialNumber = x.flow_no.Trim(); sublist.Add(rel); }); } } #endregion if (flowList.Count() < 1) { return; //如果不存在交易流程,返回 } #region item和线的处理 LayOut();//对容器的元素进行布局 var i = 0; foreach (Tx_Node node in m_LstNodes) { SerialNumber.Add(Convert.ToInt32(node.Flow_code)); //组件 var lbl = typeList.Where(z => z.Tag.ToString().Trim() == node.Component_code.Trim()).FirstOrDefault(); if (lbl != null) { var tmp = new List <SubRel>(); sublist.ForEach(x => { if (x.SerialNumber == node.Flow_code) { tmp.Add(x); } }); var item = DeserializeDesignerItem(TradeCode, node.Flow_code, node.X, node.Y, lbl, m_Connection[node.Component_code], tmp); if (!string.IsNullOrWhiteSpace(node.Sub_tx_code.Trim())) { item.IsDragConnectionOver = true; } Canvas.SetZIndex(item, 1); this.Children.Add(item); ControlTemplate template = DesignerItem.GetConnectorDecoratorTemplate(item) as ControlTemplate; DesignerItem.SetConnectorDecoratorTemplate(item, template); } i++; } this.InvalidateVisual();//使元素的呈现无效,并强制执行完整的新布局处理过程。布局循环完成后 if (m_LstEntrys == null) { return; } foreach (Tx_Entry entry in m_LstEntrys) { string sourceID = entry.StartNode; string sinkID = entry.EndNode; if (!string.IsNullOrEmpty(sinkID) && !string.IsNullOrEmpty(sourceID)) { var sourceConnector = GetConnector(sourceID, 6); var sinkConnector = GetConnector(sinkID, 2); var connection = new Connection(sourceConnector, sinkConnector, entry.Condition, entry.ConditionList); Canvas.SetZIndex(connection, 2); this.Children.Add(connection); } } #endregion //value = SerialNumber.OrderByDescending(x2 => x2).FirstOrDefault() + 1;//出 UpdateZIndex(); }