private BusinessObject GetBizObject(string tablename) { if (bizObjectHistory.ContainsKey(tablename)) { return(bizObjectHistory[tablename]); } else { //BizObject b = BOFactory.GetBO(tablename); BusinessObject b = BusinessObjectFactory.BuildBusinessObject(tablename); bizObjectHistory[tablename] = b; return(b); } }
public static DataTable GetAuditLog(string tablename, int primaryKey, IEnumerable <string> selectedFields) { if (!BusinessObjectFactory.CanBuildBusinessObject(tablename)) { throw new ArgumentException(string.Format("No business object has the tablename '{0}'.", tablename), "tablename"); } AuditLogDa da = new AuditLogDa(); string primaryKeyName = BusinessObject.GetPrimaryKeyName(tablename); if (BusinessObject.TableHasVirtualFields(tablename)) { IEnumerable <string> selectedRealFields = selectedFields.Where(f => !BusinessObject.IsVirtualField(tablename, f)); IEnumerable <string> virtualFields = BusinessObject.GetVirtualFields(tablename); return(da.GetVirtualAuditByTableAndPrimaryKey(tablename, primaryKeyName, primaryKey, selectedRealFields, virtualFields)); } else { return(da.GetAuditByTableAndPrimaryKey(tablename, primaryKeyName, primaryKey, selectedFields)); } }
public static List <IBusinessObject> ReadXml(string xml, out string notes, out string notesTable, out string notesField) { List <IBusinessObject> list = new List <IBusinessObject>(); StringBuilder notesBuffer = new StringBuilder(); XmlReader reader = XmlNodeReader.Create(new StringReader(xml)); string currentElementName = null; IBusinessObject currentBO = null; bool currentBOHasData = false; bool recordNotes = false; // we have to handle Status, PathTest, QOL_Therapy as special cases, since they have fieldnames = tablenames bool insideSpecialTable = false; notesTable = null; notesField = null; Truncator truncator = null; while (reader.Read()) { // state machine: every tag hit either forks or saves switch (reader.NodeType) { case XmlNodeType.EndElement: if (insideSpecialTable && reader.Name == currentBO.TableName) { insideSpecialTable = false; } break; case XmlNodeType.Element: currentElementName = reader.Name; //if ((!insideSpecialTable && BOFactory.CanBuild(currentElementName)) || currentElementName == "NoTable") if ((!insideSpecialTable && BusinessObjectFactory.CanBuildBusinessObject(currentElementName)) || currentElementName == "NoTable") { if (currentBOHasData) { list.Add(currentBO); if (truncator != null) { truncator.Finish(); } } if (currentElementName == "NoTable") { notesTable = reader.GetAttribute("PutDataInTable"); notesField = reader.GetAttribute("PutDataInField"); currentBO = null; recordNotes = true; } else { //currentBO = BOFactory.GetBO(currentElementName); currentBO = BusinessObjectFactory.BuildBusinessObject(currentElementName); recordNotes = false; //if (currentBO.HasColumn(currentBO.Tablename)) if (currentBO.HasField(currentBO.TableName)) { insideSpecialTable = true; } truncator = new Truncator(currentBO); } currentBOHasData = false; } break; case XmlNodeType.Text: if (reader.Value != null && reader.Value != "") { // if (recordNotes) // OR !currentBO.HasField(currentElementName) if (recordNotes || !currentBO.HasField(currentElementName)) { notesBuffer.Append(" | "); notesBuffer.Append(currentElementName); notesBuffer.Append(" :: "); notesBuffer.Append(reader.Value); } else { currentBO[currentElementName] = truncator.HandleValue(currentElementName, reader.Value); currentBOHasData = true; } } break; } } // finishing up if (currentBOHasData) { list.Add(currentBO); if (truncator != null) { truncator.Finish(); } } reader.Close(); if (notesBuffer.Length > 0) { notes = "OTHER EFORM DATA: " + notesBuffer.ToString(); } else { notes = null; } return(list); }