Beispiel #1
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode propertiesNode = document.ChildNodes[1].ChildNodes[0];


            #region Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureDomainId", CareMeasureDomainId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "CareMeasureDomainName", CareMeasureDomainName);

            #endregion


            #region Object Nodes

            document.LastChild.AppendChild(document.ImportNode(CareMeasureDomain.XmlSerialize().LastChild, true));

            #endregion


            return(document);
        }
Beispiel #2
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)
                            {
                            // DO NOTHING EXTRA, NO PROPERTIES BESIDES BASE PROPERTIES

                            // DOMAIN IS HANDLED UNDER RELATED OBJECTS

                            default: break;
                            }
                        }

                        break;

                    case "CareMeasureDomain":

                        careMeasureDomainId = application.CoreObjectGetIdByName("CareMeasureDomain", currentNode.Attributes["Name"].InnerText);

                        if (careMeasureDomainId == 0)
                        {
                            // DOES NOT EXIST, CREATE NEW FROM IMPORT

                            CareMeasureDomain careMeasureDomain = new CareMeasureDomain(application);

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

                            careMeasureDomain.Save();

                            careMeasureDomainId = application.CoreObjectGetIdByName("CareMeasureDomain", currentNode.Attributes["Name"].InnerText);

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

                        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 Care Measure Class: " + Name + ".");
                }
            }

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

            return(response);
        }
        public override Boolean Save()
        {
            Boolean success = false;

            String childIds = String.Empty;


            try {
                if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.CareMeasureManage))
                {
                    throw new ApplicationException("PermissionDenied");
                }

                Dictionary <String, String> validationResponse = Validate();

                if (validationResponse.Count != 0)
                {
                    foreach (String validationKey in validationResponse.Keys)
                    {
                        throw new ApplicationException("Invalid [" + validationKey + "]: " + validationResponse[validationKey]);
                    }
                }


                ModifiedAccountInfo = new Data.AuthorityAccountStamp(application);

                application.EnvironmentDatabase.BeginTransaction();


                careMeasureDomainId = application.CoreObjectGetIdByName("CareMeasureDomain", careMeasureDomainName);

                if (careMeasureDomainId == 0)
                {
                    CareMeasureDomain careMeasureDomain = new CareMeasureDomain(application);

                    careMeasureDomain.Name = careMeasureDomainName;

                    careMeasureDomain.Description = careMeasureDomainName;

                    careMeasureDomain.Enabled = true;

                    careMeasureDomain.Visible = true;

                    careMeasureDomain.Save();

                    careMeasureDomainId = careMeasureDomain.Id;
                }

                careMeasureClassId = application.CareMeasureClassGetIdByName(careMeasureDomainId, careMeasureClassName);

                if (careMeasureClassId == 0)
                {
                    CareMeasureClass careMeasureClass = new CareMeasureClass(application);

                    careMeasureClass.Name = careMeasureClassName;

                    careMeasureClass.Description = careMeasureClassName;

                    careMeasureClass.CareMeasureDomainId = careMeasureDomainId;

                    careMeasureClass.Enabled = true;

                    careMeasureClass.Visible = true;

                    careMeasureClass.Save();

                    careMeasureClassId = careMeasureClass.Id;
                }



                System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("CareMeasure_InsertUpdate");

                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureId", Id);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureName", Name, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureDescription", Description, Server.Data.DataTypeConstants.Description);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@careMeasureClassId", careMeasureClassId);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@enabled", Enabled);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@visible", Visible);


                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAuthorityName", ModifiedAccountInfo.SecurityAuthorityName, Server.Data.DataTypeConstants.Name);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountId", ModifiedAccountInfo.UserAccountId, Server.Data.DataTypeConstants.UserAccountId);

                application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@modifiedAccountName", ModifiedAccountInfo.UserAccountName, Server.Data.DataTypeConstants.Name);


                success = (sqlCommand.ExecuteNonQuery() > 0);


                if (!success)
                {
                    application.SetLastException(application.EnvironmentDatabase.LastException);

                    throw application.EnvironmentDatabase.LastException;
                }

                SetIdentity();


                foreach (CareMeasureComponent currentComponent in components)
                {
                    if (currentComponent.Id != 0)
                    {
                        childIds += currentComponent.Id.ToString() + ", ";
                    }
                }

                if (!String.IsNullOrWhiteSpace(childIds))    // DELETE ALL REMOVED CHILD IDS FROM DATABASE

                {
                    childIds += "0";

                    String deleteStatement = "DELETE FROM dbo.CareMeasureComponent WHERE CareMeasureId = " + Id.ToString() + " AND CareMeasureComponentId NOT IN (" + childIds + ")";

                    success = application.EnvironmentDatabase.ExecuteSqlStatement(deleteStatement);

                    if (!success)
                    {
                        throw new ApplicationException("Unable to propertly delete child Components from database.");
                    }
                }

                foreach (CareMeasureComponent currentComponent in components)
                {
                    currentComponent.Application = application;

                    currentComponent.CareMeasureId = id;

                    success = currentComponent.Save();

                    if (!success)
                    {
                        throw new ApplicationException("Unable to save Measure Component.");
                    }
                }


                application.EnvironmentDatabase.CommitTransaction();

                success = true;
            }

            catch (Exception applicationException) {
                success = false;

                application.EnvironmentDatabase.RollbackTransaction();

                application.SetLastException(applicationException);
            }

            return(success);
        }