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, "ProblemDomainId", ProblemDomainId.ToString()); CommonFunctions.XmlDocumentAppendPropertyNode(document, propertiesNode, "ProblemDomainName", ProblemDomainName); #endregion #region Object Nodes document.LastChild.AppendChild(document.ImportNode(ProblemDomain.XmlSerialize().LastChild, true)); #endregion return(document); }
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 "ProblemDomain": problemDomainId = application.CoreObjectGetIdByName("ProblemDomain", currentNode.Attributes["Name"].InnerText); if (problemDomainId == 0) { // DOES NOT EXIST, CREATE NEW FROM IMPORT ProblemDomain problemDomain = new ProblemDomain(application); response.AddRange(problemDomain.XmlImport(currentNode)); problemDomain.Save(); problemDomainId = application.CoreObjectGetIdByName("ProblemDomain", currentNode.Attributes["Name"].InnerText); if (problemDomainId == 0) { throw new ApplicationException("Unable to import Problem 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 " + ObjectType + ": " + Name + "."); } } catch (Exception importException) { response.Add(new ImportExport.Result(ObjectType, Name, importException)); } return(response); }
public override Boolean Save() { Boolean success = false; StringBuilder sqlStatement = new StringBuilder(); try { if (!application.HasEnvironmentPermission(Server.EnvironmentPermissions.ProblemStatementManage)) { 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(); problemDomainId = application.CoreObjectGetIdByName("ProblemDomain", problemDomainName); if (problemDomainId == 0) { ProblemDomain problemDomain = new ProblemDomain(application); problemDomain.Name = problemDomainName; problemDomain.Description = problemDomainName; problemDomain.Enabled = true; problemDomain.Visible = true; problemDomain.Save(); problemDomainId = problemDomain.Id; } problemClassId = application.ProblemClassGetIdByName(problemDomainId, problemClassName); if (problemClassId == 0) { ProblemClass problemClass = new ProblemClass(application); problemClass.Name = problemClassName; problemClass.Description = problemClassName; problemClass.ProblemDomainId = problemDomainId; problemClass.Enabled = true; problemClass.Visible = true; problemClass.Save(); problemClassId = problemClass.Id; } System.Data.IDbCommand sqlCommand = application.EnvironmentDatabase.CreateCommand("ProblemStatement_InsertUpdate"); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@problemStatementId", Id); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@problemStatementName", Name, Server.Data.DataTypeConstants.Name); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@problemStatementDescription", Description, Server.Data.DataTypeConstants.Description); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@problemDomainId", problemDomainId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@problemClassId", problemClassId); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@definingCharacteristics", definingCharacteristics, Server.Data.DataTypeConstants.Description); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@relatedFactors", relatedFactors, Server.Data.DataTypeConstants.Description); application.EnvironmentDatabase.AppendCommandParameter(sqlCommand, "@defaultCarePlanId", defaultCarePlanId); 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.Name); 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(); application.EnvironmentDatabase.CommitTransaction(); success = true; } catch (Exception applicationException) { success = false; application.EnvironmentDatabase.RollbackTransaction(); application.SetLastException(applicationException); } return(success); }