public static void Begin(MessageGroup messageGroup)
        {
            int beforeCount = 0;
            int afterCount  = 0;

            // MessageGroup API
            List <MessageGroup> messageGroups;

            // Get existing
            beforeCount = MessageGroupDAO.Get().Count;

            // Insert and Updating: if ID is included, it will update
            messageGroup = MessageGroupDAO.PostUpdate(messageGroup);

            // Reading: Use GetMessageGroups() to retrieve a list of obj
            messageGroups = MessageGroupDAO.Get();

            // get master item count
            afterCount = messageGroups.Count;

            // write
            MessageGroupTest.Write(messageGroups, "INSERT", beforeCount, afterCount, true);
            Console.Read();

            // make a soft update to some property (Optional)
            // messageGroup.<property> = 1;

            // re-assign the before count
            beforeCount = afterCount;

            // Insert and Updating: if ID is included, it will update
            messageGroup = MessageGroupDAO.PostUpdate(messageGroup);

            // Reading: Use GetMessageGroups() to retrieve a list of obj
            messageGroups = MessageGroupDAO.Get();

            // Get existing
            afterCount = MessageGroupDAO.Get().Count;

            // write
            MessageGroupTest.Write(messageGroups, "UPDATE", beforeCount, afterCount);
            Console.Read();

            // Reading: Use GetMessageGroups() to retrieve a list of obj w/ 1 item
            messageGroups = MessageGroupDAO.Get(messageGroup);

            // get count
            afterCount = messageGroups.Count;

            // reassign count
            beforeCount = afterCount;

            // write
            MessageGroupTest.Write(messageGroups, "Single", afterCount, 1);
            Console.Read();

            // Deleting - Send in the obj w/ at minimal the ID populated
            MessageGroupDAO.Delete(messageGroup);

            // Reading: Use GetMessageGroups() to retrieve a list of obj
            messageGroups = MessageGroupDAO.Get();

            // get count
            afterCount = messageGroups.Count;

            // write
            MessageGroupTest.Write(messageGroups, "Removed", beforeCount, afterCount, true);
            Console.Read();
        }
Example #2
0
        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();
        }