/// <summary>
 /// Adds a new workflow into one of the local workflow tables.
 /// If this is a newer version of an existing workflow, it is
 /// placed in the defaultWorlows table and the older version is
 /// placed in the olderWorkflows table. 
 /// </summary>
 /// <param name="fileElement">Class defining the new workflow to add.  The version
 /// member of this class is used to determine the latest version of a workflow.</param>
 private void AddNewWorkflow(WorkflowFileElement fileElement)
 {
     if (this.defaultWorkflows.ContainsKey(fileElement.Name))
     {
         var defaultItem = this.defaultWorkflows[fileElement.Name] as WorkflowFileElement;
         if (defaultItem != null && defaultItem.Version > fileElement.Version)
         {
             // Add new  to older table
             this.olderWorkflows.Add(fileElement);
         }
         else
         {
             // Found a later version of a workflow
             // Move item in default table to older table 
             // and add new element to default table
             this.olderWorkflows.Add(defaultItem);
             this.defaultWorkflows[fileElement.Name] = fileElement;
         }
     }
     else
     {
         // first time this workflow has been encountered.
         // add it to the default table.
         this.defaultWorkflows.Add(fileElement.Name, fileElement);
     }
 }
        /// <summary>
        /// Load stepData for specific workflow versi
        /// </summary>
        /// <param name="name">String containing name of workflow to load</param>
        /// <param name="version">String containing version of workflow to load</param>
        /// <param name="stepData">stepData object that is filled in with steps from 
        /// the specified BPEL workflow</param>
        /// <returns>true if workflow load was successful, false otherwise</returns>
        //public bool LoadExistingWorkflow(string name, string version, StepData stepData)
        //{
        //    XmlElement rootElement = this.LoadWorkflowFile(name, version);
        //    if (rootElement == null)
        //    {
        //        return false;
        //    }

        //    XmlNodeList childList = rootElement.ChildNodes;
        //    string cancelEventHandlerName = string.Empty;
        //    this.FillStepList(stepData.WorkflowVariables, stepData.FaultHandlers, 0, stepData.WorkflowSteps, childList, stepData.MessageTimeoutEventHanlderDict, ref cancelEventHandlerName);
        //    stepData.CancelEventHandlerName = cancelEventHandlerName;
        //    return true;
        //}

        /// <summary>
        /// Adds a new workflow bpel file to the list of known workflows.  This could be
        /// a new workflow or an updated version to an existing workflow.
        /// </summary>
        /// <param name="name">The name of the workflow.  This must correspond to the workflow name
        /// used when starting the workflow.</param>
        /// <param name="version">The version of the workflow.  This must be greater than 0.</param>
        /// <param name="fileName">The filename of the BPEL file.  This is assumed to reside in the
        /// local BPEL folder.</param>
        /// /// <param name="encryptedFileName">encrypted file name of the BPEL workflow description file</param>
        public void AddNewWorkflow(string name, float version, string fileName, string encryptedFileName)
        {
            // ensure we have a collection to add to
            this.LoadWorkflowFileCollection();
            WorkflowFileElement fileElement = new WorkflowFileElement(name, version, fileName, encryptedFileName);
            lock (this.lockObject)
            {
                this.AddNewWorkflow(fileElement);
            }
        }