Beispiel #1
0
 public void InitWebSiteUrl(ref WebSiteEntity webSiteEntity)
 {
     if (webSiteEntity != null && !string.IsNullOrEmpty(webSiteEntity.Id))
     {
         List <WebSiteForUrlEntity> webSiteForUrlEntitys = GetListByWebSiteId(webSiteEntity.Id);
         if (webSiteForUrlEntitys != null && webSiteForUrlEntitys.Count > 0)
         {
             PropertyInfo[] props = webSiteEntity.GetType().GetProperties();
             foreach (var webSiteForUrlEntity in webSiteForUrlEntitys)
             {
                 string propNames = "SpareUrlAddress";
                 if (webSiteForUrlEntity.SortCode != 0 && webSiteForUrlEntity.SortCode < 10)
                 {
                     propNames = propNames + "0" + webSiteForUrlEntity.SortCode;
                 }
                 else
                 {
                     propNames = propNames + webSiteForUrlEntity.SortCode;
                 }
                 PropertyInfo prop = props.FirstOrDefault(m => m.Name.ToLower() == propNames.ToLower());
                 if (prop != null)
                 {
                     prop.SetValue(webSiteEntity, webSiteForUrlEntity.UrlAddress, null);
                 }
             }
         }
     }
 }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary>
        /// 获取站点资源文件所占大小 单位m
        /// </summary>
        /// <returns></returns>
        public decimal GetWebSiteDirSizeByWebSiteId(string webSiteId)
        {
            decimal       dirSize       = 0;
            WebSiteEntity webSiteEntity = GetForm(webSiteId);

            if (webSiteEntity != null && !string.IsNullOrEmpty(webSiteEntity.Id))
            {
                string lucenceFilePaths        = FileHelper.MapPath(string.Format(LUCENCEINDEXPATH, webSiteEntity.ShortName));
                string htmlSrcPaths            = FileHelper.MapPath(HTMLSRC + @"\" + webSiteEntity.ShortName + @"\");
                string htmlContentSrcPaths     = FileHelper.MapPath(HTMLCONTENTSRC + @"\" + webSiteEntity.ShortName + @"\");
                string htmlRootContentSrcPaths = FileHelper.MapPath(HTMLROOTCONTENTSRC + @"\" + webSiteEntity.ShortName + @"\");
                string uploadImgPaths          = FileHelper.MapPath(UPLOADIMGPATH + @"\" + webSiteEntity.ShortName + @"\");
                string uploadFilePaths         = FileHelper.MapPath(UPLOADFILEPATH + @"\" + webSiteEntity.ShortName + @"\");

                dirSize += FileHelper.GetDirectoryLength(lucenceFilePaths);
                dirSize += FileHelper.GetDirectoryLength(htmlSrcPaths);
                dirSize += FileHelper.GetDirectoryLength(htmlContentSrcPaths);
                dirSize += FileHelper.GetDirectoryLength(htmlRootContentSrcPaths);
                dirSize += FileHelper.GetDirectoryLength(uploadImgPaths);
                dirSize += FileHelper.GetDirectoryLength(uploadFilePaths);

                if (dirSize > 0)
                {
                    dirSize = Math.Round(dirSize / 1024 / 1024, 2);
                }
            }
            return(dirSize);
        }
Beispiel #4
0
        public WebSiteEntity GetForm(string keyValue)
        {
            WebSiteEntity webSiteEntity = service.FindEntity(keyValue);

            if (webSiteEntity != null && !string.IsNullOrEmpty(webSiteEntity.Id))
            {
                new WebSiteForUrlApp().InitWebSiteUrl(ref webSiteEntity);
            }

            return(webSiteEntity);
        }
Beispiel #5
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);
        }
Beispiel #6
0
 public void SubmitForm(WebSiteEntity moduleEntity, List <WebSiteForUrlEntity> webSiteForUrlEntitys, string keyValue, UpFileDTO upFileentity)
 {
     if (string.IsNullOrWhiteSpace(moduleEntity.ShortName))
     {
         throw new Exception("网站简称不能为空!");
     }
     if (!System.Text.RegularExpressions.Regex.IsMatch(moduleEntity.ShortName, "^[0-9a-zA-Z]+$"))
     {
         throw new Exception("网站简称只能为字母或数字!");
     }
     service.SubmitForm(moduleEntity, webSiteForUrlEntitys, keyValue, upFileentity);
 }
Beispiel #7
0
 public ActionResult SubmitForm(WebSiteEntity moduleEntity, string keyValue, UpFileDTO upFileentity)
 {
     try
     {
         webSiteApp.SubmitForm(moduleEntity, GetSpareUrlAddress(), keyValue, upFileentity);
         return(Success("操作成功。"));
     }
     catch (Exception e)
     {
         return(Error(e.Message));
     }
 }
Beispiel #8
0
        /// <summary>
        /// 根据域名获取实体
        /// </summary>
        /// <returns></returns>
        public string GetWebSiteId(System.Web.HttpRequestBase request)
        {
            string        webSiteIds    = string.Empty;
            string        hosturl       = new RequestHelp().GetHostRequest(request);
            WebSiteEntity webSiteEntity = GetModelByUrlHost(hosturl);

            if (webSiteEntity != null)
            {
                webSiteIds = webSiteEntity.Id;
            }
            return(webSiteIds);
        }
Beispiel #9
0
        /// <summary>
        /// 根据域名获取实体
        /// </summary>
        /// <returns></returns>
        public WebSiteEntity GetModelByUrlHost(string urlHost)
        {
            WebSiteEntity       webSiteEntity       = new WebSiteEntity();
            WebSiteForUrlEntity webSiteForUrlEntity = serviceWebSiteForUrl.IQueryable(m => m.UrlAddress == urlHost && m.DeleteMark != true).FirstOrDefault();

            if (webSiteForUrlEntity != null && !string.IsNullOrEmpty(webSiteForUrlEntity.WebSiteId))
            {
                webSiteEntity = service.FindEntity(webSiteForUrlEntity.WebSiteId);
            }

            return(webSiteEntity);
        }
Beispiel #10
0
        /// <summary>
        /// 获取站点空间大小
        /// </summary>
        /// <returns></returns>
        public decimal GetWebSiteSize(string webSiteShortName)
        {
            decimal       websiteSize   = 0;
            WebSiteEntity webSiteEntity = GetFormByShortName(webSiteShortName);

            if (webSiteEntity != null && !string.IsNullOrEmpty(webSiteEntity.Id))
            {
                WebSiteConfigEntity model = GetWebSiteConfigFormByWebSiteId(webSiteEntity.Id);
                websiteSize = model.WebSiteResourceSize;
            }
            return(websiteSize);
        }
Beispiel #11
0
        public void DeleteForm(string keyValue)
        {
            WebSiteEntity moduleEntity = service.FindEntity(keyValue);

            if (moduleEntity != null)
            {
                //验证用户站点权限
                iUserRepository.VerifyUserWebsiteRole(moduleEntity.Id);
            }
            service.DeleteForm(keyValue);
            //添加日志
            LogHelp.logHelp.WriteDbLog(true, "删除站点信息=>" + keyValue, Enums.DbLogType.Delete, "站点管理");
        }
Beispiel #12
0
        /// <summary>
        /// 根据站点id获取站点根目录资源文件
        /// </summary>
        /// <param name="webSiteId"></param>
        /// <returns></returns>
        public List <ResourceEntity> GetRootList(string webSiteId)
        {
            List <ResourceEntity> models     = new List <ResourceEntity>();
            WebSiteApp            webSiteApp = new WebSiteApp();

            if (!string.IsNullOrEmpty(webSiteId))
            {
                WebSiteEntity webSiteEntity = webSiteApp.GetForm(webSiteId);
                if (webSiteEntity != null && !string.IsNullOrEmpty(webSiteEntity.ShortName))
                {
                    models = GetRootFilesByWebSiteShortName(webSiteEntity.ShortName, webSiteEntity.UrlAddress);
                }
            }
            return(models);
        }
Beispiel #13
0
        /// <summary>
        /// 判断域名是否存在
        /// </summary>
        /// <param name="keyId"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool IsExistUrl(WebSiteEntity moduleEntity, string url)
        {
            moduleEntity.UrlAddress = moduleEntity.UrlAddress.Trim();

            WebSiteForUrlEntity TwebSiteForUrlEntity = IQueryable(m => m.DeleteMark != true && m.WebSiteId == moduleEntity.Id && m.SortCode == 0).FirstOrDefault();

            if (TwebSiteForUrlEntity != null)
            {
                return(IsExist(TwebSiteForUrlEntity.Id, "UrlAddress", moduleEntity.UrlAddress, true));
            }
            else
            {
                return(IsExist("", "UrlAddress", moduleEntity.UrlAddress, true));
            }
        }
Beispiel #14
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);
        }
Beispiel #15
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"));
        }
Beispiel #16
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();
                }
            }
        }
Beispiel #17
0
        public void GenStaticPage(string keyValue)
        {
            ContentEntity moduleEntity = service.FindEntity(keyValue);

            if (moduleEntity != null)
            {
                //验证用户站点权限
                iUserRepository.VerifyUserWebsiteRole(moduleEntity.WebSiteId);
            }
            ColumnsEntity columnsEntity = GetModuleByContentID(keyValue);

            if (columnsEntity != null &&
                (columnsEntity.Type == (int)Enums.ModuleType.List || columnsEntity.Type == (int)Enums.ModuleType.AdvancedList))
            {
                if (new WebSiteApp().IsOverSizeByWebSiteId(columnsEntity.WebSiteId))
                {
                    throw new Exception("该站点空间已不足,请联系管理员!");
                }
                WebSiteApp    webSiteApp    = new WebSiteApp();
                WebSiteEntity webSiteEntity = webSiteApp.GetFormNoDel(columnsEntity.WebSiteId);
                if (webSiteEntity != null && !string.IsNullOrEmpty(webSiteEntity.Id))
                {
                    TempletApp    templetapp = new TempletApp();
                    TempletEntity templet    = templetapp.GetFormNoDel(columnsEntity.CTempletId);
                    if (templet != null)
                    {
                        new TempHelp().GenHtmlPage(keyValue, webSiteEntity, columnsEntity, templet);
                    }
                    if (new WebSiteApp().IsMobile(webSiteEntity.Id))
                    {
                        templet = templetapp.GetFormNoDel(columnsEntity.MCTempletId);
                        if (templet != null)
                        {
                            new TempHelp().GenMHtmlPage(keyValue, webSiteEntity, columnsEntity, templet);
                        }
                    }
                }
                //添加日志
                LogHelp.logHelp.WriteDbLog(true, "内容信息=>生成列表详情静态页" + columnsEntity.FullName, Enums.DbLogType.Submit, "内容管理");
            }
        }
Beispiel #18
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);
        }
Beispiel #19
0
 public void SubmitForm(WebSiteEntity moduleEntity, string keyValue)
 {
     service.SubmitForm(moduleEntity, keyValue);
 }