Пример #1
0
        public override List <ImportExport.Result> XmlImport(System.Xml.XmlNode objectNode)
        {
            List <ImportExport.Result> response = base.XmlImport(objectNode);


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

                        foreach (System.Xml.XmlNode currentPropertyNode in currentNode.ChildNodes)
                        {
                            switch (currentPropertyNode.Attributes["Name"].InnerText)
                            {
                            case "ProblemDomainName":

                                problemDomainName = currentPropertyNode.InnerText;

                                problemDomainId = application.CoreObjectGetIdByName("ProblemDomain", problemDomainName);

                                break;

                            case "DefiningCharacteristics": DefiningCharacteristics = currentPropertyNode.InnerText; break;

                            case "RelatedFactors": RelatedFactors = currentPropertyNode.InnerText; break;

                            default: break;
                            }
                        }

                        break;

                    case "ProblemClass":

                        // USES THE DOMAIN ID CAPTURED UNDER PROPERTIES

                        problemClassName = currentNode.Attributes["Name"].InnerText;

                        ProblemClass problemClass = application.ProblemClassGetByName(problemDomainId, problemClassName);

                        if (problemClass == null)
                        {
                            // DOES NOT EXIST, CREATE NEW FROM IMPORT

                            problemClass = new ProblemClass(application);

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

                            problemDomainId = problemClass.ProblemDomainId;

                            problemClassId = problemClass.Id;


                            if (problemClassId == 0)
                            {
                                throw new ApplicationException("Unable to import Care Measure Class: " + currentNode.Attributes["Name"].InnerText + ".");
                            }
                        }

                        break;

                    case "CarePlan":

                        CarePlan defaultCarePlan = application.CarePlanGet(currentNode.Attributes["Name"].InnerText);

                        if (defaultCarePlan == null)
                        {
                            // DOES NOT EXIST, CREATE NEW FROM IMPORT

                            defaultCarePlan = new CarePlan(application);

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

                        if (defaultCarePlan != null)
                        {
                            defaultCarePlanId = defaultCarePlan.Id;
                        }

                        break;
                    } // switch (currentNode.Attributes["Name"].InnerText) {
                }     // foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes) {


                // SAVE IMPORTED CLASS

                if (!Save())
                {
                    throw new ApplicationException("Unable to save " + ObjectType + ": " + Name + ".");
                }
            }

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

            return(response);
        }