Example #1
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void Initialization()
        {
            This_clientConfig.SecretKey = "qizhuhua";

            Qi_LAN_Setting temp1 = new Qi_LAN_Setting();

            temp1.Type = MessageType.WEB;
            temp1.IP   = "192.168.99.93";
            temp1.Port = 5002;
            This_clientConfig.LAN_list.Add(temp1);

            Qi_LAN_Setting temp2 = new Qi_LAN_Setting();

            temp2.Type = MessageType.WEB;
            temp2.IP   = "192.168.99.93";
            temp2.Port = 3389;
            This_clientConfig.LAN_list.Add(temp2);
        }
Example #2
0
        private void Initialization()
        {
            //TODO:这部分最后加,现在暂时使用默认值。
            This_client_Config.SecretKey = "qizhuhua";

            This_client_Config.LAN_list.Clear();

            Qi_LAN_Setting temp1 = new Qi_LAN_Setting();

            temp1.Type = ConnectType.WEB;
            temp1.Note = "我的测试网站";
            temp1.IP   = "192.168.31.29";
            temp1.Port = 80;
            This_client_Config.LAN_list.Add(temp1);

            Qi_LAN_Setting temp2 = new Qi_LAN_Setting();

            temp2.Type = ConnectType.WEB;
            temp2.Note = "公司电脑远程桌面";
            temp2.IP   = "192.168.31.29";
            temp2.Port = 3389;
            This_client_Config.LAN_list.Add(temp2);
        }
Example #3
0
        /// <summary>
        /// 差异更新:相同的不做操作
        /// </summary>
        /// <param name="_old"></param>
        /// <param name="_new"></param>
        private void ChaYiGengXin(ref List <Qi_LAN_Setting> _old, List <Qi_LAN_Setting> _new)
        {
            if (_old.Count == 0)
            {
                //原始没有,直接添加
                for (int i = 0; i < _new.Count; i++)
                {
                    Qi_LAN_Setting temp = new Qi_LAN_Setting();
                    temp.IP   = _new[i].IP;
                    temp.Port = _new[i].Port;
                    temp.Type = _new[i].Type;
                    _old.Add(temp);
                }
            }
            else if (_old.Count == _new.Count)
            {
                bool all_the_same = true;
                for (int i = 0; i < _new.Count; i++)
                {
                    if (_old[i].IP == _new[i].IP && _old[i].Port == _new[i].Port && _old[i].Type == _new[i].Type)
                    {
                        //全等
                    }
                    else
                    {
                        all_the_same = false;

                        //因为数量相等,所以直接更新。
                        _old[i].IP   = _new[i].IP;
                        _old[i].Port = _new[i].Port;
                        _old[i].Type = _new[i].Type;
                    }
                }

                if (!all_the_same)
                {
                    //只要有一个不等,上面已经更新完毕了。
                }
            }
            else
            {
                //最麻烦的就是这个了,差异化。
                int maxNum = _old.Count > _new.Count ? _old.Count : _new.Count; //取个大数
                int minNum = _old.Count > _new.Count ? _new.Count : _old.Count; //取个小数

                if (_old.Count <= _new.Count)
                {
                    //新的配置比旧的配置多
                    for (int i = 0; i < maxNum; i++) // 考虑数量增加的情况
                    {
                        if (_old.Count > i)
                        {
                            //原来就有,暂时不管。
                        }
                        else
                        {
                            //原先没有。加一行
                            Qi_LAN_Setting temp = new Qi_LAN_Setting();
                            temp.IP   = _new[i].IP;
                            temp.Port = _new[i].Port;
                            temp.Type = _new[i].Type;
                            _old.Add(temp);
                        }
                    }
                }
                else
                {
                    //新的配置比旧的配置少
                    List <int> removeIndexS = new List <int>();
                    for (int i = 0; i < maxNum; i++)
                    {
                        if (i > minNum)
                        {
                            removeIndexS.Insert(0, i);
                        }
                        else
                        {
                            //原来就有,暂时不管。
                        }
                    }

                    for (int i = 0; i < removeIndexS.Count; i++)
                    {
                        _old.RemoveAt(removeIndexS[i]);
                    }
                }
            }
        }