public DepositController(IUnitOfWork _unitOfWork, IDepositService _depositService, IAccountService _accountService, IMT4Service _mt4Service)
 {
     this.depositService = _depositService;
     this.mt4Service     = _mt4Service;
     this.accountService = _accountService;
     this.unitOfWork     = _unitOfWork;
 }
Example #2
0
 public DepositController(IUnitOfWork _unitOfWork, IDepositService _depositService, IAccountService _accountService, IMT4Service _mt4Service)
 {
     this.depositService = _depositService;
     this.mt4Service = _mt4Service;
     this.accountService = _accountService;
     this.unitOfWork = _unitOfWork;
 }
Example #3
0
 public HomeController(ISystemSettingsService _systemSettingService, IAccountService _accountService, IDepositService _depositService, IMT4Service _mt4Service, IUnitOfWork _unitOfWork)
 {
     this.accountService       = _accountService;
     this.systemSettingService = _systemSettingService;
     this.depositService       = _depositService;
     this.mt4Service           = _mt4Service;
     this.unitOfWork           = _unitOfWork;
 }
Example #4
0
 public HomeController(ISystemSettingsService _systemSettingService, IAccountService _accountService, IDepositService _depositService, IMT4Service _mt4Service, IUnitOfWork _unitOfWork)
 {
     this.accountService = _accountService;
     this.systemSettingService = _systemSettingService;
     this.depositService = _depositService;
     this.mt4Service = _mt4Service;
     this.unitOfWork = _unitOfWork;
 }
Example #5
0
 public WithdrawalController(
     IUnitOfWork _unitOfWork,
     IWithdrawalsService _withdrawalService,
     IAccountService _accountService,
     IMT4Service _mt4Service)
 {
     this.withdrawalService = _withdrawalService;
     this.mt4Service        = _mt4Service;
     this.accountService    = _accountService;
     this.unitOfWork        = _unitOfWork;
 }
        public WithdrawalController(
            IUnitOfWork _unitOfWork,
            IWithdrawalsService _withdrawalService,
            IAccountService _accountService,
            IMT4Service _mt4Service)
        {
            this.withdrawalService = _withdrawalService;
            this.mt4Service = _mt4Service;
            this.accountService = _accountService;
            this.unitOfWork = _unitOfWork;

        }
 public AccountController(IUnitOfWork unitOfWork,
     IAccountService accountService,
     IMT4Service mt4service,
     ISystemSettingsService systemSettingService,
     IDepositService depositService,
     log4net.ILog log)
 {
     this._accountService = accountService;
     this._mt4Service = mt4service;
     this._unitOfWork = unitOfWork;
     this._systemSettingService = systemSettingService;
     this._depositService = depositService;
     this._log = log;
 }
Example #8
0
 public HomeController(IMT4Service mt4Service, IAccountService accountService, ISystemSettingsService SystemSettingsService)
 {
     _mt4Service = mt4Service;
     _accountService = accountService;
     _SystemSettingsService = SystemSettingsService;
 }
Example #9
0
 public HomeController(IMT4Service mt4Service, IAccountService accountService, ISystemSettingsService SystemSettingsService)
 {
     _mt4Service            = mt4Service;
     _accountService        = accountService;
     _SystemSettingsService = SystemSettingsService;
 }
        public static void Start()
        {
            IClosingPriceService service        = (IClosingPriceService)AutofacDependencyResolver.Current.GetService(typeof(IClosingPriceService));
            IUnitOfWork          unitOfWork     = (IUnitOfWork)AutofacDependencyResolver.Current.GetService(typeof(IUnitOfWork));
            IMT4Service          mt4Service     = (IMT4Service)AutofacDependencyResolver.Current.GetService(typeof(IMT4Service));
            IAccountService      accountService = (IAccountService)AutofacDependencyResolver.Current.GetService(typeof(IAccountService));

            log4net.ILog log = (log4net.ILog)AutofacDependencyResolver.Current.GetService(typeof(log4net.ILog));
            ThreadPool.QueueUserWorkItem(async(obj) =>
            {
                DateTime today = DateTime.Now, yesterday = DateTime.Now;
                while (true)
                {
                    try
                    {
                        yesterday = DateTime.Now;
                        if (yesterday.AddDays((double)1).Day == today.Day)
                        {
                            decimal closeprice = await mt4Service.GetGoldPrice();
                            while (closeprice <= 0)
                            {
                                closeprice = await mt4Service.GetGoldPrice();
                                Thread.Sleep(2000);
                            }
                            foreach (Account item in accountService.GetAll().ToList())
                            {
                                List <TradingModel> tradings = await mt4Service.GetTradingByLoginId(item.MT4Account);
                                if (tradings == null)
                                {
                                    item.Profit = 0;
                                    accountService.Update(item);
                                    unitOfWork.Commit();
                                    continue;
                                }
                                if (tradings.Count == 0)
                                {
                                    if (item.Profit != 0 && item.Interest != 0)
                                    {
                                        item.Profit   = 0;
                                        item.Interest = 0;
                                        accountService.Update(item);
                                        unitOfWork.Commit();
                                    }
                                }
                                else
                                {
                                    //昨日收益
                                    var profit        = (decimal)tradings.Sum(e => e.Profit);
                                    var sumWeight     = (decimal)tradings.Sum(e => e.Weight);
                                    item.Profit       = profit;
                                    item.Interest     = GetInterest(closeprice, sumWeight);
                                    item.SumInterest += item.Interest;
                                    accountService.Update(item);
                                    unitOfWork.Commit();
                                }
                            }
                            service.Add(new Core.Entitys.ClosingPrice()
                            {
                                Price = closeprice
                            });
                            unitOfWork.Commit();
                        }
                        Thread.Sleep(1000 * 60);
                        today = DateTime.Now;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }
                }
            });
        }