예제 #1
0
        public ObjectId postError(string collectionName, mongoData errorData)
        {
            Console.WriteLine(errorData);
            var collection = db.GetCollection <mongoData>(collectionName);

            //var doc = new mongoData { }; /* empty document*/
            collection.InsertOne(errorData);
            var id = errorData.Id;

            return(id);
        }
예제 #2
0
        // /to be updated
        public ObjectId postRecord(string collectionName)
        {
            var collection = db.GetCollection <mongoData>(collectionName);

            var doc = new mongoData {
            };                           /* empty document*/

            collection.InsertOne(doc);
            var id = doc.Id;

            return(id);
        }
예제 #3
0
        public void updateEntireRecord(string collectionName, ObjectId ID, mongoData dt)
        {
            var collection = db.GetCollection <BsonDocument>(collectionName);
            //var query = Query<mongoData>.EQ(p => p.Id, 10);

            var filter = Builders <BsonDocument> .Filter.Eq("_id", ID);

            //var update = Builders<BsonDocument>.Update.

            var replaceOneResult = collection.ReplaceOne(filter, dt.ToBsonDocument());

            //Console.WriteLine("replacement result: " + replaceOneResult);
        }
예제 #4
0
        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));
            }
        }