Beispiel #1
0
        public int SendVisitsCount(int functionID, int requestID, UserSecurityVisitsCount visitsCount)
        {
            Binary binary = new Binary();

            binary.WriteInt(visitsCount.m_userID);
            binary.WriteString(visitsCount.CodesToString());
            byte[] bytes = binary.GetBytes();
            int    num   = this.Send(new CMessage(base.GroupID, base.ServiceID, functionID, base.SessionID, requestID, this.m_socketID, 0, base.CompressType, bytes.Length, bytes));

            binary.Close();
            return(num);
        }
        /// <summary>
        /// 添加访问次数
        /// </summary>
        /// <param name="code">代码</param>
        /// <returns>状态</returns>
        public int AddVisitsCount(String code)
        {
            UserSecurityVisitsCount visitsCount = new UserSecurityVisitsCount();

            visitsCount.m_userID      = DataCenter.UserID;
            visitsCount.m_codes[code] = 1;
            AddVisitsCount(0, visitsCount);
            if (m_visitsCount.ContainsKey(code))
            {
                m_visitsCount[code] = m_visitsCount[code] + 1;
            }
            else
            {
                m_visitsCount[code] = 1;
            }
            return(1);
        }
Beispiel #3
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);
        }
Beispiel #4
0
 public int AddVisitsCount(int requestID, UserSecurityVisitsCount visitsCount)
 {
     return((this.SendVisitsCount(8, requestID, visitsCount) > 0) ? 1 : 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);
        }