Hello Rocky, Thanks for your reply. i have looked at the blog you had put about async validation rules
and i did as i found in the blog but there's little problem , that i know that there's something missing in my code
iam sure that i have missed something, i would appreciate if you check the following code for me .
in .NET client ihad this code :
private class UniqueCurrency : BusinessRule
{
public UniqueCurrency(PropertyInfo<string> primaryProperty, PropertyInfo<string
> Affectedproperty)
{ InputProperties =
new List<Csla.Core.IPropertyInfo
> { primaryProperty };
AffectedProperties.Add(Affectedproperty); }
protected override void Execute(RuleContext context)
// bool UniqueCurrencyName<T>(T target, RuleArgs e) where T : Currency
{
var target = (Currency
)context.Target;
if (target.IsNew && ExsistCurrncyName
.IsExsist(target.ReadProperty(NameProperty)))
{ context.AddErrorResult(
"This name is allready exsist"
);
and to Async the rule in SL client side i have put the following code :
private class UniqueCurrency : BusinessRule { public UniqueCurrency(PropertyInfo<string> primaryProperty, PropertyInfo<string> Affectedproperty) { IsAsync=true; InputProperties = new List<Csla.Core.IPropertyInfo> { primaryProperty }; AffectedProperties.Add(Affectedproperty); } protected override void Execute(RuleContext context) { var bw = new System.ComponentModel.BackgroundWorker(); bw.DoWork += (o, e) => { var value = (string)context.InputPropertyValues[InputProperties[0]]; context.AddOutValue(InputProperties[0], value.ToUpper()); }; bw.RunWorkerCompleted += (o, e) => { if (e.Error != null) context.AddErrorResult(e.Error.Message); context.Complete(); }; bw.RunWorkerAsync(); } } well , what i think is happeining that the rule doesnt check any thing from the server one more last thing do i have to change any thing in the command that the rule execute on server-side
Copyright (c) Marimer LLC