Beispiel #1
0
        public static void LogDeviceOperation(this Equipment equipment, DeviceOpEnum command, User user)
        {
            var deviceCommand = new TempModel.DeviceCommand
                {
                    CommandDateTime = DateTime.Now,
                    DeviceId = equipment.SerialNumber,
                    DeviceStatusId = DBCache.Statuses.First(s => s.StatusName == equipment.Status).StatusId,
                    LocationId = equipment.LocationId,
                    Operation = command.ToString("G"),
                    SubscriberId = equipment.AssociatedSubscriberId,
                    TransactionTypeID = 6
                };

            try
            {
                using (var db = DBContextFactory.CreateContext())
                {
                    deviceCommand.EntityId = db.UniqueIds.First(u => u.UniqueIdValue == user.Name).EntityId;
                    db.DeviceCommands.AddObject(deviceCommand);
                    db.SaveChanges();
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("There was a problem logging the action to the database", ex);
            }
        }
Beispiel #2
0
 public bool PerformOperation(DeviceOpEnum deviceOp)
 {
     return MagnumApi.Actions.PerformDeviceOperation(this, deviceOp);
 }