/// <summary>
		/// Gets the first importer that match the parameter criteria.
		/// </summary>
		/// <param name="documentType">Type of the document.</param>
		/// <param name="loadPath">The save path.</param>
		/// <returns></returns>
		public IImporter GetFirstImporter(DocumentTypes documentType, string loadPath)
		{
			string targetExtension			= ExportHandler.GetExtension(loadPath);

			foreach(IImporter iImporter in this.LoadImporter())
			{
				foreach(DocumentSupportInfo documentSupportInfo in iImporter.DocumentSupportInfos)
					if (documentSupportInfo.Extension.ToLower().Equals(targetExtension.ToLower()))
						if (documentSupportInfo.DocumentType == documentType)
							return iImporter;
			}

			throw new AODLException("No importer available for type "+documentType.ToString()+" and extension "+targetExtension);
		}
        public string UploadFile(byte[] fileBytes, DocumentTypes type, string extention)
        {
            string folder = Path.GetFullPath(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "/DocumentStore/" + type.ToString());
            string fileName = System.Guid.NewGuid().ToString() + "." + extention;
            log.Debug("file " + fileName + " intends to save at " + folder);

            if (!Directory.Exists(folder))
                Directory.CreateDirectory(folder);

            using (MemoryStream mstream = new MemoryStream(fileBytes))
                using (FileStream fstream = new FileStream(folder + "/" + fileName, FileMode.Create))
                    mstream.WriteTo(fstream);

            log.Info("file " + fileName + " saved successfully");
            return fileName;
        }
Exemple #3
0
        /// <summary>
        /// Gets the first importer that match the parameter criteria.
        /// </summary>
        /// <param name="documentType">Type of the document.</param>
        /// <param name="loadPath">The save path.</param>
        /// <returns></returns>
        public IImporter GetFirstImporter(DocumentTypes documentType, string loadPath)
        {
            string targetExtension			= ExportHandler.GetExtension(loadPath);

            foreach(IImporter iImporter in this.LoadImporter())
            {
                foreach(DocumentSupportInfo documentSupportInfo in iImporter.DocumentSupportInfos)
                    if(documentSupportInfo.Extension.ToLower().Equals(targetExtension.ToLower()))
                        if(documentSupportInfo.DocumentType == documentType)
                            return iImporter;
            }

            AODLException exception		= new AODLException("No importer available for type "+documentType.ToString()+" and extension "+targetExtension);
            exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
            throw exception;
        }
Exemple #4
0
        /// <summary>
        /// Gets the first exporter that match the parameter criteria.
        /// </summary>
        /// <param name="documentType">Type of the document.</param>
        /// <param name="savePath">The save path.</param>
        /// <returns></returns>
        public IExporter GetFirstExporter(DocumentTypes documentType, string savePath)
        {
            string targetExtension = GetExtension(savePath);

            foreach (IExporter iExporter in this.LoadExporter())
            {
                foreach (DocumentSupportInfo documentSupportInfo in iExporter.DocumentSupportInfos)
                {
                    if (documentSupportInfo.Extension.ToLower().Equals(targetExtension.ToLower()))
                    {
                        if (documentSupportInfo.DocumentType == documentType)
                        {
                            return(iExporter);
                        }
                    }
                }
            }

            throw new AODLException("No exporter available for type " + documentType.ToString() + " and extension " + targetExtension);
        }
        /// <summary>
        /// Gets the first importer that match the parameter criteria.
        /// </summary>
        /// <param name="documentType">Type of the document.</param>
        /// <param name="loadPath">The save path.</param>
        /// <returns></returns>
        public IImporter GetFirstImporter(DocumentTypes documentType, string loadPath)
        {
            string targetExtension = ExportHandler.GetExtension(loadPath);

            foreach (IImporter iImporter in this.LoadImporter())
            {
                foreach (DocumentSupportInfo documentSupportInfo in iImporter.DocumentSupportInfos)
                {
                    if (documentSupportInfo.Extension.ToLower().Equals(targetExtension.ToLower()))
                    {
                        if (documentSupportInfo.DocumentType == documentType)
                        {
                            return(iImporter);
                        }
                    }
                }
            }

            throw new AODLException("No importer available for type " + documentType.ToString() + " and extension " + targetExtension);
        }
 /// <summary>
 /// Get document by type
 /// </summary>
 /// <param name="documentType"></param>
 /// <returns></returns>
 public Document GetDocumentByType(DocumentTypes documentType)
 {
     return GetDocumentByType(documentType.ToString());
 }
Exemple #7
0
        /// <summary>
        /// Gets the first importer that match the parameter criteria.
        /// </summary>
        /// <param name="documentType">Type of the document.</param>
        /// <param name="loadPath">The save path.</param>
        /// <returns></returns>
        public IImporter GetFirstImporter(DocumentTypes documentType, string loadPath, string tmpPath)
        {
            string targetExtension = ExportHandler.GetExtension(loadPath);

            foreach (IImporter iImporter in this.LoadImporter())
            {
                foreach (DocumentSupportInfo documentSupportInfo in iImporter.DocumentSupportInfos)
                {
                    if (documentSupportInfo.Extension.ToLower().Equals(targetExtension.ToLower()))
                    {
                        if (documentSupportInfo.DocumentType == documentType)
                        {
                            return(iImporter);
                        }
                    }
                }
            }

            AODLException exception = new AODLException("No importer available for type " + documentType.ToString() + " and extension " + targetExtension);

            exception.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
            throw exception;
        }
        /// <summary>
        /// Get document by type
        /// </summary>
        /// <param name="documentType"></param>
        /// <returns></returns>
        public Document GetDocumentByType(DocumentTypes documentType)
        {
            getDocumentByType getDocumentByType = new getDocumentByType()
            {
                type = documentType.ToString(),
                service = _Scenario.Service,
                transactionId = TransactionId
            };

            getDocumentByTypeResponse getDocumentByTypeResponse = _DocumentPortCli.getDocumentByType(getDocumentByType);
            Document doc = getDocumentByTypeResponse.document;

            return doc;
        }