private void ThreadPoolLoadPortrait(object obj) { // 向服务器请求小头像 if (obj is NetAccount m_NetAccount) { try { System.Drawing.Bitmap bitmap = UserPortrait.DownloadSmallPortraint(m_NetAccount.UserName); MemoryStream ms = new MemoryStream(); bitmap.Save(ms, bitmap.RawFormat); bitmap.Dispose(); Dispatcher.Invoke(new Action(() => { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = ms; bi.EndInit(); Image1.Source = bi; })); } catch (Exception ex) { UserClient.LogNet?.WriteException("Thread Download Portrait Failed", ex); } } }
private void SoftUserPortraitInitialization() { SoftUserPortrait = new UserPortrait(AppDomain.CurrentDomain.BaseDirectory + @"Portrait\" + UserClient.UserAccount.UserName, m => { byte[] content = System.IO.File.ReadAllBytes(m); BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.StreamSource = new System.IO.MemoryStream(content); bi.EndInit(); AccountPortrait.Source = bi; }, () => { AccountPortrait.Source = null; }); }
protected override async void Run(Session session, C2G_QueryUserPortrait message, Action <G2C_QueryUserPortrait> reply) { G2C_QueryUserPortrait response = new G2C_QueryUserPortrait(); UserPortrait UserPortrait = null; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserPortrait>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count <= 0) { UserPortrait Info = ComponentFactory.Create <UserPortrait>(); Info._AccountID = message.AccountID; Info._InfoID = message.InfoID; Info._PortraitList = new List <int>(); response.PortraitList = RepeatedFieldAndListChangeTool.ListToRepeatedField(Info._PortraitList); await dBProxyComponent.Save(Info); await dBProxyComponent.SaveLog(Info); } else { UserPortrait = acounts[0] as UserPortrait; response.PortraitList = RepeatedFieldAndListChangeTool.ListToRepeatedField(UserPortrait._PortraitList); await dBProxyComponent.Save(UserPortrait); await dBProxyComponent.SaveLog(UserPortrait); } reply(response); } catch (Exception e) { response.Message = "数据库异常"; ReplyError(response, e, reply); } }
protected override async void Run(Session session, C2G_AddUserPortrait message, Action <G2C_AddUserPortrait> reply) { G2C_AddUserPortrait response = new G2C_AddUserPortrait(); UserPortrait UserPortrait = null; response.IsOk = false; try { DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); var acounts = await dBProxyComponent.Query <UserPortrait>("{ '_AccountID': " + message.AccountID + "}"); if (acounts.Count <= 0) { UserPortrait userPortrait = ComponentFactory.Create <UserPortrait>(); userPortrait._AccountID = message.AccountID; userPortrait._InfoID = message.InfoID; userPortrait._PortraitList = new List <int>(); UserPortrait = userPortrait; } if (acounts.Count > 0 || UserPortrait != null) { if (UserPortrait == null) { UserPortrait = acounts[0] as UserPortrait; } UserPortrait._PortraitList.Insert(0, message.Portrait); response.IsOk = true; } await dBProxyComponent.Save(UserPortrait); await dBProxyComponent.SaveLog(UserPortrait); reply(response); } catch (Exception e) { response.IsOk = false; response.Message = "数据库异常"; ReplyError(response, e, reply); } }
private void SoftUserPortraitInitialization() { SoftUserPortrait = new UserPortrait(AppDomain.CurrentDomain.BaseDirectory + @"Portrait\" + UserClient.UserAccount.UserName, ShowSmallPortrait); }
private void SoftUserPortraitInitialization() { SoftUserPortrait = new UserPortrait(Application.StartupPath + @"\Portrait\" + UserClient.UserAccount.UserName, m => pictureBox1.LoadAsync(m), null); }
private void SoftUserPortraitInitialization() { SoftUserPortrait = new UserPortrait(Application.StartupPath + @"\Portrait\" + UserClient.UserAccount.UserName, LoadSmallProtraitAsync); }
public string GetRemarkInfo(string remarkIdStr) { return(CommonLib.Helper.JsonSerializeObject(UserPortrait.GetRemarkInfo(remarkIdStr))); }
public string GetUserExtInfo(int accid) { return(UserPortrait.GetUserExtInfo(accid)); }
public string AddUserPortrait(P_Sys_UserPortraitModel model) { return(UserPortrait.AddUserPortrait(model)); }
public string GetDicItem() { return(UserPortrait.GetDicItem()); }
public string AddNewDicItem(int itemType, string addItemValue, int parentId = 0) { return(UserPortrait.AddNewDicItem(itemType, addItemValue, parentId)); }
public string GetSingleUsrPortrait(int accId) { return(UserPortrait.GetSingleUsrPortrait(accId)); }