public void OnEntityUpdate(IUpdatingEntry <ProductInstance, InventoryContext> entry)
        {
            Log log = new Log(this._userService.CurrentUser.UserName, entry.Entity.GetType().ToString(), entry.Entity.Name, InventoryOperations.UPDATE.GetDescription(), DateTime.UtcNow);

            log.SessionId = this._userService.CurrentSession.Id;
            entry.Context.Logs.Add(log);
        }
示例#2
0
        public async void ServerUpdated(IUpdatingEntry <Server> server)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var authService = scope.ServiceProvider.GetService <IAuthorizationService>();

                //Dictionary<string, bool[]> connections = new Dictionary<string, bool[]>();
                var connections = (await Task.WhenAll(
                                       _hubConnectionManager.GetConnectedUsers <ServersHub>().Select(async connection =>
                {
                    return(new KeyValuePair <string, bool[]>(connection.Key,
                                                             (await Task.WhenAll(
                                                                  authService.AuthorizeAsync(connection.Value, server.Original, "ServerPolicy"),
                                                                  authService.AuthorizeAsync(connection.Value, server.Entity, "ServerPolicy")
                                                                  )).Select <AuthorizationResult, bool>(a => a.Succeeded).ToArray()
                                                             ));
                })
                                       )).ToDictionary(r => r.Key, r => r.Value);

                var allowedConnections    = connections.Where(v => v.Value[0] && v.Value[1]).Select(v => v.Key).ToArray();
                var disallowedConnections = connections.Where(v => v.Value[0] && !v.Value[1]).Select(v => v.Key).ToArray();
                var newConnections        = connections.Where(v => !v.Value[0] && v.Value[1]).Select(v => v.Key).ToArray();


                await Task.WhenAll(
                    NotifyServerUpdated(server.Entity, allowedConnections),
                    NotifyServerDeleted(server.Entity, disallowedConnections),
                    NotifyServerInserted(server.Entity, disallowedConnections)
                    );
            }
        }
示例#3
0
        public static void OnUpdating(IUpdatingEntry entry)
        {
            var entity = (BaseModel)entry.Entity;
            var now    = DateTime.Now;

            SetModified(entity, now);
        }
示例#4
0
        public static async void WhileUpdatingAsync(IUpdatingEntry <SysMenu, DbContext> entry)
        {
            using (var service = AspectCoreContainer.Resolve <ISysMenuRepository>())
            {
                var parentMenu = await service.GetSingleAsync(entry.Entity.ParentId);

                entry.Entity.SortIndex = entry.Entity.Id;
                entry.Entity.MenuPath  = (parentMenu?.MenuPath ?? "0") + "," + entry.Entity.Id;
            }
        }
示例#5
0
 public static void WhileUpdating(IUpdatingEntry <SysMenu, DbContext> entry)
 {
     using (var service = AspectCoreContainer.Resolve <ISysMenuRepository>())
     {
         var parentMenu = service.GetSingle(entry.Entity.ParentId);
         if (string.IsNullOrEmpty(parentMenu?.MenuPath))
         {
             entry.Entity.MenuPath = entry.Entity.Id;
         }
         else
         {
             entry.Entity.MenuPath = parentMenu.MenuPath + "," + entry.Entity.Id;
         }
     }
 }
 public void OnEntityUpdate(IUpdatingEntry <PartInstance, InventoryContext> entry) => throw new NotImplementedException();
 public void OnEntityUpdate(IUpdatingEntry <Attachment, InventoryContext> entry) => throw new NotImplementedException();
 public void OnEntityUpdate(IUpdatingEntry <Manufacturer, InventoryContext> entry) => throw new NotImplementedException();
示例#9
0
 public void OnEntityUpdate(IUpdatingEntry <Lot, InventoryContext> entry)
 {
     Log log = new Log(this._userService.CurrentUser.UserName, entry.Entity.GetType().ToString(),
                       "(" + entry.Entity.LotNumber + "," + entry.Entity.SupplierPoNumber + ")",
                       InventoryOperations.UPDATE.GetDescription(), DateTime.UtcNow);
 }
示例#10
0
 public void OnEntityUpdate(IUpdatingEntry <Distributor, InventoryContext> entry) => throw new NotImplementedException();
示例#11
0
 public void OnUpdate(IUpdatingEntry <Attachment, InventoryContext> entry)
 {
 }
示例#12
0
 public void OnUpdate(IUpdatingEntry <Part, InventoryContext> entry)
 {
 }