Example #1
0
        /// <summary>
        /// Uploads the specified <paramref name="content"/> and attaches it for check in to the specified <paramref name="dokumentversjon"/>.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="dokumentversjon">The document object.</param>
        /// <param name="content">The content.</param>
        /// <param name="fileName">Name of the file.</param>
        public static async Task UploadAsync(this IAsyncDocumentManager instance, Dokumentversjon dokumentversjon, Stream content, string fileName)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            if (dokumentversjon == null)
            {
                throw new ArgumentNullException("dokumentversjon");
            }

            var identifier = await instance.UploadAsync(content, fileName, null);

            dokumentversjon.Dokumentreferanse = identifier;
        }
        /// <summary>
        /// Uploads the specified <paramref name="content"/> and attaches it for check in to the specified <paramref name="documentObject"/>.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="documentObject">The document object.</param>
        /// <param name="content">The content.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="storageIdentifier">The storage identifier.</param>
        public static async System.Threading.Tasks.Task UploadAsync(this IAsyncDocumentManager instance, DocumentObject documentObject, Stream content, string fileName, string storageIdentifier = "ObjectModelService")
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            if (documentObject == null)
            {
                throw new ArgumentNullException("documentObject");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            if (string.IsNullOrEmpty(storageIdentifier))
            {
                throw new ArgumentNullException("storageIdentifier");
            }

            if (string.IsNullOrEmpty(documentObject.VariantFormatId))
            {
                throw new ArgumentException("The DocumentObject.VariantFormatId cannot be <null> or empty.");
            }

            if (string.IsNullOrEmpty(documentObject.FileformatId))
            {
                var fileFormatId = Path.GetExtension(fileName);
                if (string.IsNullOrEmpty(fileFormatId))
                {
                    fileFormatId = "TXT";
                }

                documentObject.FileformatId = fileFormatId.Trim('.').ToUpperInvariant();
            }

            var identifier = await instance.UploadAsync(content, fileName, storageIdentifier);

            documentObject.FilePath = identifier;
        }
Example #3
0
        /// <summary>
        /// Uploads the specified <paramref name="content"/> and attaches it for check in to the specified <paramref name="dokumentversjon"/>.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <param name="dokumentversjon">The document object.</param>
        /// <param name="content">The content.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="storageIdentifier"></param>
        public static async Task UploadAsync(this IAsyncDocumentManager instance, Dokumentversjon dokumentversjon, Stream content, string fileName, string storageIdentifier = "ObjectModelService")
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            if (dokumentversjon == null)
            {
                throw new ArgumentNullException("dokumentversjon");
            }

            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }

            if (string.IsNullOrEmpty(storageIdentifier))
            {
                throw new ArgumentNullException("storageIdentifier");
            }

            if (string.IsNullOrEmpty(dokumentversjon.VariantId))
            {
                throw new InvalidOperationException("The Documentversjon.VariantId cannot be <null> or empty.");
            }

            if (string.IsNullOrEmpty(dokumentversjon.LagringsformatId))
            {
                var fileFormatId = Path.GetExtension(fileName);
                if (string.IsNullOrEmpty(fileFormatId))
                {
                    fileFormatId = "TXT";
                }

                dokumentversjon.LagringsformatId = fileFormatId.Trim('.').ToUpperInvariant();
            }

            var identifier = await instance.UploadAsync(content, fileName, storageIdentifier);

            dokumentversjon.Dokumentreferanse = identifier;
        }