Пример #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (BrokerId.Length != 0)
            {
                hash ^= BrokerId.GetHashCode();
            }
            if (UserId.Length != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (UserProductInfo.Length != 0)
            {
                hash ^= UserProductInfo.GetHashCode();
            }
            if (AppId.Length != 0)
            {
                hash ^= AppId.GetHashCode();
            }
            if (AppType != 0)
            {
                hash ^= AppType.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #2
0
        protected override async void Run(Session session, C2G_UserProductInfo message, Action <G2C_UserProductInfo> reply)
        {
            G2C_UserProductInfo response        = new G2C_UserProductInfo();
            UserProductInfo     UserProductInfo = null;

            response.IsOk = false;
            try
            {
                DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
                var acounts = await dBProxyComponent.Query <UserProductInfo>("{ '_AccountID': " + message.AccountID + "}");

                if (acounts.Count <= 0)
                {
                    UserProductInfo userProductInfo = ComponentFactory.Create <UserProductInfo>();
                    userProductInfo._AccountID   = message.AccountID;
                    userProductInfo._InfoID      = message.InfoID;
                    userProductInfo._ProductList = new List <int>();
                    userProductInfo._UserPoint   = 0;

                    UserProductInfo = userProductInfo;
                }
                if (acounts.Count > 0 || UserProductInfo != null)
                {
                    if (UserProductInfo == null)
                    {
                        UserProductInfo = acounts[0] as UserProductInfo;
                    }
                    if (message.Type == 1)
                    {
                        UserProductInfo._ProductList.Insert(0, message.Product);
                        response.IsOk = true;
                    }
                    if (message.Type == 2)
                    {
                        UserProductInfo._ProductList.Remove(message.Product);
                        response.IsOk = true;
                    }
                }

                await dBProxyComponent.Save(UserProductInfo);

                await dBProxyComponent.SaveLog(UserProductInfo);

                reply(response);
            }
            catch (Exception e)
            {
                response.IsOk    = false;
                response.Message = "数据库异常";
                ReplyError(response, e, reply);
            }
        }
Пример #3
0
        protected override async void Run(Session session, C2G_QueryUserProductInfo message, Action <G2C_QueryUserProductInfo> reply)
        {
            G2C_QueryUserProductInfo response        = new G2C_QueryUserProductInfo();
            UserProductInfo          UserProductInfo = null;

            try
            {
                DBProxyComponent dBProxyComponent = Game.Scene.GetComponent <DBProxyComponent>();

                var acounts = await dBProxyComponent.Query <UserProductInfo>("{ '_AccountID': " + message.AccountID + "}");

                if (acounts.Count <= 0)
                {
                    UserProductInfo Info = ComponentFactory.Create <UserProductInfo>();

                    Info._AccountID   = message.AccountID;
                    Info._InfoID      = message.InfoID;
                    Info._ProductList = new List <int>();
                    Info._UserPoint   = 0;

                    response.ProductList = RepeatedFieldAndListChangeTool.ListToRepeatedField(Info._ProductList);
                    response.UserPoint   = Info._UserPoint;
                    await dBProxyComponent.Save(Info);

                    await dBProxyComponent.SaveLog(Info);
                }
                else
                {
                    UserProductInfo = acounts[0] as UserProductInfo;

                    response.ProductList = RepeatedFieldAndListChangeTool.ListToRepeatedField(UserProductInfo._ProductList);
                    response.UserPoint   = UserProductInfo._UserPoint;

                    await dBProxyComponent.Save(UserProductInfo);

                    await dBProxyComponent.SaveLog(UserProductInfo);
                }

                reply(response);
            }
            catch (Exception e)
            {
                response.Message = "数据库异常";
                ReplyError(response, e, reply);
            }
        }