public void AddOrEditWatcherEntry(DateTime timestamp, WatcherChangeTypes changeType, string path) { long id = ComputeGroupId(timestamp); if (CurrentGroup == null || id != CurrentGroup.Id) { CurrentGroup = new WatcherEntryGroup(id, timestamp); if (!this.GroupDict.ContainsKey(id)) { GroupDict.Add(id, CurrentGroup); } } CurrentGroup.AddOrEditWatcherEntry(changeType, path); }
GroupDict getInterlockGroups() { GroupDict Groups = new GroupDict(); List <IMyDoor> Doors = new List <IMyDoor>(); GridTerminalSystem.GetBlocksOfType <IMyDoor>(Doors, (d => d.CubeGrid.Equals(Me.CubeGrid) && TAG.IsMatch(d.CustomName))); foreach (IMyDoor Door in Doors) { string groupName = TAG.Match(Door.CustomName)?.Groups[1]?.Value; if (groupName != null) { Groups.Add(groupName, Door); } } return(Groups); }
/// <summary> /// 道がつながっているかどうかグループ分けする. /// </summary> /// <returns>The group.</returns> /// <param name="nodeMap">Node map.</param> /// <param name="group">Group.</param> public static int Group(NodeMap nodeMap, out GroupDict group) { var groupId = 0; var keys = nodeMap.nodeMap.Keys.ToArray(); group = new GroupDict(keys.Length); for (int i = 0; i < keys.Length; i++) { var key = keys[i]; if (!group.ContainsKey(key)) { Paint(nodeMap, group, key, groupId); groupId++; } } return(groupId); }
private static void Paint(NodeMap nodeMap, GroupDict costDict, string startKey, int paintId) { costDict[startKey] = paintId; var stack = new List <string>(); stack.Add(startKey); while (stack.Count != 0) { var key = stack[0]; var graph = nodeMap.nodeMap[key].Graph; foreach (var obj in graph) { if (!costDict.ContainsKey(obj)) { costDict[obj] = paintId; stack.Add(obj); } } stack.RemoveAt(0); } }
private void Button_Search_Click(object sender, RoutedEventArgs e) { this.NotUseCount = 0; int tradeDataType = int.Parse((cbTodayType.SelectedItem as ComboBoxItem).DataContext.ToString()); bool isCheckPort = this.ckbIsCheckPort.IsChecked == true; var group = cmbGroup.SelectedItem as string; if (!string.IsNullOrEmpty(group) && GroupDict.ContainsKey(group)) { this.loading.Visibility = Visibility.Visible; var action = new Action(() => { try { var o = Cryptor.MD5Decrypt(GroupDict[group]).FromJson <券商>(); if (o != null) { DateTime dt1 = DateTime.Now; DataTable dt = DataAdapter.QueryTradeData(o, tradeDataType, isCheckPort); var span = DateTime.Now - dt1; var s = span.TotalSeconds; if (dt != null && dictDataColumn != null && dictDataColumn.ContainsKey(tradeDataType.ToString())) { CommonUtils.Log(string.Format("交易接口查询耗时记录, 交易类型 {0}, 耗时 {1}", tradeDataType, s)); var list = dictDataColumn[tradeDataType.ToString()]; //if ("FCAA14B3008F 005056C00001 005056C00008".IndexOf(CommonUtils.GetMac()) > -1 && CommonUtils.GetCpuID() == "BFEBFBFF000306C3") if (tradeDataType != 0 && tradeDataType != 6) { for (int i = dt.Columns.Count - 1; i > -1; i--) { if (!list.Contains(dt.Columns[i].ColumnName)) { dt.Columns.RemoveAt(i); } } } if (tradeDataType == 2 && dt.Columns.Contains("买卖标志") && dt.Rows.Count > 0 && Regex.IsMatch(dt.Rows[0]["买卖标志"] + "", "^[01]+$")) { foreach (DataRow row in dt.Rows) { row["买卖标志"] = GetBuySaleInfo(row["买卖标志"] + ""); } } if (tradeDataType == 1) { AddPosition(isCheckPort, o, dt); } } this.QueryData = dt; } } catch (Exception ex) { this.Dispatcher.ShowMsg(ex.Message); } }); var completeAction = new Action(() => { if (QueryData == null) { dgMain.ItemsSource = null; } else { //dgMain.AutoGenerateColumns = false; dgMain.ItemsSource = QueryData.DefaultView; } this.loading.Visibility = Visibility.Collapsed; }); this.Dispatcher.RunAsync(action, null, null, completeAction); } }