Example #1
0
        private void GetData()
        {
            DBHelper helper = null;

            helper = new DBHelper(_conStrPortalDbRoot);

            DataTable dt;
            long      accID = 0;
            var       query = "";

            if (_id > 0)
            {
                var account = AgencyDAO.GetById(_id);
                if (UserContext.UserInfo.GroupID == 0)
                {
                    if (account != null)
                    {
                        if (account.IsAgency == true)
                        {
                            accID = account.ID;
                        }
                    }
                }
                else
                {
                    if (account != null)
                    {
                        if (account.IsAgency == true)
                        {
                            var agencyInfo = TransactionDAO.GetAgencyInfo(account.GameAccountId);
                            if (agencyInfo != null && agencyInfo.Creator == UserContext.UserInfo.AccountID)
                            {
                                accID = account.GameAccountId;
                            }
                        }
                    }
                }
            }
            else
            {
                var agency = AgencyDAO.GetById(UserContext.UserInfo.AccountID);
                accID = agency.GameAccountId;
            }

            if (_type == 0)
            {
                query = $"select top 1000 * from ag.[Transaction] where {accID} in (SenderID, RecvID) and CreatedTimeInt >= {_start} and CreatedTimeInt <= {_end} order by id desc";
            }
            else if (_type == 1)
            {
                query = $"select top 1000 * from ag.[Transaction] where RecvID = {accID} and CreatedTimeInt >= {_start} and CreatedTimeInt <= {_end} order by id desc";
            }
            else
            {
                query = $"select top 1000 * from ag.[Transaction] where SenderID = {accID} and CreatedTimeInt >= {_start} and CreatedTimeInt <= {_end} order by id desc";
            }
            dt = helper.GetDataTable(query);
            CreateSheet("Lịch sử giao dịch", dt);
        }
        public dynamic AgencyTransaction(int id, string start, string end, int type, int page = 0)
        {
            try
            {
                DateTime from = new DateTime(Convert.ToInt32(start.Substring(0, 4)), Convert.ToInt32(start.Substring(4, 2)), Convert.ToInt32(start.Substring(6, 2)));
                DateTime to   = new DateTime(Convert.ToInt32(end.Substring(0, 4)), Convert.ToInt32(end.Substring(4, 2)), Convert.ToInt32(end.Substring(6, 2)));

                var  skip = page * 50;
                long totalMoney = 0, totalFee = 0;
                if (id > 0)
                {
                    var account = AgencyDAO.GetById(id);
                    if (UserContext.UserInfo.GroupID == 0)
                    {
                        if (account != null)
                        {
                            if (account.IsAgency == true)
                            {
                                var _data = TransactionDAO.TransactionHistory(account.GameAccountId, from, to, type, skip, 50, out totalMoney, out totalFee);
                                return(new
                                {
                                    TotalMoney = totalMoney,
                                    TotalFee = totalFee,
                                    Data = _data
                                });
                            }
                        }
                    }
                    else
                    {
                        if (account != null)
                        {
                            if (account.IsAgency == true)
                            {
                                var agencyInfo = TransactionDAO.GetAgencyInfo(account.GameAccountId);
                                if (agencyInfo != null && agencyInfo.Creator == UserContext.UserInfo.AccountID)
                                {
                                    var _data = TransactionDAO.TransactionHistory(account.GameAccountId, from, to, type, skip, 50, out totalMoney, out totalFee);
                                    return(new
                                    {
                                        TotalMoney = totalMoney,
                                        TotalFee = totalFee,
                                        Data = _data
                                    });
                                }
                            }
                        }
                    }
                }
                else
                {
                    var agency = AgencyDAO.GetById(UserContext.UserInfo.AccountID);
                    if (agency != null)
                    {
                        var _data = TransactionDAO.TransactionHistory(agency.GameAccountId, from, to, type, skip, 50, out totalMoney, out totalFee);
                        return(new
                        {
                            TotalMoney = totalMoney,
                            TotalFee = totalFee,
                            Data = _data
                        });
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(null);
        }