コード例 #1
0
        public static void CreateIndexCreative(Creative entity, string IndexPath)
        {
            var document = new Document();
            document.Add(new Field("CreativeId", entity.Creativeid.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            document.Add(new Field("Title", entity.Title, Field.Store.YES, Field.Index.ANALYZED));
            if (!string.IsNullOrEmpty(entity.About))
            {
                document.Add(new Field("About", entity.About, Field.Store.YES, Field.Index.ANALYZED));
            }

            Directory directory = FSDirectory.Open(new DirectoryInfo(IndexPath));
              Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);

               var writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);

              try
              {

            writer.AddDocument(document);

            writer.Optimize();

            writer.Dispose();
              }
             finally
              {

              writer.Dispose();
              }
        }
コード例 #2
0
ファイル: AddCreative.cs プロジェクト: Zwem/Creatives
 public static void Add(Creative creative)
 {
     using (EntityContext _db = new EntityContext())
     {
         _db.Creative.Add(creative);
         _db.SaveChanges();
     }
 }
コード例 #3
0
ファイル: CreativeController.cs プロジェクト: Zwem/Creatives
        public ActionResult Edit(Creative creative, int id)
        {
            if (ModelState.IsValid)
            {
              _creativesRepository.ModifiedCreatives(creative);
              _creativesRepository.AddTag(creative.Creativeid);
              return RedirectToAction("Find", new { id });

            }
            return View();
        }
コード例 #4
0
ファイル: CreativeController.cs プロジェクト: Zwem/Creatives
 public ActionResult Create(Creative creative)
 {
     if (ModelState.IsValid)
     {
         var user = _creativesRepository.GetUserByName(User.Identity.Name);
         creative.DateCreate = DateTime.Now;
         creative.UserId = user.UserId;
         AddCreative.Add(creative);
         string IndexPath = Server.MapPath("~/App_Data");
         CreativeIndexDefinition.CreateIndexCreative(creative, IndexPath);
         if (creative.Tagon != null)
         {
             _creativesRepository.AddTag(creative.Creativeid);
         }
         return RedirectToAction("Add", "Chapter", new { id = creative.Creativeid });
     }
     return View();
 }
コード例 #5
0
ファイル: CreativesRepository.cs プロジェクト: Zwem/Creatives
 public void ModifiedCreatives(Creative creative)
 {
     _db.Entry(GetCreativeById(creative.Creativeid)).CurrentValues.SetValues(creative);
     _db.SaveChanges();
 }