Esempio n. 1
0
        public Guid Add <TEntity>(AddEntityContext <TEntity> context) where TEntity : UserEntity
        {
            var args = new RepositoryEventArgs
            {
                AccessDbContext = context
            };

            base.OnBefore(args);
            using (var db = context.ContextProvider.Provide())
            {
                var entities = db.Set <TEntity>();
                var entity   = context.Entity;
                entity.UserId = context.UserId;
                entities.Add(entity);
                var count = db.SaveChanges();
                base.OnComplete(args);
                var success = count > 0;
                if (success)
                {
                    args.NewEntityId = entity.Id;
                    OnSuccess(args);
                }
                else
                {
                    OnFail(args);
                }
                return(success ? entity.Id : Guid.Empty);
            }
        }
Esempio n. 2
0
        public override void HandleEvent(object sender, RepositoryEventArgs e)
        {
            if (this.Name.EndsWith("AppEx"))
            {
                throw new ApplicationException("AppEx");
            }
            if (this.Name.EndsWith("NullRefEx"))
            {
                throw new NullReferenceException("NullRefEx");
            }
            if (this.Name.EndsWith("Ex"))
            {
                throw new Exception("Ex");
            }

            if (this.Name.EndsWith("Handled"))
            {
                e.Handled = true;
                return;
            }

            if (RepositoryEventFired != null)
            {
                RepositoryEventFired(this, new TestRepositoryEventArgs {
                    ContextPath = e.ContextNode.Path
                });
            }
        }
Esempio n. 3
0
        private void AddEntity_SuccessEvent(object sender, RepositoryEventArgs args)
        {
            if (args.NewEntityId == Guid.Empty)
            {
                throw new ArgumentNullException("AddEntity_SuccessEvent=>EntityId");
            }
            var context = args.AccessDbContext as AddPropertyOwnerContext <TEntity, TPropertyValueEntity>;

            if (context == null)
            {
                return;
            }
            if (context.Values == null || !context.Values.Any())
            {
                return;
            }
            var values = context.Values.ToList();

            values.ForEach(value =>
            {
                value.UserId = context.UserId;
                value.SetInstance(args.NewEntityId);
            });
            var valueContext = new SetPropertyValueContext <TPropertyValueEntity>
            {
                ContextProvider = _contextProvider,
                InstanceId      = args.NewEntityId,
                KeyProperty     = _propertyValueKeyProviderSelector.Select().Provide <TPropertyValueEntity>(),
                UserId          = context.UserId,
                PropertyValues  = values
            };

            _repositoryProviderProvider.Provide <IPropertyValueSetRepository>().Provide().SetValues(valueContext);
        }
Esempio n. 4
0
 private void OnRepositoryUpdated(object sender, RepositoryEventArgs repositoryEventArgs)
 {
     if (Visible)
     {
         this.UIThread(UpdateRepoList);
     }
 }
Esempio n. 5
0
        private void OnTreeViewItemSelected(object sender, RepositoryEventArgs e)
        {
            UpdateDescription(e.Item);

            var folder = e.Item as IFolderItem;

            toolRemoveFolder.Enabled = folder != null && folder.Root;
        }
Esempio n. 6
0
        private void OnPreAdd(object sender, RepositoryEventArgs e)
        {
            var repository = Repository.Create <IAnswerRepository>();

            foreach (var answer in _Answers)
            {
                repository.Add(answer);
            }
        }
Esempio n. 7
0
        protected override void OnDragDrop(DragEventArgs e)
        {
            bool flag  = false;
            bool flag2 = e.Effect == DragDropEffects.Copy;

            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] source = e.Data.GetData(DataFormats.FileDrop) as string[];
                if ((source != null) && (MainForm.Instance != null))
                {
                    Func <string, bool> predicate = s => ".dll .exe .xml .pdb .winmd".Split(new char[0]).Contains <string>(Path.GetExtension(s).ToLowerInvariant());
                    if (source.All <string>(predicate))
                    {
                        RunnableQuery currentQuery = MainForm.Instance.CurrentQuery;
                        if (currentQuery != null)
                        {
                            foreach (string str in source)
                            {
                                if (".dll .exe .winmd".Split(new char[0]).Contains <string>(Path.GetExtension(str).ToLowerInvariant()))
                                {
                                    currentQuery.AddRefIfNotPresent(true, new string[] { str });
                                }
                            }
                            currentQuery.SortReferences();
                            flag = true;
                        }
                    }
                    else
                    {
                        foreach (string str in source)
                        {
                            if (".linq .sql .txt".Split(new char[0]).Contains <string>(Path.GetExtension(str).ToLowerInvariant()) || (new FileInfo(str).Length < 0xc350L))
                            {
                                MainForm.Instance.OpenQuery(str, true);
                            }
                        }
                    }
                }
                MainForm.Instance.Activate();
            }
            else if (e.Data.GetDataPresent(typeof(RepositoryDragData)))
            {
                RepositoryDragData  data = (RepositoryDragData)e.Data.GetData(typeof(RepositoryDragData));
                RepositoryEventArgs args = new RepositoryEventArgs {
                    Repository = data.Repository,
                    Copy       = flag2
                };
                this.RepositoryDropped(this, args);
            }
            base.OnDragDrop(e);
            base.Focus();
            if (flag)
            {
                MainForm.Instance.BeginInvoke(new Action(MainForm.Instance.AdvancedQueryProps));
            }
        }
Esempio n. 8
0
        private void OnPreDelete(object sender, RepositoryEventArgs e)
        {
            //删除试卷原型下的问题定义
            var repository = Repository.Create <IQuestionRepository>();

            foreach (var question in _Questions)
            {
                repository.Delete(question);
            }
        }
Esempio n. 9
0
        private void OnPreDelete(object sender, RepositoryEventArgs e)
        {
            //删除试卷原型下的问题定义
            var repository = Repository.Create <IAnswerRepository>();

            foreach (var answer in _Answers)
            {
                repository.Delete(answer);
            }
        }
        private void DeleteProperty_SuccessEvent(object sender, RepositoryEventArgs args)
        {
            var successContext = args.AccessDbContext as DeletePropertyContext <TPropertyEntity>;
            var context        = new DeletePropertyValueContext <TPropertyValueEntity>
            {
                ContextProvider = _contextProvider,
                InstanceId      = successContext.Id,
                IsCancel        = false,
                KeyProperty     = _propertyValueKeyProviderSelector.Select().Provide <TPropertyValueEntity>(),
                UserId          = UserContext.Current.UserId
            };
            var repository = _repositoryProviderProvider.Provide <IPropertyValueDeleteRepository>().Provide();

            repository.Delete(context);
        }
Esempio n. 11
0
        private Task ConvertRepositoryEventAsync(object sender, RepositoryEventArgs args)
        {
            if (_mediator != null)
            {
                var repositoryAlias   = _repositoryTypeResolver.GetAlias(args.RepositoryType);
                var collectionAliases = _collectionAliasResolver.GetAlias(repositoryAlias);

                foreach (var collection in collectionAliases)
                {
                    _mediator.NotifyEvent(sender, new CollectionRepositoryEventArgs(collection, repositoryAlias, args.ParentPath, args.Id, args.Action));
                }
            }

            return(Task.CompletedTask);
        }
Esempio n. 12
0
 protected override void OnPasteDragDrop(PasteDragDropEventArgs e)
 {
     if (!(string.IsNullOrEmpty(e.get_Text()) || UserOptions.Instance.ConvertTabsToSpaces))
     {
         e.set_Text(ConvertSpacesToTabs(e.get_Text()));
     }
     if ((e.get_Source() == 4) && (SchemaTree.DragRepository != null))
     {
         RepositoryEventArgs args = new RepositoryEventArgs {
             Repository = SchemaTree.DragRepository
         };
         this.RepositoryDropped(this, args);
     }
     base.OnPasteDragDrop(e);
 }
Esempio n. 13
0
 private void ViewItemDoubleClicked(object sender, RepositoryEventArgs e)
 {
     if (e.Item is IFileItem || e.Item is IDatabaseLayerItem || e.Item is ITmsItem)
     {
         RunCommand(RepositoryCommand.AddToMap);
     }
     else if (e.Item is IServerItem)
     {
         RunCommand(RepositoryCommand.AddConnection);
     }
     else if (e.Item.Type == RepositoryItemType.TmsRoot)
     {
         RunCommand(RepositoryCommand.AddTms);
     }
     else if (e.Item.Type == RepositoryItemType.FileSystem)
     {
         RunCommand(RepositoryCommand.AddFolder);
     }
 }
Esempio n. 14
0
        private void OnPreUpdate(object sender, RepositoryEventArgs e)
        {
            if (this.IsPropertyChanged(AnswersProperty))
            {
                var repository = Repository.Create <IAnswerRepository>();
                foreach (var answer in _Answers)
                {
                    if (answer.IsNew)
                    {
                        repository.Add(answer);
                        continue;
                    }

                    if (answer.IsDirty)
                    {
                        repository.Update(answer);
                        continue;
                    }
                }
            }
        }
Esempio n. 15
0
        private void OnRepositoryStatusChanged(object sender, RepositoryEventArgs e)
        {
            // Notify
            trayIcon.ShowBalloonTip(500, "Repo changed", $"Repository {e.Name} has changed from status {e.OldStatus} to {e.NewStatus}", ToolTipIcon.Info);

            // Update menu
            var menuItems = trayMenu.Items.Find(e.Location, false);

            if (menuItems.Length == 0)
            {
                return;
            }
            this.UIThread(() =>
            {
                foreach (var affectedMenuItem in menuItems)
                {
                    UpdateRepoMenu(affectedMenuItem, e.Name, e.NewStatus);
                }
                UpdateIcon();
            });
        }
Esempio n. 16
0
 private static void Output(string name, object sender, RepositoryEventArgs args)
 {
     OutLineFormat("Event Fired: {0}, Schema {1}, Sender: {2}, Type: {3}, Data: {4}, Message: {5}", ConsoleColor.DarkYellow, name, sender?.Property("SchemaName", false), sender, args.Type?.FullName, args.Data, args.Message);
 }
Esempio n. 17
0
 void pluginHost_FileOpen(object sender, RepositoryEventArgs e)
 {
     EaLogAppender.InitializeEaLogging(e.Repository);
 }
Esempio n. 18
0
 private void OnRepositoyListChanged(object sender, RepositoryEventArgs e)
 {
     CreateRepositoryMenyEntries();
 }
Esempio n. 19
0
 private void OnPreDelete(object sender, RepositoryEventArgs e)
 {
     //删除组织之前,需要删除该组织下的所有角色
     DeleteRoles();
 }
Esempio n. 20
0
 protected override void OnPasteDragDrop(PasteDragDropEventArgs e)
 {
     if (!(string.IsNullOrEmpty(e.get_Text()) || UserOptions.Instance.ConvertTabsToSpaces))
     {
         e.set_Text(ConvertSpacesToTabs(e.get_Text()));
     }
     if ((e.get_Source() == 4) && (SchemaTree.DragRepository != null))
     {
         RepositoryEventArgs args = new RepositoryEventArgs {
             Repository = SchemaTree.DragRepository
         };
         this.RepositoryDropped(this, args);
     }
     base.OnPasteDragDrop(e);
 }
Esempio n. 21
0
 protected override void OnDragDrop(DragEventArgs e)
 {
     bool flag = false;
     bool flag2 = e.Effect == DragDropEffects.Copy;
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] source = e.Data.GetData(DataFormats.FileDrop) as string[];
         if ((source != null) && (MainForm.Instance != null))
         {
             Func<string, bool> predicate = s => ".dll .exe .xml .pdb .winmd".Split(new char[0]).Contains<string>(Path.GetExtension(s).ToLowerInvariant());
             if (source.All<string>(predicate))
             {
                 RunnableQuery currentQuery = MainForm.Instance.CurrentQuery;
                 if (currentQuery != null)
                 {
                     foreach (string str in source)
                     {
                         if (".dll .exe .winmd".Split(new char[0]).Contains<string>(Path.GetExtension(str).ToLowerInvariant()))
                         {
                             currentQuery.AddRefIfNotPresent(true, new string[] { str });
                         }
                     }
                     currentQuery.SortReferences();
                     flag = true;
                 }
             }
             else
             {
                 foreach (string str in source)
                 {
                     if (".linq .sql .txt".Split(new char[0]).Contains<string>(Path.GetExtension(str).ToLowerInvariant()) || (new FileInfo(str).Length < 0xc350L))
                     {
                         MainForm.Instance.OpenQuery(str, true);
                     }
                 }
             }
         }
         MainForm.Instance.Activate();
     }
     else if (e.Data.GetDataPresent(typeof(RepositoryDragData)))
     {
         RepositoryDragData data = (RepositoryDragData) e.Data.GetData(typeof(RepositoryDragData));
         RepositoryEventArgs args = new RepositoryEventArgs {
             Repository = data.Repository,
             Copy = flag2
         };
         this.RepositoryDropped(this, args);
     }
     base.OnDragDrop(e);
     base.Focus();
     if (flag)
     {
         MainForm.Instance.BeginInvoke(new Action(MainForm.Instance.AdvancedQueryProps));
     }
 }
Esempio n. 22
0
 /// <summary>
 /// Handles the Addin Connect event of the PluginHost control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The instance containing the event data.</param>
 /// <returns>an optional xml containing a MDG Technology via e.ReturnString</returns>
 void PluginHost_Connect(object sender, RepositoryEventArgs e)
 {
     pluginHost.LoadPlugins();
     pluginHost.AddPlugin(new AboutPluginHost(), Assembly.GetExecutingAssembly());
 }