예제 #1
0
        protected override void ProcessOnMenuDeleteCommand()
        {
            var model = this.CurrentDocView.CurrentDiagram.ModelElement as nHydrateModel;
            var store = this.CurrentDocData.Store;

            var list       = new List <string>();
            var entityList = new List <Entity>();
            var leftovers  = new List <object>();

            foreach (var item in this.CurrentSelection)
            {
                if (item is EntityShape)
                {
                    list.Add(((item as EntityShape).ModelElement as nHydrate.Dsl.Entity).Name);
                    entityList.Add((item as EntityShape).ModelElement as nHydrate.Dsl.Entity);
                }
                else if (item is ViewShape)
                {
                    list.Add(((item as ViewShape).ModelElement as nHydrate.Dsl.View).Name);
                }
                else
                {
                    leftovers.Add(item);
                }
            }

            if (list.Count > 0)
            {
                var F = new nHydrate.DslPackage.Forms.DeleteModeObjectPrompt(list);
                if (F.ShowDialog() == DialogResult.OK)
                {
                    model.IsLoading = true;
                    try
                    {
                        using (var transaction = store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString()))
                        {
                            entityList.ForEach(x => x.Indexes.ForEach(z => z.IndexType = IndexTypeConstants.User));
                            transaction.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    finally
                    {
                        model.IsLoading = false;
                    }
                    base.ProcessOnMenuDeleteCommand();
                }
            }
            else
            {
                base.ProcessOnMenuDeleteCommand();
            }
        }
예제 #2
0
        protected override void ProcessOnMenuDeleteCommand()
        {
            var model = this.CurrentDocView.CurrentDiagram.ModelElement as nHydrateModel;
            var store = this.CurrentDocData.Store;

            var list = new List<string>();
            var entityList = new List<Entity>();
            var leftovers = new List<object>();
            foreach (var item in this.CurrentSelection)
            {
                if (item is EntityShape)
                {
                    list.Add(((item as EntityShape).ModelElement as nHydrate.Dsl.Entity).Name);
                    entityList.Add((item as EntityShape).ModelElement as nHydrate.Dsl.Entity);
                }
                else if (item is ViewShape)
                {
                    list.Add(((item as ViewShape).ModelElement as nHydrate.Dsl.View).Name);
                }
                else if (item is StoredProcedureShape)
                {
                    list.Add(((item as StoredProcedureShape).ModelElement as nHydrate.Dsl.StoredProcedure).Name);
                }
                else if (item is FunctionShape)
                {
                    list.Add(((item as FunctionShape).ModelElement as nHydrate.Dsl.Function).Name);
                }
                else
                {
                    leftovers.Add(item);
                }
            }

            if (list.Count > 0)
            {
                var F = new nHydrate.DslPackage.Forms.DeleteModeObjectPrompt(list);
                if (F.ShowDialog() == DialogResult.OK)
                {
                    model.IsLoading = true;
                    try
                    {
                        using (var transaction = store.TransactionManager.BeginTransaction(Guid.NewGuid().ToString()))
                        {
                            entityList.ForEach(x => x.Indexes.ForEach(z => z.IndexType = IndexTypeConstants.User));
                            transaction.Commit();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    finally
                    {
                        model.IsLoading = false;
                    }
                    base.ProcessOnMenuDeleteCommand();
                }
            }
            else
            {
                base.ProcessOnMenuDeleteCommand();
            }

        }