コード例 #1
0
        public void DeleteSubscriber(long subscriberId)
        {
            using (var db = GetDBConnect())
            {
                try
                {
                    db.BeginTransaction();

                    Queryable.Where(db.signal_providers, subscriber => subscriber.id == subscriberId)
                    .Set(subscriber => subscriber.isdeleted, true)
                    .Update();

                    Queryable.Where(db.signal_subscriptions, sub => sub.account_slave_id == subscriberId)
                    .Set(sub => sub.status, (short)SubscriptionStatus.Off)
                    .Update();

                    var subscriberVal = subscriberCache.Get(subscriberId);
                    subscriberVal.isdeleted = true;
                    subscriberCache.InsertOrUpdate(subscriberId, subscriberVal);

                    db.CommitTransaction();
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                    throw;
                }
            }
        }
コード例 #2
0
        public void SignalSubscriptionSettingsUpdate(Int64 accountSlaveId, Int64 accountMasterId, ISubscribeSettings settings)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_subscriptions, sub => sub.account_slave_id == accountSlaveId && sub.account_master_id == accountMasterId)
                .Set(p => p.subscription_type, (short)settings.SignalType)
                .Set(p => p.multiplier, settings.Multiplier)
                .Set(p => p.reverse, settings.Reverse)
                .Set(p => p.risk, settings.Risk)
                .Set(p => p.max_order_count, settings.MaxOrderCount)
                .Set(p => p.max_volume, settings.MaxVolume)
                .Set(p => p.order_type, (short)settings.OrdersType)
                .Set(p => p.status, (short)settings.Status)
                .Update();

                var settingsVal = Enumerable.First(subscriptionCache.Filter(x => x.account_slave_id == accountSlaveId && x.account_master_id == accountMasterId));
                settingsVal.subscription_type = (short)settings.SignalType;
                settingsVal.multiplier        = settings.Multiplier;
                settingsVal.reverse           = settings.Reverse;
                settingsVal.risk            = settings.Risk;
                settingsVal.max_order_count = settings.MaxOrderCount;
                settingsVal.max_volume      = settings.MaxVolume;
                settingsVal.order_type      = (short)settings.OrdersType;
                settingsVal.status          = (short)settings.Status;
                subscriptionCache.InsertOrUpdate(settingsVal.id, settingsVal);
            }
        }
コード例 #3
0
        public ProviderFullInformation[] GetProvider(long clientId)
        {
            using (var db = GetDBConnect())
            {
                var providers = Enumerable.ToArray(Queryable.Select(Queryable.Where(db.signal_providers, x => x.client_account_id == clientId), x => new ProviderFullInformation
                {
                    AccountId   = x.id,
                    AccountType = (AccountType)x.account_type_id,
                    Avatar      = x.avatar,
                    ClientId    = x.client_account_id,
                    Currency    = x.currency,
                    IsVisible   = x.isvisible,
                    Login       = x.login,
                    Nickname    = x.nickname,
                    RatingValue = x.rating_value == null ? 0.0f : x.rating_value.Value,
                }));

                foreach (var provider in providers)
                {
                    provider.Subscribers = Enumerable.ToList <SubscriberData>((from subscriber in db.signal_subscribers
                                                                               join subscription in db.signal_subscriptions on subscriber.id equals subscription.account_slave_id
                                                                               where subscription.account_master_id == provider.AccountId
                                                                               select new SubscriberData
                    {
                        AccountId = subscriber.id,
                        Avatar = subscriber.avatar,
                        ClientId = subscriber.client_account_id,
                        Nickname = subscriber.nickname
                    }));
                }

                return(providers);
            }
        }
コード例 #4
0
 public signal_providers[] GetAllProviders()
 {
     using (var db = GetDBConnect())
     {
         return(Enumerable.ToArray(Queryable.Where(db.signal_providers, provider => !provider.isdeleted)));
     }
 }
コード例 #5
0
ファイル: CollectionExtensions.cs プロジェクト: zhk0603/ixq
        /// <summary>
        ///     按指定的属性名称对<see cref="IQueryable{T}" />序列进行排序
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="propertyName"></param>
        /// <param name="sortDirection"></param>
        /// <returns></returns>
        public static IQueryable <T> OrderBy <T>(this IQueryable <T> source,
                                                 string propertyName,
                                                 ListSortDirection sortDirection = ListSortDirection.Ascending)
        {
            dynamic keySelector = LambdaExpression <T> .GetKeySelector(propertyName);

            return(sortDirection == ListSortDirection.Ascending
                ? Queryable.OrderBy(source, keySelector)
                : Queryable.OrderByDescending(source, keySelector));
        }
コード例 #6
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;
                }
            }
        }
コード例 #7
0
        public void ChangeProviderVisibility(long accountId, bool value)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_providers, acc => acc.id == accountId)
                .Set(acc => acc.isvisible, value)
                .Update();

                var providerVal = providerCache.Get(accountId);
                providerVal.isvisible = value;
                providerCache.InsertOrUpdate(accountId, providerVal);
            }
        }
コード例 #8
0
        public void ChangeSubscriberAvatar(long accountId, string newAvatar)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_subscribers, acc => acc.id == accountId)
                .Set(acc => acc.avatar, newAvatar)
                .Update();

                var subscriberVal = subscriberCache.Get(accountId);
                subscriberVal.avatar = newAvatar;
                subscriberCache.InsertOrUpdate(accountId, subscriberVal);
            }
        }
コード例 #9
0
        public void ChangeProviderDescription(long accountId, string newDescription)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_providers, acc => acc.id == accountId)
                .Set(acc => acc.description, newDescription)
                .Update();

                var providerVal = providerCache.Get(accountId);
                providerVal.description = newDescription;
                providerCache.InsertOrUpdate(accountId, providerVal);
            }
        }
コード例 #10
0
        public void Unsubscribe(long slaveId, long masterId)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_subscriptions, x => x.account_slave_id == slaveId && x.account_master_id == masterId)
                .Set(x => x.status, (short)SubscriptionStatus.Off)
                .Update();

                var subscriptionVal = Enumerable.First(subscriptionCache.Filter(x => x.account_slave_id == slaveId && x.account_master_id == masterId));
                subscriptionVal.status = (short)SubscriptionStatus.Off;
                subscriptionCache.InsertOrUpdate(subscriptionVal.id, subscriptionVal);
            }
        }
コード例 #11
0
        public void ChangeProviderAvatar(long accountId, string newAvatar)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_providers, acc => acc.id == accountId)
                .Set(acc => acc.avatar, newAvatar)
                .Update();
            }

            var providerVal = providerCache.Get(accountId);

            providerVal.avatar = newAvatar;
            providerCache.InsertOrUpdate(accountId, providerVal);
        }
コード例 #12
0
        public void ChangeSubscriberVisibility(long accountId, bool value)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_subscribers, acc => acc.id == accountId)
                .Set(acc => acc.isvisible, value)
                .Update();
            }

            var subscriberVal = subscriberCache.Get(accountId);

            subscriberVal.isvisible = value;
            subscriberCache.InsertOrUpdate(accountId, subscriberVal);
        }
コード例 #13
0
        public void AddProfit(long slaveId, long masterId, decimal profit)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_subscriptions, sub => sub.account_master_id == masterId && sub.account_slave_id == slaveId)
                .Set(sub => sub.slave_profit, sub => sub.slave_profit + profit)
                .Update();

                var signalSubscription =
                    Queryable.First(db.signal_subscriptions, sub => sub.account_slave_id == slaveId && sub.account_master_id == masterId);

                subscriptionCache.InsertOrUpdate(signalSubscription.id, signalSubscription);
            }
        }
コード例 #14
0
        public void UpdateSubscriberRating(long accountId, float?rating, int count)
        {
            using (var db = GetDBConnect())
            {
                Queryable.Where(db.signal_subscribers, acc => acc.id == accountId)
                .Set(acc => acc.rating_value, rating)
                .Set(acc => acc.rating_count, count)
                .Update();

                var subscriberVal = subscriberCache.Get(accountId);
                subscriberVal.rating_value = rating;
                subscriberVal.rating_count = count;
                subscriberCache.InsertOrUpdate(accountId, subscriberVal);
            }
        }
コード例 #15
0
        private IEnumerable <TerritoryEntity> FetchTerritoryEntities
            (Expression <Func <TerritoryEntity, bool> > filter)
        {
            IEnumerable <TerritoryEntity> territoryEntities;

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(myAdapter);
                territoryEntities = Enumerable.ToList <TerritoryEntity>(Queryable.Where(linqMetaData.Territory.
                                                                                        WithPath(p => p.Prefetch(t => t.ZipCollectionViaTerritoryZip).
                                                                                                 Prefetch(t => t.FranchiseeTerritory).
                                                                                                 Prefetch(t => t.OrganizationRoleUserTerritory).
                                                                                                 Prefetch(t => t.HospitalPartnerTerritory).
                                                                                                 Prefetch(t => t.TerritoryPackage)), filter));
            }
            return(territoryEntities);
        }
コード例 #16
0
        public HostDeposit GetByHostDepositById(long hostDepositId)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var hostPayment = Queryable.FirstOrDefault <HostPaymentEntity>(linqMetaData.HostPayment.WithPath(prefetchPath =>
                                                                                                                 prefetchPath.Prefetch(path => path.Address).Prefetch(path => path.HostPaymentTransaction)).Where(
                                                                                   hp => hp.HostPaymentId == hostDepositId && hp.IsDeposit));
                if (hostPayment == null)
                {
                    throw new ObjectNotFoundInPersistenceException <HostPayment>(hostDepositId);
                }
                var address = _addressRepository.GetAddress(hostPayment.MailingAddressId.Value);

                return(_hostDepositFactory.CreateHostDeposit(hostPayment, address));
            }
        }
コード例 #17
0
ファイル: IEnumerableExtensions.cs プロジェクト: zzti/Furion
        /// <summary>
        /// [EF Core] 与操作合并多个表达式,支持索引器
        /// </summary>
        /// <typeparam name="TSource">泛型类型</typeparam>
        /// <param name="sources">集合对象</param>
        /// <param name="expressions">表达式数组</param>
        /// <returns>新的集合对象</returns>
        public static IQueryable <TSource> Where <TSource>(this IQueryable <TSource> sources, params Expression <Func <TSource, int, bool> >[] expressions)
        {
            if (expressions == null || !expressions.Any())
            {
                return(sources);
            }
            if (expressions.Length == 1)
            {
                return(Queryable.Where(sources, expressions[0]));
            }

            var expression = LinqExpression.IndexOr <TSource>();

            foreach (var _expression in expressions)
            {
                expression = expression.Or(_expression);
            }
            return(Queryable.Where(sources, expression));
        }
コード例 #18
0
        public void DeleteProvider(long providerId)
        {
            using (var db = GetDBConnect())
            {
                try
                {
                    db.BeginTransaction();

                    Queryable.Where(db.signal_providers, provider => provider.id == providerId)
                    .Set(provider => provider.isdeleted, true)
                    .Update();

                    Queryable.Where(db.signal_subscriptions, sub => sub.account_master_id == providerId)
                    .Set(sub => sub.status, (short)SubscriptionStatus.Off)
                    .Update();

                    var providerVal = providerCache.Get(providerId);
                    providerVal.isdeleted = true;
                    providerCache.InsertOrUpdate(providerId, providerVal);

                    var subscriptions = subscriptionCache.Filter(x => x.account_master_id == providerId);
                    foreach (var subscription in subscriptions)
                    {
                        subscription.status = (short)SubscriptionStatus.Off;
                        subscriptionCache.InsertOrUpdate(subscription.id, subscription);
                    }

                    db.CommitTransaction();
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                    throw;
                }
            }
        }
コード例 #19
0
ファイル: IEnumerableExtensions.cs プロジェクト: zzti/Furion
 /// <summary>
 /// [EF Core] 根据条件成立再构建 Where 查询,支持索引器
 /// </summary>
 /// <typeparam name="TSource">泛型类型</typeparam>
 /// <param name="sources">集合对象</param>
 /// <param name="condition">布尔条件</param>
 /// <param name="expression">表达式</param>
 /// <returns>新的集合对象</returns>
 public static IQueryable <TSource> Where <TSource>(this IQueryable <TSource> sources, bool condition, Expression <Func <TSource, int, bool> > expression)
 {
     return(condition ? Queryable.Where(sources, expression) : sources);
 }