Beispiel #1
0
 public SubscriptionSettings(signal_subscriptions sub)
 {
     Status        = sub.status;
     SignalType    = sub.subscription_type;
     Multiplier    = sub.multiplier;
     Reverse       = sub.reverse;
     Risk          = sub.risk;
     MaxOrderCount = sub.max_order_count;
     MaxVolume     = sub.max_volume;
     OrdersType    = sub.order_type;
 }
Beispiel #2
0
        public void SignalSubscription(short status, long accountSlaveId, string masterNickname, ISubscribeSettings settings,
                                       AccountInfo result)
        {
            using (var db = GetDBConnect())
            {
                try
                {
                    db.BeginTransaction();

                    var signalSubscriber = new signal_subscribers
                    {
                        id = (int)accountSlaveId,
                        client_account_id = result.ClientId,
                        account_type_id   = result.AccountTypeId,
                        isenabled         = result.IsEnabled,
                        isdeleted         = false,
                        login             = result.Login,
                        nickname          = result.Nickname,
                        avatar            = result.Avatar,
                        currency          = result.Currency
                    };

                    db.InsertOrReplace(signalSubscriber);
                    subscriberCache.InsertOrUpdate(accountSlaveId, signalSubscriber);

                    var signalSubscription = new signal_subscriptions
                    {
                        status            = (short)SubscriptionStatus.On,
                        account_slave_id  = accountSlaveId,
                        account_master_id = Queryable.First(db.signal_providers, source => source.nickname.ToLower() == masterNickname.ToLower()).id,
                        slave_profit      = 0,
                        subscription_type = (short)settings.SignalType,
                        multiplier        = settings.Multiplier,
                        reverse           = settings.Reverse,
                        risk            = settings.Risk,
                        max_order_count = settings.MaxOrderCount,
                        max_volume      = settings.MaxVolume,
                        order_type      = (short)settings.OrdersType
                    };

                    var id = Convert.ToInt32(db.InsertWithIdentity(signalSubscription));
                    subscriptionCache.InsertOrUpdate(id, signalSubscription);

                    db.CommitTransaction();
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                    throw;
                }
            }
        }