Beispiel #1
0
 public ActionResult Edit(Content model)
 {
     if (ModelState.IsValid)
     {
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         model.ModifiedBy   = session.UserName;
         model.ModifiedDate = DateTime.Now;
         var  dao = new ContentDao();
         long id  = dao.Edit(model);
         if (id > 0)
         {
             SetAlert("Update content thành công", "success");
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật content không thành công");
         }
     }
     SetViewBag(model.CategoryID);
     return(View());
 }
Beispiel #2
0
 public ActionResult Create(Content model)
 {
     if (ModelState.IsValid)
     {
         var contentDao = new ContentDao();
         model.MetaTitle = Converter.ConvertToUnSign(model.Name);
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         model.CreatedBy = session.UserName;
         var rs = contentDao.Insert(model);
         if (rs > 0)
         {
             SetAlert("Insert success!", "success");
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Insert failed, check the contents again");
         }
     }
     SetViewBag();
     return(View("Create"));
 }
Beispiel #3
0
        public ActionResult Category(long id)
        {
            int page = 1; int pageSize = 10;
            var model       = new ContentDao().ListAllByCategory(id);
            int totalRecord = 0;

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            ViewBag.Page       = 1;
            ViewBag.category   = new CategoriesDao().ListAll();
            ViewBag.recentpost = new ContentDao().ListRecentPost();
            ViewBag.tags       = new ContentDao().ListAllTag();
            int maxPage   = 5;
            int totalPage = 0;

            ViewBag.Last = totalPage;
            ViewBag.Next = page + 1;
            ViewBag.Prev = page - 1;

            return(View(model));
        }
 public ActionResult AddContent(Content item)
 {
     if (ModelState.IsValid)
     {
         item.CreatedDate  = DateTime.Now;
         item.ModifiedDate = DateTime.Now;
         var status = new ContentDao().Insert(item);
         if (status)
         {
             SetAlert("Thêm tin tức thành công", "success");
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm thất bại. Vui lòng thử lại!");
             setViewBag();
             return(View());
         }
     }
     setViewBag();
     return(View());
 }
Beispiel #5
0
 public ActionResult Create(Content model)
 {
     if (ModelState.IsValid)
     {
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         model.CreatedBy = session.UserName;
         var  dao = new ContentDao();
         long id  = dao.Create(model);
         if (id > 0)
         {
             SetAlert("Thêm thông tin thành công", "success");
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             SetAlert("Thêm user không thành công", "error");
             ModelState.AddModelError("", "Thêm thông tin không thành công");
         }
     }
     SetViewBag();
     return(View());
 }
Beispiel #6
0
        public JsonResult Delete(int id)
        {
            if (id <= 0)
            {
                return(Json(new { status = false, mess = "không xóa được" }));
            }
            var data = new ContentDao().GetByID((long)id);

            if (data.Status)
            {
                return(Json(new { status = false, mess = "không xóa được" }));
            }
            var result = new ContentDao().Delete(id);

            if (result)
            {
                return(Json(new { status = true, mess = "xóa thành công" }));
            }
            else
            {
                return(Json(new { status = false, mess = "không xóa được" }));
            }
        }
        // GET: Content
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            var model       = new ContentDao().ListAllPaging(page, pageSize);
            int totalRecord = 0;

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;

            // Số trang hiển thị tối đa
            int maxPage = 5;
            //Tổng số trang tính ra , mặc định là 0
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }
        public ActionResult Tag(string tagId, int page = 1, int pageSize = 10)
        {
            var model = new ContentDao().ListAllByTag(tagId, page, pageSize);

            int totalRecord = 0;

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;
            ViewBag.Tag   = new ContentDao().GetTag(tagId);

            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalRecord;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }
 public ActionResult Create(Content content)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var dao    = new ContentDao();
             var result = dao.Insert(content);
             if (result > 0)
             {
                 return(RedirectToAction("Index", "Content"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới không thành công");
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(RedirectToAction("Index", "Create"));
 }
Beispiel #10
0
        public ActionResult Edit(ContentViewModel contentView)
        {
            if (ModelState.IsValid)
            {
                Content content = new Content();
                content.ID          = contentView.ID;
                content.Name        = contentView.Name;
                content.MetaTitle   = contentView.MetaTitle;
                content.Image       = contentView.Image;
                content.Description = contentView.Description;
                content.Detail      = contentView.Detail;
                content.CategoryID  = contentView.CategoryID;
                content.Status      = contentView.Status;

                var contentDao  = new ContentDao();
                var categoryDao = new CategoryDao();

                int result = contentDao.Update(content);
                if (result == 1)
                {
                    ShowNotify("Update successfully", "success");
                    return(RedirectToAction("Index", "Content"));
                }
                else if (result == -1)
                {
                    ShowNotify("This '" + categoryDao.GetByID(content.CategoryID).Name + "' category is locked", "error");
                }
                else if (result == 0)
                {
                    ShowNotify("System error", "error");
                }
            }

            SetViewBagCategory(contentView.ID, false);

            return(View("Edit"));
        }
        public ActionResult Tag(string tagId, int page = 1, int pageSize = 20)
        {
            var tag = new ContentDao().GetTag(tagId);

            ViewBag.Tag = tag;
            int totalRecord = 0;
            var model       = new ContentDao().ListAllByTag(tagId, ref totalRecord, page, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = page;
            //maxPage cho nút ở class pagination
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((decimal)totalRecord / pageSize);
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }
Beispiel #12
0
        // GET: Content
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            var model       = new ContentDao().ListAllPaging(page, pageSize);
            int totalRecord = 0;

            ViewBag.Total      = totalRecord;
            ViewBag.Page       = page;
            ViewBag.category   = new CategoriesDao().ListAll();
            ViewBag.recentpost = new ContentDao().ListRecentPost();
            ViewBag.tag        = new ContentDao().ListAllTag();

            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }
Beispiel #13
0
        public IActionResult Edit(long id)
        {
            var dao     = new ContentDao();
            var content = dao.GetByID(id);

            SetViewBag(content.CategoryId);
            ContentCreateViewModel result = new ContentCreateViewModel
            {
                Name            = content.Name,
                MetalTitle      = content.MetalTitle,
                Description     = content.Description,
                CategoryId      = content.CategoryId,
                Detail          = content.Detail,
                Warranty        = content.Warranty,
                ModifiedDate    = content.ModifiedDate,
                ModifiedBy      = content.ModifiedBy,
                MetaKeywords    = content.MetaKeywords,
                MetaDescription = content.MetaDescription,
                Status          = content.Status,
                TopHot          = content.TopHot,
            };

            return(View(result));
        }
Beispiel #14
0
        public ActionResult Tag(string tagId, int?page, int pageSize = 10)
        {
            var currentPage = page ?? 1;
            var contentDao  = new ContentDao();
            var model       = contentDao.GetAllContentByTag(tagId, currentPage, pageSize);
            int totalRecord = 0;

            ViewBag.Tag = new ContentDao().GetTag(tagId);

            ViewBag.TotalRecord = totalRecord;
            ViewBag.Page        = page;
            ViewBag.MaxPage     = 5;
            var totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize));

            ViewBag.TotalPage = totalPage;

            ViewBag.First = 1;
            ViewBag.Last  = totalPage;

            ViewBag.NextPage     = page + 1;
            ViewBag.PreviousPage = page - 1;

            return(View(model));
        }
        //Liệt kê tất cả content với categoryID
        public ActionResult ContentWithCategoryID(long categoryID, int pageIndex, int pageSize = 2)
        {
            var category = new CategoryDao().ViewDetail(categoryID);

            ViewBag.Category = category;
            int totalRecord = 0;
            var model       = new ContentDao().ListByCategoryId(categoryID, ref totalRecord, pageIndex, pageSize);

            ViewBag.Total = totalRecord;
            ViewBag.Page  = pageIndex;
            //maxPage cho nút ở class pagination
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((decimal)totalRecord / pageSize);
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;

            return(View(model));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PopulateContentByCategoryIdResponseHydrator"/> class.
 /// </summary>
 /// <param name="contentDao">
 /// The content dao.
 /// </param>
 /// <param name="contentConfiguration">
 /// The content configuration.
 /// </param>
 public PopulateContentByCategoryIdResponseHydrator(ContentDao<Models.Content> contentDao, IContentConfiguration contentConfiguration)
     : base(contentDao, contentConfiguration)
 {
 }
Beispiel #17
0
        public async Task UpdateSplitContentsTableInfoAsync(Dictionary <int, TableInfo> splitSiteTableDict, List <int> siteIdList, string oldTableName, TableInfo oldTableInfo, ConvertInfo converter)
        {
            if (converter == null)
            {
                converter = new ConvertInfo();
            }

            if (converter.IsAbandon)
            {
                await CliUtils.PrintRowAsync(oldTableName, "Abandon", "--");

                return;
            }

            if (converter.NewColumns == null || converter.NewColumns.Count == 0)
            {
                converter.NewColumns = oldTableInfo.Columns;
            }

            await CliUtils.PrintRowAsync(oldTableName, "#split-content#", oldTableInfo.TotalCount.ToString("#,0"));

            if (oldTableInfo.RowFiles.Count > 0)
            {
                var i = 0;
                using (var progress = new ProgressBar())
                {
                    foreach (var fileName in oldTableInfo.RowFiles)
                    {
                        progress.Report((double)i++ / oldTableInfo.RowFiles.Count);

                        var newRows = new List <Dictionary <string, object> >();

                        var oldFilePath = OldTreeInfo.GetTableContentFilePath(oldTableName, fileName);

                        var oldRows =
                            TranslateUtils.JsonDeserialize <List <JObject> >(await FileUtils.ReadTextAsync(oldFilePath, Encoding.UTF8));

                        newRows.AddRange(UpdateUtils.UpdateRows(oldRows, converter.ConvertKeyDict, converter.ConvertValueDict));

                        var siteIdWithRows = new Dictionary <int, List <Dictionary <string, object> > >();
                        foreach (var siteId in siteIdList)
                        {
                            siteIdWithRows.Add(siteId, new List <Dictionary <string, object> >());
                        }

                        foreach (var newRow in newRows)
                        {
                            if (newRow.ContainsKey(nameof(CMS.Model.ContentInfo.SiteId)))
                            {
                                var siteId = Convert.ToInt32(newRow[nameof(CMS.Model.ContentInfo.SiteId)]);
                                if (siteIdList.Contains(siteId))
                                {
                                    var rows = siteIdWithRows[siteId];
                                    rows.Add(newRow);
                                }
                            }
                        }

                        foreach (var siteId in siteIdList)
                        {
                            var siteRows      = siteIdWithRows[siteId];
                            var siteTableName = ContentDao.GetContentTableName(siteId);
                            var siteTableInfo = splitSiteTableDict[siteId];
                            siteTableInfo.TotalCount += siteRows.Count;

                            foreach (var tableColumn in converter.NewColumns)
                            {
                                if (!siteTableInfo.Columns.Any(t => StringUtils.EqualsIgnoreCase(t.AttributeName, tableColumn.AttributeName)))
                                {
                                    siteTableInfo.Columns.Add(tableColumn);
                                }
                            }

                            if (siteRows.Count > 0)
                            {
                                var siteTableFileName = $"{siteTableInfo.RowFiles.Count + 1}.json";
                                siteTableInfo.RowFiles.Add(siteTableFileName);
                                var filePath = NewTreeInfo.GetTableContentFilePath(siteTableName, siteTableFileName);
                                await FileUtils.WriteTextAsync(filePath, Encoding.UTF8, TranslateUtils.JsonSerialize(siteRows));
                            }
                        }
                    }
                }
            }
        }
Beispiel #18
0
        private int Validate_SiteInfo(out string errorMessage)
        {
            try
            {
                var isRoot       = TranslateUtils.ToBool(RblIsRoot.SelectedValue); // 是否主站
                var parentSiteId = 0;
                var siteDir      = string.Empty;
                var domainName   = string.Empty;
                if (DirectoryUtils.IsSystemDirectory(TbSiteDir.Text) || DirectoryUtils.IsWebSiteDirectory(TbSiteDir.Text))
                {
                    errorMessage = "文件夹名称不能为系统文件夹名称!";
                    return(0);
                }

                parentSiteId = TranslateUtils.ToInt(DdlParentId.SelectedValue);
                siteDir      = TbSiteDir.Text;

                var list = DataProvider.SiteDao.GetLowerSiteDirList(parentSiteId);
                if (list.IndexOf(siteDir.ToLower()) != -1)
                {
                    errorMessage = "已存在相同的发布路径!";
                    return(0);
                }

                if (!DirectoryUtils.IsDirectoryNameCompliant(siteDir))
                {
                    errorMessage = "文件夹名称不符合系统要求!";
                    return(0);
                }
                if (isRoot == false)//如果不是主站
                {
                    if (String.IsNullOrWhiteSpace(TbDomainName.Text))
                    {
                        errorMessage = "网站域名不能为空!";
                        return(0);
                    }
                    else
                    {
                        String[] domainNames = TbDomainName.Text.Split(';');
                        foreach (String domain in domainNames)
                        {
                            if (SystemManager.SiteList.ContainsKey(domain))
                            {
                                errorMessage = "域名“" + domain + "”已被其他网站占用,请选择其他域名!";
                                return(0);
                            }
                            else if (domainName.Length > 0)
                            {
                                domainName += ";" + domain;
                            }
                            else
                            {
                                domainName += ";" + domain;
                            }
                        }
                    }
                    if (domainName.Split(';').Length > 3)
                    {
                        errorMessage = "一个网站最多只能绑定3个域名,而您绑定了" + domainName.Split(';').Length + "个,请删除多余的域名!";
                        return(0);
                    }
                }
                var nodeInfo = new ChannelInfo();

                nodeInfo.ChannelName          = nodeInfo.IndexName = "首页";
                nodeInfo.ParentId             = 0;
                nodeInfo.ContentModelPluginId = string.Empty;

                var tableName = string.Empty;
                var tableRule = ETableRuleUtils.GetEnumType(RblTableRule.SelectedValue);
                if (tableRule == ETableRule.Choose)
                {
                    tableName = DdlTableChoose.SelectedValue;
                }
                else if (tableRule == ETableRule.HandWrite)
                {
                    tableName = TbTableHandWrite.Text;
                    if (!DataProvider.DatabaseDao.IsTableExists(tableName))
                    {
                        DataProvider.ContentDao.CreateContentTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                    }
                    else
                    {
                        DataProvider.DatabaseDao.AlterSystemTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                    }
                }

                var siteInfo = new SiteInfo
                {
                    SiteName   = AttackUtils.FilterXss(TbSiteName.Text),
                    DomainName = domainName,
                    SiteDir    = siteDir,
                    TableName  = tableName,
                    ParentId   = parentSiteId,
                    IsRoot     = isRoot
                };

                siteInfo.Additional.IsCheckContentLevel = TranslateUtils.ToBool(RblIsCheckContentUseLevel.SelectedValue);

                if (siteInfo.Additional.IsCheckContentLevel)
                {
                    siteInfo.Additional.CheckContentLevel = TranslateUtils.ToInt(DdlCheckContentLevel.SelectedValue);
                }
                siteInfo.Additional.Charset = DdlCharset.SelectedValue;

                var siteId = DataProvider.ChannelDao.InsertSiteInfo(nodeInfo, siteInfo, AuthRequest.AdminName);

                if (string.IsNullOrEmpty(tableName))
                {
                    tableName = ContentDao.GetContentTableName(siteId);
                    DataProvider.ContentDao.CreateContentTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                    DataProvider.SiteDao.UpdateTableName(siteId, tableName);
                }

                if (AuthRequest.AdminPermissionsImpl.IsSystemAdministrator && !AuthRequest.AdminPermissionsImpl.IsConsoleAdministrator)
                {
                    var siteIdList = AuthRequest.AdminPermissionsImpl.GetSiteIdList() ?? new List <int>();
                    siteIdList.Add(siteId);
                    var adminInfo = AdminManager.GetAdminInfoByUserId(AuthRequest.AdminId);
                    DataProvider.AdministratorDao.UpdateSiteIdCollection(adminInfo, TranslateUtils.ObjectCollectionToString(siteIdList));
                }

                AuthRequest.AddAdminLog("创建新站点", $"站点名称:{AttackUtils.FilterXss(TbSiteName.Text)}");

                errorMessage = string.Empty;
                return(siteId);
            }
            catch (Exception e)
            {
                errorMessage = e.Message;
                return(0);
            }
        }
        public ActionResult DetailBlogs(long id)
        {
            var mode = new ContentDao().ViewDetail(id);

            return(View(mode));
        }
        public ActionResult Blogs()
        {
            var mode = new ContentDao().newContent(5);

            return(PartialView(mode));
        }
        public ActionResult ViewDetail(long id)
        {
            var account = new ContentDao().GetByID(id);

            return(View(account));
        }
        public ActionResult Detail(long id)
        {
            var model = new ContentDao().GetByID(id);

            return(View(model));
        }
Beispiel #23
0
        public static async Task Execute(IJobContext context)
        {
            if (!CliUtils.ParseArgs(Options, context.Args))
            {
                return;
            }

            if (_isHelp)
            {
                PrintUsage();
                return;
            }

            if (string.IsNullOrEmpty(_directory))
            {
                await CliUtils.PrintErrorAsync("未指定需要转换至最新版本的备份数据文件夹:directory");

                return;
            }

            var oldTreeInfo = new TreeInfo(_directory);
            var newTreeInfo = new TreeInfo(Folder);

            if (!DirectoryUtils.IsDirectoryExists(oldTreeInfo.DirectoryPath))
            {
                await CliUtils.PrintErrorAsync($"备份数据的文件夹 {oldTreeInfo.DirectoryPath} 不存在");

                return;
            }
            DirectoryUtils.CreateDirectoryIfNotExists(newTreeInfo.DirectoryPath);

            var updater = new UpdaterManager(oldTreeInfo, newTreeInfo);

            var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            await Console.Out.WriteLineAsync($"备份数据文件夹: {oldTreeInfo.DirectoryPath},升级数据文件夹: {newTreeInfo.DirectoryPath},升级版本: {version.Substring(0, version.Length - 2)}");

            var oldTableNames = TranslateUtils.JsonDeserialize <List <string> >(await FileUtils.ReadTextAsync(oldTreeInfo.TablesFilePath, Encoding.UTF8));
            var newTableNames = new List <string>();

            await CliUtils.PrintRowLineAsync();

            await CliUtils.PrintRowAsync("备份表名称", "升级表名称", "总条数");

            await CliUtils.PrintRowLineAsync();

            var siteIdList = new List <int>();
            var tableNameListForContent     = new List <string>();
            var tableNameListForGovPublic   = new List <string>();
            var tableNameListForGovInteract = new List <string>();
            var tableNameListForJob         = new List <string>();

            UpdateUtils.LoadSites(oldTreeInfo, siteIdList,
                                  tableNameListForContent, tableNameListForGovPublic, tableNameListForGovInteract, tableNameListForJob);

            var splitSiteTableDict = new Dictionary <int, TableInfo>();

            if (_contentSplit)
            {
                var converter = ContentConverter.GetSplitConverter();
                foreach (var siteId in siteIdList)
                {
                    splitSiteTableDict.Add(siteId, new TableInfo
                    {
                        Columns    = converter.NewColumns,
                        TotalCount = 0,
                        RowFiles   = new List <string>()
                    });
                }
            }

            foreach (var oldTableName in oldTableNames)
            {
                var oldMetadataFilePath = oldTreeInfo.GetTableMetadataFilePath(oldTableName);

                if (!FileUtils.IsFileExists(oldMetadataFilePath))
                {
                    continue;
                }

                var oldTableInfo = TranslateUtils.JsonDeserialize <TableInfo>(await FileUtils.ReadTextAsync(oldMetadataFilePath, Encoding.UTF8));

                if (StringUtils.ContainsIgnoreCase(tableNameListForContent, oldTableName))
                {
                    if (_contentSplit)
                    {
                        var converter = ContentConverter.GetConverter(oldTableName, oldTableInfo.Columns);

                        await updater.UpdateSplitContentsTableInfoAsync(splitSiteTableDict, siteIdList, oldTableName,
                                                                        oldTableInfo, converter);
                    }
                    else
                    {
                        var converter = ContentConverter.GetConverter(oldTableName, oldTableInfo.Columns);
                        var tuple     = await updater.GetNewTableInfoAsync(oldTableName, oldTableInfo, converter);

                        if (tuple != null)
                        {
                            newTableNames.Add(tuple.Item1);

                            await FileUtils.WriteTextAsync(newTreeInfo.GetTableMetadataFilePath(tuple.Item1), Encoding.UTF8, TranslateUtils.JsonSerialize(tuple.Item2));
                        }
                    }
                }
                else
                {
                    var tuple = await updater.UpdateTableInfoAsync(oldTableName, oldTableInfo, tableNameListForGovPublic, tableNameListForGovInteract, tableNameListForJob);

                    if (tuple != null)
                    {
                        newTableNames.Add(tuple.Item1);

                        await FileUtils.WriteTextAsync(newTreeInfo.GetTableMetadataFilePath(tuple.Item1), Encoding.UTF8, TranslateUtils.JsonSerialize(tuple.Item2));
                    }
                }
            }

            if (_contentSplit)
            {
                foreach (var siteId in siteIdList)
                {
                    var siteTableInfo = splitSiteTableDict[siteId];
                    var siteTableName = ContentDao.GetContentTableName(siteId);
                    newTableNames.Add(siteTableName);

                    await FileUtils.WriteTextAsync(newTreeInfo.GetTableMetadataFilePath(siteTableName), Encoding.UTF8, TranslateUtils.JsonSerialize(siteTableInfo));
                }

                await UpdateUtils.UpdateSitesSplitTableNameAsync(newTreeInfo, splitSiteTableDict);
            }

            await FileUtils.WriteTextAsync(newTreeInfo.TablesFilePath, Encoding.UTF8, TranslateUtils.JsonSerialize(newTableNames));

            await CliUtils.PrintRowLineAsync();

            await Console.Out.WriteLineAsync($"恭喜,成功从备份文件夹:{oldTreeInfo.DirectoryPath} 升级至新版本:{newTreeInfo.DirectoryPath} !");
        }
Beispiel #24
0
        // GET: Content
        public ActionResult Index(int pageNumber = 1, int pageSize = 4)
        {
            var model = new ContentDao().Paging(pageNumber, pageSize);

            return(View(model));
        }
Beispiel #25
0
        public ActionResult Edit(long id)
        {
            var content = new ContentDao().ViewDetail(id);

            return(View(content));
        }
        public ActionResult Edit(int id)
        {
            var user = new ContentDao().ViewDetail(id);

            return(View(user));
        }
Beispiel #27
0
        // GET: Mesage/Details/5
        public ActionResult Details(long id)
        {
            ContentDao bdDao = new ContentDao();

            return(View(bdDao.FindByID(id)));
        }
Beispiel #28
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.SiteAdd))
                {
                    return(Unauthorized());
                }

                var createType          = request.GetPostString("createType");
                var createTemplateId    = request.GetPostString("createTemplateId");
                var siteName            = request.GetPostString("siteName");
                var isRoot              = request.GetPostBool("isRoot");
                var parentId            = request.GetPostInt("parentId");
                var siteDir             = request.GetPostString("siteDir");
                var domainName          = request.GetPostString("domainName");
                var tableRule           = ETableRuleUtils.GetEnumType(request.GetPostString("tableRule"));
                var tableChoose         = request.GetPostString("tableChoose");
                var tableHandWrite      = request.GetPostString("tableHandWrite");
                var isImportContents    = request.GetPostBool("isImportContents");
                var isImportTableStyles = request.GetPostBool("isImportTableStyles");

                if (!isRoot)
                {
                    if (DirectoryUtils.IsSystemDirectory(siteDir))
                    {
                        return(BadRequest("文件夹名称不能为系统文件夹名称,请更改文件夹名称!"));
                    }
                    if (!DirectoryUtils.IsDirectoryNameCompliant(siteDir))
                    {
                        return(BadRequest("文件夹名称不符合系统要求,请更改文件夹名称!"));
                    }
                    var list = DataProvider.SiteDao.GetLowerSiteDirList(parentId);
                    if (list.IndexOf(siteDir.ToLower()) != -1)
                    {
                        return(BadRequest("已存在相同的发布路径,请更改文件夹名称!"));
                    }
                }

                var channelInfo = new ChannelInfo();

                channelInfo.ChannelName          = channelInfo.IndexName = "首页";
                channelInfo.ParentId             = 0;
                channelInfo.ContentModelPluginId = string.Empty;

                var tableName = string.Empty;
                if (tableRule == ETableRule.Choose)
                {
                    tableName = tableChoose;
                }
                else if (tableRule == ETableRule.HandWrite)
                {
                    tableName = tableHandWrite;
                    if (!DataProvider.DatabaseDao.IsTableExists(tableName))
                    {
                        DataProvider.ContentDao.CreateContentTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                    }
                    else
                    {
                        DataProvider.DatabaseDao.AlterSystemTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                    }
                }

                var siteInfo = new SiteInfo
                {
                    SiteName   = AttackUtils.FilterXss(siteName),
                    SiteDir    = siteDir,
                    DomainName = domainName,
                    TableName  = tableName,
                    ParentId   = parentId,
                    IsRoot     = isRoot
                };

                siteInfo.Additional.IsCheckContentLevel = false;
                siteInfo.Additional.Charset             = ECharsetUtils.GetValue(ECharset.utf_8);

                var siteId = DataProvider.ChannelDao.InsertSiteInfo(channelInfo, siteInfo, request.AdminName);

                if (string.IsNullOrEmpty(tableName))
                {
                    tableName = ContentDao.GetContentTableName(siteId);
                    DataProvider.ContentDao.CreateContentTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                    DataProvider.SiteDao.UpdateTableName(siteId, tableName);
                }

                if (request.AdminPermissionsImpl.IsSystemAdministrator && !request.AdminPermissionsImpl.IsConsoleAdministrator)
                {
                    var siteIdList = request.AdminPermissionsImpl.GetSiteIdList() ?? new List <int>();
                    siteIdList.Add(siteId);
                    var adminInfo = AdminManager.GetAdminInfoByUserId(request.AdminId);
                    DataProvider.AdministratorDao.UpdateSiteIdCollection(adminInfo, TranslateUtils.ObjectCollectionToString(siteIdList));
                }

                var siteTemplateDir    = string.Empty;
                var onlineTemplateName = string.Empty;
                if (StringUtils.EqualsIgnoreCase(createType, "local"))
                {
                    siteTemplateDir = createTemplateId;
                }
                else if (StringUtils.EqualsIgnoreCase(createType, "cloud"))
                {
                    onlineTemplateName = createTemplateId;
                }

                var redirectUrl = PageProgressBar.GetCreateSiteUrl(siteId,
                                                                   isImportContents, isImportTableStyles, siteTemplateDir, onlineTemplateName, StringUtils.Guid());
                SystemManager.UpdateSites();
                return(Ok(new
                {
                    Value = redirectUrl
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #29
0
        public void Execute(string intentMessage, object parameter)
        {
            try
            {
                Console.WriteLine("[ServerMessageService][Execute] " + intentMessage);
                Console.WriteLine("[ServerMessageService][Execute] parameter = " + parameter);
                var memCache      = Container.GetInstance <IMemoryCache>();
                var intentManager = Container.GetInstance <IIntentManager>();

                if (intentMessage == "GETCATEGORY")
                {
                    var param = JsonConvert.DeserializeObject <GetCategoryParam>(parameter.ToString());

                    var dao_cat  = new CategoryDao();
                    var category = dao_cat.LoadCategory(param.CategoryId, param.OffsetSubCategory, param.LimitOffsetSubCategory);

                    var response = new CategoryDetailResponse();
                    response.Category    = category;
                    response.SubCategory = category.LinkSubCategoryList.ToArray();
                    response.Content     = category.LinkContentList.ToArray();

                    memCache.Set("ResponseCategory", response);

                    intentManager.AddIntent(ServiceType.Workflow, "RESPONSE_GETCATEGORY", null);
                }
                else if (intentMessage == "GETCATEGORYCONTENT")
                {
                    var categoryId = long.Parse(parameter.ToString());

                    var dao_cat  = new CategoryDao();
                    var category = dao_cat.LoadCategory(categoryId, 0, CategoryDao.MAXLIMIT);

                    var response = new CategoryDetailResponse();
                    response.Content = category.LinkContentList.ToArray();

                    memCache.Set("ResponseCategoryContent", response);

                    intentManager.AddIntent(ServiceType.Workflow, "RESPONSE_GETCATEGORYCONTENT", null);
                }
                else if (intentMessage == "GETCONTENT")
                {
                    var contentId = long.Parse(parameter.ToString());

                    var dao_content = new ContentDao();
                    var content     = dao_content.LoadContent(contentId);

                    var response = new ContentDetailResponse()
                    {
                        Content  = content,
                        Category = content.LinkCategory
                    };

                    memCache.Set("ResponsePreviewContent", response);

                    intentManager.AddIntent(ServiceType.Workflow, "RESPONSE_GETCONTENT", null);
                }
                else
                {
                    Console.WriteLine("Unknown MessageName " + intentMessage);
                }
            }
            catch (Exception expr)
            {
                Console.WriteLine(expr.Message);
            }
        }
Beispiel #30
0
 public ContentController()
 {
     contentDao  = new ContentDao();
     categoryDao = new CategoryDao();
 }
        public ActionResult ContentCategory()
        {
            var mode = new ContentDao().newContent(5);

            return(PartialView(mode));
        }