protected void BackgroundWorker_Metric_OnDoWork(Object sender, System.ComponentModel.DoWorkEventArgs eventArgs)
        {
            Int64 metricId = 0;

            Boolean success = false;


            lock (processingThreadsLock) {
                foreach (Int64 currentId in processingThreads.Keys)
                {
                    if (processingThreads[currentId] == sender)
                    {
                        metricId = currentId;

                        System.Diagnostics.Debug.WriteLine("Found Metric to Process: " + currentId.ToString());

                        System.Diagnostics.Debug.WriteLine("Current Thread Count: " + processingThreads.Count);
                    }
                }
            }

            if (metricId != 0)
            {
                Application threadApplication = new Application(enterpriseConfiguration, token);

                Core.Metrics.Metric metric = threadApplication.MetricGet(metricId);

                System.Diagnostics.Debug.WriteLine("Processing Metric: " + metric.Name);

                System.Console.WriteLine("Processing Metric: " + metric.Name);

                success = metric.Process(threadApplication);
            }

            return;
        }
        public override List <ImportExport.Result> XmlImport(System.Xml.XmlNode objectNode)
        {
            List <ImportExport.Result> response = base.XmlImport(objectNode);

            MedicalServices.Service service = null;

            try {
                foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes)
                {
                    switch (currentNode.Name)
                    {
                    case "Dependencies":

                        #region Dependencies

                        foreach (System.Xml.XmlNode currentDependencyNode in currentNode.ChildNodes)
                        {
                            switch (currentDependencyNode.Name)
                            {
                            case "ServiceSet":

                                service = application.MedicalServiceGet(currentNode.Attributes["Name"].Value);

                                if (service == null)
                                {
                                    MedicalServices.ServiceSet serviceSet = new MedicalServices.ServiceSet(application);

                                    response.AddRange(serviceSet.XmlImport(currentNode));
                                }

                                break;

                            case "ServiceSingleton":

                                service = application.MedicalServiceGet(currentNode.Attributes["Name"].Value);

                                if (service == null)
                                {
                                    MedicalServices.ServiceSingleton serviceSingleton = new MedicalServices.ServiceSingleton(application);

                                    response.AddRange(serviceSingleton.XmlImport(currentNode));
                                }

                                break;

                            case "AuthorizedService":

                                Core.AuthorizedServices.AuthorizedService authorizedService = application.AuthorizedServiceGet(currentNode.Attributes["Name"].Value);

                                if (authorizedService == null)
                                {
                                    authorizedService = new AuthorizedServices.AuthorizedService(application);

                                    response.AddRange(authorizedService.XmlImport(currentDependencyNode));
                                }

                                break;

                            case "Metric":

                                Core.Metrics.Metric metric = application.MetricGet(currentNode.Attributes["Name"].Value);

                                if (metric == null)
                                {
                                    metric = new Metrics.Metric(application);

                                    response.AddRange(metric.XmlImport(currentDependencyNode));
                                }

                                break;

                            case "ProblemStatement":

                                // TODO:

                                break;
                            }
                        }

                        #endregion

                        break;

                    case "Properties":

                        #region Properties

                        foreach (System.Xml.XmlNode currentPropertyNode in currentNode.ChildNodes)
                        {
                            switch (currentPropertyNode.Attributes["Name"].Value)
                            {
                            case "EventTypeInt32": EventType = (Enumerations.PopulationTriggerEventType)Convert.ToInt32(currentPropertyNode.InnerText); break;

                            case "MetricTypeInt32": MetricType = (Metrics.Enumerations.MetricType)Convert.ToInt32(currentPropertyNode.InnerText); break;

                            case "MetricMinimum": MetricMinimum = Convert.ToDecimal(currentPropertyNode.InnerText); break;

                            case "MetricMaximum": MetricMaximum = Convert.ToDecimal(currentPropertyNode.InnerText); break;

                            case "AuthorizedServiceName": authorizedServiceId = application.AuthorizedServiceGetIdByName(currentPropertyNode.InnerText); break;

                            case "ServiceName": serviceId = application.CoreObjectGetIdByName("Service", currentPropertyNode.InnerText); break;

                            case "MetricName": metricId = application.MetricGetIdByName(currentPropertyNode.InnerText); break;

                            case "ProblemStatementName": /* TODO */ break;
                            }
                        }

                        #endregion

                        break;

                    case "Action":

                        action = new Action.Action(application);

                        response.AddRange(action.XmlImport(currentNode));

                        break;
                    } // switch (currentNode.Name) {
                }     // foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes) {

                // SAVE IS PERFORMED BY PARENT OBJECT
            }

            catch (Exception importException) {
                response.Add(new ImportExport.Result(ObjectType, Name, importException));
            }

            return(response);
        }