Exemple #1
0
 /// <summary>
 /// 注册单次事件
 /// </summary>
 /// <param name="eventName">事件名字</param>
 /// <param name="fn">回调方法</param>
 public void OnceRegiestEvent(string eventName, EventMethod fn)
 {
     AddListener(eventName, fn, onceEvent);
 }
Exemple #2
0
        private Dictionary <string, EventItem> onceEvent     = new Dictionary <string, EventItem>(); //单次事件集合

        /// <summary>
        /// 注册常驻事件
        /// </summary>
        /// <param name="eventName">事件名字</param>
        /// <param name="fn">回调方法</param>
        public void OnRegiestEvent(string eventName, EventMethod fn)
        {
            AddListener(eventName, fn, standingEvent);
        }
Exemple #3
0
        public EventMethod HandleDesktopKeyEvent(System.Windows.Forms.Keys vkCode, System.Windows.Input.Key inputKey)
        {
            EventMethod method = null;

            if (Desktop.WindowManager.CurrentActiveWindow == ActiveWindow.CHARACTERS_AND_CROWDS)
            {
                if (inputKey == Key.C && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanCloneCrowdMember)
                    {
                        method = this.CloneCrowdMember;
                    }
                }
                else if (inputKey == Key.X && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanCutCrowdMember)
                    {
                        method = this.CutCrowdMember;
                    }
                }
                else if (inputKey == Key.V && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanPasteCrowdMember)
                    {
                        method = this.PasteCrowdMember;
                    }
                }
                else if (inputKey == Key.L && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanLinkCrowdMember)
                    {
                        method = this.LinkCrowdMember;
                    }
                }
                else if (inputKey == Key.E && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanEditCharacterCrowd)
                    {
                        method = this.EditCharacterCrowd;
                    }
                }
                else if (inputKey == Key.F && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanFlattenCopyCrowd)
                    {
                        method = this.FlattenCopyCrowd;
                    }
                }
                else if (inputKey == Key.N && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanEnterFlattenNumber)
                    {
                        method = this.EnterFlattenNumber;
                    }
                }
                else if (inputKey == Key.M && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanCloneMemberships)
                    {
                        method = this.CloneMemberships;
                    }
                }
                else if ((inputKey == Key.OemPlus || inputKey == Key.Add) && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanAddCharacterCrowdMember)
                    {
                        method = this.AddCharacterCrowdMember;
                    }
                }
                else if ((inputKey == Key.OemPlus || inputKey == Key.Add) && Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift))
                {
                    method = this.AddCrowd;
                }
                else if ((inputKey == Key.OemMinus || inputKey == Key.Subtract || inputKey == Key.Delete) && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanDeleteCrowdMember)
                    {
                        method = this.DeleteCrowdMember;
                    }
                }
                else if (inputKey == Key.R && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    if (this.CanAddToRoster)
                    {
                        method = AddToRoster;
                    }
                }
                else if (inputKey == Key.S && Keyboard.Modifiers == ModifierKeys.Control)
                {
                    method = Save;
                }
            }

            return(method);
        }
Exemple #4
0
 public TimedEvent(int timeoutMilliseconds, EventMethod method, int invokeCountTotal)
 {
     TimeTotal        = timeoutMilliseconds;
     Method           = method;
     InvokeCountTotal = invokeCountTotal;
 }
Exemple #5
0
 public void AddMethodToCall(EventMethod methodToCall)
 {
     methodsToCall.Add(methodToCall);
 }
        private async Task <bool> TrackStatePrivateAsync([NotNull] EntityEntry entry, EntityState state)
        {
            if (entry.Entity is IEntity e)
            {
                Changecount++;

                var auditTran = await EnsureTransactionAuditAsync();

                EventMethod method = EventMethod.Add;
                switch (state)
                {
                case EntityState.Deleted:
                    break;

                case EntityState.Modified:

                    e.UpdatedTransaction   = auditTran;
                    e.UpdatedTransactionId = auditTran.Id;
                    method = EventMethod.Update;

                    if (null != e.DeletedTransaction)
                    {
                        method = EventMethod.Delete;
                    }

                    break;

                case EntityState.Added:
                    e.CreatedTransaction   = auditTran;
                    e.CreatedTransactionId = auditTran.Id;
                    e.UpdatedTransaction   = auditTran;
                    e.UpdatedTransactionId = auditTran.Id;
                    break;
                }

                if (AuditingEnabled)
                {
                    var    t           = FindEntityType(e);
                    string strObjectId = "";



                    //var json = System.Text.Json.JsonSerializer.Serialize(entity, EntityJsonSerializerOptions);
                    var jSettings = new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                        Formatting            = Formatting.None,
                    };
                    //jSettings.Converters.Add(new EntityConverter());

                    var eo    = new ExpandoObject();
                    var d     = (IDictionary <string, object>)eo;
                    var props = entry.CurrentValues.Properties.OrderBy(x => x.Name).ToList();
                    foreach (var property in props)
                    {
                        var name = property.Name;

                        var getter   = property.PropertyInfo.GetMethod;
                        var valueRaw = getter?.Invoke(e, null);
                        d.Add(name, valueRaw);

                        if (name == "Id")
                        {
                            strObjectId = $"{valueRaw}";
                        }
                    }

                    var vl = Newtonsoft.Json.JsonConvert.SerializeObject(d, jSettings);

                    var a = new Audit.Audit()
                    {
                        Author        = Author,
                        Action        = $"{method}",
                        DateTime      = DateTime.UtcNow,
                        EntityName    = t.entityType.Name,
                        TableName     = t.TableName,
                        Id            = $"{NewId.NextGuid():N}",
                        KeyValue      = strObjectId,
                        TransactionId = auditTran.Id,
                        Values        = Encoding.UTF8.GetBytes(vl)
                    };

                    await Audits.AddAsync(a);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }