Example #1
0
 public ActionResult Edit(SampleData data)
 {
     if (data.Id == 0)
     {
         ViewData["msg"] = "Id不能为空";
     }
     else if (string.IsNullOrEmpty(data.Name))
     {
         ViewData["msg"] = "Name不能为空";
     }
     else if (string.IsNullOrEmpty(data.Description))
     {
         ViewData["msg"] = "Description不能为空";
     }
     else
     {
         if (GoLucene.Search(data.Id.ToString(), "Id").Any())
         {
             ViewData["msg"] = "Id已存在";
         }
         else
         {
             IndexQueue.GetInstance().AddQueue(new Data {
                 SampleData = data, OptionType = IndexOptionType.Add
             });
         }
     }
     return(View());
 }
Example #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            log4net.Config.XmlConfigurator.ConfigureAndWatch(
                new System.IO.FileInfo(Path.Combine(Server.MapPath("~"), "log4net.config")));

            //设置lucene索引文件的地址
            GoLucene._luceneDir = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("/App_Data"), @"lucene_index");

            //启动队列处理队列中的数据
            IndexQueue.GetInstance().StartThread();
        }