/// <summary> /// Get the QQ Group Name list /// </summary> /// <param name="isLoadGroupAccountDetailedInfo">The flag whether or not to load the group member profile</param> /// <returns></returns> public List <GroupAccount> GetGroupList(bool isLoadGroupAccountDetailedInfo = true) { string url = "http://s.web2.qq.com/api/get_group_name_list_mask2"; string sendData = string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", smartQQ.VFWebQQ, smartQQ.Hash); string dat = HTTP.Post(url, sendData, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2"); Groups groups = (Groups)JsonConvert.DeserializeObject(dat, typeof(Groups)); if (groups.result == null) { return(null); } smartQQ.GroupAccounts = new List <GroupAccount>(); foreach (var group in groups.result.gnamelist) { GroupAccount groupAccount = new GroupAccount(); groupAccount.Code = group.code; groupAccount.Flag = group.flag; groupAccount.Gid = group.gid; groupAccount.Name = group.name; smartQQ.GroupAccounts.Add(groupAccount); } if (isLoadGroupAccountDetailedInfo) { foreach (GroupAccount groupAccount in smartQQ.GroupAccounts) { LoadGroupAccountDetailedInfo(groupAccount); } } return(smartQQ.GroupAccounts); }
public void Ctor_TypeIdSet_Ok() { var a = new Account("nick1", "*****@*****.**"); var gr = new Group("group1", a); var ga = new GroupAccount(a, gr, GroupAccountType.Member); Assert.Equal(GroupAccountType.Member.Id, ga.TypeId); }
public string CreateAccount(GroupAccount groupaccount) { string returnValue = ""; try { returnValue = e.AddGroupAccount(groupaccount); } catch (Exception ex) { returnValue = ex.Message; } return(returnValue); }
public bool DeleteGroupAccount(int ID) { try { GroupAccount groupaccount = db.GroupAccounts.Single(gacc => gacc.ID == ID); db.GroupAccounts.Remove(groupaccount); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool UpdateGroupAccount(GroupAccount groupAccount) { try { GroupAccount groupAccountData = db.GroupAccounts.Single(gacc => gacc.ID == groupAccount.ID); groupAccountData.AccountID = groupAccount.AccountID; groupAccountData.GroupID = groupAccount.GroupID; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
/// <summary> /// Selects the group accounts. /// </summary> /// <param name="_GroupAccount">The _ group account.</param> /// <returns></returns> public List <GroupAccount> SelectGroupAccounts(GroupAccount _GroupAccount) { List <GroupAccount> listGroupAccountSelect = new List <GroupAccount>(); try { listGroupAccountSelect = ApplicationState.DAClient.SelectGroupAccount(_GroupAccount); } catch (Exception ex) { ErrorHandler _ErrorHandler = new ErrorHandler(); _ErrorHandler.ONSERRORProcessing(ex); } return(listGroupAccountSelect); }
public string AddGroupAccount(GroupAccount groupAccount) { string returnString = ""; try { db.GroupAccounts.Add(groupAccount); db.SaveChanges(); returnString = groupAccount.ID.ToString(); } catch (Exception ex) { returnString = ex.Message; } return(returnString); }
/// <summary> /// Inserts the group accounts. /// </summary> /// <param name="_GroupAccount">The _ group account.</param> /// <returns></returns> public ONSResult InsertGroupAccounts(GroupAccount _GroupAccount) { ONSResult _ONSResultSave = new ONSResult(); try { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, DBHelper.TransactionOptions)) { _ONSResultSave = ApplicationState.DAClient.InsertGroupAccount(_GroupAccount); transaction.Complete(); } } catch (Exception ex) { ErrorHandler _ErrorHandler = new ErrorHandler(); _ErrorHandler.ONSERRORProcessing(ex); } return(_ONSResultSave); }
public List <GroupAccount> SelectGroupAccount(GroupAccount parameter) { List <GroupAccount> list = new List <GroupAccount>(); try { var query = from a in _dataContext.GroupAccounts .WhereIf(!String.IsNullOrEmpty(parameter.GroupId), q => q.GroupId == parameter.GroupId) .WhereIf(!String.IsNullOrEmpty(parameter.Name), q => q.Name == parameter.Name) .WhereIf(!String.IsNullOrEmpty(parameter.BalanceType), q => q.BalanceType == parameter.BalanceType) orderby a.Name ascending select a; list = query.ToList <GroupAccount>(); } catch (SqlException ex) { _ErrorHandler.ONSERRORProcessing(ex); } return(list); }
public ONSResult UpdateGroupAccount(GroupAccount parameter) { ONSResult _ONSResultInsert = new ONSResult(); try { List <GroupAccount> list = new List <GroupAccount>(); var query = from a in _dataContext.GroupAccounts where a.GroupId == parameter.GroupId select a; list = query.ToList <GroupAccount>(); if (list.Count == 1) { GroupAccount obj = list[0]; if (!String.IsNullOrEmpty(parameter.GroupId)) { obj.GroupId = parameter.GroupId; } if (!String.IsNullOrEmpty(parameter.Name)) { obj.Name = parameter.Name; } if (!String.IsNullOrEmpty(parameter.BalanceType)) { obj.BalanceType = parameter.BalanceType; } _dataContext.SubmitChanges(); } _ONSResultInsert.IsSuccess = true; _ONSResultInsert.Message = "Group Account updated successfully."; } catch (Exception ex) { _ONSResultInsert.IsSuccess = false; _ONSResultInsert.Message = ex.Message; _ErrorHandler.ONSERRORProcessing(ex); } return(_ONSResultInsert); }
public ONSResult InsertGroupAccount(GroupAccount parameter) { ONSResult _ONSResultInsert = new ONSResult(); try { _dataContext.GroupAccounts.InsertOnSubmit(parameter); _dataContext.SubmitChanges(); _ONSResultInsert.ID = parameter.GroupId; _ONSResultInsert.IsSuccess = true; _ONSResultInsert.Message = "Group Account inserted successfully."; } catch (Exception ex) { _ONSResultInsert.IsSuccess = false; _ONSResultInsert.Message = ex.Message; _ErrorHandler.ONSERRORProcessing(ex); } return(_ONSResultInsert); }
public bool Put(GroupAccount groupaccount) { return(e.UpdateGroupAccount(groupaccount)); }
public void Ctor_Ok() { var a = new Account("nick1", "*****@*****.**"); var gr = new Group("group1", a); var ga = new GroupAccount(a, gr, GroupAccountType.Member); }
/// <summary> /// Get the QQ group member profile /// </summary> /// <param name="groupAccount"></param> private void LoadGroupAccountDetailedInfo(GroupAccount groupAccount) { string gcode = groupAccount.Code; string url = "http://s.web2.qq.com/api/get_group_info_ext2?gcode=#{group_code}&vfwebqq=#{vfwebqq}&t=#{t}".Replace("#{group_code}", gcode).Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{t}", HTTP.AID_TimeStamp()); string dat = HTTP.Get(url, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1"); GroupInfo groupInfo = (GroupInfo)JsonConvert.DeserializeObject(dat, typeof(GroupInfo)); if (groupInfo.result == null) { return; } groupAccount.Class = ""; //groupInfo.result.ginfo.class; groupAccount.Code = groupInfo.result.ginfo.code; groupAccount.CreateTime = groupInfo.result.ginfo.createtime; groupAccount.Memo = groupInfo.result.ginfo.memo; groupAccount.Level = groupInfo.result.ginfo.level; groupAccount.Name = groupInfo.result.ginfo.name; groupAccount.Owner = groupInfo.result.ginfo.owner; Dictionary <string, string> GroupCardList = new Dictionary <string, string>(); if (groupInfo.result.cards != null) { foreach (var goupCard in groupInfo.result.cards) { GroupCardList.Add(goupCard.muin, goupCard.card); } } Dictionary <string, GroupMember> GroupMemberList = new Dictionary <string, GroupMember>(); if (groupInfo.result.minfo != null) { foreach (var minfo in groupInfo.result.minfo) { GroupMember groupMember = new GroupMember(); groupMember.Nick = minfo.nick; groupMember.Province = minfo.province; groupMember.Gender = minfo.gender; groupMember.Uin = minfo.uin; groupMember.Country = minfo.country; groupMember.City = minfo.city; groupMember.Card = GroupCardList.ContainsKey(minfo.uin) ? GroupCardList[minfo.uin] : ""; GroupMemberList.Add(minfo.uin, groupMember); } } groupAccount.Members = new List <GroupMember>(); foreach (var member in groupInfo.result.ginfo.members) { if (GroupMemberList.ContainsKey(member.muin)) { groupAccount.Members.Add(GroupMemberList[member.muin]); } } foreach (var member in groupAccount.Members) { member.Account = GetQQAccountByUin(member.Uin); } }
public void ForestExtractionResource(int forestResource) { ResourcesGroup.forest += forestResource; GroupAccount.Notify(); }
public void GoldExtractionResource(int goldResource) { ResourcesGroup.gold += goldResource; GroupAccount.Notify(); }