Exemple #1
0
			} // proc Dispose

			public IOdetteFileWriter CreateInFile(IOdetteFile file, string userData)
			{
				var incomingFile = String.Format("In coming file {0} ", OdetteFileMutable.FormatFileName(file, userData));
				if (!service.IsInFileAllowed(file))
				{
					log.Info(incomingFile + "ignored");
					return null;
				}

				var fi = service.CreateInFileName(file, OdetteInFileState.Pending);

				// check if the file exists
				if (File.Exists(Path.ChangeExtension(fi.FullName, GetInFileExtention(OdetteInFileState.Received))) ||
					File.Exists(Path.ChangeExtension(fi.FullName, GetInFileExtention(OdetteInFileState.PendingEndToEnd))) ||
					File.Exists(Path.ChangeExtension(fi.FullName, GetInFileExtention(OdetteInFileState.Finished))))
					throw new OdetteFileServiceException(OdetteAnswerReason.DuplicateFile, "File already exists.", false);

				// open the file to write
				var fileItem = new FileItem(service, fi, file, true);
				fileItem.Log(log, incomingFile + "accepted");
				try
				{
					return fileItem.OpenWrite();
				}
				catch (IOException e)
				{
					throw new OdetteFileServiceException(OdetteAnswerReason.UnspecifiedReason, e.Message, false, e);
				}
			} // func CreateInFile