예제 #1
0
        public void PropertyTypeTest()
        {
            using (PropertySets propertySets = new PropertySets(s_testFile, false))
            {
                Console.WriteLine("Before:");
                DumpPropertySets(propertySets);

                if (propertySets.Contains(PropertySetIds.UserDefinedProperties))
                {
                    /* Clear all custom properties */
                    propertySets[PropertySetIds.UserDefinedProperties].Delete();
                }

                PropertySet custom = propertySets.Add(PropertySetIds.UserDefinedProperties, false);

                custom.Add("TestString", "Hello");
                custom.Add("TestDate", DateTime.Now);
                custom.Add("TestDouble", 1.0d);
                custom.Add("TestBoolean", false);

                Console.WriteLine();
                Console.WriteLine("After:");
                DumpPropertySets(propertySets);
            }
        }
예제 #2
0
        public void ModifyDeleteAddPropertyTest()
        {
            using (PropertySets propertySets = new PropertySets(s_testFile, false))
            {
                Console.WriteLine("Before:");
                DumpPropertySets(propertySets);

                PropertySet projectInfo = null;
                if (propertySets.Contains(PropertySetIds.ProjectInformation))
                {
                    projectInfo = propertySets[PropertySetIds.ProjectInformation];
                }
                else
                {
                    projectInfo = propertySets.Add(PropertySetIds.ProjectInformation, false);
                }

                Property docNumber = null;
                if (projectInfo.Contains(ProjectInfoIds.DocumentNumber))
                {
                    docNumber = projectInfo[ProjectInfoIds.DocumentNumber];
                }
                else
                {
                    docNumber = projectInfo.Add(ProjectInfoIds.DocumentNumber, string.Empty);
                }
                docNumber.Value = "Testing";
                Console.WriteLine();
                Console.WriteLine("After modification:");
                DumpPropertySets(propertySets);

                docNumber.Delete();
                Console.WriteLine();
                Console.WriteLine("After deletion:");
                DumpPropertySets(propertySets);

                docNumber = projectInfo.Add(ProjectInfoIds.DocumentNumber, "New property");
                Console.WriteLine();
                Console.WriteLine("After adding:");
                DumpPropertySets(propertySets);
            }
        }
예제 #3
0
        public void DeleteAddPropertySetTest()
        {
            File.Copy(s_testFile, s_testFile + ".tmp");
            using (PropertySets propertySets = new PropertySets(s_testFile + ".tmp", false))
            {
                Console.WriteLine("Before deletion:");
                DumpPropertySets(propertySets);

                if (propertySets.Contains(PropertySetIds.SummaryInformation))
                {
                    propertySets[PropertySetIds.SummaryInformation].Delete();
                }

                PropertySet summaryInfo = propertySets.Add(PropertySetIds.SummaryInformation, false);

                summaryInfo.Add(SummaryInfoIds.Author, "Me");
                summaryInfo.Add(SummaryInfoIds.Created, DateTime.Now);

                Console.WriteLine();
                Console.WriteLine("After adding:");
                DumpPropertySets(propertySets);
            }
            File.Delete(s_testFile + ".tmp");
        }
예제 #4
0
		static void Main(string[] args)
		{
			DrawProgramInfo();

			Console.Write("Input folder path: (empty for current folder)");
			Path = Console.ReadLine();

			StartWatch();

			if (string.IsNullOrWhiteSpace(Path))
				Path = System.Environment.CurrentDirectory;

			Files = Directory.GetFiles(Path, "*.*", SearchOption.AllDirectories);

			Console.WriteLine($"Number of files: {Files.Length}");

			foreach (var file in Files)
			{
				string line = $"file: {file}:";
				result.Add(line);

				if (!File.Exists(file))
				{
					err_file_not_found.Add($"File NOT EXIST. ({file})."); 
					continue;
				}

				PropertySets psets = new PropertySets(file, true);
				PropertySet psi = null;

				if (psets.Contains(PropertySetIds.UserDefinedProperties))
				{
					if ((psi = psets[PropertySetIds.UserDefinedProperties]) != null)
					{ ReadProp(file, psi); }
				}
				if (psets.Contains(PropertySetIds.DocumentSummaryInformation))
				{
					if ((psi = psets[PropertySetIds.DocumentSummaryInformation]) != null)
					{ ReadProp(file, psi); }
				}
				if (psets.Contains(PropertySetIds.ProjectInformation))
				{
					if ((psi = psets[PropertySetIds.ProjectInformation]) != null)
					{ ReadProp(file, psi); }
				}
				if (psets.Contains(PropertySetIds.SummaryInformation))
				{
					if ((psi = psets[PropertySetIds.SummaryInformation]) != null)
					{ ReadProp(file, psi); }
				}
				if (psets.Contains(PropertySetIds.ExtendedSummaryInformation))
				{
					if ((psi = psets[PropertySetIds.ExtendedSummaryInformation]) != null)
					{ ReadProp(file, psi); }
				}

				result.Add("------------------------------------------------------");
				result.Add(string.Empty);
			}

			PauseWatch();

			Console.Write("\nInput folder with links files: ");
			Path = Console.ReadLine();

			UnpauseWatch();

			if (string.IsNullOrWhiteSpace(Path))
				Console.WriteLine("Null path. Continue...");
			else
				ReadDummyFiles(Path);

			
			DrawHeader(err_too_long_props, "TOO LONG PROPERTIES");
			DrawHeader(err_file_not_found, "FILES NOT FOUND");
			DrawHeader(err_too_long_links, "TOO LONG LINKS");

			TimeSpan time = StopWatch();

			string output = $"{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}_PropsInfo.txt";
			File.AppendAllLines(output, err_too_long_props, Encoding.UTF8);
			File.AppendAllLines(output, err_file_not_found, Encoding.UTF8);
			File.AppendAllLines(output, err_too_long_links, Encoding.UTF8);
			File.AppendAllLines(output, result, Encoding.UTF8);

			Console.WriteLine($"\nLogfile '{output}' was created.");
			Console.WriteLine($"end program (duration: {time.TotalMilliseconds} ms, {time.TotalSeconds} s, {time.TotalMinutes} m)");
			Console.ReadLine();
		}
예제 #5
0
        static void Main(string[] args)
        {
            DrawProgramInfo();

            Console.Write("Input folder path: (empty for current folder)");
            Path = Console.ReadLine();

            StartWatch();

            if (string.IsNullOrWhiteSpace(Path))
            {
                Path = System.Environment.CurrentDirectory;
            }

            Files = Directory.GetFiles(Path, "*.*", SearchOption.AllDirectories);

            Console.WriteLine($"Number of files: {Files.Length}");

            foreach (var file in Files)
            {
                string line = $"file: {file}:";
                result.Add(line);

                if (!File.Exists(file))
                {
                    err_file_not_found.Add($"File NOT EXIST. ({file}).");
                    continue;
                }

                PropertySets psets = new PropertySets(file, true);
                PropertySet  psi   = null;

                if (psets.Contains(PropertySetIds.UserDefinedProperties))
                {
                    if ((psi = psets[PropertySetIds.UserDefinedProperties]) != null)
                    {
                        ReadProp(file, psi);
                    }
                }
                if (psets.Contains(PropertySetIds.DocumentSummaryInformation))
                {
                    if ((psi = psets[PropertySetIds.DocumentSummaryInformation]) != null)
                    {
                        ReadProp(file, psi);
                    }
                }
                if (psets.Contains(PropertySetIds.ProjectInformation))
                {
                    if ((psi = psets[PropertySetIds.ProjectInformation]) != null)
                    {
                        ReadProp(file, psi);
                    }
                }
                if (psets.Contains(PropertySetIds.SummaryInformation))
                {
                    if ((psi = psets[PropertySetIds.SummaryInformation]) != null)
                    {
                        ReadProp(file, psi);
                    }
                }
                if (psets.Contains(PropertySetIds.ExtendedSummaryInformation))
                {
                    if ((psi = psets[PropertySetIds.ExtendedSummaryInformation]) != null)
                    {
                        ReadProp(file, psi);
                    }
                }

                result.Add("------------------------------------------------------");
                result.Add(string.Empty);
            }

            PauseWatch();

            Console.Write("\nInput folder with links files: ");
            Path = Console.ReadLine();

            UnpauseWatch();

            if (string.IsNullOrWhiteSpace(Path))
            {
                Console.WriteLine("Null path. Continue...");
            }
            else
            {
                ReadDummyFiles(Path);
            }


            DrawHeader(err_too_long_props, "TOO LONG PROPERTIES");
            DrawHeader(err_file_not_found, "FILES NOT FOUND");
            DrawHeader(err_too_long_links, "TOO LONG LINKS");

            TimeSpan time = StopWatch();

            string output = $"{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}_PropsInfo.txt";

            File.AppendAllLines(output, err_too_long_props, Encoding.UTF8);
            File.AppendAllLines(output, err_file_not_found, Encoding.UTF8);
            File.AppendAllLines(output, err_too_long_links, Encoding.UTF8);
            File.AppendAllLines(output, result, Encoding.UTF8);

            Console.WriteLine($"\nLogfile '{output}' was created.");
            Console.WriteLine($"end program (duration: {time.TotalMilliseconds} ms, {time.TotalSeconds} s, {time.TotalMinutes} m)");
            Console.ReadLine();
        }