Dynamic signing of moss approval workflow

Source: Internet
Author: User
I haven't updated my blog for a long time .. It may be because I have been busy recently, or because I have too few visits and I have no motivation to write... If you want to see more Article Please harass me a lot !!!

Back to the truth:
Application scenarios:

(5.4 file approval
5.4.1 the Management System Manual shall be approved by the General Manager.
5.4.2ProgramThe document will be signed by the relevant department manager and approved by the General Manager or manager representative.
5.4.3 the assignment documents shall be approved by the drafting department manager. When other departments are involved, they must be signed by the relevant departments .)

If the same document author is in charge of multiple products or multiple documents, there will be multiple approval processes without fixed standards.

Question 1
5.4.2, I want to design it. If you want to be flexible,
It is difficult to dynamically create an activity and draw a signing channel based on the number of people...

Let's take a look at the above requirements. Moss + infopath + WF. What are your solutions ??
The key is that signatures are dynamic. I don't know how many people will sign together?

One of the above is the need for dynamic signatures. I don't know how many people have approved them,
After a friend's pick up .. You can solve this problem by using the copy component of WF...
But first we need to create an activity, and then copy the activity with the copy component...
Activity:

Workflow:

Take a closer look at my workflow interface, which contains only one replicatoractivity, and then put an activity in it
In this way, you can use the replication component to implement
Code:

Activity: Code

Using system;
Using system. componentmodel;
Using system. componentmodel. design;
Using system. collections;
Using system. drawing;
Using system. workflow. componentmodel;
Using system. workflow. componentmodel. design;
Using system. workflow. componentmodel. compiler;
Using system. workflow. componentmodel. serialization;
Using system. workflow. runtime;
Using system. workflow. Activities;
Using system. workflow. Activities. Rules;
Using Microsoft. SharePoint;
Using Microsoft. Sharepoint. workflow;

Namespace managehandbook
{
Public partial class retasksactivity: sequenceactivity
{
Public retasksactivity ()
{
Initializecomponent ();
}

Private Static dependencyproperty instancedataproperty = dependencyproperty. Register ("instancedata", typeof (spworkflowtaskproperties), typeof (retasksactivity ));

[Designerserializationvisibilityattribute (designerserializationvisibility. Visible)]
[Browsableattribute (true)]
Public spworkflowtaskproperties instancedata
{
Get
{
Return (spworkflowtaskproperties) (base. getvalue (retasksactivity. instancedataproperty )));
}
Set
{
Base. setvalue (retasksactivity. instancedataproperty, value );
}
}

Private string comment;
Public String comment
{
Set {comment = value ;}
Get {return comment ;}
}

 

Public guid taskid1 = default (system. guid);
Public Microsoft. sharepoint. workflow. spworkflowtaskproperties taskproperties1 = new Microsoft. sharepoint. workflow. spworkflowtaskproperties ();
Public Microsoft. sharepoint. workflow. spworkflowtaskproperties afterproperties1 = new Microsoft. sharepoint. workflow. spworkflowtaskproperties ();
Public Microsoft. sharepoint. workflow. spworkflowtaskproperties beforeproperties1 = new Microsoft. sharepoint. workflow. spworkflowtaskproperties ();

Private void createtask1_methodinvoking (Object sender, eventargs E)
{
Taskid1 = guid. newguid ();
Taskproperties1.tasktype = 0;
Taskproperties1.extendedproperties ["aftercomments"] = comment;
}

Private void ontaskchanged1_invoked (Object sender, externaldataeventargs E)
{
Comment = ontaskchanged1.afterproperties. extendedproperties ["Comments"]. tostring ();
}
}
}

This is from the activity.CodeIt's easy .. It mainly uses spworkflowtaskproperties to dynamically create tasks ..

Workflow. CS

Using system;
Using system. componentmodel;
Using system. componentmodel. design;
Using system. collections;
Using system. drawing;
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 Microsoft. SharePoint;
Using Microsoft. Sharepoint. workflow;
Using system. xml;
Using system. xml. serialization;
Namespace managehandbook
{
Public sealed partial class workflow1: sequentialworkflowactivity
{
Public workflow1 ()
{
Initializecomponent ();
}

private void replicatoractivity_childcompleted (Object sender, replicatorchildeventargs e)
{< br> retasksactivity = E. activity as retasksactivity;
comments = string. format ("{0} approved {1 }:{ 2} \ n", comments, workflowproperties1.web. allusers [activity. taskproperties1.assignedto]. name, activity. comment);

}

private void replicatoractivity_childinitialized (Object sender, replicatorchildeventargs e)
{< br> retasksactivity = E. activity as retasksactivity;
activity. taskproperties1 = E. instancedata as spworkflowtaskproperties;
activity. comment = comments;
}< br> Public guid workflowid = default (system. guid);
Public Microsoft. sharepoint. workflow. spworkflowactivationproperties workflowproperties1 = new Microsoft. sharepoint. workflow. spworkflowactivationproperties ();

Private string comments = string. empty;
Private person [] allperson = NULL;
Private void onworkflowactivated1_invoked (Object sender, externaldataeventargs E)
{
Workflowid = workflowproperties1.workflowid;

// Deserialize workflowproperties. initiationdata to get the instance of the initial form
Xmlserializer xs = new xmlserializer (typeof (inits ));
Xmltextreader XTR = new xmltextreader (new system. Io. stringreader (workflowproperties1.initiationdata ));
Inits init = (inits) XS. deserialize (XTR );
Allperson = init. contact;
Arraylist initlist = new arraylist ();
For (INT I = 0; I <allperson. length; I ++)
{
Spworkflowtaskproperties taskproperty = new spworkflowtaskproperties ();
Taskproperty. assignedto = allperson [I]. accountid;
Taskproperty. tasktype = 0;
Taskproperty. Title = string. Format ("Please approve {0}", workflowproperties1.item. displayname );
Initlist. Add (taskproperty );
}

Replicatoractivity. initialchilddata = initlist;
}
}

}

workflow code is simpler...
it is more important to copy the two methods of the component ..
private void replicatoractivity_childcompleted (Object sender, replicatorchildeventargs e)
{< br> retasksactivity = E. activity as retasksactivity;
comments = string. format ("{0} approved {1 }:{ 2} \ n", comments, workflowproperties1.web. allusers [activity. taskproperties1.assignedto]. name, activity. comment);

}

Private void replicatoractivity_childinitialized (Object sender, replicatorchildeventargs E)
{
Retasksactivity activity = E. activity as retasksactivity;
Activity. taskproperties1 = E. instancedata as spworkflowtaskproperties;
Activity. Comment = comments;
}

The code looks simple. But it can implement complicated processes. Dynamic signatures are certainly not a problem ..
If you follow the extension steps .. It can indeed implement many applications ..

/Files/wanghao-3/managehandbook.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.