public string SubscribeOnPortfolioOnExistAccount(TopPortfolioItem newTopPortfolio) { string errorMessage; if (!newTopPortfolio.ManagedAccount.HasValue) { errorMessage = Resource.ErrorMessageCampaignAccount; Logger.Error(errorMessage); return(errorMessage); } var ownerUser = userRepository.GetAccountOwner(newTopPortfolio.ManagedAccount.Value); if (ownerUser == null) { errorMessage = Resource.ErrorMessageNotFindUserAccountOwner; Logger.Error(errorMessage); return(errorMessage); } var topPortfolio = AddTopPortfolio(newTopPortfolio); if (topPortfolio == null) { errorMessage = Resource.ErrorMessageTopPortfolioUnableAdd; Logger.Error(errorMessage); return(errorMessage); } Logger.Info("Новый портфель роботов создан"); try { var proxy = new TradeSharpServerTrade(EmptyTradeSharpCallbackReceiver.Instance).proxy; var status = proxy.SubscribeOnPortfolio(ProtectedOperationContext.MakeServerSideContext(), ownerUser.Login, topPortfolio, null, Utils.GetDefaultPortfolioTradeSettings()); if (status != RequestStatus.OK) { errorMessage = Resource.ErrorMessageCampaignAccount; Logger.Error(errorMessage); return(errorMessage); } return(string.Empty); } catch (Exception ex) { errorMessage = Resource.ErrorMessageUnableSignAccount + ": " + ex.Message; Logger.Error("AddTopPortfolio", ex); } return(errorMessage); }
public string SubscribeOnPortfolioOnNewAccount(TopPortfolioItem newTopPortfolio) { var accountRepository = DependencyResolver.Current.GetService <IAccountRepository>(); string errorMessage; if (!accountRepository.AddAccount(newTopPortfolio.AddAccountModel)) { errorMessage = Resource.ErrorMessageNotCreateAccountForTopPortfolio + " " + newTopPortfolio.AddAccountModel.UserName; Logger.Error("SubscribeOnPortfolioOnNewAccount() - " + errorMessage); return(errorMessage); } newTopPortfolio.ManagedAccount = accountRepository.GetAccountId(newTopPortfolio.AddAccountModel.UserLogin); var topPortfolio = AddTopPortfolio(newTopPortfolio); if (topPortfolio == null) { errorMessage = Resource.ErrorMessageTopPortfolioUnableAdd; Logger.Error(errorMessage); return(errorMessage); } Logger.Info("Новый портфель роботов создан"); try { var proxy = new TradeSharpServerTrade(EmptyTradeSharpCallbackReceiver.Instance).proxy; var status = proxy.SubscribeOnPortfolio(ProtectedOperationContext.MakeServerSideContext(), newTopPortfolio.AddAccountModel.UserLogin, topPortfolio, null, Utils.GetDefaultPortfolioTradeSettings()); if (status != RequestStatus.OK) { errorMessage = Resource.ErrorMessageUnableSignAccount; Logger.Error(errorMessage); return(errorMessage); } return(string.Empty); } catch (Exception ex) { errorMessage = Resource.ErrorMessageUnableSignAccount + ": " + ex.Message; Logger.Error("AddTopPortfolio", ex); } return(errorMessage); }
public string SubscribeOnPortfolioOnNewAccount(TopPortfolioItem newTopPortfolio) { var accountRepository = DependencyResolver.Current.GetService<IAccountRepository>(); string errorMessage; if (!accountRepository.AddAccount(newTopPortfolio.AddAccountModel)) { errorMessage = Resource.ErrorMessageNotCreateAccountForTopPortfolio + " " + newTopPortfolio.AddAccountModel.UserName; Logger.Error("SubscribeOnPortfolioOnNewAccount() - " + errorMessage); return errorMessage; } newTopPortfolio.ManagedAccount = accountRepository.GetAccountId(newTopPortfolio.AddAccountModel.UserLogin); var topPortfolio = AddTopPortfolio(newTopPortfolio); if (topPortfolio == null) { errorMessage = Resource.ErrorMessageTopPortfolioUnableAdd; Logger.Error(errorMessage); return errorMessage; } Logger.Info("Новый портфель роботов создан"); try { var proxy = new TradeSharpServerTrade(EmptyTradeSharpCallbackReceiver.Instance).proxy; var status = proxy.SubscribeOnPortfolio(ProtectedOperationContext.MakeServerSideContext(), newTopPortfolio.AddAccountModel.UserLogin, topPortfolio, null, Utils.GetDefaultPortfolioTradeSettings()); if (status != RequestStatus.OK) { errorMessage = Resource.ErrorMessageUnableSignAccount; Logger.Error(errorMessage); return errorMessage; } return string.Empty; } catch (Exception ex) { errorMessage = Resource.ErrorMessageUnableSignAccount + ": " + ex.Message; Logger.Error("AddTopPortfolio", ex); } return errorMessage; }
public string SubscribeOnPortfolioOnExistAccount(TopPortfolioItem newTopPortfolio) { string errorMessage; if (!newTopPortfolio.ManagedAccount.HasValue) { errorMessage = Resource.ErrorMessageCampaignAccount; Logger.Error(errorMessage); return errorMessage; } var ownerUser = userRepository.GetAccountOwner(newTopPortfolio.ManagedAccount.Value); if (ownerUser == null) { errorMessage = Resource.ErrorMessageNotFindUserAccountOwner; Logger.Error(errorMessage); return errorMessage; } var topPortfolio = AddTopPortfolio(newTopPortfolio); if (topPortfolio == null) { errorMessage = Resource.ErrorMessageTopPortfolioUnableAdd; Logger.Error(errorMessage); return errorMessage; } Logger.Info("Новый портфель роботов создан"); try { var proxy = new TradeSharpServerTrade(EmptyTradeSharpCallbackReceiver.Instance).proxy; var status = proxy.SubscribeOnPortfolio(ProtectedOperationContext.MakeServerSideContext(), ownerUser.Login, topPortfolio, null, Utils.GetDefaultPortfolioTradeSettings()); if (status != RequestStatus.OK) { errorMessage = Resource.ErrorMessageCampaignAccount; Logger.Error(errorMessage); return errorMessage; } return string.Empty; } catch (Exception ex) { errorMessage = Resource.ErrorMessageUnableSignAccount + ": " + ex.Message; Logger.Error("AddTopPortfolio", ex); } return errorMessage; }