public WalletManager4Pamm(ProtectedOperationContext secCtx, string login, int accountId) { this.secCtx = secCtx; this.login = login; this.accountId = accountId; }
public AuthenticationResponse ChangePassword(ProtectedOperationContext ctx, string login, string newPassword) { try { if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.ChangeAccountSettings)) if (!UserSessionStorage.Instance.PermitUserOperation(ctx, UserOperationRightsStorage.IsTradeOperation(UserOperation.ChangeAccountSettings), false)) return AuthenticationResponse.NotAuthorized; } catch (Exception ex) { Logger.ErrorFormat("Ошибка в AuthenticationResponse({0}): {1}", login, ex); return AuthenticationResponse.ServerError; } using (var dbContext = DatabaseContext.Instance.Make()) { try { var user = dbContext.PLATFORM_USER.FirstOrDefault(u => u.Login == login); if (user == null) return AuthenticationResponse.InvalidAccount; user.Password = newPassword; dbContext.SaveChanges(); } catch (Exception ex) { Logger.ErrorFormat("Ошибка в ChangePassword({0}) : {1}", login, ex); return AuthenticationResponse.ServerError; } } return AuthenticationResponse.OK; }
public RequestStatus UnsubscribePortfolio(ProtectedOperationContext secCtx, string subscriberLogin, bool deletePortfolio, bool deleteSubscriptions) { if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.GetAccountDetail)) if ( !UserSessionStorage.Instance.PermitUserOperation(secCtx, UserOperationRightsStorage.IsTradeOperation( UserOperation.BindToSignal), false)) return RequestStatus.Unauthorized; using (var ctx = DatabaseContext.Instance.Make()) return walletRepository.UnsubscribeUserFromPortfolio(ctx, subscriberLogin, deletePortfolio, deleteSubscriptions); }
public bool DisableService(ProtectedOperationContext ctx, int serviceId, out WalletError error) { error = WalletError.OK; if (Channel == null) throw new Exception("WalletManagerProxy: связь не установлена"); try { return Channel.DisableService(ctx, serviceId, out error); } catch { RenewFactory(); try { return Channel.DisableService(ctx, serviceId, out error); } catch (Exception ex2) { Logger.Error("DisableService() error: ", ex2); return false; } } }
public RequestStatus ApplyPortfolioTradeSettings(ProtectedOperationContext secCtx, string login, AutoTradeSettings sets) { if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.BindToSignal)) if (!UserSessionStorage.Instance.PermitUserOperation(secCtx, UserOperationRightsStorage.IsTradeOperation(UserOperation.BindToSignal), false)) return RequestStatus.Unauthorized; try { using (var ctx = DatabaseContext.Instance.Make()) { var user = ctx.PLATFORM_USER.FirstOrDefault(u => u.Login == login); if (user == null) return RequestStatus.Unauthorized; var subsription = ctx.USER_TOP_PORTFOLIO.FirstOrDefault(u => u.User == user.ID); if (subsription == null) return RequestStatus.CommonError; subsription.AutoTrade = sets.TradeAuto; subsription.MaxLeverage = sets.MaxLeverage; subsription.PercentLeverage = sets.PercentLeverage; subsription.HedgingOrdersEnabled = sets.HedgingOrdersEnabled; subsription.FixedVolume = sets.FixedVolume; subsription.MinVolume = sets.MinVolume; subsription.MaxVolume = sets.MaxVolume; subsription.VolumeRound = (int?) sets.VolumeRound; subsription.StepVolume = sets.StepVolume; subsription.TargetAccount = sets.TargetAccount; ctx.SaveChanges(); return RequestStatus.OK; } } catch (Exception ex) { Logger.Error("Ошибка в ApplyPortfolioTradeSettings()", ex); return RequestStatus.ServerError; } }
/// <summary> /// подписать на портфель /// отключить остальные подписки /// если портфель пользовательский - сохранить его /// </summary> public RequestStatus SubscribeOnPortfolio( ProtectedOperationContext secCtx, string subscriberLogin, TopPortfolio portfolio, decimal? maxFee, AutoTradeSettings tradeAutoSettings) { //Logger.InfoFormat("SubscribeOnPortfolio({0})", subscriberLogin); if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.BindToSignal)) if (!UserSessionStorage.Instance.PermitUserOperation(secCtx, UserOperationRightsStorage.IsTradeOperation(UserOperation.BindToSignal), false)) return RequestStatus.Unauthorized; try { using (var ctx = DatabaseContext.Instance.Make()) return walletRepository.SubscribeUserOnPortfolio(ctx, subscriberLogin, portfolio, maxFee, tradeAutoSettings); } catch (Exception ex) { Logger.Error("Ошибка в SubscribeOnPortfolio()", ex); return RequestStatus.ServerError; } }
public WalletError ChangePaymentSystemWallets(ProtectedOperationContext ctx, UserPaymentSystem paySys, bool remove, string userLogin, string walletPwrd) { if (Channel == null) throw new Exception("WalletManagerProxy: связь не установлена"); try { return Channel.ChangePaymentSystemWallets(ctx, paySys, remove, userLogin, walletPwrd); } catch { RenewFactory(); try { return Channel.ChangePaymentSystemWallets(ctx, paySys, remove, userLogin, walletPwrd); } catch (Exception ex2) { Logger.Error("ChangePaymentSystemWallets() error: ", ex2); return WalletError.CommonError; } } }
public override RequestStatus SendCloseRequest(ProtectedOperationContext ctx, int accountId, int orderId, PositionExitReason reason) { return proxyTrade.proxy.SendCloseRequest(ctx, accountId, orderId, reason); }
public override RequestStatus SendEditMarketRequest(ProtectedOperationContext secCtx, MarketOrder pos) { if (IsDayOff()) return RequestStatus.WrongTime; return base.SendEditMarketRequest(secCtx, pos); }
public override RequestStatus SendNewOrderRequest(ProtectedOperationContext secCtx, int requestUniqueId, MarketOrder order, OrderType orderType, decimal requestedPrice, decimal slippagePoints) { if (IsDayOff()) return RequestStatus.WrongTime; return base.SendNewOrderRequest(secCtx, requestUniqueId, order, orderType, requestedPrice, slippagePoints); }
public override RequestStatus SendCloseByTickerRequest(ProtectedOperationContext ctx, int accountId, string ticker, PositionExitReason reason) { return proxyTrade.proxy.SendCloseByTickerRequest(ctx, accountId, ticker, reason); }
public abstract RequestStatus SendEditPendingRequest(ProtectedOperationContext secCtx, PendingOrder ord);
public override RequestStatus SendEditPendingRequest(ProtectedOperationContext secCtx, PendingOrder ord) { return proxyTrade.proxy.SendEditPendingRequest(secCtx, ord); }
public override RequestStatus SendNewPendingOrderRequest( ProtectedOperationContext ctx, int requestUniqueId, PendingOrder order) { return proxyTrade.proxy.SendNewPendingOrderRequest(ctx, requestUniqueId, order); }
public List<Transfer> GetAccountTransfersPartByPart(ProtectedOperationContext secCtx, string login, int startId, int countMax) { throw new NotImplementedException(); }
public abstract RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx, PendingOrder order, PendingOrderStatus status, int? positionId, string closeReason);
public RequestStatus ApplyPortfolioTradeSettings(ProtectedOperationContext secCtx, string login, AutoTradeSettings sets) { throw new NotImplementedException(); }
public List<AccountShare> GetAccountShares(ProtectedOperationContext secCtx, int accountId, bool needMoneyShares) { throw new NotImplementedException(); }
public virtual void SendTradeSignalEvent(ProtectedOperationContext ctx, int accountId, int tradeSignalCategory, UserEvent acEvent) { Logger.InfoFormat("Текстовое сообщение робота: [{0:dd.MM.yyyy HH:mm}] {1} {2} {3}", acEvent.Time, acEvent.Code, acEvent.Title, acEvent.Text); }
public abstract RequestStatus SendNewPendingOrderRequest(ProtectedOperationContext ctx, int requestUniqueId, PendingOrder order);
public abstract RequestStatus SendNewOrderRequest(ProtectedOperationContext secCtx, int requestUniqueId, MarketOrder order, OrderType orderType, decimal requestedPrice, decimal slippagePoints);
public override RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx, PendingOrder order, PendingOrderStatus status, int? positionId, string closeReason) { return proxyTrade.proxy.SendDeletePendingOrderRequest(ctx, order, status, positionId, closeReason); }
public void ReviveChannel(ProtectedOperationContext ctx, string login, int accountId, string terminalVersion) { string address; var clientCallback = GetContextParams(out address); UserSessionStorage.Instance.ReviveChannel(ctx, clientCallback, address, login, accountId, terminalVersion); }
public override RequestStatus SendEditMarketRequest(ProtectedOperationContext secCtx, MarketOrder pos) { return proxyTrade.proxy.SendEditMarketRequest(secCtx, pos); }
public static bool IsServerContext(ProtectedOperationContext ctx) { return(ctx.userMachineName == "server#" && ctx.terminalId == long.MaxValue); }
public override RequestStatus SendNewOrderRequest( ProtectedOperationContext secCtx, int requestUniqueId, MarketOrder order, OrderType orderType, decimal requestedPrice, decimal slippagePoints) { return proxyTrade.proxy.SendNewOrderRequest( secCtx, requestUniqueId, order, orderType, requestedPrice, slippagePoints); }
public override RequestStatus SendCloseByTickerRequest(ProtectedOperationContext ctx, int accountId, string ticker, PositionExitReason reason) { if (IsDayOff()) return RequestStatus.WrongTime; return base.SendCloseByTickerRequest(ctx, accountId, ticker, reason); }
public override void SendTradeSignalEvent(ProtectedOperationContext ctx, int accountId, int tradeSignalCategory, UserEvent acEvent) { try { proxyTrade.proxy.SendTradeSignalEvent(ctx, accountId, tradeSignalCategory, acEvent); } catch (Exception ex) { Logger.ErrorFormat("Ошибка в SendTradeSignalEvent(acc: {0}, cat: {1}): {2}", accountId, tradeSignalCategory, ex); } }
public override RequestStatus SendCloseRequest(ProtectedOperationContext ctx, int accountId, int orderId, PositionExitReason reason) { if (IsDayOff()) return RequestStatus.WrongTime; return base.SendCloseRequest(ctx, accountId, orderId, reason); }
public void Logout(ProtectedOperationContext ctx) { UserSessionStorage.Instance.Logout(ctx); }
public abstract RequestStatus SendEditMarketRequest(ProtectedOperationContext secCtx, MarketOrder pos);