public void Test_02_CreateContainerFromUroRemovableDeviceRootFolder()
        {
            IContainer container;
            PolicyResponseObject pro = ProHelper.GeneratePRO(null, PolicyType.ClientRemovableMedia, out container);

            Assert.IsNotNull(pro);
            Assert.IsNotNull(pro.ContentCollection);
            Assert.IsNotNull(container);

            string[] files = new string[] 
            {
                Path.Combine(TEST_FOLDER, "TestProfanity.doc"),
                Path.Combine(TEST_FOLDER, "small.xls"),
                Path.Combine(TEST_FOLDER, "TestDoc.ppt")
            };

            TestHelpers.AddFilesToRemovableDeviceRoot(pro.UniversalRequestObject, files);

            ContainerBuilder containerBuilder = new ContainerBuilder(pro);
            container = containerBuilder.CreateContainerFromUro();

            Assert.AreEqual(FileType.Selection, (container as File).FileType);

            Assert.AreEqual(1, container.Files.Count);
            Assert.AreEqual(3, container.Files[0].Files.Count);
            Assert.AreEqual(4, pro.ContentCollection.Count);

            ContentItem contentItemParent = pro.ContentCollection[0] as ContentItem;
            Assert.AreEqual(FileType.Folder, contentItemParent.File.FileType);
            Assert.IsNull(contentItemParent.Parent);

            ContentItem contentItem = pro.ContentCollection[1] as ContentItem;
            Assert.AreEqual(FileType.WordDocument, contentItem.File.FileType);
            Assert.IsNotNull(contentItem.Parent);
            Assert.AreEqual(contentItem.Parent.Name, contentItemParent.Name);

            contentItem = pro.ContentCollection[2] as ContentItem;
            Assert.AreEqual(FileType.ExcelSheet, contentItem.File.FileType);
            Assert.IsNotNull(contentItem.Parent);
            Assert.AreEqual(contentItem.Parent.Name, contentItemParent.Name);

            contentItem = pro.ContentCollection[3] as ContentItem;
            Assert.AreEqual(FileType.PowerPoint, contentItem.File.FileType);
            Assert.IsNotNull(contentItem.Parent);
            Assert.AreEqual(contentItem.Parent.Name, contentItemParent.Name);
        }
Exemple #2
0
        public static PolicyResponseObject GeneratePRO(string[] files, PolicyType policyType, out IContainer container)
        {
            PolicyResponseObject pro = new PolicyResponseObject();
            pro.RunAt = RunAt.Client;

            UniversalRequestObject uro = new UniversalRequestObject();
            uro.PolicyType = policyType;
            uro.DataTimeStamp = DateTime.Now;
            GenerateURORoutingDetails(uro, policyType);
            GenerateUROProperties(uro, policyType);
            GenerateUROAttachmentData(uro, files);
            pro.UniversalRequestObject = uro;

            ContainerBuilder containerBuilder = new ContainerBuilder(pro);
            container = containerBuilder.CreateContainerFromUro();

            return pro;
        }
        public void Test_07_CreateContainerFromNetMonChannelAsHTTPType()
        {
            string[] attachments = new string[] 
            {
                Path.Combine(TEST_FOLDER, "TestProfanity.doc"),
                Path.Combine(TEST_FOLDER, "small.xls"),
                Path.Combine(TEST_FOLDER, "TestDoc.ppt")
            };


            PolicyResponseObject pro = new PolicyResponseObject();
            pro.RunAt = RunAt.Client;

            UniversalRequestObject uro = new UniversalRequestObject();
            uro.PolicyType = PolicyType.NetMon;
            uro.DataTimeStamp = DateTime.Now;

            uro.Properties[HttpRequestPropertyKeys.Description] = "stuff";
            uro.Properties["tag1"] = "This is a test";
            uro.Properties["tag2"] = "This is a test";

            ProHelper.GenerateUROAttachmentData(uro, attachments);
            pro.UniversalRequestObject = uro;

            ContainerBuilder containerBuilder = new ContainerBuilder(pro);
            IContainer container = containerBuilder.CreateContainerFromUro();

            Assert.IsTrue(container.DisplayName == "HTTP Content");
        }
        public void Test_06_CreateContainerFromNetMonChannelAsEmailType()
        {
            string[] attachments = new string[] 
            {
                Path.Combine(TEST_FOLDER, "TestProfanity.doc"),
                Path.Combine(TEST_FOLDER, "small.xls"),
                Path.Combine(TEST_FOLDER, "TestDoc.ppt")
            };


            PolicyResponseObject pro = new PolicyResponseObject();
            pro.RunAt = RunAt.Client;

            UniversalRequestObject uro = new UniversalRequestObject();
            uro.PolicyType = PolicyType.NetMon;
            uro.DataTimeStamp = DateTime.Now;
            ProHelper.GenerateUROProperties(uro, PolicyType.NetMon);
            ProHelper.GenerateUROAttachmentData(uro, attachments);
            pro.UniversalRequestObject = uro;

            ContainerBuilder containerBuilder = new ContainerBuilder(pro);
            IContainer container = containerBuilder.CreateContainerFromUro();

            Assert.IsTrue(container.DisplayName == "message subject/body");
        }
		internal static void AddFiles(PolicyResponseObject pro, out IContainer container)
		{
			if ((null == pro) || (null == pro.UniversalRequestObject) || (null == pro.UniversalRequestObject.Attachments))
			{
				container = null;
				return;
			}

			ContainerBuilder containerBuilder = new ContainerBuilder(pro);
			container = containerBuilder.CreateContainerFromUro() as IContainer;
		}
Exemple #6
0
        private void InitialisePro(PolicyResponseObject pro, IUniversalRequestObject uro)
        {
            pro.RunAt = m_runAt;
            pro.UniversalRequestObject = uro;
            pro.PolicyType = uro.PolicyType;
            pro.ChannelDetail = uro.Properties.ContainsKey("RequestChannel") ? uro.Properties["RequestChannel"] : "";
            RoutingInfoHelper.PopulateRoutingInfo(pro);

            ContainerBuilder containerBuilder = new ContainerBuilder(pro);
            containerBuilder.CreateContainerFromUro();
        }
		private static IContainer HandleContent(PolicyResponseObject proOut, Response responseIn)
		{
			ContainerBuilder containerBuilder = new ContainerBuilder(proOut);
			IContainer retVal = containerBuilder.CreateContainerFromUro();
			

			AssignContentIds(responseIn, proOut.ContentCollection);
			
			//We now have a populated content collection, with the correct container structure.
			//Next, associate policy with the new content collection.

			Dictionary<string, Workshare.PolicyContent.ContentItem> contentItemLookup = new Dictionary<string, Workshare.PolicyContent.ContentItem>();
			foreach (Workshare.PolicyContent.ContentItem item in responseIn.Contents)
			{
				contentItemLookup[item.Id] = item;

				//This just gives us an indexer into the Response content items.  
			}

			foreach (IContentItem item in proOut.ContentCollection)
			{
				Workshare.Policy.Engine.ContentItem contentItem =
					item as Workshare.Policy.Engine.ContentItem;

				Debug.Assert(contentItemLookup.ContainsKey(contentItem.File.ContentId));

				PolicySet[] policySets = contentItemLookup[contentItem.File.ContentId].PolicySets;

				foreach (PolicySet set in policySets)
				{
					item.PolicySetCollection.Add( PolicySetAdaptor.GetIPolicySetResponse(set) );
				}
			}

			return retVal;
		}