public List <ReferenceData.Entity.Account> SearchAccount(string keyword) { List <ReferenceData.Entity.Account> list = null; var resultSet = db.Usp_SearchAccountByEmailOrName(keyword).ToList(); if (resultSet.Count > 0) { string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; list = new List <ReferenceData.Entity.Account>(); foreach (var a in resultSet) { ReferenceData.Entity.Account acc = new ReferenceData.Entity.Account(); acc.id = (int)a.id; acc.email = a.email; acc.password = a.password; acc.firstName = a.firstName; acc.lastName = a.lastName; acc.birthday = a.birthday; acc.createdAt = a.createdAt; acc.avatar = ChatAppUtils.ConvertFileToByte(imagesFolder + a.avatar); list.Add(acc); } } return(list); }
public override void Run() { ReferenceData.Entity.Account account = (ReferenceData.Entity.Account)data.Data; int result = 1; try { db.Usp_InsertAccount(account.email, account.password, account.firstName, account.lastName); } catch (Exception e) { Console.WriteLine(e); result = 0; } SocketData dataRes; if (result == 1) { dataRes = new SocketData("OK", true); } else { dataRes = new SocketData("FAIL", false); } worker.send(dataRes); }
public ReferenceData.Entity.Account UpdateAccount(ReferenceData.Entity.Account acc) { string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; string avatar = "avatar" + acc.id + ".png"; int result = db.Usp_UpdateAccount(acc.id, acc.email, acc.password, acc.firstName, acc.lastName, acc.birthday, avatar); if (result == 1) { File.WriteAllBytes(imagesFolder + avatar, acc.avatar); return(acc); } return(null); }
public void Handle(SocketData data) { ReferenceData.Entity.Account acc = (ReferenceData.Entity.Account)data.Data; foreach (var onl in worker.Server.OnlineList) { if (onl.Acc.id != acc.id) { onl.Worker.send(new SocketData("OFFLINE", acc)); } } worker.Server.OnlineList.Remove(new OnlineAccount(worker, acc)); Console.WriteLine($"Account: {acc.firstName} {acc.lastName}, AccountId: {acc.id} Signed Out!!!"); Console.WriteLine($"Number Of Online Account: {worker.Server.OnlineList.Count}"); }
public override void Run() { ReferenceData.Entity.Account acc = (ReferenceData.Entity.Account)data.Data; ReferenceData.Entity.Account user = new AccountDAO().GetAccountBySignInInfo(acc.email, acc.password); SocketData response = new SocketData("ACCOUNT", user); worker.send(response); if (user != null) { worker.Server.OnlineList.Add(new OnlineAccount(worker, user)); sendConversationList(user); Console.WriteLine($"Account: {user.firstName} {user.lastName}, AccountId: {user.id} Signed In!!!"); Console.WriteLine($"Number Of Online Account: {worker.Server.OnlineList.Count}"); } }
public ReferenceData.Entity.Account GetAccountBySignInInfo(string email, string password) { var list = db.Usp_GetAccountBySignInInfo(email, password).ToList(); ReferenceData.Entity.Account acc = null; if (list.Count > 0) { string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; acc = new ReferenceData.Entity.Account(); foreach (var u in list) { acc.id = u.id; acc.email = u.email; acc.password = u.password; acc.firstName = u.firstName; acc.lastName = u.lastName; acc.avatar = ChatAppUtils.ConvertFileToByte(imagesFolder + u.avatar); acc.birthday = u.birthday; acc.createdAt = u.createdAt; } } return(acc); }
private void sendConversationList(ReferenceData.Entity.Account user) { List <ReferenceData.Entity.Conversation> list = new ConversationDAO(worker.Server.OnlineList).GetConversationListOfAccount(user.id); if (list != null) { SocketData response = new SocketData("CONVERSATIONLIST", list); worker.send(response); foreach (var onl in worker.Server.OnlineList) { if (onl.Acc.id != user.id) { foreach (var c in list) { if (c.memberList.Count == 2) { onl.Worker.send(new SocketData("ONLINE", user)); } } } } } }
public OnlineAccount(ServerWorker worker, ReferenceData.Entity.Account acc) { Worker = worker; Acc = acc; }
public Conversation(ReferenceData.Entity.Conversation conversation, ReferenceData.Entity.Account acc) { InitializeComponent(); Cvst = conversation; Acc = acc; }
public override void Run() { ReferenceData.Entity.Account acc = (ReferenceData.Entity.Account)data.Data; ReferenceData.Entity.Account account = new AccountDAO().UpdateAccount(acc); worker.send(new SocketData("RESULTUPDATE", account)); }
public GroupMember(ReferenceData.Entity.Account acc) { InitializeComponent(); Acc = acc; }