示例#1
0
        public NewCameraKey GenerateUniqueCameraKey()
        {
            int count = 0;

            while (count < 5)
            {
                count++;
                // Camera Key must be exactly 12 characters.
                string randomCameraKey = StringGenerator.GenerateRandomString(12, 12);

                // Ensure Key does not exist in database (return value is -1).
                if (_dbQueryService.GetCameraIdFromKey(randomCameraKey) == -1)
                {
                    // Persist new camera key to database.

                    DatabaseCamera emptyCamera = new DatabaseCamera();
                    emptyCamera.CameraKey = randomCameraKey;
                    bool success = _dbQueryService.PersistNewCamera(emptyCamera);

                    if (success)
                    {
                        return(new NewCameraKey(randomCameraKey));
                    }

                    return(null);
                }
            }

            return(null);
        }
示例#2
0
        public bool SaveNewCamera(CameraDetails cameraDetails)
        {
            DatabaseCamera camera = new DatabaseCamera(cameraDetails);

            return(_dbQueryService.PersistNewCamera(camera));
        }