Example #1
0
 public ActionResult Index(queryClass model)
 {
     //USING TEMPDATA TO PASS TO RESULTS VIEW
     TempData["Query"] = model.Query;
     TempData["check"] = model.fileCheck;
     return(RedirectToAction("Results"));
 }
Example #2
0
        public ActionResult Results(queryClass newList)
        {
            queryClass    files           = new queryClass();
            List <string> sharepointFiles = new List <string>();
            List <string> boxFiles        = new List <string>();

            sharepointFiles = (List <string>)TempData["sharepointFiles"]; //retreiving from local storage
            boxFiles        = (List <string>)TempData["boxFiles"];        //retreiving from local storage

            if (boxFiles.Count >= sharepointFiles.Count)                  //adding the shorter list into the longerlist
            {
                foreach (string i in sharepointFiles)                     //string together all of the names into one list
                {
                    boxFiles.Add(i);
                }
                files.documentList = boxFiles;
            }
            else
            {
                foreach (string i in boxFiles) //string together all of the names into one list
                {
                    sharepointFiles.Add(i);
                }
                files.documentList = sharepointFiles;
            }


            return(View(files)); //updating the user that files are downloaded and displaying
        }
Example #3
0
        public ActionResult Results(queryClass model)
        {
            //SETTING INPUT TO SEARCH FROM TEMP DATA
            string input = TempData["Query"].ToString();

            //SETTING INPUT TO THE MODEL
            model.Query = input;
            //INTIALIZE CHECK BOX AND TURN IT IN
            string check = null;

            check = TempData["check"].ToString();

            //ERROR HANDLING FOR NULL REFRENCE
            if (input != null)
            {
                //IF COMMENTED OUT THE SERVER IS DOWN
                var node     = new Uri("http://10.115.2.126:9200");
                var settings = new ConnectionSettings(node).DefaultIndex("documents");
                var client   = new ElasticClient(settings);
                //UNCOMMENT IF THE SERVER IS DOWN
                //var settings = new ConnectionSettings().DefaultIndex("shakespeare");
                var config = new ConnectionConfiguration().PrettyJson();

                //CHECKS IF SEARCHING BY AUTHOR
                if (check == "True")
                {
                    //THIS IS THE USER INPUTED LINQ QUERY CALLING DOCS WHICH IS PART OF OUR PIPELINE
                    var test = client.Search <docs>(s => s.Query(q => q.Match(m => m.Field(f => f.Attachment.Author).Query(input)))); //CLIENT IS TO CONNECT TO ELASTICSEARCH. SEARCH IS A METHOD TO CREATE YOUR QUERY. MATCH IS TO FIND A SIMILAR AND FIELD IS TO FIND SOMETHING THAT WAS UP. FIELD.ATTACHMENT IS IS THE PIPELINE THAT WE CALL SO WE CAN GO THROUGH

                    //INTIALIZING ALL THE LISTS TO DISPLAY THE RESULTS
                    model.docList     = new List <string>();
                    model.contentList = new List <string>();
                    model.authorList  = new List <string>();
                    model.dateList    = new List <string>();
                    model.typeList    = new List <string>();
                    model.nameList    = new List <string>();
                    model.pathList    = new List <string>();
                    //VIEWBAG CREATION FOR THE HREF USED TO DISPLAY THE URL
                    ViewBag.Path = "";

                    //MAKES SURE THAT THE RESULTS ARE NOT NULL
                    if (test.Fields.Count != 0)
                    {
                        //FOREACH THAT ADDS EACH ENTRY TO THE RESPECTED LIST
                        foreach (var doc in test.Documents)
                        {
                            model.docList.Add(doc.Attachment.ToString());               //DOCUMENT LIST
                            model.authorList.Add(doc.Attachment.Author.ToString());     //AUTHOR LIST
                            model.dateList.Add(doc.Attachment.Date.ToString());         // DATE CREATION LIST
                            model.typeList.Add(doc.Attachment.ContentType.ToString());  // FILE TYPE LIST
                            model.contentList.Add(doc.Attachment.Content.ToString());   // THE CONTENT STRING LIST
                            model.pathList.Add(doc.Path.ToString());                    // LIST OF ALL THE FILE PATHS
                            var count = model.pathList.Count;                           // USED AS A COUNT FOR TOTAL DOCUMENTS IN THE TEST LINQ QUERY RESULTS
                            var path  = model.pathList.ToList();                        // A LIST OF ALL THE PATHS TO ADD TO THE VIEWBAG
                            ViewBag.Paths = path;                                       // SETTING THE LIST OFPATH EQUAL TO THE VIEWBAG
                        }
                        return(View(model));
                    }

                    return(View(model));
                }
                else // SEARCH BY KEYWORDS IN THE CONTENT
                {
                    var test = client.Search <docs>(s => s.Query(q => q.Match(m => m.Field(f => f.Attachment.Content).Query(input))));

                    //INTIALIZING ALL THE LISTS TO DISPLAY THE RESULTS
                    model.docList     = new List <string>();
                    model.contentList = new List <string>();
                    model.authorList  = new List <string>();
                    model.dateList    = new List <string>();
                    model.typeList    = new List <string>();
                    model.nameList    = new List <string>();
                    model.pathList    = new List <string>();
                    ViewBag.Path      = "";

                    //MAKES SURE THAT THE RESULTS ARE NOT NULL
                    if (test.Fields.Count != 0)
                    {
                        //FOREACH THAT ADDS EACH ENTRY TO THE RESPECTED LIST
                        foreach (var doc in test.Documents)
                        {
                            if (doc.Attachment.Author == null)
                            {
                                model.docList.Add(doc.Attachment.ToString());                  //DOCUMENT LIST
                                model.dateList.Add(doc.Attachment.Date.ToString());            //AUTHOR LIST
                                model.typeList.Add(doc.Attachment.ContentType.ToString());     //DATE LIST
                                model.contentList.Add(doc.Attachment.Content.ToString());      //FILE TYPE LIST
                                model.pathList.Add(doc.Path.ToString());                       //LIST OF FILE PATHS
                                doc.Attachment.Author = "None";                                //SETS AUTHORTO NONE IF NULL
                            }
                            else //IF THE AUTHOR IS NOT NULL
                            {
                                model.docList.Add(doc.Attachment.ToString());                  //DOC LIST
                                model.authorList.Add(doc.Attachment.Author.ToString());        //AUTHOR LIST
                                model.dateList.Add(doc.Attachment.Date.ToString());            //DATE LIST
                                model.typeList.Add(doc.Attachment.ContentType.ToString());     //TYPE LIST
                                model.contentList.Add(doc.Attachment.Content.ToString());      //CONTENT LIST
                                model.pathList.Add(doc.Path.ToString());                       //PATH LIST
                            }
                        }
                        return(View(model));
                    }

                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }