WF:Windows Workflow #۶
نویسنده: محمد جواد تواضعی
تاریخ: ۱۳۹۱/۰۹/۱۲ ۲:۳۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
public class ItemInfo
{
public string ItemCode { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
}
public class OutOfStockException : Exception
{
public OutOfStockException()
: base()
{
}
public OutOfStockException(string message)
: base(message)
{
}
}
public sealed class LookupItem : CodeActivity
{
// Define an activity input argument of type string
public InArgument<string> ItemCode { get; set; }
public OutArgument<ItemInfo> Item { get; set; }
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
ItemInfo i = new ItemInfo();
i.ItemCode = context.GetValue<string>(ItemCode);
switch (i.ItemCode)
{
case "12345":
i.Description = "Widget";
i.Price = (decimal)10.0;
break;
case "12346":
i.Description = "Gadget";
i.Price = (decimal)15.0;
break;
case "12347":
i.Description = "Super Gadget";
i.Price = (decimal)25.0; break;
}
context.SetValue(this.Item, i);
}
}
item.ItemCode
new OutOfStockException("Item Code"+item.ItemCode)
باتشکر از مطالب مفیدتون
منتظر ادامهی آموزشها هستیم
موفق باشید
namespace LeadGenerator
{
public sealed class CreateLead : CodeActivity
{
public InArgument<string> ContactName { get; set; }
public InArgument<string> ContactPhone { get; set; }
public InArgument<string> Interests { get; set; }
public InArgument<string> Notes { get; set; }
public InArgument<string> ConnectionString { get; set; }
public OutArgument<Lead> Lead { get; set; }
protected override void Execute(CodeActivityContext context)
{
// Create a Lead class and populate it with the input arguments
Lead l = new Lead();
l.ContactName = ContactName.Get(context);
l.ContactPhone = ContactPhone.Get(context);
l.Interests = Interests.Get(context);
l.Comments = Notes.Get(context);
l.WorkflowID = context.WorkflowInstanceId;
l.Status = "Open";
// Insert a record into the Lead table
LeadDataDataContext dc =
new LeadDataDataContext(ConnectionString.Get(context));
dc.Leads.InsertOnSubmit(l);
dc.SubmitChanges();
// Store the request in the OutArgument
Lead.Set(context, l);
}
}
}