Esempio n. 1
0
 /// <summary>
 /// 创建服务
 /// </summary>
 public BSStockService()
 {
     UserCookie cookie = new UserCookie();
     UserCookieService cookieService = DataCenter.UserCookieService;
     if (cookieService.GetCookie("BSSTOCK", ref cookie) > 0)
     {
         try
         {
             m_bsStocks = JsonConvert.DeserializeObject<List<BSStockInfo>>(AESHelper.Decrypt(cookie.m_value));
         }
         catch (Exception ex)
         {
         }
         if (m_bsStocks == null)
         {
             try
             {
                 m_bsStocks = JsonConvert.DeserializeObject<List<BSStockInfo>>(cookie.m_value);
             }
             catch (Exception ex)
             {
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public DimensionService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("DIMENSION", ref cookie) > 0)
            {
                try
                {
                    m_dimensions = JsonConvert.DeserializeObject <List <DimensionInfo> >(AESHelper.Decrypt(cookie.m_value));
                }
                catch (Exception ex)
                {
                }
                if (m_dimensions == null)
                {
                    try
                    {
                        m_dimensions = JsonConvert.DeserializeObject <List <DimensionInfo> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public LevelService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("LEVEL", ref cookie) > 0)
            {
                try
                {
                    m_levels = JsonConvert.DeserializeObject <List <LevelInfo> >(AESHelper.Decrypt(cookie.m_value));
                }
                catch (Exception ex)
                {
                }
                if (m_levels == null)
                {
                    try
                    {
                        m_levels = JsonConvert.DeserializeObject <List <LevelInfo> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public BusinessCardService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("BUSINESSCARD", ref cookie) > 0)
            {
                try
                {
                    m_businessCards = JsonConvert.DeserializeObject <List <BusinessCardInfo> >(AESHelper.Decrypt(cookie.m_value));
                }
                catch (Exception ex)
                {
                }
                if (m_businessCards == null)
                {
                    try
                    {
                        m_businessCards = JsonConvert.DeserializeObject <List <BusinessCardInfo> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public ProjectService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("PROJECT", ref cookie) > 0)
            {
                try
                {
                    m_projects = JsonConvert.DeserializeObject <List <ProjectInfo> >(AESHelper.Decrypt(cookie.m_value));
                }
                catch (Exception ex)
                {
                }
                if (m_projects == null)
                {
                    try
                    {
                        m_projects = JsonConvert.DeserializeObject <List <ProjectInfo> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public CalendarService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("CALENDAR", ref cookie) > 0)
            {
                try
                {
                    m_calendars = JsonConvert.DeserializeObject <Dictionary <String, CalendarInfo> >(AESHelper.Decrypt(cookie.m_value));
                }
                catch (Exception ex)
                {
                }
                if (m_calendars == null)
                {
                    try
                    {
                        m_calendars = JsonConvert.DeserializeObject <Dictionary <String, CalendarInfo> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 退出程序
        /// </summary>
        public override void Exit()
        {
            UserCookie cookie = new UserCookie();

            cookie.m_key    = "MENULAYOUT" + DataCenter.UserID.ToString();
            cookie.m_userID = DataCenter.UserID;
            List <FoldSubMenuA> subMenus = m_foldMenu.SubMenus;
            int           subMenusSize   = subMenus.Count;
            StringBuilder sb             = new StringBuilder();

            for (int i = 0; i < subMenusSize; i++)
            {
                FoldSubMenuA foldSubMenu = subMenus[i];
                sb.Append(foldSubMenu.Name + "," + (foldSubMenu.LayoutDiv.Visible ? "1" : "0") + ",");
                List <ControlA> subControls     = foldSubMenu.LayoutDiv.m_controls;
                int             subControlsSize = subControls.Count;
                for (int j = 0; j < subControlsSize; j++)
                {
                    ControlA subControl = subControls[j];
                    sb.Append(subControl.Name);
                    if (j != subControlsSize - 1)
                    {
                        sb.Append(",");
                    }
                }
                if (i != subMenusSize - 1)
                {
                    sb.Append("\r\n");
                }
            }
            cookie.m_value = sb.ToString();
            DataCenter.UserCookieService.AddCookie(cookie);
        }
Esempio n. 8
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public UserSecurityService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("USERSECURITY", ref cookie) > 0)
            {
                try
                {
                    m_codes = JsonConvert.DeserializeObject <List <UserSecurity> >(cookie.m_value);
                }
                catch (Exception ex)
                {
                }
                if (m_codes == null)
                {
                    try
                    {
                        m_codes = JsonConvert.DeserializeObject <List <UserSecurity> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 创建服务
        /// </summary>
        public FollowService()
        {
            UserCookie        cookie        = new UserCookie();
            UserCookieService cookieService = DataCenter.UserCookieService;

            if (cookieService.GetCookie("FOLLOW", ref cookie) > 0)
            {
                try
                {
                    m_follows = JsonConvert.DeserializeObject <List <FollowInfo> >(AESHelper.Decrypt(cookie.m_value));
                }
                catch (Exception ex)
                {
                }
                if (m_follows == null)
                {
                    try
                    {
                        m_follows = JsonConvert.DeserializeObject <List <FollowInfo> >(cookie.m_value);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
Esempio n. 10
0
 /// <summary>
 /// 保存信息
 /// </summary>
 public void Save()
 {
     UserCookie cookie = new UserCookie();
     cookie.m_key = "BSSTOCK";
     cookie.m_value = AESHelper.Encrypt(JsonConvert.SerializeObject(m_bsStocks));
     UserCookieService cookieService = DataCenter.UserCookieService;
     cookieService.AddCookie(cookie);
 }
Esempio n. 11
0
        /// <summary>
        /// 设置COOKIE
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>结果</returns>
        private double SETCOOKIE(CVariable var)
        {
            String            cookieName    = m_indicator.GetText(var.m_parameters[0]);
            UserCookieService cookieService = DataCenter.UserCookieService;
            UserCookie        cookie        = new UserCookie();

            cookie.m_key   = cookieName;
            cookie.m_value = m_indicator.GetText(var.m_parameters[1]);
            return(cookieService.AddCookie(cookie));
        }
Esempio n. 12
0
        /// <summary>
        /// 保存信息
        /// </summary>
        public void Save()
        {
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "BUSINESSCARD";
            cookie.m_value = AESHelper.Encrypt(JsonConvert.SerializeObject(m_businessCards));
            UserCookieService cookieService = DataCenter.UserCookieService;

            cookieService.AddCookie(cookie);
        }
Esempio n. 13
0
        /// <summary>
        /// 保存信息
        /// </summary>
        public void Save()
        {
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "DIMENSION";
            cookie.m_value = AESHelper.Encrypt(JsonConvert.SerializeObject(m_dimensions));
            UserCookieService cookieService = DataCenter.UserCookieService;

            cookieService.AddCookie(cookie);
        }
Esempio n. 14
0
        /// <summary>
        /// 保存信息
        /// </summary>
        public void Save()
        {
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "PERSONAL";
            cookie.m_value = AESHelper.Encrypt(JsonConvert.SerializeObject(m_personals));
            UserCookieService cookieService = DataCenter.UserCookieService;

            cookieService.AddCookie(cookie);
        }
Esempio n. 15
0
        /// <summary>
        /// 保存信息
        /// </summary>
        public void Save()
        {
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "CALENDAR";
            cookie.m_value = AESHelper.Encrypt(JsonConvert.SerializeObject(m_calendars));
            UserCookieService cookieService = DataCenter.UserCookieService;

            cookieService.AddCookie(cookie);
        }
Esempio n. 16
0
        /// <summary>
        /// 保存信息
        /// </summary>
        public void Save()
        {
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "USERSECURITY";
            cookie.m_value = JsonConvert.SerializeObject(m_codes);
            UserCookieService cookieService = DataCenter.UserCookieService;

            cookieService.AddCookie(cookie);
        }
Esempio n. 17
0
        public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体

        /// <summary>
        /// 加载XML
        /// </summary>
        /// <param name="xmlPath">XML路径</param>
        public override void Load(String xmlPath)
        {
            LoadFile(xmlPath, null);
            DataCenter.MainUI   = this;
            m_mainDiv           = Native.GetControls()[0] as DivA;
            m_mainDiv.BackColor = COLOR.CONTROL;
            ControlPaintEvent paintLayoutEvent = new ControlPaintEvent(PaintLayoutDiv);

            m_mainDiv.RegisterEvent(paintLayoutEvent, EVENTID.PAINT);
            m_mainDiv.RegisterEvent(new ControlInvokeEvent(Invoke), EVENTID.INVOKE);
            DataCenter.ServerChatService.RegisterListener(DataCenter.ChatRequestID, new ListenerMessageCallBack(ChatMessageCallBack));
            m_gridHosts = GetGrid("gridHosts");
            m_gridHosts.GridLineColor = COLOR.CONTROLBORDER;
            GridRowStyle rowStyle = new GridRowStyle();

            rowStyle.HoveredBackColor  = CDraw.PCOLORS_HOVEREDROWCOLOR;
            rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR;
            rowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4;
            rowStyle.Font        = new FONT("微软雅黑", 12, false, false, false);
            m_gridHosts.RowStyle = rowStyle;
            GridRowStyle alternateRowStyle = new GridRowStyle();

            alternateRowStyle.BackColor         = CDraw.PCOLORS_ALTERNATEROWCOLOR;
            alternateRowStyle.HoveredBackColor  = CDraw.PCOLORS_HOVEREDROWCOLOR;
            alternateRowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR;
            alternateRowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4;
            alternateRowStyle.Font        = new FONT("微软雅黑", 12, false, false, false);
            m_gridHosts.AlternateRowStyle = alternateRowStyle;
            m_gridGroups                   = GetGrid("gridGroups");
            m_gridGroups.RowStyle          = rowStyle;
            m_gridGroups.AlternateRowStyle = alternateRowStyle;
            m_gridGroups.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK);
            RegisterEvents(m_mainDiv);
            //全节点服务器
            if (DataCenter.IsFull)
            {
                DataCenter.UserID   = DataCenter.HostInfo.m_localHost + ":" + CStr.ConvertIntToStr(DataCenter.HostInfo.m_localPort);
                DataCenter.UserName = DataCenter.UserID;
                Thread thread = new Thread(new ThreadStart(StartConnect));
                thread.Start();
            }
            else
            {
                UserCookie cookie = new UserCookie();
                if (DataCenter.UserCookieService.GetCookie("USERINFO2", ref cookie) > 0)
                {
                    String[] strs = cookie.m_value.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    GetTextBox("txtPhone").Text    = strs[0];
                    GetTextBox("txtUserName").Text = strs[1];
                    GetTextBox("txtPort").Text     = strs[2];
                }
            }
            m_chatGroups = ChatGroup.ReadGroups();
            BindGroups();
        }
Esempio n. 18
0
        /// <summary>
        /// 更新会话
        /// </summary>
        /// <param name="cookie">会话</param>
        /// <returns>状态</returns>
        public int UpdateCookie(UserCookie cookie)
        {
            String sql = String.Format("UPDATE USERCOOKIE SET VALUE = '{0}' WHERE USERID = {1} AND KEY = '{2}'",
                                       CStrA.GetDBString(cookie.m_value), m_userID, CStrA.GetDBString(cookie.m_key));
            SQLiteConnection conn = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd  = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
            return(1);
        }
Esempio n. 19
0
        /// <summary>
        /// 获取COOKIE
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>状态</returns>
        private double GETCOOKIE(CVariable var)
        {
            String            cookieName    = m_indicator.GetText(var.m_parameters[1]);
            UserCookieService cookieService = DataCenter.UserCookieService;
            UserCookie        cookie        = new UserCookie();

            if (cookieService.GetCookie(cookieName, ref cookie) > 0)
            {
                CVariable newVar = new CVariable(m_indicator);
                newVar.m_expression = "'" + cookie.m_value + "'";
                m_indicator.SetVariable(var.m_parameters[0], newVar);
                return(1);
            }
            return(0);
        }
Esempio n. 20
0
        /// <summary>
        /// 初始化方法
        /// </summary>
        public void Init()
        {
            UserCookie cookie = new UserCookie();

            if (DataCenter.UserCookieService.GetCookie("PLANS", ref cookie) > 0)
            {
                String[] strs     = cookie.m_value.Split(new String[] { "☀" }, StringSplitOptions.RemoveEmptyEntries);
                int      strsSize = strs.Length;
                for (int i = 0; i < strsSize; i++)
                {
                    CPlan plan = new CPlan();
                    plan.FromString(strs[i]);
                    if (plan.m_id.Length > 0)
                    {
                        m_plans[plan.m_id] = plan;
                    }
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 保存
        /// </summary>
        public void SavePlans()
        {
            String       str   = "";
            List <CPlan> plans = new List <CPlan>();

            GetPlans(plans);
            int plansSize = plans.Count;

            for (int i = 0; i < plansSize; i++)
            {
                CPlan plan = plans[i];
                str += plan.ToString();
                str += "☀";
            }
            plans.Clear();
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "PLANS";
            cookie.m_value = str;
            DataCenter.UserCookieService.AddCookie(cookie);
        }
Esempio n. 22
0
        /// <summary>
        /// 添加用户Cookie
        /// </summary>
        /// <param name="cookie">消息</param>
        /// <returns>状态</returns>
        public int AddCookie(UserCookie cookie)
        {
            UserCookie oldCookie = new UserCookie();

            if (GetCookie(cookie.m_key, ref oldCookie) > 0)
            {
                UpdateCookie(cookie);
            }
            else
            {
                String sql = String.Format("INSERT INTO USERCOOKIE(USERID, KEY, VALUE, MODIFYTIME, CREATETIME) values ({0}, '{1}', '{2}','1970-1-1','1970-1-1')",
                                           m_userID, CStrA.GetDBString(cookie.m_key), CStrA.GetDBString(cookie.m_value));
                SQLiteConnection conn = new SQLiteConnection(m_connectStr);
                conn.Open();
                SQLiteCommand cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            return(1);
        }
Esempio n. 23
0
        /// <summary>
        /// 登陆
        /// </summary>
        private void Login()
        {
            String phone    = GetTextBox("txtPhone").Text.Trim();
            String userName = GetTextBox("txtUserName").Text.Trim();
            String myPort   = GetTextBox("txtPort").Text.Trim();

            if (phone.Length == 0)
            {
                MessageBox.Show("请输入手机号码!", "提示");
                return;
            }
            if (userName.Length == 0)
            {
                MessageBox.Show("请输入姓名!", "提示");
                return;
            }
            m_isLogining        = true;
            DataCenter.UserID   = phone;
            DataCenter.UserName = userName;
            UserCookie cookie = new UserCookie();

            cookie.m_key   = "USERINFO2";
            cookie.m_value = phone + "," + userName + "," + myPort;
            DataCenter.UserCookieService.AddCookie(cookie);
            DataCenter.ServerChatService.Port = CStr.ConvertStrToInt(GetTextBox("txtPort").Text);
            OwLibSV.BaseService.StartServer(0, DataCenter.ServerChatService.Port);
            Thread thread = new Thread(new ThreadStart(StartConnect));

            thread.Start();
            while (m_isLogining)
            {
                Thread.Sleep(100);
            }
            GetLabel("lblState").Visible = true;
            GetLabel("lblState").Text    = "用户" + userName + "已登陆";
            GetDiv("divLogin").Visible   = false;
            GetDiv("divChat").Top        = 30;
            Native.Update();
            Native.Invalidate();
        }
Esempio n. 24
0
        /// <summary>
        /// 获取用户Cookie
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="cookie">会话</param>
        /// <returns>状态</returns>
        public int GetCookie(String key, ref UserCookie cookie)
        {
            int              state = 0;
            String           sql   = String.Format("SELECT * FROM USERCOOKIE WHERE USERID = {0} AND KEY = '{1}'", m_userID, CStrA.GetDBString(key));
            SQLiteConnection conn  = new SQLiteConnection(m_connectStr);
            SQLiteCommand    cmd   = conn.CreateCommand();

            cmd.CommandText = sql;
            conn.Open();
            SQLiteDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                cookie.m_userID = reader.GetInt32(0);
                cookie.m_key    = reader.GetString(1);
                cookie.m_value  = reader.GetString(2);
                state           = 1;
            }
            reader.Close();
            conn.Close();
            return(state);
        }
Esempio n. 25
0
 /// <summary>
 /// 接收消息
 /// </summary>
 /// <param name="message">消息</param>
 public override void OnReceive(CMessage message)
 {
     base.OnReceive(message);
     if (DataCenter.IsFull && message.m_functionID == FUNCTIONID_SENDALL)
     {
         DataCenter.ServerChatService.SendAll(message);
     }
     if (message.m_functionID == 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];
                 //全节点
                 if (hostInfo.m_type == 1)
                 {
                     if (hostInfo.m_ip != "127.0.0.1")
                     {
                         OwLibSV.ChatHostInfo serverHostInfo = new OwLibSV.ChatHostInfo();
                         serverHostInfo.m_ip         = hostInfo.m_ip;
                         serverHostInfo.m_serverPort = hostInfo.m_serverPort;
                         serverHostInfo.m_type       = hostInfo.m_type;
                         DataCenter.ServerChatService.AddServerHosts(serverHostInfo);
                         String newServer = hostInfo.m_ip + ":" + CStr.ConvertIntToStr(hostInfo.m_serverPort);
                         List <ChatHostInfo> hostInfos = new List <ChatHostInfo>();
                         UserCookie          cookie    = new UserCookie();
                         if (DataCenter.UserCookieService.GetCookie("DANDANSERVERS", ref cookie) > 0)
                         {
                             hostInfos = JsonConvert.DeserializeObject <List <ChatHostInfo> >(cookie.m_value);
                         }
                         int  hostInfosSize = hostInfos.Count;
                         bool contains      = false;
                         for (int j = 0; j < hostInfosSize; j++)
                         {
                             ChatHostInfo oldHostInfo = hostInfos[j];
                             String       key         = oldHostInfo.ToString();
                             if (key == newServer)
                             {
                                 contains = true;
                                 break;
                             }
                         }
                         if (!contains)
                         {
                             hostInfos.Add(hostInfo);
                             cookie.m_key   = "DANDANSERVERS";
                             cookie.m_value = JsonConvert.SerializeObject(hostInfos);
                             DataCenter.UserCookieService.AddCookie(cookie);
                         }
                         String            key2            = hostInfo.ToString();
                         OwLib.ChatService findChatService = DataCenter.GetClientChatService(key2);
                         if (findChatService == null)
                         {
                             int socketID = OwLib.BaseService.Connect(hostInfo.m_ip, hostInfo.m_serverPort);
                             if (socketID != -1)
                             {
                                 OwLib.ChatService clientChatService = new OwLib.ChatService();
                                 DataCenter.AddClientChatService(key2, clientChatService);
                                 OwLib.BaseService.AddService(clientChatService);
                                 clientChatService.Connected = true;
                                 clientChatService.ToServer  = type == 1;
                                 //clientChatService.RegisterListener(DataCenter.ChatRequestID, new ListenerMessageCallBack(GintechMessageCallBack));
                                 clientChatService.SocketID = socketID;
                                 clientChatService.Enter();
                             }
                         }
                         else
                         {
                             OwLib.ChatService clientChatService = DataCenter.GetClientChatService(key2);
                             if (!clientChatService.Connected)
                             {
                                 int socketID = OwLib.BaseService.Connect(hostInfo.m_ip, hostInfo.m_serverPort);
                                 if (socketID != -1)
                                 {
                                     clientChatService.Connected = true;
                                     clientChatService.SocketID  = socketID;
                                     clientChatService.Enter();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     SendToListener(message);
 }
Esempio n. 26
0
        /// <summary>
        /// 获取App功能
        /// </summary>
        public void GetApps(List <UserAppsTable> type1List, List <UserAppsTable> type2List,
                            List <UserAppsTable> type3List, List <UserAppsTable> type4List)
        {
            PADDING margin1 = new PADDING(5, 5, 5, 5);
            PADDING padding = new PADDING(5, 5, 5, 5);
            PADDING margin2 = new PADDING(5, 5, 5, 5);
            Dictionary <String, FoldSubMenuA> menuCaches = new Dictionary <String, FoldSubMenuA>();

            if (type1List != null && type1List.Count > 0)
            {
                int          num             = type1List.Count;
                FoldSubMenuA menuItemAccount = new FoldSubMenuA();
                m_foldMenu.AddSubMenu(menuItemAccount);
                menuItemAccount.Name              = "TYPE1";
                menuCaches[menuItemAccount.Name]  = menuItemAccount;
                menuItemAccount.TitleLabel.Text   = "员工管理(" + num + ")";
                menuItemAccount.ShrinkButton.Text = "收缩";
                menuItemAccount.ShrinkButton.Name = "shrink";
                menuItemAccount.LayoutDiv.Margin  = margin1;
                menuItemAccount.Padding           = padding;
                menuItemAccount.Margin            = margin2;
                menuItemAccount.TitleLabel.Size   = new SIZE(150, 20);
                menuItemAccount.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type1List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemAccount.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            if (type2List != null && type2List.Count > 0)
            {
                int          num = type2List.Count;
                FoldSubMenuA menuItemFundTrade = new FoldSubMenuA();
                m_foldMenu.AddSubMenu(menuItemFundTrade);
                menuItemFundTrade.Name              = "TYPE2";
                menuCaches[menuItemFundTrade.Name]  = menuItemFundTrade;
                menuItemFundTrade.TitleLabel.Text   = "项目管理(" + num + ")";
                menuItemFundTrade.ShrinkButton.Text = "收缩";
                menuItemFundTrade.ShrinkButton.Name = "shrink";
                menuItemFundTrade.LayoutDiv.Margin  = margin1;
                menuItemFundTrade.Padding           = padding;
                menuItemFundTrade.Margin            = margin2;
                menuItemFundTrade.TitleLabel.Size   = new SIZE(150, 20);
                menuItemFundTrade.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type2List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemFundTrade.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            if (type3List != null && type3List.Count > 0)
            {
                int          num            = type3List.Count;
                FoldSubMenuA menuItemSystem = new FoldSubMenuA();
                menuItemSystem.Name             = "TYPE3";
                menuCaches[menuItemSystem.Name] = menuItemSystem;
                m_foldMenu.AddSubMenu(menuItemSystem);
                menuItemSystem.TitleLabel.Text   = "个人管理(" + num + ")";
                menuItemSystem.ShrinkButton.Text = "收缩";
                menuItemSystem.ShrinkButton.Name = "shrink";
                menuItemSystem.LayoutDiv.Margin  = margin1;
                menuItemSystem.Padding           = padding;
                menuItemSystem.Margin            = margin2;
                menuItemSystem.TitleLabel.Size   = new SIZE(150, 20);
                menuItemSystem.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type3List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemSystem.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            if (type4List != null && type4List.Count > 0)
            {
                int          num          = type4List.Count;
                FoldSubMenuA menuItemRisk = new FoldSubMenuA();
                menuItemRisk.Name             = "TYPE4";
                menuCaches[menuItemRisk.Name] = menuItemRisk;
                m_foldMenu.AddSubMenu(menuItemRisk);
                menuItemRisk.TitleLabel.Text   = "情报管理(" + num + ")";
                menuItemRisk.ShrinkButton.Text = "收缩";
                menuItemRisk.ShrinkButton.Name = "shrink";
                menuItemRisk.LayoutDiv.Margin  = margin1;
                menuItemRisk.Padding           = padding;
                menuItemRisk.Margin            = margin2;
                menuItemRisk.TitleLabel.Size   = new SIZE(150, 20);
                menuItemRisk.ShrinkButton.Size = new SIZE(80, 20);
                foreach (UserAppsTable userApp in type4List)
                {
                    FoldMenuItemA menuButtonAddUser = new FoldMenuItemA();
                    menuButtonAddUser.Text      = userApp.m_appName;
                    menuButtonAddUser.Name      = userApp.m_appID;
                    menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'";
                    menuButtonAddUser.Margin    = margin2;
                    menuItemRisk.LayoutDiv.AddControl(menuButtonAddUser);
                }
            }
            //读取布局信息
            UserCookie cookie = new UserCookie();

            cookie.m_key    = "MENULAYOUT" + DataCenter.UserID.ToString();
            cookie.m_userID = DataCenter.UserID;
            if (DataCenter.UserCookieService.GetCookie(cookie.m_key, ref cookie) > 0)
            {
                String   value    = cookie.m_value;
                String[] strs     = value.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                int      strsSize = strs.Length;
                for (int i = 0; i < strsSize; i++)
                {
                    String[] subStrs  = strs[i].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    String   foldName = subStrs[0];
                    bool     visible  = subStrs[1] == "1";
                    if (menuCaches.ContainsKey(foldName))
                    {
                        FoldSubMenuA foldSubMenu = menuCaches[foldName];
                        foldSubMenu.LayoutDiv.Visible = visible;
                        int subStrsSize = subStrs.Length;
                        int orderNum    = 0;
                        for (int j = 2; j < subStrsSize; j++)
                        {
                            List <ControlA> subControls     = foldSubMenu.LayoutDiv.m_controls;
                            int             subControlsSize = subControls.Count;
                            for (int m = 0; m < subControlsSize; m++)
                            {
                                ControlA subControl = subControls[m];
                                if (subControl.Name == subStrs[j])
                                {
                                    (subControl as FoldMenuItemA).OrderNum = orderNum;
                                    orderNum++;
                                    break;
                                }
                            }
                        }
                        foldSubMenu.LayoutDiv.m_controls.Sort(new FoldMenuItemOrderNumCompare());
                    }
                }
            }
            menuCaches.Clear();
            m_foldMenu.Update();
            Native.Update();
            ControlPaintEvent paintLayoutEvent = new ControlPaintEvent(PaintLayoutDiv);

            m_foldMenu.RegisterEvent(paintLayoutEvent, EVENTID.PAINT);
        }
Esempio n. 27
0
        /// <summary>
        /// 开始启动服务
        /// </summary>
        public void StartConnect()
        {
            List <ChatHostInfo> hostInfos = new List <ChatHostInfo>();
            UserCookie          cookie    = new UserCookie();

            if (DataCenter.UserCookieService.GetCookie("DANDANSERVERS", ref cookie) > 0)
            {
                hostInfos = JsonConvert.DeserializeObject <List <ChatHostInfo> >(cookie.m_value);
            }
            else
            {
                if (DataCenter.HostInfo.m_defaultHost.Length > 0)
                {
                    ChatHostInfo defaultHostInfo = new ChatHostInfo();
                    defaultHostInfo.m_ip         = DataCenter.HostInfo.m_defaultHost;
                    defaultHostInfo.m_serverPort = DataCenter.HostInfo.m_defaultPort;
                    hostInfos.Add(defaultHostInfo);
                }
            }
            int hostInfosSize = hostInfos.Count;

            if (DataCenter.IsFull && hostInfosSize == 0)
            {
                ChatHostInfo defaultHostInfo = new ChatHostInfo();
                defaultHostInfo.m_ip         = "127.0.0.1";
                defaultHostInfo.m_serverPort = 16666;
                hostInfos.Add(defaultHostInfo);
            }
            if (hostInfosSize > 0)
            {
                Random rd = new Random();
                while (DataCenter.IsAppAlive())
                {
                    ChatHostInfo hostInfo = hostInfos[rd.Next(0, hostInfosSize)];
                    int          socketID = OwLib.BaseService.Connect(hostInfo.m_ip, hostInfo.m_serverPort);
                    if (socketID != -1)
                    {
                        String key = hostInfo.ToString();
                        if (m_mainForm != null)
                        {
                            m_mainForm.SetTitle(key);
                            m_mainForm.BeginInvoke(new EventHandler(m_mainForm.SetTitle));
                        }
                        Console.WriteLine(hostInfo.m_ip);
                        OwLib.ChatService clientChatService = new OwLib.ChatService();
                        DataCenter.AddClientChatService(key, clientChatService);
                        OwLib.BaseService.AddService(clientChatService);
                        clientChatService.ToServer  = true;
                        clientChatService.Connected = true;
                        if (!DataCenter.IsFull)
                        {
                            clientChatService.RegisterListener(DataCenter.ChatRequestID, new ListenerMessageCallBack(ChatMessageCallBack));
                        }
                        clientChatService.SocketID = socketID;
                        clientChatService.Enter();
                        m_isLogining = false;
                        DataCenter.CheckConnects();
                        return;
                    }
                }
            }
        }