latest posts

As mentioned yesterday I began diving back into a large project at work that involves Windows Workflow. At this point it had been almost six months to the day when I last touched the initial code I did, so today involved a lot of getting back into the mindset I had then and what I was trying to accomplish. This digging unfortunately left me figuring out I had left the code in a non-functional state, to the point that the Workflow Service was not connecting to the AppFabric databases properly. Long story short, three hours later I was able to get everything where I thought I had left it. Lesson learned here is that before jumping projects, always make sure you leave it in a usable state or at least document what isn't working properly. In my defense, the original sidetracking project was to be only three weeks. Back to the Windows Workflow development - one issue I was having today with my xamlx/Code Activity was my InArgument variables defined at a global level in my xamlx file I was not able to retrieve or set using the more proper method of: [csharp] InArgument<decimal> SomeID { get; set; protected override Guid Execute(CodeActivityContext context) { SomeID.Get(context); // To get the value SomeID.Set(context, 1234); // Set it to 1234 } [/csharp] No matter what, the value was always 0 when getting the variable's value even though it had been set on the entry point of the Workflow. After trying virtually just about everything I could I came up with a work around that does work. Do note I highly doubt this is the way Microsoft intended for it to be accomplished, but for the time being this is the only way I could get my xamlx defined variables updated/set in the custom CodeActivity. What I did was create as generic set/get functions as possible below: [csharp] private T getValue<T>(CodeActivityContext context, string name) { var properties = context.DataContext.GetProperties()[name]; if (properties == null) { return default(T); } return (T) properties.GetValue(context.DataContext); } private void setValue(CodeActivityContext context, string name, object value) { context.DataContext.GetProperties()[name].SetValue(context.DataContext, value); } [/csharp] And then to use the functionality in your CodeActivity: [csharp] protected override Guid Execute(CodeActivityContext context) { var SomeID = getValue<decimal>(context, "SomeID"); // Get the SomeID variable setValue(context, "SomeID", 1234); // Set SomeID to 1234 } [/csharp] Hopefully that gets someone on the right track and if you do eventually find the "correct" way please let me know. Otherwise I will definitely be asking the Windows Workflow experts at TechED North America in June.
Monodroid gave me headaches this afternoon, trying to mimic the Pivots on Windows Phone 7 on Android using the TabActivity. You would think you access an Activity after attaching it to a TabActivity. Well the answer is you can, but figuring it out on Monodroid will make your hair go gray. After digging through the Java based Android Documentation I finally figured it out. I don't know if this is the right way, but it works: Declare an enumeration object with each of your tabs: [csharp] public enum TABS { BasicInformation = 0, Detailinformation = 1, OptionalInforation = 2 }; [/csharp] Then add an abstract class to each of your Activity Objects: [csharp] public abstract class MyDroidActivity : Activity { public abstract bool SaveActivity(); // Any other custom code you had } Then inside your inherited Activity: public class BasicInfoActivity : MyDroidActivity { public override bool SaveActivity() { // Error handling to return false if for instance the fields weren't populated } } [/csharp] Then in your TabActivity Class: [csharp] private void SaveAllTabs() { TabHost.CurrentTab = (int)TABS.BasicInformation; BasicInformation biTab = (BasicInformation)LocalActivityManager.GetActivity(TabHost.CurrentTabTag); if (!biTab.SaveActivity()) { return; } // And continue with your other Tabs } [/csharp] Not the most elegant, but works. The inherited class and enumerations are not necessary, but helps keep things in order, especially if you have a larger application in my opinion.