private void ModifyTables()
 {
     // foreach field
     // 1. check if table exists. If not create change table. Add add column cr.
     foreach (QPoolField poolField in poolFields)
     {
         // normally there is only one alter table cr, but check all.
         List <QAlterTableCR> alterTablesCR = ChangeRequest.GetDescendants <QAlterTableCR>().Where(CR => CR.TableName == poolField.TableName && CR.DatabaseName == DatabaseName).ToList();
         if (alterTablesCR != null && alterTablesCR.Count > 0)
         {
             // check if QAddColumnToTableCR item exists in alterTableCR.
             foreach (QAlterTableCR alterTableCR in alterTablesCR)
             {
                 List <QAddColumnToTableCR> columns = alterTableCR.GetDescendants <QAddColumnToTableCR>().Where(CR => CR.ColumnName == poolField.FieldName).ToList();
                 if (columns == null || columns.Count == 0)
                 {
                     // add field to table.
                     alterTableCR.AddColumnToTableCR(poolField.FieldName);
                 }
             }
         }
         else
         {
             // create alter table cr, add field and add it to change request.
             QAlterTableCR alterTableCR = ChangeRequest.AddNewChild <QAlterTableCR>();
             alterTableCR.TableName    = poolField.TableName;
             alterTableCR.DatabaseName = DatabaseName;
             alterTableCR.AddColumnToTableCR(poolField.FieldName);
         }
     }
 }
Beispiel #2
0
 public override void CopyState(object source)
 {
     if (source is QAlterTableCR)
     {
         QAlterTableCR cr  = (QAlterTableCR)source;
         XmlDocument   doc = new XmlDocument();
         doc.LoadXml(cr.Serialize());
         Deserialize(doc.DocumentElement);
     }
 }
Beispiel #3
0
        public override object Clone()
        {
            QAlterTableCR retval = new QAlterTableCR()
            {
                DatabaseName = this.databaseName,
                TableName    = this.tableName,
                Parent       = this.Parent
            };

            foreach (QChangeRequest child in this.Children)
            {
                retval.Children.Add((QChangeRequest)child.Clone());
            }
            return(retval);
        }
        private void UpdateChildren()
        {
            try
            {
                Children.Clear();

                foreach (QDatabaseName dbName in databaseNames)
                {
                    QAlterTableCR cr = AddNewChild <QAlterTableCR>();
                    cr.DatabaseName = dbName;
                    cr.TableName    = tableName;
                }
                foreach (QDatabaseName dbName in databaseNamesForDUI)
                {
                    QConfigureDUICR duiCR = AddNewChild <QConfigureDUICR>();
                    duiCR.Name             = dynamicUIName;
                    duiCR.InstallationCode = installationCode;
                    duiCR.DatabaseName     = dbName;

                    QConfigureDatasourceCR dsCR = AddNewChild <QConfigureDatasourceCR>();
                    dsCR.Name             = datasourceName;
                    dsCR.InstallationCode = installationCode;
                    dsCR.DatabaseName     = dbName;
                    if (dbObjectType == QDBObjectType.View)
                    {
                        QAlterViewCR viewCR = AddNewChild <QAlterViewCR>();
                        viewCR.ViewName = relatedDBObject;
                    }
                    else if (dbObjectType == QDBObjectType.Table)
                    {
                        QAlterTableCR tableCR = AddNewChild <QAlterTableCR>();
                        tableCR.TableName = relatedDBObject;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }