Example #1
0
        /// <summary>
        /// 重设企业组织架构版本信息
        /// </summary>
        public static IMLibrary3.Protocol.OrgVersion ResetOrgVersion()
        {
            IMLibrary3.Protocol.OrgVersion OrgVersion = new IMLibrary3.Protocol.OrgVersion();
            string GroupsVersion   = "";
            string UsersVersion    = "";
            int    sendGroupsCount = 80;                     //每次发送分组信息数量(太多发送不到对方,太少服务器负载增加)
            int    sendUsersCount  = 80;                     //每次发送用户信息数量(太多发送不到对方,太少服务器负载增加)

            Dictionary <string, Group> Groups = GetGroups(); //获得所有分组信息

            if (Groups != null)
            {
                IMLibrary3.Protocol.DownloadGroups pGroups = new IMLibrary3.Protocol.DownloadGroups();
                pGroups.type = IMLibrary3.Protocol.type.result;

                int i = 0;
                foreach (Group group in Groups.Values)
                {
                    pGroups.Data.Add(group);
                    i++;
                    if (i == sendGroupsCount)
                    {
                        GroupsVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups);
                        OrgVersion.GroupsXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups));
                        pGroups.Data = new List <object>();//分组信息清零
                        i            = 0;
                    }
                }
                if (pGroups.Data.Count > 0)//剩下的分组信息
                {
                    GroupsVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups);
                    OrgVersion.GroupsXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups));
                }

                OrgVersion.GroupsCount   = Groups.Count;
                OrgVersion.GroupsVersion = IMLibrary3.Security.Hasher.GetMD5Hash(Encoding.Default.GetBytes(GroupsVersion));
            }

            Dictionary <string, User> Users = GetUsers();//获得所有用户信息

            if (Users != null)
            {
                IMLibrary3.Protocol.DownloadUsers pUsers = new IMLibrary3.Protocol.DownloadUsers();
                pUsers.type = IMLibrary3.Protocol.type.result;

                int i = 0;
                foreach (User user in Users.Values)
                {
                    pUsers.Data.Add(user);
                    i++;
                    if (i == sendUsersCount)
                    {
                        UsersVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers);
                        OrgVersion.UsersXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers));
                        pUsers.Data = new List <object>();//用户信息清零
                        i           = 0;
                    }
                }
                if (pUsers.Data.Count > 0)//剩下的用户信息
                {
                    UsersVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers);
                    OrgVersion.UsersXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers));
                }

                OrgVersion.UsersCount   = Users.Count;
                OrgVersion.UsersVersion = IMLibrary3.Security.Hasher.GetMD5Hash(Encoding.Default.GetBytes(UsersVersion));
            }

            return(OrgVersion);
        }
Example #2
0
        /// <summary>
        /// 重设企业组织架构版本信息
        /// </summary>
        public static IMLibrary3.Protocol.OrgVersion ResetOrgVersion()
        {
            IMLibrary3.Protocol.OrgVersion OrgVersion = new IMLibrary3.Protocol.OrgVersion();
            string GroupsVersion = "";
            string UsersVersion = "";
            int sendGroupsCount =80;//每次发送分组信息数量(太多发送不到对方,太少服务器负载增加)
            int sendUsersCount = 80;//每次发送用户信息数量(太多发送不到对方,太少服务器负载增加)

            Dictionary<string, Group> Groups = GetGroups();//获得所有分组信息
            if (Groups != null)
            {
                IMLibrary3.Protocol.DownloadGroups pGroups = new IMLibrary3.Protocol.DownloadGroups();
                pGroups.type = IMLibrary3.Protocol.type.result;

                int i = 0;
                foreach (Group group in Groups.Values)
                {
                    pGroups.Data.Add(group);
                    i++;
                    if (i == sendGroupsCount)
                    {
                        GroupsVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups);
                        OrgVersion.GroupsXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups));
                        pGroups.Data = new List<object>();//分组信息清零
                        i = 0;
                    }
                }
                if (pGroups.Data.Count > 0)//剩下的分组信息
                {
                    GroupsVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups);
                    OrgVersion.GroupsXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pGroups));
                }

                OrgVersion.GroupsCount = Groups.Count;
                OrgVersion.GroupsVersion = IMLibrary3.Security.Hasher.GetMD5Hash(Encoding.Default.GetBytes(GroupsVersion));
            }

            Dictionary<string, User> Users = GetUsers();//获得所有用户信息
            if (Users != null)
            {
                IMLibrary3.Protocol.DownloadUsers pUsers = new IMLibrary3.Protocol.DownloadUsers();
                pUsers.type = IMLibrary3.Protocol.type.result;

                int i = 0;
                foreach (User user in Users.Values)
                {
                    pUsers.Data.Add(user);
                    i++;
                    if (i == sendUsersCount)
                    {
                        UsersVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers);
                        OrgVersion.UsersXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers));
                        pUsers.Data = new List<object>();//用户信息清零
                        i = 0;
                    }
                }
                if (pUsers.Data.Count > 0)//剩下的用户信息
                {
                    UsersVersion += IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers);
                    OrgVersion.UsersXML.Add(IMLibrary3.Protocol.Factory.CreateXMLMsg(pUsers));
                }

                OrgVersion.UsersCount = Users.Count;
                OrgVersion.UsersVersion = IMLibrary3.Security.Hasher.GetMD5Hash(Encoding.Default.GetBytes(UsersVersion)); 
            }

            return OrgVersion;
        }