Пример #1
0
        public void RecoveryButton_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                if (TranslateUtils.ToBool(IsRecoveryByUpload.SelectedValue))
                {
                    if (myFile.PostedFile != null && "" != myFile.PostedFile.FileName)
                    {
                        var filePath = myFile.PostedFile.FileName;
                        if (EBackupTypeUtils.Equals(EBackupType.Templates, BackupType.SelectedValue))
                        {
                            if (EFileSystemTypeUtils.GetEnumType(PathUtils.GetExtension(filePath)) != EFileSystemType.Xml)
                            {
                                FailMessage("必须上传Xml文件");
                                return;
                            }
                        }
                        else
                        {
                            if (!EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath)))
                            {
                                FailMessage("必须上传Zip压缩文件");
                                return;
                            }
                        }

                        try
                        {
                            var localFilePath = PathUtils.GetTemporaryFilesPath(PathUtils.GetFileName(filePath));

                            myFile.PostedFile.SaveAs(localFilePath);

                            var importObject = new ImportObject(PublishmentSystemId);

                            if (EBackupTypeUtils.Equals(EBackupType.Templates, BackupType.SelectedValue))
                            {
                                importObject.ImportTemplates(localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue), Body.AdministratorName);
                                SuccessMessage("恢复模板成功!");
                            }
                            else if (EBackupTypeUtils.Equals(EBackupType.ChannelsAndContents, BackupType.SelectedValue))
                            {
                                importObject.ImportChannelsAndContentsByZipFile(0, localFilePath, TranslateUtils.ToBool(IsOverride.SelectedValue));
                                SuccessMessage("恢复栏目及内容成功!");
                            }
                            else if (EBackupTypeUtils.Equals(EBackupType.Files, BackupType.SelectedValue))
                            {
                                var filesDirectoryPath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.Files));
                                DirectoryUtils.DeleteDirectoryIfExists(filesDirectoryPath);
                                DirectoryUtils.CreateDirectoryIfNotExists(filesDirectoryPath);

                                ZipUtils.UnpackFiles(localFilePath, filesDirectoryPath);

                                importObject.ImportFiles(filesDirectoryPath, TranslateUtils.ToBool(IsOverride.SelectedValue));
                                SuccessMessage("恢复文件成功!");
                            }
                            else if (EBackupTypeUtils.Equals(EBackupType.Site, BackupType.SelectedValue))
                            {
                                var userKeyPrefix = StringUtils.Guid();
                                PageUtils.Redirect(PageProgressBar.GetRecoveryUrl(PublishmentSystemId, IsDeleteChannels.SelectedValue, IsDeleteTemplates.SelectedValue, IsDeleteFiles.SelectedValue, true, localFilePath, IsOverride.SelectedValue, IsOverride.SelectedValue, userKeyPrefix));
                            }
                        }
                        catch (Exception ex)
                        {
                            FailMessage(ex, "数据恢复失败!");
                        }
                    }
                }
            }
        }
Пример #2
0
        public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (!isVisible)
            {
                output.SuppressOutput();
                return(Task.CompletedTask);
            }

            #region << Init >>
            var initSuccess = InitField(context, output);

            if (!initSuccess)
            {
                return(Task.CompletedTask);
            }

            #region << DataSource Variable >>
            if (((Value ?? "").ToString()).StartsWith("{"))
            {
                try
                {
                    DataSourceVariable = JsonConvert.DeserializeObject <DataSourceVariable>((Value ?? "").ToString());
                }
                catch
                {
                }
            }
            #endregion

            #region << PropertyNameLibrary>>
            if (PageId != null)
            {
                var dictionaryKey = PageId + "property-name-library";
                if (ViewContext.HttpContext.Items.ContainsKey(dictionaryKey))
                {
                    PropertyNameLibrary = (List <string>)ViewContext.HttpContext.Items[dictionaryKey];
                }
                else
                {
                    PropertyNameLibrary = PageUtils.PropertyNamesList(PageId ?? Guid.Empty);
                    ViewContext.HttpContext.Items[dictionaryKey] = PropertyNameLibrary;
                }
            }
            #endregion

            #endregion

            #region << InputGroup textbox >>
            {
                var inputGroupEl = new TagBuilder("div");
                inputGroupEl.AddCssClass("input-group");

                if (DataSourceVariable != null)
                {
                    inputGroupEl.AddCssClass("d-none");
                }

                #region << Form Control >>
                var inputEl             = new TagBuilder("input");
                var inputElCssClassList = new List <string>();
                inputElCssClassList.Add("form-control erp-datasource");
                inputEl.Attributes.Add("type", "text");
                inputEl.Attributes.Add("value", (Value ?? "").ToString());

                inputEl.Attributes.Add("id", $"input-{FieldId}");
                inputEl.Attributes.Add("name", Name);
                if (Required)
                {
                    inputEl.Attributes.Add("required", null);
                }
                if (!String.IsNullOrWhiteSpace(Placeholder))
                {
                    inputEl.Attributes.Add("placeholder", Placeholder);
                }


                if (ValidationErrors.Count > 0)
                {
                    inputElCssClassList.Add("is-invalid");
                }

                inputEl.Attributes.Add("class", String.Join(' ', inputElCssClassList));

                inputGroupEl.InnerHtml.AppendHtml(inputEl);

                #endregion

                #region << Append >>
                var igAppendEl = new TagBuilder("div");
                igAppendEl.AddCssClass("input-group-append");

                var igLinkBtnEl = new TagBuilder("button");
                igLinkBtnEl.Attributes.Add("type", "button");
                igLinkBtnEl.Attributes.Add("id", $"input-{FieldId}-create-ds-link");
                igLinkBtnEl.Attributes.Add("title", "Link option to dynamic value");
                igLinkBtnEl.AddCssClass("btn btn-white");
                var igLinkBtnIconEl = new TagBuilder("i");
                igLinkBtnIconEl.AddCssClass("fa fa-cloud-download-alt fa-fw");
                igLinkBtnEl.InnerHtml.AppendHtml(igLinkBtnIconEl);

                igAppendEl.InnerHtml.AppendHtml(igLinkBtnEl);

                inputGroupEl.InnerHtml.AppendHtml(igAppendEl);
                #endregion

                output.Content.AppendHtml(inputGroupEl);
            }
            #endregion

            #region << Datasource Selected >>
            {
                var dsInputGroupEl = new TagBuilder("div");
                dsInputGroupEl.AddCssClass("input-group");
                if (DataSourceVariable == null)
                {
                    dsInputGroupEl.AddCssClass("d-none");
                }

                #region << Form Control >>
                var divEl = new TagBuilder("div");
                divEl.AddCssClass("form-control disabled erp-text erp-linked p-0");
                divEl.Attributes.Add("id", $"input-{FieldId}-datasource");
                if (DataSourceVariable == null || DataSourceVariable.Type == DataSourceVariableType.DATASOURCE)
                {
                    divEl.AddCssClass("datasource");
                }
                else if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.CODE)
                {
                    divEl.AddCssClass("code");
                }
                else
                {
                    divEl.AddCssClass("html");
                }
                var select2ContainerEl = new TagBuilder("span");
                select2ContainerEl.AddCssClass("select2 select2-container select2-container--default d-block disabled");

                var select2SelectionEl = new TagBuilder("span");
                select2SelectionEl.AddCssClass("selection");

                var select2SelectionInnerEl = new TagBuilder("span");
                select2SelectionInnerEl.AddCssClass("select2-selection select2-selection--multiple");

                var select2SelectionUlEl = new TagBuilder("ul");
                select2SelectionUlEl.AddCssClass("select2-selection__rendered");
                var optionEl = new TagBuilder("li");
                optionEl.AddCssClass("select2-selection__choice");
                if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.DATASOURCE)
                {
                    optionEl.Attributes.Add("title", DataSourceVariable.String);
                }

                var optionIcon = new TagBuilder("i");

                if (DataSourceVariable == null || DataSourceVariable.Type == DataSourceVariableType.DATASOURCE)
                {
                    optionIcon.AddCssClass("fa fa-fw fa-link mr-1");
                    optionEl.InnerHtml.AppendHtml(optionIcon);
                    var textSpan = new TagBuilder("span");
                    textSpan.InnerHtml.AppendHtml(DataSourceVariable != null ? DataSourceVariable.String : "");
                    optionEl.InnerHtml.AppendHtml(textSpan);
                }
                else if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.CODE)
                {
                    optionIcon.AddCssClass("fa fa-fw fa-code mr-1");
                    optionEl.InnerHtml.AppendHtml(optionIcon);
                    var textSpan = new TagBuilder("span");
                    textSpan.InnerHtml.AppendHtml("c# code");
                    optionEl.InnerHtml.AppendHtml(textSpan);
                }
                else
                {
                    optionIcon.AddCssClass("fa fa-fw fa-code mr-1");
                    optionEl.InnerHtml.AppendHtml(optionIcon);
                    var textSpan = new TagBuilder("span");
                    textSpan.InnerHtml.AppendHtml("html");
                    optionEl.InnerHtml.AppendHtml(textSpan);
                }

                select2SelectionUlEl.InnerHtml.AppendHtml(optionEl);
                select2SelectionInnerEl.InnerHtml.AppendHtml(select2SelectionUlEl);

                select2SelectionEl.InnerHtml.AppendHtml(select2SelectionInnerEl);
                select2ContainerEl.InnerHtml.AppendHtml(select2SelectionEl);
                divEl.InnerHtml.AppendHtml(select2ContainerEl);
                dsInputGroupEl.InnerHtml.AppendHtml(divEl);
                #endregion


                #region << Append >>
                var dsAppendEl = new TagBuilder("div");
                dsAppendEl.AddCssClass("input-group-append");

                var dsRemoveBtnEl = new TagBuilder("button");
                dsRemoveBtnEl.Attributes.Add("type", "button");
                dsRemoveBtnEl.Attributes.Add("id", $"input-{FieldId}-remove-ds-link");
                dsRemoveBtnEl.AddCssClass("btn btn-white");
                var dsRemoveBtnIconEl = new TagBuilder("i");
                dsRemoveBtnIconEl.AddCssClass("fa fa-times go-red  fa-fw");
                dsRemoveBtnEl.InnerHtml.AppendHtml(dsRemoveBtnIconEl);
                dsAppendEl.InnerHtml.AppendHtml(dsRemoveBtnEl);

                var dsEditBtnEl = new TagBuilder("button");
                dsEditBtnEl.Attributes.Add("type", "button");
                dsEditBtnEl.Attributes.Add("id", $"input-{FieldId}-edit-ds-link");
                dsEditBtnEl.AddCssClass("btn btn-white");
                var dsEditBtnIconEl = new TagBuilder("i");
                dsEditBtnIconEl.AddCssClass("fa fa-pencil-alt go-orange  fa-fw");
                dsEditBtnEl.InnerHtml.AppendHtml(dsEditBtnIconEl);
                dsAppendEl.InnerHtml.AppendHtml(dsEditBtnEl);

                dsInputGroupEl.InnerHtml.AppendHtml(dsAppendEl);
                output.Content.AppendHtml(dsInputGroupEl);
                #endregion
            }
            #endregion


            #region << Modal >>
            {
                var editModalEl = new TagBuilder("div");
                editModalEl.AddCssClass("modal");
                editModalEl.Attributes.Add("id", $"modal-{FieldId}-datasource");
                editModalEl.Attributes.Add("style", "padding-right: 15px;");
                editModalEl.Attributes.Add("tabindex", "-1");
                var editModalDialog = new TagBuilder("div");
                editModalDialog.AddCssClass("modal-dialog modal-xl");
                var editModalContent = new TagBuilder("div");
                editModalContent.AddCssClass("modal-content");

                #region << Modal Header >>
                var editModalHeader = new TagBuilder("div");
                editModalHeader.AddCssClass("modal-header");
                var editModalHeaderTitle = new TagBuilder("h5");
                editModalHeaderTitle.AddCssClass("modal-title");
                editModalHeaderTitle.InnerHtml.Append("Link option to dynamic value");
                editModalHeader.InnerHtml.AppendHtml(editModalHeaderTitle);
                var editModalHeaderButton = new TagBuilder("button");
                editModalHeaderButton.Attributes.Add("type", "button");
                editModalHeaderButton.AddCssClass("close");
                editModalHeaderButton.Attributes.Add("data-dismiss", "modal");
                editModalHeaderButton.InnerHtml.AppendHtml(new TagBuilder("span").InnerHtml.AppendHtml("&times;"));
                editModalHeader.InnerHtml.AppendHtml(editModalHeaderButton);
                editModalContent.InnerHtml.AppendHtml(editModalHeader);
                #endregion

                #region << Modal Body >>
                var editModalBody = new TagBuilder("div");
                editModalBody.AddCssClass("modal-body");

                #region << Type >>
                {
                    var fieldGroupEl = new TagBuilder("div");
                    fieldGroupEl.AddCssClass("form-group erp-field");
                    var fieldLabel = new TagBuilder("label");
                    fieldLabel.AddCssClass("control-label label-stacked");
                    fieldLabel.InnerHtml.AppendHtml("Type");
                    fieldGroupEl.InnerHtml.AppendHtml(fieldLabel);

                    var fieldFormControl = new TagBuilder("div");
                    fieldFormControl.AddCssClass("form-control-plaintext erp-radio-list");

                    #region << Datasource chkb >>
                    {
                        var formCheckEl = new TagBuilder("div");
                        formCheckEl.AddCssClass("form-check form-check-inline");
                        var formCheckInput = new TagBuilder("input");
                        formCheckInput.AddCssClass("form-check-input ds-type-radio");
                        formCheckInput.Attributes.Add("type", "radio");
                        formCheckInput.Attributes.Add("id", $"modal-{FieldId}-checkbox-datasource");
                        formCheckInput.Attributes.Add("value", "0");
                        if (DataSourceVariable == null || DataSourceVariable.Type == DataSourceVariableType.DATASOURCE)
                        {
                            formCheckInput.Attributes.Add("checked", "checked");
                        }
                        formCheckEl.InnerHtml.AppendHtml(formCheckInput);
                        var formCheckLabel = new TagBuilder("label");
                        formCheckLabel.AddCssClass("form-check-label");
                        formCheckLabel.Attributes.Add("for", $"modal-{FieldId}-checkbox-datasource");
                        formCheckLabel.InnerHtml.AppendHtml("datasource");
                        formCheckEl.InnerHtml.AppendHtml(formCheckLabel);
                        fieldFormControl.InnerHtml.AppendHtml(formCheckEl);
                    }
                    #endregion

                    #region << Code chkb >>
                    {
                        var formCheckEl = new TagBuilder("div");
                        formCheckEl.AddCssClass("form-check form-check-inline");
                        var formCheckInput = new TagBuilder("input");
                        formCheckInput.AddCssClass("form-check-input ds-type-radio");
                        formCheckInput.Attributes.Add("type", "radio");
                        formCheckInput.Attributes.Add("id", $"modal-{FieldId}-checkbox-code");
                        formCheckInput.Attributes.Add("value", "1");
                        if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.CODE)
                        {
                            formCheckInput.Attributes.Add("checked", "checked");
                        }
                        formCheckEl.InnerHtml.AppendHtml(formCheckInput);
                        var formCheckLabel = new TagBuilder("label");
                        formCheckLabel.AddCssClass("form-check-label");
                        formCheckLabel.Attributes.Add("for", $"modal-{FieldId}-checkbox-code");
                        formCheckLabel.InnerHtml.AppendHtml("code");
                        formCheckEl.InnerHtml.AppendHtml(formCheckLabel);
                        fieldFormControl.InnerHtml.AppendHtml(formCheckEl);
                    }
                    #endregion

                    #region << Html chkb >>
                    {
                        var formCheckEl = new TagBuilder("div");
                        formCheckEl.AddCssClass("form-check form-check-inline");
                        var formCheckInput = new TagBuilder("input");
                        formCheckInput.AddCssClass("form-check-input ds-type-radio");
                        formCheckInput.Attributes.Add("type", "radio");
                        formCheckInput.Attributes.Add("id", $"modal-{FieldId}-checkbox-html");
                        formCheckInput.Attributes.Add("value", "2");
                        if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.HTML)
                        {
                            formCheckInput.Attributes.Add("checked", "checked");
                        }
                        formCheckEl.InnerHtml.AppendHtml(formCheckInput);
                        var formCheckLabel = new TagBuilder("label");
                        formCheckLabel.AddCssClass("form-check-label");
                        formCheckLabel.Attributes.Add("for", $"modal-{FieldId}-checkbox-html");
                        formCheckLabel.InnerHtml.AppendHtml("html");
                        formCheckEl.InnerHtml.AppendHtml(formCheckLabel);
                        fieldFormControl.InnerHtml.AppendHtml(formCheckEl);
                    }
                    #endregion
                    fieldGroupEl.InnerHtml.AppendHtml(fieldFormControl);
                    editModalBody.InnerHtml.AppendHtml(fieldGroupEl);
                }
                #endregion

                #region << Datasource >>
                {
                    var fieldGroupEl = new TagBuilder("div");
                    fieldGroupEl.AddCssClass("form-group erp-field");
                    if (DataSourceVariable != null && DataSourceVariable.Type != DataSourceVariableType.DATASOURCE)
                    {
                        fieldGroupEl.AddCssClass("d-none");
                    }
                    fieldGroupEl.Attributes.Add("id", $"modal-{FieldId}-datasource-group");
                    var fieldLabel = new TagBuilder("label");
                    fieldLabel.AddCssClass("control-label label-stacked");
                    fieldLabel.InnerHtml.AppendHtml("Value");
                    fieldGroupEl.InnerHtml.AppendHtml(fieldLabel);

                    var inputEl = new TagBuilder("input");
                    inputEl.AddCssClass("form-control erp-text");
                    inputEl.Attributes.Add("type", "text");

                    if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.DATASOURCE)
                    {
                        inputEl.Attributes.Add("value", DataSourceVariable.String);
                    }
                    else
                    {
                        inputEl.Attributes.Add("value", "");
                    }
                    fieldGroupEl.InnerHtml.AppendHtml(inputEl);

                    editModalBody.InnerHtml.AppendHtml(fieldGroupEl);
                }
                #endregion

                #region << Code >>
                {
                    var fieldGroupEl = new TagBuilder("div");
                    fieldGroupEl.AddCssClass("form-group erp-field");
                    if (DataSourceVariable == null || DataSourceVariable.Type != DataSourceVariableType.CODE)
                    {
                        fieldGroupEl.AddCssClass("d-none");
                    }
                    fieldGroupEl.Attributes.Add("id", $"modal-{FieldId}-code-group");
                    var fieldLabel = new TagBuilder("label");
                    fieldLabel.AddCssClass("control-label label-stacked");
                    fieldLabel.InnerHtml.AppendHtml("Value (templates: <a href='javascript:void(0)' class='simple-code ml-1'>simple</a>, <a href='javascript:void(0)' class='datasource-code ml-1'>data source get</a>, <a href='javascript:void(0)' class='datasource-selectoptions-code ml-1'>List&lt;EntityRecord&gt; to List&lt;SelectOptions&gt;</a>)");
                    fieldGroupEl.InnerHtml.AppendHtml(fieldLabel);

                    var editorWrapperEl     = new TagBuilder("div");
                    var wrapperCssClassList = new List <string>();
                    wrapperCssClassList.Add("form-control-plaintext erp-code");
                    if (ValidationErrors.Count > 0)
                    {
                        wrapperCssClassList.Add("is-invalid");
                    }
                    editorWrapperEl.Attributes.Add("class", String.Join(' ', wrapperCssClassList));
                    var editorWrapper = new TagBuilder("div");
                    editorWrapper.Attributes.Add("id", $"modal-{FieldId}-code-editor");
                    editorWrapper.Attributes.Add("style", $"min-height:250px");
                    editorWrapperEl.InnerHtml.AppendHtml(editorWrapper);
                    fieldGroupEl.InnerHtml.AppendHtml(editorWrapperEl);

                    var inputEl = new TagBuilder("input");
                    inputEl.Attributes.Add("type", "hidden");
                    inputEl.Attributes.Add("id", $"modal-{FieldId}-code-input");
                    if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.CODE)
                    {
                        inputEl.Attributes.Add("value", DataSourceVariable.String);
                    }
                    else
                    {
                        var defaultCode = @"using System;
using System.Collections.Generic;
using WebVella.Erp.Web.Models;
using WebVella.Erp.Api.Models;
using Newtonsoft.Json;

public class SampleCodeVariable : ICodeVariable
{
	public object Evaluate(BaseErpPageModel pageModel)
	{
		try{
			return DateTime.Now;
		}
		catch(Exception ex){
			return ""Error: "" + ex.Message;
		}
	}
}";
                        inputEl.Attributes.Add("value", defaultCode);
                    }
                    fieldGroupEl.InnerHtml.AppendHtml(inputEl);
                    editModalBody.InnerHtml.AppendHtml(fieldGroupEl);
                }
                #endregion


                #region << HTML >>
                {
                    var fieldGroupEl = new TagBuilder("div");
                    fieldGroupEl.AddCssClass("form-group erp-field");
                    if (DataSourceVariable == null || DataSourceVariable.Type != DataSourceVariableType.HTML)
                    {
                        fieldGroupEl.AddCssClass("d-none");
                    }
                    fieldGroupEl.Attributes.Add("id", $"modal-{FieldId}-html-group");
                    var fieldLabel = new TagBuilder("label");
                    fieldLabel.AddCssClass("control-label label-stacked");
                    fieldLabel.InnerHtml.AppendHtml("Value");
                    fieldGroupEl.InnerHtml.AppendHtml(fieldLabel);

                    var editorWrapperEl     = new TagBuilder("div");
                    var wrapperCssClassList = new List <string>();
                    wrapperCssClassList.Add("form-control-plaintext erp-code");
                    if (ValidationErrors.Count > 0)
                    {
                        wrapperCssClassList.Add("is-invalid");
                    }
                    editorWrapperEl.Attributes.Add("class", String.Join(' ', wrapperCssClassList));
                    var editorWrapper = new TagBuilder("div");
                    editorWrapper.Attributes.Add("id", $"modal-{FieldId}-html-editor");
                    editorWrapper.Attributes.Add("style", $"min-height:250px");
                    editorWrapperEl.InnerHtml.AppendHtml(editorWrapper);
                    fieldGroupEl.InnerHtml.AppendHtml(editorWrapperEl);

                    var inputEl = new TagBuilder("input");
                    inputEl.Attributes.Add("type", "hidden");
                    inputEl.Attributes.Add("id", $"modal-{FieldId}-html-input");
                    if (DataSourceVariable != null && DataSourceVariable.Type == DataSourceVariableType.HTML)
                    {
                        inputEl.Attributes.Add("value", DataSourceVariable.String);
                    }
                    else
                    {
                        var defaultCode = @"<div>HTML code</div>";
                        inputEl.Attributes.Add("value", defaultCode);
                    }
                    fieldGroupEl.InnerHtml.AppendHtml(inputEl);
                    editModalBody.InnerHtml.AppendHtml(fieldGroupEl);
                }
                #endregion

                #region << Default >>
                {
                    var fieldGroupEl = new TagBuilder("div");
                    fieldGroupEl.AddCssClass("form-group erp-field");
                    fieldGroupEl.Attributes.Add("id", $"modal-{FieldId}-default-group");
                    var fieldLabel = new TagBuilder("label");
                    fieldLabel.AddCssClass("control-label label-stacked");
                    fieldLabel.InnerHtml.AppendHtml("Default Value");
                    fieldGroupEl.InnerHtml.AppendHtml(fieldLabel);

                    var inputEl = new TagBuilder("input");
                    inputEl.AddCssClass("form-control erp-text");
                    inputEl.Attributes.Add("type", "text");
                    if (DataSourceVariable != null)
                    {
                        inputEl.Attributes.Add("value", DataSourceVariable.Default);
                    }
                    else
                    {
                        inputEl.Attributes.Add("value", "");
                    }
                    fieldGroupEl.InnerHtml.AppendHtml(inputEl);
                    editModalBody.InnerHtml.AppendHtml(fieldGroupEl);
                }
                #endregion


                editModalContent.InnerHtml.AppendHtml(editModalBody);
                #endregion

                #region << modal footer >>
                var editModalFooter = new TagBuilder("div");
                editModalFooter.AddCssClass("modal-footer");

                var editModalFooterTest = new TagBuilder("button");
                editModalFooterTest.Attributes.Add("type", "button");
                editModalFooterTest.AddCssClass("btn btn-secondary test btn-sm d-none");
                editModalFooterTest.Attributes.Add("style", "position: absolute;left: 10px;");
                editModalFooterTest.InnerHtml.AppendHtml("<i class='fa fa-cog'></i> test code");
                editModalFooter.InnerHtml.AppendHtml(editModalFooterTest);

                var editModalFooterSave = new TagBuilder("button");
                editModalFooterSave.Attributes.Add("type", "button");
                editModalFooterSave.AddCssClass("btn btn-green btn-sm submit");
                var editModalFooterSaveIcon = new TagBuilder("span");
                editModalFooterSaveIcon.AddCssClass("fa fa-link mr-1");
                editModalFooterSave.InnerHtml.AppendHtml(editModalFooterSaveIcon);
                editModalFooterSave.InnerHtml.AppendHtml("create link");
                editModalFooter.InnerHtml.AppendHtml(editModalFooterSave);
                var editModalFooterCancel = new TagBuilder("button");
                editModalFooterCancel.Attributes.Add("type", "button");
                editModalFooterCancel.AddCssClass("btn btn-secondary cancel btn-sm");
                editModalFooterCancel.InnerHtml.Append("cancel");
                editModalFooter.InnerHtml.AppendHtml(editModalFooterCancel);
                editModalContent.InnerHtml.AppendHtml(editModalFooter);
                #endregion


                editModalDialog.InnerHtml.AppendHtml(editModalContent);
                editModalEl.InnerHtml.AppendHtml(editModalDialog);

                output.Content.AppendHtml(editModalEl);
            }
            #endregion

            var jsCompressor = new JavaScriptCompressor();

            #region << Add Ace lib >>
            {
                var aceLibInitialized = false;
                var fileName          = "ace.js";
                if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldDatasource) + fileName))
                {
                    var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldDatasource) + fileName];
                    aceLibInitialized = tagHelperContext.Initialized;
                }
                if (!aceLibInitialized)
                {
                    var scriptEl = new TagBuilder("script");
                    scriptEl.Attributes.Add("type", "text/javascript");
                    scriptEl.Attributes.Add("src", "/lib/ace/ace.js");
                    output.Content.AppendHtml(scriptEl);

                    ViewContext.HttpContext.Items[typeof(WvFieldDatasource) + fileName] = new WvTagHelperContext()
                    {
                        Initialized = true
                    };
                }
            }
            #endregion

            #region << Add Typeahead lib >>
            {
                var aceLibInitialized = false;
                var fileName          = "bootstrap3-typeahead.js";
                if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldDatasource) + fileName))
                {
                    var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldDatasource) + fileName];
                    aceLibInitialized = tagHelperContext.Initialized;
                }
                if (!aceLibInitialized)
                {
                    var scriptEl = new TagBuilder("script");
                    scriptEl.Attributes.Add("type", "text/javascript");
                    scriptEl.Attributes.Add("src", "/lib/bootstrap-3-typeahead/bootstrap3-typeahead.min.js");
                    output.Content.AppendHtml(scriptEl);

                    ViewContext.HttpContext.Items[typeof(WvFieldDatasource) + fileName] = new WvTagHelperContext()
                    {
                        Initialized = true
                    };
                }
            }
            #endregion


            #region << Init Scripts >>
            {
                var tagHelperInitialized = false;
                if (ViewContext.HttpContext.Items.ContainsKey(typeof(WvFieldDatasource) + "-form"))
                {
                    var tagHelperContext = (WvTagHelperContext)ViewContext.HttpContext.Items[typeof(WvFieldDatasource) + "-form"];
                    tagHelperInitialized = tagHelperContext.Initialized;
                }
                if (!tagHelperInitialized)
                {
                    var scriptContent = FileService.GetEmbeddedTextResource("form.js", "WebVella.Erp.Web.TagHelpers.WvFieldDatasource");
                    var scriptEl      = new TagBuilder("script");
                    scriptEl.Attributes.Add("type", "text/javascript");
                    //scriptEl.InnerHtml.AppendHtml(jsCompressor.Compress(scriptContent));
                    scriptEl.InnerHtml.AppendHtml(scriptContent);
                    output.Content.AppendHtml(scriptEl);

                    ViewContext.HttpContext.Items[typeof(WvFieldDatasource) + "-form"] = new WvTagHelperContext()
                    {
                        Initialized = true
                    };
                }
            }
            #endregion

            #region << Add Inline Init Script for this instance >>
            {
                var initScript = new TagBuilder("script");
                initScript.Attributes.Add("type", "text/javascript");
                var scriptTemplate = @"
						$(function(){
							DataSourceFormEditInit(""{{FieldId}}"",{{PropertyNameCsv}});
						});"                        ;
                scriptTemplate = scriptTemplate.Replace("{{FieldId}}", (FieldId ?? null).ToString());
                scriptTemplate = scriptTemplate.Replace("{{PropertyNameCsv}}", JsonConvert.SerializeObject(PropertyNameLibrary));

                initScript.InnerHtml.AppendHtml(jsCompressor.Compress(scriptTemplate));

                output.Content.AppendHtml(initScript);
            }
            #endregion



            //Finally
            if (SubInputEl != null)
            {
                output.Content.AppendHtml(SubInputEl);
            }

            return(Task.CompletedTask);
        }
Пример #3
0
 public static string GetRedirectUrl(string roleName)
 {
     return(PageUtils.GetSettingsUrl(nameof(PageAdminRoleAdd), new NameValueCollection {
         { "RoleName", roleName }
     }));
 }
Пример #4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }
            var roleName = Body.GetQueryString("RoleName");

            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(roleName))
                {
                    PageUtils.RedirectToErrorPage("参数错误!");
                }
                TbRoleName.Text    = roleName;
                TbRoleName.Enabled = false;
                TbDescription.Text = BaiRongDataProvider.RoleDao.GetRoleDescription(roleName);

                DataTable dt = new DataTable();
                //if (PermissionsManager.GetPermissions(PublishmentSystemInfo.AdministratorAccount).IsAdministrator)
                //{
                dt = DataProvider.SystemPermissionsDao.GetAllList();
                //}
                //else
                //{
                //    dt = DataProvider.SystemPermissionsDao.GetList(PermissionsManager.GetPermissions(PublishmentSystemInfo.AdministratorAccount).Roles);
                //}
                var channelPermision  = DataProvider.SystemPermissionsDao.GetChannelPermissionSortedList(new string[] { roleName });
                var webSitePermission = DataProvider.SystemPermissionsDao.GetWebsitePermissionSortedList(new string[] { roleName });
                rptContents.DataSource = dt;
                rptContents.DataBind();
                for (int i = 0; i < rptContents.Items.Count; i++)
                {
                    string nodeId = ((HiddenField)rptContents.Items[i].FindControl("hidNodeId")).Value;
                    //string navName = ((HiddenField)rptContents.Items[i].FindControl("hidName")).Value;
                    CheckBoxList cblActionType = (CheckBoxList)rptContents.Items[i].FindControl("cblActionType");
                    foreach (KeyValuePair <int, List <string> > kv in channelPermision)
                    {
                        if (kv.Key.ToString().Equals(nodeId, StringComparison.OrdinalIgnoreCase))
                        {
                            for (int n = 0; n < cblActionType.Items.Count; n++)
                            {
                                if (kv.Value.Contains(cblActionType.Items[n].Value))
                                {
                                    cblActionType.Items[n].Selected = true;
                                }
                            }
                        }
                    }
                }
                //rptContents.ItemDataBound += rptContents_ItemDataBound;

                List <PermissionConfig> webSitePermissions = new List <PermissionConfig>();
                //var currentWebsitePermissions=
                foreach (PermissionConfig permission in PermissionConfigManager.Instance.WebsitePermissions)
                {
                    //if (permission.Name == websitePermission)
                    //{
                    //    WebsitePermissionsPlaceHolder.Visible = true;
                    //    var listItem = new ListItem(permission.Text, permission.Name);
                    //    WebsitePermissions.Items.Add(listItem);
                    //}
                    if (StringUtils.EqualsIgnoreCase(permission.Type, "party"))
                    {
                        webSitePermissions.Add(permission);
                    }
                }
                rptWebSite.DataSource = webSitePermissions;
                rptWebSite.DataBind();
                for (int i = 0; i < rptWebSite.Items.Count; i++)
                {
                    CheckBoxList cblActionType = (CheckBoxList)rptWebSite.Items[i].FindControl("cblWebSiteType");
                    for (int n = 0; n < cblActionType.Items.Count; n++)
                    {
                        foreach (List <string> list in webSitePermission.Values)
                        {
                            if (list.Contains(cblActionType.Items[n].Value))
                            {
                                cblActionType.Items[n].Selected = true;
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
 public static string GetSearchApiUrl(ISettingsManager settingsManager)
 {
     return(PageUtils.Combine(settingsManager.ApiHost, Constants.ApiPrefix, Constants.ApiStlPrefix, Constants.RouteStlActionsSearch));
 }
Пример #6
0
 public static string GetOsUserPluginsDirectoryPath(params string[] paths)
 {
     return(PathUtils.GetOsUserProfileDirectoryPath("plugins", PageUtils.Combine(paths)));
 }
Пример #7
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new RequestImpl();

                if (string.IsNullOrEmpty(WebConfigUtils.ConnectionString))
                {
                    return(Ok(new
                    {
                        Value = false,
                        RedirectUrl = "Installer/"
                    }));
                }

                if (ConfigManager.Instance.IsInitialized && ConfigManager.Instance.DatabaseVersion != SystemManager.Version)
                {
                    return(Ok(new
                    {
                        Value = false,
                        RedirectUrl = PageSyncDatabase.GetRedirectUrl()
                    }));
                }

                if (!request.IsAdminLoggin || request.AdminInfo == null || request.AdminInfo.IsLockedOut)
                {
                    return(Ok(new
                    {
                        Value = false,
                        RedirectUrl = "pageLogin.cshtml"
                    }));
                }

                var siteId       = request.GetQueryInt("siteId");
                var siteInfo     = SiteManager.GetSiteInfo(siteId);
                var adminInfo    = request.AdminInfo;
                var permissions  = request.AdminPermissionsImpl;
                var isSuperAdmin = permissions.IsConsoleAdministrator;
                var siteIdListWithPermissions = permissions.GetSiteIdList();

                if (siteInfo == null || !siteIdListWithPermissions.Contains(siteInfo.Id))
                {
                    if (siteIdListWithPermissions.Contains(adminInfo.SiteId))
                    {
                        return(Ok(new
                        {
                            Value = false,
                            RedirectUrl = PageUtils.GetMainUrl(adminInfo.SiteId)
                        }));
                    }

                    if (siteIdListWithPermissions.Count > 0)
                    {
                        return(Ok(new
                        {
                            Value = false,
                            RedirectUrl = PageUtils.GetMainUrl(siteIdListWithPermissions[0])
                        }));
                    }

                    if (isSuperAdmin)
                    {
                        return(Ok(new
                        {
                            Value = false,
                            RedirectUrl = PageSiteAdd.GetRedirectUrl()
                        }));
                    }

                    return(Ok(new
                    {
                        Value = false,
                        RedirectUrl = $"pageError.html?message={HttpUtility.UrlEncode("您没有可以管理的站点,请联系超级管理员协助解决")}"
                    }));
                }

                var packageIds = new List <string>
                {
                    PackageUtils.PackageIdSsCms
                };
                var packageList = new List <object>();
                var dict        = PluginManager.GetPluginIdAndVersionDict();
                foreach (var id in dict.Keys)
                {
                    packageIds.Add(id);
                    var version = dict[id];
                    packageList.Add(new
                    {
                        id,
                        version
                    });
                }

                var siteIdListLatestAccessed = DataProvider.AdministratorDao.UpdateSiteId(adminInfo, siteInfo.Id);

                var permissionList = new List <string>(permissions.PermissionList);
                if (permissions.HasSitePermissions(siteInfo.Id))
                {
                    var websitePermissionList = permissions.GetSitePermissions(siteInfo.Id);
                    if (websitePermissionList != null)
                    {
                        permissionList.AddRange(websitePermissionList);
                    }
                }
                var channelPermissions = permissions.GetChannelPermissions(siteInfo.Id);
                if (channelPermissions.Count > 0)
                {
                    permissionList.AddRange(channelPermissions);
                }

                var topMenus  = GetTopMenus(siteInfo, isSuperAdmin, siteIdListLatestAccessed, siteIdListWithPermissions);
                var siteMenus =
                    GetLeftMenus(siteInfo, ConfigManager.TopMenu.IdSite, isSuperAdmin, permissionList);
                var pluginMenus = GetLeftMenus(siteInfo, string.Empty, isSuperAdmin, permissionList);

                return(Ok(new
                {
                    Value = true,
                    DefaultPageUrl = PluginMenuManager.GetSystemDefaultPageUrl(siteId) ?? "dashboard.cshtml",
                    IsNightly = WebConfigUtils.IsNightlyUpdate,
                    Version = SystemManager.PluginVersion,
                    IsSuperAdmin = isSuperAdmin,
                    PackageList = packageList,
                    PackageIds = packageIds,
                    CurrentVersion = SystemManager.Version,
                    TopMenus = topMenus,
                    SiteMenus = siteMenus,
                    PluginMenus = pluginMenus,
                    Local = new
                    {
                        UserId = adminInfo.Id,
                        adminInfo.UserName,
                        adminInfo.AvatarUrl,
                        Level = permissions.GetAdminLevel()
                    }
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #8
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            _isHeadquarters = SiteInfo.IsRoot;

            var selectedList = new List <string>();

            if (Page.IsPostBack)
            {
                return;
            }

            if (_isHeadquarters)
            {
                InfoMessage($"将站点{SiteInfo.SiteName}转移到子目录");

                PhChangeToSite.Visible         = true;
                PhChangeToHeadquarters.Visible = false;
                var fileSystems = FileManager.GetFileSystemInfoExtendCollection(WebConfigUtils.PhysicalApplicationPath, true);
                var siteDirList = DataProvider.SiteDao.GetLowerSiteDirListThatNotIsRoot();
                foreach (FileSystemInfoExtend fileSystem in fileSystems)
                {
                    if (fileSystem.IsDirectory)
                    {
                        if (!DirectoryUtils.IsSystemDirectory(fileSystem.Name) && !siteDirList.Contains(fileSystem.Name.ToLower()))
                        {
                            CblFilesToSite.Items.Add(new ListItem(fileSystem.Name, fileSystem.Name));
                        }
                    }
                    else
                    {
                        if (!PathUtility.IsSystemFileForChangeSiteType(fileSystem.Name))
                        {
                            CblFilesToSite.Items.Add(new ListItem(fileSystem.Name, fileSystem.Name));
                        }
                    }

                    if (PathUtility.IsWebSiteFile(fileSystem.Name) || DirectoryUtils.IsWebSiteDirectory(fileSystem.Name))
                    {
                        selectedList.Add(fileSystem.Name);
                    }
                }

                //主站下的单页模板
                var fileTemplateInfoList = DataProvider.TemplateDao.GetTemplateInfoListByType(SiteId, TemplateType.FileTemplate);
                foreach (var fileT in fileTemplateInfoList)
                {
                    if (fileT.CreatedFileFullName.StartsWith("@/") || fileT.CreatedFileFullName.StartsWith("~/"))
                    {
                        var arr = fileT.CreatedFileFullName.Substring(2).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                        if (arr.Length > 0)
                        {
                            selectedList.Add(arr[0]);
                        }
                    }
                }
            }
            else
            {
                InfoMessage($"将站点{SiteInfo.SiteName}转移到根目录");

                var headquartersExists = false;
                var siteIdList         = SiteManager.GetSiteIdList();
                foreach (var psId in siteIdList)
                {
                    var psInfo = SiteManager.GetSiteInfo(psId);
                    if (psInfo.IsRoot)
                    {
                        headquartersExists = true;
                        break;
                    }
                }
                if (headquartersExists)
                {
                    FailMessage($"根目录站点已经存在,站点{SiteInfo.SiteName}不能转移到根目录");
                    BtnSubmit.Visible              = false;
                    PhChangeToSite.Visible         = false;
                    PhChangeToHeadquarters.Visible = false;
                }
                else
                {
                    PhChangeToSite.Visible         = false;
                    PhChangeToHeadquarters.Visible = true;
                }
            }

            //设置选中的文件以及文件夹
            ControlUtils.SelectMultiItems(CblFilesToSite, selectedList);
        }
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isSuccess = false;

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

                if (PhChannel.Visible)
                {
                    channelInfo.LinkUrl  = TbLinkUrl.Text;
                    channelInfo.LinkType = DdlLinkType.SelectedValue;

                    var filePath = channelInfo.FilePath;
                    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 (TbFilePath.Text != PageUtility.GetInputChannelUrl(SiteInfo, channelInfo, false))
                    {
                        channelInfo.FilePath = TbFilePath.Text;
                    }
                }

                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 (TbChannelFilePathRule.Text != PathUtility.GetChannelFilePathRule(SiteInfo, _channelId))
                {
                    channelInfo.ChannelFilePathRule = TbChannelFilePathRule.Text;
                }
                if (TbContentFilePathRule.Text != PathUtility.GetContentFilePathRule(SiteInfo, _channelId))
                {
                    channelInfo.ContentFilePathRule = TbContentFilePathRule.Text;
                }

                channelInfo.Additional.IsChannelCreatable = TranslateUtils.ToBool(RblIsChannelCreatable.SelectedValue);
                channelInfo.Additional.IsContentCreatable = TranslateUtils.ToBool(RblIsContentCreatable.SelectedValue);

                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));
            }
        }
Пример #10
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            var serviceParamters = new ExtendedAttributes();

            if (_serviceType == EServiceType.Create)
            {
                var taskCreateInfo = new TaskCreateInfo(string.Empty);
                taskCreateInfo.IsCreateAll         = CreateIsCreateAll.Checked;
                taskCreateInfo.ChannelIDCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(CreateChannelIDCollection));
                taskCreateInfo.CreateTypes         = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(CreateCreateTypes));
                serviceParamters = taskCreateInfo;
            }
            else if (_serviceType == EServiceType.Gather)
            {
                var taskGatherInfo = new TaskGatherInfo(string.Empty);
                if (PublishmentSystemId != 0)
                {
                    var webGatherNames      = new ArrayList();
                    var databaseGatherNames = new ArrayList();
                    var fileGatherNames     = new ArrayList();
                    foreach (ListItem item in GatherListBox.Items)
                    {
                        if (item.Selected)
                        {
                            var gatherType = EGatherTypeUtils.GetEnumType(item.Value.Split('_')[0]);
                            var gatherName = item.Value.Substring(item.Value.Split('_')[0].Length + 1);
                            if (gatherType == EGatherType.Web && !webGatherNames.Contains(gatherName))
                            {
                                webGatherNames.Add(gatherName);
                            }
                            else if (gatherType == EGatherType.Database && !databaseGatherNames.Contains(gatherName))
                            {
                                databaseGatherNames.Add(gatherName);
                            }
                            else if (gatherType == EGatherType.File && !fileGatherNames.Contains(gatherName))
                            {
                                fileGatherNames.Add(gatherName);
                            }
                        }
                    }
                    taskGatherInfo.WebGatherNames      = TranslateUtils.ObjectCollectionToString(webGatherNames);
                    taskGatherInfo.DatabaseGatherNames = TranslateUtils.ObjectCollectionToString(databaseGatherNames);
                    taskGatherInfo.FileGatherNames     = TranslateUtils.ObjectCollectionToString(fileGatherNames);
                }
                else
                {
                    taskGatherInfo.PublishmentSystemIDCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(GatherListBox));
                }
                serviceParamters = taskGatherInfo;
            }
            else if (_serviceType == EServiceType.Backup)
            {
                var taskBackupInfo = new TaskBackupInfo(string.Empty);
                taskBackupInfo.BackupType  = EBackupTypeUtils.GetEnumType(BackupType.SelectedValue);
                taskBackupInfo.IsBackupAll = BackupIsBackupAll.Checked;
                taskBackupInfo.PublishmentSystemIDCollection = TranslateUtils.ObjectCollectionToString(ControlUtils.GetSelectedListControlValueArrayList(BackupPublishmentSystemIDCollection));
                serviceParamters = taskBackupInfo;
            }

            if (Body.IsQueryExists("TaskID"))
            {
                try
                {
                    var taskId   = Body.GetQueryInt("TaskID");
                    var taskInfo = DataProvider.TaskDao.GetTaskInfo(taskId);
                    taskInfo.FrequencyType = EFrequencyTypeUtils.GetEnumType(FrequencyType.SelectedValue);
                    if (taskInfo.FrequencyType == EFrequencyType.Period)
                    {
                        taskInfo.PeriodIntervalMinute = TranslateUtils.ToInt(PeriodInterval.Text) * TranslateUtils.ToInt(PeriodIntervalType.SelectedValue);
                    }
                    else if (taskInfo.FrequencyType != EFrequencyType.JustInTime)
                    {
                        taskInfo.StartDay     = TranslateUtils.ToInt(StartDay.SelectedValue);
                        taskInfo.StartWeekday = TranslateUtils.ToInt(StartWeekday.SelectedValue);
                        taskInfo.StartHour    = TranslateUtils.ToInt(StartHour.SelectedValue);
                    }
                    taskInfo.Description       = Description.Text;
                    taskInfo.ServiceParameters = serviceParamters.ToString();

                    DataProvider.TaskDao.Update(taskInfo);

                    Body.AddSiteLog(PublishmentSystemId, $"修改{EServiceTypeUtils.GetText(taskInfo.ServiceType)}任务", $"任务名称:{taskInfo.TaskName}");

                    SuccessMessage("任务修改成功!");
                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "任务修改失败!");
                }
            }
            else
            {
                if (DataProvider.TaskDao.IsExists(TaskName.Text))
                {
                    FailMessage("任务添加失败,任务名称已存在!");
                }
                else
                {
                    try
                    {
                        var taskInfo = new TaskInfo();
                        taskInfo.TaskName            = TaskName.Text;
                        taskInfo.PublishmentSystemID = PublishmentSystemId;
                        taskInfo.ServiceType         = _serviceType;
                        taskInfo.FrequencyType       = EFrequencyTypeUtils.GetEnumType(FrequencyType.SelectedValue);
                        if (taskInfo.FrequencyType == EFrequencyType.Period)
                        {
                            taskInfo.PeriodIntervalMinute = TranslateUtils.ToInt(PeriodInterval.Text) * TranslateUtils.ToInt(PeriodIntervalType.SelectedValue);
                        }
                        else if (taskInfo.FrequencyType != EFrequencyType.JustInTime)
                        {
                            taskInfo.StartDay     = TranslateUtils.ToInt(StartDay.SelectedValue);
                            taskInfo.StartWeekday = TranslateUtils.ToInt(StartWeekday.SelectedValue);
                            taskInfo.StartHour    = TranslateUtils.ToInt(StartHour.SelectedValue);
                        }
                        taskInfo.Description = Description.Text;

                        taskInfo.ServiceParameters = serviceParamters.ToString();

                        taskInfo.IsEnabled       = true;
                        taskInfo.AddDate         = DateTime.Now;
                        taskInfo.OnlyOnceDate    = DateUtils.SqlMinValue;
                        taskInfo.LastExecuteDate = DateUtils.SqlMinValue;

                        DataProvider.TaskDao.Insert(taskInfo);

                        Body.AddSiteLog(PublishmentSystemId, $"添加{EServiceTypeUtils.GetText(taskInfo.ServiceType)}任务", $"任务名称:{taskInfo.TaskName}");

                        SuccessMessage("任务添加成功!");
                        isChanged = true;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "任务添加失败!");
                    }
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPageAndRedirect(Page, PageTask.GetRedirectUrl(PublishmentSystemId, _serviceType));
            }
        }
Пример #11
0
        private HttpResponseMessage GetResponseMessage(VisualInfo visualInfo)
        {
            if (visualInfo.SiteInfo == null || visualInfo.TemplateInfo == null)
            {
                return(null);
            }

            var siteInfo     = visualInfo.SiteInfo;
            var templateInfo = visualInfo.TemplateInfo;

            var pageInfo = new PageInfo(visualInfo.ChannelId, visualInfo.ContentId, siteInfo, templateInfo, new Dictionary <string, object>())
            {
                IsLocal = true
            };
            var contextInfo = new ContextInfo(pageInfo)
            {
                ContextType = visualInfo.ContextType
            };

            var contentBuilder = new StringBuilder(TemplateManager.GetTemplateContent(siteInfo, templateInfo));

            //需要完善,考虑单页模板、内容正文、翻页及外部链接

            if (templateInfo.TemplateType == TemplateType.FileTemplate)           //单页
            {
                var fileContentBuilder = new StringBuilder(TemplateManager.GetTemplateContent(siteInfo, templateInfo));
                Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);
                return(Response(fileContentBuilder.ToString(), siteInfo));
            }
            if (templateInfo.TemplateType == TemplateType.IndexPageTemplate || templateInfo.TemplateType == TemplateType.ChannelTemplate)        //栏目页面
            {
                var nodeInfo = ChannelManager.GetChannelInfo(siteInfo.Id, visualInfo.ChannelId);
                if (nodeInfo == null)
                {
                    return(null);
                }

                if (nodeInfo.ParentId > 0)
                {
                    if (!string.IsNullOrEmpty(nodeInfo.LinkUrl))
                    {
                        PageUtils.Redirect(nodeInfo.LinkUrl);
                        return(null);
                    }
                }

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                //如果标签中存在Content
                var stlContentElement = string.Empty;

                foreach (var label in stlLabelList)
                {
                    if (StlParserUtility.IsStlChannelElement(label, ChannelAttribute.PageContent))
                    {
                        stlContentElement = label;
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(stlContentElement))//内容存在
                {
                    var innerBuilder = new StringBuilder(stlContentElement);
                    StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                    var contentAttributeHtml = innerBuilder.ToString();
                    var pageCount            = StringUtils.GetCount(ContentUtility.PagePlaceHolder, contentAttributeHtml) + 1;//一共需要的页数
                    if (pageCount > 1)
                    {
                        Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                        for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var index  = contentAttributeHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
                            var length = index == -1 ? contentAttributeHtml.Length : index;

                            if (currentPageIndex == visualInfo.PageIndex)
                            {
                                var pagedContentAttributeHtml = contentAttributeHtml.Substring(0, length);
                                var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlContentElement, pagedContentAttributeHtml));
                                StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, 0);

                                return(Response(pagedBuilder.ToString(), siteInfo));
                            }

                            if (index != -1)
                            {
                                contentAttributeHtml = contentAttributeHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
                            }
                        }
                        return(null);
                    }
                    contentBuilder.Replace(stlContentElement, contentAttributeHtml);
                }

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))//如果标签中存在<stl:pageContents>
                {
                    var stlElement           = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);

                    var pageContentsElementParser = new StlPageContents(stlElement, pageInfo, contextInfo, false);
                    int totalNum;
                    var pageCount = pageContentsElementParser.GetPageCount(out totalNum);

                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml     = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, false);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlLabelList))//如果标签中存在<stl:pageChannels>
                {
                    var stlElement           = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);

                    var pageChannelsElementParser = new StlPageChannels(stlElement, pageInfo, contextInfo, false);
                    int totalNum;
                    var pageCount = pageChannelsElementParser.GetPageCount(out totalNum);

                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml     = pageChannelsElementParser.Parse(currentPageIndex, pageCount);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList))//如果标签中存在<stl:pageSqlContents>
                {
                    var stlElement           = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);

                    var pageSqlContentsElementParser = new StlPageSqlContents(stlElement, pageInfo, contextInfo, false);
                    int totalNum;
                    var pageCount = pageSqlContentsElementParser.GetPageCount(out totalNum);

                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml     = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageChannelId, currentPageIndex, pageCount, totalNum);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }
                    }
                }

                Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);
                return(Response(contentBuilder.ToString(), siteInfo));
            }
            if (templateInfo.TemplateType == TemplateType.ContentTemplate)        //内容页面
            {
                if (contextInfo.ContentInfo == null)
                {
                    return(null);
                }

                if (!string.IsNullOrEmpty(contextInfo.ContentInfo.GetString(ContentAttribute.LinkUrl)))
                {
                    PageUtils.Redirect(contextInfo.ContentInfo.GetString(ContentAttribute.LinkUrl));
                    return(null);
                }

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                if (StlParserUtility.IsStlContentElementWithTypePageContent(stlLabelList))//内容存在
                {
                    var stlElement           = StlParserUtility.GetStlContentElementWithTypePageContent(stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);
                    contentBuilder.Replace(stlElement, stlElementTranslated);

                    var innerBuilder = new StringBuilder(stlElement);
                    StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                    var pageContentHtml = innerBuilder.ToString();
                    var pageCount       = StringUtils.GetCount(ContentUtility.PagePlaceHolder, pageContentHtml) + 1;//一共需要的页数
                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        var index  = pageContentHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
                        var length = index == -1 ? pageContentHtml.Length : index;

                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml = pageContentHtml.Substring(0, length);

                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInContentPage(pagedBuilder, thePageInfo, stlLabelList, visualInfo.ChannelId, visualInfo.ContentId, currentPageIndex, pageCount);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }

                        if (index != -1)
                        {
                            pageContentHtml = pageContentHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
                        }
                    }
                }

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))//如果标签中存在<stl:pageContents>
                {
                    var stlElement           = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);

                    var pageContentsElementParser = new StlPageContents(stlElement, pageInfo, contextInfo, false);
                    int totalNum;
                    var pageCount = pageContentsElementParser.GetPageCount(out totalNum);

                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml     = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, false);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInContentPage(pagedBuilder, thePageInfo, stlLabelList, visualInfo.ChannelId, visualInfo.ContentId, currentPageIndex, pageCount);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlLabelList))//如果标签中存在<stl:pageChannels>
                {
                    var stlElement           = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);

                    var pageChannelsElementParser = new StlPageChannels(stlElement, pageInfo, contextInfo, false);
                    int totalNum;
                    var pageCount = pageChannelsElementParser.GetPageCount(out totalNum);

                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml     = pageChannelsElementParser.Parse(currentPageIndex, pageCount);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInContentPage(pagedBuilder, thePageInfo, stlLabelList, visualInfo.ChannelId, visualInfo.ContentId, currentPageIndex, pageCount);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }
                    }
                }
                else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlLabelList))//如果标签中存在<stl:pageSqlContents>
                {
                    var stlElement           = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlLabelList);
                    var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);

                    var pageSqlContentsElementParser = new StlPageSqlContents(stlElement, pageInfo, contextInfo, false);
                    int totalNum;
                    var pageCount = pageSqlContentsElementParser.GetPageCount(out totalNum);

                    Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex == visualInfo.PageIndex)
                        {
                            var thePageInfo = pageInfo.Clone();
                            thePageInfo.IsLocal = true;

                            var pageHtml     = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount);
                            var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

                            StlParserManager.ReplacePageElementsInContentPage(pagedBuilder, thePageInfo, stlLabelList, visualInfo.ChannelId, visualInfo.ContentId, currentPageIndex, pageCount);

                            return(Response(pagedBuilder.ToString(), siteInfo));
                        }
                    }
                }

                Parser.Parse(siteInfo, pageInfo, contextInfo, contentBuilder, visualInfo.FilePath, true);
                StlParserManager.ReplacePageElementsInContentPage(contentBuilder, pageInfo, stlLabelList, contextInfo.ContentInfo.ChannelId, contextInfo.ContentInfo.Id, 0, 1);
                return(Response(contentBuilder.ToString(), siteInfo));
            }

            return(null);
        }
Пример #12
0
        public IActionResult OnGet()
        {
            var initResult = Init();

            if (initResult != null)
            {
                return(initResult);
            }

            var entMan = new EntityManager();
            var recMan = new RecordManager();

            #region << InitPage >>
            int           pager     = 1;
            string        sortBy    = "";
            QuerySortType sortOrder = QuerySortType.Ascending;
            PageUtils.GetListQueryParams(PageContext.HttpContext, out pager, out sortBy, out sortOrder);
            Pager     = pager;
            SortBy    = sortBy;
            SortOrder = sortOrder;

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;

            if (ErpEntity == null)
            {
                return(NotFound());
            }

            ReadAccess   = SecurityContext.HasEntityPermission(EntityPermission.Read, ErpEntity);
            CreateAccess = SecurityContext.HasEntityPermission(EntityPermission.Create, ErpEntity);
            UpdateAccess = SecurityContext.HasEntityPermission(EntityPermission.Update, ErpEntity);
            DeleteAccess = SecurityContext.HasEntityPermission(EntityPermission.Delete, ErpEntity);

            if (string.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/";
            }

            Fields = ErpEntity.Fields.OrderBy(x => x.Name).ToList();
            var idField = Fields.Single(x => x.Name == "id");
            Fields.Remove(idField);
            Fields = Fields.OrderBy(x => x.Name).ToList();
            Fields.Insert(0, idField);

            List <QueryObject> filterQueries = new List <QueryObject>();

            #region << Process filters >>

            var submittedFilters = PageUtils.GetPageFiltersFromQuery(PageContext.HttpContext);
            if (submittedFilters.Count > 0)
            {
                foreach (var filter in submittedFilters)
                {
                    if (!ErpEntity.Fields.Any(x => x.Name == filter.Name))
                    {
                        continue;
                    }

                    switch (filter.Type)
                    {
                    case FilterType.EQ:
                        filterQueries.Add(EntityQuery.QueryEQ(filter.Name, filter.Value));
                        break;

                    case FilterType.CONTAINS:
                        filterQueries.Add(EntityQuery.QueryContains(filter.Name, filter.Value));
                        break;

                    case FilterType.FTS:
                        filterQueries.Add(EntityQuery.QueryFTS(filter.Name, filter.Value));
                        break;

                    case FilterType.STARTSWITH:
                        filterQueries.Add(EntityQuery.QueryStartsWith(filter.Name, filter.Value));
                        break;

                    case FilterType.REGEX:
                        filterQueries.Add(EntityQuery.QueryRegex(filter.Name, filter.Value));
                        break;
                    }
                }
            }
            #endregion


            #region << Process Sort >>

            var sort = new List <QuerySortObject> {
                new QuerySortObject("id", QuerySortType.Ascending)
            };
            if (!String.IsNullOrWhiteSpace(SortBy) && Fields.Any(x => x.Name == SortBy))
            {
                sort = new List <QuerySortObject> {
                    new QuerySortObject(SortBy, SortOrder == QuerySortType.Ascending ? QuerySortType.Ascending : QuerySortType.Descending)
                }
            }
            ;

            #endregion

            if (!ReadAccess)
            {
                Records    = new List <EntityRecord>();
                TotalCount = 0;

                Validation.Message = "You have no permissions to view records.";
                Validation.Errors.Add(new ValidationError("", "You have no permissions to view records."));
            }
            else
            {
                EntityQuery enQuery = null;

                if (filterQueries.Any())
                {
                    enQuery = new EntityQuery(ErpEntity.Name, query: EntityQuery.QueryAND(filterQueries.ToArray()), sort: sort.ToArray(), skip: (pager - 1) * PagerSize, limit: PagerSize);
                }
                else
                {
                    enQuery = new EntityQuery(ErpEntity.Name, sort: sort.ToArray(), skip: (pager - 1) * PagerSize, limit: PagerSize);
                }

                var queryResponse = recMan.Find(enQuery);
                if (!queryResponse.Success)
                {
                    throw new Exception(queryResponse.Message);
                }

                Records    = queryResponse.Object.Data;
                TotalCount = (int)recMan.Count(enQuery).Object;
            }

            ReturnUrlEncoded = HttpUtility.UrlEncode(PageUtils.GetCurrentUrl(PageContext.HttpContext));
            PageDescription  = PageUtils.GenerateListPageDescription(PageContext.HttpContext, "", TotalCount);
            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "data"));

            #endregion

            #region << Create Columns >>

            Columns.Add(new WvGridColumnMeta()
            {
                Name       = "",
                Label      = "",
                Width      = "90px",
                Sortable   = false,
                Searchable = false
            });

            foreach (var field in Fields)
            {
                var fieldAccess            = GetFieldAccess(field);
                var searchAndSortAvailable = field.Searchable && (fieldAccess == WvFieldAccess.Full || fieldAccess == WvFieldAccess.ReadOnly);
                var column = new WvGridColumnMeta()
                {
                    Name       = field.Name,
                    Label      = field.Name,                //should present just the name not to confuse
                    Sortable   = searchAndSortAvailable,
                    Searchable = searchAndSortAvailable
                };

                if (field.GetFieldType() == FieldType.GuidField)
                {
                    column.Width = "1%";
                }

                Columns.Add(column);
            }

            #endregion

            #region << Filters >>

            foreach (var field in Fields)
            {
                //remove fields with no access from search
                var fieldAccess = GetFieldAccess(field);
                var searchable  = field.Searchable && (fieldAccess == WvFieldAccess.Full || fieldAccess == WvFieldAccess.ReadOnly);
                if (!searchable)
                {
                    continue;
                }

                if (field.Name == "id")
                {
                    dynamic filterObj = new ExpandoObject();
                    filterObj.Name         = field.Name;
                    filterObj.Label        = field.Label;
                    filterObj.Type         = FilterType.EQ;
                    filterObj.AllowedTypes = new List <FilterType> {
                        FilterType.EQ
                    };
                    Filters.Add(filterObj);
                }
                else if (field.Searchable)
                {
                    dynamic filterObj = new ExpandoObject();
                    filterObj.Name         = field.Name;
                    filterObj.Label        = field.Label;
                    filterObj.Type         = FilterType.EQ;
                    filterObj.AllowedTypes = new List <FilterType> {
                        FilterType.EQ, FilterType.NOT
                    };

                    var fieldType = field.GetFieldType();
                    if (fieldType == FieldType.TextField || fieldType == FieldType.MultiLineTextField ||
                        fieldType == FieldType.UrlField || fieldType == FieldType.EmailField || fieldType == FieldType.HtmlField ||
                        fieldType == FieldType.SelectField || fieldType == FieldType.MultiSelectField)
                    {
                        filterObj.AllowedTypes.Add(FilterType.REGEX);
                        filterObj.AllowedTypes.Add(FilterType.FTS);
                        filterObj.AllowedTypes.Add(FilterType.STARTSWITH);
                        filterObj.AllowedTypes.Add(FilterType.CONTAINS);
                    }

                    Filters.Add(filterObj);
                }
            }

            #endregion

            BeforeRender();
            return(Page());
        }
Пример #13
0
        public static string GetCategoryRowHtml(GovPublicCategoryInfo categoryInfo, bool enabled, EGovPublicCategoryLoadingType loadingType, NameValueCollection additional)
        {
            var treeItem = GovPublicCategoryTreeItem.CreateInstance(categoryInfo, enabled);
            var title    = treeItem.GetItemHtml(loadingType);

            var rowHtml = string.Empty;

            if (loadingType == EGovPublicCategoryLoadingType.Tree || loadingType == EGovPublicCategoryLoadingType.Select)
            {
                rowHtml = $@"
<tr treeItemLevel=""{categoryInfo.ParentsCount + 1}"">
	<td nowrap>
		{title}
	</td>
</tr>
";
            }
            else if (loadingType == EGovPublicCategoryLoadingType.List)
            {
                var editUrl      = string.Empty;
                var upLink       = string.Empty;
                var downLink     = string.Empty;
                var checkBoxHtml = string.Empty;

                if (enabled)
                {
                    editUrl =
                        $@"<a href=""javascript:;"" onclick=""{ModalGovPublicCategoryAdd.GetOpenWindowStringToEdit(
                            categoryInfo.ClassCode, categoryInfo.PublishmentSystemID, categoryInfo.CategoryID,
                            GetRedirectUrl(categoryInfo.PublishmentSystemID, categoryInfo.ClassCode, categoryInfo.CategoryID))}"">编辑</a>";

                    var urlUp = PageUtils.GetWcmUrl(nameof(PageGovPublicCategory), new NameValueCollection
                    {
                        { "siteId", categoryInfo.PublishmentSystemID.ToString() },
                        { "ClassCode", categoryInfo.ClassCode },
                        { "Subtract", true.ToString() },
                        { "CategoryID", categoryInfo.CategoryID.ToString() }
                    });
                    upLink = $@"<a href=""{urlUp}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升"" /></a>";

                    var urlDown = PageUtils.GetWcmUrl(nameof(PageGovPublicCategory), new NameValueCollection
                    {
                        { "siteId", categoryInfo.PublishmentSystemID.ToString() },
                        { "ClassCode", categoryInfo.ClassCode },
                        { "Add", true.ToString() },
                        { "CategoryID", categoryInfo.CategoryID.ToString() }
                    });
                    downLink =
                        $@"<a href=""{urlDown}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降"" /></a>";

                    checkBoxHtml =
                        $"<input type='checkbox' name='CategoryIDCollection' value='{categoryInfo.CategoryID}' />";
                }

                rowHtml = $@"
<tr treeItemLevel=""{categoryInfo.ParentsCount + 1}"">
    <td>{title}</td>
    <td>{categoryInfo.CategoryCode}</td>
    <td class=""center"">{upLink}</td>
    <td class=""center"">{downLink}</td>
    <td class=""center"">{editUrl}</td>
    <td class=""center"">{checkBoxHtml}</td>
</tr>
";
            }
            return(rowHtml);
        }
Пример #14
0
 public static string GetRedirectUrl(int publishmentSystemID, int collectID, string returnUrl)
 {
     return(PageUtils.GetWXUrl(
                $"background_collectLog.aspx?publishmentSystemID={publishmentSystemID}&collectID={collectID}&returnUrl={StringUtils.ValueToUrl(returnUrl)}"));
 }
Пример #15
0
 public static string GetRedirectUrl(int siteId)
 {
     return(PageUtils.GetCmsUrl(siteId, nameof(PageTemplate), null));
 }
Пример #16
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            SpContents.ControlToPaginate = RptContents;
            SpContents.ItemsPerPage      = StringUtils.Constants.PageSize;

            SpContents.SelectCommand = !AuthRequest.IsQueryExists("Keyword") ? DataProvider.LogDao.GetSelectCommend() : DataProvider.LogDao.GetSelectCommend(AuthRequest.GetQueryString("UserName"), AuthRequest.GetQueryString("Keyword"), AuthRequest.GetQueryString("DateFrom"), AuthRequest.GetQueryString("DateTo"));

            SpContents.SortField       = nameof(LogInfo.Id);
            SpContents.SortMode        = SortMode.DESC;
            RptContents.ItemDataBound += RptContents_ItemDataBound;

            if (IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.SettingsPermissions.Log);

            if (AuthRequest.IsQueryExists("Keyword"))
            {
                TbUserName.Text = AuthRequest.GetQueryString("UserName");
                TbKeyword.Text  = AuthRequest.GetQueryString("Keyword");
                TbDateFrom.Text = AuthRequest.GetQueryString("DateFrom");
                TbDateTo.Text   = AuthRequest.GetQueryString("DateTo");
            }

            if (AuthRequest.IsQueryExists("Delete"))
            {
                var arraylist = TranslateUtils.StringCollectionToIntList(AuthRequest.GetQueryString("IDCollection"));
                try
                {
                    DataProvider.LogDao.Delete(arraylist);
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (AuthRequest.IsQueryExists("DeleteAll"))
            {
                DataProvider.LogDao.DeleteAll();
                SuccessDeleteMessage();
            }
            else if (AuthRequest.IsQueryExists("Setting"))
            {
                ConfigManager.SystemConfigInfo.IsLogAdmin = !ConfigManager.SystemConfigInfo.IsLogAdmin;
                DataProvider.ConfigDao.Update(ConfigManager.Instance);
                SuccessMessage($"成功{(ConfigManager.SystemConfigInfo.IsLogAdmin ? "启用" : "禁用")}日志记录");
            }

            BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
            {
                { "Delete", "True" }
            }), "IDCollection", "IDCollection", "请选择需要删除的日志!", "此操作将删除所选日志,确认吗?"));

            BtnDeleteAll.Attributes.Add("onclick",
                                        AlertUtils.ConfirmRedirect("删除所有日志", "此操作将删除所有日志信息,确定吗?", "删除全部",
                                                                   PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
            {
                { "DeleteAll", "True" }
            })));

            if (ConfigManager.SystemConfigInfo.IsLogAdmin)
            {
                BtnSetting.Text = "禁用管理员日志";
                BtnSetting.Attributes.Add("onclick",
                                          AlertUtils.ConfirmRedirect("禁用管理员日志", "此操作将禁用管理员日志记录功能,确定吗?", "禁 用",
                                                                     PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
                {
                    { "Setting", "True" }
                })));
            }
            else
            {
                LtlState.Text   = @"<div class=""alert alert-danger m-t-10"">管理员日志当前处于禁用状态,系统将不会记录管理员操作日志!</div>";
                BtnSetting.Text = "启用管理员日志";
                BtnSetting.Attributes.Add("onclick",
                                          AlertUtils.ConfirmRedirect("启用管理员日志", "此操作将启用管理员日志记录功能,确定吗?", "启 用",
                                                                     PageUtils.GetSettingsUrl(nameof(PageLogAdmin), new NameValueCollection
                {
                    { "Setting", "True" }
                })));
            }

            SpContents.DataBind();
        }
Пример #17
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            _templateType = AuthRequest.GetQueryString("templateType");
            _keywords     = AuthRequest.GetQueryString("keywords");

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

            DdlTemplateType.Items.Add(new ListItem("<所有类型>", string.Empty));
            TemplateTypeUtils.AddListItems(DdlTemplateType);
            ControlUtils.SelectSingleItem(DdlTemplateType, _templateType);

            TbKeywords.Text = _keywords;

            if (AuthRequest.IsQueryExists("Delete"))
            {
                var templateId = AuthRequest.GetQueryInt("TemplateID");

                try
                {
                    var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId);
                    if (templateInfo != null)
                    {
                        DataProvider.TemplateDao.Delete(SiteId, templateId);
                        AuthRequest.AddSiteLog(SiteId,
                                               $"删除{TemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                               $"模板名称:{templateInfo.TemplateName}");
                    }
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (AuthRequest.IsQueryExists("SetDefault"))
            {
                var templateId = AuthRequest.GetQueryInt("TemplateID");

                try
                {
                    var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId);
                    if (templateInfo != null)
                    {
                        DataProvider.TemplateDao.SetDefault(SiteId, templateId);
                        AuthRequest.AddSiteLog(SiteId,
                                               $"设置默认{TemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                               $"模板名称:{templateInfo.TemplateName}");
                    }
                    SuccessMessage();
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败");
                }
            }

            if (string.IsNullOrEmpty(_templateType))
            {
                LtlCommands.Text = $@"
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.IndexPageTemplate)}';"" value=""添加首页模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.ChannelTemplate)}';"" value=""添加栏目模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.ContentTemplate)}';"" value=""添加内容模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.FileTemplate)}';"" value=""添加单页模板"" />
";
            }
            else
            {
                var templateType = TemplateTypeUtils.GetEnumType(_templateType);
                LtlCommands.Text = $@"
<input type=""button"" class=""btn btn-success"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, templateType)}';"" value=""添加{TemplateTypeUtils.GetText(templateType)}"" />
";
            }

            RptContents.DataSource     = DataProvider.TemplateDao.GetDataSource(SiteId, _keywords, _templateType);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();
        }
Пример #18
0
        public IHttpActionResult Main()
        {
            try
            {
                var request = new AuthRequest();
                var form    = request.GetPostCollection();

                var isAllSites    = request.GetPostBool(StlSearch.IsAllSites.Name.ToLower());
                var siteName      = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.SiteName.Name.ToLower()));
                var siteDir       = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.SiteDir.Name.ToLower()));
                var siteIds       = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.SiteIds.Name.ToLower()));
                var channelIndex  = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.ChannelIndex.Name.ToLower()));
                var channelName   = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.ChannelName.Name.ToLower()));
                var channelIds    = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.ChannelIds.Name.ToLower()));
                var type          = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.Type.Name.ToLower()));
                var word          = PageUtils.FilterSql(request.GetPostString(StlSearch.Word.Name.ToLower()));
                var dateAttribute = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.DateAttribute.Name.ToLower()));
                var dateFrom      = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.DateFrom.Name.ToLower()));
                var dateTo        = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.DateTo.Name.ToLower()));
                var since         = PageUtils.FilterSqlAndXss(request.GetPostString(StlSearch.Since.Name.ToLower()));
                var pageNum       = request.GetPostInt(StlSearch.PageNum.Name.ToLower());
                var isHighlight   = request.GetPostBool(StlSearch.IsHighlight.Name.ToLower());
                var siteId        = request.GetPostInt("siteid");
                var ajaxDivId     = PageUtils.FilterSqlAndXss(request.GetPostString("ajaxdivid"));
                var template      = TranslateUtils.DecryptStringBySecretKey(request.GetPostString("template"));
                var pageIndex     = request.GetPostInt("page", 1) - 1;

                var templateInfo = new TemplateInfo(0, siteId, string.Empty, TemplateType.FileTemplate, string.Empty, string.Empty, string.Empty, ECharset.utf_8, false);
                var siteInfo     = SiteManager.GetSiteInfo(siteId);
                var pageInfo     = new PageInfo(siteId, 0, siteInfo, templateInfo, new Dictionary <string, object>())
                {
                    UserInfo = request.UserInfo
                };
                var contextInfo    = new ContextInfo(pageInfo);
                var contentBuilder = new StringBuilder(StlRequestEntities.ParseRequestEntities(form, template));

                var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());

                if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
                {
                    var stlElement             = StlParserUtility.GetStlElement(StlPageContents.ElementName, stlLabelList);
                    var stlPageContentsElement = stlElement;
                    var stlPageContentsElementReplaceString = stlElement;

                    var whereString = DataProvider.ContentDao.GetWhereStringByStlSearch(isAllSites, siteName, siteDir, siteIds, channelIndex, channelName, channelIds, type, word, dateAttribute, dateFrom, dateTo, since, siteId, ApiRouteActionsSearch.ExlcudeAttributeNames, form);

                    var stlPageContents = new StlPageContents(stlPageContentsElement, pageInfo, contextInfo, pageNum, siteInfo.TableName, whereString);

                    int totalNum;
                    var pageCount = stlPageContents.GetPageCount(out totalNum);

                    if (totalNum == 0)
                    {
                        return(NotFound());
                    }

                    for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                    {
                        if (currentPageIndex != pageIndex)
                        {
                            continue;
                        }

                        var pageHtml     = stlPageContents.Parse(totalNum, currentPageIndex, pageCount, false);
                        var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlPageContentsElementReplaceString, pageHtml));

                        StlParserManager.ReplacePageElementsInSearchPage(pagedBuilder, pageInfo, stlLabelList, ajaxDivId, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum);

                        if (isHighlight && !string.IsNullOrEmpty(word))
                        {
                            var pagedContents = pagedBuilder.ToString();
                            pagedBuilder = new StringBuilder();
                            pagedBuilder.Append(RegexUtils.Replace(
                                                    $"({word.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", pagedContents,
                                                    $"<span style='color:#cc0000'>{word}</span>"));
                        }

                        Parser.Parse(pageInfo, contextInfo, pagedBuilder, string.Empty, false);
                        return(Ok(pagedBuilder.ToString()));
                    }
                }

                Parser.Parse(pageInfo, contextInfo, contentBuilder, string.Empty, false);
                return(Ok(contentBuilder.ToString()));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #19
0
        private static List <Tab> GetTopMenus(SiteInfo siteInfo, bool isSuperAdmin, List <int> siteIdListLatestAccessed, List <int> siteIdListWithPermissions)
        {
            var menus = new List <Tab>();

            if (siteInfo != null && siteIdListWithPermissions.Contains(siteInfo.Id))
            {
                var siteMenus = new List <Tab>();
                if (siteIdListWithPermissions.Count == 1)
                {
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Children = siteMenus.ToArray()
                    });
                }
                else
                {
                    var siteIdList = AdminManager.GetLatestTop10SiteIdList(siteIdListLatestAccessed, siteIdListWithPermissions);
                    foreach (var siteId in siteIdList)
                    {
                        var site = SiteManager.GetSiteInfo(siteId);
                        if (site == null)
                        {
                            continue;
                        }

                        siteMenus.Add(new Tab
                        {
                            Href   = PageUtils.GetMainUrl(site.Id),
                            Target = "_top",
                            Text   = site.SiteName
                        });
                    }
                    siteMenus.Add(new Tab
                    {
                        Href   = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target = "_layer",
                        Text   = "全部站点..."
                    });
                    menus.Add(new Tab
                    {
                        Text     = siteInfo.SiteName,
                        Href     = ModalSiteSelect.GetRedirectUrl(siteInfo.Id),
                        Target   = "_layer",
                        Children = siteMenus.ToArray()
                    });
                }

                var linkMenus = new List <Tab>
                {
                    //new Tab {Href = PageUtility.GetSiteUrl(siteInfo, false), Target = "_blank", Text = "访问站点"},
                    //new Tab {Href = ApiRoutePreview.GetSiteUrl(siteInfo.Id), Target = "_blank", Text = "预览站点"}
                };
                //menus.Add(new Tab {Text = "站点链接", Children = linkMenus.ToArray()});                    modify on 2019/1/18
            }

            if (isSuperAdmin)
            {
                foreach (var tab in TabManager.GetTopMenuTabs())
                {
                    var tabs = TabManager.GetTabList(tab.Id, 0);
                    tab.Children = tabs.ToArray();

                    menus.Add(tab);
                }
            }

            return(menus);
        }
Пример #20
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var taskID       = 0;
            var checkedLevel = TranslateUtils.ToIntWithNagetive(rblCheckType.SelectedValue);
            var isChecked    = false;
            var isTask       = false;

            if (checkedLevel >= PublishmentSystemInfo.CheckContentLevel)
            {
                isChecked = true;
            }
            else
            {
                isChecked = false;
            }

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

            foreach (var nodeID in _idsDictionary.Keys)
            {
                var tableStyle                = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeID);
                var tableName                 = NodeManager.GetTableName(PublishmentSystemInfo, nodeID);
                var contentIDArrayList        = _idsDictionary[nodeID];
                var contentIDArrayListToCheck = new List <int>();

                var checkedLevelOfUser = 0;
                var isCheckedOfUser    = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevelOfUser);

                foreach (int contentID in contentIDArrayList)
                {
                    var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentID);
                    if (contentInfo != null)
                    {
                        if (LevelManager.IsCheckable(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            contentInfoArrayListToCheck.Add(contentInfo);
                            contentIDArrayListToCheck.Add(contentID);
                        }

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

                        if (contentInfo.IsChecked)
                        {
                            CreateManager.CreateContentAndTrigger(PublishmentSystemId, contentInfo.NodeId, contentID);
                        }
                    }
                }
                if (contentIDArrayListToCheck.Count > 0)
                {
                    idsDictionaryToCheck[nodeID] = contentIDArrayListToCheck;
                }
            }

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

                    foreach (int nodeID in idsDictionaryToCheck.Keys)
                    {
                        var tableName          = NodeManager.GetTableName(PublishmentSystemInfo, nodeID);
                        var contentIDArrayList = idsDictionaryToCheck[nodeID];
                        BaiRongDataProvider.ContentDao.UpdateIsChecked(tableName, PublishmentSystemId, nodeID, contentIDArrayList, translateNodeID, true, Body.AdministratorName, isChecked, checkedLevel, tbCheckReasons.Text);

                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, nodeID, true);
                    }

                    if (translateNodeID > 0)
                    {
                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, translateNodeID, true);
                    }

                    Body.AddSiteLog(PublishmentSystemId, PublishmentSystemId, 0, "设置内容状态为" + rblCheckType.SelectedItem.Text, tbCheckReasons.Text);

                    if (isChecked)
                    {
                        foreach (int nodeID in idsDictionaryToCheck.Keys)
                        {
                            var contentIDArrayList = _idsDictionary[nodeID];
                            if (contentIDArrayList != null)
                            {
                                foreach (int contentID in contentIDArrayList)
                                {
                                    CreateManager.CreateContent(PublishmentSystemId, nodeID, contentID);
                                }
                            }
                        }
                    }

                    PageUtils.CloseModalPageAndRedirect(Page, _returnUrl);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败!");
                }
            }
        }
Пример #21
0
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var publishmentSystemId = body.GetPostInt("publishmentSystemId");
                var nodeId = body.GetPostInt("nodeId");

                var searchType = PageUtils.FilterSqlAndXss(body.GetPostString("searchType"));
                var keyword    = PageUtils.FilterSqlAndXss(body.GetPostString("keyword"));
                var dateFrom   = PageUtils.FilterSqlAndXss(body.GetPostString("dateFrom"));
                var dateTo     = PageUtils.FilterSqlAndXss(body.GetPostString("dateTo"));
                var page       = body.GetPostInt("page");

                var user          = new User(body.UserInfo);
                var groupInfo     = UserGroupManager.GetGroupInfo(user.GroupId);
                var adminUserName = groupInfo.Additional.WritingAdminUserName;

                var nodeIdList = new List <int> {
                    nodeId
                };

                var writingNodeInfoList = PublishmentSystemManager.GetWritingNodeInfoList(adminUserName, publishmentSystemId);
                foreach (var writingNodeInfo in writingNodeInfoList)
                {
                    if (StringUtils.In(writingNodeInfo.ParentsPath, nodeId.ToString()))
                    {
                        nodeIdList.Add(writingNodeInfo.NodeId);
                    }
                }

                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var nodeInfo          = NodeManager.GetNodeInfo(publishmentSystemId, nodeId);
                var tableName         = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
                var tableStyle        = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
                var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemId, nodeId);

                var sqlString = DataProvider.ContentDao.GetWritingSelectCommend(user.UserName, tableName, publishmentSystemId, nodeIdList, searchType, keyword, dateFrom, dateTo);

                var results  = new List <Dictionary <string, object> >();
                var sqlPager = new SqlPager
                {
                    ItemsPerPage  = 20,
                    SelectCommand = sqlString,
                    OrderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByAddDateDesc)
                };

                sqlPager.DataBind(page);

                if (sqlPager.TotalCount > 0)
                {
                    foreach (System.Data.DataRowView row in sqlPager.PagedDataSource.DataSource)
                    {
                        var contentInfo = new ContentInfo(row);
                        results.Add(ContentUtility.ContentToDictionary(contentInfo, tableStyle, tableName, relatedIdentities));
                    }
                }

                return(Ok(new
                {
                    Results = results,
                    TotalPage = sqlPager.TotalPages
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #22
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID", "ReturnUrl");
            _returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("ReturnUrl"));

            _idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString);

            if (!IsPostBack)
            {
                var         checkTaskTotal    = 0;
                var         checkContentTotal = 0;
                var         unCheckTaskTotal  = 0;
                ContentInfo contentInfo;
                var         titles = new StringBuilder();
                foreach (var nodeID in _idsDictionary.Keys)
                {
                    var tableStyle    = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeID);
                    var tableName     = NodeManager.GetTableName(PublishmentSystemInfo, nodeID);
                    var contentIdList = _idsDictionary[nodeID];
                    foreach (var contentId in contentIdList)
                    {
                        checkContentTotal++;
                        contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentId);

                        titles.Append(contentInfo.Title + "<br />");
                    }
                }

                if (!string.IsNullOrEmpty(ltlTitles.Text))
                {
                    titles.Length -= 6;
                }
                ltlTitles.Text = titles.ToString();

                var checkedLevel = 5;
                var isChecked    = true;

                foreach (var nodeID in _idsDictionary.Keys)
                {
                    int checkedLevelByNodeID;
                    var isCheckedByNodeID = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevelByNodeID);
                    if (checkedLevel > checkedLevelByNodeID)
                    {
                        checkedLevel = checkedLevelByNodeID;
                    }
                    if (!isCheckedByNodeID)
                    {
                        isChecked = isCheckedByNodeID;
                    }
                }

                LevelManager.LoadContentLevelToCheck(rblCheckType, PublishmentSystemInfo, isChecked, checkedLevel);

                var listItem = new ListItem("<保持原栏目不变>", "0");
                ddlTranslateNodeID.Items.Add(listItem);

                NodeManager.AddListItemsForAddContent(ddlTranslateNodeID.Items, PublishmentSystemInfo, true, Body.AdministratorName);
            }
        }
Пример #23
0
        public static string Parse(int siteId, string filePath, bool isClearFormat, bool isFirstLineIndent, bool isClearFontSize, bool isClearFontFamily, bool isClearImages)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(string.Empty);
            }

            var filename = PathUtils.GetFileNameWithoutExtension(filePath);

            //被转换的html文档保存的位置
            try
            {
                var saveFilePath = PathUtils.GetTemporaryFilesPath(filename + ".html");
                FileUtils.DeleteFileIfExists(saveFilePath);
                WordDntb.buildWord(filePath, saveFilePath);

                var parsedContent = FileUtils.ReadText(saveFilePath, System.Text.Encoding.Default);
                parsedContent = RegexUtils.GetInnerContent("body", parsedContent);

                //try
                //{
                //    parsedContent = HtmlClearUtils.ClearElementAttributes(parsedContent, "p");
                //}
                //catch { }

                if (isClearFormat)
                {
                    parsedContent = HtmlClearUtils.ClearFormat(parsedContent);
                }

                if (isFirstLineIndent)
                {
                    parsedContent = HtmlClearUtils.FirstLineIndent(parsedContent);
                }

                if (isClearFontSize)
                {
                    parsedContent = HtmlClearUtils.ClearFontSize(parsedContent);
                }

                if (isClearFontFamily)
                {
                    parsedContent = HtmlClearUtils.ClearFontFamily(parsedContent);
                }

                if (isClearImages)
                {
                    parsedContent = StringUtils.StripTags(parsedContent, "img");
                }
                else
                {
                    var siteInfo = SiteManager.GetSiteInfo(siteId);
                    var imageFileNameArrayList = RegexUtils.GetOriginalImageSrcs(parsedContent);
                    if (imageFileNameArrayList != null && imageFileNameArrayList.Count > 0)
                    {
                        foreach (var imageFileName in imageFileNameArrayList)
                        {
                            var imageFilePath       = PathUtils.GetTemporaryFilesPath(imageFileName);
                            var fileExtension       = PathUtils.GetExtension(imageFilePath);
                            var uploadDirectoryPath = PathUtility.GetUploadDirectoryPath(siteInfo, fileExtension);
                            var uploadDirectoryUrl  = PageUtility.GetSiteUrlByPhysicalPath(siteInfo, uploadDirectoryPath, true);
                            if (!FileUtils.IsFileExists(imageFilePath))
                            {
                                continue;
                            }

                            var uploadFileName = PathUtility.GetUploadFileName(siteInfo, imageFilePath);
                            var destFilePath   = PathUtils.Combine(uploadDirectoryPath, uploadFileName);
                            FileUtils.MoveFile(imageFilePath, destFilePath, false);
                            parsedContent = parsedContent.Replace(imageFileName, PageUtils.Combine(uploadDirectoryUrl, uploadFileName));

                            FileUtils.DeleteFileIfExists(imageFilePath);
                        }
                    }
                }

                FileUtils.DeleteFileIfExists(filePath);
                FileUtils.DeleteFileIfExists(saveFilePath);
                return(parsedContent.Trim());
            }
            catch (Exception ex)
            {
                LogUtils.AddSystemErrorLog(ex);
                return(string.Empty);
            }
        }
Пример #24
0
 public void Return_OnClick(object sender, EventArgs e)
 {
     PageUtils.Redirect(PageContentGroup.GetRedirectUrl(SiteId));
 }
Пример #25
0
        } // RenderView

        public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            string formName = "editFlashObject_" + page.ID.ToString() + identifier.ToString() + langToRenderFor.shortCode;

            FlashObjectDb   db          = (new FlashObjectDb());
            FlashObjectData flashObject = db.getFlashObject(page, identifier, true);

            StringBuilder html = new StringBuilder();
            // ------- CHECK THE FORM FOR ACTIONS
            string action = Hatfield.Web.Portal.PageUtils.getFromForm(formName + "_FlashObjectAction", "");

            if (action.Trim().ToLower() == "saveflashobject")
            {
                flashObject.SWFPath       = PageUtils.getFromForm(formName + "SWFPath", "");
                flashObject.DisplayWidth  = PageUtils.getFromForm(formName + "displayWidth", FlashObject.DefaultDisplayWidth);
                flashObject.DisplayHeight = PageUtils.getFromForm(formName + "displayHeight", FlashObject.DefaultDisplayHeight);
                bool b = db.saveUpdatedFlashObject(page, identifier, flashObject);
                if (!b)
                {
                    html.Append("Error: Flash Object not saved - database error<p><p>");
                }
            }

            // ------- START RENDERING

            // note: no need to put in the <form></form> tags.

            html.Append("<table>");

            html.Append("<tr><td>");
            html.Append("Flash (SWF) Object:");
            html.Append("</td><td>");


            string JSCallbackFunctionName = formName + "_selectPath";

            StringBuilder js = new StringBuilder();

            js.Append("function " + JSCallbackFunctionName + "(selText, selVal) { " + Environment.NewLine);
            // html.Append("alert(selVal);" + Environment.NewLine);
            js.Append(" var selectBox = document.getElementById('" + formName + "SWFPath'); " + Environment.NewLine);
            js.Append(" var found= false; " + Environment.NewLine);
            js.Append(" for (var i =0; i < selectBox.options.length; i++) {" + Environment.NewLine);
            js.Append("   if (selectBox.options[i].text == selText){ " + Environment.NewLine);
            js.Append("      selectBox.options[i].selected = true; found = true; " + Environment.NewLine);
            js.Append("   } // if" + Environment.NewLine);
            js.Append(" } // for" + Environment.NewLine);
            js.Append(" if (!found) { " + Environment.NewLine);
            js.Append("   var newOption = new Option(selText,selVal); " + Environment.NewLine);
            js.Append("   selectBox.options[selectBox.options.length]= newOption;" + Environment.NewLine);
            js.Append("   newOption.selected = true; " + Environment.NewLine);
            js.Append(" } // if ! found" + Environment.NewLine);
            js.Append("}" + Environment.NewLine);

            page.HeadSection.AddJSStatements(js.ToString());

            string SWFPathDropDownHtml = getSWFPathDropdown(formName + "SWFPath", flashObject);

            html.Append(SWFPathDropDownHtml);

            string onclick = "window.open(this.href, 'newWin', 'resizable,height=" + PopupFlashObjectBrowser.PopupHeight + ",width=" + PopupFlashObjectBrowser.PopupWidth + "'); return false;";

            html.Append(" <a href=\"" + PopupFlashObjectBrowser.getUrl(JSCallbackFunctionName) + "\" onclick=\"" + onclick + "\">browse for flash file</a>");

            html.Append("</td></tr>");

            html.Append("<tr><td>");
            html.Append("Width:");
            html.Append("</td><td>");
            html.Append(PageUtils.getInputTextHtml(formName + "displayWidth", formName + "displayWidth", flashObject.DisplayWidth.ToString(), 7, 5));
            html.Append("<br><em>values < 1 will not display the SWF</em>");
            html.Append("</td></tr>");

            html.Append("<tr><td>");
            html.Append("Height:");
            html.Append("</td><td>");
            html.Append(PageUtils.getInputTextHtml(formName + "displayHeight", formName + "displayHeight", flashObject.DisplayHeight.ToString(), 7, 5));
            html.Append("<br><em>values < 1 will not display the SWF</em>");
            html.Append("</td></tr>");

            html.Append("</table>");

            // -- hidden field actions
            html.Append("<input type=\"hidden\" name=\"" + formName + "_FlashObjectAction\" value=\"saveflashobject\">");

            writer.WriteLine(html.ToString());
        }
Пример #26
0
        public void Page_Load(object sender, EventArgs e)
        {
            PageUtils.CheckRequestParameter("PublishmentSystemID");

            _adAreadId = Body.GetQueryInt("AdAreaID");
            if (Body.IsQueryExists("AdvID"))
            {
                _isEdit = true;
                _advId  = Body.GetQueryInt("AdvID");
            }

            if (!Page.IsPostBack)
            {
                var pageTitle = _isEdit ? "编辑广告" : "添加广告";
                BreadCrumb(AppManager.Cms.LeftMenu.IdFunction, AppManager.Cms.LeftMenu.Function.IdAdvertisement, pageTitle, AppManager.Cms.Permission.WebSite.Advertisement);

                ltlPageTitle.Text = pageTitle;

                StartDate.Text = DateUtils.GetDateAndTimeString(DateTime.Now);
                EndDate.Text   = DateUtils.GetDateAndTimeString(DateTime.Now.AddMonths(1));

                var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(PublishmentSystemId);
                var nodeCount  = nodeIdList.Count;
                _isLastNodeArray = new bool[nodeCount];
                foreach (int theNodeID in nodeIdList)
                {
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, theNodeID);

                    var title    = WebUtils.GetChannelListBoxTitle(PublishmentSystemId, nodeInfo.NodeId, nodeInfo.NodeName, nodeInfo.NodeType, nodeInfo.ParentsCount, nodeInfo.IsLastNode, _isLastNodeArray);
                    var listitem = new ListItem(title, nodeInfo.NodeId.ToString());
                    NodeIDCollectionToChannel.Items.Add(listitem);
                    title = title + $"({nodeInfo.ContentNum})";
                    var listitem2 = new ListItem(title, nodeInfo.NodeId.ToString());
                    NodeIDCollectionToContent.Items.Add(listitem2);
                }

                var fileTemplateInfoArrayList = DataProvider.TemplateDao.GetTemplateInfoArrayListByType(PublishmentSystemId, ETemplateType.FileTemplate);
                if (fileTemplateInfoArrayList.Count > 0)
                {
                    foreach (TemplateInfo fileTemplateInfo in fileTemplateInfoArrayList)
                    {
                        var listitem = new ListItem(fileTemplateInfo.CreatedFileFullName, fileTemplateInfo.TemplateId.ToString());
                        FileTemplateIDCollection.Items.Add(listitem);
                    }
                }
                else
                {
                    FileTemplateIDCollectionRow.Visible = false;
                }

                EBooleanUtils.AddListItems(IsEnabled);
                ControlUtils.SelectListItems(IsEnabled, true.ToString());

                EAdvLevelTypeUtils.AddListItems(LevelType);
                ControlUtils.SelectListItems(LevelType, EAdvLevelTypeUtils.GetValue(EAdvLevelType.Hold));

                EAdvLevelUtils.AddListItems(Level);
                ControlUtils.SelectListItems(Level, EAdvLevelUtils.GetValue(EAdvLevel.Level1));

                EAdvWeightUtils.AddListItems(Weight);
                ControlUtils.SelectListItems(Weight, EAdvWeightUtils.GetValue(EAdvWeight.Level1));

                EAdvRotateTypeUtils.AddListItems(RotateType);
                ControlUtils.SelectListItems(RotateType, EAdvRotateTypeUtils.GetValue(EAdvRotateType.HandWeight));

                if (_isEdit)
                {
                    var advInfo = DataProvider.AdvDao.GetAdvInfo(_advId, PublishmentSystemId);
                    AdvName.Text            = advInfo.AdvName;
                    IsEnabled.SelectedValue = advInfo.IsEnabled.ToString();
                    IsDateLimited.Checked   = advInfo.IsDateLimited;
                    StartDate.Text          = DateUtils.GetDateAndTimeString(advInfo.StartDate);
                    EndDate.Text            = DateUtils.GetDateAndTimeString(advInfo.EndDate);
                    ControlUtils.SelectListItems(NodeIDCollectionToChannel, TranslateUtils.StringCollectionToStringList(advInfo.NodeIDCollectionToChannel));
                    ControlUtils.SelectListItems(NodeIDCollectionToContent, TranslateUtils.StringCollectionToStringList(advInfo.NodeIDCollectionToContent));
                    ControlUtils.SelectListItems(FileTemplateIDCollection, TranslateUtils.StringCollectionToStringList(advInfo.FileTemplateIDCollection));
                    LevelType.SelectedValue  = EAdvLevelTypeUtils.GetValue(advInfo.LevelType);
                    Level.SelectedValue      = advInfo.Level.ToString();
                    IsWeight.Checked         = advInfo.IsWeight;
                    Weight.SelectedValue     = advInfo.Weight.ToString();
                    RotateType.SelectedValue = EAdvRotateTypeUtils.GetValue(advInfo.RotateType);
                    RotateInterval.Text      = advInfo.RotateInterval.ToString();
                    Summary.Text             = advInfo.Summary;
                }

                ReFresh(null, EventArgs.Empty);
            }

            SuccessMessage(string.Empty);
        }
Пример #27
0
 public static string GetRedirectUrl()
 {
     return(PageUtils.GetSettingsUrl(nameof(PageAdminRoleAdd), null));
 }
Пример #28
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var templateId          = SqlUtils.EvalInt(e.Item.DataItem, nameof(TemplateInfo.Id));
            var templateType        = TemplateTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.TemplateType)));
            var templateName        = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.TemplateName));
            var relatedFileName     = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.RelatedFileName));
            var createdFileFullName = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.CreatedFileFullName));
            var isDefault           = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.IsDefault)));

            var ltlTemplateName    = (Literal)e.Item.FindControl("ltlTemplateName");
            var ltlRelatedFileName = (Literal)e.Item.FindControl("ltlRelatedFileName");
            var ltlFileName        = (Literal)e.Item.FindControl("ltlFileName");
            var ltlUseCount        = (Literal)e.Item.FindControl("ltlUseCount");
            var ltlTemplateType    = (Literal)e.Item.FindControl("ltlTemplateType");
            var ltlDefaultUrl      = (Literal)e.Item.FindControl("ltlDefaultUrl");
            var ltlCopyUrl         = (Literal)e.Item.FindControl("ltlCopyUrl");
            var ltlLogUrl          = (Literal)e.Item.FindControl("ltlLogUrl");
            var ltlCreateUrl       = (Literal)e.Item.FindControl("ltlCreateUrl");
            var ltlDeleteUrl       = (Literal)e.Item.FindControl("ltlDeleteUrl");

            var templateAddUrl = PageTemplateAdd.GetRedirectUrl(SiteId, templateId, templateType);

            ltlTemplateName.Text    = $@"<a href=""{templateAddUrl}"">{templateName}</a>";
            ltlRelatedFileName.Text = relatedFileName;

            if (templateType == TemplateType.IndexPageTemplate || templateType == TemplateType.FileTemplate)
            {
                var url = PageUtility.ParseNavigationUrl(SiteInfo, createdFileFullName, false);
                ltlFileName.Text = $"<a href='{url}' target='_blank'>{createdFileFullName}</a>";
            }

            ltlUseCount.Text = DataProvider.ChannelDao.GetTemplateUseCount(SiteId, templateId, templateType, isDefault).ToString();

            ltlTemplateType.Text = TemplateTypeUtils.GetText(templateType);

            if (templateType != TemplateType.FileTemplate)
            {
                if (isDefault)
                {
                    ltlDefaultUrl.Text = @"<span class=""badge badge-primary"">默认模板</span>";
                }
                else
                {
                    var defaultUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageTemplate), new NameValueCollection
                    {
                        { "TemplateID", templateId.ToString() },
                        { "SetDefault", true.ToString() },
                        { "TemplateType", templateType.Value }
                    });
                    ltlDefaultUrl.Text =
                        $@"<a href=""{defaultUrl}"" onClick=""javascript:return confirm('此操作将把此模板设为默认,确认吗?');"">设为默认</a>";
                }
            }

            var copyUrl = PageTemplateAdd.GetRedirectUrlToCopy(SiteId, templateId);

            ltlCopyUrl.Text = $@"<a href=""{copyUrl}"">快速复制</a>";

            var logUrl = PageTemplateLog.GetRedirectUrl(SiteId, templateId);

            ltlLogUrl.Text = $@"<a href=""{logUrl}"">修订历史</a>";

            ltlCreateUrl.Text =
                $@"<a href=""javascript:;"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(
                    SiteId, templateId)}"">生成页面</a>";

            if (!isDefault)
            {
                var deleteUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageTemplate), new NameValueCollection
                {
                    { "TemplateID", templateId.ToString() },
                    { "Delete", true.ToString() },
                    { "TemplateType", templateType.Value }
                });

                ltlDeleteUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{AlertUtils.ConfirmDelete("删除文件", $"此操作将删除模板“{templateName}”,确认吗?", deleteUrl)}"">删除</a>";
            }
        }
Пример #29
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissioins = PermissionsManager.GetPermissions(Body.AdminName);

            _theRoleName           = Body.GetQueryString("RoleName");
            _generalPermissionList = permissioins.PermissionList;

            if (IsPostBack)
            {
                return;
            }

            PermissionsManager.VerifyAdministratorPermissions(Body.AdminName, ConfigManager.Permissions.Settings.Admin);

            if (!string.IsNullOrEmpty(_theRoleName))
            {
                TbRoleName.Text    = _theRoleName;
                TbRoleName.Enabled = false;
                TbDescription.Text = DataProvider.RoleDao.GetRoleDescription(_theRoleName);

                if (Body.GetQueryString("Return") == null)
                {
                    var systemPermissionsInfoList = DataProvider.SitePermissionsDao.GetSystemPermissionsInfoList(_theRoleName);
                    Session[SystemPermissionsInfoListKey] = systemPermissionsInfoList;
                }
            }
            else
            {
                if (Body.GetQueryString("Return") == null)
                {
                    Session[SystemPermissionsInfoListKey] = new List <SitePermissionsInfo>();
                }
            }

            var permissions = PermissionConfigManager.Instance.GeneralPermissions;

            if (permissions.Count > 0)
            {
                foreach (var permission in permissions)
                {
                    if (_generalPermissionList.Contains(permission.Name))
                    {
                        var listItem = new ListItem(permission.Text, permission.Name);
                        CblPermissions.Items.Add(listItem);
                    }
                }

                if (!string.IsNullOrEmpty(_theRoleName))
                {
                    var permissionList = DataProvider.PermissionsInRolesDao.GetGeneralPermissionList(new[] { _theRoleName });
                    if (permissionList != null && permissionList.Count > 0)
                    {
                        ControlUtils.SelectMultiItems(CblPermissions, permissionList);
                    }
                }
            }

            PhSitePermissions.Visible = false;

            var psPermissionsInRolesInfoList = Session[SystemPermissionsInfoListKey] as List <SitePermissionsInfo>;

            if (psPermissionsInRolesInfoList != null)
            {
                var allSiteIdList = new List <int>();
                foreach (var itemForPsid in ProductPermissionsManager.Current.WebsitePermissionDict.Keys)
                {
                    if (ProductPermissionsManager.Current.ChannelPermissionDict.ContainsKey(itemForPsid) && ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(itemForPsid))
                    {
                        var listOne = ProductPermissionsManager.Current.ChannelPermissionDict[itemForPsid];
                        var listTwo = ProductPermissionsManager.Current.WebsitePermissionDict[itemForPsid];
                        if (listOne != null && listOne.Count > 0 || listTwo != null && listTwo.Count > 0)
                        {
                            PhSitePermissions.Visible = true;
                            allSiteIdList.Add(itemForPsid);
                        }
                    }
                }
                var managedSiteIdList = new List <int>();
                foreach (var systemPermissionsInfo in psPermissionsInRolesInfoList)
                {
                    managedSiteIdList.Add(systemPermissionsInfo.SiteId);
                }
                LtlSites.Text = GetSitesHtml(allSiteIdList, managedSiteIdList);
            }
            else
            {
                PageUtils.RedirectToErrorPage("页面超时,请重新进入。");
            }

            if (Request.QueryString["Return"] == null)
            {
                BtnReturn.Visible = false;
                StrCookie         = @"_setCookie(""pageRoleAdd"", """");";
            }
            else
            {
                StrCookie = @"
var ss_role = _getCookie(""pageRoleAdd"");
if (ss_role) {
    var strs = ss_role.split("","");
    for (i = 0; i < strs.length; i++) {
        var el = document.getElementById(strs[i].split("":"")[0]);
        if (el.type == ""checkbox"") {
            el.checked = (strs[i].split("":"")[1] == ""true"");
        } else {
            el.value = strs[i].split("":"")[1];
        }
    }
}
";
            }
        }
Пример #30
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                if (hdType.Value == "1")
                {
                    if (IsRecommend.Checked || IsHot.Checked || IsColor.Checked || IsTop.Checked)
                    {
                        foreach (int contentID in _idArrayList)
                        {
                            var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentID) as BackgroundContentInfo;
                            if (contentInfo != null)
                            {
                                if (IsRecommend.Checked)
                                {
                                    contentInfo.IsRecommend = true;
                                }
                                if (IsHot.Checked)
                                {
                                    contentInfo.IsHot = true;
                                }
                                if (IsColor.Checked)
                                {
                                    contentInfo.IsColor = true;
                                }
                                if (IsTop.Checked)
                                {
                                    contentInfo.IsTop = true;
                                }
                                DataProvider.ContentDao.Update(_tableName, PublishmentSystemInfo, contentInfo);
                            }
                        }

                        Body.AddSiteLog(PublishmentSystemId, "设置内容属性");

                        isChanged = true;
                    }
                }
                else if (hdType.Value == "2")
                {
                    if (IsRecommend.Checked || IsHot.Checked || IsColor.Checked || IsTop.Checked)
                    {
                        foreach (int contentID in _idArrayList)
                        {
                            var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentID) as BackgroundContentInfo;
                            if (contentInfo != null)
                            {
                                if (IsRecommend.Checked)
                                {
                                    contentInfo.IsRecommend = false;
                                }
                                if (IsHot.Checked)
                                {
                                    contentInfo.IsHot = false;
                                }
                                if (IsColor.Checked)
                                {
                                    contentInfo.IsColor = false;
                                }
                                if (IsTop.Checked)
                                {
                                    contentInfo.IsTop = false;
                                }
                                DataProvider.ContentDao.Update(_tableName, PublishmentSystemInfo, contentInfo);
                            }
                        }

                        Body.AddSiteLog(PublishmentSystemId, "取消内容属性");

                        isChanged = true;
                    }
                }
                else if (hdType.Value == "3")
                {
                    var hits = TranslateUtils.ToInt(Hits.Text);

                    foreach (int contentID in _idArrayList)
                    {
                        BaiRongDataProvider.ContentDao.SetValue(_tableName, contentID, ContentAttribute.Hits, hits.ToString());
                    }

                    Body.AddSiteLog(PublishmentSystemId, "设置内容点击量");

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

            if (isChanged)
            {
                PageUtils.CloseModalPage(Page);
            }
        }