예제 #1
0
 public override void CopyState(object source)
 {
     if (source is QAlterViewCR)
     {
         QAlterViewCR cr  = (QAlterViewCR)source;
         XmlDocument  doc = new XmlDocument();
         doc.LoadXml(cr.Serialize());
         Deserialize(doc.DocumentElement);
     }
 }
예제 #2
0
        public override object Clone()
        {
            QAlterViewCR retval = new QAlterViewCR()
            {
                DatabaseName = this.databaseName,
                ViewName     = this.viewName,
                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)
            {
            }
        }
        public override void Modify()
        {
            // Table
            ModifyTables();

            // View / Stored procedure(todo)
            if (dbObjectType == QDBObjectType.View)
            {
                var viewChildren = ChangeRequest.Children.Where(c => c.GetType() == typeof(QAlterViewCR) &&
                                                                ((QAlterViewCR)c).ViewName == RelatedDBObject &&
                                                                ((QAlterViewCR)c).DatabaseName == DatabaseName).ToList();
                if (viewChildren != null && viewChildren.Count > 0)
                {
                    foreach (QAlterViewCR alterViewCR in viewChildren)
                    {
                        QAlterViewCRModifier alterViewCRModifier = new QAlterViewCRModifier();
                        alterViewCRModifier.ChangeRequest = alterViewCR;
                        alterViewCRModifier.PoolFields    = poolFields;
                        alterViewCRModifier.Modify();
                    }
                }
                else
                {
                    QAlterViewCR alterViewCR = ChangeRequest.AddNewChild <QAlterViewCR>();
                    alterViewCR.ViewName     = RelatedDBObject;
                    alterViewCR.DatabaseName = DatabaseName;

                    QAlterViewCRModifier alterViewCRModifier = new QAlterViewCRModifier();
                    alterViewCRModifier.ChangeRequest = alterViewCR;
                    alterViewCRModifier.PoolFields    = poolFields;
                    alterViewCRModifier.Modify();
                }
            }

            // Datasource
            var dsChildren = ChangeRequest.Children.Where(c => c.GetType() == typeof(QConfigureDatasourceCR) &&
                                                          ((QConfigureDatasourceCR)c).Name == DatasourceName &&
                                                          ((QConfigureDatasourceCR)c).DatabaseName == DatabaseName &&
                                                          ((QConfigureDatasourceCR)c).InstallationCode == InstallationCode).ToList();

            if (dsChildren != null && dsChildren.Count > 0)
            {
                foreach (QConfigureDatasourceCR configureDatasourceCR in dsChildren)
                {
                    QConfigureDatasourceCRModifier configureDatasourceCRModifier = new QConfigureDatasourceCRModifier();
                    configureDatasourceCRModifier.ChangeRequest = configureDatasourceCR;
                    configureDatasourceCRModifier.PoolFields    = poolFields;
                    configureDatasourceCRModifier.Modify();
                }
            }
            else
            {
                QConfigureDatasourceCR configureDatasourceCR = ChangeRequest.AddNewChild <QConfigureDatasourceCR>();
                configureDatasourceCR.Name             = DatasourceName;
                configureDatasourceCR.DatabaseName     = DatabaseName;
                configureDatasourceCR.InstallationCode = InstallationCode;
                configureDatasourceCR.RelatedDBObject  = RelatedDBObject;
                QConfigureDatasourceCRModifier configureDatasourceCRModifier = new QConfigureDatasourceCRModifier();
                configureDatasourceCRModifier.ChangeRequest = configureDatasourceCR;
                configureDatasourceCRModifier.PoolFields    = poolFields;
                configureDatasourceCRModifier.Modify();
            }

            // DUI
            var duiChildren = ChangeRequest.Children.Where(c => c.GetType() == typeof(QConfigureDUICR) &&
                                                           ((QConfigureDUICR)c).Name == DatasourceName &&
                                                           ((QConfigureDUICR)c).DatabaseName == DatabaseName &&
                                                           ((QConfigureDUICR)c).InstallationCode == InstallationCode).ToList();

            if (duiChildren != null && duiChildren.Count > 0)
            {
                foreach (QConfigureDUICR configureDatasourceCR in duiChildren)
                {
                    QConfigureDUICRModifier configureDatasourceCRModifier = new QConfigureDUICRModifier();
                    configureDatasourceCRModifier.ChangeRequest = configureDatasourceCR;
                    configureDatasourceCRModifier.PoolFields    = poolFields;
                    configureDatasourceCRModifier.Modify();
                }
            }
            else
            {
                QConfigureDUICR configureDUICR = ChangeRequest.AddNewChild <QConfigureDUICR>();
                configureDUICR.Name             = DynamicUIName;
                configureDUICR.DatabaseName     = DatabaseName;
                configureDUICR.InstallationCode = InstallationCode;
                configureDUICR.RelatedDBObject  = RelatedDBObject;
                QConfigureDUICRModifier configureDUICRModifier = new QConfigureDUICRModifier();
                configureDUICRModifier.ChangeRequest = configureDUICR;
                configureDUICRModifier.PoolFields    = poolFields;
                configureDUICRModifier.Modify();
            }
        }