private bool SaveValidation() { using (TriglavBL temp = new TriglavBL()) { List <Post> listaClanaka = temp.getAllPosts(5); foreach (var clanak in listaClanaka) { if (String.Compare(txt_Naslov.Text, Convert.ToString(clanak.Naslov), true) == 0) { Response.Write("<script>alert('Greška! Članak pod ovim imenom već postoji.\n Pokušajte promijeniti naslov članka.');</script>"); return(false); } } if (txt_Naslov.Text.Count() < 3) { Response.Write("<script>alert('Greška! Naziv mora biti duži od 3 karaktera.');</script>"); return(false); } if (txt_Sadrzaj.Text.Count() < 3) { Response.Write("<script>alert('Greška! Sadržaj mora biti duži od 3 karaktera.');</script>"); return(false); } if (txt_Tagovi.Text.Count() < 3) { Response.Write("<script>alert('Greška! Tagovi moraju biti duži od 3 karaktera.');</script>"); return(false); } return(true); } }
protected void Page_Load(object sender, EventArgs e) { using (TriglavBL temp = new TriglavBL()) { Directory directory = FSDirectory.Open(new DirectoryInfo("J:/Triglav_Web_App/Triglav/Web/Lucene/LuceneIndex")); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_29); var writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED); List <Post> sviPostovi = temp.getAllPosts(1); foreach (var post in sviPostovi) { var document = new Document(); document.Add(new Field("id", Convert.ToString(post.id), Field.Store.YES, Field.Index.NOT_ANALYZED)); document.Add(new Field("Naslov", post.Naslov, Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Sadrzaj", post.Sadrzaj, Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Sazetak", post.Sazetak, Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Tagovi", post.Tagovi, Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("DatumKreiranja", Convert.ToString(post.DatumKreiranja), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("DatumZadnjeIzmjene", Convert.ToString(post.DatumZadnjeIzmjene), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("DatumZadnjeAktivnosti", Convert.ToString(post.DatumZadnjeAktivnosti), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("BrojOdgovora", Convert.ToString(post.BrojOdgovora), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Likes", Convert.ToString(post.Likes), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Unlikes", Convert.ToString(post.Unlikes), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("VlasnikId", Convert.ToString(post.VlasnikID), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new Field("Unlikes", Convert.ToString(post.Unlikes), Field.Store.YES, Field.Index.ANALYZED)); writer.AddDocument(document); } writer.Optimize(); writer.Close(); } }