using System; using System.Collections.Generic; using System.Text; using Skelta.HWS.WorkListChannel; using Skelta.Core; using Workflow.NET; using System.Xml; using Skelta.HWS; namespace My.Net.Workflow { public class SimpleChannel : WorkListChannelBase, ISkeltaAddInProvider { //Mandatory methods to be overriden are: Name, Type, ReadXml, WriteXml, Clone //Methods which does not have any default implementation are: OnChannelIgnoredForWorkItem, ChannelConfigurationUserInterfaceURL //1eaef0f6-a220-454c-91cd-bbae594a770e Channel SimpleWorkList My.Net.Workflow.SimpleChannel bin\My.Net.Workflow.dll private Guid _id; private string _settings; private string _configUrl; private Log log; public SimpleChannel() { log = new Log(); _configUrl = ""; } /// /// The key used to look up the provider in the database /// public override string Name { get { return "SimpleWorkList"; } } /// /// The type of channel. All of the forms that support this type will be /// loaded as options for this channel. /// public override string Type { get { return "SimpleWork"; } } /// /// Provide a way to create a unique instance for each workflow instance /// /// public override IWorkListChannel Clone() { log.LogDebug("^^^^^ Cloning the New Simple Channel ^^^^^"); //copy across the channel properties SimpleChannel channel = (SimpleChannel)this.MemberwiseClone(); //duplicate the forms if (this._Forms == null) { channel._Forms = null; } else { log.LogDebug("^^^^^ Cloning the New Simple Channel Forms ^^^^^"); channel._Forms = this._Forms.Clone(); log.LogDebug("^^^^^ Done Cloning the New Simple Channel Forms ^^^^^"); } //copy across the state channel._RunTimeProperties = new Dictionary(); foreach (string key in _RunTimeProperties.Keys) { channel._RunTimeProperties.Add(key, this._RunTimeProperties[key]); } log.LogDebug("^^^^^ Done Cloning the New Simple Channel ^^^^^"); return channel; } /// /// Write out the instance level xml into the workflow definition when the workflow is /// saved by the designer /// /// public override void WriteXml(XmlTextWriter writer) { log.LogDebug("^^^^^ Begin WriteXML ^^^^^"); writer.WriteStartElement("config"); writer.WriteAttributeString("url", this._configUrl); writer.WriteEndElement(); base._Forms.WriteInstanceXml(writer); log.LogDebug("^^^^^ End WriteXML ^^^^^"); } /// /// Read the xml config block that is passed in here. It is coming from the workflow /// instance configured in the workflow designer. /// /// public override void ReadXml(XmlTextReader reader) { log.LogDebug("^^^^^ Begin ReadXML ^^^^^"); while (!reader.EOF) { if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Name == "channel")) { log.LogDebug("^^^^^ Found end of channel section ^^^^^"); return; } reader.Read(); if (reader.NodeType == XmlNodeType.Element) { log.LogDebug("^^^^^ Found element : " + reader.Name + " ^^^^^"); if (!(reader.Name == "config")) { if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "forms")) { log.LogDebug("^^^^^ Reading the Forms Section : " + reader.ReadOuterXml() + " ^^^^^"); this._Forms.ReadInstanceXml(reader); } } else { log.LogDebug("^^^^^ Setting Config URL : " + reader.GetAttribute("url") + " ^^^^^"); this._configUrl = reader.GetAttribute("url"); } } } log.LogDebug("^^^^^ End ReadXML ^^^^^"); } #region ISkeltaAddInProvider Members Guid ISkeltaAddInProvider.Id { get { return _id; } } void ISkeltaAddInProvider.InitializeProvider(string settings, Guid id) { log.LogDebug(string.Format("^^^^^ Initializing the new Simple Channel: {0} {1}", id.ToString(), settings)); _settings = settings; _id = id; } string ISkeltaAddInProvider.Settings { get { return _settings; } } #endregion } }