Ejemplo n.º 1
0
        public ActionResult CreateKnowledgeBox(KnowledgeBox knowledgeBox)
        {
            if (ModelState.IsValid)
            {
                if (knowledgeBox.docUpload2 != null)
                {
                    var    fileNameDoc = Path.GetFileNameWithoutExtension(knowledgeBox.docUpload2.FileName);
                    string extension2  = Path.GetExtension(knowledgeBox.docUpload2.FileName);
                    fileNameDoc            = fileNameDoc + "_" + DateTime.Now.ToString("ddMMyy_HHmmss") + extension2;
                    knowledgeBox.docUpload = "/docUploadKnowledgeBox/" + fileNameDoc;
                    var path = Path.Combine(Server.MapPath("~/docUploadKnowledgeBox/"), fileNameDoc);
                    knowledgeBox.docUpload2.SaveAs(path);
                }

                knowledgeBox.date  = DateTime.Today;
                knowledgeBox.views = 0;
                db.KnowledgeBox.Add(knowledgeBox);
                db.SaveChanges();
                ModelState.Clear();

                return(RedirectToAction("CreateSuccessMessage"));
            }

            return(View(knowledgeBox));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteKnowledgeBoxConfirm(int id)
        {
            KnowledgeBox knowledgeBox = db.KnowledgeBox.Find(id);

            db.KnowledgeBox.Remove(knowledgeBox);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult KnowledgeBoxDetail(int id)
        {
            KnowledgeBox knowledgeBox = db.KnowledgeBox.Find(id);

            if (knowledgeBox == null)
            {
                return(RedirectToAction("Index"));
            }

            //--Page Visitor
            knowledgeBox.views           = knowledgeBox.views + 1;
            db.Entry(knowledgeBox).State = EntityState.Modified;
            db.SaveChanges();

            return(View(knowledgeBox));
        }
Ejemplo n.º 4
0
        public ActionResult EditKnowledgeBox(int id)
        {
            if (Session["Role"] != null)
            {
                if (Session["Role"].Equals("Admin"))
                {
                    KnowledgeBox knowledgeBox = db.KnowledgeBox.Find(id);
                    if (knowledgeBox == null)
                    {
                        return(RedirectToAction("Index"));
                    }

                    return(View(knowledgeBox));
                }
                return(RedirectToAction("Index", "KnowledgeBox"));
            }
            else
            {
                return(RedirectToAction("Index", "KnowledgeBox"));
            }
        }
Ejemplo n.º 5
0
        public ActionResult EditKnowledgeBox(KnowledgeBox knowledgeBox)
        {
            if (ModelState.IsValid)
            {
                if (knowledgeBox.docUpload2 != null)
                {
                    var    fileNameDoc = Path.GetFileNameWithoutExtension(knowledgeBox.docUpload2.FileName);
                    string extension2  = Path.GetExtension(knowledgeBox.docUpload2.FileName);
                    fileNameDoc            = fileNameDoc + "_" + DateTime.Now.ToString("ddMMyy_HHmmss") + extension2;
                    knowledgeBox.docUpload = "/docUploadKnowledgeBox/" + fileNameDoc;
                    var path = Path.Combine(Server.MapPath("~/docUploadKnowledgeBox/"), fileNameDoc);
                    knowledgeBox.docUpload2.SaveAs(path);
                }

                db.KnowledgeBox.Attach(knowledgeBox);
                db.Entry(knowledgeBox).Property(x => x.name).IsModified        = true;
                db.Entry(knowledgeBox).Property(x => x.description).IsModified = true;
                db.Entry(knowledgeBox).Property(x => x.docUpload).IsModified   = true;
                db.SaveChanges();
                return(RedirectToAction("EditSuccessMessage"));
            }

            return(View(knowledgeBox));
        }
Ejemplo n.º 6
0
 public static void AddUpdateLuceneIndex(KnowledgeBox.Models.Item itemData)
 {
     AddUpdateLuceneIndex(new List<KnowledgeBox.Models.Item> { itemData });
 }
Ejemplo n.º 7
0
        private static void _addToLuceneIndex(KnowledgeBox.Models.Item itemData, IndexWriter writer)
        {
            // remove older index entry
            var searchQuery = new TermQuery(new Term("Id", itemData.Item_Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            // add new index entry
            var doc = new Document();

            // add lucene fields mapped to db fields
            doc.Add(new Field("Id", itemData.Item_Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Name", itemData.Item_Name, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Description", itemData.Item_Description, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Tags", itemData.Item_TagWords, Field.Store.YES, Field.Index.ANALYZED));
            //doc.Add(new Field("Subject", itemData.ItemSubjects.FirstOrDefault().Subject.Subject_Description , Field.Store.YES, Field.Index.ANALYZED));
            //doc.Add(new Field("Phase", itemData.Item_Description, Field.Store.YES, Field.Index.ANALYZED));

            // add entry to index
            writer.AddDocument(doc);
        }