/// <summary> /// 添加成员到结果表格 /// </summary> /// <param name="staffs">成员</param> public void AddToResultGrid(List <StaffInfo> staffs) { Dictionary <String, String> existsIds = new Dictionary <String, String>(); List <GridRow> rows = m_gridResult.GetRows(); int rowSize = rows.Count; for (int i = 0; i < rowSize; i++) { GridRow row = rows[i]; String id = row.GetCell(0).GetString(); existsIds[id] = ""; } int staffsSize = staffs.Count; m_gridResult.BeginUpdate(); for (int i = 0; i < staffsSize; i++) { StaffInfo staff = staffs[i]; if (!existsIds.ContainsKey(staff.m_jobID)) { GridRow row = new GridRow(); m_gridResult.AddRow(row); row.AddCell(0, new GridStringCell(staff.m_jobID)); row.AddCell(1, new GridStringCell(staff.m_name)); existsIds[staff.m_jobID] = ""; } } m_gridResult.EndUpdate(); m_gridResult.Invalidate(); }
/// <summary> /// 增加证券到表格中 /// </summary> /// <param name="securities">证券列表</param> public void AddSecuritiesToSecuritiesGrid(List <Security> securities) { Dictionary <String, String> existsCodes = new Dictionary <String, String>(); List <GridRow> rows = m_gridSecurities.GetRows(); int rowSize = rows.Count; for (int i = 0; i < rowSize; i++) { GridRow row = rows[i]; String code = row.GetCell(0).GetString(); existsCodes[code] = ""; } int securitiesSize = securities.Count; m_gridSecurities.BeginUpdate(); for (int i = 0; i < securitiesSize; i++) { Security security = securities[i]; if (!existsCodes.ContainsKey(security.m_code)) { GridRow row = new GridRow(); m_gridSecurities.AddRow(row); row.AddCell(0, new GridStringCell(security.m_code)); row.AddCell(1, new GridStringCell(security.m_name)); existsCodes[security.m_code] = ""; } } m_gridSecurities.EndUpdate(); m_gridSecurities.Invalidate(); }
/// <summary> /// 从表格中移除类别 /// </summary> /// <param name="categories">类别</param> public void RemoveCategoriesFromCategoryGrid(List <UserSecurityCategory> categories) { if (m_gridCategory.EditTextBox != null) { m_gridCategory.OnCellEditEnd(null); } m_gridCategory.BeginUpdate(); Dictionary <String, String> removeKeys = new Dictionary <String, String>(); int categoriesSize = categories.Count; for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory category = categories[i]; removeKeys[category.m_categoryID] = ""; } int rowSize = m_gridCategory.GetRows().Count; for (int i = 0; i < rowSize; i++) { GridRow row = m_gridCategory.GetRow(i); String categoryID = row.GetCell(0).GetString(); if (removeKeys.ContainsKey(categoryID)) { m_gridCategory.RemoveRow(row); row.ClearCells(); row.Dispose(); rowSize--; i--; } } removeKeys.Clear(); m_gridCategory.EndUpdate(); m_gridCategory.Invalidate(); }
/// <summary> /// 删除服务器 /// </summary> private void DeleteServer() { List <GridRow> selectedRows = m_gridServers.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { GridRow row = selectedRows[0]; m_serverService.DeleteServer(row.GetCell(0).Text); m_gridServers.RemoveRow(row); row.Dispose(); List <GridRow> rows = m_gridServers.GetRows(); int rowsSize = rows.Count; if (rowsSize > 0) { selectedRows = new List <GridRow>(); selectedRows.Add(m_gridServers.GetRow(rowsSize - 1)); m_gridServers.SelectedRows = selectedRows; } m_gridServers.Update(); m_gridServers.Update(); BindServersToComboBox(); m_window.Invalidate(); } }
/// <summary> /// 获取表格数据 /// </summary> /// <param name="grid">表格</param> /// <returns>流</returns> public byte[] GetBytes(GridA grid) { Binary br = new Binary(); br.WriteString(grid.Name); List <GridColumn> columns = grid.GetColumns(); int columnsSize = columns.Count; br.WriteInt(columnsSize); for (int i = 0; i < columnsSize; i++) { GridColumn column = columns[i]; br.WriteString(column.Name); br.WriteString(column.ColumnType); } List <GridRow> rows = grid.GetRows(); int rowsCount = rows.Count; br.WriteInt(rowsCount); for (int i = 0; i < rowsCount; i++) { GridRow row = rows[i]; for (int j = 0; j < columnsSize; j++) { GridColumn column = columns[j]; String columnType = column.ColumnType.ToLower(); GridCell cell = row.GetCell(j); if (columnType == "bool") { br.WriteBool(cell.GetBool()); } else if (columnType == "double") { br.WriteDouble(cell.GetDouble()); } else if (columnType == "float") { br.WriteFloat(cell.GetFloat()); } else if (columnType == "int") { br.WriteInt(cell.GetInt()); } else if (columnType == "long") { br.WriteDouble(cell.GetLong()); } else if (columnType == "string") { br.WriteString(cell.GetString()); } } } byte[] bytes = br.GetBytes(); br.Close(); return(bytes); }
/// <summary> /// 获取模板行的哈希表 /// </summary> /// <returns>哈希表</returns> private Dictionary <String, GridRow> GetTemplateRows() { Dictionary <String, GridRow> templateRowsMap = new Dictionary <String, GridRow>(); List <GridRow> rows = m_gridTemplate.GetRows(); int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { GridRow row = rows[i]; templateRowsMap[row.GetCell(0).Text] = row; } return(templateRowsMap); }
/// <summary> /// 获取布局行的哈希表 /// </summary> /// <returns>哈希表</returns> private Dictionary <String, GridRow> GetIndicatorLayoutsRows() { Dictionary <String, GridRow> ilRowsMap = new Dictionary <String, GridRow>(); List <GridRow> rows = m_gridLayouts.GetRows(); int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { GridRow row = rows[i]; ilRowsMap[row.GetCell(0).Text] = row; } return(ilRowsMap); }
/// <summary> /// 获取宏行的哈希表 /// </summary> /// <returns>哈希表</returns> private Dictionary <String, GridRow> GetMacroRows() { Dictionary <String, GridRow> mRowsMap = new Dictionary <String, GridRow>(); List <GridRow> rows = m_gridMacros.GetRows(); int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { GridRow row = rows[i]; mRowsMap[row.GetCell(0).Text] = row; } return(mRowsMap); }
/// <summary> /// 选中全部 /// </summary> public void SelectAll() { List <GridRow> rows = m_gridStaffs.GetRows(); int rowSize = rows.Count; if (rowSize > 0) { List <StaffInfo> staffs = new List <StaffInfo>(); for (int i = 0; i < rowSize; i++) { GridRow row = rows[i]; staffs.Add(DataCenter.StaffService.GetStaff(row.GetCell(0).GetString())); } AddToResultGrid(staffs); } }
/// <summary> /// 全选股票 /// </summary> public void SelectAllSecurities() { List <GridRow> rows = m_gridSelectSecurities.GetRows(); int rowSize = rows.Count; if (rowSize > 0) { List <Security> securities = new List <Security>(); for (int i = 0; i < rowSize; i++) { GridRow row = rows[i]; Security security = new Security(); if (m_securityService.GetSecurityByCode(row.GetCell(0).GetString(), ref security)) { securities.Add(security); } } AddSecuritiesToSecuritiesGrid(securities); } }
/// <summary> /// 点击按钮方法 /// </summary> /// <param name="sender">调用者</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="click">点击次数</param> /// <param name="delta">滚轮滚动值</param> private void ClickButton(object sender, POINT mp, MouseButtonsA button, int click, int delta) { if (button == MouseButtonsA.Left && click == 1) { ControlA control = sender as ControlA; String name = control.Name; if (name == "btnAdd") { ShowFilterWindow(); } if (name == "btnSubmit") { List <GridRow> rows = m_searchTable.GetRows(); int count = rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { GridRow gridrow = rows[i]; //拿到表达式 List <GridCell> cells = gridrow.GetCells(); int cellsCount = cells.Count; String[] expressions = cells[1].Text.Split(' '); List <Expression> exp = new List <Expression>(); Expression exps = new Expression(expressions[0], expressions[1], expressions[2]); exp.Add(exps); m_expressionChanged(exp); } } } if (name == "btnDel") { DeleteRow(); } if (name == "btnClose") { CloseWindow(); } } }
/// <summary> /// 刷新数据 /// </summary> public void Renovate() { //从服务端拿取数据 m_jiras = XmlHandle.GetJiras(); int count = m_jiras.Count; //创建Dictionary存放ID和数据 Dictionary <String, Jira> jiraIDs = new Dictionary <String, Jira>(); //遍历服务器的数据 for (int i = 0; i < count; i++) { Jira jira = m_jiras[i]; jiraIDs.Add(jira.JiraID, jira); } //获取表格所有行 List <GridRow> rows = m_gridDgvTable.GetRows(); int rowsCount = rows.Count; Dictionary <String, GridRow> gridRows = new Dictionary <String, GridRow>(); //遍历表格的数据 for (int i = 0; i < rowsCount; i++) { GridRow row = rows[i]; //取ID String id = row.GetCell("colT1").Text; //依据ID判断 if (!jiraIDs.ContainsKey(id)) { //ID不匹配删除行 m_gridDgvTable.RemoveRow(row); rowsCount--; i--; } else { //匹配则加到Dictionary gridRows.Add(id, row); } } m_gridDgvTable.Update(); m_gridDgvTable.BeginUpdate(); for (int i = 0; i < count; i++) { //遍历服务器数据 Jira jira = m_jiras[i]; bool newData = false; String key = jira.JiraID; GridRow row; if (gridRows.ContainsKey(key)) { row = gridRows[key]; } else { newData = true; row = new GridRow(); //row.Grid = m_gridDgvTable; //m_gridDgvTable.m_rows.Add(row); //row.OnAdd(); m_gridDgvTable.AddRow(row); } //遍历columns List <GridColumn> columns = m_gridDgvTable.GetColumns(); int countColumn = columns.Count; for (int j = 0; j < countColumn; j++) { GridColumn column = columns[j]; GridCell cell; if (newData) { cell = new GridCellExp(); row.AddCell(column.Index, cell); cell.Column = column; } else { cell = row.GetCell(column.Index); } DateTime dt = DateTime.Now; String status = jira.EndDate.ToFileTime() > dt.ToFileTime() ? "(超时)" : "(正常)"; int countGroup = XmlHandle.Groups.Count; switch (j) { case 0: GridCellStyle gridStyle1 = new GridCellStyle(); gridStyle1.BackColor = COLOR.DISABLEDCONTROL; gridStyle1.ForeColor = COLOR.ARGB(255, 255, 255); cell.Text = jira.JiraID; cell.Style = gridStyle1; //colT1 break; case 1: GridCellStyle gridStyle2 = new GridCellStyle(); gridStyle2.BackColor = COLOR.DISABLEDCONTROL; gridStyle2.ForeColor = COLOR.ARGB(45, 142, 45); cell.Text = jira.Title; cell.Style = gridStyle2; break; case 2: GridCellStyle gridStyle3 = new GridCellStyle(); gridStyle3.BackColor = COLOR.DISABLEDCONTROL; gridStyle3.ForeColor = COLOR.ARGB(47, 145, 145); cell.Text = jira.Creater; cell.Style = gridStyle3; break; case 3: GridCellStyle gridStyle4 = new GridCellStyle(); gridStyle4.BackColor = COLOR.DISABLEDCONTROL; gridStyle4.ForeColor = COLOR.ARGB(47, 145, 145);; cell.Style = gridStyle4; cell.Text = jira.Developer; break; case 4: { for (int m = 0; m < countGroup; m++) { if (XmlHandle.Groups[m].Id == jira.GroupID) { GridCellStyle gridStyle5 = new GridCellStyle(); gridStyle5.BackColor = COLOR.DISABLEDCONTROL; gridStyle5.ForeColor = COLOR.ARGB(47, 145, 145); cell.Style = gridStyle5; cell.Text = XmlHandle.Groups[m].Name; break; } } break; } case 5: { for (int m = 0; m < countGroup; m++) { if (XmlHandle.Groups[m].Id == jira.GroupID) { GridCellStyle gridStyle6 = new GridCellStyle(); gridStyle6.BackColor = COLOR.DISABLEDCONTROL; gridStyle6.ForeColor = COLOR.ARGB(255, 153, 153); cell.Style = gridStyle6; cell.Text = XmlHandle.Groups[m].Manager; break; } } break; } case 6: { for (int m = 0; m < countGroup; m++) { if (XmlHandle.Groups[m].Id == jira.GroupID) { List <JCategory> categories = XmlHandle.Groups[m].Categories; int cateCount = categories.Count; for (int n = 0; n < cateCount; n++) { if (categories[n].Id == jira.CategoryID) { GridCellStyle gridStyle7 = new GridCellStyle(); gridStyle7.BackColor = COLOR.DISABLEDCONTROL; gridStyle7.ForeColor = COLOR.ARGB(45, 142, 45); cell.Style = gridStyle7; cell.Text = categories[n].Name; break; } } break; } } break; } case 7: cell.Text = jira.DeveloperReceive ? "是" : "否"; GridCellStyle gridStyle8 = new GridCellStyle(); gridStyle8.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle8.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle8.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle8; break; case 8: cell.Text = jira.DeveloperPass ? "是" : "否"; GridCellStyle gridStyle9 = new GridCellStyle(); gridStyle9.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle9.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle9.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle9; break; case 9: cell.Text = jira.TestPass ? "是" : "否"; GridCellStyle gridStyle10 = new GridCellStyle(); gridStyle10.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle10.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle10.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle10; break; case 10: cell.Text = jira.ProductPass ? "是" : "否"; GridCellStyle gridStyle11 = new GridCellStyle(); gridStyle11.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle11.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle11.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle11; break; case 11: cell.Text = jira.WaitPublish ? "是" : "否"; GridCellStyle gridStyle12 = new GridCellStyle(); gridStyle12.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle12.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle12.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle12; break; case 12: cell.Text = jira.Published ? "是" : "否"; GridCellStyle gridStyle13 = new GridCellStyle(); gridStyle13.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle13.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle13.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle13; break; case 13: cell.Text = jira.CloseTask ? "是" : "否"; GridCellStyle gridStyle14 = new GridCellStyle(); gridStyle14.ForeColor = COLOR.ARGB(255, 255, 255); if (cell.Text == "是") { gridStyle14.BackColor = COLOR.ARGB(93, 146, 202); } else { gridStyle14.BackColor = COLOR.ARGB(163, 5, 50); } cell.Style = gridStyle14; break; case 14: cell.Text = jira.Hurry; GridCellStyle gridStyle15 = new GridCellStyle(); gridStyle15.BackColor = COLOR.ARGB(0, 0, 0); if (cell.Text == "紧急") { gridStyle15.ForeColor = COLOR.ARGB(163, 5, 50); } else { gridStyle15.ForeColor = COLOR.ARGB(227, 171, 26); } cell.Style = gridStyle15; break; case 15: GridCellStyle gridStyle16 = new GridCellStyle(); GridCell cell16 = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString()); cell.Text = cell16.Text; gridStyle16.ForeColor = COLOR.ARGB(255, 255, 0); cell.Style = gridStyle16; break; case 16: GridCellStyle gridStyle17 = new GridCellStyle(); GridCell cell17 = new GridCellExp(status + jira.StartDate.ToLongDateString().ToString()); cell.Text = cell17.Text; gridStyle17.ForeColor = COLOR.ARGB(255, 255, 0); cell.Style = gridStyle17; break; } } } m_gridDgvTable.EndUpdate(); m_gridDgvTable.Invalidate(); }
/// <summary> /// 定时检查 /// </summary> public void Check() { m_planService.OnTimer(); Dictionary <int, GridColumn> columnsIndex = new Dictionary <int, GridColumn>(); List <GridColumn> columns = m_gridPlan.GetColumns(); int columnsSize = columns.Count; for (int i = 0; i < columnsSize; i++) { GridColumn column = columns[i]; columnsIndex[CStr.ConvertStrToInt(column.Name.Substring(4))] = column; } Dictionary <String, String> pids = new Dictionary <String, String>(); List <CPlan> plans = new List <CPlan>(); DataCenter.PlanService.GetPlans(plans); int plansSize = plans.Count; for (int i = 0; i < plansSize; i++) { pids[plans[i].m_id] = ""; } GridRow selectedRow = null; Dictionary <String, GridRow> rowsMap = new Dictionary <String, GridRow>(); List <GridRow> rows = m_gridPlan.GetRows(); int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { GridRow row = rows[i]; String id = ""; if (row.GetCell("colP1") != null) { id = row.GetCell("colP1").GetString(); } if (pids.ContainsKey(id)) { rowsMap[id] = row; } else { m_gridPlan.RemoveRow(row); row.Dispose(); rowsSize--; i--; } } m_gridPlan.Update(); m_gridPlan.BeginUpdate(); for (int i = 0; i < plansSize; i++) { CPlan plan = plans[i]; GridRow row = null; bool newData = false; if (rowsMap.ContainsKey(plan.m_id)) { row = rowsMap[plan.m_id]; } else { row = new GridRow(); row.Height = 50; selectedRow = row; m_gridPlan.AddRow(row); newData = true; } foreach (int col in columnsIndex.Keys) { GridCell cell = null; GridColumn column = columnsIndex[col]; if (newData) { if (col == 5) { GridProgressCell progressCell = new GridProgressCell(); cell = progressCell; row.AddCell(column.Index, cell); } else { cell = new GridStringCell(); if (col == 3) { cell.AllowEdit = true; } row.AddCell(column.Index, cell); } } else { cell = row.GetCell(column.Index); } switch (col) { //ID case 1: cell.SetString(plan.m_id); break; //名称 case 2: cell.SetString(plan.m_name); break; //进程 case 3: cell.SetString(plan.m_command); break; //状态 case 4: cell.SetString(plan.m_status); GridCellStyle cellStyle = new GridCellStyle(); if (plan.m_status == "启动") { cellStyle.ForeColor = CDraw.GetPriceColor(1, 2); } else if (plan.m_status == "禁用") { cellStyle.ForeColor = CDraw.GetPriceColor(2, 1); } cell.Style = cellStyle; break; //下次执行时间 case 5: GridProgressCell progressCell = cell as GridProgressCell; if (plan.m_nextTime != 0) { DateTime nowDate = DateTime.Now; long span = (long)plan.m_timeSpan * 1000 * 10000; double rate = 100 - 100 * (plan.m_nextTime - nowDate.Ticks) / span; if (rate < 0) { rate = 100 - 100 * (double)(plan.m_nextTime - nowDate.Ticks) / (plan.m_nextTime - plan.m_createTime); } progressCell.Rate = rate; } else { progressCell.Rate = 0; } cell.SetString(new DateTime(plan.m_nextTime).ToString()); break; //上次执行时间 case 6: cell.SetString(new DateTime(plan.m_lastTime).ToString()); break; //上次结果 case 7: cell.SetString(plan.m_lastResult); break; //间隔 case 8: cell.SetString(plan.m_timeSpan.ToString()); break; //创建时间 case 9: cell.SetString(new DateTime(plan.m_createTime).ToString()); break; //相关人员 case 10: cell.SetString(plan.m_member); break; } } } //修正选中行 if (selectedRow != null) { List <GridRow> selectedRows = new List <GridRow>(); selectedRows.Add(selectedRow); m_gridPlan.SelectedRows = selectedRows; } m_gridPlan.EndUpdate(); Native.Invalidate(); columnsIndex.Clear(); pids.Clear(); plans.Clear(); }