public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                var allRoles = EPredefinedRoleUtils.GetAllPredefinedRoleName();
                foreach (var roleName in allRoles)
                {
                    DataProvider.AdministratorsInRolesDao.RemoveUserFromRole(_userName, roleName);
                }
                DataProvider.AdministratorsInRolesDao.AddUserToRole(_userName, DdlPredefinedRole.SelectedValue);

                DataProvider.AdministratorDao.UpdateSiteIdCollection(_userName,
                                                                     EPredefinedRoleUtils.Equals(EPredefinedRole.SystemAdministrator, DdlPredefinedRole.SelectedValue)
                        ? ControlUtils.SelectedItemsValueToStringCollection(CblSiteId.Items)
                        : string.Empty);

                AuthRequest.AddAdminLog("设置管理员权限", $"管理员:{_userName}");

                SuccessMessage("权限设置成功!");
                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, "权限设置失败!");
            }

            if (isChanged)
            {
                var redirectUrl = PageAdministrator.GetRedirectUrl();
                LayerUtils.CloseAndRedirect(Page, redirectUrl);
            }
        }
Exemple #2
0
        private void UpdateByUpload()
        {
            if (HifFile.PostedFile == null || HifFile.PostedFile.FileName == "")
            {
                return;
            }

            var filePath = HifFile.PostedFile.FileName;

            if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".nupkg"))
            {
                FailMessage("必须上传后缀为.nupkg的文件");
                return;
            }

            var idAndVersion  = Path.GetFileNameWithoutExtension(filePath);
            var directoryPath = PathUtils.GetPackagesPath(idAndVersion);
            var localFilePath = PathUtils.Combine(directoryPath, idAndVersion + ".nupkg");

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            HifFile.PostedFile.SaveAs(localFilePath);

            ZipUtils.ExtractZip(localFilePath, directoryPath);

            AuthRequest.AddAdminLog("手动升级 SiteServer CMS 版本:" + idAndVersion);

            LayerUtils.CloseAndRedirect(Page, PageUtils.GetAdminUrl(PageUtils.Combine("plugins/manage.cshtml")));
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

            try
            {
                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

                nodeInfo.Additional.IsCreateChannelIfContentChanged  = TranslateUtils.ToBool(DdlIsCreateChannelIfContentChanged.SelectedValue);
                nodeInfo.Additional.CreateChannelIDsIfContentChanged = ControlUtils.GetSelectedListControlValueCollection(LbChannelId);

                DataProvider.ChannelDao.Update(nodeInfo);

                Body.AddSiteLog(SiteId, _channelId, 0, "设置栏目变动生成页面", $"栏目:{nodeInfo.ChannelName}");
                isSuccess = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }

            if (isSuccess)
            {
                LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateTrigger.GetRedirectUrl(SiteId, _channelId));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

            try
            {
                _channelInfo.Additional.TransType         = ECrossSiteTransTypeUtils.GetEnumType(DdlTransType.SelectedValue);
                _channelInfo.Additional.TransSiteId       = _channelInfo.Additional.TransType == ECrossSiteTransType.SpecifiedSite ? TranslateUtils.ToInt(DdlSiteId.SelectedValue) : 0;
                _channelInfo.Additional.TransChannelIds   = ControlUtils.GetSelectedListControlValueCollection(LbChannelId);
                _channelInfo.Additional.TransChannelNames = TbNodeNames.Text;

                _channelInfo.Additional.TransIsAutomatic = TranslateUtils.ToBool(DdlIsAutomatic.SelectedValue);

                var translateDoneType = ETranslateContentTypeUtils.GetEnumType(DdlTranslateDoneType.SelectedValue);
                _channelInfo.Additional.TransDoneType = translateDoneType;

                DataProvider.ChannelDao.Update(_channelInfo);

                Body.AddSiteLog(SiteId, "修改跨站转发设置");

                isSuccess = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }

            if (isSuccess)
            {
                LayerUtils.CloseAndRedirect(Page, PageConfigurationCrossSiteTrans.GetRedirectUrl(SiteId, _channelInfo.Id));
            }
        }
Exemple #5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var fileCount = TranslateUtils.ToInt(Request.Form["File_Count"]);

            if (fileCount == 1)
            {
                var fileName    = Request.Form["fileName_1"];
                var redirectUrl = WebUtils.GetContentAddUploadWordUrl(SiteId, _channelInfo, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue), fileName, _returnUrl);
                LayerUtils.CloseAndRedirect(Page, redirectUrl);

                return;
            }
            if (fileCount > 1)
            {
                var tableName         = ChannelManager.GetTableName(SiteInfo, _channelInfo);
                var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelInfo.Id);
                var styleInfoList     = TableStyleManager.GetTableStyleInfoList(tableName, relatedIdentities);

                for (var index = 1; index <= fileCount; index++)
                {
                    var fileName = Request.Form["fileName_" + index];
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        var formCollection = WordUtils.GetWordNameValueCollection(SiteId, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToInt(DdlContentLevel.SelectedValue), fileName);

                        if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title]))
                        {
                            var contentInfo = new ContentInfo();

                            BackgroundInputTypeParser.SaveAttributes(contentInfo, SiteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributesLowercase);

                            contentInfo.ChannelId        = _channelInfo.Id;
                            contentInfo.SiteId           = SiteId;
                            contentInfo.AddUserName      = Body.AdminName;
                            contentInfo.AddDate          = DateTime.Now;
                            contentInfo.LastEditUserName = contentInfo.AddUserName;
                            contentInfo.LastEditDate     = contentInfo.AddDate;

                            contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                            contentInfo.IsChecked    = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;

                            contentInfo.Id = DataProvider.ContentDao.Insert(tableName, SiteInfo, contentInfo);

                            if (contentInfo.IsChecked)
                            {
                                CreateManager.CreateContentAndTrigger(SiteId, _channelInfo.Id, contentInfo.Id);
                            }
                        }
                    }
                }
            }

            LayerUtils.Close(Page);
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = InsertOrUpdateTableStyleInfo();

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _redirectUrl);
            }
        }
Exemple #7
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue);

            var isChanged = InsertTableStyleInfo(inputType);

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _redirectUrl);
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var channelId   = AuthRequest.GetQueryInt("channelId");
            var channelInfo = ChannelManager.GetChannelInfo(SiteId, channelId);

            _tableName = ChannelManager.GetTableName(SiteInfo, channelInfo);

            DataProvider.ContentDao.UpdateArrangeTaxis(SiteId, _tableName, channelId, DdlAttributeName.SelectedValue, TranslateUtils.ToBool(DdlIsDesc.SelectedValue));

            LayerUtils.CloseAndRedirect(Page, _returnUrl);
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var templateLogId = TranslateUtils.ToInt(DdlLogId.SelectedValue);

            if (templateLogId == 0)
            {
                FailMessage("当前模板不存在历史版本,无法进行还原");
            }
            else
            {
                LayerUtils.CloseAndRedirect(Page, PageTemplateAdd.GetRedirectUrlToRestore(SiteId, _templateId, templateLogId));
            }
        }
Exemple #10
0
        private void UpdateByVersion()
        {
            //string errorMessage;
            //if (!SystemManager.GetPackageAndUpdate(TbVersion.Text, out errorMessage))
            //{
            //    FailMessage($"手动升级 SiteServer CMS 版本失败:{errorMessage}");
            //    return;
            //}

            AuthRequest.AddAdminLog($"手动升级 SiteServer CMS 版本:{TbVersion.Text}");

            LayerUtils.CloseAndRedirect(Page, PageUtils.GetAdminUrl(PageUtils.Combine("plugins/manage.cshtml")));
        }
        private void UpdateByVersion()
        {
            //string errorMessage;
            //if (!SystemManager.GetPackageAndUpdate(TbVersion.Text, out errorMessage))
            //{
            //    FailMessage($"手动升级 SiteServer CMS 版本失败:{errorMessage}");
            //    return;
            //}

            Body.AddAdminLog($"手动升级 SiteServer CMS 版本:{TbVersion.Text}");

            LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isUp     = DdlTaxisType.SelectedValue == "Up";
            var taxisNum = TranslateUtils.ToInt(TbTaxisNum.Text);

            var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

            if (ETaxisTypeUtils.Equals(nodeInfo.Additional.DefaultTaxisType, ETaxisType.OrderByTaxis))
            {
                isUp = !isUp;
            }

            if (isUp == false)
            {
                _contentIdList.Reverse();
            }

            foreach (var contentId in _contentIdList)
            {
                var tuple = DataProvider.ContentDao.GetValue(_tableName, contentId, ContentAttribute.IsTop);
                if (tuple == null)
                {
                    continue;
                }

                var isTop = TranslateUtils.ToBool(tuple.Item2);
                for (var i = 1; i <= taxisNum; i++)
                {
                    if (isUp)
                    {
                        if (DataProvider.ContentDao.SetTaxisToUp(SiteId, _tableName, _channelId, contentId, isTop) == false)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (DataProvider.ContentDao.SetTaxisToDown(SiteId, _tableName, _channelId, contentId, isTop) == false)
                        {
                            break;
                        }
                    }
                }
            }

            CreateManager.TriggerContentChangedEvent(SiteId, _channelId);
            AuthRequest.AddSiteLog(SiteId, _channelId, 0, "对内容排序", string.Empty);

            LayerUtils.CloseAndRedirect(Page, _returnUrl);
        }
        private void ImportSiteTemplate(bool isUpload)
        {
            if (isUpload)
            {
                if (!string.IsNullOrEmpty(HifFile.PostedFile?.FileName))
                {
                    var filePath = HifFile.PostedFile.FileName;
                    var sExt     = PathUtils.GetExtension(filePath);
                    if (!StringUtils.EqualsIgnoreCase(sExt, ".zip"))
                    {
                        FailMessage("站点模板压缩包为zip格式,请选择有效的文件上传");
                        return;
                    }
                    try
                    {
                        var directoryName = PathUtils.GetFileNameWithoutExtension(filePath);
                        var directoryPath = PathUtility.GetSiteTemplatesPath(directoryName);
                        if (DirectoryUtils.IsDirectoryExists(directoryPath))
                        {
                            FailMessage($"站点模板导入失败,文件夹{directoryName}已存在");
                            return;
                        }
                        var localFilePath = PathUtility.GetSiteTemplatesPath(directoryName + ".zip");
                        FileUtils.DeleteFileIfExists(localFilePath);

                        HifFile.PostedFile.SaveAs(localFilePath);

                        ZipUtils.ExtractZip(localFilePath, directoryPath);

                        LayerUtils.CloseAndRedirect(Page, PageSiteTemplate.GetRedirectUrl());
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "文件上传失败!");
                    }
                }
            }
            else
            {
                var sExt = PathUtils.GetExtension(TbDownloadUrl.Text);
                if (!StringUtils.EqualsIgnoreCase(sExt, ".zip"))
                {
                    FailMessage("站点模板压缩包为zip格式,请输入有效文件地址");
                    return;
                }

                PageUtils.Redirect(ModalProgressBar.GetRedirectUrlStringWithSiteTemplateDownload(0, TbDownloadUrl.Text));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                if (_departmentId == 0)
                {
                    var departmentInfo = new DepartmentInfo
                    {
                        DepartmentName = TbDepartmentName.Text,
                        Code           = TbCode.Text,
                        ParentId       = TranslateUtils.ToInt(DdlParentId.SelectedValue),
                        Summary        = TbSummary.Text
                    };

                    DataProvider.DepartmentDao.Insert(departmentInfo);
                }
                else
                {
                    var departmentInfo = DepartmentManager.GetDepartmentInfo(_departmentId);

                    departmentInfo.DepartmentName = TbDepartmentName.Text;
                    departmentInfo.Code           = TbCode.Text;
                    departmentInfo.ParentId       = TranslateUtils.ToInt(DdlParentId.SelectedValue);
                    departmentInfo.Summary        = TbSummary.Text;

                    DataProvider.DepartmentDao.Update(departmentInfo);
                }

                Body.AddAdminLog("维护部门信息");

                SuccessMessage("部门设置成功!");
                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, "部门设置失败!");
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _returnUrl);
            }
        }
Exemple #15
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                if (_areaId == 0)
                {
                    var areaInfo = new AreaInfo
                    {
                        AreaName = TbAreaName.Text,
                        ParentId = TranslateUtils.ToInt(DdlParentId.SelectedValue)
                    };

                    DataProvider.AreaDao.Insert(areaInfo);
                }
                else
                {
                    var areaInfo = AreaManager.GetAreaInfo(_areaId);

                    areaInfo.AreaName = TbAreaName.Text;
                    areaInfo.ParentId = TranslateUtils.ToInt(DdlParentId.SelectedValue);

                    DataProvider.AreaDao.Update(areaInfo);
                }

                AuthRequest.AddAdminLog("维护区域信息");

                SuccessMessage("区域设置成功!");
                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, "区域设置失败!");
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _returnUrl);
            }
        }
Exemple #16
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;

            try
            {
                var itemNameArray = TbItemNames.Text.Split('\n');
                foreach (var item in itemNameArray)
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    var itemName  = item.Trim();
                    var itemValue = itemName;

                    if (itemName.IndexOf('|') != -1)
                    {
                        itemValue = itemName.Substring(itemName.IndexOf('|') + 1);
                        itemName  = itemName.Substring(0, itemName.IndexOf('|'));
                    }

                    var itemInfo = new RelatedFieldItemInfo(0, _relatedFieldId, itemName, itemValue, _parentId, 0);
                    DataProvider.RelatedFieldItemDao.Insert(itemInfo);
                }

                isChanged = true;
            }
            catch
            {
                isChanged = false;
                FailMessage("添加字段项出错!");
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, PageRelatedFieldItem.GetRedirectUrl(SiteId, _relatedFieldId, _parentId, _level));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!DirectoryUtils.IsDirectoryNameCompliant(TbFileName.Text))
            {
                FailMessage("文件名称不符合要求");
                return;
            }

            var path = PathUtils.Combine(_directoryPath, TbFileName.Text);
            if (FileUtils.IsFileExists(path))
            {
                FailMessage("文件已经存在");
                return;
            }
            var pathSource = PathUtils.Combine(_directoryPath, LtlFileName.Text);
            FileUtils.MoveFile(pathSource, path, true);
            FileUtils.DeleteFileIfExists(pathSource);

            AuthRequest.AddSiteLog(SiteId, "修改文件名", $"文件名:{TbFileName.Text}");
            //JsUtils.SubModal.CloseModalPageWithoutRefresh(Page);
            LayerUtils.CloseAndRedirect(Page, RedirectUrl());
        }
Exemple #18
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var tableName = ChannelManager.GetTableName(SiteInfo, _channelId);

            ArchiveManager.CreateArchiveTableIfNotExists(SiteInfo, tableName);
            var tableNameOfArchive = TableMetadataManager.GetTableNameOfArchive(tableName);

            foreach (var contentId in _contentIdList)
            {
                var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
                contentInfo.LastEditDate = DateTime.Now;
                DataProvider.ContentDao.Insert(tableNameOfArchive, SiteInfo, contentInfo);
            }

            DataProvider.ContentDao.DeleteContents(SiteId, tableName, _contentIdList, _channelId);

            CreateManager.CreateContentTrigger(SiteId, _channelId);

            Body.AddSiteLog(SiteId, _channelId, 0, "归档内容", string.Empty);

            LayerUtils.CloseAndRedirect(Page, _returnUrl);
        }
Exemple #19
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;

            var inputType = InputTypeUtils.GetEnumType(DdlInputType.SelectedValue);

            if (inputType == InputType.Radio || inputType == InputType.SelectMultiple || inputType == InputType.SelectOne)
            {
                var isRapid = TranslateUtils.ToBool(DdlIsRapid.SelectedValue);
                if (!isRapid)
                {
                    var itemCount = TranslateUtils.ToInt(TbItemCount.Text);
                    if (itemCount == 0)
                    {
                        FailMessage("操作失败,选项数目不能为0!");
                        return;
                    }
                }
            }

            if (_styleInfo.Id == 0 && _styleInfo.RelatedIdentity == 0)//数据库中没有此项及父项的表样式
            {
                isChanged = InsertTableStyleInfo(inputType);
            }
            else if (_styleInfo.RelatedIdentity != _relatedIdentities[0])//数据库中没有此项的表样式,但是有父项的表样式
            {
                isChanged = InsertTableStyleInfo(inputType);
            }
            else//数据库中有此项的表样式
            {
                isChanged = UpdateTableStyleInfo(inputType);
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _redirectUrl);
            }
        }
Exemple #20
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

            try
            {
                var assetsDir = TbDirectoryPath.Text.Trim('/');
                if (_type == PageTemplateAssets.TypeInclude)
                {
                    SiteInfo.Additional.TemplatesAssetsIncludeDir = assetsDir;
                }
                else if (_type == PageTemplateAssets.TypeJs)
                {
                    SiteInfo.Additional.TemplatesAssetsJsDir = assetsDir;
                }
                else if (_type == PageTemplateAssets.TypeCss)
                {
                    SiteInfo.Additional.TemplatesAssetsCssDir = assetsDir;
                }

                DataProvider.SiteDao.Update(SiteInfo);

                AuthRequest.AddSiteLog(SiteId, "模板文件夹设置");

                isSuccess = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }

            if (isSuccess)
            {
                LayerUtils.CloseAndRedirect(Page, PageTemplateAssets.GetRedirectUrl(SiteId, _type));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;

            try
            {
                var itemInfo = DataProvider.RelatedFieldItemDao.GetRelatedFieldItemInfo(_id);
                itemInfo.ItemName  = TbItemName.Text;
                itemInfo.ItemValue = TbItemValue.Text;
                DataProvider.RelatedFieldItemDao.Update(itemInfo);

                isChanged = true;
            }
            catch (Exception ex)
            {
                isChanged = false;
                FailMessage(ex, ex.Message);
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, PageRelatedFieldItem.GetRedirectUrl(SiteId, _relatedFieldId, _parentId, _level));
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlCheckType.SelectedValue);

            var isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;

            var contentInfoArrayListToCheck = new List <ContentInfo>();
            var idsDictionaryToCheck        = new Dictionary <int, List <int> >();

            foreach (var channelId in _idsDictionary.Keys)
            {
                var tableName            = ChannelManager.GetTableName(SiteInfo, channelId);
                var contentIdList        = _idsDictionary[channelId];
                var contentIdListToCheck = new List <int>();

                int checkedLevelOfUser;
                var isCheckedOfUser = CheckManager.GetUserCheckLevel(Body.AdminName, SiteInfo, channelId, out checkedLevelOfUser);

                foreach (var contentId in contentIdList)
                {
                    var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
                    if (contentInfo != null)
                    {
                        if (CheckManager.IsCheckable(SiteInfo, contentInfo.ChannelId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            contentInfoArrayListToCheck.Add(contentInfo);
                            contentIdListToCheck.Add(contentId);
                        }

                        DataProvider.ContentDao.Update(tableName, SiteInfo, contentInfo);

                        if (contentInfo.IsChecked)
                        {
                            CreateManager.CreateContentAndTrigger(SiteId, contentInfo.ChannelId, contentId);
                        }
                    }
                }
                if (contentIdListToCheck.Count > 0)
                {
                    idsDictionaryToCheck[channelId] = contentIdListToCheck;
                }
            }

            if (contentInfoArrayListToCheck.Count == 0)
            {
                LayerUtils.CloseWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');");
            }
            else
            {
                try
                {
                    var translateChannelId = TranslateUtils.ToInt(DdlTranslateChannelId.SelectedValue);

                    foreach (var channelId in idsDictionaryToCheck.Keys)
                    {
                        var tableName     = ChannelManager.GetTableName(SiteInfo, channelId);
                        var contentIdList = idsDictionaryToCheck[channelId];
                        DataProvider.ContentDao.UpdateIsChecked(tableName, SiteId, channelId, contentIdList, translateChannelId, true, Body.AdminName, isChecked, checkedLevel, TbCheckReasons.Text);

                        DataProvider.ChannelDao.UpdateContentNum(SiteInfo, channelId, true);
                    }

                    if (translateChannelId > 0)
                    {
                        DataProvider.ChannelDao.UpdateContentNum(SiteInfo, translateChannelId, true);
                    }

                    Body.AddSiteLog(SiteId, SiteId, 0, "设置内容状态为" + DdlCheckType.SelectedItem.Text, TbCheckReasons.Text);

                    if (isChecked)
                    {
                        foreach (var channelId in idsDictionaryToCheck.Keys)
                        {
                            var contentIdList = _idsDictionary[channelId];
                            if (contentIdList != null)
                            {
                                foreach (var contentId in contentIdList)
                                {
                                    CreateManager.CreateContent(SiteId, channelId, contentId);
                                }
                            }
                        }
                    }

                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败!");
                }
            }
        }
Exemple #23
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var checkedLevel = TranslateUtils.ToIntWithNagetive(DdlCheckType.SelectedValue);

            var isChecked = checkedLevel >= SiteInfo.Additional.CheckContentLevel;

            var contentInfoListToCheck = new List <ContentInfo>();
            var idsDictionaryToCheck   = new Dictionary <int, List <int> >();

            foreach (var channelId in _idsDictionary.Keys)
            {
                var channelInfo          = ChannelManager.GetChannelInfo(SiteInfo.Id, channelId);
                var contentIdList        = _idsDictionary[channelId];
                var contentIdListToCheck = new List <int>();

                int checkedLevelOfUser;
                var isCheckedOfUser = CheckManager.GetUserCheckLevel(AuthRequest.AdminPermissionsImpl, SiteInfo, channelId, out checkedLevelOfUser);

                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(SiteInfo, channelInfo, contentId);
                    if (contentInfo != null)
                    {
                        if (CheckManager.IsCheckable(contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            contentInfoListToCheck.Add(contentInfo);
                            contentIdListToCheck.Add(contentId);
                        }

                        //DataProvider.ContentDao.Update(SiteInfo, channelInfo, contentInfo);

                        //CreateManager.CreateContent(SiteId, contentInfo.ChannelId, contentId);
                        //CreateManager.TriggerContentChangedEvent(SiteId, contentInfo.ChannelId);
                    }
                }
                if (contentIdListToCheck.Count > 0)
                {
                    idsDictionaryToCheck[channelId] = contentIdListToCheck;
                }
            }

            if (contentInfoListToCheck.Count == 0)
            {
                LayerUtils.CloseWithoutRefresh(Page, "alert('您的审核权限不足,无法审核所选内容!');");
                return;
            }

            var translateChannelId = TranslateUtils.ToInt(DdlTranslateChannelId.SelectedValue);

            foreach (var channelId in idsDictionaryToCheck.Keys)
            {
                var tableName     = ChannelManager.GetTableName(SiteInfo, channelId);
                var contentIdList = idsDictionaryToCheck[channelId];
                DataProvider.ContentDao.UpdateIsChecked(tableName, SiteId, channelId, contentIdList, translateChannelId, AuthRequest.AdminName, isChecked, checkedLevel, TbCheckReasons.Text);
            }

            if (translateChannelId > 0)
            {
                var tableName = ChannelManager.GetTableName(SiteInfo, translateChannelId);
                ContentManager.RemoveCache(tableName, translateChannelId);
            }

            AuthRequest.AddSiteLog(SiteId, SiteId, 0, "设置内容状态为" + DdlCheckType.SelectedItem.Text, TbCheckReasons.Text);

            foreach (var channelId in idsDictionaryToCheck.Keys)
            {
                var contentIdList = _idsDictionary[channelId];
                if (contentIdList != null)
                {
                    foreach (var contentId in contentIdList)
                    {
                        CreateManager.CreateContent(SiteId, channelId, contentId);
                        CreateManager.TriggerContentChangedEvent(SiteId, channelId);
                    }
                }
            }

            LayerUtils.CloseAndRedirect(Page, _returnUrl);
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

            try
            {
                var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

                var filePath = channelInfo.FilePath;

                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = TbFilePath.Text.Trim();
                    if (!string.IsNullOrEmpty(TbFilePath.Text) && !StringUtils.EqualsIgnoreCase(filePath, TbFilePath.Text))
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                        {
                            TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                        filePathArrayList.AddRange(DataProvider.TemplateMatchDao.GetAllFilePathBySiteId(SiteId));
                        if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(TbChannelFilePathRule.Text))
                {
                    var filePathRule = TbChannelFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("栏目页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("栏目页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(TbContentFilePathRule.Text))
                {
                    var filePathRule = TbContentFilePathRule.Text.Replace("|", string.Empty);
                    if (!DirectoryUtils.IsDirectoryNameCompliant(filePathRule))
                    {
                        FailMessage("内容页面命名规则不符合系统要求!");
                        return;
                    }
                    if (PathUtils.IsDirectoryPath(filePathRule))
                    {
                        FailMessage("内容页面命名规则必须包含生成文件的后缀!");
                        return;
                    }
                }

                if (TbFilePath.Text != PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false))
                {
                    channelInfo.FilePath = TbFilePath.Text;
                }
                if (TbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(SiteInfo, _channelId))
                {
                    channelInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                }
                if (TbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(SiteInfo, _channelId))
                {
                    channelInfo.ContentFilePathRule = TbContentFilePathRule.Text;
                }

                DataProvider.ChannelDao.Update(channelInfo);

                CreateManager.CreateChannel(SiteId, _channelId);

                AuthRequest.AddSiteLog(SiteId, _channelId, 0, "设置页面命名规则", $"栏目:{channelInfo.ChannelName}");

                isSuccess = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }

            if (isSuccess)
            {
                LayerUtils.CloseAndRedirect(Page, PageConfigurationCreateRule.GetRedirectUrl(SiteId, _channelId));
            }
        }
Exemple #25
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;
            var  parentChannelId = TranslateUtils.ToInt(Request.Form["channelId"]);

            if (parentChannelId == 0)
            {
                parentChannelId = SiteId;
            }

            try
            {
                if (string.IsNullOrEmpty(TbNodeNames.Text))
                {
                    FailMessage("请填写需要添加的栏目名称");
                    return;
                }

                var insertedChannelIdHashtable = new Hashtable {
                    [1] = parentChannelId
                };                                                                      //key为栏目的级别,1为第一级栏目

                var           nodeNameArray     = TbNodeNames.Text.Split('\n');
                List <string> nodeIndexNameList = null;
                foreach (var item in nodeNameArray)
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }

                    //count为栏目的级别
                    var count     = (StringUtils.GetStartCount('-', item) == 0) ? StringUtils.GetStartCount('-', item) : StringUtils.GetStartCount('-', item);
                    var nodeName  = item.Substring(count, item.Length - count);
                    var nodeIndex = string.Empty;
                    count++;

                    if (!string.IsNullOrEmpty(nodeName) && insertedChannelIdHashtable.Contains(count))
                    {
                        if (CbIsNameToIndex.Checked)
                        {
                            nodeIndex = nodeName.Trim();
                        }

                        if (StringUtils.Contains(nodeName, "(") && StringUtils.Contains(nodeName, ")"))
                        {
                            var length = nodeName.IndexOf(')') - nodeName.IndexOf('(');
                            if (length > 0)
                            {
                                nodeIndex = nodeName.Substring(nodeName.IndexOf('(') + 1, length);
                                nodeName  = nodeName.Substring(0, nodeName.IndexOf('('));
                            }
                        }
                        nodeName  = nodeName.Trim();
                        nodeIndex = nodeIndex.Trim(' ', '(', ')');
                        if (!string.IsNullOrEmpty(nodeIndex))
                        {
                            if (nodeIndexNameList == null)
                            {
                                nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                            }
                            if (nodeIndexNameList.IndexOf(nodeIndex) != -1)
                            {
                                nodeIndex = string.Empty;
                            }
                            else
                            {
                                nodeIndexNameList.Add(nodeIndex);
                            }
                        }

                        var parentId             = (int)insertedChannelIdHashtable[count];
                        var contentModelPluginId = DdlContentModelPluginId.SelectedValue;
                        if (string.IsNullOrEmpty(contentModelPluginId))
                        {
                            var parentNodeInfo = ChannelManager.GetChannelInfo(SiteId, parentId);
                            contentModelPluginId = parentNodeInfo.ContentModelPluginId;
                        }

                        var channelTemplateId = TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue);
                        var contentTemplateId = TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue);

                        var insertedChannelId = DataProvider.ChannelDao.Insert(SiteId, parentId, nodeName, nodeIndex, contentModelPluginId, ControlUtils.GetSelectedListControlValueCollection(CblContentRelatedPluginIds), channelTemplateId, contentTemplateId);
                        insertedChannelIdHashtable[count + 1] = insertedChannelId;

                        CreateManager.CreateChannel(SiteId, insertedChannelId);
                    }
                }

                AuthRequest.AddSiteLog(SiteId, parentChannelId, 0, "快速添加栏目", $"父栏目:{ChannelManager.GetChannelName(SiteId, parentChannelId)},栏目:{TbNodeNames.Text.Replace('\n', ',')}");

                isChanged = true;
            }
            catch (Exception ex)
            {
                isChanged = false;
                FailMessage(ex, ex.Message);
            }

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _returnUrl);
            }
        }
Exemple #26
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (TranslateUtils.ToBool(RblInstallType.SelectedValue))
            {
                if (HifFile.PostedFile == null || HifFile.PostedFile.FileName == "")
                {
                    return;
                }

                var filePath = HifFile.PostedFile.FileName;
                if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".nupkg"))
                {
                    FailMessage("必须上传后缀为.nupkg的文件");
                    return;
                }

                var idAndVersion  = Path.GetFileNameWithoutExtension(filePath);
                var directoryPath = PathUtils.GetPackagesPath(idAndVersion);
                var localFilePath = PathUtils.Combine(directoryPath, idAndVersion + ".nupkg");

                if (!Directory.Exists(directoryPath))
                {
                    Directory.CreateDirectory(directoryPath);
                }

                HifFile.PostedFile.SaveAs(localFilePath);

                ZipUtils.ExtractZip(localFilePath, directoryPath);

                string errorMessage;
                if (!PackageUtils.UpdatePackage(idAndVersion, PackageType.Plugin, out errorMessage))
                {
                    FailMessage($"手动安装插件失败:{errorMessage}");
                    return;
                }

                AuthRequest.AddAdminLog("手动安装插件:" + idAndVersion);

                LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
            }
            else
            {
                string errorMessage;
                try
                {
                    PackageUtils.DownloadPackage(TbPluginId.Text, TbVersion.Text);
                }
                catch (Exception ex)
                {
                    FailMessage($"手动安装插件失败:{ex.Message}");
                    return;
                }

                var idWithVersion = $"{TbPluginId.Text}.{TbVersion.Text}";
                if (!PackageUtils.UpdatePackage(idWithVersion, PackageType.Plugin, out errorMessage))
                {
                    FailMessage($"手动安装插件失败:{errorMessage}");
                    return;
                }

                AuthRequest.AddAdminLog($"手动安装插件:{TbPluginId.Text} {TbVersion.Text}");

                LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl());
            }
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var fileNames = TranslateUtils.StringCollectionToStringList(HihFileNames.Value);

            if (fileNames.Count == 1)
            {
                var fileName = fileNames[0];
                if (!string.IsNullOrEmpty(fileName))
                {
                    var redirectUrl = WebUtils.GetContentAddUploadWordUrl(SiteId, _channelInfo, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue), fileName, _returnUrl);
                    LayerUtils.CloseAndRedirect(Page, redirectUrl);
                }

                return;
            }

            if (fileNames.Count > 1)
            {
                var tableName     = ChannelManager.GetTableName(SiteInfo, _channelInfo);
                var styleInfoList = TableStyleManager.GetContentStyleInfoList(SiteInfo, _channelInfo);

                foreach (var fileName in fileNames)
                {
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        var formCollection = WordUtils.GetWordNameValueCollection(SiteId, CbIsFirstLineTitle.Checked, CbIsFirstLineRemove.Checked, CbIsClearFormat.Checked, CbIsFirstLineIndent.Checked, CbIsClearFontSize.Checked, CbIsClearFontFamily.Checked, CbIsClearImages.Checked, fileName);

                        if (!string.IsNullOrEmpty(formCollection[ContentAttribute.Title]))
                        {
                            var dict = BackgroundInputTypeParser.SaveAttributes(SiteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributes.Value);

                            var contentInfo = new ContentInfo(dict)
                            {
                                ChannelId   = _channelInfo.Id,
                                SiteId      = SiteId,
                                AddUserName = AuthRequest.AdminName,
                                AddDate     = DateTime.Now
                            };

                            contentInfo.LastEditUserName = contentInfo.AddUserName;
                            contentInfo.LastEditDate     = contentInfo.AddDate;

                            contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(DdlContentLevel.SelectedValue);
                            contentInfo.IsChecked    = contentInfo.CheckedLevel >= SiteInfo.Additional.CheckContentLevel;

                            contentInfo.Title = formCollection[ContentAttribute.Title];

                            contentInfo.Id = DataProvider.ContentDao.Insert(tableName, SiteInfo, _channelInfo, contentInfo);

                            CreateManager.CreateContent(SiteId, _channelInfo.Id, contentInfo.Id);
                            CreateManager.TriggerContentChangedEvent(SiteId, _channelInfo.Id);
                        }
                    }
                }
            }

            LayerUtils.Close(Page);
        }
Exemple #28
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var isChanged = false;

            try
            {
                var nodeInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);

                if (!nodeInfo.IndexName.Equals(TbNodeIndexName.Text) && TbNodeIndexName.Text.Length != 0)
                {
                    var nodeIndexNameList = DataProvider.ChannelDao.GetIndexNameList(SiteId);
                    if (nodeIndexNameList.IndexOf(TbNodeIndexName.Text) != -1)
                    {
                        FailMessage("栏目修改失败,栏目索引已存在!");
                        return;
                    }
                }

                if (PhFilePath.Visible)
                {
                    TbFilePath.Text = TbFilePath.Text.Trim();
                    if (!nodeInfo.FilePath.Equals(TbFilePath.Text) && TbFilePath.Text.Length != 0)
                    {
                        if (!DirectoryUtils.IsDirectoryNameCompliant(TbFilePath.Text))
                        {
                            FailMessage("栏目页面路径不符合系统要求!");
                            return;
                        }

                        if (PathUtils.IsDirectoryPath(TbFilePath.Text))
                        {
                            TbFilePath.Text = PageUtils.Combine(TbFilePath.Text, "index.html");
                        }

                        var filePathArrayList = DataProvider.ChannelDao.GetAllFilePathBySiteId(SiteId);
                        if (filePathArrayList.IndexOf(TbFilePath.Text) != -1)
                        {
                            FailMessage("栏目修改失败,栏目页面路径已存在!");
                            return;
                        }
                    }
                }

                var extendedAttributes = new ExtendedAttributes();
                var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
                var styleInfoList      = TableStyleManager.GetTableStyleInfoList(DataProvider.ChannelDao.TableName,
                                                                                 relatedIdentities);
                BackgroundInputTypeParser.SaveAttributes(extendedAttributes, SiteInfo, styleInfoList, Request.Form, null);
                if (extendedAttributes.ToNameValueCollection().Count > 0)
                {
                    nodeInfo.Additional.Load(extendedAttributes.ToNameValueCollection());
                }

                nodeInfo.ChannelName = TbNodeName.Text;
                nodeInfo.IndexName   = TbNodeIndexName.Text;
                if (PhFilePath.Visible)
                {
                    nodeInfo.FilePath = TbFilePath.Text;
                }

                var list = new ArrayList();
                foreach (ListItem item in CblNodeGroupNameCollection.Items)
                {
                    if (item.Selected)
                    {
                        list.Add(item.Value);
                    }
                }
                nodeInfo.GroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                nodeInfo.ImageUrl            = TbImageUrl.Text;
                nodeInfo.Content             = ContentUtility.TextEditorContentEncode(SiteInfo, Request.Form[ChannelAttribute.Content]);
                if (TbKeywords.Visible)
                {
                    nodeInfo.Keywords = TbKeywords.Text;
                }
                if (TbDescription.Visible)
                {
                    nodeInfo.Description = TbDescription.Text;
                }

                if (PhLinkUrl.Visible)
                {
                    nodeInfo.LinkUrl = TbLinkUrl.Text;
                }
                if (PhLinkType.Visible)
                {
                    nodeInfo.LinkType = DdlLinkType.SelectedValue;
                }
                nodeInfo.Additional.DefaultTaxisType = ETaxisTypeUtils.GetValue(ETaxisTypeUtils.GetEnumType(DdlTaxisType.SelectedValue));
                if (PhChannelTemplateId.Visible)
                {
                    nodeInfo.ChannelTemplateId = DdlChannelTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlChannelTemplateId.SelectedValue) : 0;
                }
                nodeInfo.ContentTemplateId = DdlContentTemplateId.Items.Count > 0 ? TranslateUtils.ToInt(DdlContentTemplateId.SelectedValue) : 0;

                DataProvider.ChannelDao.Update(nodeInfo);

                AuthRequest.AddSiteLog(SiteId, _channelId, 0, "修改栏目", $"栏目:{nodeInfo.ChannelName}");

                isChanged = true;
            }
            catch (Exception ex)
            {
                FailMessage(ex, $"栏目修改失败:{ex.Message}");
                LogUtils.AddErrorLog(ex);
            }

            if (isChanged)
            {
                CreateManager.CreateChannel(SiteId, _channelId);

                if (string.IsNullOrEmpty(_returnUrl))
                {
                    LayerUtils.Close(Page);
                }
                else
                {
                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
            }
        }