/// <summary>
        /// Restores the state of a session from the passed XML.
        /// </summary>
        /// <param name="sessionInfoXml"></param>
        /// <returns>true if this is an active session, false if not</returns>
        public override bool Restore(string sessionInfoXml)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode     node;
            bool        active = false;

            // Right now we only permit a single transfer record
            doc.LoadXml(sessionInfoXml);

            // Get the name and presence state of the saved session
            node = doc.SelectSingleNode("Session");
            XmlAttribute attr = node.Attributes["name"];

            if (attr != null)
            {
                this.Name = attr.Value;
            }
            attr = node.Attributes["presence"];
            if (attr != null)
            {
                this.PresenceState = Convert.ToInt32(attr.Value);
            }

            // Return true if this was an active session
            attr = node.Attributes["active"];
            if (attr != null)
            {
                active = Convert.ToBoolean(attr.Value);
            }

            CustomerProviderCustomerRecord c = null;

            node = doc.SelectSingleNode("descendant::Customer");
            if (node != null &&
                (this.customer == null || this.customer.CustomerID == String.Empty))
            {
                c = ReadCustomer(node.InnerXml) as CustomerProviderCustomerRecord;
                if (c != null && c.CustomerID != String.Empty)
                {
                    customer = c;
                }
            }

            // Get workflow information, if any
            node = doc.SelectSingleNode("descendant::WorkflowData");
            if (node != null)
            {
                //Workflow = node.InnerXml.Trim();

                // Workflow Driven Implementation:
                // Add the <restoredWorkflow/> tag to the workflow data so that
                // Workflow control recognise this pending workflow as restored one.
                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(node.InnerXml.Trim());
                XmlElement restoredWrkflNode = xdoc.CreateElement("restoredWorkflow");
                xdoc.DocumentElement.AppendChild(restoredWrkflNode);

                Workflow = xdoc.OuterXml;
            }

            // Get the saved application state and pass it to the current apps
            XmlNodeList nodeList = doc.SelectNodes("descendant::Application");

            if (nodeList != null)
            {
                foreach (XmlNode appNode in nodeList)
                {
                    XmlNode stateNode = appNode.SelectSingleNode("State");
                    if (stateNode != null)
                    {
                        XmlAttribute       id  = appNode.Attributes["id"];
                        IHostedApplication app = GetApplication(Convert.ToInt32(id.Value));
                        if (app != null)
                        {
                            app.SetStateData(stateNode.InnerXml);
                        }
                    }
                }
            }

            // Get the context information, if any
            // This context wraps the Ccf Conext, hence the "Context"
            // tag name and not "CcfContext"
            node = doc.SelectSingleNode("descendant::Context");
            if (node != null)
            {
                Context context = new Context();
                context.SetContext(node.InnerXml.Trim());
                this.AppHost.SetContext(context);
            }

            //added to ensure that when actions are executed
            //after the correct context is set.
            if (customer.CustomerID != String.Empty)
            {
                this.AppHost.ExecuteApplicationState();
            }

            // Select the app the transferring agent was looking at
            node = doc.SelectSingleNode("descendant::CurrentApplication");
            if (node != null)
            {
                int appID = Convert.ToInt32(node.InnerText);
                this.FocusedApplication = GetApplication(appID);
            }
            //AUDIT TRAIL
            if (null == customer)
            {
                LogData.CustomerID = String.Empty;
            }
            else
            {
                LogData.CustomerID = customer.CustomerID;
            }
            if (this.FocusedApplication != null)
            {
                LogData.ApplicationID = this.FocusedApplication.ApplicationID;
            }
            //AUDIT TRAIL END

            return(active);
        }