Ejemplo n.º 1
0
        public static Hashtable LoadPdmCatalog()
        {
            Hashtable pdmHashTable = new Hashtable();

            //load Pdm Catalog File
            StreamReader sr         = new StreamReader(Program.catalogFile);
            string       headerLine = sr.ReadLine();
            string       catalogLine;

            while ((catalogLine = sr.ReadLine()) != null)
            {
                var           pdmCatalogItem = new PdmItem();
                List <string> pdmCatalog     = catalogLine.Split(',').ToList();

                pdmCatalogItem.Server   = pdmCatalog[0];
                pdmCatalogItem.FileName = pdmCatalog[2];

                if (!pdmHashTable.ContainsKey(pdmCatalogItem.FileName))
                {
                    pdmHashTable.Add(pdmCatalogItem.FileName, null);
                }
            }
            return(pdmHashTable);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            LoadConfig();

            Dictionary <string, List <PdmItem> > dictionary = new Dictionary <string, List <PdmItem> >();
            Hashtable     pdmCatalogTable    = PdmHashtable.LoadPdmCatalog();
            List <string> delimitedDataField = new List <string> {
                "FILE_SIZE,LAST_ACCESSED,ITEM,REV,SHEET,SERVER,UNC_RAW,UNC_PDF"
            };
            List <string> islandOfMisfitToys = new List <string>();
            List <string> batchLines         = new List <string>();

            //parse extract file
            StreamReader file = new StreamReader(inputFile);
            string       inputLine;

            while ((inputLine = file.ReadLine()) != null)
            {
                Console.WriteLine(inputLine);
                PdmItem pdmItem = new PdmItem();
                pdmItem.ParseExtractLine(inputLine);

                if (pdmItem.FileDateTime < recentDateTime)
                {
                    continue;
                }

                if (!pdmCatalogTable.ContainsKey(pdmItem.FileName))
                {
                    pdmItem.IsMisfit = true;
                    islandOfMisfitToys.Add("Not in catalog: " + inputLine);
                    continue;
                }

                if (pdmItem.IsMisfit)
                {
                    islandOfMisfitToys.Add("Misfit: " + inputLine);
                }
                else
                {
                    delimitedDataField.Add(pdmItem.GetOutputLine());
                }

                //logic to handle no revs
                string uID;
                if (String.IsNullOrEmpty(pdmItem.ItemRev))
                {
                    uID = pdmItem.ItemName;
                }
                else
                {
                    uID = pdmItem.ItemName + "." + pdmItem.ItemRev;
                }

                if (!dictionary.Keys.Contains(uID))
                {
                    List <PdmItem> pdmItems = new List <PdmItem>();
                    pdmItems.Add(pdmItem);
                    dictionary.Add(uID, pdmItems);
                }
                else
                {
                    dictionary[uID].Add(pdmItem);
                }
            }

            //output all misfits to file
            File.WriteAllLines(misfitToys, islandOfMisfitToys);

            //Comment this next code until misfits are reviewed and corrected in source extract file
            //generate file for Graig
            File.WriteAllLines(outputFile, delimitedDataField);

            //generate XML job tickets
            XmlTicket.JobTicketGenerator(dictionary, batchLines);
        }