- ãèªçæ¥ããã§ãšã
- æ¶è²»è ãé·ãéãµã€ãã蚪ããŠããªãå Žåããµã€ããåŒã³åºããŸã
- ããŒãœãã©ã€ãºããããªãã¡ãŒãè¡ãïŒæ¶è²»è ãã»ã°ã¡ã³ãã«åå²ããåã»ã°ã¡ã³ãã«æçŽãéãïŒ
ãã®èšäºã§ã¯ããã®åé¡ãã©ã®ããã«è§£æ±ºãããã説æããŸãã3幎åã«éçºè ãåã ã®ã¡ãŒãªã³ã°ãªã¹ããæåããäœæããŠãããçŸåšãWebã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠãããŒãžã£ãŒãã¡ãŒãªã³ã°ãªã¹ããèšå®ããŸãã ãã®ã¹ããŒãªãŒã¯ãé»åã¡ãŒã«ããŒã±ãã£ã³ã°ã«æºãã人ã ãã§ãªããç¹å®ã®æ¶è²»è ãµã³ãã«ã§å®æçã«è€éãªæäœãå®è¡ããå¿ èŠããããã¹ãŠã®äººã«ãèå³ããããããããŸããïŒéåžžã«æœè±¡çã«èããããããããŸããããæçµçã«ã¯ãã®ãããªæœè±¡çãªåé¡ã解決ããªããã°ãªããŸããã§ããïŒã
æåã®å®è£
3幎åããã®ãããªã¿ã¹ã¯ã¯éåžžã«ãŸãã«ããçºçããããŒãããå®è£ ãããã³ã«çºçããŸããã ãã®å Žåãåã質åãçºçããŸããïŒ- ãã®ã¡ãŒã«ãæ¢ã«éä¿¡ããæ¶è²»è ã«ã¿ã°ãä»ããæ¹æ³ã¯ïŒ
- ãã¹ãŠã®æ¶è²»è ãã§ããã ãè¿ éã«åŠçãããšåæã«ããµã€ãïŒããŒã¿ããŒã¹å ã®åãã¬ã³ãŒãã«ã¢ã¯ã»ã¹ãããµã€ãïŒã®äœæ¥ãé ãããªãæ¹æ³
æåã®è³ªåãžã®çãã¯ç§ãã¡ã«ãšã£ãŠæããã§ãããæ¶è²»è ïŒãµã€ããžã®å ¥åãå人ããŒã¿ã®å€æŽïŒãŸãã¯ãã®äžïŒè³åã®åŒãåããéç¥ã®éä¿¡ïŒã«ãã£ãŠå®è¡ããããã¹ãŠã®éèŠãªã¢ã¯ã·ã§ã³ã«é¢ããæ å ±ã¯ã·ã¹ãã ã«ä¿åãããŸãã ããã«ãæ¶è²»è ã«ããããŸããŸãªãã¯ãã«ã«ããŒãã®ã¢ã¯ã·ã§ã³ã䜿çšããŸãã ãã®ãããèªåã¡ãŒãªã³ã°ãéä¿¡ãããšãã«ããã®èªåã¡ãŒãªã³ã°ããã§ã«åœŒã«éä¿¡ãããããšã瀺ãããŒã¯ãšããŠãæ¶è²»è ã«ç¹å¥ãªã¢ã¯ã·ã§ã³ããŒã«ãŒãä»ããããšã決å®ããŸããã ãã¥ãŒã¹ã¬ã¿ãŒãåéä¿¡ããªãããã«ããæ¶è²»è ã«ã¯ããŒã¯ã³ã¢ã¯ã·ã§ã³ããããŸããããšããæ¡ä»¶ãåžžã«ãã¥ãŒã¹ã¬ã¿ãŒã®æ¡ä»¶ã«è¿œå ãããŸãã
2çªç®ã®è³ªåã§ã¯ãããŒã¿ããŒã¹ã®ããã¯ã«é¢é£ããå€ãã®ã³ãŒã³ãååŸãããã®çµæã次ã®ãã¿ãŒã³ã«ãªããŸããã
- ãã¥ãŒã¹ã¬ã¿ãŒã®éä¿¡ã¯ãæ¡ä»¶ã«äžèŽããæ°ããæ¶è²»è ããããã©ãããå®æçã«ç¢ºèªããwindows-serviceããè¡ãããŸãã
- ãµãŒãã¹ã®æåã®ã¹ãããã¯ã éã³ãããèªã¿åãåé¢ã¬ãã«ã®ããŒã¿ããŒã¹ãžã®1ã€ã®ã¯ãšãªã§ã ã ãã®ãªã¯ãšã¹ãã«ãããã¬ã¿ãŒã®éä¿¡å ã§ãããã¹ãŠã®æ¶è²»è ã®IDãååŸãããŸãã åé¢ã¬ãã«ãäœãããããã®ãããªèŠæ±ã¯ããŒã¿ããŒã¹å ã®ã¬ã³ãŒãã«ããã¯ã課ããããã®çµæããµã€ãã®éçšã«éåžžã«åŒ±ã圱é¿ãäžããŸãã ãã ããããŒã¿ã®çŽåºŠãä¿èšŒãããã®ã§ã¯ãªããããããé«ãã¬ãã«ã®åé¢ã§å確èªããå¿ èŠããããŸãã
- ã³ã³ã·ã¥ãŒãã®IDãååŸããåŸãåã³ã³ã·ã¥ãŒãã«å¯ŸããŠã Serializableã®åé¢ã¬ãã«ã§åå¥ã®ãã©ã³ã¶ã¯ã·ã§ã³ãå®è¡ããŸãã ãã®ãã©ã³ã¶ã¯ã·ã§ã³ã§ã¯ãæ¶è²»è ãæ¡ä»¶ã«é©ããŠãããã©ãããå確èªããé©åã§ããã°ã圌ã«æçŽãéããããŒã«ãŒã¢ã¯ã·ã§ã³ãçºè¡ããŸãã åã³ã³ã·ã¥ãŒããŒã¯åå¥ã®ãã©ã³ã¶ã¯ã·ã§ã³ã§åŠçããããããããã¯ã¯1ã€ã®ã³ã³ã·ã¥ãŒããŒã®ããŒã¿ã«ã®ã¿èª²ãããä»ã®ã³ã³ã·ã¥ãŒããŒã®äœæ¥ã®åœ±é¿ãåããŸããã ãã®ãããªãã©ã³ã¶ã¯ã·ã§ã³ã¯éåžžã«çãããããã®æç¹ã§ãµã€ãã蚪åããã°ãæçŽã®éä¿¡å ã®æ¶è²»è ãããŸãåé¡ã«ãªããŸããã ãã©ã³ã¶ã¯ã·ã§ã³åé¢ã¬ãã«ã¯æ£ç¢ºã«Serializableã§ããå¿ èŠããããŸããããã«ããã1éã®æçŽã誀ã£ãŠ2åéä¿¡ããããçªç¶æ¡ä»¶ã«é©åããªããªã£ãæ¶è²»è ã«æçŽãéä¿¡ãããããŸããã ãã ããåãã¡ãŒãªã³ã°ãéä¿¡ã§ããã®ã¯1ã€ã®ã¹ããªãŒã ãš1ã€ã®ãµãŒããŒããã®ã¿ã§ãããçžäºã«æä»çãªæ¡ä»¶ãæã€2ã€ã®ã¡ãŒãªã³ã°ãåãã³ã³ã·ã¥ãŒããŒã«éä¿¡ãããå¯èœæ§ãå°ããããšãå¿ããå Žåã¯ã Read Committedãã©ã³ã¶ã¯ã·ã§ã³ã䜿çšã§ããŸãã
ãã¡ããããã®ãã³ãã¬ãŒãã«ããã€ãã®ã¡ãŒãªã³ã°ãå®è£ ããåŸããã³ãã¬ãŒãã³ãŒããäœæããããšã«ããŸããã ãã®ããã«ã BatchMailingã¯ã©ã¹ãäœæãããæ°ããã¡ãŒãªã³ã°ããšã«ããã®çžç¶äººãäœæããŠç¹å¥ãªã¬ãžã¹ããªã«ç»é²ããŸããã çžç¶äººã¯ã次ã®ããããã£ãšã¡ãœããããªãŒããŒããŒãããå¿ èŠããããŸããã
- ããŒã«ãŒã¢ã¯ã·ã§ã³ãã³ãã¬ãŒã ïŒä»¥åã¯ãã³ãã¬ãŒããã¢ã¯ã·ã§ã³ã¿ã€ããšåŒãã§ããŸããïŒããã¯éçºè ã«ãšã£ãŠããç解ããããçšèªã ãšæããŸãïŒãã¡ãŒã«éä¿¡æã«çºè¡ãããŸã
- çºéæ¹æ³
- è¿œå ã®ã¢ã¯ã·ã§ã³ãå®è¡ããã¡ãœããïŒããšãã°ãèªçæ¥ã®æšæ¶ãéä¿¡ãããšãšãã«ãæ¶è²»è ã«ãã€ã³ããçºè¡ã§ããŸãïŒ
- Expression <Func <Customerãbool >>ãçæããã³ã³ã·ã¥ãŒããŒãæ¡ä»¶ã«äžèŽããããšãæ€èšŒããã¡ãœãã
ããããã£ãšæåã®2ã€ã®ã¡ãœããã¯åé¡ãåŒãèµ·ãããŸããã§ãããã Expressionã®ã³ã³ãã€ã«ã¯éåžžã«å°é£ã§ããã ãã®åŒã¯2å䜿çšãããŸãã-æåã«ã³ã³ã·ã¥ãŒãã®IDãåŒãåºãããã®éã³ãããèªã¿åãèŠæ±ã§ã次ã«ã³ã³ã·ã¥ãŒããé©æ Œãã©ãããåãã§ãã¯ããããã®ã·ãªã¢ã«åå¯èœãªãã©ã³ã¶ã¯ã·ã§ã³ã§ã Linq to SQL㧠T-SQLã«å€æã§ããããã«äœæããå¿ èŠããããŸããã æ¡ä»¶ã¯éåžžã«è€éã«ãªãå¯èœæ§ããããåžžã«åé¡ããããŸããã å€æ°ã®ãã¹ããæžããã«ãã¥ãŒã¹ã¬ã¿ãŒãäœæããããšã¯ã§ããŸããã ããã«ãSMSãšé»åã¡ãŒã«ãéä¿¡ããããã«ãBatchMailingããç°ãªãäžéçžç¶äººãååŸããŸããã é»åã¡ãŒã«ãšSMSã®äž¡æ¹ãéä¿¡ããå¿ èŠãããå Žåãã³ããŒã¢ã³ãããŒã¹ãããå¿ èŠããããŸããã ãããä¿®æ£ããæ¹æ³ã«ã€ããŠã¯ã¢ã€ãã¢ããããŸããããã¯ã©ã€ã¢ã³ãã¯ããã»ã©é »ç¹ã«èªåã¡ãŒã«éä¿¡ãèŠæ±ããªãã£ããããåªå 床ã®äœãã¿ã¹ã¯ã§ããã
ç¶æ¿ãã³ã³ããžã·ã§ã³ã«çœ®ãæãã
2幎åã次ã®åºåãã£ã³ããŒã³ãéçºããéãã¯ã©ã€ã¢ã³ãã¯äžåºŠã«8çš®é¡ã®èªåã¡ãŒã«ãéä¿¡ããããäŸé ŒããŸããã ããã«ããã¥ãŒã¹ã¬ã¿ãŒã®æ¡ä»¶ãäžéšç¹°ãè¿ãããŸããã ãã¯ããã®ããã«çããããšãã§ããªããªã£ãããšã«çãã¯ãããŸããã§ãããç§ã¯ã¢ãŒããã¯ãã£ãæžãçŽãããšã«ããŸããã äžèšã®ãã¹ãŠã®åé¡ã«å¯ŸåŠããããã«ãç§ãã¡ã®å¥œããªãã¯ããã¯ãé©çšããã ãã§ååã§ãïŒç¶æ¿ãã³ã³ããžã·ã§ã³ã«çœ®ãæããã ãã®ææ³ã¯äœåºŠã圹ã«ç«ã¡ãŸããã®ã§ãå¯èœãªéãç¶æ¿ã®ä»£ããã«æ§æã䜿çšããããšããå§ãããŸãïŒãŸãããŸãã¯å°ãªããšããã®ãªãã·ã§ã³ãæ€èšããŠãã ããïŒã ãç¹å®ã®ã¿ã¹ã¯ããšã«çžç¶äººã®ãªãŒããŒããŒãã¡ãœãããšããããã£ãããããšããèãã§åºæ¬çãªæœè±¡ã¯ã©ã¹ãäœæããå Žåã¯ãããã«ã代ããã«åã¿ã¹ã¯ã®ã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ãç»é²ããŠãç°ãªãèšå®ãæž¡ãã®ã¯ãªããããšèªåããŠãã ããã ããã§æ§æãé©åã§ãªãããšã確å®ãªå Žåã«ã®ã¿ãç¶æ¿ã䜿çšããŸãã ãããé©åãªå Žåãåžžã«æ§æã«åŸã-ããã«ãããã¯ããã«æè»ã§ç解ããããã¢ãŒããã¯ãã£ãåŸãããŸããç§ãã¡ã®ç¶æ³ã§ã¯ïŒ
- ã¢ã¯ã·ã§ã³ããŒã«ãŒãã³ãã¬ãŒããè¿ãããããã£ããªãŒããŒããŒããã代ããã«ããã®ããããã£ã¯ã¯ã©ã¹ã€ã³ã¹ã¿ã³ã¹ã«ä»å ãããŸã
- æå/ SMSãéä¿¡ããŠè¿œå ã®ããžãã¯ãå®è¡ããã¡ãœããããªãŒããŒããŒããã代ããã«ãä»»æã®æäœãã¯ã©ã¹ã€ã³ã¹ã¿ã³ã¹ã«çœ®ãããŸããããã¯ã³ã³ã·ã¥ãŒãã§å®è¡ããå¿ èŠããããŸãã ããã«ãæäœã¯ä»ã®æäœã®çµã¿åããã§ãã£ãŠããã
- Expressionã圢æããã¡ãœããããªãŒããŒããŒããã代ããã«ãã¯ã©ã¹ã€ã³ã¹ã¿ã³ã¹ã«æ¡ä»¶ãäžããããŸãã ãã®å Žåãæ¡ä»¶ã¯AND / ORã§çµã¿åãããããšãã§ããŸã
ã¡ãŒãªã³ã°ã®éä¿¡ã«å ããŠããã®ãšã³ãã£ãã£ã¯ã³ã³ã·ã¥ãŒãã§ä»»æã®æäœãå®è¡ã§ãããããã¡ãŒãªã³ã°ãªã¹ããšåŒã¶ã®ã¯æ£ãããããŸããã å®éãããã¯ãç¹å®ã®æ¶è²»è ãµã³ãã«ã§ããã€ãã®æœè±¡çãªäœæ¥ãè¡ãã¯ã©ã¹ã§ãã ããè¯ããã®ãçºæããããšãªããç§ãã¡ã¯ãããããªã¬ãŒãšåŒã³å§ããŸããïŒããŒã±ãã£ã³ã°ã§ã¯ããã®ãããªãã®ãšåŒã°ããã®ã§ãååã¯æªããããŸããïŒã æ£çŽã«èšããšãã·ã¹ãã ã«éåžžã«æœè±¡çãªãšã³ãã£ãã£ïŒ DoSomeWorkOnSomeCustomersãšåŒã°ããïŒãå°å ¥ããã®ã¯å°ãæãã£ãã§ãã ããããããªã¬ãŒã®å°éåã«ã¯æå³ããããŸããã§ããã®ã§ãç§ã¯ãããæ°ã«ããªãããšã«ããŸããããããŠãååãšããŠãã¯ã©ã€ã¢ã³ãã«ãšã£ãŠããªã¬ãŒãäœã§ããããç解ããããšã«å€§ããªåé¡ã¯ãããŸããã
ããªã¬ãŒã®ç»é²ã¯æ¬¡ã®ããã«ãªããŸããã
Add(new Trigger(â one-to-oneâ) { MarkerActionTemplateSystemName = âInvitationMarkerâ, TriggerAction = new TriggerActionCombination( new GeneratePasswordForCustomerTriggerAction(), new SendEmailTriggerAction(âInvitationMailingâ)), TriggerCondition = new AndTriggerConditionSet( new CustomerHasSubscripionCondition(), new CustomerHasEmailTriggerCondition(), new CustomerHadFirstActionOverChannelCondition(âOneToOneâ)), });
TriggerActionã®ã€ã³ã¿ãŒãã§ã€ã¹ã¯éåžžã«ã·ã³ãã«ã§ãã
public interface ITriggerAction { void Execute( ModelContext modelContext, // Customer customer); }
ããªã¬ãŒæ¡ä»¶ã®åºæ¬ã¯ã©ã¹ã¯æ¬¡ã®ãšããã§ãã
public class TriggerCondition { private readonly Func<ModelContext, Expression<Func<Customer, bool>>> triggerExpressionBuilder; public TriggerCondition(Func<ModelContext, Expression<Func<Customer, bool>>> triggerExpressionBuilder) { if (triggerExpressionBuilder == null) throw new ArgumentNullException("triggerExpressionBuilder"); this.triggerExpressionBuilder = triggerExpressionBuilder; } public Expression<Func<Customer, bool>> GetExpression(ModelContext modelContext) { return triggerExpressionBuilder(modelContext, brand); } // Read Uncommitted c Id , public IQueryable<Customer> ChooseCustomers(ModelContext modelContext, IQueryable<Customer> customers) { if (modelContext == null) throw new ArgumentNullException("modelContext"); if (customers == null) throw new ArgumentNullException("customers"); var expression = GetExpression(modelContext); return customers.Where(expression).ExpandExpressions(); } // Serializable , , public bool ShouldTrigger(ModelContext modelContext, Customer customer) { if (modelContext == null) throw new ArgumentNullException("modelContext"); if (customer == null) throw new ArgumentNullException("customer"); var expression = GetExpression(modelContext); // expression.Evaluate(customer), // return modelContext.Repositories.Get<CustomerRepository>().Items .Where(aCustomer => aCustomer == customer) .Where(aCustomer => expression.Evaluate(aCustomer)) .ExpandExpressions() .Any(); } }
äžè¬çã«äœ¿çšãããæ¡ä»¶ã«ã€ããŠã¯ãã³ã³ã¹ãã©ã¯ã¿ãŒã«æž¡ããããã©ã¡ãŒã¿ãŒã«å¿ããŠç¹å®ã®åŒãæ§ç¯ãããTriggerConditionããç¶æ¿è
ãäœæããŸããã
ç²ããŠãããèªåã§ããªã¬ãŒãéå§ãã
äžèšã®ã¢ãŒããã¯ãã£ã䜿çšããŠãæ¢ã«èšè¿°ãããæ¡ä»¶ãšTriggerActionsãçµã¿åãããŠã30å以å ã«ããªã¬ãŒãèšå®ããŸãã ããããããã§ã¯ååã§ã¯ãããŸããã§ããã 次ã®ã¹ãããã§ã¯ãããªã¬ãŒãäœæããããã»ã¹ããéçºè ãå®å šã«é€å€ããŸãã ãããŠããããäžè¬çã«ã©ã®ããã«è¡ããã«ã€ããŠã¯ã以åã®ããŒãžã§ã³ã®ã¢ãŒããã¯ãã£ã®å®è£ ããæ°ãæåŸã«å®çŸããŸããã ããªã¬ãŒæ¡ä»¶ã¯ã管çããã«ã§äœ¿çšãããã£ã«ã¿ãŒãšåæ§ã«äžå¯Ÿäžã§ããã åœç€Ÿã®ãã£ã«ã¿ãŒã·ã¹ãã ã§ã¯ãé¢é£ãããšã³ãã£ãã£ãžã®ã¯ãšãªãå«ãè€éãªæ¡ä»¶ãèšè¿°ããããAND / ORã§ããããçµåãããããããšãã§ããŸãã ãã£ã«ã¿ãŒã¯åŒã圢æããŸããããã«ãããããŒã¿ããŒã¹å ã®ãšã³ãã£ãã£ãæ¢ã«ãã£ã«ã¿ãŒåŠçã§ããŸãã ãããŠãããããã¹ãŠã®ããã«ãUIãšã·ãªã¢ã©ã€ãŒãŒã·ã§ã³ã¯ãã§ã«æžãããŠããŸãã ããªã¬ãŒã«ããå¿ èŠãšãªããã£ã«ã¿ãŒãããã€ãè¿œå ããã ãã§ããããã³ã³ã·ã¥ãŒããŒã®ãªã¹ãã䜿çšããéåžžã®äœæ¥ã§ã¯æå³ããããŸããã§ããïŒããšãã°ããã¢ã¯ã·ã§ã³ããNæ¥ãçµéããŸãããïŒã TriggerActionsã®å ŽåãããŒã¿ããŒã¹ã«ããããä¿åããããã®UIãšæ§é ãèšè¿°ããå¿ èŠããããŸããããããã§ã¯ãäžè¬çã«ãã¹ãŠãæ確ã§ããã ãã ãããŸã 解決ããªããã°ãªããªãå°ããªè³ªåããããŸããã- ãã®æãŸã§ã«ãç§ãã¡ã¯ããããæçŽã®éä¿¡ãã¢ã¯ã·ã§ã³ãšããŠç»é²ãå§ããã¢ã¯ã·ã§ã³ããŒã«ãŒã¯äžèŠã«ãªããŸãã-ãã§ã«èª°ã«æçŽãéä¿¡ããããå€æã§ããŸãããäžè¬çã«ã¯ãå¯èœãªéãäžå¿ èŠãªã¢ã¯ã·ã§ã³ãçºè¡ããããªã
- åã³ã³ã·ã¥ãŒãã§ç¹å®ã®æäœã»ããã1åå®è¡ããåçŽãªããªã¬ãŒã«å ããŠã å®æçãªããªã¬ãŒããããŸã ã ããããã¹ãŠããŒã¿ããŒã¹ã«è»¢éãããšåæã«ã ä»»æã®ããŒã«ãŒã®äœ¿çšãèš±å¯ããæ¹æ³ãç解ããå¿ èŠããããŸããã
- ããŒã±ãã£ã³ã°æ åœè ã¯ãããªã¬ãŒãåå¥ã«äœæããã®ã§ã¯ãªãããµã€ãã§æ¶è²»è ãããªã¬ãŒãšæäœã®äž¡æ¹ãå®è¡ãããã§ãŒã³ãšããŠãµã€ãã«ã¢ã¯ã»ã¹ããŸãïŒãµã€ãã«ã¢ã¯ã»ã¹ããŠäœããå®è¡ããããã«æ±ããæçŽâæ¶è²»è ããµã€ãã§ããã€ãã®æäœãå®è¡ããâããŒãã¹ãã€ã³ããä»äžãããŸãïŒããã«ã€ããŠã®æçŽãéãããŸãïŒã ããã«æ°ã¥ããªãã£ãå Žåãããªã¬ãŒãšæäœã®éã®äŸåé¢ä¿ã説æããã®ãé£ãããªããªãããã«ãå°æ¥ã®ããã«åºç€ãæ®ããããšæããŸã
ãã£ãšè¡šçŸãå¿ èŠ
ããªã¬ãŒã¯æ¶è²»è ã«å¯ŸããŠæœè±¡æäœã¹ããã ïŒä»¥åã®TriggerActionïŒãå®è¡ããã»ãŒåžžã«ãã®æäœã¹ãããã¯äžæã§ããããïŒããšãã°ãç¹å®ã®æçŽãéä¿¡ãããããç¹å®ã®è³åããã®ããªã¬ãŒããã®ã¿çºè¡ãããïŒãããžãã¯ããã§ãã¯ã¢ãŠããããŠå®è¡ããããã©ããã確èªã§ããŸãã ããªã¬ãŒã«ã¯æäœã®ããã€ãã®ã¹ããããããå ŽåãããããããããŒãžã£ãŒã¯ã©ã¡ããããŒã«ãŒã«ããããéžæããå¿ èŠããããŸã ïŒåã¹ãããã®å®è¡ããã§ãã¯ããããšã¯æå³ããããŸããïŒã ãã ããæäœã¹ãããã§åŒ<Func <Customerãbool >>ãè¿ãã¡ãœãããå®è£ ããã®ã¯ç°¡åã§ããåæäœã¹ãããã§1åéãã®ããªã¬ãŒçšã«1ã€ã®åŒãäœæããå®æçãªããªã¬ãŒçšã«å¥ã®åŒãäœæããå¿ èŠãããããã§ãã ããã§ã¯ãã·ã¹ãã å ã®ãŠãŒã¶ãŒã«å¯Ÿããã»ãšãã©ãã¹ãŠã®æäœãã¢ã¯ã·ã§ã³ãæäŸãããšããäºå®ã«ãã£ãŠä¿åãããŠããŸãã ãããã£ãŠãæäœã¹ãããã¯ããããã«çºè¡ãããã¢ã¯ã·ã§ã³ãé€å€ã§ããŸãã æäœã®ã»ãšãã©ã®ã¹ãããã¯ç¹å®ã®ã¢ã¯ã·ã§ã³ãçæããã¢ã¯ã·ã§ã³ããã£ã«ã¿ãªã³ã°ããããã«åŒã圢æããã¡ãœããã¯æ¬¡ã®ããã«ãªããŸãã public sealed override Expression<Func<CustomerAction, bool>> GetIsMarkerExpression(ModelContext modelContext) { return action => action.ActionTemplateId == ActionTemplateId; }
ããããããšãã°ãè³åãçºè¡ããã¹ãããã§ã¯ã次ã®ããã«ãªããŸãã
public override Expression<Func<CustomerAction, bool>> GetIsMarkerExpression(ModelContext modelContext) { IQueryable<anchor>habracut</anchor> customerPrizes = modelContext.Repositories.Get<CustomerPrizeRepository>().GetByPrizes(Prize); // , return action => customerPrizes.Any(prize => prize.CustomerActionId == action.Id); }
ãŸããç¶æ¿ã®ä»£ããã«ãæ°ã«å ¥ãã®ã³ã³ããžã·ã§ã³ãå床é©çšããå®æçããã³1åéãã®ããªã¬ãŒã®åã ã®çžç¶äººã®ä»£ããã«ãçŸåšã®ã³ã³ã·ã¥ãŒããŒã§ããªã¬ãŒãç¹°ãè¿ãå¿ èŠããããã©ããããã§ãã¯ããæŠç¥ãäœæããŸããã ãã®æŠç¥ã¯ãããªã¬ãŒããŒã«ãŒã¹ãããããExpression <Func <CustomerActionãbool >>ãååŸã ãããã䜿çšããŠExpression <Func <Customerãbool >>ã圢æããŠãããªã¬ãŒãã³ã³ã·ã¥ãŒããŒã§å®è¡ããå¿ èŠããããã©ãããè¿œå ãã§ãã¯ããŸãã ã¯ã³ã¿ã€ã ããªã¬ãŒã®å®è£ ã¯æ¬¡ã®ãšããã§ãã
public override Expression<Func<Customer, bool>> BuildShouldRepeatExpression(ModelContext modelContext, Expression<Func<CustomerAction, bool>> isMarkerExpression) { var markerActions = modelContext.Repositories.Get<CustomerActionRepository>().Items .Where(isMarkerExpression.ExpandExpressions()); return customer => !markerActions.Any(action => action.Customer == customer); }
ããããå®æçã«ïŒ
public override Expression<Func<Customer, bool>> BuildShouldRepeatExpression( ModelContext modelContext, Expression<Func<CustomerAction, bool>> isMarkerExpression) { var isInPeriodExpression = PeriodType.BuildIsInPeriodExpression(modelContext, PeriodValue); var markerActions = modelContext.Repositories.Get<CustomerActionRepository>().Items .Where(isMarkerExpression.ExpandExpressions()); var markerActionsInPeriod = markerActions.Where(isInPeriodExpression.ExpandExpressions()); if (MaxRepeatCount == null) { return customer => !markerActionsInPeriod.Any(action => action.Customer == customer); } else { return customer => !markerActionsInPeriod.Any(action => action.Customer == customer) && markerActions.Count() < MaxRepeatCount.Value; } }
ããã§ã¯ãNæ¥ããšã«1åã ãã§ãªããæŠæ/幎ã«ã1åãµããŒããããŠãããããã¢ã¯ã·ã§ã³ãç¹å®ã®æéã«ãããã©ããã確èªããExpressionã¯ãç¹å¥ãªPeriodTypeã¯ã©ã¹ã«ç§»åãããŸãã ãŸããç¹°ãè¿ãåæ°ã®å¶éããµããŒãããŠããŸãã
ããŒã¿ããŒã¹å ã®ããããã¹ãŠã®ãã®ã®ã¹ãã¬ãŒãžã¹ããŒã ã¯æ¬¡ã®ããã«ãªããŸãã
1ã€ã®ãã£ãŒã«ããæã€OperationStepGroupã®æ¬è³ªã¯ããªãå¥åŠã«èŠããŸãããç°ãªããšã³ãã£ãã£ïŒããªã¬ãŒããµã€ãã§ã®æäœãªã©ïŒããªã¬ãŒã·ã§ãã«ããŒã¿ããŒã¹å ã®ã¬ã³ãŒãã®ã°ã«ãŒããåç §ã§ããããã«ããŸãã ããã«ããã®ãšã³ãã£ãã£ã«ã¯åŸã§è¿œå ã®ãã£ãŒã«ããåºçŸããããããã¹ãŠãããã»ã©æãããã§ã¯ãããŸããã
äžèŠãªããŒã«ãŒã¢ã¯ã·ã§ã³ãã³ãã¬ãŒããåé€ãããšããäºå®ã«å ããŠãããªã¬ãŒæäœã®æ°ã«é¢ããçµ±èšã衚瀺ããããã«ãããªã¬ãŒã®ããŒã«ãŒã¹ãããããååŸããIsMarkerExpressionã䜿çšã§ããŸãã ããªã¬ãŒãšæäœã®ãã§ãŒã³ãè¿œå ããããšãã§ããŸãïŒæäœã§ã¯ã¹ãããã䜿çšããŸããã¹ãããã®1ã€ã¯ããŒã«ãŒãšããŠããŒã¯ãããŠããŸãïŒã
ãã®çµæã管çè ã¯éçºè ã®åå ãªãã§ç®¡çè ããã«ã§çŽæ¥ããªã¬ãŒãéå§ã§ããŸãããå€ãã®å Žåãããããä¿ãå¿ èŠããããŸãïŒæ°ããããªã¬ãŒã®ç¢ºç«ã¯ç°¡åãªã¿ã¹ã¯ã§ã¯ãªãããã®ãœãªã¥ãŒã·ã§ã³ã®æè»æ§ã«å¯Ÿãããã®ãããªä»£åã§ãã åçŽãªãœãªã¥ãŒã·ã§ã³ã§ã¯æè»æ§ãäœäžããŸããããã¡ãããçŸåšã®ã¢ãŒããã¯ãã£ã®æè»æ§ã倱ããã«UIãåçŽåããããã«å€ãã®äœæ¥ãè¡ãå¿ èŠããããŸãïŒããšãã°ãåçŽãªããªã¬ãŒãäœæããããã®ãŠã£ã¶ãŒããäœæã§ããŸãïŒã
UIã§ã©ã®ããã«èŠãããã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã