Exemplo n.º 1
0
        /// <summary>
        /// 获取分页内容
        /// </summary>
        /// <returns></returns>
        public ExtPageModel GetPageModels(System.Web.HttpContext context)
        {
            ExtPageModel  extPageModel = new ExtPageModel();
            string        urlHost      = GetHost(context);
            WebSiteApp    app          = new WebSiteApp();
            WebSiteEntity entity       = app.GetModelByUrlHost(urlHost);

            if (entity != null && !string.IsNullOrWhiteSpace(entity.Id))
            {
                string strRqs = context.Request["pageDatas"];
                if (!string.IsNullOrEmpty(strRqs))
                {
                    ExtPageModel extPageModelReq = Json.ToObject <ExtPageModel>(strRqs);
                    string       cIds            = GetColumnIds(context);
                    extPageModelReq.SourceIds = cIds;

                    string attrDatas = context.Request["attrDatas"];
                    if (!string.IsNullOrEmpty(attrDatas))
                    {
                        extPageModelReq.AttrDatas = Json.ToObject <Dictionary <string, string> >(attrDatas);
                    }
                    extPageModel = new TempHelp().GetContentModels(extPageModelReq, entity.ShortName);
                }
            }
            return(extPageModel);
        }
Exemplo n.º 2
0
        public ActionResult GetTypeSelectJson()
        {
            List <EnumModel> models = EnumHelp.enumHelp.EnumToList(typeof(CMS.Code.Enums.ModuleType));
            bool             bState = new WebSiteApp().IsAdvancedContent(Base_WebSiteId);

            if (!bState)
            {
                models = models.FindAll(m => m.Value != (int)CMS.Code.Enums.ModuleType.AdvancedList);
            }
            return(Content(models.ToJson()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理访问参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private RequestLogEntity InitRequestLog(RequestLogEntity entity, bool IsProcessWebSite)
        {
            WebSiteApp    app           = new WebSiteApp();
            WebSiteEntity webSiteEntity = app.GetModelByUrlHost(entity.WebSiteName);

            if (webSiteEntity != null)
            {
                entity.WebSiteId = webSiteEntity.Id;
            }
            return(entity);
        }
Exemplo n.º 4
0
 public ActionResult Index(string strLoginMark)
 {
     if (!string.IsNullOrEmpty(strLoginMark))
     {
         WebSiteApp webSiteApp    = new WebSiteApp();
         string     strWebSiteIds = string.Empty;
         if (webSiteApp.IsExistDefaultWebSite(ref strWebSiteIds))
         {
             return(RedirectToAction("WebSite", "Home", new { key = strWebSiteIds }));
         }
     }
     return(View());
 }
Exemplo n.º 5
0
 public ActionResult SubmitMessage(MessagesEntity moduleEntity)
 {
     try
     {
         string webSiteIds = new WebSiteApp().GetWebSiteId(HttpContext.Request);
         moduleEntity.SessionId = HttpContext.Session.SessionID;
         moduleEntity.WebSiteId = webSiteIds;
         messagesApp.AddForm(moduleEntity);
         return(Json(new { state = true, message = "提交成功。" }));
     }
     catch (Exception e)
     {
         return(Json(new { state = false, message = "提交失败。" + e.Message }));
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 根据网站ID和关键字查询结果
        /// </summary>
        /// <param name="wenSiteIds"></param>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public static List <ContentEntity> Search(string wenSiteIds, string keyword)
        {
            List <ContentEntity> mdoels = new List <ContentEntity>();

            if (!string.IsNullOrEmpty(wenSiteIds))
            {
                WebSiteApp    webSiteApp = new WebSiteApp();
                WebSiteEntity webSite    = webSiteApp.GetFormNoDel(wenSiteIds);
                if (webSite != null)
                {
                    LUCENCEINDEXPATH = string.Format(LUCENCEINDEXPATH, webSite.ShortName);
                    INDEX_DIR        = new DirectoryInfo(LUCENCEINDEXPATH);
                    BooleanQuery bQuery = new BooleanQuery();

                    using (IndexSearcher searcher = new IndexSearcher(FSDirectory.Open(INDEX_DIR), true))
                    {
                        QueryParser parseFullName = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "FullName", analyzer);
                        Query       query         = parseFullName.Parse(keyword);
                        bQuery.Add(query, Occur.SHOULD);

                        QueryParser parseAuthor = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "Author", analyzer);
                        Query       queryAuthor = parseAuthor.Parse(keyword);
                        bQuery.Add(queryAuthor, Occur.SHOULD);

                        QueryParser parseContent = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "Content", analyzer);
                        Query       queryContent = parseContent.Parse(keyword);
                        bQuery.Add(queryContent, Occur.SHOULD);

                        TopDocs       tds = searcher.Search(bQuery, Int32.MaxValue);
                        List <string> ids = new List <string>();
                        foreach (ScoreDoc sd in tds.ScoreDocs)
                        {
                            Document doc = searcher.Doc(sd.Doc);
                            ids.Add(doc.Get("Id"));
                        }
                        if (ids != null && ids.Count > 0)
                        {
                            ContentApp contentApp = new ContentApp();
                            mdoels = contentApp.GetLists(m => ids.Contains(m.Id) && m.DeleteMark != true && m.EnabledMark == true);
                        }
                        searcher.Dispose();
                    }
                }
            }
            return(mdoels);
        }
Exemplo n.º 7
0
        public ActionResult WebSite(string key)
        {
            WebSiteApp    app    = new WebSiteApp();
            WebSiteEntity entity = app.GetForm(key);

            if (entity != null && !string.IsNullOrEmpty(entity.Id))
            {
                SysLoginObjHelp.sysLoginObjHelp.AddWebSiteId(entity.Id);
                SysLoginObjHelp.sysLoginObjHelp.AddWebSiteName(entity.FullName);
                SysLoginObjHelp.sysLoginObjHelp.AddWebSiteShortName(entity.ShortName);
                if (!string.IsNullOrEmpty(entity.UrlAddress))
                {
                    string strUrlAddress = entity.UrlAddress.ToLower().Replace("http://", "");
                    SysLoginObjHelp.sysLoginObjHelp.AddWebSiteAddress(strUrlAddress);
                }
                SysLoginObjHelp.sysLoginObjHelp.AddWebSite <WebSiteEntity>(entity);
            }

            return(RedirectToAction("WebSiteMgr"));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 根据网站id创建内容索引
        /// </summary>
        public static void CreateIndex(string wenSiteIds)
        {
            if (!string.IsNullOrEmpty(wenSiteIds))
            {
                WebSiteApp    webSiteApp = new WebSiteApp();
                ContentApp    contentApp = new ContentApp();
                WebSiteEntity webSite    = webSiteApp.GetFormNoDel(wenSiteIds);
                if (webSite != null)
                {
                    LUCENCEINDEXPATH = string.Format(LUCENCEINDEXPATH, webSite.ShortName);
                    INDEX_DIR        = new DirectoryInfo(LUCENCEINDEXPATH);
                    List <ContentEntity> contents = contentApp.GetListByWebSiteId(wenSiteIds);

                    IndexWriter iw = new IndexWriter(Lucene.Net.Store.FSDirectory.Open(INDEX_DIR), analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
                    foreach (ContentEntity content in contents)
                    {
                        Document doc = new Document();
                        if (content.Id != null)
                        {
                            doc.Add(new Field("Id", content.Id, Field.Store.YES, Field.Index.ANALYZED));
                            if (content.FullName != null)
                            {
                                doc.Add(new Field("FullName", content.FullName, Field.Store.YES, Field.Index.ANALYZED));
                            }
                            if (content.Author != null)
                            {
                                doc.Add(new Field("Author", content.Author, Field.Store.YES, Field.Index.ANALYZED));
                            }
                            if (content.Content != null)
                            {
                                doc.Add(new Field("Content", content.Content, Field.Store.YES, Field.Index.ANALYZED));
                            }
                        }
                        iw.AddDocument(doc);
                    }
                    iw.Commit();
                    iw.Optimize();
                    iw.Dispose();
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 判断是否为根目录文件
        /// </summary>
        /// <returns></returns>
        private bool IsRootUrl(string urlhost, string urlRaw)
        {
            bool          bState        = false;
            WebSiteEntity webSiteEntity = new WebSiteApp().GetModelByUrlHost(urlhost);

            if (webSiteEntity != null && !string.IsNullOrWhiteSpace(webSiteEntity.Id))
            {
                List <string> urlRaws = WebHelper.GetUrls(urlRaw);
                if (new WebSiteApp().IsRoot(webSiteEntity.Id) &&
                    urlRaws.Count == 1)
                {
                    string   fileName  = urlRaws[0];
                    string[] fileNames = fileName.Split('.');
                    if (fileNames.Length == 2)
                    {
                        bState = new ResourceApp().IsRootFile(webSiteEntity.Id, fileName);
                    }
                }
            }
            return(bState);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取请求路径栏目Id
        /// </summary>
        /// <returns></returns>
        private string GetColumnIds(System.Web.HttpContext context)
        {
            string cIds    = string.Empty;
            string urlHost = GetHost(context);
            string urlRaw  = context.Request.RawUrl.ToString();

            urlRaw = context.Server.UrlDecode(urlRaw);

            //处理Url参数
            urlRaw = Common.HandleUrlRaw(urlRaw);
            List <string> urlRaws      = WebHelper.GetUrls(urlRaw);
            WebSiteApp    app          = new WebSiteApp();
            ColumnsApp    c_ColumnsApp = new ColumnsApp();
            WebSiteEntity entity       = app.GetModelByUrlHost(urlHost);

            if (urlRaws == null || urlRaws.Count == 0)
            {
                ColumnsEntity columnsEntity = c_ColumnsApp.GetMain(entity.Id);
                if (columnsEntity != null)
                {
                    cIds = columnsEntity.Id;
                }
            }
            else
            {
                if (urlRaws.Count > 0)
                {
                    ColumnsEntity columnsEntity = c_ColumnsApp.GetFormByActionName(urlRaws.FirstOrDefault(), entity.Id);
                    if (columnsEntity != null)
                    {
                        cIds = columnsEntity.Id;
                    }
                }
            }

            return(cIds);
        }