Exemplo n.º 1
0
        /// <summary>
        /// 表格选中行改变方法
        /// </summary>
        public void OnGridSelectedRowsChanged()
        {
            List <GridRow> selectedRows     = m_tvBlock.SelectedRows;
            int            selectedRowsSize = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                TreeNodeA node       = selectedRows[0].GetCell(0) as TreeNodeA;
                TreeNodeA parentNode = node.Parent;
                if (parentNode != null && parentNode.Text == "自选股")
                {
                    String categoryID             = node.Value;
                    UserSecurityCategory category = new UserSecurityCategory();
                    m_userSecurityService.GetCategory(categoryID, ref category);
                    List <Security> securities = new List <Security>();
                    m_securityService.GetSecuritiesByCodes(category.m_codes, securities);
                    BindSecuritiesToSelectSecuritiesGrid(securities);
                }
                else
                {
                    if (node.GetChildNodes().Count == 0)
                    {
                        String blockID = node.Value;
                        m_securityService.GetSecuritiesByBlockID(m_securitiesRequestID, blockID);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 证券列表窗体关闭方法
        /// </summary>
        /// <param name="securityList">是否取消</param>
        /// <param name="cancel">是否取消</param>
        private void OnSecurityListWindowClosed(SecurityList securityList, ref bool cancel)
        {
            List <GridRow> selectedCategoryRows = m_gridCategory.SelectedRows;
            int            rowsSize             = selectedCategoryRows.Count;

            if (rowsSize > 0)
            {
                UserSecurityCategory category = new UserSecurityCategory();
                m_userSecurityService.GetCategory(selectedCategoryRows[0].GetCell(0).GetString(), ref category);
                if (securityList.IsSubmit)
                {
                    List <Security> selectedSecurities = new List <Security>();
                    securityList.GetSelectedSecurities(selectedSecurities);
                    int    selectedSecuritiesSize = selectedSecurities.Count;
                    String codes = "";
                    for (int i = 0; i < selectedSecuritiesSize; i++)
                    {
                        codes += selectedSecurities[i].m_code;
                        if (i != selectedSecuritiesSize - 1)
                        {
                            codes += ",";
                        }
                    }
                    category.m_codes = codes;
                    m_userSecurityService.UpdateCategory(m_userSecurityService.OperatorRequestID, category);
                }
            }
            m_window.Invalidate();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加证券成份
        /// </summary>
        public void AddSecurities()
        {
            List <GridRow> selectedCategoryRows = m_gridCategory.SelectedRows;
            int            rowsSize             = selectedCategoryRows.Count;

            if (rowsSize > 0)
            {
                UserSecurityCategory category = new UserSecurityCategory();
                m_userSecurityService.GetCategory(selectedCategoryRows[0].GetCell(0).GetString(), ref category);
                SecurityList securityList = new SecurityList(m_native);
                securityList.Show();
                WindowEx window = securityList.Window;
                window.IsChildWindow = true;
                window.Tag           = securityList;
                if (category.m_codes != null && category.m_codes.Length > 0)
                {
                    List <Security> securities = new List <Security>();
                    m_securityService.GetSecuritiesByCodes(category.m_codes, securities);
                    securityList.AddSecuritiesToSecuritiesGrid(securities);
                }
                WindowClosingEvent windowClosingEvent = new WindowClosingEvent(SecurityListWindowClosed);
                window.RegisterEvent(windowClosingEvent, EVENTID.WINDOWCLOSING);
                m_native.Invalidate();
            }
        }
Exemplo n.º 4
0
        public int UpdateOrderNum(int requestID, int userID, List <string> ids)
        {
            string str   = "";
            int    count = ids.Count;

            for (int i = 0; i < count; i++)
            {
                str = str + ids[i];
                if (i != (count - 1))
                {
                    str = str + ",";
                }
            }
            UserSecurityCategory category = new UserSecurityCategory();

            category.m_categoryID = str;
            category.m_userID     = userID;
            List <UserSecurityCategory> categories = new List <UserSecurityCategory>();

            categories.Add(category);
            int num3 = this.Send(6, requestID, categories);

            categories.Clear();
            return((num3 > 0) ? 1 : 0);
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 添加类别到表格中
        /// </summary>
        /// <param name="categories">类别</param>
        public void AddCategoriesToCategoryGrid(List <UserSecurityCategory> categories)
        {
            if (m_gridCategory.EditTextBox != null)
            {
                m_gridCategory.OnCellEditEnd(null);
            }
            m_gridCategory.BeginUpdate();
            int categoriesSize = categories.Count;

            for (int i = 0; i < categoriesSize; i++)
            {
                UserSecurityCategory category = categories[i];
                GridRow row = new GridRow();
                row.Grid = m_gridCategory;
                GridStringCell idCell = new GridStringCell();
                idCell.Text = category.m_categoryID;
                row.AddCell(0, idCell);
                GridStringCell textCell = new GridStringCell();
                textCell.AllowEdit = true;
                textCell.Text      = category.m_name;
                row.AddCell(1, textCell);
                m_gridCategory.AddRow(row);
                if (i == 0)
                {
                    m_gridCategory.OnCellEditBegin(textCell);
                }
            }
            m_gridCategory.EndUpdate();
            m_gridCategory.Invalidate();
        }
Exemplo n.º 7
0
        /// <summary>
        /// 更新表格中的类别
        /// </summary>
        /// <param name="categories">类别</param>
        public void UpdateCategoriesToCategoryGrid(List <UserSecurityCategory> categories)
        {
            Dictionary <String, UserSecurityCategory> updateKeys = new Dictionary <String, UserSecurityCategory>();
            int categoriesSize = categories.Count;

            for (int i = 0; i < categoriesSize; i++)
            {
                UserSecurityCategory category = categories[i];
                updateKeys[category.m_categoryID] = category;
            }
            List <GridRow> rows    = m_gridCategory.GetRows();
            int            rowSize = rows.Count;

            for (int i = 0; i < rowSize; i++)
            {
                GridRow row = rows[i] as GridRow;
                UserSecurityCategory category = new UserSecurityCategory();
                m_userSecurityService.GetCategory(row.GetCell(0).GetString(), ref category);
                if (updateKeys.ContainsKey(category.m_categoryID))
                {
                    UserSecurityCategory updateCategory = updateKeys[category.m_categoryID];
                    m_userSecurityService.GetCategory(updateCategory.m_categoryID, ref updateCategory);
                    row.GetCell(1).SetString(updateCategory.m_name);
                    BindSecuritiesToSecuritiesGrid(category);
                }
            }
            updateKeys.Clear();
        }
Exemplo n.º 8
0
 /// <summary>
 /// 点击单元格
 /// </summary>
 /// <param name="cell">单元格</param>
 /// <param name="mp">坐标</param>
 /// <param name="button">按钮</param>
 /// <param name="clicks">点击次数</param>
 /// <param name="delta">鼠标滚轮值</param>
 public void OnClickCell(UserSecurityCellT2 cell, POINT mp, MouseButtonsA button, int clicks, int delta)
 {
     if (m_cellState > 0)
     {
         if (m_isEditing)
         {
             if (mp.x <= 30 && mp.y <= 30)
             {
                 UserSecurityCategory category = new UserSecurityCategory();
                 category.m_categoryID = "primary";
                 category.m_userID     = DataCenter.UserID;
                 category.m_codes      = cell.SecurityCode;
                 m_userSecurityService.DeleteSecurities(m_userSecurityService.OperatorRequestID, category);
             }
             Invalidate();
         }
         else
         {
             Security security = new Security();
             m_securityService.GetSecurityByCode(cell.SecurityCode, ref security);
             m_userSecurityService.AddVisitsCount(security.m_code);
             m_chart.SearchSecurity(security);
             cell.Clicks++;
             m_cells.Sort(new UserSecurityCellT2Compare());
             Update();
         }
     }
     m_cellState = 0;
 }
Exemplo n.º 9
0
        /// <summary>
        /// 添加类别到表格中
        /// </summary>
        /// <param name="categories">类别</param>
        public void LoadCategoriesToCategoryGrid(List <UserSecurityCategory> categories)
        {
            m_gridCategory.BeginUpdate();
            int categoriesSize = categories.Count;

            for (int i = 0; i < categoriesSize; i++)
            {
                UserSecurityCategory category = categories[i];
                GridRow row = new GridRow();
                row.Grid = m_gridCategory;
                GridStringCell idCell = new GridStringCell();
                idCell.Grid   = m_gridCategory;
                idCell.Column = m_gridCategory.GetColumn(0);
                idCell.Text   = category.m_categoryID;
                row.AddCell(0, idCell);
                GridStringCell textCell = new GridStringCell();
                textCell.Grid      = m_gridCategory;
                textCell.Column    = m_gridCategory.GetColumn(0);
                textCell.AllowEdit = true;
                textCell.Text      = category.m_name;
                row.AddCell(1, textCell);
                m_gridCategory.AddRow(row);
            }
            m_gridCategory.EndUpdate();
            m_gridCategory.Invalidate();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 删除证券成份
        /// </summary>
        public void DeleteSecurities()
        {
            List <GridRow> selectedCategoryRows = m_gridCategory.SelectedRows;
            int            rowsSize             = selectedCategoryRows.Count;

            if (rowsSize > 0)
            {
                UserSecurityCategory category = new UserSecurityCategory();
                m_userSecurityService.GetCategory(selectedCategoryRows[0].GetCell(0).GetString(), ref category);
                List <GridRow>  selectedRows     = m_gridSecurities.SelectedRows;
                int             selectedRowsSize = selectedRows.Count;
                List <Security> securities       = new List <Security>();
                if (selectedRowsSize > 0)
                {
                    String codes = "";
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        GridRow row = selectedRows[i];
                        codes += row.GetCell(0).GetString();
                        if (i != selectedRowsSize - 1)
                        {
                            codes += ",";
                        }
                    }
                    UserSecurityCategory updateCategory = new UserSecurityCategory();
                    updateCategory.m_categoryID = category.m_categoryID;
                    updateCategory.m_codes      = codes;
                    updateCategory.m_userID     = DataCenter.UserID;
                    m_userSecurityService.DeleteSecurities(m_userSecurityService.OperatorRequestID, updateCategory);
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 添加类别
        /// </summary>
        public void AddCategory()
        {
            UserSecurityCategory category = new UserSecurityCategory();

            category.m_name   = "未命名的自选股";
            category.m_userID = DataCenter.UserID;
            m_userSecurityService.AddCategory(m_userSecurityService.OperatorRequestID, category);
        }
Exemplo n.º 12
0
        public int GetCategories(int requestID, UserSecurityCategory category)
        {
            List <UserSecurityCategory> categories = new List <UserSecurityCategory>();

            categories.Add(category);
            int num = this.Send(2, requestID, categories);

            categories.Clear();
            return((num > 0) ? 1 : 0);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 加载单元格
        /// </summary>
        private void LoadCells()
        {
            int cellsSize = m_cells.Count;
            Dictionary <String, UserSecurityCellT2> removeCells = new Dictionary <String, UserSecurityCellT2>();

            for (int i = 0; i < cellsSize; i++)
            {
                UserSecurityCellT2 cell = m_cells[i];
                removeCells[cell.SecurityCode] = cell;
            }
            m_cells.Clear();
            List <UserSecurityCategory> categories = new List <UserSecurityCategory>();

            m_userSecurityService.GetCategories(categories);
            UserSecurityCategory category = categories[0];

            String[] strs     = category.m_codes.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int      strsSize = strs.Length;

            for (int i = 0; i < strsSize; i++)
            {
                String securityCode = strs[i];
                if (removeCells.ContainsKey(securityCode))
                {
                    m_cells.Add(removeCells[securityCode]);
                    removeCells.Remove(securityCode);
                }
                else
                {
                    UserSecurityCellT2 cell = new UserSecurityCellT2();
                    cell.SecurityCode = securityCode;
                    cell.BackColor    = COLOR.ARGB(200, 0, 0, 0);
                    cell.PaintRect    = cell.Bounds;
                    cell.List         = this;
                    if (m_userSecurityService.VisitsCount.ContainsKey(securityCode))
                    {
                        cell.Clicks = m_userSecurityService.VisitsCount[securityCode];
                    }
                    m_cells.Add(cell);
                    AddControl(cell);
                }
            }
            foreach (UserSecurityCellT2 cell in removeCells.Values)
            {
                if (cell == m_selectedCell)
                {
                    m_selectedCell = null;
                }
                RemoveControl(cell);
                cell.Dispose();
            }
            removeCells.Clear();
            m_cells.Sort(new UserSecurityCellT2Compare());
            Update();
        }
Exemplo n.º 14
0
        /// <summary>
        /// 获取类别信息
        /// </summary>
        /// <param name="categoryID">类别ID</param>
        /// <param name="category">返回类别</param>
        /// <returns>状态</returns>
        public bool GetCategory(String categoryID, ref UserSecurityCategory category)
        {
            int categoriesSize = m_categories.Count;

            for (int i = 0; i < categoriesSize; i++)
            {
                if (m_categories[i].m_categoryID == categoryID)
                {
                    category = m_categories[i];
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 删除类别
        /// </summary>
        public void DeleteCategory()
        {
            List <GridRow> selectedRows = m_gridCategory.SelectedRows;
            int            rowsSize     = selectedRows.Count;

            if (rowsSize > 0)
            {
                UserSecurityCategory category = new UserSecurityCategory();
                m_userSecurityService.GetCategory(selectedRows[0].GetCell(0).GetString(), ref category);
                if (category != null)
                {
                    m_userSecurityService.DeleteCategory(m_userSecurityService.OperatorRequestID, category);
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 表格选中行改变方法
        /// </summary>
        public void OnGridSelectedRowsChanged()
        {
            String         categoryID       = "";
            List <GridRow> selectedRows     = m_gridCategory.SelectedRows;
            int            selectedRowsSize = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                categoryID = selectedRows[0].GetCell(0).Text;
            }
            UserSecurityCategory category = new UserSecurityCategory();

            m_userSecurityService.GetCategory(categoryID, ref category);
            BindSecuritiesToSecuritiesGrid(category);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="state">状态</param>
        /// <returns>加载状态</returns>
        public static int LoadData(int state)
        {
            ChatData chatData = new ChatData();

            m_chatService.Enter(m_chatService.RequestID, chatData);
            Indicator indicator = new Indicator();

            indicator.m_userID = m_userID;
            m_indicatorService.GetIndicators(m_indicatorService.GetListRequestID, indicator);
            SecurityFilterTemplate template = new SecurityFilterTemplate();

            template.m_userID = m_userID;
            m_securityFilterService.GetTemplates(m_securityFilterService.GetListRequestID, template);
            UserSecurityVisitsCount visitsCount = new UserSecurityVisitsCount();

            visitsCount.m_userID = DataCenter.UserID;
            m_userSecurityService.GetVisitsCount(m_userSecurityService.GetListRequestID, visitsCount);
            UserSecurityCategory category = new UserSecurityCategory();

            category.m_userID = m_userID;
            m_userSecurityService.GetCategories(m_userSecurityService.GetListRequestID, category);
            IndicatorLayout indicatorLayout = new IndicatorLayout();

            indicatorLayout.m_userID = m_userID;
            m_indicatorLayoutService.GetLayouts(m_indicatorLayoutService.GetListRequestID, indicatorLayout);
            Macro macro = new Macro();

            macro.m_userID = m_userID;
            m_macroService.GetMacros(m_macroService.GetListRequestID, macro);
            UserSession userSession = new UserSession();

            userSession.m_userID = m_userID;
            m_userSessionService.GetSessions(m_userSessionService.GetListRequestID, userSession);
            if (state == 1)
            {
                m_securityService.LoadSecurities();
            }
            if (m_mainUI != null)
            {
                m_mainUI.LoadData();
            }
            return(0);
        }
Exemplo n.º 18
0
 /// <summary>
 /// 类别表格单元格编辑完成方法
 /// </summary>
 /// <param name="cell">单元格</param>
 public void OnCategoryGridCellEditEnd(GridCell cell)
 {
     if (cell != null)
     {
         UserSecurityCategory category = new UserSecurityCategory();
         m_userSecurityService.GetCategory(cell.Row.GetCell(0).GetString(), ref category);
         if (category != null)
         {
             UserSecurityCategory updateCategory = new UserSecurityCategory();
             updateCategory.m_categoryID = category.m_categoryID;
             updateCategory.m_codes      = category.m_codes;
             updateCategory.m_name       = m_gridCategory.EditTextBox.Text;
             updateCategory.m_orderNum   = category.m_orderNum;
             updateCategory.m_type       = category.m_type;
             updateCategory.m_userID     = category.m_userID;
             m_userSecurityService.UpdateCategory(m_userSecurityService.OperatorRequestID, updateCategory);
         }
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// 绑定自选股类别中的证券到表格
        /// </summary>
        /// <param name="category">类别</param>
        public void BindSecuritiesToSecuritiesGrid(UserSecurityCategory category)
        {
            m_gridSecurities.ClearRows();
            List <Security> securities = new List <Security>();

            if (category.m_codes != null && category.m_codes.Length > 0)
            {
                String[] codes     = category.m_codes.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                int      codesSize = codes.Length;
                for (int i = 0; i < codesSize; i++)
                {
                    Security security = new Security();
                    bool     state    = m_securityService.GetSecurityByCode(codes[i], ref security);
                    if (state)
                    {
                        securities.Add(security);
                    }
                }
            }
            AddSecuritiesToSecuritiesGrid(securities);
        }
Exemplo n.º 20
0
        public int Send(int functionID, int requestID, List <UserSecurityCategory> categories)
        {
            Binary binary = new Binary();
            int    count  = categories.Count;

            binary.WriteInt(count);
            for (int i = 0; i < count; i++)
            {
                UserSecurityCategory category = categories[i];
                binary.WriteString(category.m_categoryID);
                binary.WriteInt(category.m_userID);
                binary.WriteString(category.m_name);
                binary.WriteString(category.m_codes);
                binary.WriteInt(category.m_type);
                binary.WriteInt(category.m_orderNum);
            }
            byte[] bytes = binary.GetBytes();
            int    num3  = this.Send(new CMessage(base.GroupID, base.ServiceID, functionID, base.SessionID, requestID, this.m_socketID, 0, base.CompressType, bytes.Length, bytes));

            binary.Close();
            return(num3);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 加载自选股类别
        /// </summary>
        /// <param name="categories">自选股列表</param>
        public void LoadUserSecurityCategories(List <UserSecurityCategory> categories)
        {
            int categoriesSize = categories.Count;

            m_tvBlock.BeginUpdate();
            List <TreeNodeA> childNodes = m_tvBlock.GetChildNodes();
            int childNodesSize          = childNodes.Count;

            if (childNodesSize > 0)
            {
                TreeNodeA userSecurityNode = childNodes[childNodesSize - 1];
                for (int i = 0; i < categories.Count; i++)
                {
                    UserSecurityCategory category     = categories[i];
                    TreeNodeA            categoryNode = new TreeNodeA();
                    userSecurityNode.AppendNode(categoryNode);
                    categoryNode.Text  = category.m_name;
                    categoryNode.Value = category.m_categoryID;
                }
            }
            m_tvBlock.EndUpdate();
        }
Exemplo n.º 22
0
        public static int GetCategories(List <UserSecurityCategory> categories, byte[] body, int bodyLength)
        {
            Binary binary = new Binary();

            binary.Write(body, bodyLength);
            int num = binary.ReadInt();

            if (num > 0)
            {
                for (int i = 0; i < num; i++)
                {
                    UserSecurityCategory item = new UserSecurityCategory();
                    item.m_categoryID = binary.ReadString();
                    item.m_userID     = binary.ReadInt();
                    item.m_name       = binary.ReadString();
                    item.m_codes      = binary.ReadString();
                    item.m_type       = binary.ReadInt();
                    item.m_orderNum   = binary.ReadInt();
                    categories.Add(item);
                }
            }
            binary.Close();
            return(1);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 接收消息方法
        /// </summary>
        /// <param name="message">消息</param>
        public override void OnReceive(CMessage message)
        {
            if (message.m_functionID == FUNCTIONID_USERSECURITY_GETVISITSCOUNT)
            {
                UserSecurityVisitsCount visitsCount = new UserSecurityVisitsCount();
                Binary br = new Binary();
                br.Write(message.m_body, message.m_bodyLength);
                visitsCount.m_userID = br.ReadInt();
                visitsCount.CodesFromString(br.ReadString());
                m_visitsCount = visitsCount.m_codes;
                br.Close();
            }
            else
            {
                List <UserSecurityCategory> categories = new List <UserSecurityCategory>();
                UserSecurityService.GetCategories(categories, message.m_body, message.m_bodyLength);
                int categoriesSize = categories.Count;
                if (message.m_functionID != FUNCTIONID_USERSECURITY_GETCATEGORIES)
                {
                    message.m_requestID = m_operatorRequestID;
                }
                switch (message.m_functionID)
                {
                case FUNCTIONID_USERSECURITY_GETCATEGORIES:
                {
                    m_categories = categories;
                    m_loaded     = true;
                    break;
                }

                case FUNCTIONID_USERSECURITY_ADDCATEGORIES:
                {
                    bool add = false;
                    for (int i = 0; i < categoriesSize; i++)
                    {
                        UserSecurityCategory category = null;
                        if (!GetCategory(categories[i].m_categoryID, ref category))
                        {
                            m_categories.Add(categories[i]);
                            add = true;
                        }
                    }
                    if (!add)
                    {
                        return;
                    }
                    break;
                }

                case FUNCTIONID_USERSECURITY_DELETECATEGORIES:
                {
                    for (int i = 0; i < categoriesSize; i++)
                    {
                        UserSecurityCategory category = null;
                        if (GetCategory(categories[i].m_categoryID, ref category))
                        {
                            m_categories.Remove(category);
                        }
                    }
                    break;
                }

                case FUNCTIONID_USERSECURITY_UPDATECATEGORIES:
                {
                    for (int i = 0; i < categoriesSize; i++)
                    {
                        UserSecurityCategory updateCategory = categories[i];
                        int curCategoriesSize = m_categories.Count;
                        for (int j = 0; j < curCategoriesSize; j++)
                        {
                            UserSecurityCategory category = m_categories[j];
                            if (category.m_categoryID == updateCategory.m_categoryID)
                            {
                                m_categories[j] = updateCategory;
                                break;
                            }
                        }
                    }
                    break;
                }

                case FUNCTIONID_USERSECURITY_ADDSECURITIES:
                {
                    for (int i = 0; i < categoriesSize; i++)
                    {
                        UserSecurityCategory updateCategory = categories[i];
                        int curCategoriesSize = m_categories.Count;
                        for (int j = 0; j < curCategoriesSize; j++)
                        {
                            UserSecurityCategory category = m_categories[j];
                            if (category.m_categoryID == updateCategory.m_categoryID)
                            {
                                if (category.m_codes != null && category.m_codes.Length > 0)
                                {
                                    updateCategory.m_codes = m_categories[j].m_codes + "," + updateCategory.m_codes;
                                }
                                m_categories[j] = updateCategory;
                                break;
                            }
                        }
                    }
                    break;
                }

                case FUNCTIONID_USERSECURITY_DELETESECURITIES:
                {
                    for (int i = 0; i < categoriesSize; i++)
                    {
                        UserSecurityCategory updateCategory = categories[i];
                        int curCategoriesSize = m_categories.Count;
                        for (int j = 0; j < curCategoriesSize; j++)
                        {
                            UserSecurityCategory category = m_categories[j];
                            if (category.m_categoryID == updateCategory.m_categoryID)
                            {
                                if (updateCategory.m_codes != null && updateCategory.m_codes.Length > 0 && category.m_codes != null && category.m_codes.Length > 0)
                                {
                                    String[] deleteCodes     = updateCategory.m_codes.Split(',');
                                    int      deleteCodesSize = deleteCodes.Length;
                                    Dictionary <String, String> deleteCodesMap = new Dictionary <String, String>();
                                    for (int m = 0; m < deleteCodesSize; m++)
                                    {
                                        deleteCodesMap[deleteCodes[m]] = "";
                                    }
                                    String[] codes     = category.m_codes.Split(',');
                                    int      codesSize = codes.Length;
                                    String   newCodes  = "";
                                    for (int m = 0; m < codesSize; m++)
                                    {
                                        if (!deleteCodesMap.ContainsKey(codes[m]))
                                        {
                                            newCodes += codes[m] + ",";
                                        }
                                    }
                                    if (newCodes != null && newCodes.Length > 0)
                                    {
                                        if (newCodes.Substring(newCodes.Length - 1) == ",")
                                        {
                                            newCodes = newCodes.Substring(0, newCodes.Length - 1);
                                        }
                                    }
                                    updateCategory.m_codes = newCodes;
                                }
                                m_categories[j] = updateCategory;
                                break;
                            }
                        }
                    }
                    break;
                }
                }
            }
            base.OnReceive(message);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage message = (CMessage)args;

            if (message.m_serviceID == m_quoteService.ServiceID)
            {
                LatestDataInfo            dataInfo = new LatestDataInfo();
                List <SecurityLatestData> datas    = new List <SecurityLatestData>();
                QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength);
                int datasSize = datas.Count;
                for (int i = 0; i < datasSize; i++)
                {
                    m_latestDatas[datas[i].m_securityCode] = datas[i];
                }
                datas.Clear();
            }
            else
            {
                List <UserSecurityCategory> categories = new List <UserSecurityCategory>();
                UserSecurityService.GetCategories(categories, message.m_body, message.m_bodyLength);
                UserSecurityCategory category = categories[0];
                switch (message.m_functionID)
                {
                case UserSecurityService.FUNCTIONID_USERSECURITY_ADDCATEGORIES:
                    AddCategoriesToCategoryGrid(categories);
                    break;

                case UserSecurityService.FUNCTIONID_USERSECURITY_DELETECATEGORIES:
                    RemoveCategoriesFromCategoryGrid(categories);
                    break;

                case UserSecurityService.FUNCTIONID_USERSECURITY_UPDATECATEGORIES:
                    UpdateCategoriesToCategoryGrid(categories);
                    break;

                case UserSecurityService.FUNCTIONID_USERSECURITY_ADDSECURITIES:
                case UserSecurityService.FUNCTIONID_USERSECURITY_DELETESECURITIES:
                {
                    String         categoryID       = "";
                    List <GridRow> selectedRows     = m_gridCategory.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    if (selectedRowsSize > 0)
                    {
                        categoryID = selectedRows[0].GetCell(0).Text;
                    }
                    if (categoryID != null && categoryID == category.m_categoryID)
                    {
                        List <Security> securities = new List <Security>();
                        m_securityService.GetSecuritiesByCodes(category.m_codes, securities);
                        if (message.m_functionID == UserSecurityService.FUNCTIONID_USERSECURITY_ADDSECURITIES)
                        {
                            AddSecuritiesToSecuritiesGrid(securities);
                        }
                        else if (message.m_functionID == UserSecurityService.FUNCTIONID_USERSECURITY_DELETESECURITIES)
                        {
                            RemoveSecuritiesFromSecuritiesGrid(securities);
                        }
                    }
                    break;
                }
                }
            }
            m_window.Invalidate();
        }