.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

How to assign the value of my custom activity to the variable of the parent activity?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery
 

How to assign the value of my custom activity to the variable of the parent activity?

You can see the code:

public class ExecuteService : NativeActivity
{
public OutArgument Result
{
get;
set;
}

public ExecuteService()
{
}

protected override void Execute(NativeActivityContext context)
{
//assign the value to the variable of the parent activity
}
}

public class Test
{
static Activity CreateActivity()
{

//Variable
var FirstName = new Variable<System.String>();
var LastName = new Variable<System.String>();

//FlowStep
ExecuteService ExecuteServiceObject1 = new ExecuteService()
{
Result = new System.Activities.OutArgument<System.String>(FirstName)
};
FlowStep FlowStepObject1 = new FlowStep() { Action = ExecuteServiceObject1 };

ExecuteService ExecuteServiceObject2 = new ExecuteService()
{
Result = new System.Activities.OutArgument<System.String>(LastName)
};
FlowStep FlowStepObject2 = new FlowStep() { Action = ExecuteServiceObject2 };

FlowStepObject1.Next = FlowStepObject2;

//Flowchart
Flowchart FlowChartObject1 = new Flowchart()
{
Variables =
{
FirstName,

LastName
},

StartNode = FlowStepObject1,
Nodes =



View Complete Post


More Related Resource Links

How to assign the value of my custom activity to the variable of the parent activity?

  

How to assign the value of my custom activity to the variable of the parent activity?

The custom acticity code:

public class ExecuteService : NativeActivity
    {
        public OutArgument Result
        {
            get;
            set;
        }

        public ExecuteService()
        {
        }

        protected override void Execute(NativeActivityContext context)
        {
            //assign the value to the variable of the parent activity
        }
    }

 

The workflow Code:

static Activity CreateActivity()
        {
            var FirstName = new Variable<System.String>();

  &nbs

How can i access to params and args defined in parent activity from custom NativeActivity

  

There is a scenario that the custom NativeActivity need to access to params or args defined in parent activity. What i have done as below

 protected override void Execute(NativeActivityContext context)

  {

   WorkflowInstanceProxy proxy = context.GetExtension<WorkflowInstanceInfo>().GetProxy();

   Activity root = proxy.WorkflowDefinition;

   Activity rootChild = WorkflowInspectionServices.GetActivities(root).ElementAt(0);

   EditingContext ec = new EditingContext();

   ModelTreeManager mtm = new ModelTreeManager(ec);

   mtm.Load(rootChild);

   ModelItem modelItem = mtm.Root;

   ModelProperty c1 = modelItem.Properties["Variables"];

   ModelItemCollection c2 = c1.Collection;

   dynamic c3 = c2[0].GetCurrentValue();

   string value = c3.Get(context);

  }

Apparently it is not possible to access to external params with local context so the error prompt "An activity can only access its own implementation variables."

My question is how to get it ? Is there another easy way to do so ?

Thanks,

Alex


be together be stro

When creating a custom workflow activity, how can I specify a workflow variable as a parameter?

  

I have a functioning custom workflow activity developed in VisualStudio, deployed successfully and visible in SharePoint Designer.

My problem is that I'm trying to collect a Workflow Variable of type Number from SPD as a parameter for the activity, and can't find the right combination of values for my .ACTIONS XML file...

As a simple example/test WF Activity, I'm trying to just increment a variable and return the new value to another variable. Since this is an increment (variable++) I want both variables to be defined of type Number in SPD, not String. For an example of what I want, take a look at the "Do Calculation" OotB WFA in SPD and it's (Output To _variable:_ ) , where clicking on the parameter placeholder displays a drop-down list of all Workflow Variables in the current WF.

If I set the FieldBind attribute DesignerType to Text (and the Parameter attribute Type to "System.String, mscorlib") then I get the textbox with the "..." and "fx" buttons, allowing me to select any Workflow Data variables.

But if I change that to Integer and "System.Int32, mscorlib" I get the same control, but nothing is available in the Workflow Data variables list. And if I use FieldBind.DesignerType="ParameterNames" and Parameter.Type="System.int, mscorlib" I get an empty drop-down-

Creating a Validator class for a custom activity

  
I created a new Workflow Activity Library and then added a new Activity called BindForm2Activity. After that I added a new class called BindForm2Validator and then placed an attribute to the BindForm2Activity to link it to the validator class.   Here is the code for each of the classes:   BindForm2Activity.xoml.cs: Code Snippet   using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collections;using System.Drawing;using System.Linq;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.Rules; using FormsCollection;using Utils; namespace ActivityLibrary{    [ActivityValidator(typeof(BindForm2Validator))] public partial class BindForm2Activity : SequenceActivity {        public static DependencyProperty FormToBindProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FormToBind", typeof(FormsCollection.Form2), typeof(BindForm2Activity));         [Description("Form to bind a datasource to it ")]        [Category("BindForm2ToDataSource")]        [Browsable(true)]        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]        public FormsCollection.Form2 Form

How to get this.Parent in execute method of activity.

  
Hi, Inside execute "protected override void Execute" of the NativeActivity i want to get its parent.    protected override void Execute     (     NativeActivityContext context     )       { this.Parent Actually my problem is that i want to check if this activity is in sequence or parallel during execution. Please help me.    ilogik

Freeform Custom Activity Designers using ICompositeView

  
Hello,   I'm using code posted here http://blogs.msdn.com/b/tilovell/archive/2009/12/31/freeform-custom-activity-designers-using-icompositeview.aspx hosted in a designer taken from Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4( UsingWorkflowItemPresenter.sln). However, I can't drag & drop Activity1 given as sample into Canvas or any other kind of activity for that matter. Could you tell me what I'm doing wrong, please? Also, I would like to know how I could make the Canvas activity fill the WorkflowDesigner and not being able to be deleted. Thank you

How to Prevent the expand/collapse behaviour of my Custom Activity?

  
  How can I prevent the expand feature of my custom activity with custom designer ? I have custom WF4 activities with Custom designers. These activities are not container activities. I just want to prevent the expand feature of the same; just like Assign activity. I set the Collapsible attribute of teh ActivityDesigner false; but still it is expanding to the next level. Thanks AmbilyIT Analyst

How to display breakpoint and debug visual cues with custom activity designer based on WorkflowViewE

  
Hi,   I am developing custom activity designers based on "WorkflowViewElement" instead of "ActivityDesigner" in my xaml. It allows me to have greater control of the look and feel of the designer. However I noticed that with this approach, the breakpoint visual cue (Dark red solid circle that appears on the left side of the designer when you set breakpoint on the designer) is not visible. It works fine when you write your designed based on "ActivityDesigner". The same behavior happens to the debug visual cue when you debugging the WF. It appears as bright yellow rectangle surrounding the activity designer if you are based on "ActivityDesigner", but it is not available when your designer is based on"WorkflowViewElement". Any help is highly appreciated. Li

Custom sequence activity deriving from System.Workflow.Activities.SequenceActivity

  
Hi, I try to create custom sequence activity. I found some sample (http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/f54e8eb2-29d9-46f6-ad96-766fe6fad333/). But this custom activity looks ugly (to separate nested activity using ellipses instead of arrows). My question is - how to create custom sequence activity, which will look like sequence activity. I also found this sample - <ContentPresenter x:Uid="ContentPresenter_1" Content="{Binding}" Style="{x:Static sacdt:DesignerStylesDictionary.SequenceStyle}"/> When I used this ContentPresenter my custom activity looks like System.Workflow.Activities.SequenceActivity, but I couldn't put on it another activity. I also created class, which derives from System.Workflow.Activities.SequenceActivity, but I couldn't see it in toolbox. My question is - how to create class, which derives from System.Workflow.Activities.SequenceActivity and is visible in toolbox or how to use ContentPresenter for sequence activity, which allows put on itself another activity.

Custom designer for a Flowchart activity?

  
Can anyone point me in the right direction for developing a custom designer for a Flowchart activity?  In actual fact, the Flowchart control we are using is a custom activity - it's not the regular .NET Flowchart activity, but our own creation with a collection for FlowNodes/etc.  We'd like to put a UI around it now as well ... mimicking the .NET Fllowchart designer.  Is that really possible, or extremely difficult?  It seems there's no real API or anything available for constructing the node connectors, arrows, etc.

How do I get the parent activity when an activity is moved/dropped/pasted?

  
I can't seem to find a way of determining the parent activity of an activity when it is moved about.  I have an activity that needs to be bound to a parent activity when it is inside a certain parent activity, but when outside of the parent, it needs to have the inarg blanked out so that it can be manually bound to the parent. I have all the logic worked out other than determining the parent activity. I'm using the ModelService_changed event in my rehost to detect the movement of the activity (this seems to be the only way of detecting when an activity is added, moved or copied).  The only problem is that when an activity is moved within the patern (dragged to a new location) the ModelService_changed event fires before the activities model item has been updated. So my attemps to bind always end up binding to the previous parent activity! Is there either 1. A way of getting the current (new) parent activity from the modelItem inside the ModelService_changed event? 2. Another way of detecting if an activity has been added, moved, or pasted into a new location in the workflow? Any help will be greatly appreciated. Cheers,  JasonJason Bolstad

CacheMetadata is not called when a custom activity is placed inside a flowchart

  
I wrote a simple Native activity which implements CacheMetadata(NativeActivityMetadata metadata) to declare arguments and variables. The activity works great but when I tried to use it inside a flowchart activity I found out that CacheMetadata is not called by visual studioo when the activity is dragged from the toolbox into the flow chart . This of course prevents my activity from working correctly. How can a custom activity be used inside a flowchart activity if CacheMetadata not called? Is there a way to make CacheMetadata run when the custom activity is placed inside a flowchart activity? Thanks Manu    

Custom Workflow Activity dependency property FieldNames

  
I have a custom actvity in VS2008. All is well until I added a new dependancy property like so: public static DependencyProperty EventLookupColumnNameProperty = DependencyProperty.Register("EventLookupColumnName",typeof(string),typeof(FTFSyncEventToAttachmentListItem)); public static DependencyProperty EventLookupColumnIDProperty = DependencyProperty.Register("EventLookupColumnID",typeof(string),typeof(FTFSyncEventToAttachmentListItem)); [Description("Event Lookup Column Name")][DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)][Browsable(true)][ValidationOption(ValidationOption.Required)]public string EventLookupColumnName{get { return ((string)(base.GetValue(EventLookupColumnNameProperty))); }set { base.SetValue(EventLookupColumnNameProperty, value); } [Description("Event Lookup Column ID")][ValidationOption(ValidationOption.Required)][Browsable(true)][DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]public int EventLookupColumnID{get { return ((int)(base.GetValue(EventLookupColumnIDProperty))); }set { base.SetValue(EventLookupColumnIDProperty, value); }}Then in the actions file:    <Action Name="FTF Sync Event To Attachment List Item"   ClassName="DP.Sharepoint.Workflow.FTFSyncEventToAttachmentListItem"   Assembly="DP.Sharepoint.Workflow, Version=1.0.0.0, Cultur

Custom Activity properties usage

  
I have one Custom Activity which I have used in a dynamic workflow. Dynamic means I have re hosted the designer in windows form application. Now if I try to access this Custom Activity in any other Activities I got following message. "The type of the member "messageActivity1" could not be determined.  Ensure that the declaration is correct" The Dll of this activity is in GAC and in Win Form Bin. If do the same in .Net designer it works fine. Any idea to solve this???  farukh

Custom activity feed.

  
I am trying to implement activity feed functionality for SharePoint sites. User should be able to follow activities (document added, delete etc.) on multiple SharePoint sites by subscribing to it. All sites are available for all authenticated users. Users have the option of unsubscribing to it at any time. I know that I can add custom activities. The question that I have is how can I publish these events to only users who have subscribed to the site. There are about 50K users. Does SharePoint 2010 provide any mechanism for storing who has subscribed to what site and use that to publish the events?

Flowchart workflow, custom "FlowDecision" activity?

  
Dear all, in order to simplify the workflow "design" we would like to build our own activities that return a result with one or more nodes. Something like the "True/False" nodes that come out of the FlowDecision Activity. I know that one could normally add a FlowDecision activity after our custom activity and insert the condition expression to redirect the flow based on the result... however this requires the ability to know the "content" of the previous activity, and for some users we're targeting it's not immediate. Thank you!Adriano

Change custom activity behavior

  

Hi,

To run the workflows from XAML I use WorkflowApplication.Run. I would like to change behavior of the custom activity depends on how the activity was running. I mean - in some situations my custom activity should report to DB, but in other situation shouldn't. I can add InArgument (or property) to this activity, but I don't know how to pass to my custom activity value for this InArgument (property).

Is there any other way to do, what I described?


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend