Beispiel #1
0
 /// <summary>
 /// 添加指标列
 /// </summary>
 private void AddIndicatorColumns()
 {
     if (m_task != null)
     {
         m_gridFilterResult.BeginUpdate();
         CIndicator indicator = m_task.Indicator;
         foreach (String name in indicator.MainVariables.Keys)
         {
             GridColumn column = new GridColumn(name);
             column.Name      = name;
             column.TextAlign = ContentAlignmentA.MiddleRight;
             column.Width     = 80;
             m_gridFilterResult.AddColumn(column);
             if (name == "FILTER")
             {
                 column.Text = "符合条件";
             }
         }
         List <GridColumn> columns = m_gridFilterResult.GetColumns();
         int columnsSize           = columns.Count;
         for (int i = 0; i < columnsSize; i++)
         {
             GridColumn column = columns[i];
             column.AllowResize = true;
             column.BackColor   = CDraw.PCOLORS_BACKCOLOR4;
             column.BorderColor = COLOR.EMPTY;
             column.Font        = new FONT("SimSun", 14, false, false, false);
             column.ForeColor   = CDraw.PCOLORS_FORECOLOR7;
         }
         m_gridFilterResult.EndUpdate();
     }
 }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        /// <summary>
        /// 加载图标
        /// </summary>
        private void LoadIcons()
        {
            String dir = DataCenter.GetAppPath() + "\\config\\icons\\";

            m_gridIcons.ResourcePath = dir;
            List <String> files = new List <String>();

            CFileA.GetFiles(dir, files);
            int filesSize   = files.Count;
            int columnsSize = m_gridIcons.GetColumns().Count;

            m_gridIcons.BeginUpdate();
            GridRow row = null;

            for (int i = 0; i < filesSize; i++)
            {
                int col = i;
                if (i >= columnsSize)
                {
                    col = i % columnsSize;
                }
                if (col == 0)
                {
                    row        = new GridRow();
                    row.Height = 64;
                    m_gridIcons.AddRow(row);
                }
                String file = files[i];
                file = file.Substring(file.LastIndexOf('\\') + 1);
                GridIconCell iconCell = new GridIconCell();
                iconCell.SetString(file);
                row.AddCell(col, iconCell);
            }
            m_gridIcons.EndUpdate();
            m_gridIcons.Invalidate();
        }
Beispiel #4
0
        /// <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();
        }
Beispiel #5
0
        /// <summary>
        /// 获取表格
        /// </summary>
        /// <param name="bytes">流</param>
        /// <param name="native">方法库</param>
        /// <returns>表格</returns>
        public GridA GetGrid(byte[] bytes, INativeBase native)
        {
            Binary br = new Binary();

            br.Write(bytes, bytes.Length);
            GridA grid = new GridA();

            grid.Native = native;
            grid.Name   = br.ReadString();
            int columnsSize = br.ReadInt();

            for (int i = 0; i < columnsSize; i++)
            {
                GridColumn column = new GridColumn();
                column.Name       = br.ReadString();
                column.ColumnType = br.ReadString();
                grid.AddColumn(column);
            }
            grid.Update();
            List <GridColumn> columns = grid.GetColumns();
            int rowsCount             = br.ReadInt();

            for (int i = 0; i < rowsCount; i++)
            {
                GridRow row = new GridRow();
                grid.AddRow(row);
                for (int j = 0; j < columnsSize; j++)
                {
                    GridColumn column     = columns[j];
                    string     columnType = column.ColumnType.ToLower();
                    GridCell   cell       = null;
                    if (columnType == "bool")
                    {
                        cell = new GridBoolCell();
                        row.AddCell(j, cell);
                        cell.SetBool(br.ReadBool());
                    }
                    else if (columnType == "double")
                    {
                        cell = new GridDoubleCell();
                        row.AddCell(j, cell);
                        cell.SetDouble(br.ReadDouble());
                    }
                    else if (columnType == "float")
                    {
                        cell = new GridFloatCell();
                        row.AddCell(j, cell);
                        cell.SetFloat(br.ReadFloat());
                    }
                    else if (columnType == "int")
                    {
                        cell = new GridIntCell();
                        row.AddCell(j, cell);
                        cell.SetInt(br.ReadInt());
                    }
                    else if (columnType == "long")
                    {
                        cell = new GridLongCell();
                        row.AddCell(j, cell);
                        cell.SetLong((long)br.ReadDouble());
                    }
                    else if (columnType == "string")
                    {
                        cell = new GridStringCell();
                        row.AddCell(j, cell);
                        cell.SetString(br.ReadString());
                    }
                    else
                    {
                        cell = new GridStringCell();
                        row.AddCell(j, cell);
                        cell.SetString(br.ReadString());
                    }
                }
            }
            br.Close();
            return(grid);
        }
Beispiel #6
0
        /// <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();
        }