public static void Begin(MessageGroupInstance messageGroupInstance) { int beforeCount = 0; int afterCount = 0; // MessageGroupInstance API List <MessageGroupInstance> messageGroupInstances; // Get existing beforeCount = MessageGroupInstanceDAO.Get().Count; // Insert and Updating: if ID is included, it will update messageGroupInstance = MessageGroupInstanceDAO.PostUpdate(messageGroupInstance); // Reading: Use GetMessageGroupInstances() to retrieve a list of obj messageGroupInstances = MessageGroupInstanceDAO.Get(); // get master item count afterCount = messageGroupInstances.Count; // write MessageGroupInstanceTest.Write(messageGroupInstances, "INSERT", beforeCount, afterCount, true); Console.Read(); // make a soft update to some property (Optional) // messageGroupInstance.<property> = 1; // re-assign the before count beforeCount = afterCount; // Insert and Updating: if ID is included, it will update messageGroupInstance = MessageGroupInstanceDAO.PostUpdate(messageGroupInstance); // Reading: Use GetMessageGroupInstances() to retrieve a list of obj messageGroupInstances = MessageGroupInstanceDAO.Get(); // Get existing afterCount = MessageGroupInstanceDAO.Get().Count; // write MessageGroupInstanceTest.Write(messageGroupInstances, "UPDATE", beforeCount, afterCount); Console.Read(); // Reading: Use GetMessageGroupInstances() to retrieve a list of obj w/ 1 item messageGroupInstances = MessageGroupInstanceDAO.Get(messageGroupInstance); // get count afterCount = messageGroupInstances.Count; // reassign count beforeCount = afterCount; // write MessageGroupInstanceTest.Write(messageGroupInstances, "Single", afterCount, 1); Console.Read(); // Deleting - Send in the obj w/ at minimal the ID populated MessageGroupInstanceDAO.Delete(messageGroupInstance); // Reading: Use GetMessageGroupInstances() to retrieve a list of obj messageGroupInstances = MessageGroupInstanceDAO.Get(); // get count afterCount = messageGroupInstances.Count; // write MessageGroupInstanceTest.Write(messageGroupInstances, "Removed", beforeCount, afterCount, true); Console.Read(); }
public static void makeNewMessageGroups() { List <String> lines = new List <string>(); lines = File.ReadAllLines(@"C:\Users\chrisb\Source\Repos\HL7Broker\HL7BrokerConsoleTest\NewMessageGroupForWebService.txt").ToList(); lines.ForEach(delegate(String line) { // skip comments if (line.Contains("##")) { return; } string[] elementSplit = line.Split('|'); // gives the first part string[] tempMessageGroupInstance = elementSplit[0].Split(','); Console.WriteLine("Inserting Message Group Instance"); MessageGroupInstance messageGroupInstance = MessageGroupInstanceDAO.PostUpdate(new MessageGroupInstance() { messageTypeId = Convert.ToInt32(tempMessageGroupInstance[0]), segmentTypeId = Convert.ToInt32(tempMessageGroupInstance[1]), description = tempMessageGroupInstance[2] }); if (messageGroupInstance.id != -1 || messageGroupInstance.id != 0) { List <String> tempMessageGroup = elementSplit[1].Split(',').ToList(); tempMessageGroup.ForEach(delegate(String tempElement) { Console.WriteLine("Inserting Message Group"); string[] tempInnerElement = tempElement.Split('^'); MessageGroupDAO.PostUpdate(new MessageGroup() { messageGroupInstanceId = messageGroupInstance.id, messagePartId = Convert.ToInt32(tempInnerElement[0]), position = Convert.ToInt32(tempInnerElement[1]) }); }); Console.WriteLine("Inserting Message Group Property or Column Set"); // gives the first part string[] tempColumnSet = elementSplit[2].Split(','); /* * ColumnSet columnSet = new ColumnSet() * { * databaseTableId = Convert.ToInt32(tempColumnSet[0]), * name = tempColumnSet[1], * messageGroupInstanceId = messageGroupInstance.id, * isPrimaryKey = Convert.ToBoolean(tempColumnSet[2]), * columnDataType = tempColumnSet[3] * }; * * ColumnSetDAO.PostUpdate(columnSet); */ WebservicePropertySet webservicePropertySet = new WebservicePropertySet() { webserviceObjectId = Convert.ToInt32(tempColumnSet[0]), name = tempColumnSet[1], messageGroupInstanceId = messageGroupInstance.id, columnDataType = tempColumnSet[2] }; WebservicePropertySetDAO.PostUpdate(webservicePropertySet); } }); Console.Read(); }