Exemple #1
0
        private void GenerateTriggers(List <DBInfo.Core.Statement.CreateTrigger> triggerList)
        {
            if (!Directory.Exists(OutputDir + "\\" + TriggersDir))
            {
                Directory.CreateDirectory(OutputDir + "\\" + TriggersDir);
            }

            List <string> tableNames =
                (from DBInfo.Core.Statement.CreateTrigger ct in triggerList
                 select ct.Trigger.TableName).Distinct <string>().ToList <string>();

            foreach (string tableName in tableNames)
            {
                List <DBInfo.Core.Statement.CreateTrigger> createTrigger =
                    (from DBInfo.Core.Statement.CreateTrigger ct in triggerList
                     where ct.Trigger.TableName == tableName
                     select ct).ToList <DBInfo.Core.Statement.CreateTrigger>();

                foreach (DBInfo.Core.Statement.CreateTrigger tr in createTrigger)
                {
                    CreateTrigger xmlTrigger = new CreateTrigger();
                    xmlTrigger.TableName   = tr.Trigger.TableName;
                    xmlTrigger.TriggerName = tr.Trigger.TriggerName;
                    xmlTrigger.SourceCode  = tr.Trigger.Body;

                    StatementCollection stCol = new StatementCollection();
                    stCol.Statement    = new Statement[1];
                    stCol.Statement[0] = xmlTrigger;

                    generateXMLOutput(stCol, OutputDir + "\\" + TriggersDir + "\\" + tableName + "." + tr.Trigger.TriggerName + ".trigger.xml", true);
                }
            }
        }
        private DBInfo.Core.Statement.CreateTrigger ParseCreateTriggerStatement(CreateTrigger xmlTrigger)
        {
            DBInfo.Core.Model.Trigger tr = new DBInfo.Core.Model.Trigger();
            tr.TableName   = xmlTrigger.TableName;
            tr.Body        = xmlTrigger.SourceCode;
            tr.TriggerName = xmlTrigger.TriggerName;

            DBInfo.Core.Statement.CreateTrigger ctrigger = new DBInfo.Core.Statement.CreateTrigger();
            ctrigger.Trigger = tr;
            return(ctrigger);
        }