コード例 #1
0
ファイル: AccountService.cs プロジェクト: sishui198/SmartQQ
        /// <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);
        }
コード例 #2
0
ファイル: GroupAccountTest.cs プロジェクト: Virus887/MailApp
        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);
        }
コード例 #3
0
        public string CreateAccount(GroupAccount groupaccount)
        {
            string returnValue = "";

            try
            {
                returnValue = e.AddGroupAccount(groupaccount);
            }
            catch (Exception ex)
            {
                returnValue = ex.Message;
            }
            return(returnValue);
        }
コード例 #4
0
ファイル: Entity.cs プロジェクト: dkprajapati1988/scimcore
 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);
     }
 }
コード例 #5
0
ファイル: Entity.cs プロジェクト: dkprajapati1988/scimcore
 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);
     }
 }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
ファイル: Entity.cs プロジェクト: dkprajapati1988/scimcore
        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);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
 public bool Put(GroupAccount groupaccount)
 {
     return(e.UpdateGroupAccount(groupaccount));
 }
コード例 #13
0
ファイル: GroupAccountTest.cs プロジェクト: Virus887/MailApp
 public void Ctor_Ok()
 {
     var a  = new Account("nick1", "*****@*****.**");
     var gr = new Group("group1", a);
     var ga = new GroupAccount(a, gr, GroupAccountType.Member);
 }
コード例 #14
0
ファイル: AccountService.cs プロジェクト: sishui198/SmartQQ
        /// <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);
            }
        }
コード例 #15
0
 public void ForestExtractionResource(int forestResource)
 {
     ResourcesGroup.forest += forestResource;
     GroupAccount.Notify();
 }
コード例 #16
0
 public void GoldExtractionResource(int goldResource)
 {
     ResourcesGroup.gold += goldResource;
     GroupAccount.Notify();
 }