static void runHash() { __BACKUP__FileHash newHash = new __BACKUP__FileHash(); string pa = System.Reflection.Assembly.GetExecutingAssembly().Location; var dd = System.IO.Path.GetDirectoryName(pa); exe_root = dd.ToString(); string ppt = exe_root + @"\" + @"d5000.pdf"; //Console.WriteLine(ppt); //Console.WriteLine(pdf2Text(ppt)); //pdf2Image(ppt); //Console.ReadLine(); //return; //Console.WriteLine(args[0]); string prefix = ""; string pptfile = ""; /* GET PATH OF EXE */ string path = System.Reflection.Assembly.GetExecutingAssembly().Location; //To get the location the assembly normally resides on disk or the install directory //string path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; //once you have the path you get the directory with: var directory = System.IO.Path.GetDirectoryName(pa); exe_root = dd.ToString(); /* END PATH */ ppt_img_root = exe_root; /* * For commandline only run: * $> PPT2Image sample.pptx * OR * */ /* * if (args.Length != 0) // while using commandline <this>.exe <filename>.pptx * { * ppt = exeBase + @"\" + args[0].ToString().Trim(); * prefix = args[0].ToString().Trim(); * } * * else // while running tests * { * //String pptfile = @"G:\LS_CAT_Apps_Weekly_7-17-15_Final.pptx"; * //string pptfile = @"H:\output\FULL_Q1FY17_LS-SWIFT_DivisionReview_Draft_Final.pptx"; * ppt = exeBase + @"\" + @"ppt1.pptx"; * * } */ //pptfile = exe_root + @"\" + @"ppt1.pptx"; //pptfile = exe_root + @"\" + @"LS-SWIFT.pptx"; //pptfile = exe_root + @"\" + @"VoyagerWeeklyUpdate_18-07-27.pptx"; pptfile = exe_root + @"\" + @"LS-Char-Extraction.pptx"; //pptfile = exe_root + @"\" + @"Flash_SJ_Pitch.ppt"; //pptfile = exe_root + @"\" + @"9650_Intro_111110.ppt"; //pptfile = exeBase + @"\" + @"LS-SWIFT_Product_Apps_Weekly_2018-07-06.pptx"; // remove when standalone application //string[] filePaths = System.IO.Directory.GetFiles(imagebase + @"\", "*.pptx"); //pptfile = filePaths[0]; // END //db = new DBConnect(); //db.Insert("insert into weekly (filename, hashtext, imgthumb, imglarge) values ('LS_WEEKLY5', 'PO1 ET', '/img/weekly7/thumb.png', '/img/weekly7/HD.png') "); //MongoDBConnect mg = new MongoDBConnect(); //mg.Connect(); //mg.getDocuments(); ////print all ascii chars //for (int i = 0; i < 256; ++i) //{ // Console.Write(i + ":" + (char)i + "| "); //} Console.WriteLine("Exe Base Dir = " + exe_root); Console.WriteLine("Image Base Dir = " + ppt_img_root); ppt_img_root = exe_root + @"\ppt-img"; pdf_root = exe_root + @"\pdf"; content_img_root = exe_root + @"\content-img"; /* PPT Operations */ pptParser fe = new pptParser(); fe.GetMetaData(); //fe.ppt2Image(pptfile, ppt_img_root, prefix); //fe.ppt2ImageAlt(pptfile, ppt_img_root, prefix); //fe.ppt2pdf(pptfile, "8ih423yu673", pdf_root, ""); fe.ppt2text(pptfile); //fe.ppt2pdfByPage(pptfile, null, null, 1); /* PDF Operations */ //string pdfFile = pdf_root + @"\8ih423yu673.pdf"; //fe.pdf2Text(pdfFile); //fe.pdf2TextByPage(pdfFile, 2); //newHash.readPPTText(pptfile); //newHash.mergePPTs(exeBase + @"\" + @"ppt1.pptx", exeBase + @"\" + @"ppt2.pptx"); pptController pc = new pptController(); }
public Tuple <ObjectId, bool> runPptParserFlow(BsonDocument document) { string pptfile = document["rawPath"].ToString(); string fid = document["_id"].ToString(); string fname = document["filename"].ToString(); //Console.WriteLine(pptfile + " : id = " + fid); ObjectId file_ID = new ObjectId(fid); /* connect database */ md = new MongoDBConnect(); md.Connect("result_database"); //read raw ppt Path from file ID // insert entry ppt : 'slide collection' into Mother var mother_ID = md.newEmptyRecord("mother"); // get iD from mother for entry /* TESTING CODE */ string pa = System.Reflection.Assembly.GetExecutingAssembly().Location; var dd = System.IO.Path.GetDirectoryName(pa); string binary_root = dd.ToString(); string ppt_img_root = binary_root + @"\ppt-img"; string content_img_root = binary_root + @"\content-img"; //string pptfile = binary_root + @"\" + @"LS-Char-Extraction.pptx"; /* CLOSE INITIALIZING CODE */ pptParser my_Ppt_Parser = new pptParser(mother_ID, file_ID, pptfile, ppt_img_root, content_img_root, document); bool success = my_Ppt_Parser.runPptParserFlow(); if (success) { /* Update MOTHER DB with <collection> {slide ID, meta , author } */ // create new Class entity for post mongoData mg = new mongoData(); mg.Id = mother_ID; mg.Data = new BsonDocument().AddRange(my_Ppt_Parser.get_PPT_METADATA()); mg.Collection = new BsonDocument().AddRange(my_Ppt_Parser.get_Slide_Collection()); /* Addition Fields for Mother */ Dictionary <string, Object> fd = new Dictionary <string, Object>(); //List<Object> lt = new List<Object>(); object lt = document["tags"]; // link parent fd.Add("sourceID", file_ID); fd.Add("source", "fileStor"); fd.Add("filename", fname); fd.Add("filePath", pptfile); fd.Add("fileType", "*.pptx"); // link child <collection> fd.Add("collection_source", "dataSlides"); fd.Add("tags", lt); mg.Data.AddRange(fd); md.updateEntireRecord("mother", mother_ID, mg); return(Tuple.Create(mother_ID, true)); } else { return(Tuple.Create(ObjectId.Empty, false)); } }