예제 #1
0
        /// <summary>
        /// 从表格中删除员工
        /// </summary>
        /// <param name="staffs">员工列表</param>
        public void RemoveFromResultGrid(List <StaffInfo> staffs)
        {
            Dictionary <String, StaffInfo> existsIds = new Dictionary <String, StaffInfo>();
            int staffsSize = staffs.Count;

            for (int i = 0; i < staffsSize; i++)
            {
                StaffInfo staff = staffs[i];
                existsIds[staff.m_jobID] = staff;
            }
            int rowSize = m_gridResult.GetRows().Count;

            m_gridResult.BeginUpdate();
            for (int i = 0; i < rowSize; i++)
            {
                GridRow   row       = m_gridResult.GetRow(i);
                StaffInfo staffInfo = DataCenter.StaffService.GetStaff(row.GetCell(0).GetString());
                if (existsIds.ContainsKey(staffInfo.m_jobID))
                {
                    m_gridResult.RemoveRow(row);
                    i--;
                    rowSize--;
                }
            }
            m_gridResult.EndUpdate();
            m_gridResult.Invalidate();
        }
예제 #2
0
        /// <summary>
        /// 从表格中删除证券
        /// </summary>
        /// <param name="securities">证券列表</param>
        public void RemoveSecuritiesFromSecuritiesGrid(List <Security> securities)
        {
            Dictionary <String, Security> existsCodes = new Dictionary <String, Security>();
            int securitiesSize = securities.Count;

            for (int i = 0; i < securitiesSize; i++)
            {
                Security security = securities[i];
                existsCodes[security.m_code] = security;
            }
            int rowSize = m_gridSecurities.GetRows().Count;

            m_gridSecurities.BeginUpdate();
            for (int i = 0; i < rowSize; i++)
            {
                GridRow  row      = m_gridSecurities.GetRow(i);
                Security security = new Security();
                if (m_securityService.GetSecurityByCode(row.GetCell(0).GetString(), ref security))
                {
                    if (existsCodes.ContainsKey(security.m_code))
                    {
                        m_gridSecurities.RemoveRow(row);
                        i--;
                        rowSize--;
                    }
                }
            }
            m_gridSecurities.EndUpdate();
            m_gridSecurities.Invalidate();
        }
예제 #3
0
        /// <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();
        }
예제 #4
0
        /// <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();
            }
        }
예제 #5
0
        /// <summary>
        /// 删除
        /// </summary>
        public void Delete()
        {
            List <GridRow> selectedRows     = m_gridExams.SelectedRows;
            int            selectedRowsSize = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                GridRow deleteRow = selectedRows[0];
                String  pID       = deleteRow.GetCell("colP1").GetString();
                DataCenter.ExamService.Delete(pID);
                m_gridExams.RemoveRow(deleteRow);
                m_gridExams.Update();
                m_gridExams.Invalidate();
            }
        }
예제 #6
0
 /// <summary>
 /// 删除选中行
 /// </summary>
 public void DeleteRow()
 {
     if (MessageBox.Show("是否删除?", "提示!", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         List <GridRow> rows          = m_searchTable.SelectedRows;
         int            selectRowSize = rows.Count;
         if (selectRowSize <= 0)
         {
             return;
         }
         m_searchTable.BeginUpdate();
         m_searchTable.RemoveRow(rows[0]);
         m_searchTable.EndUpdate();
         m_searchTable.Invalidate();
     }
 }
예제 #7
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage message = (CMessage)args;
            List <SecurityFilterTemplate> templates = new List <SecurityFilterTemplate>();

            SecurityFilterService.GetTemplates(templates, message.m_body, message.m_bodyLength);
            int templatesSize = templates.Count;

            switch (message.m_functionID)
            {
            case SecurityFilterService.FUNCTIONID_SECURITYFILTER_ADDTEMPLATES:
                AddTemplatesToGrid(templates);
                break;

            case SecurityFilterService.FUNCTIONID_SECURITYFILTER_DELETETEMPLATES:
            {
                Dictionary <String, GridRow> templateRowsMap = GetTemplateRows();
                for (int i = 0; i < templatesSize; i++)
                {
                    SecurityFilterTemplate template = templates[i];
                    if (templateRowsMap.ContainsKey(template.m_templateID))
                    {
                        m_gridTemplate.RemoveRow(templateRowsMap[template.m_templateID]);
                    }
                }
                m_gridTemplate.Update();
                break;
            }

            case SecurityFilterService.FUNCTIONID_SECURITYFILTER_UPDATETEMPLATES:
            {
                Dictionary <String, GridRow> templateRowsMap = GetTemplateRows();
                for (int i = 0; i < templatesSize; i++)
                {
                    SecurityFilterTemplate template = templates[i];
                    if (templateRowsMap.ContainsKey(template.m_templateID))
                    {
                        templateRowsMap[template.m_templateID].GetCell(1).Text = template.m_name;
                    }
                }
                break;
            }
            }
            m_window.Invalidate();
        }
예제 #8
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage message = (CMessage)args;
            List <IndicatorLayout> layouts = new List <IndicatorLayout>();

            IndicatorLayoutService.GetLayouts(layouts, message.m_body, message.m_bodyLength);
            int layoutsSize = layouts.Count;

            switch (message.m_functionID)
            {
            case IndicatorLayoutService.FUNCTIONID_INDICATORLAYOUT_ADDLAYOUTS:
                AddLayoutsToGrid(layouts);
                break;

            case IndicatorLayoutService.FUNCTIONID_INDICATORLAYOUT_DELETELAYOUTS:
            {
                Dictionary <String, GridRow> ilRowsMap = GetIndicatorLayoutsRows();
                for (int i = 0; i < layoutsSize; i++)
                {
                    IndicatorLayout layout = layouts[i];
                    if (ilRowsMap.ContainsKey(layout.m_layoutID))
                    {
                        m_gridLayouts.RemoveRow(ilRowsMap[layout.m_layoutID]);
                    }
                }
                m_gridLayouts.Update();
                break;
            }

            case IndicatorLayoutService.FUNCTIONID_INDICATORLAYOUT_UPDATELAYOUTS:
            {
                Dictionary <String, GridRow> ilRowsMap = GetIndicatorLayoutsRows();
                for (int i = 0; i < layoutsSize; i++)
                {
                    IndicatorLayout layout = layouts[i];
                    if (ilRowsMap.ContainsKey(layout.m_layoutID))
                    {
                        ilRowsMap[layout.m_layoutID].GetCell(1).Text = layout.m_name;
                    }
                }
                break;
            }
            }
            m_window.Invalidate();
        }
예제 #9
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage     message = (CMessage)args;
            List <Macro> macros  = new List <Macro>();

            MacroService.GetMacros(macros, message.m_body, message.m_bodyLength);
            int macrosSize = macros.Count;

            switch (message.m_functionID)
            {
            case MacroService.FUNCTIONID_MACRO_ADDMACROS:
                AddMacrosToGrid(macros);
                break;

            case MacroService.FUNCTIONID_MACRO_DELETEMACROS:
            {
                Dictionary <String, GridRow> mRowsMap = GetMacroRows();
                for (int i = 0; i < macrosSize; i++)
                {
                    Macro macro = macros[i];
                    if (mRowsMap.ContainsKey(macro.m_macroID))
                    {
                        m_gridMacros.RemoveRow(mRowsMap[macro.m_macroID]);
                    }
                }
                m_gridMacros.Update();
                break;
            }

            case MacroService.FUNCTIONID_MACRO_UPDATEMACROS:
            {
                Dictionary <String, GridRow> mRowsMap = GetMacroRows();
                for (int i = 0; i < macrosSize; i++)
                {
                    Macro macro = macros[i];
                    if (mRowsMap.ContainsKey(macro.m_macroID))
                    {
                        mRowsMap[macro.m_macroID].GetCell(1).Text = macro.m_name;
                    }
                }
                break;
            }
            }
            m_window.Invalidate();
        }
예제 #10
0
        /// <summary>
        /// 删除
        /// </summary>
        public void Delete()
        {
            List <GridRow> selectedRows     = m_gridClues.SelectedRows;
            int            selectedRowsSize = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                if (DialogResult.Yes == MessageBox.Show("是否确认删除该条信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    GridRow deleteRow = selectedRows[0];
                    String  pID       = deleteRow.GetCell("colP1").GetString();
                    DataCenter.ClueService.Delete(pID);
                    m_gridClues.RemoveRow(deleteRow);
                    m_gridClues.Update();
                    m_gridClues.Invalidate();
                }
            }
        }
예제 #11
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();
        }
예제 #12
0
파일: MainFrame.cs 프로젝트: owchart/iteam
        /// <summary>
        /// 绑定所有的群组
        /// </summary>
        private void BindGroups()
        {
            m_gridGroups.UseAnimation = true;
            List <GridRow> rows     = m_gridGroups.m_rows;
            int            rowsSize = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                GridRow row = rows[i];
                if (row.EditButton != null)
                {
                    m_gridGroups.RemoveControl(row.EditButton);
                    row.EditButton = null;
                }
                m_gridGroups.RemoveRow(row);
                i--;
                rowsSize--;
            }
            m_gridGroups.Update();
            GridRow firstRow = new GridRow();

            m_gridGroups.AddRow(firstRow);
            GridStringCell cell1 = new GridStringCell("");

            firstRow.AddCell("colG1", cell1);
            GridStringCell cell2 = new GridStringCell("全部");

            firstRow.AddCell("colG2", cell2);
            GridStringCell cell3 = new GridStringCell("");

            firstRow.AddCell("colG3", cell3);
            int groupsSize = m_chatGroups.Count;

            for (int i = 0; i < groupsSize; i++)
            {
                ChatGroup chatGroup = m_chatGroups[i];
                GridRow   cRow      = new GridRow();
                m_gridGroups.AddRow(cRow);
                ButtonA deleteButton = new ButtonA();
                deleteButton.Height    = cRow.Height;
                deleteButton.Name      = "btnDelete";
                deleteButton.Tag       = chatGroup.Name;
                deleteButton.BackColor = COLOR.ARGB(255, 0, 0);
                deleteButton.Native    = m_gridHosts.Native;
                deleteButton.Text      = "删除";
                cRow.EditButton        = deleteButton;
                cRow.AllowEdit         = true;
                GridStringCell cCell1 = new GridStringCell(chatGroup.Name);
                cRow.AddCell("colG1", cCell1);
                GridStringCell cCell2 = new GridStringCell(chatGroup.DisplayName);
                cRow.AddCell("colG2", cCell2);
                String strIDs      = "";
                int    userIDsSize = chatGroup.UserIDs.Count;
                for (int j = 0; j < userIDsSize; j++)
                {
                    strIDs += chatGroup.UserIDs[j];
                    if (j != userIDsSize - 1)
                    {
                        strIDs += ",";
                    }
                }
                GridStringCell cCell3 = new GridStringCell(strIDs);
                cRow.AddCell("colG3", cCell3);

                ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickEvent);
                deleteButton.RegisterEvent(clickButtonEvent, EVENTID.CLICK);
            }
            m_gridGroups.Update();
            m_gridGroups.Invalidate();
        }
예제 #13
0
파일: MainFrame.cs 프로젝트: owchart/iteam
        /// <summary>
        /// 调用主线程返方法
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="args">参数</param>
        public void Invoke(object sender, object args)
        {
            CMessage message = args as CMessage;

            if (message != null)
            {
                if (message.m_serviceID == ChatService.SERVICEID_CHAT)
                {
                    if (message.m_functionID == ChatService.FUNCTIONID_SENDALL)
                    {
                        ChatData chatData = new ChatData();
                        ChatService.GetChatData(chatData, message.m_body, message.m_bodyLength);
                        CIndicator indicator = CFunctionEx.CreateIndicator2("", chatData, this);
                        indicator.Clear();
                        indicator.Dispose();
                    }
                    else if (message.m_functionID == ChatService.FUNCTIONID_GETHOSTS)
                    {
                        List <ChatHostInfo> datas = new List <ChatHostInfo>();
                        int type = 0;
                        ChatService.GetHostInfos(datas, ref type, message.m_body, message.m_bodyLength);
                        if (type != 2)
                        {
                            int datasSize = datas.Count;
                            for (int i = 0; i < datasSize; i++)
                            {
                                ChatHostInfo   hostInfo    = datas[i];
                                List <GridRow> rows        = m_gridHosts.m_rows;
                                int            rowsSize    = rows.Count;
                                bool           containsRow = false;
                                for (int j = 0; j < rowsSize; j++)
                                {
                                    GridRow oldRow = rows[j];
                                    if (oldRow.GetCell("colP1").GetString() == hostInfo.m_ip && oldRow.GetCell("colP2").GetInt() == hostInfo.m_serverPort)
                                    {
                                        containsRow = true;
                                    }
                                }
                                if (!containsRow)
                                {
                                    if (hostInfo.m_type == 1)
                                    {
                                        String      key = hostInfo.m_ip + ":" + hostInfo.m_serverPort;
                                        ChatService newServerService = DataCenter.GetClientChatService(key);
                                        if (newServerService == null)
                                        {
                                            newServerService            = new ChatService();
                                            newServerService.ServerIP   = hostInfo.m_ip;
                                            newServerService.ServerPort = hostInfo.m_serverPort;
                                            newServerService.ToServer   = true;
                                            BaseService.AddService(newServerService);
                                            DataCenter.AddClientChatService(key, newServerService);
                                        }
                                    }
                                    else
                                    {
                                        GridRow row = new GridRow();
                                        m_gridHosts.AddRow(row);
                                        row.AddCell("colP1", new GridStringCell(hostInfo.m_ip));
                                        row.AddCell("colP2", new GridIntCell(hostInfo.m_serverPort));
                                        if (hostInfo.m_type == 1)
                                        {
                                            row.AddCell("colP3", new GridStringCell("--"));
                                            row.AddCell("colP4", new GridStringCell("--"));
                                        }
                                        else
                                        {
                                            row.AddCell("colP3", new GridStringCell(hostInfo.m_userID));
                                            row.AddCell("colP4", new GridStringCell(hostInfo.m_userName));
                                        }
                                        row.AddCell("colP5", new GridStringCell(hostInfo.m_type == 1 ? "服务器" : "客户端"));
                                    }
                                }
                            }
                        }
                        else
                        {
                            Dictionary <String, String> removeHosts = new Dictionary <String, String>();
                            foreach (ChatHostInfo hostInfo in datas)
                            {
                                removeHosts[hostInfo.ToString()] = "";
                            }
                            List <GridRow> rows     = m_gridHosts.m_rows;
                            int            rowsSize = rows.Count;
                            if (rowsSize > 0)
                            {
                                for (int i = 0; i < rowsSize; i++)
                                {
                                    GridRow row = rows[i];
                                    String  key = row.GetCell("colP1").GetString() + ":" + row.GetCell("colP2").GetString();
                                    if (removeHosts.ContainsKey(key))
                                    {
                                        m_gridHosts.RemoveRow(row);
                                        i--;
                                        rowsSize--;
                                    }
                                }
                            }
                        }
                        SetHostGridRowVisible();
                    }
                    else if (message.m_functionID == ChatService.FUNCTIONID_SEND)
                    {
                        ChatData chatData = new ChatData();
                        ChatService.GetChatData(chatData, message.m_body, message.m_bodyLength);
                        CIndicator indicator = CFunctionEx.CreateIndicator2("", chatData, this);
                        indicator.Clear();
                        indicator.Dispose();
                    }
                }
            }
            String newStr = args as String;

            if (newStr != null)
            {
                if (newStr == "showchat")
                {
                    FlashWindow(m_mainForm.Handle, true);
                    SetForegroundWindow(m_mainForm.Handle);
                }
                else if (newStr == "shake")
                {
                    m_mainForm.Play();
                }
                else if (newStr.StartsWith("how:"))
                {
                    String  text    = newStr.Substring(4);
                    Barrage barrage = new Barrage();
                    barrage.Text = text;
                    barrage.Mode = 1;
                    m_barrageForm.BarrageDiv.AddBarrage(barrage);
                }
                else
                {
                    TextBoxA txtReceive = GetTextBox("txtReceive");
                    txtReceive.Text += newStr;
                    txtReceive.Invalidate();
                    if (txtReceive.VScrollBar != null && txtReceive.VScrollBar.Visible)
                    {
                        txtReceive.VScrollBar.ScrollToEnd();
                        txtReceive.Update();
                        txtReceive.Invalidate();
                    }
                }
            }
        }
예제 #14
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();
        }