public async Task <IHttpActionResult> Post(AccountEvent request)
        {
            await _orchestrator.CreateEvent(request);

            // 201 for list of all events
            return(CreatedAtRoute("GetAllAccountEvents", new {}, default(AccountEvent)));
        }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccountEvent accountEvent = new AccountEvent("03401", "李明", 200);

        accountEvent.Overdraw += new EventHandler(account_Overdraw);
        accountEvent.Acquire(400);
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccountEvent account = new AccountEvent("3113002319", "李代福", 200);

        account.Overdraw += new EventHandler(account_Overdraw);
        account.Acquire(300);
    }
Example #4
0
    void GetUserInfoResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        UnityEngine.Debug.Log("GetUserInfoResultHandler" + MiniJSON.jsonEncode(result));

        if (state == ResponseState.Success)
        {
            AccountEvent.ThirdPartyLoginResult ret;
            ret.head = (string)result["figureurl_qq_2"];
            ret.name = (string)result["nickname"];
            ret.sex  = ((string)result["gender"]) == "女"?0:1;

            ret.openId     = _thirdOpenId;
            ret.token      = _thirdToken;
            ret.expireTime = _thirdExpireTime;

            AccountEvent.EM().InvokeEvent(AccountEvent.EVENT.THIRD_PARTY_LOGIN_RET, (object)ret);
        }
        else if (state == ResponseState.Fail)
        {
            CommonUtil.Util.showDialog("温馨提示", "获取用户信息错误! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
        }
        else if (state == ResponseState.Cancel)
        {
            CommonUtil.Util.showDialog("温馨提示", "您取消了登陆");
        }
    }
        protected override async Task HandleCore(CreateAccountEventCommand command)
        {
            _logger.Info($"Received message {command.Event}", accountId: command.ResourceUri, @event: command.Event);

            Validate(command);

            try
            {
                var newAccountEvent = new AccountEvent
                {
                    Event       = command.Event,
                    CreatedOn   = DateTime.UtcNow,
                    ResourceUri = command.ResourceUri
                };

                await _accountEventRepository.Create(newAccountEvent);

                _logger.Info($"Finished processing message {command.Event}");
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Error processing message {command.Event} - {ex.Message}", accountId: command.ResourceUri, @event: command.Event);
                throw;
            }
        }
Example #6
0
    public void addAllEvent()
    {
        AccountEvent.EM().AddEvent(AccountEvent.EVENT.LOGIN_SUCCESS, onAccountLoginSuccess);
        //子界面或独立界面刷新事件,请参考store
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_USER_INFO, onEventShowUserInfo);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_PLAZA, onEventShowPlaza);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_LUCKDRAW, onEventShowLuckDraw);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_PACKAGE, onEventShowPackage);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_PRIVATE_MSG, onEventShowPrivateMsg);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_SIGNIN, onEventShowSignIn);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_STORE, onEventShowStore);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_FRIEND, onEventShowFriend);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.SHOW_RANK, onEventShowRank);

        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.REQ_UPDATE_EMAIL, onEventReqUpdateEmail);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.REQ_FEEDBACK, onEventReqFeedback);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.REQ_OPEN_TALENTSLOT, onEventReqOpenTalentslot);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.UPDATE_USER_TALENT, onEventUpdateUserTalent);

        //声音
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.OPEN_CLOSE_BG_SND, onEventBgSndSwitch);
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.OPEN_CLOSE_EFFECT_SND, onEventEffectSndSwitch);


        ProtocolManager.getInstance().addPushMsgEventListener(LobbyProtocol.P_LOBBY_AWARD_EMAIL, OnAwardEmail);
    }
 private void FormAdmin_UpdateAccountEvent(object sender, AccountEvent e)
 {
     lbDisplayName.Text = e.Acc.DisplayName;
     if (e.Acc.Type == 0)
     {
         btnAdmin.Hide();
     }
 }
Example #8
0
    // Use this for initialization
    void Start()
    {
        //add all need game event and call back
        ssdk.authHandler     = AuthResultHandler;
        ssdk.showUserHandler = GetUserInfoResultHandler;

        AccountEvent.EM().InvokeEvent(AccountEvent.EVENT.CONNECT_SERVER, (object)false);
    }
Example #9
0
 public static AccountEvent EM()
 {
     if (_instance == null)
     {
         _instance = new AccountEvent();
     }
     return(_instance);
 }
Example #10
0
 // обработчик вывода средств
 private static void WithdrawSumHandler(object sender, AccountEvent e)
 {
     Console.WriteLine(e.Message);
     if (e.Sum > 0)
     {
         Console.WriteLine("Идем тратить деньги");
     }
 }
Example #11
0
        public bool UpdateAccount(UpdateCustomerEvent updateAccount, DbAccount accountDetails)
        {
            try
            {
                var accountEvent = new AccountEvent
                {
                    AccountName          = updateAccount.CustomerName,
                    AccountUID           = updateAccount.CustomerUID,
                    Action               = Operation.Update.ToString(),
                    BSSID                = updateAccount.BSSID,
                    DealerAccountCode    = updateAccount.DealerAccountCode,
                    NetworkCustomerCode  = updateAccount.NetworkCustomerCode,
                    fk_ParentCustomerUID = accountDetails.fk_ParentCustomerUID ?? null,
                    fk_ChildCustomerUID  = accountDetails.fk_ChildCustomerUID ?? null,
                    ActionUTC            = updateAccount.ActionUTC,
                    ReceivedUTC          = updateAccount.ReceivedUTC
                };

                if (!FieldHelper.IsValidValuesFilled(accountEvent, accountDetails, logger))
                {
                    logger.LogError("DB Object expects typeOf IDbTable");
                }

                FieldHelper.ReplaceEmptyFieldsByNull(accountEvent);

                var message = new KafkaMessage
                {
                    Key     = updateAccount.CustomerUID.ToString(),
                    Topic   = AccountTopic,
                    Message = new { AccountEvent = accountEvent }
                };

                var accountObj = new DbAccount
                {
                    CustomerAccountID  = accountDetails.CustomerAccountID,
                    CustomerAccountUID = accountEvent.AccountUID,
                    BSSID                = accountEvent.BSSID,
                    AccountName          = accountEvent.AccountName,
                    NetworkCustomerCode  = accountEvent.NetworkCustomerCode,
                    DealerAccountCode    = accountEvent.DealerAccountCode,
                    fk_ChildCustomerUID  = accountDetails.fk_ChildCustomerUID ?? null,
                    fk_ParentCustomerUID = accountDetails.fk_ParentCustomerUID ?? null,
                    RowUpdatedUTC        = DateTime.UtcNow
                };

                var actions = new List <Action>()
                {
                    () => transaction.Upsert(accountObj),
                    () => transaction.Publish(message)
                };
                return(transaction.Execute(actions));
            }
            catch (Exception ex)
            {
                logger.LogError($"Error while updating account customer : {ex.Message}, {ex.StackTrace}");
                throw;
            }
        }
Example #12
0
 // Калл бэк при старте модуля
 public static void OnStartGameScene(GameScene scene)        // калл бэк при загрузке модуля: ...
 //var _this = getScenesController;
 {
     if (scene == GameScene.RAFFLE)
     {
         //var accountEvent = _this.getNetwork().GetComponent<AccountEvent>();
         AccountEvent.requestAccountInformation();
     }
 }
        public async Task ThenTheEventIsCreated()
        {
            var request = new AccountEvent {
                ResourceUri = "/api/accounts/ABC123", Event = "Test"
            };
            await Orchestrator.CreateEvent(request);

            EventsLogger.Verify(x => x.Info($"Creating Account Event ({request.Event})", request.ResourceUri, null, request.Event));
            Mediator.Verify(m => m.SendAsync(It.Is <CreateAccountEventCommand>(x => x.ResourceUri == request.ResourceUri && x.Event == request.Event)));
        }
Example #14
0
        private void CreateHistory(AccountEvent accountEvent, CancellationToken cancellationToken)
        {
            var account = _context.Accounts.Find(accountEvent.Account.No);

            if (account is Account)
            {
                var history = new AccountOperation(accountEvent.When, accountEvent.ToString(), accountEvent.Amount, accountEvent.What);
                account.AddOperation(history);
            }
        }
    public void addAllEvent()
    {
        AccountEvent.EM().AddEvent(AccountEvent.EVENT.CONNECT_SERVER, onConnectServer);
        AccountEvent.EM().AddEvent(AccountEvent.EVENT.LOGIN, onLogin);
        AccountEvent.EM().AddEvent(AccountEvent.EVENT.LOGOUT, onLogout);
        AccountEvent.EM().AddEvent(AccountEvent.EVENT.THIRD_PARTY_LOGIN_RET, onThirdPartyLoginResult);

        AccountEvent.EM().AddEvent(AccountEvent.EVENT.NETWORK_DISCONNECT, onDisconnect);
        AccountEvent.EM().AddEvent(AccountEvent.EVENT.NETWORK_ERROR, onError);
    }
Example #16
0
 //void onMarketItemsRecive() {
 //AccountEvent.requestAccountInformation(); // запрашиваем данные об аккаунте
 //}
 void onRoomsReceive(RoomsData rooms) // █ получив комнаты
 {
     Rooms.setNewRoomsData(rooms);
     /////////////////////////////////////////////////////////
     //var controller = WindowController.getWinController;
     //MarketEvent marketEvent = controller.getMarketEvent();
     //marketEvent.OnReady += (sender, e) => controller.onMarketItemsRecive();
     //WindowController.requestContent(WindowController.TypePopUpWindow.NONE);
     /////////////////////////////////////////////////////////
     AccountEvent.requestAccountInformation(); // запрашиваем данные об аккаунте
 }
        public async Task Publish(AccountEvent evt)
        {
            var message = new BrokeredMessage();

            message.Properties["AccountId"]  = evt.AccountId;
            message.Properties["CustomerId"] = evt.CustomerId;
            message.Properties["Type"]       = evt.Type.ToString();
            message.Properties["Amount"]     = evt.Amount;

            await _queueClient.SendAsync(message);
        }
        public void AndValidationFailsThenTheFailureIsLogged()
        {
            var request             = new AccountEvent();
            var validationException = new ValidationException("Exception");

            Mediator.Setup(m => m.SendAsync(It.Is <CreateAccountEventCommand>(x => x.ResourceUri == request.ResourceUri && x.Event == request.Event))).ThrowsAsync(validationException);

            Assert.ThrowsAsync <ValidationException>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Warn(validationException, "Invalid request", request.ResourceUri, null, request.Event));
        }
        public void AndAnExceptionOccursThenTheErrorIsLogged()
        {
            var request   = new AccountEvent();
            var exception = new Exception("Exception");

            Mediator.Setup(m => m.SendAsync(It.Is <CreateAccountEventCommand>(x => x.ResourceUri == request.ResourceUri && x.Event == request.Event))).ThrowsAsync(exception);

            Assert.ThrowsAsync <Exception>(() => Orchestrator.CreateEvent(request));

            EventsLogger.Verify(x => x.Error(exception, exception.Message, null, null, null));
        }
        /// <summary>
        /// Brokerages can send account updates, this include cash balance updates. Since it is of
        /// utmost important to always have an accurate picture of reality, we'll trust this information
        /// as truth
        /// </summary>
        private void HandleAccountChanged(AccountEvent account)
        {
            // how close are we?
            var delta = _algorithm.Portfolio.CashBook[account.CurrencySymbol].Quantity - account.CashBalance;

            if (delta != 0)
            {
                Log.Trace(string.Format("BrokerageTransactionHandler.HandleAccountChanged(): {0} Cash Delta: {1}", account.CurrencySymbol, delta));
            }

            // override the current cash value to we're always gauranted to be in sync with the brokerage's push updates
            _algorithm.Portfolio.CashBook[account.CurrencySymbol].Quantity = account.CashBalance;
        }
Example #21
0
        public async Task CreateAccountEvent()
        {
            var input           = new AccountEvent();
            var employerRequest = new TestRequest(new Uri(ExpectedApiBaseUrl + $"api/events/accounts"), JsonConvert.SerializeObject(input));

            _fakeHandler.AddFakeResponse(employerRequest, new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK, Content = new StringContent(string.Empty)
            });

            await _sut.CreateAccountEvent(input);

            Assert.Pass();
        }
Example #22
0
        /// <summary>
        /// Event invocator for the AccountChanged event
        /// </summary>
        /// <param name="e">The AccountEvent</param>
        protected virtual void OnAccountChanged(AccountEvent e)
        {
            try
            {
                Log.Trace($"Brokerage.OnAccountChanged(): {e}");

                AccountChanged?.Invoke(this, e);
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }
Example #23
0
        public override void SetInstance(ScheduleInstance instance)
        {
            if (instance.Schedule.AccountEvents == null || instance.Schedule.AccountEvents.Count != 1)
            {
                throw new Exception(string.Format("Orphaned schedule instance {0}.", instance.Id));
            }

            AccountEvent evt = (AccountEvent)instance.Schedule.AccountEvents[0];

            AccountEventId   = evt.Id;
            AccountEventType = evt.AccountEventType.Name;
            Description      = evt.Description;
            Created          = evt.Created;
            Modified         = evt.Modified;
            AccountId        = evt.Account.Id;
            AccountName      = evt.Account.Name;
            ScheduleId       = evt.Schedule.Id;
            PlaceId          = evt.Place.Id;
            PlaceName        = evt.Place.Name;
            if (evt.Place.City != null)
            {
                PlaceCity = evt.Place.City.Name;
            }
            if (evt.Place.City != null && evt.Place.City.Country != null)
            {
                PlaceCountry = evt.Place.City.Country.Name;
            }
            if (evt.Place.City != null && evt.Place.City.State != null)
            {
                PlaceState = evt.Place.City.State.Name;
            }
            if (evt.Place.Neighborhood != null)
            {
                PlaceNeighborhood = evt.Place.Neighborhood.Name;
            }
            Name      = evt.Name;
            Phone     = evt.Phone;
            Email     = evt.Email;
            Website   = evt.Website;
            Cost      = evt.Cost;
            PictureId = ManagedService <AccountEventPicture, TransitAccountEventPicture> .GetRandomElementId(evt.AccountEventPictures);

            StartDateTime = instance.StartDateTime;
            EndDateTime   = instance.EndDateTime;
            Instance      = instance.Instance;
            NoEndDateTime = instance.Schedule.NoEndDateTime;

            base.SetInstance(instance);
        }
Example #24
0
File: Errors.cs Project: lunice/bgo
    public static void showError(Api.ServerErrors serverErrorType, GameScene fromScene = GameScene.UNDEF)
    {
        switch (serverErrorType)
        {
        case Api.ServerErrors.E_VERSION_ERROR: showError(TypeError.ES_NEED_UPDATE, fromScene); break;

        case Api.ServerErrors.E_SESSION_EXPIRED: showError(TypeError.ES_SESSION_EXPIRED, fromScene); break;

        case Api.ServerErrors.E_REQUEST_PARAMS: show("Ошибка покупки", () => { WindowController.rebildCurrentWindow(); }); break;

        case Api.ServerErrors.E_DRAWING_END: ScenesController.loadScene(GameScene.MAIN_MENU); break;

        case Api.ServerErrors.E_NOT_ENOUGH: {
            var errWnd = show("Недостаточно средств для совершения операции.\nПопробуйте ещё.");
            errWnd.setAction(0, () => {
                    WindowController.rebildCurrentWindow();
                    AccountEvent.requestAccountInformation();
                    if (fromScene == GameScene.RAFFLE)
                    {
                        ScenesController.loadScene(GameScene.MAIN_MENU);
                    }
                });
        } break;

        case Api.ServerErrors.E_SESSION: { showErrorAndReAutification("Ошибка сессии"); } break;

        case Api.ServerErrors.E_SESSION_ID: { showErrorAndReAutification("Ошибка сессии"); } break;

        case Api.ServerErrors.E_DB_ERROR: showServerError("Ошибка сервера", fromScene); break;

        case Api.ServerErrors.E_TEMP_ERROR: showServerError("Временная ошибка сервера", fromScene); break;

        case Api.ServerErrors.E_PENDING: showServerError("ошибка сервера", fromScene); break;

        default: {
            if (fromScene != GameScene.AUTORIZATION)
            {
                var errWnd = show("Неизвестная ошибка");
                errWnd.setAction(0, () => { ScenesController.loadScene(GameScene.AUTORIZATION); });
            }
            else
            {
                var errWnd = show("Приложение не рабочее", "выход");
                errWnd.setAction(0, () => { MAIN.exit(); });
            }
        }  break;
        }
    }
        /// <summary>
        /// Brokerages can send account updates, this include cash balance updates. Since it is of
        /// utmost important to always have an accurate picture of reality, we'll trust this information
        /// as truth
        /// </summary>
        private void HandleAccountChanged(AccountEvent account)
        {
            // how close are we?
            var delta = _algorithm.Portfolio.CashBook[account.CurrencySymbol].Amount - account.CashBalance;
            if (delta != 0)
            {
                Log.Trace(string.Format("BrokerageTransactionHandler.HandleAccountChanged(): {0} Cash Delta: {1}", account.CurrencySymbol, delta));
            }

            // maybe we don't actually want to do this, this data can be delayed. Must be explicitly supported by brokerage
            if (_brokerage.AccountInstantlyUpdated)
            {
                // override the current cash value so we're always guaranteed to be in sync with the brokerage's push updates
                _algorithm.Portfolio.CashBook[account.CurrencySymbol].SetAmount(account.CashBalance);
            }
        }
Example #26
0
        /// <summary>
        /// Event invocator for the AccountChanged event
        /// </summary>
        /// <param name="e">The AccountEvent</param>
        protected virtual void OnAccountChanged(AccountEvent e)
        {
            try
            {
                Log.Trace("Brokerage.OnAccountChanged(): " + e);

                var handler = AccountChanged;
                if (handler != null)
                {
                    handler(this, e);
                }
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }
Example #27
0
        /// <summary>
        /// Event invocator for the AccountChanged event
        /// </summary>
        /// <param name="e">The AccountEvent</param>
        protected virtual void OnAccountChanged(AccountEvent e)
        {
            try
            {
                if (!CashSyncEnabled)
                {
                    Log.Trace($"Brokerage.OnAccountChanged(): {e}. Skipping cash sync disabled");
                    return;
                }
                Log.Trace($"Brokerage.OnAccountChanged(): {e}");

                AccountChanged?.Invoke(this, e);
            }
            catch (Exception err)
            {
                Log.Error(err);
            }
        }
Example #28
0
 public void addEvent(AccountEvent.Alter.Event pevent)
 {
     if (this.actEvent < Account.MAX_EVENT)
     {
         this.events[this.actEvent] = pevent;
         System.Console.WriteLine(this.events[this.actEvent]);
         if (pevent is TransferEvent)
         {
             TransferEvent te = (TransferEvent)pevent;
             Account targetAccount = te.TargetAccount;
             if ( (targetAccount is MoneyAccount) && (this is MoneyAccount) ){
                 MoneyAccount baseAccount = (MoneyAccount)this;
                 MoneyAccount targetMoneyAccount = (MoneyAccount)targetAccount;
                 baseAccount.Money -= te.TransferValue;
                 targetMoneyAccount.Money += te.TransferValue;
             }
         }
         actEvent++;
     }
 }
Example #29
0
        public override Task <Unused> Account(AccountEvent request, ServerCallContext context)
        {
            string action = string.Empty;

            if (request.Action == Crud.Create)
            {
                action = "created";
            }
            else if (request.Action == Crud.Update)
            {
                action = "updated";
            }
            else if (request.Action == Crud.Delete)
            {
                action = "deleted";
            }
            else
            {
                action = "unknown";
            }
            return(Task.FromResult(new Unused()));
        }
Example #30
0
        protected override async Task HandleMessage(FeedMessage msg)
        {
            if (msg.Type == "message" && msg.Topic == Topic)
            {
                var obj = msg.Data.ToObject <AccountEventData>();

                if (msg.Subject == "orderMargin.change")
                {
                    obj.EventType = EventType.OrderMargin;
                }
                else if (msg.Subject == "availableBalance.change")
                {
                    obj.EventType = EventType.OrderMargin;
                }
                else if (msg.Subject == "withdrawHold.change")
                {
                    obj.EventType = EventType.OrderMargin;
                }

                await PushNext(obj);


                AccountEvent?.Invoke(this, obj);

                if (msg.Subject == "orderMargin.change")
                {
                    OrderMaginEvent?.Invoke(this, obj);
                }
                else if (msg.Subject == "availableBalance.change")
                {
                    AvailableBalanceEvent?.Invoke(this, obj);
                }
                else if (msg.Subject == "withdrawHold.change")
                {
                    WithdrawHoldEvent?.Invoke(this, obj);
                }
            }
        }
        public async Task CreateEvent(AccountEvent request)
        {
            try
            {
                _logger.Info($"Creating Account Event ({request.Event})", accountId: request.ResourceUri, @event: request.Event);

                await _mediator.SendAsync(new CreateAccountEventCommand
                {
                    Event       = request.Event,
                    ResourceUri = request.ResourceUri
                });
            }
            catch (ValidationException ex)
            {
                _logger.Warn(ex, "Invalid request", accountId: request.ResourceUri, @event: request.Event);
                throw;
            }
            catch (Exception ex)
            {
                _logger.Error(ex, ex.Message);
                throw;
            }
        }
Example #32
0
 public static ACL GetACL(ISession session, AccountEvent instance, Type type) { return new ManagedAccountEvent(session, instance).GetACL(type); }
Example #33
0
 public static string GetObjectName(AccountEvent instance, int id) { return instance.Name; }
Example #34
0
 public static int GetOwnerId(AccountEvent instance, int id) { return instance.Account.Id; }