Beispiel #1
0
		public static Workshare.Policy.Engine.Interfaces.IFile GetIFile(Workshare.PolicyContent.Attachment origAttachment)
		{
			if (null == origAttachment)
				throw new ArgumentException("origAttachment");

			using( MemoryStream memStr = new MemoryStream(origAttachment.Content))
			{
				File fileOut = new File(memStr, origAttachment.Name);
				fileOut.ContentId = origAttachment.Id;
				fileOut.ContentItemIndex = int.Parse(origAttachment.Index);

				return fileOut;
			}
		}
		public string Execute(IActionData3 inputData, ActionPropertySet aProperties)
		{
			Stream inputStream = null;
			Stream outputStream = null;
			try
			{
				using (Workshare.Policy.Engine.Interfaces.IFile inputFile = new Workshare.Policy.Engine.File(inputData.FileName, Path.GetFileName(inputData.FileName)))
				{
					inputStream = inputFile.Contents;
					outputStream = ExecuteStream(inputStream, inputData.Properties, aProperties);
					if (null != inputStream)
					{
						inputStream.Close();
					}
				}
				
				using (FileStream file = new FileStream(inputData.FileName, FileMode.Create, FileAccess.Write, FileShare.Read))
				{
					StreamUtils.CopyStreamToStream(outputStream, file);
					if (null != outputStream)
					{
						outputStream.Close();
					}
				}

				return inputData.FileName;
			}
			finally
			{
				if (null != inputStream)
				{
					inputStream.Close();
				}
				
				if (null != outputStream)
				{
					outputStream.Close();
				}
			}
		}
 private bool IsEncrypted(string filename)
 {
     Workshare.Policy.Engine.File file = new Workshare.Policy.Engine.File(filename, filename);
     return !file.CanOpenContent;
 }