public static async Task InsertGroupMemberInfo(Model.GetGroupMemberListPackage getGroupMemberListPackage) { System.Collections.Concurrent.ConcurrentDictionary <int, DB.GroupMemberInfo> dic = new System.Collections.Concurrent.ConcurrentDictionary <int, DB.GroupMemberInfo>(); var array = getGroupMemberListPackage.data.items.ToArray(); foreach (var item in array) { DB.GroupMemberInfo info = new DB.GroupMemberInfo() { groupId = item.groupId, memoInGroup = item.memoInGroup,//群昵称 userId = item.userId, userName = item.userName, auditUserId = item.auditUserId, city = item.city, createTime = item.createTime, mobile = item.mobile, photo = item.photo, province = item.province, recommendByUser = item.recommendByUser, sex = item.sex }; dic.TryAdd(info.userId, info); } try { await SDKProperty.SQLiteConn.ExecuteAsync($"delete from GroupMemberInfo where groupId ={getGroupMemberListPackage.data.groupId}"); await SDKProperty.SQLiteConn.InsertAllAsync(dic.Values); } catch (Exception) { await SDKProperty.SQLiteConn.ExecuteAsync($"delete from GroupMemberInfo where groupId ={getGroupMemberListPackage.data.groupId}"); } }
public static async Task UpdateGroupMemberInfo(GetGroupMemberPackage memberPackage) { var model = await GetGroupMemberInfo(memberPackage.data.partnerId, memberPackage.data.groupId); if (model == null) { DB.GroupMemberInfo info = new DB.GroupMemberInfo() { groupId = memberPackage.data.user.groupId, memoInGroup = memberPackage.data.user.memoInGroup,//群昵称 userId = memberPackage.data.user.userId, userName = memberPackage.data.user.userName, auditUserId = memberPackage.data.user.auditUserId, city = memberPackage.data.user.city, createTime = memberPackage.data.user.createTime, mobile = memberPackage.data.user.mobile, photo = memberPackage.data.user.photo, province = memberPackage.data.user.province, recommendByUser = memberPackage.data.user.recommendByUser, sex = memberPackage.data.user.sex }; try { await SDKProperty.SQLiteConn.InsertAsync(info); } catch (Exception ex) { SDKClient.logger.Error($"消息处理异常:error:{ex.Message},stack:{ex.StackTrace};\r\n GroupMemberInfo:{Util.Helpers.Json.ToJson(info)}"); } } //else //{ // await SDKProperty.SQLiteConn.DeleteAsync(model); // DB.GroupMemberInfo info = new DB.GroupMemberInfo() // { // groupId = memberPackage.data.user.groupId, // memoInGroup = memberPackage.data.user.memoInGroup,//群昵称 // userId = memberPackage.data.user.userId, // userName = memberPackage.data.user.userName, // auditUserId = memberPackage.data.user.auditUserId, // city = memberPackage.data.user.city, // createTime = memberPackage.data.user.createTime, // mobile = memberPackage.data.user.mobile, // photo = memberPackage.data.user.photo, // province = memberPackage.data.user.province, // recommendByUser = memberPackage.data.user.recommendByUser, // sex = memberPackage.data.user.sex // }; // await SDKProperty.SQLiteConn.InsertAsync(info); //} }
public static async Task <bool> UpdateGroupMemberInfo(DB.GroupMemberInfo groupMemberInfo) { var model = await SDKProperty.SQLiteConn.Table <DB.GroupMemberInfo>().Where(g => g.groupId == groupMemberInfo.groupId && g.userId == groupMemberInfo.userId).FirstOrDefaultAsync(); await SDKProperty.SQLiteConn.DeleteAsync(model); try { int i = await SDKProperty.SQLiteConn.InsertAsync(groupMemberInfo); return(i > 0 ? true : false); } catch (Exception ex) { SDKClient.logger.Error($"消息处理异常:error:{ex.Message},stack:{ex.StackTrace};\r\n"); return(false); } }