public static void Handle_User_Data(string token) { User_Info = new User_Information { Username = "" }; Users_Info = new List <User_Information>(); string[] users = Utils.Split(token, '%'); foreach (string user in users) { string[] data = Utils.Split(user, '#'); for (int x = 0; x < data.Length; x++) { data[x] = Encryption.Decrypt(data[x]); } User_Information new_User = new User_Information(); new_User.Id = uint.Parse(data[0]); new_User.Username = data[1]; new_User.Name = data[2]; new_User.Surname = data[3]; Enum.TryParse(data[4], out new_User.Role); new_User.Tel = data[5]; new_User.Email = data[6]; new_User.Polls_Data = Vote_Data.Parse_Data(data[7]); new_User.Events_Data = Vote_Data.Parse_Data(data[8]); new_User.News_Data = new List <uint>(); if (!data[9].Contains("empty")) { foreach (string element in Utils.Split(data[9], '|')) { new_User.News_Data.Add(uint.Parse(element)); } } if (User_Info.Username == "") { User_Info = new_User; } else if (User_Info.Username != new_User.Username) { Users_Info.Add(new_User); } } }
public static List <Vote_Data> Parse_Data(string data) { List <Vote_Data> result = new List <Vote_Data>(); if (data == "empty") { return(result); } string[] elements = Utils.Split(data, "|"); foreach (string element in elements) { string[] pair = Utils.Split(element, "-"); Vote_Data vote_data = new Vote_Data(); vote_data.id = uint.Parse(pair[0]); vote_data.response = int.Parse(pair[1]); result.Add(vote_data); } return(result); }