Esempio n. 1
0
        public void DisplayDerivedHierarchies(Identifier modelId)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Metadata        metadata = new Metadata();
                OperationResult or       = new OperationResult();

                Metadata metaData = MDSWrapper.GetMetaData(new International(), ref or, modelId, (Identifier)null, (Identifier)null, MDAction.DerivedHierarchiesOnly);
                if (metaData == null)
                {
                    return;
                }
                this.lstDerivedHierarchies.Items.Clear();
                (this.FindForm() as Form1).ProgressBar.Maximum = metaData.DerivedHierarchies.Count;
                foreach (MdmDataContractOfModelContextIdentifier contextIdentifier in metaData.DerivedHierarchies)
                {
                    this.lstDerivedHierarchies.Items.Add((object)contextIdentifier.Identifier);
                    (this.FindForm() as Form1).ProgressBar.PerformStep();
                }
                this.lstDerivedHierarchies.DisplayMember     = "Name";
                (this.FindForm() as Form1).ProgressBar.Value = 0;
                this.initialDHlist = Enumerable.ToList <Identifier>(Enumerable.Cast <Identifier>((IEnumerable)this.lstDerivedHierarchies.Items));
            }
            catch (Exception ex)
            {
                this.lblError.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
        private void cbModel_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.cbModel.SelectedItem == null)
            {
                return;
            }
            OperationResult or = new OperationResult();

            this.DisplayVersions(MDSWrapper.GetMetaData(new International(), ref or, this.cbModel.SelectedItem as Identifier, (Identifier)null, (Identifier)null, MDAction.VersionsOnly));
        }
Esempio n. 3
0
        public static List <Identifier> GetDBAEntities(Identifier modelId, Identifier customVersionId, Entity ent)
        {
            List <Entity>   collection = new List <Entity>();
            OperationResult or         = new OperationResult();

            Metadata metaData = MDSWrapper.GetMetaData(new International(), ref or, modelId, customVersionId, (Identifier)ent.Identifier, MDAction.EntitiesOnly);

            if (metaData != null)
            {
                return(CustomEntity.GetChildDBAEntitiesId(modelId, customVersionId, metaData));
            }

            return((List <Identifier>)null);
        }
Esempio n. 4
0
        public void DisplayEntities(Identifier modelId, Identifier versionId = null)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Metadata        metadata = new Metadata();
                OperationResult or       = new OperationResult();

                Metadata metaData = MDSWrapper.GetMetaData(new International(), ref or, modelId, (Identifier)null, (Identifier)null, MDAction.EntitiesOnly);
                if (metaData == null)
                {
                    return;
                }
                this.lstEntities.Items.Clear();
                Form1 form1 = this.FindForm() as Form1;
                //Using the progress bar requires using the asyncmethods
                //if (form1 != null)
                //{
                //    form1.progressBar1.Maximum = metaData.Entities.Count;
                //    form1.progressBar1.Update();
                //}
                foreach (Entity e in metaData.Entities)
                {
                    this.lstEntities.Items.Add((object)new CustomEntity(e, versionId));
                    //if (form1 != null)
                    //{
                    //    form1.progressBar1.PerformStep();
                    //    form1.progressBar1.Update();
                    //}
                }
                this.lstEntities.DisplayMember = "Name";
                //if (form1 != null)
                //{
                //    form1.progressBar1.Value = 0;
                //    form1.progressBar1.Update();
                //}
                this.initialEntitylist = Enumerable.ToList <CustomEntity>(Enumerable.Cast <CustomEntity>((IEnumerable)this.lstEntities.Items));
            }
            catch (Exception ex)
            {
                this.lblError.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 5
0
        public void DisplayAttributes()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                OperationResult or           = new OperationResult();
                Form1           form1        = this.FindForm() as Form1;
                CustomEntity    customEntity = ((ucManageEntities)form1.FilterControlsOne(c => c is ucManageEntities)).lstEntities.SelectedItem as CustomEntity;
                if (customEntity == null || customEntity.entityId == null)
                {
                    return;
                }

                Metadata metaData      = MDSWrapper.GetMetaData(new International(), ref or, (Identifier)form1.lstModels.SelectedItem, ((CustomVersion)form1.lstVersions.SelectedItem).Identifier, (Identifier)customEntity.entityId, MDAction.AttributesOnly);
                object   selectedItem  = this.lstAttributes.SelectedItem;
                int      selectedIndex = this.lstAttributes.SelectedIndex;
                this.lstAttributes.Items.Clear();
                form1.ProgressBar.Maximum = metaData.Attributes.Count;
                foreach (MetadataAttribute attribute in metaData.Attributes)
                {
                    this.lstAttributes.Items.Add((object)new CustomMetaDataAttribute(attribute));
                    form1.ProgressBar.PerformStep();
                }
                form1.ProgressBar.Value          = 0;
                this.lstAttributes.DisplayMember = this.rbNameType.Checked ? "NameType" : "TypeName";
                //this.lstAttributes.Items.Count.ToString();
                if (this.IsAttributeExists(selectedItem as CustomMetaDataAttribute, this.lstAttributes.Items))
                {
                    this.lstAttributes.SelectedIndex = selectedIndex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
        private void btExportDiagram_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                System.Data.SqlClient.SqlConnectionStringBuilder builder = null;
                if (rbUseSingleConString.Checked && !string.IsNullOrWhiteSpace(txtSingleConString.Text))
                {
                    builder = new System.Data.SqlClient.SqlConnectionStringBuilder(txtSingleConString.Text);


                    this.cbDataSource.Text        = builder.DataSource;
                    this.cbInitialCatalog.Text    = builder.InitialCatalog;
                    this.txtAttachDbFilename.Text = builder.AttachDBFilename;
                }
                else
                if (rbUseConStringElements.Checked)
                {
                    builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
                    builder.AttachDBFilename = txtAttachDbFilename.Text;
                    builder.DataSource       = cbDataSource.Text;
                    builder.InitialCatalog   = cbInitialCatalog.Text;

                    this.txtSingleConString.Text = builder.ConnectionString;
                }

                if (!string.IsNullOrEmpty(this.cbDataSource.Text) && !string.IsNullOrEmpty(this.txtModellingDb.Text))
                {
                    if (this.cbModel.SelectedItem != null)
                    {
                        this.txtDefaultSchema.Text = string.IsNullOrEmpty(this.txtDefaultSchema.Text) ? "dbo" : this.txtDefaultSchema.Text;
                        if (this.chkDropExistingDB.Checked)
                        {
                            try
                            {
                                MDSModelling.DropExistingDb(txtSingleConString.Text, txtModellingDb.Text);
                            }
                            catch (Exception ex)
                            {
                                this.lblError.Text = ex.Message + ";" + ex.InnerException != null ? ex.InnerException.Message : "";
                            }
                        }
                        if (this.ckCreateDb.Checked)
                        {
                            try
                            {
                                MDSModelling.CreateNewDb(txtSingleConString.Text, txtModellingDb.Text);
                            }
                            catch (Exception ex)
                            {
                                this.lblError.Text = ex.Message + ";" + ex.InnerException != null ? ex.InnerException.Message : "";
                            }
                        }
                        foreach (CustomEntity customEntity in this.ucManageEntities1.lstEntities.Items)
                        {
                            MDSModelling.CreateTable(txtSingleConString.Text, customEntity.Name, txtAttachDbFilename.Text, txtModellingDb.Text, this.txtDefaultSchema.Text);
                        }

                        foreach (CustomEntity customEntity in this.ucManageEntities1.lstEntities.Items)
                        {
                            OperationResult or       = new OperationResult();
                            Metadata        metaData = MDSWrapper.GetMetaData(new International(), ref or, (Identifier)this.cbModel.SelectedItem, ((CustomVersion)this.cbVersion.SelectedItem).Identifier, (Identifier)customEntity.entityId, MDAction.AttributesOnly);
                            if (metaData != null)
                            {
                                foreach (MetadataAttribute att in metaData.Attributes)
                                {
                                    AttributeType?attributeType = att.AttributeType;
                                    if ((attributeType.GetValueOrDefault() != AttributeType.Domain ? 0 : (attributeType.HasValue ? 1 : 0)) != 0)
                                    {
                                        MDSModelling.CreateRelationShips(this.cbDataSource.Text, this.cbInitialCatalog.Text, this.txtModellingDb.Text, att.DomainEntityId.Name, att.Identifier.EntityId.Name);
                                    }
                                    else
                                    {
                                        MDSModelling.AddColumn(txtSingleConString.Text, this.txtModellingDb.Text, customEntity.Name, att);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        this.lblError.Text = "You must select a model first!";
                    }
                }
                else
                {
                    this.lblError.Text = "You must enter a data source, an initial catalog and a modelling database name or a connection string!";
                }
            }
            catch (Exception ex)
            {
                this.lblError.Text = ex.Message;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }