Exemple #1
0
        void HandleDevice(IDbConnection Db, ulong deviceId, GXEventsItem e)
        {
            ulong mask = (ulong)((int)e.Target << 16 | (int)e.Action);

            //Find is anyone interested from this device event.
            lock (Db)
            {
                foreach (GXSession it in Sessions)
                {
                    foreach (GXEvent e1 in it.NotifyClients)
                    {
                        if (e1.UserID != 0 && (mask & e1.Mask) != 0)
                        {
                            //Notify only super admin and if user has access to this device.
                            if (e1.SuperAdmin || GXDeviceService.CanUserAccessDevice(Db, e1.UserID, deviceId))
                            {
                                e1.Rows.Add(e);
                                it.Received.Set();
                            }
                        }
                        else if (e1.DataCollectorGuid != Guid.Empty && GXDataCollectorService.CanDataCollectorsAccessDevice(Db, deviceId, e1.DataCollectorGuid))
                        {
                            e1.Rows.Add(e);
                            it.Received.Set();
                        }
                    }
                }
            }
        }
Exemple #2
0
        void HandleDeviceErrors(IDbConnection Db, GXAmiDeviceError error, GXEventsItem e)
        {
            ulong mask = (ulong)((int)e.Target << 16 | (int)e.Action);

            //Find is anyone interested from this data collector event.
            lock (Db)
            {
                foreach (GXSession it in Sessions)
                {
                    foreach (GXEvent e1 in it.NotifyClients)
                    {
                        if (e1.UserID != 0 && (mask & e1.Mask) != 0)
                        {
                            //Notify only super admin or if user has access to this data collector.
                            if (e1.SuperAdmin || GXDeviceService.CanUserAccessDevice(Db, e1.UserID, error.TargetDeviceID.Value))
                            {
                                e1.Rows.Add(e);
                                it.Received.Set();
                            }
                        }
                    }
                }
            }
        }