Making DelayActivity Work In SharePoint 2010

Posted by | Filed under , , , ,

In the previous MOSS 2007 version of SharePoint, there was an issue of delay activities in workflows not waking up because of how the SharePoint workflow runtime works.

 Sadly, Microsoft didn't reslove the issue by default with SharePoint 2010. You still have to jump through some hoops to get it running (usually after scratching your head as to why it doesn't work and scouring the internet for solutions).

 It turns out that the way to get things running is to dust off stsadm.exe and run the following commands:

stsadm -o setproperty -pn job-workflow -pv "Every 5 minutes between 0 and 59" -url http://webappurl
stsadm -o setproperty -pn workflow-eventdelivery-throttle -pv "45"

Thanks to StackOverflow for pointing me in the right direction.

Currently rated 3.0 by 15 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Serialize or Deserialize Any .NET Object To and From an XML String

Posted by | Filed under , , , , , , ,

A new and handy feature of C# 3.0 is "extension methods". Extension methods essentially allow you to write methods for classes that you may or may not have written yourself.

Additionally, a great feature of .NET 2.0 is "generics", which allow you to create templates of methods (and classes) for multiple types at once.

Combine extension methods and generics, and you can really cook up some trouble! In terms of XML serialization, you can code a few simple lines to handle all your XML string serialization needs.

Observe:

public static class Extensions
{
   public static string ToXml<T>(this T toSerialize)
   {
 
     var serializer = new XmlSerializer(typeof(T));
      var sb = new StringBuilder();
      using (var writer = new StringWriter(sb))
         serializer.Serialize(writer, toSerialize);
      return sb.ToString();
   }


   public static T DeserializeXmlString<T>(this string xml)
   {
     
var serializer = new XmlSerializer(typeof(T));
      using (var reader = new StringReader(xml))
         return (T)serializer.Deserialize(reader);
   }
}

Observe. After creating the class above and referencing its namespace in your code, the extension method becomes available for use so that you can perform serialization/deserialization trickery like so:

public class MyClass
{

   public
int IntProperty { get; set; }
   public string StringProperty { get; set; }
}

var mc = new MyClass(){ IntProperty = 1, StringProperty = "Test" };
var xml = mc.ToXml();
//output:
//<MyClass>
// <IntProperty>1</IntProperty>
// <StringProperty>Test</StringProperty>
//</MyClass>
var deserializedMc = xml.DeserializeXmlString<MyClass>();

Currently rated 2.6 by 8 people

  • Currently 2.625/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5