public static ScoreDetail GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_score_detail.Find(id)); } }
public static TEntity FindEntity <TEntity>(Expression <Func <TEntity, bool> > predicate) where TEntity : class, new() { using (DistributionContext dbcontext = new DistributionContext()) { return(dbcontext.Set <TEntity>().FirstOrDefault(predicate)); } }
public static Product GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_product.Find(id)); } }
public void WhenInstancesRemoved_ShouldOnlyDistributeAcrossRemainingInstances() { var strategy = new SingleInstanceRoundRobinDistributionStrategy("endpointA", DistributionStrategyScope.Send); var instances = new[] { "1", "2", "3" }; var distributionContext = new DistributionContext(instances, null, null, null, null, null); var result = new List <string> { strategy.SelectDestination(distributionContext), strategy.SelectDestination(distributionContext) }; instances = instances.Take(2).ToArray(); // remove last instance. distributionContext = new DistributionContext(instances, null, null, null, null, null); result.Add(strategy.SelectDestination(distributionContext)); Assert.That(result.Count, Is.EqualTo(3)); Assert.That(result, Has.Exactly(2).EqualTo(instances[0])); Assert.That(result, Has.Exactly(1).EqualTo(instances[1])); }
public static Order GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_order.Find(id)); } }
/// <summary> /// 统计人数 /// </summary> /// <param name="agentId"></param> /// <param name="secondCount">二代人数</param> /// <param name="otherCount">二代外人数</param> /// <param name="expCount">体验店数</param> /// <returns></returns> public static int GetFirstCount(string agentId, out int secondCount, out int otherCount, out int expCount) { using (DistributionContext context = new DistributionContext()) { expCount = 0; otherCount = 0; var list = context.t_agent_relation.ToList(); var firstList = list.Where(t => t.c_parent_id == agentId && t.ChildrenAgent != null && t.ChildrenAgent.c_state > 0 ).ToList(); expCount += list.Where(t => t.c_parent_id == agentId && t.ChildrenAgent != null && t.ChildrenAgent.c_agnet_type == (int)AgentType.Exp).Count(); var pIds = firstList.Select(t => t.c_child_id).ToList(); var secondList = list.Where(t => pIds.Contains(t.c_parent_id) && t.ChildrenAgent != null && t.ChildrenAgent.c_state > 0).ToList(); expCount += list.Where(t => pIds.Contains(t.c_parent_id) && t.ChildrenAgent != null && t.ChildrenAgent.c_agnet_type == (int)AgentType.Exp).Count(); secondCount = secondList.Where(t => t.ChildrenAgent.c_agnet_type != (int)AgentType.Exp).Count();//二代数量 while (secondList.Count() > 0) { var otherParentIds = secondList.Select(t => t.c_child_id).ToList(); secondList = list.Where(t => otherParentIds.Contains(t.c_parent_id) && t.ChildrenAgent != null && t.ChildrenAgent.c_state > 0).ToList(); otherCount += secondList.Where(t => t.ChildrenAgent.c_agnet_type != (int)AgentType.Exp).Count(); } return(firstList.Where(t => t.ChildrenAgent.c_agnet_type != (int)AgentType.Exp).Count()); } }
public void WhenNewInstancesAdded_ShouldIncludeAllInstancesInDistribution() { var strategy = new SingleInstanceRoundRobinDistributionStrategy("endpointA", DistributionStrategyScope.Send); var instances = new[] { "1", "2", }; var distributionContext = new DistributionContext(instances, null, null, null, null, null); var result = new List <string> { strategy.SelectDestination(distributionContext), strategy.SelectDestination(distributionContext) }; instances = instances.Concat(new[] { "3" }).ToArray(); // add new instance distributionContext = new DistributionContext(instances, null, null, null, null, null); result.Add(strategy.SelectDestination(distributionContext)); Assert.That(result.Count, Is.EqualTo(3)); Assert.That(result, Has.Exactly(1).EqualTo(instances[0])); Assert.That(result, Has.Exactly(1).EqualTo(instances[1])); Assert.That(result, Has.Exactly(1).EqualTo(instances[2])); }
public static ScoreCash GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return context.t_score_cash.Find(id); } }
public static AgentRelation GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_agent_relation.Find(id)); } }
public static PublicNotice GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_public_notice.Find(id)); } }
public static ExpApply GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_exp_apply.Find(id)); } }
HashSet <string> SelectDestinationsForEachEndpoint(IEnumerable <UnicastRouteGroup> routeGroups, IOutgoingPublishContext context) { //Make sure we are sending only one to each transport destination. Might happen when there are multiple routing information sources. var addresses = new HashSet <string>(); foreach (var group in routeGroups) { if (group.EndpointName == null) //Routing targets that do not specify endpoint name { //Send a message to each target as we have no idea which endpoint they represent foreach (var subscriber in group.Routes) { foreach (var address in ResolveRoute(subscriber)) { addresses.Add(address); } } } else { var candidates = group.Routes.SelectMany(ResolveRoute).ToArray(); var distributionContext = new DistributionContext(candidates, context.Message, context.MessageId, context.Headers, _resolveTransportAddress, context.Extensions); var selected = _distributionPolicy.GetDistributionStrategy(group.EndpointName, DistributionStrategyScope.Publish).SelectDestination(distributionContext); addresses.Add(selected); } } return(addresses); }
public static CommConfig GetEnityById(string id) { using (DistributionContext context = new DistributionContext()) { return(context.t_common_config.Find(id)); } }
/// <summary> /// 代理等级提升判断并执行 /// </summary> /// <param name="RecomAgent">需要判断升级的代理商</param> /// <returns></returns> public static bool IsLevelUpWithCondition(Agent RecomAgent) { bool result = false; using (DistributionContext context = new DistributionContext()) { context.SaveChanges(); if (RecomAgent.c_agnet_type == (int)AgentType.Exp) { return(result); } int currentLevel = (int)RecomAgent.c_levle; //当前等级 int maxLevel = (int)context.t_level_config.Where(t => t.c_is_delete == 0).Max(t => t.c_level); //当前系统的最高级别 if (currentLevel == maxLevel) { return(result); } var list = context.t_level_config.Where(f => f.c_is_delete == 0 && f.c_level == (currentLevel + 1)); if (list.Count() > 0) { //升级所需条件配置 LevelConfig config = list.First(); var list_direct = context.t_agent_relation.Where(f => f.c_parent_id == RecomAgent.c_id && f.ChildrenAgent.c_agnet_type != (int)AgentType.Exp);//直推人数 if (list_direct.Count() < config.c_need_nums) { result = false; } else { //达到相应等级的人数 int levelCount = list_direct.Where(f => f.ChildrenAgent.c_levle >= config.c_need_level && f.ChildrenAgent.c_agnet_type != (int)AgentType.Exp).Count(); if (config.c_need_level == null) { RecomAgent.c_levle = currentLevel + 1; AgentLogic.UpdateEntity(RecomAgent); result = true; } else if (levelCount >= config.c_level_num) { RecomAgent.c_levle = currentLevel + 1; AgentLogic.UpdateEntity(RecomAgent); result = true; } } } var plist = context.t_agent_relation.Where(f => f.c_child_id == RecomAgent.c_id).ToList(); if (plist.Count() > 0) { Agent pAg = plist.FirstOrDefault().ParentAgent; IsLevelUpWithCondition(pAg); } else { result = false; } } return(result); }
public static void DeleteEntity(int ProductId) { using (DistributionContext context = new DistributionContext()) { PublicNotice DelProduct = context.t_public_notice.Find(ProductId); context.t_public_notice.Remove(DelProduct); context.SaveChanges(); } }
public static void UpdateEntity(PublicNotice UpdateProduct) { using (DistributionContext context = new DistributionContext()) { PublicNotice ag = context.t_public_notice.Find(UpdateProduct.F_Id); CommLogic.DeepClone <PublicNotice>(ag, UpdateProduct); context.SaveChanges(); } }
public static void InsertNewEntiy(PublicNotice NewProduct) { using (DistributionContext context = new DistributionContext()) { NewProduct.F_Id = Guid.NewGuid().ToString(); context.t_public_notice.Add(NewProduct); context.SaveChanges(); } }
public static void DeleteEntity(string OrderId) { using (DistributionContext context = new DistributionContext()) { Order DelOrder = context.t_order.Find(OrderId); context.t_order.Remove(DelOrder); context.SaveChanges(); } }
public static void UpdateEntity(CommConfig UpdateCommConfig) { using (DistributionContext context = new DistributionContext()) { CommConfig ag = context.t_common_config.Find(UpdateCommConfig.c_id); CommLogic.DeepClone <CommConfig>(ag, UpdateCommConfig); context.SaveChanges(); } }
public static void DeleteEntity(string AgentRelationId) { using (DistributionContext context = new DistributionContext()) { AgentRelation DelAgentRelation = context.t_agent_relation.Find(AgentRelationId); context.t_agent_relation.Remove(DelAgentRelation); context.SaveChanges(); } }
public static void DeleteEntity(string ExpApplyId) { using (DistributionContext context = new DistributionContext()) { ExpApply DelExpApply = context.t_exp_apply.Find(ExpApplyId); context.t_exp_apply.Remove(DelExpApply); context.SaveChanges(); } }
public static void UpdateEntity(ExpApply UpdateExpApply) { using (DistributionContext context = new DistributionContext()) { ExpApply ag = context.t_exp_apply.Find(UpdateExpApply.F_Id); CommLogic.DeepClone <ExpApply>(ag, UpdateExpApply); context.SaveChanges(); } }
public static void DeleteEntity(string CommConfigId) { using (DistributionContext context = new DistributionContext()) { CommConfig DelCommConfig = context.t_common_config.Find(CommConfigId); context.t_common_config.Remove(DelCommConfig); context.SaveChanges(); } }
public static void InsertNewEntiy(AgentRelation NewAgentRelation) { using (DistributionContext context = new DistributionContext()) { NewAgentRelation.c_id = Guid.NewGuid().ToString(); context.t_agent_relation.Add(NewAgentRelation); context.SaveChanges(); } }
public static void UpdateEntity(AgentRelation UpdateAgentRelation) { using (DistributionContext context = new DistributionContext()) { AgentRelation ag = context.t_agent_relation.Find(UpdateAgentRelation.c_id); CommLogic.DeepClone <AgentRelation>(ag, UpdateAgentRelation); context.SaveChanges(); } }
public static void InsertNewEntiy(CommConfig NewCommConfig) { using (DistributionContext context = new DistributionContext()) { NewCommConfig.c_id = Guid.NewGuid().ToString(); context.t_common_config.Add(NewCommConfig); context.SaveChanges(); } }
public string SelectDestination(string endpoint, string[] addresses, MessageContext context) { // NOTE: We don't deserialize the message so we can't create a logical message var distributionContext = new DistributionContext(addresses, NoMessage, context.MessageId, context.Headers, transportAddressTranslation, context.Extensions); var strategy = distributionPolicy.GetDistributionStrategy(endpoint, DistributionStrategyScope.Publish); var destination = strategy.SelectDestination(distributionContext); return(destination); }
public string SelectTopicExchangeAddress(string messageId, Dictionary <string, string> headers, ContextBag context) { var addresses = GetAllTopicExchangeAddresses().ToArray(); // NOTE: We don't deserialize the message so we can't create a logical message var distributionContext = new DistributionContext(addresses, NoMessage, messageId, headers, transportAddressTranslation, context); var strategy = distributionPolicy.GetDistributionStrategy(topicExchangeName, DistributionStrategyScope.Send); return(strategy.SelectDestination(distributionContext)); }
public static void UpdateEntity(Order UpdateOrder) { using (DistributionContext context = new DistributionContext()) { Order ag = context.t_order.Find(UpdateOrder.F_Id); CommLogic.DeepClone <Order>(ag, UpdateOrder); context.SaveChanges(); } }
public static void DeleteEntity(int ProductId) { using (DistributionContext context = new DistributionContext()) { LevelConfig DelProduct = context.t_level_config.Find(ProductId); context.t_level_config.Remove(DelProduct); context.SaveChanges(); } }