Ejemplo n.º 1
0
        /// <summary>
        /// Gets the generated identifier for the input.
        /// </summary>
        /// <param name="jobID">The identifier of the job the input was saved
        /// against.</param>
        /// <param name="originalIdentifier">The original identifier given to the
        /// input.</param>
        /// <returns>The unique identifier for the input provided by the
        /// persister.</returns>
        public Guid GetPersistedIdentifier(Guid jobID, object originalIdentifier)
        {
            PersistedJobIdentifiers id = _getOrCreateIDSet(jobID);
            Guid?theID = id.GetIdentifier(originalIdentifier);

            if (theID.HasValue == false)
            {
                throw new ArgumentException("Result not persisted with identifier");
            }

            return(theID.Value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes a result from a particular job with the associated identifier
        /// from the storage.
        /// </summary>
        /// <param name="jobID">The unique identifier of the job to delete
        /// the results for.</param>
        /// <param name="identifier">The identifier given to the input to be
        /// deleted.</param>
        /// <returns><c>true</c> if the result from the job was deleted
        /// successfully; <c>false</c> otherwise.</returns>
        public bool Delete(Guid jobID, object identifier)
        {
            PersistedJobIdentifiers id = _getOrCreateIDSet(jobID);
            Guid?theID = id.GetIdentifier(identifier);

            if (theID.HasValue == false)
            {
                return(false);
            }

            string path = string.Format(@"{0}/{{{1}}}/{2}.png", TargetDirectory, jobID, theID.Value.ToString());

            if (File.Exists(path))
            {
                File.Delete(path);
                id.RemoveOriginalIdentifier(identifier);
                return(true);
            }
            else
            {
                return(false);
            }
        }