Exemplo n.º 1
0
        private static void SaveTeamXML(IList <ChatStore> teamChatList)
        {
            TeamXmlInfo info = new TeamXmlInfo();

            info.DisplayName = LoginUserInfo.DisplayName;
            info.UserName    = LoginUserInfo.UserName;
            info.Teams       = new List <TeamInfo>();
            foreach (ChatStore chat in teamChatList)
            {
                TeamInfo team = new TeamInfo();
                team.groupid       = chat.ChatUserName;
                team.groupname     = chat.ChatDisplayName;
                team.groupuserList = chat.TeamMembers.ToList();
                info.Teams.Add(team);
            }

            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TeamXML");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string fileName = Path.Combine(path, "群组" + info.UserName + ".xml");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            XmlHelper.SerializerToFile(info, fileName);
        }
Exemplo n.º 2
0
        private void CreateXML()
        {
            TeamXmlInfo xml = new TeamXmlInfo();

            xml.DisplayName = "老师111";
            xml.UserName    = "******";
            xml.Teams       = new List <TeamInfo>();
            for (int i = 0; i < 5; i++)
            {
                TeamInfo team = new TeamInfo();
                team.groupname     = "群组" + i;
                team.groupid       = Guid.NewGuid().ToString();
                team.groupuserList = new List <TeamMember>();
                for (int j = 0; j < 5; j++)
                {
                    TeamMember member = new TeamMember();
                    member.DisplayName = team.groupname + "成员" + j;
                    member.UserName    = Guid.NewGuid().ToString();
                    team.groupuserList.Add(member);
                }
                xml.Teams.Add(team);
            }
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TeamXML");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string fileName = Path.Combine(path, "群组" + xml.UserName + ".xml");

            XmlHelper.SerializerToFile(xml, fileName);
            TeamXmlInfo xml2 = XmlHelper.DeserializeFromFile <TeamXmlInfo>(fileName);
        }
Exemplo n.º 3
0
        public static void LoadTeamFromXML()
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TeamXML");

            if (!Directory.Exists(path))
            {
                return;
            }
            string fileName = Path.Combine(path, "群组" + LoginUserInfo.UserName + ".xml");

            if (!File.Exists(fileName))
            {
                return;
            }
            TeamXmlInfo info = XmlHelper.DeserializeFromFile <TeamXmlInfo>(fileName);
            TeamChatCreateOrUpdateRequest loadTeam = new TeamChatCreateOrUpdateRequest();

            loadTeam.TeamInfos = info.Teams;
            RefleshTeamList(loadTeam);
        }