Dashboard > Manuals > Workflow Server Resources > Coding Standards
Coding Standards Log In   View a printable version of the current page.

Added by Michael Feingold , last edited by Michael Zevin on Feb 12, 2008  (view change)
Labels: 
(None)

Directory structure and import attribute

  1. One document - one xml file.
    • Description: Name of the file should be equal to document name.
    • Rational:
    • Remedies:
    • Exceptions:
    • See also: import tag
  2. One container activity - one xml file.
    • Description: Name of the file should be equal to container activity name.
    • Rational:
    • See also: import tag

Working with documents

Factories

Documents created and retrived from media only with the help of appropriate Document Factory. There are many ways to get instance of the Document Factory but using static DefaultFactory property on generated document class is only one recommended.

  • Description: You should use DefaultFactory property on generated document class.
  • Rational: This property returns typed document factory with methods (also typed) for creating/retrieving documents. So you avoid type casting to access document fields through properties on document class.
  • Exceptions: Exception is factory mapping. In this uncommon case you should use GetDocumentFactory(string name) method on current activity to access factory object. This method has base DocumentFactory type as it's return type.

Examples:

using WorkflowServer.Foundation.Documents.Factories;
using WorkflowServer.GeneratedCode.Documents;
//...
{
    StoredProcedure.Factory<userProfile> factory = userProfile.DefaultFactory;
    //....
}

See also: Document tag, Document Factory

Creating document

Use CreateDocument() method on Document Factory object or [Document Binder] object.

Example:

using WorkflowServer.GeneratedCode.Documents;
//...
{
    userProfile userProfileDocument = userProfile.DefaultFactory.CreateDocument();
    //....
}
using WorkflowServer.GeneratedCode.Documents;
//...
{
    Global.UserProfileBinder.CreateDocument();
    userProfile user = Global.UserProfileBinder.Document;
    //...
}
Retrieving document

Use RetrieveDocument(string id) or one of the SelectSingleDocument(...) methods on Document Factory object. Also you can use RetrieveDocument(string id) on appropriate [Document Binder] object.

Examples:

using WorkflowServer.GeneratedCode.Documents;
//...
{
    userProfile user = userProfile.DefaultFactory.RetrieveDocument("7e54e4a0-c71e-441d-8c6c-6c796105e892");
    //....
}
using WorkflowServer.GeneratedCode.Documents;
//...
private CaseDocument RetrieveCaseDocument(int caseId, string userId)
{
    QueryParams p = CaseDocument.DefaultFactory.NewQueryParams();
    p["CaseID"] = caseId;
    p["UserID"] = userId;
    return CaseDocument.DefaultFactory.SelectSingleDocument(p);
}
Saving document

Use Save() method on document object.

Example:

using WorkflowServer.GeneratedCode.Documents;
//...
{
    userProfile user = userProfile.DefaultFactory.RetrieveDocument("7e54e4a0-c71e-441d-8c6c-6c796105e892");
    user.FirstName = "John";
    user.Save();
}
Accessing document fields

Use public properties on generated document class.

Example:

using WorkflowServer.GeneratedCode.Documents;
//...
{
    userProfile user = userProfile.DefaultFactory.RetrieveDocument("7e54e4a0-c71e-441d-8c6c-6c796105e892");
    user.FirstName = "John";
    user.Age = 21;
    user.Save();
}
Scalar nodes and reference fields
Working with vector nodes

Web applications

  1. Simple web-session document. Large documents on web-session document should be avoided.
  2. No hidden fields. Use WSViewState instead.
  3. Clear global binders. Global binders should be cleared after use to decrease WSViewState.

Document inheritance

Inheritance
Partial classes

Activities and links

Using actions vs activity name

Databinding

Simple fields
Vector nodes

Standard services

Logging
Error handling
  • Throwing exceptions vs Application.Report()
  • Error activity
Timeout
Security
  • Global authorization should be "*"
Powered by a free Atlassian Confluence Open Source Project / Non-profit License granted to Workflow Server. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators