Ejemplo n.º 1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            isEntity.Value = Request.QueryString["isEntity"];
            cardID         = TranslateUtils.ToInt(Request.QueryString["cardID"]);

            if (!string.IsNullOrEmpty(Request.QueryString["Delete"]))
            {
                var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]);
                if (list.Count > 0)
                {
                    try
                    {
                        DataProviderWX.CardSNDAO.Delete(PublishmentSystemID, list);

                        SuccessMessage("会员卡删除成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "会员卡删除失败!");
                    }
                }
            }

            spContents.ControlToPaginate = rptContents;
            spContents.ItemsPerPage      = 20;
            spContents.ConnectionString  = BaiRongDataProvider.ConnectionString;
            spContents.SelectCommand     = DataProviderWX.CardSNDAO.GetSelectString(PublishmentSystemID, TranslateUtils.ToInt(Request.QueryString["cardID"]), Request.QueryString["cardSN"], Request.QueryString["userName"], Request.QueryString["mobile"]);
            spContents.SortField         = CardSNAttribute.AddDate;
            spContents.SortMode          = SortMode.DESC;
            rptContents.ItemDataBound   += new RepeaterItemEventHandler(rptContents_ItemDataBound);

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_Card, "会员卡管理", AppManager.WeiXin.Permission.WebSite.Card);
                spContents.DataBind();

                tbCardSN.Text   = Request.QueryString["cardSN"];
                tbUserName.Text = Request.QueryString["userName"];
                tbMobile.Text   = Request.QueryString["mobile"];

                var urlAdd = BackgroundCardSNAdd.GetRedirectUrl(PublishmentSystemID, cardID);
                btnAdd.Attributes.Add("onclick", $"location.href='{urlAdd}';return false");

                btnStatus.Attributes.Add("onclick", Modal.CardSNSetting.GetOpenWindowString(PublishmentSystemID, cardID, TranslateUtils.ToBool(isEntity.Value)));
                btnExport.Attributes.Add("onclick", Modal.ExportCardSN.GetOpenWindowString(PublishmentSystemID, cardID));
                var urlDelete = PageUtils.AddQueryString(GetRedirectUrl(PublishmentSystemID, cardID, tbCardSN.Text, tbUserName.Text, tbMobile.Text, TranslateUtils.ToBool(isEntity.Value)), "Delete", "True");
                btnDelete.Attributes.Add("onclick", JsUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的会员卡", "此操作将删除所选会员卡,确认吗?"));

                btnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{BackgroundCard.GetRedirectUrl(PublishmentSystemID)}"";return false;");
            }
        }
Ejemplo n.º 2
0
        public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo)
        {
            string parsedContent;

            try
            {
                var connectionString = string.Empty;
                var queryString      = string.Empty;

                var leftText     = string.Empty;
                var rightText    = string.Empty;
                var formatString = string.Empty;
                var startIndex   = 0;
                var length       = 0;
                var wordNum      = 0;
                var ellipsis     = StringUtils.Constants.Ellipsis;
                var replace      = string.Empty;
                var to           = string.Empty;
                var isClearTags  = false;
                var isReturnToBr = false;
                var isLower      = false;
                var isUpper      = false;
                var type         = string.Empty;
                var isDynamic    = false;

                var ie = node.Attributes?.GetEnumerator();
                if (ie != null)
                {
                    while (ie.MoveNext())
                    {
                        var attr = (XmlAttribute)ie.Current;

                        if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeConnectionString))
                        {
                            connectionString = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeConnectionStringName))
                        {
                            if (string.IsNullOrEmpty(connectionString))
                            {
                                connectionString = WebConfigUtils.ConnectionString;
                            }
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeQueryString))
                        {
                            queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType))
                        {
                            type = attr.Value.ToLower();
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLeftText))
                        {
                            leftText = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeRightText))
                        {
                            rightText = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeFormatString))
                        {
                            formatString = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeStartIndex))
                        {
                            startIndex = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLength))
                        {
                            length = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum))
                        {
                            wordNum = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeEllipsis))
                        {
                            ellipsis = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeReplace))
                        {
                            replace = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTo))
                        {
                            to = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsClearTags))
                        {
                            isClearTags = TranslateUtils.ToBool(attr.Value, false);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsReturnToBr))
                        {
                            isReturnToBr = TranslateUtils.ToBool(attr.Value, false);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsLower))
                        {
                            isLower = TranslateUtils.ToBool(attr.Value, true);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsUpper))
                        {
                            isUpper = TranslateUtils.ToBool(attr.Value, true);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic))
                        {
                            isDynamic = TranslateUtils.ToBool(attr.Value);
                        }
                    }
                }

                parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(contextInfo, connectionString, queryString, leftText, rightText, formatString, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type);
            }
            catch (Exception ex)
            {
                parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex);
            }

            return(parsedContent);
        }
Ejemplo n.º 3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

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

            PageUtils.CheckRequestParameter("siteId");
            _channelId = Body.GetQueryInt("channelId");
            if (_channelId == 0)
            {
                _channelId = SiteId;
            }
            var channelInfo = ChannelManager.GetChannelInfo(SiteId, _channelId);
            var tableName   = ChannelManager.GetTableName(SiteInfo, channelInfo);

            _relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(SiteId, _channelId);
            _tableStyleInfoList = TableStyleManager.GetTableStyleInfoList(tableName, _relatedIdentities);

            SpContents.ControlToPaginate = RptContents;
            if (string.IsNullOrEmpty(Body.GetQueryString("channelId")))
            {
                SpContents.ItemsPerPage  = TranslateUtils.ToInt(DdlPageNum.SelectedValue) == 0 ? SiteInfo.Additional.PageSize : TranslateUtils.ToInt(DdlPageNum.SelectedValue);
                SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, permissions.IsSystemAdministrator, ProductPermissionsManager.Current.OwningChannelIdList, DdlSearchType.SelectedValue, TbKeyword.Text, TbDateFrom.Text, TbDateTo.Text, true, ETriState.All, false, true);
            }
            else
            {
                SpContents.ItemsPerPage  = Body.GetQueryInt("PageNum") == 0 ? SiteInfo.Additional.PageSize : Body.GetQueryInt("PageNum");
                SpContents.SelectCommand = DataProvider.ContentDao.GetSqlString(tableName, SiteId, _channelId, permissions.IsSystemAdministrator, ProductPermissionsManager.Current.OwningChannelIdList, Body.GetQueryString("SearchType"), Body.GetQueryString("Keyword"), Body.GetQueryString("DateFrom"), Body.GetQueryString("DateTo"), true, ETriState.All, false, true);
            }
            SpContents.OrderByString   = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByIdDesc);
            RptContents.ItemDataBound += RptContents_ItemDataBound;

            if (!IsPostBack)
            {
                VerifySitePermissions(ConfigManager.Permissions.WebSite.Content);

                if (Body.IsQueryExists("IsDeleteAll"))
                {
                    DataProvider.ContentDao.DeleteContentsByTrash(SiteId, tableName);
                    Body.AddSiteLog(SiteId, "清空回收站");
                    SuccessMessage("成功清空回收站!");
                    AddWaitAndRedirectScript(PageUrl);
                    return;
                }
                if (Body.IsQueryExists("IsRestore"))
                {
                    var idsDictionary = ContentUtility.GetIDsDictionary(Request.QueryString);
                    foreach (var channelId in idsDictionary.Keys)
                    {
                        var contentIdArrayList = idsDictionary[channelId];
                        DataProvider.ContentDao.TrashContents(SiteId, ChannelManager.GetTableName(SiteInfo, channelId), contentIdArrayList);
                    }
                    Body.AddSiteLog(SiteId, "从回收站还原内容");
                    SuccessMessage("成功还原内容!");
                    AddWaitAndRedirectScript(PageUrl);
                    return;
                }
                if (Body.IsQueryExists("IsRestoreAll"))
                {
                    DataProvider.ContentDao.RestoreContentsByTrash(SiteId, tableName);
                    Body.AddSiteLog(SiteId, "从回收站还原所有内容");
                    SuccessMessage("成功还原所有内容!");
                    AddWaitAndRedirectScript(PageUrl);
                    return;
                }
                ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, true, false, Body.AdminName);

                if (_tableStyleInfoList != null)
                {
                    foreach (var styleInfo in _tableStyleInfoList)
                    {
                        var listitem = new ListItem(styleInfo.DisplayName, styleInfo.AttributeName);
                        DdlSearchType.Items.Add(listitem);
                    }
                }
                //添加隐藏属性
                DdlSearchType.Items.Add(new ListItem("内容ID", ContentAttribute.Id));
                DdlSearchType.Items.Add(new ListItem("添加者", ContentAttribute.AddUserName));
                DdlSearchType.Items.Add(new ListItem("最后修改者", ContentAttribute.LastEditUserName));

                if (Body.IsQueryExists("channelId"))
                {
                    if (SiteId != _channelId)
                    {
                        ControlUtils.SelectSingleItem(DdlChannelId, _channelId.ToString());
                    }
                    ControlUtils.SelectSingleItem(DdlPageNum, Body.GetQueryString("PageNum"));
                    ControlUtils.SelectSingleItem(DdlSearchType, Body.GetQueryString("SearchType"));
                    TbKeyword.Text  = Body.GetQueryString("Keyword");
                    TbDateFrom.Text = Body.GetQueryString("DateFrom");
                    TbDateTo.Text   = Body.GetQueryString("DateTo");
                }

                SpContents.DataBind();
            }

            if (!HasChannelPermissions(_channelId, ConfigManager.Permissions.Channel.ContentDelete))
            {
                BtnDelete.Visible    = false;
                BtnDeleteAll.Visible = false;
            }
            else
            {
                BtnDelete.Attributes.Add("onclick", PageContentDelete.GetRedirectClickStringForMultiChannels(SiteId, true, PageUrl));
                BtnDeleteAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsDeleteAll", "True"), "确实要清空回收站吗?"));
            }
            BtnRestore.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValue(PageUtils.AddQueryString(PageUrl, "IsRestore", "True"), "IDsCollection", "IDsCollection", "请选择需要还原的内容!"));
            BtnRestoreAll.Attributes.Add("onclick", PageUtils.GetRedirectStringWithConfirm(PageUtils.AddQueryString(PageUrl, "IsRestoreAll", "True"), "确实要还原所有内容吗?"));
        }
Ejemplo n.º 4
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");
            voteID = TranslateUtils.ToInt(GetQueryString("voteID"));

            if (!IsPostBack)
            {
                var pageTitle = voteID > 0 ? "编辑投票活动" : "添加投票活动";
                BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_Vote, pageTitle, AppManager.WeiXin.Permission.WebSite.Vote);
                ltlPageTitle.Text = pageTitle;

                var listItem = new ListItem("文字类型投票", "false");
                ddlContentIsImageOption.Items.Add(listItem);
                listItem = new ListItem("图文类型投票", "true");
                ddlContentIsImageOption.Items.Add(listItem);

                ddlContentIsImageOption.Attributes.Add("onchange", "itemController.isImageOptionChange(this)");
                EBooleanUtils.AddListItems(ddlContentIsCheckBox, "多选", "单选");
                ControlUtils.SelectListItems(ddlContentIsCheckBox, false.ToString());

                ltlImageUrl.Text =
                    $@"<img id=""preview_imageUrl"" src=""{VoteManager.GetImageUrl(PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                ltlContentImageUrl.Text =
                    $@"<img id=""preview_contentImageUrl"" src=""{VoteManager.GetContentImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                ltlEndImageUrl.Text =
                    $@"<img id=""preview_endImageUrl"" src=""{VoteManager.GetEndImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";

                var selectImageClick  = CMS.BackgroundPages.Modal.SelectImage.GetOpenWindowString(PublishmentSystemInfo, "itemImageUrl_");
                var uploadImageClick  = CMS.BackgroundPages.Modal.UploadImageSingle.GetOpenWindowStringToTextBox(PublishmentSystemID, "itemImageUrl_");
                var cuttingImageClick = CMS.BackgroundPages.Modal.CuttingImage.GetOpenWindowStringWithTextBox(PublishmentSystemID, "itemImageUrl_");
                var previewImageClick = CMS.BackgroundPages.Modal.Message.GetOpenWindowStringToPreviewImage(PublishmentSystemID, "itemImageUrl_");
                ltlVoteItems.Text =
                    $@"itemController.selectImageClickString = ""{selectImageClick}"";itemController.uploadImageClickString = ""{uploadImageClick}"";itemController.cuttingImageClickString = ""{cuttingImageClick}"";itemController.previewImageClickString = ""{previewImageClick}"";";

                if (voteID == 0)
                {
                    ltlVoteItems.Text  += "itemController.isImageOption = false;itemController.itemCount = 2;itemController.items = [{}, {}];";
                    dtbEndDate.DateTime = DateTime.Now.AddMonths(1);
                }
                else
                {
                    var voteInfo = DataProviderWX.VoteDAO.GetVoteInfo(voteID);

                    tbKeywords.Text       = DataProviderWX.KeywordDAO.GetKeywords(voteInfo.KeywordID);
                    cbIsEnabled.Checked   = !voteInfo.IsDisabled;
                    dtbStartDate.DateTime = voteInfo.StartDate;
                    dtbEndDate.DateTime   = voteInfo.EndDate;
                    tbTitle.Text          = voteInfo.Title;
                    if (!string.IsNullOrEmpty(voteInfo.ImageUrl))
                    {
                        ltlImageUrl.Text =
                            $@"<img id=""preview_imageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, voteInfo.ImageUrl)}"" width=""370"" align=""middle"" />";
                    }
                    tbSummary.Text = voteInfo.Summary;
                    if (!string.IsNullOrEmpty(voteInfo.ContentImageUrl))
                    {
                        ltlContentImageUrl.Text =
                            $@"<img id=""preview_contentImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, voteInfo.ContentImageUrl)}"" width=""370"" align=""middle"" />";
                    }

                    tbContentDescription.Text = voteInfo.ContentDescription;
                    //ControlUtils.SelectListItems(this.ddlContentResultVisible, voteInfo.ContentResultVisible);
                    ControlUtils.SelectListItems(ddlContentIsImageOption, voteInfo.ContentIsImageOption.ToString().ToLower());
                    ControlUtils.SelectListItems(ddlContentIsCheckBox, voteInfo.ContentIsCheckBox.ToString());

                    var voteItemInfoList = DataProviderWX.VoteItemDAO.GetVoteItemInfoList(voteID);
                    var itemBuilder      = new StringBuilder();
                    foreach (var itemInfo in voteItemInfoList)
                    {
                        itemBuilder.AppendFormat(@"{{id: '{0}', title: '{1}', imageUrl: '{2}', navigationUrl: '{3}', voteNum: '{4}'}},", itemInfo.ID, itemInfo.Title, itemInfo.ImageUrl, itemInfo.NavigationUrl, itemInfo.VoteNum);
                    }
                    if (itemBuilder.Length > 0)
                    {
                        itemBuilder.Length--;
                    }

                    ltlVoteItems.Text += $@"
itemController.isImageOption = {voteInfo.ContentIsImageOption.ToString().ToLower()};itemController.itemCount = {voteItemInfoList
                        .Count};itemController.items = [{itemBuilder.ToString()}];";

                    tbEndTitle.Text   = voteInfo.EndTitle;
                    tbEndSummary.Text = voteInfo.EndSummary;
                    if (!string.IsNullOrEmpty(voteInfo.EndImageUrl))
                    {
                        ltlEndImageUrl.Text =
                            $@"<img id=""preview_endImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, voteInfo.EndImageUrl)}"" width=""370"" align=""middle"" />";
                    }

                    imageUrl.Value        = voteInfo.ImageUrl;
                    contentImageUrl.Value = voteInfo.ContentImageUrl;
                    endImageUrl.Value     = voteInfo.EndImageUrl;
                }

                btnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{BackgroundVote.GetRedirectUrl(PublishmentSystemID)}"";return false");
            }
        }
Ejemplo n.º 5
0
        private static bool IsNumber(int number, string testOperate, string testValue)
        {
            var isSuccess = false;

            if (StringUtils.EqualsIgnoreCase(testOperate, OperateEquals))
            {
                if (number == TranslateUtils.ToInt(testValue))
                {
                    isSuccess = true;
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testOperate, OperateNotEquals))
            {
                if (number != TranslateUtils.ToInt(testValue))
                {
                    isSuccess = true;
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testOperate, OperateGreatThan))
            {
                if (number > TranslateUtils.ToInt(testValue))
                {
                    isSuccess = true;
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testOperate, OperateLessThan))
            {
                if (number < TranslateUtils.ToInt(testValue))
                {
                    isSuccess = true;
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testOperate, OperateIn))
            {
                var intArrayList = ListUtils.GetIntList(testValue);
                foreach (int i in intArrayList)
                {
                    if (i == number)
                    {
                        isSuccess = true;
                        break;
                    }
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testOperate, OperateNotIn))
            {
                var intArrayList = ListUtils.GetIntList(testValue);
                var isIn         = false;
                foreach (int i in intArrayList)
                {
                    if (i == number)
                    {
                        isIn = true;
                        break;
                    }
                }
                if (!isIn)
                {
                    isSuccess = true;
                }
            }
            return(isSuccess);
        }
Ejemplo n.º 6
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (IsPostBack && IsValid)
            {
                var cardEntitySnInfo = new CardEntitySnInfo();

                if (_cardEntitySnid > 0)
                {
                    cardEntitySnInfo = DataProviderWx.CardEntitySnDao.GetCardEntitySnInfo(_cardEntitySnid);
                }

                cardEntitySnInfo.PublishmentSystemId = PublishmentSystemId;
                cardEntitySnInfo.CardId   = _cardId;
                cardEntitySnInfo.Sn       = TbCardSn.Text;
                cardEntitySnInfo.UserName = TbUserName.Text;
                cardEntitySnInfo.Amount   = TranslateUtils.ToDecimal(TbAmount.Text);
                cardEntitySnInfo.Credits  = TranslateUtils.ToInt(TbCredits.Text);
                cardEntitySnInfo.Mobile   = TbMobile.Text;
                cardEntitySnInfo.Email    = TbEmail.Text;
                cardEntitySnInfo.Address  = TbAddress.Text;

                if (_cardEntitySnid > 0)
                {
                    try
                    {
                        DataProviderWx.CardEntitySnDao.Update(cardEntitySnInfo);

                        PageUtils.CloseModalPage(Page);
                    }
                    catch (Exception ex)
                    {
                        FailMessage($"实体卡修改失败:{ex}");
                    }
                }
                else
                {
                    var isExist       = DataProviderWx.CardEntitySnDao.IsExist(PublishmentSystemId, _cardId, cardEntitySnInfo.Sn);
                    var isExistMobile = DataProviderWx.CardEntitySnDao.IsExistMobile(PublishmentSystemId, _cardId, cardEntitySnInfo.Mobile);

                    if (isExistMobile)
                    {
                        FailMessage("手机号使用,请更换手机号!");
                        return;
                    }

                    if (isExist)
                    {
                        FailMessage($"{cardEntitySnInfo.Sn}实体卡号已存在!");
                        return;
                    }
                    else
                    {
                        try
                        {
                            cardEntitySnInfo.IsBinding = false;
                            cardEntitySnInfo.AddDate   = DateTime.Now;
                            DataProviderWx.CardEntitySnDao.Insert(cardEntitySnInfo);

                            PageUtils.CloseModalPage(Page);
                        }
                        catch (Exception ex)
                        {
                            FailMessage($"实体卡新增失败:{ex}");
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private string GetConnectionString(bool isDatabaseName)
        {
            var databaseType = DatabaseTypeUtils.GetEnumType(DdlSqlDatabaseType.SelectedValue);
            var databaseName = string.Empty;

            if (isDatabaseName)
            {
                databaseName = databaseType == DatabaseType.Oracle ? TbSqlOracleDatabase.Text : DdlSqlDatabaseName.SelectedValue;
            }
            return(SqlUtils.GetConnectionString(databaseType, TbSqlServer.Text, TranslateUtils.ToBool(DdlIsDefaultPort.SelectedValue), TranslateUtils.ToInt(TbSqlPort.Text), TbSqlUserName.Text, HihSqlHiddenPassword.Value, databaseName));
        }
Ejemplo n.º 8
0
        public static ListInfo GetListInfoByXmlNode(PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType)
        {
            var listInfo = new ListInfo
            {
                _contextType = contextType
            };

            var innerXml     = contextInfo.InnerXml;
            var itemTemplate = string.Empty;

            if (!string.IsNullOrEmpty(innerXml))
            {
                var stlElementList = StlParserUtility.GetStlElementList(innerXml);
                if (stlElementList.Count > 0)
                {
                    foreach (var theStlElement in stlElementList)
                    {
                        if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItemTemplate.ElementName))
                        {
                            var attributes     = new LowerNameValueCollection();
                            var templateString = StlParserUtility.GetInnerXml(theStlElement, true, attributes);
                            if (!string.IsNullOrEmpty(templateString))
                            {
                                foreach (var key in attributes.Keys)
                                {
                                    if (!StringUtils.EqualsIgnoreCase(key, StlItemTemplate.AttributeType))
                                    {
                                        continue;
                                    }

                                    var type = attributes.Get(key);
                                    if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeItem))
                                    {
                                        itemTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeHeader))
                                    {
                                        listInfo.HeaderTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeFooter))
                                    {
                                        listInfo.FooterTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeAlternatingItem))
                                    {
                                        listInfo.AlternatingItemTemplate = templateString;
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSelectedItem))
                                    {
                                        if (!string.IsNullOrEmpty(attributes.Get(StlItemTemplate.AttributeSelected)))
                                        {
                                            var selected  = attributes.Get(StlItemTemplate.AttributeSelected);
                                            var arraylist = new ArrayList();
                                            if (selected.IndexOf(',') != -1)
                                            {
                                                arraylist.AddRange(selected.Split(','));
                                            }
                                            else
                                            {
                                                if (selected.IndexOf('-') != -1)
                                                {
                                                    var first  = TranslateUtils.ToInt(selected.Split('-')[0]);
                                                    var second = TranslateUtils.ToInt(selected.Split('-')[1]);
                                                    for (var i = first; i <= second; i++)
                                                    {
                                                        arraylist.Add(i.ToString());
                                                    }
                                                }
                                                else
                                                {
                                                    arraylist.Add(selected);
                                                }
                                            }
                                            foreach (string val in arraylist)
                                            {
                                                listInfo.SelectedItems.Set(val, templateString);
                                            }
                                            if (!string.IsNullOrEmpty(attributes.Get(StlItemTemplate.AttributeSelectedValue)))
                                            {
                                                var selectedValue = attributes.Get(StlItemTemplate.AttributeSelectedValue);
                                                listInfo.SelectedValues.Set(selectedValue, templateString);
                                            }
                                        }
                                    }
                                    else if (StringUtils.EqualsIgnoreCase(type, StlItemTemplate.TypeSeparator))
                                    {
                                        var selectedValue = TranslateUtils.ToInt(attributes.Get(StlItemTemplate.AttributeSelectedValue), 1);
                                        if (selectedValue <= 1)
                                        {
                                            listInfo.SeparatorTemplate = templateString;
                                        }
                                        else
                                        {
                                            listInfo.SeparatorRepeatTemplate = templateString;
                                            listInfo.SeparatorRepeat         = selectedValue;
                                        }
                                    }
                                }
                            }
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                        else if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlLoading.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            StlParserUtility.XmlToHtml(innerBuilder);
                            listInfo.LoadingTemplate = innerBuilder.ToString();
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                        else if (contextType == EContextType.SqlContent && StlParserUtility.IsSpecifiedStlElement(theStlElement, StlQueryString.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            StlParserUtility.XmlToHtml(innerBuilder);
                            listInfo.QueryString = innerBuilder.ToString();
                            innerXml             = innerXml.Replace(theStlElement, string.Empty);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(itemTemplate))
            {
                listInfo.ItemTemplate = !string.IsNullOrEmpty(innerXml) ? innerXml : "<stl:a target=\"_blank\"></stl:a>";
            }
            else
            {
                listInfo.ItemTemplate = itemTemplate;
            }

            var isSetDirection = false;//是否设置了direction属性

            foreach (var name in contextInfo.Attributes.Keys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeChannelIndex))
                {
                    listInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeChannelName))
                {
                    listInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeUpLevel))
                {
                    listInfo.UpLevel = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeTopLevel))
                {
                    listInfo.TopLevel = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeScope))
                {
                    listInfo.Scope = EScopeTypeUtils.GetEnumType(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsTop))
                {
                    listInfo.IsTop = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsRecommend))
                {
                    listInfo.IsRecommend = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsHot))
                {
                    listInfo.IsHot = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsColor))
                {
                    listInfo.IsColor = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeWhere))
                {
                    listInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeTotalNum))
                {
                    listInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlPageContents.AttributePageNum))
                {
                    listInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlPageContents.AttributeMaxPage))
                {
                    listInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeStartNum))
                {
                    listInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo));
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeOrder))
                {
                    if (contextType == EContextType.Content)
                    {
                        listInfo.OrderByString = StlDataUtility.GetContentOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxisDesc);
                    }
                    else if (contextType == EContextType.Channel)
                    {
                        listInfo.OrderByString = StlDataUtility.GetChannelOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxis);
                    }
                    //else if (contextType == EContextType.InputContent)
                    //{
                    //    listInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.SiteId, value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc);
                    //}
                    else
                    {
                        listInfo.OrderByString = value;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeGroupChannel))
                {
                    listInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupChannel))
                    {
                        listInfo.GroupChannel = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeGroupChannelNot))
                {
                    listInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupChannelNot))
                    {
                        listInfo.GroupChannelNot = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeGroupContent) || StringUtils.EqualsIgnoreCase(name, StlContents.AttributeGroup))
                {
                    listInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupContent))
                    {
                        listInfo.GroupContent = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeGroupContentNot) || StringUtils.EqualsIgnoreCase(name, StlContents.AttributeGroupNot))
                {
                    listInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(listInfo.GroupContentNot))
                    {
                        listInfo.GroupContentNot = "__Empty__";
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeTags))
                {
                    listInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeColumns))
                {
                    listInfo.Columns = TranslateUtils.ToInt(value);
                    listInfo.Layout  = ELayout.Table;
                    if (listInfo.Columns > 1 && isSetDirection == false)
                    {
                        listInfo.Direction = RepeatDirection.Horizontal;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeDirection))
                {
                    listInfo.Layout    = ELayout.Table;
                    listInfo.Direction = Converter.ToRepeatDirection(value);
                    isSetDirection     = true;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeHeight))
                {
                    try
                    {
                        listInfo.Height = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeWidth))
                {
                    try
                    {
                        listInfo.Width = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeAlign))
                {
                    listInfo.Align = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeItemHeight))
                {
                    try
                    {
                        listInfo.ItemHeight = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeItemWidth))
                {
                    try
                    {
                        listInfo.ItemWidth = Unit.Parse(value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeItemAlign))
                {
                    listInfo.ItemAlign = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeItemVerticalAlign))
                {
                    listInfo.ItemVerticalAlign = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeItemClass))
                {
                    listInfo.ItemClass = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsImage))
                {
                    listInfo.IsImage = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsVideo))
                {
                    listInfo.IsVideo = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsFile))
                {
                    listInfo.IsFile = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsNoDup))
                {
                    listInfo.IsNoDup = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeIsRelatedContents))
                {
                    listInfo.IsRelatedContents = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, StlContents.AttributeLayout))
                {
                    listInfo.Layout = ELayoutUtils.GetEnumType(value);
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.AttributeConnectionString))
                {
                    listInfo.ConnectionString = value;
                }
                else if (contextType == EContextType.SqlContent && StringUtils.EqualsIgnoreCase(name, StlSqlContents.AttributeConnectionStringName))
                {
                    listInfo.ConnectionString = WebConfigUtils.GetConnectionStringByName(value);
                    if (string.IsNullOrEmpty(listInfo.ConnectionString))
                    {
                        listInfo.ConnectionString = WebConfigUtils.ConnectionString;
                    }
                }
                else
                {
                    listInfo.Others.Set(name, value);
                }
            }

            return(listInfo);
        }
Ejemplo n.º 9
0
        public static ContentsDisplayInfo GetContentsDisplayInfoByXmlNode(XmlNode node, PageInfo pageInfo, ContextInfo contextInfo, EContextType contextType)
        {
            var displayInfo = new ContentsDisplayInfo
            {
                _contextType = contextType
            };

            var innerXml     = node.InnerXml;
            var itemTemplate = string.Empty;

            if (!string.IsNullOrEmpty(innerXml))
            {
                var stlElementList = StlParserUtility.GetStlElementList(innerXml);
                if (stlElementList.Count > 0)
                {
                    foreach (var theStlElement in stlElementList)
                    {
                        if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItem.ElementName) ||
                            StlParserUtility.IsSpecifiedStlElement(theStlElement, StlItem.ElementName2)
                            )
                        {
                            var attributes     = new LowerNameValueCollection();
                            var templateString = StlParserUtility.GetInnerXml(theStlElement, true, attributes);
                            if (!string.IsNullOrEmpty(templateString))
                            {
                                foreach (string key in attributes.Keys)
                                {
                                    if (key == StlItem.Attribute_Type)
                                    {
                                        var type = attributes[key];
                                        if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Item))
                                        {
                                            itemTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Header))
                                        {
                                            displayInfo._headerTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Footer))
                                        {
                                            displayInfo._footerTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_AlternatingItem))
                                        {
                                            displayInfo._alternatingItemTemplate = templateString;
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_SelectedItem))
                                        {
                                            if (!string.IsNullOrEmpty(attributes[StlItem.Attribute_Selected]))
                                            {
                                                var selected  = attributes[StlItem.Attribute_Selected];
                                                var arraylist = new ArrayList();
                                                if (selected.IndexOf(',') != -1)
                                                {
                                                    arraylist.AddRange(selected.Split(','));
                                                }
                                                else
                                                {
                                                    if (selected.IndexOf('-') != -1)
                                                    {
                                                        var first  = TranslateUtils.ToInt(selected.Split('-')[0]);
                                                        var second = TranslateUtils.ToInt(selected.Split('-')[1]);
                                                        for (var i = first; i <= second; i++)
                                                        {
                                                            arraylist.Add(i.ToString());
                                                        }
                                                    }
                                                    else
                                                    {
                                                        arraylist.Add(selected);
                                                    }
                                                }
                                                foreach (string val in arraylist)
                                                {
                                                    displayInfo._selectedItems[val] = templateString;
                                                }
                                                if (!string.IsNullOrEmpty(attributes[StlItem.Attribute_SelectedValue]))
                                                {
                                                    var selectedValue = attributes[StlItem.Attribute_SelectedValue];
                                                    displayInfo._selectedValues[selectedValue] = templateString;
                                                }
                                            }
                                        }
                                        else if (StringUtils.EqualsIgnoreCase(type, StlItem.Type_Separator))
                                        {
                                            var selectedValue = TranslateUtils.ToInt(attributes[StlItem.Attribute_SelectedValue], 1);
                                            if (selectedValue <= 1)
                                            {
                                                displayInfo._separatorTemplate = templateString;
                                            }
                                            else
                                            {
                                                displayInfo._separatorRepeatTemplate = templateString;
                                                displayInfo._separatorRepeat         = selectedValue;
                                            }
                                        }
                                    }
                                }
                            }
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                        else if (StlParserUtility.IsSpecifiedStlElement(theStlElement, StlLoading.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            StlParserUtility.XmlToHtml(innerBuilder);
                            displayInfo._loadingTemplate = innerBuilder.ToString();
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                        else if (contextType == EContextType.SqlContent && StlParserUtility.IsSpecifiedStlElement(theStlElement, StlQueryString.ElementName))
                        {
                            var innerBuilder = new StringBuilder(StlParserUtility.GetInnerXml(theStlElement, true));
                            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
                            StlParserUtility.XmlToHtml(innerBuilder);
                            displayInfo.QueryString = innerBuilder.ToString();
                            innerXml = innerXml.Replace(theStlElement, string.Empty);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(itemTemplate))
            {
                displayInfo.ItemTemplate = !string.IsNullOrEmpty(innerXml) ? innerXml : "<stl:a target=\"_blank\"></stl:a>";
            }
            else
            {
                displayInfo._itemTemplate = itemTemplate;
            }

            var ie             = node.Attributes.GetEnumerator();
            var isSetDirection = false;//是否设置了direction属性

            while (ie.MoveNext())
            {
                var attr          = (XmlAttribute)ie.Current;
                var attributeName = attr.Name.ToLower();

                if (attributeName.Equals(StlContents.Attribute_ChannelIndex))
                {
                    displayInfo.ChannelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_ChannelName))
                {
                    displayInfo.ChannelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_UpLevel))
                {
                    displayInfo.UpLevel = TranslateUtils.ToInt(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_TopLevel))
                {
                    displayInfo.TopLevel = TranslateUtils.ToInt(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_Scope))
                {
                    displayInfo.Scope = EScopeTypeUtils.GetEnumType(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsTop))
                {
                    displayInfo.IsTop = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsRecommend))
                {
                    displayInfo.IsRecommend = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsHot))
                {
                    displayInfo.IsHot = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsColor))
                {
                    displayInfo.IsColor = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_Where))
                {
                    displayInfo.Where = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsDynamic))
                {
                    displayInfo.IsDynamic = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_TotalNum))
                {
                    displayInfo.TotalNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlPageContents.AttributePageNum))
                {
                    displayInfo.PageNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlPageContents.AttributeMaxPage))
                {
                    displayInfo.MaxPage = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlContents.Attribute_TitleWordNum))
                {
                    displayInfo.TitleWordNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlContents.Attribute_StartNum))
                {
                    displayInfo.StartNum = TranslateUtils.ToInt(StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo));
                }
                else if (attributeName.Equals(StlContents.Attribute_Order))
                {
                    if (contextType == EContextType.Content)
                    {
                        displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.BackgroundContent, ETaxisType.OrderByTaxisDesc);
                    }
                    else if (contextType == EContextType.Channel)
                    {
                        displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.Channel, ETaxisType.OrderByTaxis);
                    }
                    else if (contextType == EContextType.InputContent)
                    {
                        displayInfo.OrderByString = StlDataUtility.GetOrderByString(pageInfo.PublishmentSystemId, attr.Value, ETableStyle.InputContent, ETaxisType.OrderByTaxisDesc);
                    }
                    else
                    {
                        displayInfo.OrderByString = attr.Value;
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupChannel))
                {
                    displayInfo.GroupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupChannel))
                    {
                        displayInfo.GroupChannel = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupChannelNot))
                {
                    displayInfo.GroupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupChannelNot))
                    {
                        displayInfo.GroupChannelNot = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupContent) || attributeName.Equals(StlContents.Attribute_Group))
                {
                    displayInfo.GroupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupContent))
                    {
                        displayInfo.GroupContent = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_GroupContentNot) || attributeName.Equals(StlContents.Attribute_GroupNot))
                {
                    displayInfo.GroupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                    if (string.IsNullOrEmpty(displayInfo.GroupContentNot))
                    {
                        displayInfo.GroupContentNot = "__Empty__";
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Tags))
                {
                    displayInfo.Tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                }
                else if (attributeName.Equals(StlContents.Attribute_Columns))
                {
                    displayInfo.Columns = TranslateUtils.ToInt(attr.Value);
                    displayInfo.Layout  = ELayout.Table;
                    if (displayInfo.Columns > 1 && isSetDirection == false)
                    {
                        displayInfo.Direction = RepeatDirection.Horizontal;
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Direction))
                {
                    displayInfo.Layout    = ELayout.Table;
                    displayInfo.Direction = Converter.ToRepeatDirection(attr.Value);
                    isSetDirection        = true;
                }
                else if (attributeName.Equals(StlContents.Attribute_Height))
                {
                    try
                    {
                        displayInfo.Height = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Width))
                {
                    try
                    {
                        displayInfo.Width = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_Align))
                {
                    displayInfo.Align = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemHeight))
                {
                    try
                    {
                        displayInfo.ItemHeight = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemWidth))
                {
                    try
                    {
                        displayInfo.ItemWidth = Unit.Parse(attr.Value);
                    }
                    catch
                    {
                        // ignored
                    }
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemAlign))
                {
                    displayInfo.ItemAlign = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemVerticalAlign))
                {
                    displayInfo.ItemVerticalAlign = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_ItemClass))
                {
                    displayInfo.ItemClass = attr.Value;
                }
                else if (attributeName.Equals(StlContents.Attribute_IsImage))
                {
                    displayInfo.IsImage = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsVideo))
                {
                    displayInfo.IsVideo = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsFile))
                {
                    displayInfo.IsFile = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsNoDup))
                {
                    displayInfo.IsNoDup = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_IsRelatedContents))
                {
                    displayInfo.IsRelatedContents = TranslateUtils.ToBool(attr.Value);
                }
                else if (attributeName.Equals(StlContents.Attribute_Layout))
                {
                    displayInfo.Layout = ELayoutUtils.GetEnumType(attr.Value);
                }
                else if (contextType == EContextType.SqlContent && attributeName.Equals(StlSqlContents.Attribute_ConnectionString))
                {
                    displayInfo.ConnectionString = attr.Value;
                }
                else if (contextType == EContextType.SqlContent && attributeName.Equals(StlSqlContents.Attribute_ConnectionStringName))
                {
                    if (string.IsNullOrEmpty(displayInfo.ConnectionString))
                    {
                        displayInfo.ConnectionString = WebConfigUtils.ConnectionString;
                    }
                }
                else
                {
                    displayInfo.OtherAttributes.Add(attributeName, attr.Value);
                }
            }

            return(displayInfo);
        }
Ejemplo n.º 10
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (phStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (phStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (phStep3.Visible)
                {
                    selectedStep = 3;
                }

                phStep1.Visible = phStep2.Visible = phStep3.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(tbKeywords.Text))
                    {
                        if (searchID > 0)
                        {
                            var searchInfo = DataProviderWX.SearchDAO.GetSearchInfo(searchID);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemID, searchInfo.KeywordID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        phStep1.Visible = true;
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    var isItemReady = true;

                    if (isItemReady)
                    {
                        var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]);

                        if (itemCount > 0)
                        {
                            var itemIDList        = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                            var imageCssClassList = TranslateUtils.StringCollectionToStringList(Request.Form["itemImageCssClass"]);
                            var keywordTypeList   = TranslateUtils.StringCollectionToStringList(Request.Form["itemKeywordType"]);
                            var functionIDList    = TranslateUtils.StringCollectionToIntList(Request.Form["itemFunctionID"]);
                            var channelIDList     = TranslateUtils.StringCollectionToIntList(Request.Form["itemChannelID"]);
                            var contentIDList     = TranslateUtils.StringCollectionToIntList(Request.Form["itemContentID"]);

                            var titleList          = TranslateUtils.StringCollectionToStringList(Request.Form["itemTitle"]);
                            var navigationTypeList = TranslateUtils.StringCollectionToStringList(Request.Form["itemNavigationType"]);
                            var urlList            = TranslateUtils.StringCollectionToStringList(Request.Form["itemUrl"]);

                            var navigationInfoList = new List <SearchNavigationInfo>();
                            for (var i = 0; i < itemCount; i++)
                            {
                                var navigationInfo = new SearchNavigationInfo {
                                    ID = itemIDList[i], PublishmentSystemID = PublishmentSystemID, SearchID = searchID, Title = titleList[i], Url = urlList[i], ImageCssClass = imageCssClassList[i], NavigationType = navigationTypeList[i], KeywordType = keywordTypeList[i], FunctionID = functionIDList[i], ChannelID = channelIDList[i], ContentID = contentIDList[i]
                                };

                                if (string.IsNullOrEmpty(navigationInfo.Title))
                                {
                                    FailMessage("保存失败,导航链接名称为必填项");
                                    isItemReady = false;
                                }
                                if (string.IsNullOrEmpty(navigationInfo.ImageCssClass))
                                {
                                    FailMessage("保存失败,导航链接图标为必填项");
                                    isItemReady = false;
                                }
                                if (navigationInfo.NavigationType == ENavigationTypeUtils.GetValue(ENavigationType.Url) && string.IsNullOrEmpty(navigationInfo.Url))
                                {
                                    FailMessage("保存失败,导航链接地址为必填项");
                                    isItemReady = false;
                                }

                                navigationInfoList.Add(navigationInfo);
                            }

                            if (isItemReady)
                            {
                                DataProviderWX.SearchNavigationDAO.DeleteAllNotInIDList(PublishmentSystemID, searchID, itemIDList);

                                foreach (var navigationInfo in navigationInfoList)
                                {
                                    if (navigationInfo.ID > 0)
                                    {
                                        DataProviderWX.SearchNavigationDAO.Update(navigationInfo);
                                    }
                                    else
                                    {
                                        DataProviderWX.SearchNavigationDAO.Insert(navigationInfo);
                                    }
                                }
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        phStep3.Visible = true;
                        btnSubmit.Text  = "确 认";
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 3)
                {
                    var searchInfo = new SearchInfo();
                    if (searchID > 0)
                    {
                        searchInfo = DataProviderWX.SearchDAO.GetSearchInfo(searchID);
                    }
                    searchInfo.PublishmentSystemID = PublishmentSystemID;
                    searchInfo.KeywordID           = DataProviderWX.KeywordDAO.GetKeywordID(PublishmentSystemID, searchID > 0, tbKeywords.Text, EKeywordType.Search, searchInfo.KeywordID);
                    searchInfo.IsDisabled          = !cbIsEnabled.Checked;
                    searchInfo.Title           = PageUtils.FilterXSS(tbTitle.Text);
                    searchInfo.ImageUrl        = imageUrl.Value;;
                    searchInfo.Summary         = tbSummary.Text;
                    searchInfo.ContentImageUrl = contentImageUrl.Value;

                    searchInfo.IsOutsiteSearch = cbIsOutsiteSearch.Checked;
                    searchInfo.IsNavigation    = cbIsNavigation.Checked;
                    searchInfo.NavTitleColor   = tbNavTitleColor.Text;
                    searchInfo.NavImageColor   = tbNavImageColor.Text;

                    searchInfo.ImageAreaTitle     = tbImageAreaTitle.Text;
                    searchInfo.ImageAreaChannelID = TranslateUtils.ToInt(Request.Form["imageChannelID"]);
                    searchInfo.TextAreaTitle      = tbTextAreaTitle.Text;
                    searchInfo.TextAreaChannelID  = TranslateUtils.ToInt(Request.Form["textChannelID"]);

                    try
                    {
                        if (searchID > 0)
                        {
                            DataProviderWX.SearchDAO.Update(searchInfo);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "修改微搜索",
                                            $"微搜索:{tbTitle.Text}");
                            SuccessMessage("修改微搜索成功!");
                        }
                        else
                        {
                            searchID = DataProviderWX.SearchDAO.Insert(searchInfo);

                            DataProviderWX.SearchNavigationDAO.UpdateSearchID(PublishmentSystemID, searchID);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "添加微搜索",
                                            $"微搜索:{tbTitle.Text}");
                            SuccessMessage("添加微搜索成功!");
                        }

                        var redirectUrl = BackgroundSearch.GetRedirectUrl(PublishmentSystemID);
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "微搜索设置失败!");
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");
            searchID = TranslateUtils.ToInt(GetQueryString("searchID"));

            if (!IsPostBack)
            {
                var pageTitle = searchID > 0 ? "编辑微搜索" : "添加微搜索";
                BreadCrumb(AppManager.WeiXin.LeftMenu.ID_Function, AppManager.WeiXin.LeftMenu.Function.ID_Search, pageTitle, AppManager.WeiXin.Permission.WebSite.Search);
                ltlPageTitle.Text = pageTitle;

                ltlImageUrl.Text =
                    $@"<img id=""preview_imageUrl"" src=""{SearchManager.GetImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";
                ltlContentImageUrl.Text =
                    $@"<img id=""preview_contentImageUrl"" src=""{SearchManager.GetContentImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";

                ltlSearchNavs.Text = $@"
itemController.openFunctionSelect = function(itemIndex){{
    var openString = ""{Modal.FunctionSelect.GetOpenWindowStringByItemIndex(PublishmentSystemID, "selectFunction",
                    "itemIndexValue")}"".replace(""itemIndexValue"", itemIndex);
    openString = openString.substr(0, openString.indexOf(';'));
    eval(openString);
}};
itemController.openChannelSelect = function(itemIndex){{
    var openString = ""{CMS.BackgroundPages.Modal.ChannelSelect.GetOpenWindowStringByItemIndex(
                    PublishmentSystemID, "selectChannel", "itemIndexValue")}"".replace(""itemIndexValue"", itemIndex);
    openString = openString.substr(0, openString.indexOf(';'));
    eval(openString);
}};
itemController.openContentSelect = function(itemIndex){{
    var openString = ""{Modal.ContentSelect.GetOpenWindowStringByItemIndex(PublishmentSystemID, "selectContent",
                    "itemIndexValue")}"".replace(""itemIndexValue"", itemIndex);
    openString = openString.substr(0, openString.indexOf(';'));
    eval(openString);
}};
itemController.openImageCssClassSelect = function(itemIndex){{
    var openString = ""{Modal.ImageCssClassSelect.GetOpenWindowStringByItemIndex(PublishmentSystemID,
                    "selectImageCssClass", "itemIndexValue")}"".replace(""itemIndexValue"", itemIndex);
    openString = openString.substr(0, openString.indexOf(';'));
    eval(openString);
}};
";

                if (searchID == 0)
                {
                    ltlSearchNavs.Text += "itemController.itemCount = 2;itemController.items = [{navigationType : 'Url', imageCssClass : 'fa fa-angle-double-down'}, {navigationType : 'Url', imageCssClass : 'fa fa-angle-double-down'}];";
                }
                else
                {
                    var searchInfo = DataProviderWX.SearchDAO.GetSearchInfo(searchID);

                    tbKeywords.Text     = DataProviderWX.KeywordDAO.GetKeywords(searchInfo.KeywordID);
                    cbIsEnabled.Checked = !searchInfo.IsDisabled;
                    tbTitle.Text        = searchInfo.Title;
                    if (!string.IsNullOrEmpty(searchInfo.ImageUrl))
                    {
                        ltlImageUrl.Text =
                            $@"<img id=""preview_imageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, searchInfo.ImageUrl)}"" width=""370"" align=""middle"" />";
                    }
                    tbSummary.Text = searchInfo.Summary;

                    cbIsOutsiteSearch.Checked = searchInfo.IsOutsiteSearch;
                    cbIsNavigation.Checked    = searchInfo.IsNavigation;
                    tbNavTitleColor.Text      = searchInfo.NavTitleColor;
                    tbNavImageColor.Text      = searchInfo.NavImageColor;
                    if (!string.IsNullOrEmpty(searchInfo.ContentImageUrl))
                    {
                        ltlContentImageUrl.Text =
                            $@"<img id=""preview_contentImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, searchInfo.ContentImageUrl)}"" width=""370"" align=""middle"" />";
                    }

                    var searchNavigationInfoList = DataProviderWX.SearchNavigationDAO.GetSearchNavigationInfoList(PublishmentSystemID, searchID);
                    var itemBuilder = new StringBuilder();
                    foreach (var searchNavigationInfo in searchNavigationInfoList)
                    {
                        var searchPageTitle = string.Empty;

                        if (searchNavigationInfo.NavigationType == ENavigationTypeUtils.GetValue(ENavigationType.Url))
                        {
                            searchPageTitle = string.Empty;
                        }
                        else if (searchNavigationInfo.NavigationType == ENavigationTypeUtils.GetValue(ENavigationType.Function))
                        {
                            searchPageTitle = KeywordManager.GetFunctionName(EKeywordTypeUtils.GetEnumType(searchNavigationInfo.KeywordType), searchNavigationInfo.FunctionID);
                        }
                        else if (searchNavigationInfo.NavigationType == ENavigationTypeUtils.GetValue(ENavigationType.Site))
                        {
                            if (searchNavigationInfo.ContentID > 0)
                            {
                                var tableStyle  = NodeManager.GetTableStyle(PublishmentSystemInfo, searchNavigationInfo.ChannelID);
                                var tableName   = NodeManager.GetTableName(PublishmentSystemInfo, searchNavigationInfo.ChannelID);
                                var contentInfo = DataProvider.ContentDAO.GetContentInfo(tableStyle, tableName, searchNavigationInfo.ContentID);

                                var pageUrl = PageUtilityWX.GetContentUrl(PublishmentSystemInfo, contentInfo);
                                searchPageTitle = $@"内容页:{contentInfo.Title}";
                            }
                            else
                            {
                                var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemID, searchNavigationInfo.ChannelID);
                                var pageUrl   = PageUtility.GetChannelUrl(PublishmentSystemInfo, NodeManager.GetNodeInfo(PublishmentSystemID, searchNavigationInfo.ChannelID));
                                searchPageTitle = $@"栏目页:{nodeNames}";
                            }
                        }

                        itemBuilder.AppendFormat("{{id: '{0}', title: '{1}',pageTitle: '{2}', url: '{3}', imageCssClass: '{4}',navigationType:'{5}',keywordType:'{6}',functionID:'{7}',channelID:'{8}',contentID:'{9}'}},", searchNavigationInfo.ID, searchNavigationInfo.Title, searchPageTitle, searchNavigationInfo.Url, searchNavigationInfo.ImageCssClass, searchNavigationInfo.NavigationType, searchNavigationInfo.KeywordType, searchNavigationInfo.FunctionID, searchNavigationInfo.ChannelID, searchNavigationInfo.ContentID);
                    }

                    if (itemBuilder.Length > 0)
                    {
                        itemBuilder.Length--;
                    }

                    ltlSearchNavs.Text += $@"
itemController.itemCount = {searchNavigationInfoList.Count};itemController.items = [{itemBuilder.ToString()}];";

                    imageUrl.Value        = searchInfo.ImageUrl;
                    contentImageUrl.Value = searchInfo.ContentImageUrl;

                    tbImageAreaTitle.Text = searchInfo.ImageAreaTitle;
                    tbTextAreaTitle.Text  = searchInfo.TextAreaTitle;

                    if (searchInfo.ImageAreaChannelID > 0)
                    {
                        var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemID, searchInfo.ImageAreaChannelID);
                        ltlSearchNavs.Text += $@"
$(document).ready(function() {{
    selectChannel(1, '{nodeNames}', {searchInfo.ImageAreaChannelID});
}});
";
                    }
                    if (searchInfo.TextAreaChannelID > 0)
                    {
                        var nodeNames = NodeManager.GetNodeNameNavigation(PublishmentSystemID, searchInfo.TextAreaChannelID);
                        ltlSearchNavs.Text += $@"
$(document).ready(function() {{
    selectChannel(2, '{nodeNames}', {searchInfo.TextAreaChannelID});
}});
";
                    }
                }

                btnImageChannelSelect.Attributes.Add("onclick", CMS.BackgroundPages.Modal.ChannelSelect.GetOpenWindowStringByItemIndex(PublishmentSystemID, "selectChannel", "1"));
                btnTextChannelSelect.Attributes.Add("onclick", CMS.BackgroundPages.Modal.ChannelSelect.GetOpenWindowStringByItemIndex(PublishmentSystemID, "selectChannel", "2"));

                btnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{BackgroundSearch.GetRedirectUrl(PublishmentSystemID)}"";return false");
            }
        }
Ejemplo n.º 12
0
        public static string Parse(string stlElement, XmlNode node, PageInfo pageInfo, ContextInfo contextInfo)
        {
            string parsedContent;

            try
            {
                var    ie           = node.Attributes?.GetEnumerator();
                var    attributes   = new StringDictionary();
                var    leftText     = string.Empty;
                var    rightText    = string.Empty;
                var    channelIndex = string.Empty;
                var    channelName  = string.Empty;
                var    upLevel      = 0;
                var    topLevel     = -1;
                var    type         = NodeAttribute.Title;
                var    formatString = string.Empty;
                string separator    = null;
                var    startIndex   = 0;
                var    length       = 0;
                var    wordNum      = 0;
                var    ellipsis     = StringUtils.Constants.Ellipsis;
                var    replace      = string.Empty;
                var    to           = string.Empty;
                var    isClearTags  = false;
                var    isReturnToBr = false;
                var    isLower      = false;
                var    isUpper      = false;
                var    isDynamic    = false;

                if (ie != null)
                {
                    while (ie.MoveNext())
                    {
                        var attr = (XmlAttribute)ie.Current;

                        if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelIndex))
                        {
                            channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeChannelName))
                        {
                            channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(attr.Value, pageInfo, contextInfo);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeParent))
                        {
                            if (TranslateUtils.ToBool(attr.Value))
                            {
                                upLevel = 1;
                            }
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeUpLevel))
                        {
                            upLevel = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTopLevel))
                        {
                            topLevel = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeType))
                        {
                            type = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLeftText))
                        {
                            leftText = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeRightText))
                        {
                            rightText = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeFormatString))
                        {
                            formatString = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeSeparator))
                        {
                            separator = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeStartIndex))
                        {
                            startIndex = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeLength))
                        {
                            length = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeWordNum))
                        {
                            wordNum = TranslateUtils.ToInt(attr.Value);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeEllipsis))
                        {
                            ellipsis = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeReplace))
                        {
                            replace = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeTo))
                        {
                            to = attr.Value;
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsClearTags))
                        {
                            isClearTags = TranslateUtils.ToBool(attr.Value, false);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsReturnToBr))
                        {
                            isReturnToBr = TranslateUtils.ToBool(attr.Value, false);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsLower))
                        {
                            isLower = TranslateUtils.ToBool(attr.Value, true);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsUpper))
                        {
                            isUpper = TranslateUtils.ToBool(attr.Value, true);
                        }
                        else if (StringUtils.EqualsIgnoreCase(attr.Name, AttributeIsDynamic))
                        {
                            isDynamic = TranslateUtils.ToBool(attr.Value, false);
                        }
                        else
                        {
                            attributes.Add(attr.Name, attr.Value);
                        }
                    }
                }

                parsedContent = isDynamic ? StlDynamic.ParseDynamicElement(stlElement, pageInfo, contextInfo) : ParseImpl(stlElement, node, pageInfo, contextInfo, attributes, leftText, rightText, channelIndex, channelName, upLevel, topLevel, type, formatString, separator, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper);
            }
            catch (Exception ex)
            {
                parsedContent = StlParserUtility.GetStlErrorMessage(ElementName, ex);
            }

            return(parsedContent);
        }
Ejemplo n.º 13
0
        public static string Parse(PageInfo pageInfo, ContextInfo contextInfo)
        {
            var connectionString = string.Empty;
            var queryString      = string.Empty;

            var leftText     = string.Empty;
            var rightText    = string.Empty;
            var formatString = string.Empty;
            var startIndex   = 0;
            var length       = 0;
            var wordNum      = 0;
            var ellipsis     = StringUtils.Constants.Ellipsis;
            var replace      = string.Empty;
            var to           = string.Empty;
            var isClearTags  = false;
            var isReturnToBr = false;
            var isLower      = false;
            var isUpper      = false;
            var type         = string.Empty;

            foreach (var name in contextInfo.Attributes.Keys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, AttributeConnectionString))
                {
                    connectionString = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeConnectionStringName))
                {
                    if (string.IsNullOrEmpty(connectionString))
                    {
                        connectionString = WebConfigUtils.ConnectionString;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeQueryString))
                {
                    queryString = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeType))
                {
                    type = value.ToLower();
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeLeftText))
                {
                    leftText = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeRightText))
                {
                    rightText = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeFormatString))
                {
                    formatString = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeStartIndex))
                {
                    startIndex = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeLength))
                {
                    length = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeWordNum))
                {
                    wordNum = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeEllipsis))
                {
                    ellipsis = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeReplace))
                {
                    replace = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeTo))
                {
                    to = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsClearTags))
                {
                    isClearTags = TranslateUtils.ToBool(value, false);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsReturnToBr))
                {
                    isReturnToBr = TranslateUtils.ToBool(value, false);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsLower))
                {
                    isLower = TranslateUtils.ToBool(value, true);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsUpper))
                {
                    isUpper = TranslateUtils.ToBool(value, true);
                }
            }

            return(ParseImpl(pageInfo, contextInfo, connectionString, queryString, leftText, rightText, formatString, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper, type));
        }
Ejemplo n.º 14
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            bool isChanged;
            var  parentChannelId = TranslateUtils.ToInt(Request.Form["channelId"]);

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

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

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

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

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

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

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

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

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

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

                        CreateManager.CreateChannel(SiteId, insertedChannelId);
                    }
                }

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

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

            if (isChanged)
            {
                LayerUtils.CloseAndRedirect(Page, _returnUrl);
            }
        }
Ejemplo n.º 15
0
        public static string Parse(PageInfo pageInfo, ContextInfo contextInfo)
        {
            var isGetPicUrlFromAttribute = false;
            var channelIndex             = string.Empty;
            var channelName = string.Empty;
            var upLevel     = 0;
            var topLevel    = -1;
            var type        = BackgroundContentAttribute.VideoUrl;
            var playUrl     = string.Empty;
            var imageUrl    = string.Empty;
            var playBy      = string.Empty;
            var width       = 450;
            var height      = 350;
            var isAutoPlay  = true;

            foreach (var name in contextInfo.Attributes.Keys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, ChannelIndex.Name))
                {
                    channelIndex = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (!string.IsNullOrEmpty(channelIndex))
                    {
                        isGetPicUrlFromAttribute = true;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, ChannelName.Name))
                {
                    channelName = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                    if (!string.IsNullOrEmpty(channelName))
                    {
                        isGetPicUrlFromAttribute = true;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, Parent.Name))
                {
                    if (TranslateUtils.ToBool(value))
                    {
                        upLevel = 1;
                        isGetPicUrlFromAttribute = true;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, UpLevel.Name))
                {
                    upLevel = TranslateUtils.ToInt(value);
                    if (upLevel > 0)
                    {
                        isGetPicUrlFromAttribute = true;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, TopLevel.Name))
                {
                    topLevel = TranslateUtils.ToInt(value);
                    if (topLevel >= 0)
                    {
                        isGetPicUrlFromAttribute = true;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, Type.Name))
                {
                    type = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, PlayUrl.Name) || StringUtils.EqualsIgnoreCase(name, "src"))
                {
                    playUrl = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, ImageUrl.Name))
                {
                    imageUrl = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, PlayBy.Name))
                {
                    playBy = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, Width.Name))
                {
                    width = TranslateUtils.ToInt(value, width);
                }
                else if (StringUtils.EqualsIgnoreCase(name, Height.Name))
                {
                    height = TranslateUtils.ToInt(value, height);
                }
                else if (StringUtils.EqualsIgnoreCase(name, IsAutoPlay.Name) || StringUtils.EqualsIgnoreCase(name, "play"))
                {
                    isAutoPlay = TranslateUtils.ToBool(value, true);
                }
            }

            return(ParseImpl(pageInfo, contextInfo, isGetPicUrlFromAttribute, channelIndex, channelName, upLevel, topLevel, playUrl, imageUrl, playBy, width, height, type, isAutoPlay));
        }
Ejemplo n.º 16
0
        //对“flash滚动焦点图”(stl:focusViewer)元素进行解析
        public static string Parse(PageInfo pageInfo, ContextInfo contextInfo)
        {
            // 如果是实体标签则返回空
            if (contextInfo.IsCurlyBrace)
            {
                return(string.Empty);
            }

            var channelIndex    = string.Empty;
            var channelName     = string.Empty;
            var scopeType       = EScopeType.Self;
            var groupChannel    = string.Empty;
            var groupChannelNot = string.Empty;
            var groupContent    = string.Empty;
            var groupContentNot = string.Empty;
            var tags            = string.Empty;
            var orderByString   = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByTaxisDesc);
            var startNum        = 1;
            var totalNum        = 0;
            var isShowText      = true;
            var isTopText       = string.Empty;
            var titleWordNum    = 0;

            var where = string.Empty;

            var isTop             = false;
            var isTopExists       = false;
            var isRecommend       = false;
            var isRecommendExists = false;
            var isHot             = false;
            var isHotExists       = false;
            var isColor           = false;
            var isColorExists     = false;

            var theme          = string.Empty;
            var imageWidth     = 260;
            var imageHeight    = 182;
            var textHeight     = 25;
            var bgColor        = string.Empty;
            var genericControl = new HtmlGenericControl("div");

            foreach (var name in contextInfo.Attributes.Keys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, AttributeChannelIndex))
                {
                    channelIndex = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeChannelName))
                {
                    channelName = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeScope))
                {
                    scopeType = EScopeTypeUtils.GetEnumType(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannel))
                {
                    groupChannel = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupChannelNot))
                {
                    groupChannelNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupContent))
                {
                    groupContent = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeGroupContentNot))
                {
                    groupContentNot = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeTags))
                {
                    tags = StlEntityParser.ReplaceStlEntitiesForAttributeValue(value, pageInfo, contextInfo);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeOrder))
                {
                    orderByString = StlDataUtility.GetContentOrderByString(pageInfo.SiteId, value, ETaxisType.OrderByTaxisDesc);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeStartNum))
                {
                    startNum = TranslateUtils.ToInt(value, 1);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeTotalNum))
                {
                    totalNum = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeTitleWordNum))
                {
                    titleWordNum = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeWhere))
                {
                    where = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsTop))
                {
                    isTopExists = true;
                    isTop       = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsRecommend))
                {
                    isRecommendExists = true;
                    isRecommend       = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsHot))
                {
                    isHotExists = true;
                    isHot       = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsColor))
                {
                    isColorExists = true;
                    isColor       = TranslateUtils.ToBool(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeTheme))
                {
                    theme = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeWidth))
                {
                    if (StringUtils.EndsWithIgnoreCase(value, "px"))
                    {
                        value = value.Substring(0, value.Length - 2);
                    }
                    imageWidth = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeHeight))
                {
                    if (StringUtils.EndsWithIgnoreCase(value, "px"))
                    {
                        value = value.Substring(0, value.Length - 2);
                    }
                    imageHeight = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeBgColor))
                {
                    bgColor = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsShowText))
                {
                    isShowText = TranslateUtils.ToBool(value, true);
                }
                else if (StringUtils.EqualsIgnoreCase(name, AttributeIsTopText))
                {
                    isTopText = value;
                }
                else
                {
                    genericControl.Attributes[name] = value;
                }
            }

            return(ParseImpl(pageInfo, contextInfo, genericControl, channelIndex, channelName, scopeType, groupChannel, groupChannelNot, groupContent, groupContentNot, tags, orderByString, startNum, totalNum, isShowText, isTopText, titleWordNum, where, isTop, isTopExists, isRecommend, isRecommendExists, isHot, isHotExists, isColor, isColorExists, theme, imageWidth, imageHeight, textHeight, bgColor));
        }
Ejemplo n.º 17
0
        public void Page_Load(object sender, EventArgs e)
        {
            var    type          = Request["type"];
            var    retval        = new NameValueCollection();
            string retString     = null;
            string retSiteString = null;
            var    body          = new RequestBody();

            if (type == TypeGetCountArray)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                retval = GetCountArray(userKeyPrefix);
            }
            else if (type == TypeSiteTemplateDownload)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(Request["downloadUrl"]);
                var directoryName = Request["directoryName"];
                retval = SiteTemplateDownload(downloadUrl, directoryName, userKeyPrefix);
            }
            else if (type == TypeSiteTemplateZip)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var directoryName = Request["directoryName"];
                retval = SiteTemplateZip(directoryName, userKeyPrefix);
            }
            else if (type == TypeGetLoadingChannels)
            {
                var publishmentSystemId = TranslateUtils.ToInt(Request["publishmentSystemID"]);
                var parentId            = TranslateUtils.ToInt(Request["parentID"]);
                var loadingType         = Request["loadingType"];
                var additional          = Request["additional"];
                retString = GetLoadingChannels(publishmentSystemId, parentId, loadingType, additional, body);
            }
            else if (type == TypeGetLoadingSites)
            {
                var parentId    = TranslateUtils.ToInt(Request["parentID"]);
                var loadingType = Request["loadingType"];
                var additional  = Request["additional"];
                retSiteString = GetLoadingSites(parentId, body.AdministratorName, body.AdministratorInfo.PublishmentSystemId);
            }
            //else if (type == "GetLoadingGovPublicCategories")
            //{
            //    string classCode = base.Request["classCode"];
            //    int publishmentSystemID = TranslateUtils.ToInt(base.Request["publishmentSystemID"]);
            //    int parentID = TranslateUtils.ToInt(base.Request["parentID"]);
            //    string loadingType = base.Request["loadingType"];
            //    string additional = base.Request["additional"];
            //    retString = GetLoadingGovPublicCategories(classCode, publishmentSystemID, parentID, loadingType, additional);
            //}
            //else if (type == "GetLoadingTemplates")
            //{
            //    int publishmentSystemID = TranslateUtils.ToInt(base.Request["publishmentSystemID"]);
            //    string templateType = base.Request["templateType"];
            //    retString = GetLoadingTemplates(publishmentSystemID, templateType);
            //}
            //else if (type == "StlTemplate")
            //{
            //    int publishmentSystemID = TranslateUtils.ToInt(base.Request["publishmentSystemID"]);
            //    int templateID = TranslateUtils.ToInt(base.Request["templateID"]);
            //    string includeUrl = base.Request["includeUrl"];
            //    string operation = base.Request["operation"];
            //    retval = TemplateDesignOperation.Operate(publishmentSystemID, templateID, includeUrl, operation, base.Request.Form);
            //}

            if (retString != null)
            {
                Page.Response.Write(retString);
                Page.Response.End();
            }
            else if (retSiteString != null)
            {
                Page.Response.Write(retSiteString);
                Page.Response.End();
            }
            else
            {
                var jsonString = TranslateUtils.NameValueCollectionToJsonString(retval);
                Page.Response.Write(jsonString);
                Page.Response.End();
            }
        }
Ejemplo n.º 18
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var isChanged = false;

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

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

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

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

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

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

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

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

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

                DataProvider.ChannelDao.Update(nodeInfo);

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

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

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

                if (string.IsNullOrEmpty(_returnUrl))
                {
                    LayerUtils.Close(Page);
                }
                else
                {
                    LayerUtils.CloseAndRedirect(Page, _returnUrl);
                }
            }
        }
Ejemplo n.º 19
0
        public void Page_Load(object sender, EventArgs e)
        {
            var    type      = Request["type"];
            var    retval    = new NameValueCollection();
            string retString = null;
            var    request   = new AuthRequest();

            if (!request.IsAdminLoggin)
            {
                return;
            }

            if (type == TypeGetCountArray)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                retval = GetCountArray(userKeyPrefix);
            }
            else if (type == TypeSiteTemplateDownload)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(Request["downloadUrl"]);
                var directoryName = Request["directoryName"];
                retval = SiteTemplateDownload(downloadUrl, directoryName, userKeyPrefix);
            }
            else if (type == TypeSiteTemplateZip)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var directoryName = Request["directoryName"];
                retval = SiteTemplateZip(directoryName, userKeyPrefix);
            }
            else if (type == TypeSiteTemplateUnZip)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var fileName      = Request["fileName"];
                retval = SiteTemplateUnZip(fileName, userKeyPrefix);
            }
            else if (type == TypeGetLoadingChannels)
            {
                var siteId = TranslateUtils.ToInt(Request["siteId"]);
                var contentModelPluginId = Request["contentModelPluginId"];
                var parentId             = TranslateUtils.ToInt(Request["parentId"]);
                var loadingType          = Request["loadingType"];
                var additional           = Request["additional"];
                retString = GetLoadingChannels(siteId, contentModelPluginId, parentId, loadingType, additional, request);
            }
            else if (type == TypePluginDownload)
            {
                var userKeyPrefix = Request["userKeyPrefix"];
                var downloadUrl   = TranslateUtils.DecryptStringBySecretKey(Request["downloadUrl"]);
                retval = PluginDownload(downloadUrl, userKeyPrefix);
            }
            //else if (type == "GetLoadingGovPublicCategories")
            //{
            //    string classCode = base.Request["classCode"];
            //    int siteID = TranslateUtils.ToInt(base.Request["siteID"]);
            //    int parentID = TranslateUtils.ToInt(base.Request["parentID"]);
            //    string loadingType = base.Request["loadingType"];
            //    string additional = base.Request["additional"];
            //    retString = GetLoadingGovPublicCategories(classCode, siteID, parentID, loadingType, additional);
            //}
            //else if (type == "GetLoadingTemplates")
            //{
            //    int siteID = TranslateUtils.ToInt(base.Request["siteID"]);
            //    string templateType = base.Request["templateType"];
            //    retString = GetLoadingTemplates(siteID, templateType);
            //}
            //else if (type == "StlTemplate")
            //{
            //    int siteID = TranslateUtils.ToInt(base.Request["siteID"]);
            //    int templateID = TranslateUtils.ToInt(base.Request["templateID"]);
            //    string includeUrl = base.Request["includeUrl"];
            //    string operation = base.Request["operation"];
            //    retval = TemplateDesignOperation.Operate(siteID, templateID, includeUrl, operation, base.Request.Form);
            //}

            if (retString != null)
            {
                Page.Response.Write(retString);
                Page.Response.End();
            }
            else
            {
                var jsonString = TranslateUtils.NameValueCollectionToJsonString(retval);
                Page.Response.Write(jsonString);
                Page.Response.End();
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 将频道模板中的辅助表导入发布系统中,返回修改了的表名对照
        /// 在导入辅助表的同时检查发布系统辅助表并替换对应表
        /// </summary>
        public NameValueCollection ImportAuxiliaryTables(int siteId, bool isUserTables)
        {
            if (!DirectoryUtils.IsDirectoryExists(_directoryPath))
            {
                return(null);
            }

            var siteInfo = SiteManager.GetSiteInfo(siteId);

            var nameValueCollection = new NameValueCollection();
            var tableNamePrefix     = siteInfo.SiteDir + "_";

            var filePaths = DirectoryUtils.GetFilePaths(_directoryPath);

            foreach (var filePath in filePaths)
            {
                var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(filePath));

                var tableName = AtomUtility.GetDcElementContent(feed.AdditionalElements, new List <string> {
                    nameof(TableInfo.TableName), "TableENName"
                });

                if (!isUserTables)
                {
                    nameValueCollection[tableName] = siteInfo.TableName;
                    continue;
                }

                var displayName = AtomUtility.GetDcElementContent(feed.AdditionalElements, new List <string> {
                    nameof(TableInfo.DisplayName), "TableCNName"
                });

                var serializedString = AtomUtility.GetDcElementContent(feed.AdditionalElements, "SerializedString");

                var tableNameToInsert = string.Empty;//需要增加的表名,空代表不需要添加辅助表

                var tableInfo = DataProvider.TableDao.GetTableCollectionInfo(tableName);
                if (tableInfo == null)//如果当前系统无此表名
                {
                    tableNameToInsert = tableName;
                }
                else
                {
                    var serializedStringForExistTable = TableMetadataManager.GetSerializedString(tableName);

                    if (!string.IsNullOrEmpty(serializedString))
                    {
                        if (serializedString != serializedStringForExistTable)//仅有此时,导入表需要修改表名
                        {
                            tableNameToInsert = tableNamePrefix + tableName;
                            displayName       = tableNamePrefix + displayName;
                            nameValueCollection[tableName] = tableNameToInsert;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(tableNameToInsert))//需要添加
                {
                    if (!DataProvider.DatabaseDao.IsTableExists(tableNameToInsert))
                    {
                        tableInfo = new TableInfo
                        {
                            TableName                 = tableNameToInsert,
                            DisplayName               = displayName,
                            AttributeNum              = 0,
                            IsCreatedInDb             = false,
                            IsChangedAfterCreatedInDb = false,
                            Description               = AtomUtility.GetDcElementContent(feed.AdditionalElements, nameof(TableInfo.Description))
                        };

                        var metadataInfoList = new List <TableMetadataInfo>();
                        foreach (AtomEntry entry in feed.Entries)
                        {
                            var metaInfo = new TableMetadataInfo
                            {
                                TableName     = tableNameToInsert,
                                AttributeName = AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.AttributeName)),
                                DataType      = DataTypeUtils.GetEnumType(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.DataType))),
                                DataLength    = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.DataLength))),
                                Taxis         = TranslateUtils.ToInt(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.Taxis))),
                                IsSystem      = TranslateUtils.ToBool(AtomUtility.GetDcElementContent(entry.AdditionalElements, nameof(TableMetadataInfo.IsSystem)))
                            };

                            if (string.IsNullOrEmpty(metaInfo.AttributeName) ||
                                ContentAttribute.AllAttributesLowercase.Contains(metaInfo.AttributeName.ToLower()))
                            {
                                continue;
                            }

                            metadataInfoList.Add(metaInfo);
                        }

                        DataProvider.TableDao.Insert(tableInfo, metadataInfoList);

                        DataProvider.TableDao.CreateDbTable(tableNameToInsert);
                    }
                }

                var tableNameToChange = !string.IsNullOrEmpty(tableNameToInsert) ? tableNameToInsert : tableName;
                //更新发布系统后台内容表及栏目表
                siteInfo.TableName = tableNameToChange;
                DataProvider.SiteDao.Update(siteInfo);
            }

            return(nameValueCollection);
        }
Ejemplo n.º 21
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (phStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (phStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (phStep3.Visible)
                {
                    selectedStep = 3;
                }

                phStep1.Visible = phStep2.Visible = phStep3.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(tbKeywords.Text))
                    {
                        if (voteID > 0)
                        {
                            var voteInfo = DataProviderWX.VoteDAO.GetVoteInfo(voteID);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemID, voteInfo.KeywordID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        phStep1.Visible = true;
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    var isItemReady = true;
                    var itemCount   = TranslateUtils.ToInt(Request.Form["itemCount"]);

                    if (itemCount < 2)
                    {
                        FailMessage("投票保存失败,至少设置两个投票项");
                        isItemReady = false;
                    }
                    else
                    {
                        var isImageOption = TranslateUtils.ToBool(ddlContentIsImageOption.SelectedValue);

                        var itemIDList        = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                        var titleList         = TranslateUtils.StringCollectionToStringList(Request.Form["itemTitle"]);
                        var imageUrlList      = TranslateUtils.StringCollectionToStringList(Request.Form["itemImageUrl"]);
                        var navigationUrlList = TranslateUtils.StringCollectionToStringList(Request.Form["itemNavigationUrl"]);
                        var voteNumList       = TranslateUtils.StringCollectionToIntList(Request.Form["itemVoteNum"]);
                        var voteItemInfoList  = new List <VoteItemInfo>();
                        for (var i = 0; i < itemCount; i++)
                        {
                            var imageUrl = string.Empty;
                            if (isImageOption)
                            {
                                imageUrl = imageUrlList[i];
                            }
                            var itemInfo = new VoteItemInfo {
                                ID = itemIDList[i], VoteID = voteID, PublishmentSystemID = PublishmentSystemID, Title = titleList[i], ImageUrl = imageUrl, NavigationUrl = navigationUrlList[i], VoteNum = voteNumList[i]
                            };

                            if (isImageOption && string.IsNullOrEmpty(itemInfo.ImageUrl))
                            {
                                FailMessage("投票保存失败,图片地址为必填项");
                                isItemReady = false;
                            }
                            if (string.IsNullOrEmpty(itemInfo.Title))
                            {
                                FailMessage("投票保存失败,选项标题为必填项");
                                isItemReady = false;
                            }

                            voteItemInfoList.Add(itemInfo);
                        }

                        if (isItemReady)
                        {
                            //DataProviderWX.VoteItemDAO.DeleteAll(base.PublishmentSystemID, this.voteID);

                            foreach (var itemInfo in voteItemInfoList)
                            {
                                var newVoteItemInfo = DataProviderWX.VoteItemDAO.GetVoteItemInfo(itemInfo.ID);
                                if (itemInfo.ID > 0)
                                {
                                    itemInfo.VoteNum = newVoteItemInfo.VoteNum;
                                    DataProviderWX.VoteItemDAO.Update(itemInfo);
                                }
                                else
                                {
                                    DataProviderWX.VoteItemDAO.Insert(itemInfo);
                                }
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        phStep3.Visible = true;
                        btnSubmit.Text  = "确 认";
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 3)
                {
                    var voteInfo = new VoteInfo();
                    if (voteID > 0)
                    {
                        voteInfo = DataProviderWX.VoteDAO.GetVoteInfo(voteID);
                    }
                    voteInfo.PublishmentSystemID = PublishmentSystemID;

                    voteInfo.KeywordID  = DataProviderWX.KeywordDAO.GetKeywordID(PublishmentSystemID, voteID > 0, tbKeywords.Text, EKeywordType.Vote, voteInfo.KeywordID);
                    voteInfo.IsDisabled = !cbIsEnabled.Checked;

                    voteInfo.StartDate = dtbStartDate.DateTime;
                    voteInfo.EndDate   = dtbEndDate.DateTime;
                    voteInfo.Title     = PageUtils.FilterXSS(tbTitle.Text);
                    voteInfo.ImageUrl  = imageUrl.Value;;
                    voteInfo.Summary   = tbSummary.Text;

                    voteInfo.ContentImageUrl      = contentImageUrl.Value;
                    voteInfo.ContentDescription   = tbContentDescription.Text;
                    voteInfo.ContentIsImageOption = TranslateUtils.ToBool(ddlContentIsImageOption.SelectedValue).ToString();
                    voteInfo.ContentIsCheckBox    = TranslateUtils.ToBool(ddlContentIsCheckBox.SelectedValue).ToString();
                    voteInfo.ContentResultVisible = EVoteResultVisibleUtils.GetValue(EVoteResultVisible.After);

                    voteInfo.EndTitle    = tbEndTitle.Text;
                    voteInfo.EndImageUrl = endImageUrl.Value;
                    voteInfo.EndSummary  = tbEndSummary.Text;

                    try
                    {
                        if (voteID > 0)
                        {
                            DataProviderWX.VoteDAO.Update(voteInfo);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "修改投票活动",
                                            $"投票活动:{tbTitle.Text}");
                            SuccessMessage("修改投票活动成功!");
                        }
                        else
                        {
                            voteID = DataProviderWX.VoteDAO.Insert(voteInfo);

                            DataProviderWX.VoteItemDAO.UpdateVoteID(PublishmentSystemID, voteID);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "添加投票活动",
                                            $"投票活动:{tbTitle.Text}");
                            SuccessMessage("添加投票活动成功!");
                        }

                        var redirectUrl = PageUtils.GetWXUrl(
                            $"background_vote.aspx?publishmentSystemID={PublishmentSystemID}");
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "投票活动设置失败!");
                    }

                    btnSubmit.Visible = false;
                    btnReturn.Visible = false;
                }
            }
        }
Ejemplo n.º 22
0
 public void Redirect(object sender, EventArgs e)
 {
     PageUtils.Redirect(GetRedirectUrl(SiteId, TranslateUtils.ToInt(DdlChannelId.SelectedValue)));
 }
Ejemplo n.º 23
0
        private static async Task <bool> TestTypeDefaultAsync(IParseManager parseManager, string testType, string testOperate,
                                                              string testValue)
        {
            var isSuccess = false;

            var theValue = await GetAttributeValueByContextAsync(parseManager, testType);

            if (StringUtils.EqualsIgnoreCase(testOperate, OperateNotEmpty))
            {
                if (!string.IsNullOrEmpty(theValue))
                {
                    isSuccess = true;
                }
            }
            else if (StringUtils.EqualsIgnoreCase(testOperate, OperateEmpty))
            {
                if (string.IsNullOrEmpty(theValue))
                {
                    isSuccess = true;
                }
            }
            else
            {
                if (StringUtils.IsDateTime(theValue))
                {
                    var dateTime = TranslateUtils.ToDateTime(theValue);
                    isSuccess = IsDateTime(dateTime, testOperate, testValue);
                }
                else if (StringUtils.IsNumber(theValue))
                {
                    var number = TranslateUtils.ToInt(theValue);
                    isSuccess = IsNumber(number, testOperate, testValue);
                }
                else
                {
                    if (StringUtils.EqualsIgnoreCase(testOperate, OperateEquals))
                    {
                        if (StringUtils.EqualsIgnoreCase(theValue, testValue))
                        {
                            isSuccess = true;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(testOperate, OperateNotEquals))
                    {
                        if (!StringUtils.EqualsIgnoreCase(theValue, testValue))
                        {
                            isSuccess = true;
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(testOperate, OperateGreatThan))
                    {
                        if (!string.IsNullOrEmpty(theValue) && theValue.Contains('-'))
                        {
                            if (TranslateUtils.ToDateTime(theValue) > TranslateUtils.ToDateTime(testValue))
                            {
                                isSuccess = true;
                            }
                        }
                        else
                        {
                            if (TranslateUtils.ToInt(theValue) > TranslateUtils.ToInt(testValue))
                            {
                                isSuccess = true;
                            }
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(testOperate, OperateLessThan))
                    {
                        if (!string.IsNullOrEmpty(theValue) && theValue.Contains('-'))
                        {
                            if (TranslateUtils.ToDateTime(theValue) < TranslateUtils.ToDateTime(testValue))
                            {
                                isSuccess = true;
                            }
                        }
                        else
                        {
                            if (TranslateUtils.ToInt(theValue) < TranslateUtils.ToInt(testValue))
                            {
                                isSuccess = true;
                            }
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(testOperate, OperateIn))
                    {
                        var stringList = ListUtils.GetStringList(testValue);

                        foreach (var str in stringList)
                        {
                            if (StringUtils.EndsWithIgnoreCase(str, "*"))
                            {
                                var theStr = str.Substring(0, str.Length - 1);
                                if (StringUtils.StartsWithIgnoreCase(theValue, theStr))
                                {
                                    isSuccess = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (StringUtils.EqualsIgnoreCase(theValue, str))
                                {
                                    isSuccess = true;
                                    break;
                                }
                            }
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(testOperate, OperateNotIn))
                    {
                        var stringList = ListUtils.GetStringList(testValue);

                        var isIn = false;
                        foreach (var str in stringList)
                        {
                            if (StringUtils.EndsWithIgnoreCase(str, "*"))
                            {
                                var theStr = str.Substring(0, str.Length - 1);
                                if (StringUtils.StartsWithIgnoreCase(theValue, theStr))
                                {
                                    isIn = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (StringUtils.EqualsIgnoreCase(theValue, str))
                                {
                                    isIn = true;
                                    break;
                                }
                            }
                        }
                        if (!isIn)
                        {
                            isSuccess = true;
                        }
                    }
                }
            }

            return(isSuccess);
        }
Ejemplo n.º 24
0
 public int GetQueryInt(string name, int defaultValue = 0)
 {
     return(!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[name]) ? TranslateUtils.ToInt(HttpContext.Current.Request.QueryString[name]) : defaultValue);
 }
Ejemplo n.º 25
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                if (this.contentID == 0)
                {
                    var contentInfo = new VoteContentInfo();
                    try
                    {
                        InputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                        contentInfo.NodeId = nodeID;
                        contentInfo.PublishmentSystemId = PublishmentSystemId;
                        contentInfo.AddUserName         = Body.AdministratorName;
                        if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year)
                        {
                            FailMessage($"投票添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年");
                            return;
                        }
                        contentInfo.LastEditUserName = contentInfo.AddUserName;
                        contentInfo.LastEditDate     = DateTime.Now;
                        contentInfo.IsChecked        = false;

                        contentInfo.IsSummary    = TranslateUtils.ToBool(Request.Form["IsSummary"]);
                        contentInfo.Summary      = tbSummary.Text;
                        contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue);
                        contentInfo.AddDate      = dtbAddDate.DateTime;
                        if (string.IsNullOrEmpty(ddlEndDate.SelectedValue))
                        {
                            contentInfo.EndDate = dtbEndDate.DateTime;
                        }
                        else
                        {
                            contentInfo.EndDate = TranslateUtils.ToDateTime(ddlEndDate.SelectedValue);
                        }
                        contentInfo.IsVotedView   = TranslateUtils.ToBool(rblIsVotedView.SelectedValue);
                        contentInfo.HiddenContent = tbHiddenContent.Text;

                        var checkedLevel = 0;
                        contentInfo.IsChecked    = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevel);
                        contentInfo.CheckedLevel = checkedLevel;

                        var contentID = DataProvider.ContentDao.Insert(tableName, PublishmentSystemInfo, contentInfo);

                        var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]);
                        var voteOptionInfoArrayList = new ArrayList();
                        for (var i = 0; i < itemCount; i++)
                        {
                            var title = Request.Form["options[" + i + "]"];
                            if (!string.IsNullOrEmpty(title))
                            {
                                var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0);
                                voteOptionInfoArrayList.Add(optionInfo);
                            }
                        }
                        DataProvider.VoteOptionDao.Insert(voteOptionInfoArrayList);

                        contentInfo.Id = contentID;
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, $"投票添加失败:{ex.Message}");
                        LogUtils.AddErrorLog(ex);
                        return;
                    }

                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentInfo.Id);
                    }

                    Body.AddSiteLog(PublishmentSystemId, nodeID, contentInfo.Id, "添加投票",
                                    $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}");

                    PageUtils.Redirect(PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, nodeID, contentInfo.Id, returnUrl));
                }
                else
                {
                    var contentInfo = DataProvider.VoteContentDao.GetContentInfo(PublishmentSystemInfo, contentID);
                    try
                    {
                        InputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                        contentInfo.LastEditUserName = Body.AdministratorName;
                        contentInfo.LastEditDate     = DateTime.Now;

                        contentInfo.IsSummary     = TranslateUtils.ToBool(Request.Form["IsSummary"]);
                        contentInfo.Summary       = tbSummary.Text;
                        contentInfo.MaxSelectNum  = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue);
                        contentInfo.AddDate       = dtbAddDate.DateTime;
                        contentInfo.EndDate       = dtbEndDate.DateTime;
                        contentInfo.IsVotedView   = TranslateUtils.ToBool(rblIsVotedView.SelectedValue);
                        contentInfo.HiddenContent = tbHiddenContent.Text;

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

                        var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]);
                        var voteOptionInfoArrayList = new ArrayList();
                        for (var i = 0; i < itemCount; i++)
                        {
                            var title = Request.Form["options[" + i + "]"];
                            if (!string.IsNullOrEmpty(title))
                            {
                                var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0);
                                voteOptionInfoArrayList.Add(optionInfo);
                            }
                        }
                        DataProvider.VoteOptionDao.UpdateVoteOptionInfoArrayList(PublishmentSystemId, nodeID, contentID, voteOptionInfoArrayList);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, $"投票修改失败:{ex.Message}");
                        LogUtils.AddErrorLog(ex);
                        return;
                    }

                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentID);
                    }

                    Body.AddSiteLog(PublishmentSystemId, nodeID, contentID, "修改投票",
                                    $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}");

                    PageUtils.Redirect(returnUrl);
                }
            }
        }
Ejemplo n.º 26
0
 public int GetPostInt(string name, int defaultValue = 0)
 {
     return(TranslateUtils.ToInt(PostData[name]?.ToString(), defaultValue));
 }
Ejemplo n.º 27
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(Body.GetQueryInt("PublishmentSystemId"));
                publishmentSystemInfo.PublishmentSystemName = PublishmentSystemName.Text;
                publishmentSystemInfo.Area = PublishmentSystemArea.Text;
                publishmentSystemInfo.OrganizationTypeId   = TranslateUtils.ToInt(CblPublishmentSystemType.SelectedValue);
                publishmentSystemInfo.OrganizationCategory = TranslateUtils.ToInt(CblPublishmentSystemCategory.SelectedValue);

                publishmentSystemInfo.TelePhone            = TelePhone.Text;
                publishmentSystemInfo.Address              = Address.Text;
                publishmentSystemInfo.BasicFacts           = BasicFacts.Text;
                publishmentSystemInfo.Characteristic       = Characteristic.Text;
                publishmentSystemInfo.AdministratorAccount = AdministratorAccount.Text;
                publishmentSystemInfo.ImageUrl             = ImageUrl.Text;
                //更新站点信息
                try
                {
                    DataProvider.PublishmentSystemDao.UpdateAll(PublishmentSystemInfo);
                    Body.AddAdminLog("修改站点属性", $"站点:{PublishmentSystemInfo.PublishmentSystemName}");
                    SuccessMessage("站点修改成功!");
                    // AddWaitAndRedirectScript(Sys.PagePublishmentSystem.GetRedirectUrl());
                    // AddWaitAndRedirectScript($@"/siteserver/loading.aspx?RedirectType=Loading&RedirectUrl=cms/siteManagement.aspx?PublishmentSystemID={PublishmentSystemId}");
                    var parentId = DataProvider.PublishmentSystemDao.GetParentId(PublishmentSystemId);
                    AddWaitAndRedirectScript($@"/siteserver/cms/PagePublishmentSystem.aspx?PublishmentSystemID={(parentId==0?1:parentId)}");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "站点修改失败!");
                }
                //更新管理员信息
                if (!string.IsNullOrEmpty(AdministratorPassWord.Text))
                {
                    var    _userName    = AdministratorAccount.Text;
                    string errorMessage = string.Empty;

                    if (!string.IsNullOrEmpty(_userName) && BaiRongDataProvider.AdministratorDao.IsUserNameExists(_userName))
                    {
                        try
                        {
                            if (!BaiRongDataProvider.AdministratorDao.ChangePassword(_userName, EPasswordFormat.Encrypted, AdministratorPassWord.Text, out errorMessage))
                            {
                                FailMessage(errorMessage);
                                return;
                            }

                            Body.AddAdminLog("重设管理员密码", $"管理员:{_userName}");
                        }
                        catch
                        {
                            SuccessMessage("修改管理员密码失败!");
                        }
                    }
                    else
                    {
                        FailMessage("此站点超级管理员不存在!");
                    }
                }
                //更新角色
                string[] roles                = PermissionsManager.GetPermissions(publishmentSystemInfo.AdministratorAccount).Roles;
                string   mainPermission       = string.Empty;
                var      systemPermissionlist = new List <SystemPermissionsInfo>();
                //获取栏目角色
                int    publishmentSystemId = publishmentSystemInfo.PublishmentSystemId;
                string roleName            = "superManager_" + publishmentSystemId;
                for (int i = 0; i < rptContents.Items.Count; i++)
                {
                    string nodeId = ((HiddenField)rptContents.Items[i].FindControl("hidNodeId")).Value;
                    //int publishmentSystemId = int.Parse(((HiddenField)rptContents.Items[i].FindControl("hidPublishmentSystemId")).Value);
                    string       channelPermissions = string.Empty;
                    CheckBoxList cblActionType      = (CheckBoxList)rptContents.Items[i].FindControl("cblActionType");
                    for (int n = 0; n < cblActionType.Items.Count; n++)
                    {
                        if (cblActionType.Items[n].Selected == true)
                        {
                            channelPermissions = channelPermissions + cblActionType.Items[n].Value + ",";
                        }
                    }
                    channelPermissions = channelPermissions.TrimEnd(',');
                    if (!string.IsNullOrEmpty(channelPermissions))
                    {
                        systemPermissionlist.Add(new SystemPermissionsInfo(roleName, publishmentSystemId, nodeId, channelPermissions, string.Empty));
                    }
                }
                //获取站点相关权限角色
                for (int i = 0; i < rptWebSite.Items.Count; i++)
                {
                    string webPermission = ((HiddenField)rptWebSite.Items[i].FindControl("hidPermission")).Value;
                    //int publishmentSystemId = int.Parse(((HiddenField)rptContents.Items[i].FindControl("hidPublishmentSystemId")).Value);
                    string       webSitePermissions = string.Empty;
                    CheckBoxList cblActionType      = (CheckBoxList)rptWebSite.Items[i].FindControl("cblWebSiteType");
                    for (int n = 0; n < cblActionType.Items.Count; n++)
                    {
                        if (cblActionType.Items[n].Selected == true)
                        {
                            webSitePermissions = webSitePermissions + cblActionType.Items[n].Value + ",";
                        }
                    }
                    webSitePermissions = webSitePermissions.TrimEnd(',');
                    if (!string.IsNullOrEmpty(webSitePermissions))
                    {
                        systemPermissionlist.Add(new SystemPermissionsInfo(roleName, publishmentSystemId, string.Empty, string.Empty, webSitePermissions));
                    }
                }
                foreach (string role in roles)
                {
                    if (role.StartsWith("superManager_"))
                    {
                        mainPermission = role;
                        break;
                    }
                }

                try
                {
                    DataProvider.PermissionsDao.UpdatePublishmentPermissions(mainPermission, systemPermissionlist);
                }
                catch
                {
                    FailMessage("角色修改失败!");
                }
            }
        }
Ejemplo n.º 28
0
        public static async Task <string> ParseDynamicContentAsync(IParseManager parseManager, DynamicInfo dynamicInfo, string template)
        {
            var databaseManager = parseManager.DatabaseManager;

            if (string.IsNullOrEmpty(template))
            {
                return(string.Empty);
            }

            var templateInfo = await databaseManager.TemplateRepository.GetAsync(dynamicInfo.TemplateId);

            var siteInfo = await databaseManager.SiteRepository.GetAsync(dynamicInfo.SiteId);

            await parseManager.InitAsync(siteInfo, dynamicInfo.ChannelId, dynamicInfo.ContentId, templateInfo);

            parseManager.PageInfo.User = dynamicInfo.User;

            var templateContent = StlRequest.ParseRequestEntities(dynamicInfo.QueryString, template);
            var contentBuilder  = new StringBuilder(templateContent);
            var stlElementList  = StlParserUtility.GetStlElementList(contentBuilder.ToString());

            var pageIndex = dynamicInfo.Page - 1;

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

                var pageContentsElementParser = await StlPageContents.GetAsync(stlPageContentsElement, parseManager);

                var(pageCount, totalNum) = pageContentsElementParser.GetPageCount();

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = await pageContentsElementParser.ParseAsync(totalNum, currentPageIndex, pageCount, false);

                        contentBuilder.Replace(stlPageContentsElementReplaceString, pageHtml);

                        await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, dynamicInfo.ElementId);

                        break;
                    }
                }
            }
            //如果标签中存在<stl:pageChannels>
            else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlElementList))
            {
                var stlElement             = StlParserUtility.GetStlElement(StlPageChannels.ElementName, stlElementList);
                var stlPageChannelsElement = stlElement;
                var stlPageChannelsElementReplaceString = stlElement;

                var pageChannelsElementParser = await StlPageChannels.GetAsync(stlPageChannelsElement, parseManager);

                var pageCount = pageChannelsElementParser.GetPageCount(out var totalNum);

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

                    var pageHtml = await pageChannelsElementParser.ParseAsync(currentPageIndex, pageCount);

                    contentBuilder.Replace(stlPageChannelsElementReplaceString, pageHtml);

                    await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, dynamicInfo.ElementId);

                    break;
                }
            }
            //如果标签中存在<stl:pageSqlContents>
            else if (StlParserUtility.IsStlElementExists(StlPageSqlContents.ElementName, stlElementList))
            {
                var stlElement = StlParserUtility.GetStlElement(StlPageSqlContents.ElementName, stlElementList);
                var stlPageSqlContentsElement = stlElement;
                var stlPageSqlContentsElementReplaceString = stlElement;

                var pageSqlContentsElementParser = await StlPageSqlContents.GetAsync(stlPageSqlContentsElement, parseManager);

                var pageCount = pageSqlContentsElementParser.GetPageCount(out var totalNum);

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

                    var pageHtml = await pageSqlContentsElementParser.ParseAsync(totalNum, currentPageIndex, pageCount, false);

                    contentBuilder.Replace(stlPageSqlContentsElementReplaceString, pageHtml);

                    await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, dynamicInfo.ElementId);

                    break;
                }
            }

            else if (StlParserUtility.IsStlElementExists(StlPageItems.ElementName, stlElementList))
            {
                var pageCount             = TranslateUtils.ToInt(dynamicInfo.QueryString["pageCount"]);
                var totalNum              = TranslateUtils.ToInt(dynamicInfo.QueryString["totalNum"]);
                var pageContentsAjaxDivId = dynamicInfo.QueryString["pageContentsAjaxDivId"];

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

                    await parseManager.ReplacePageElementsInDynamicPageAsync(contentBuilder, stlElementList, currentPageIndex, pageCount, totalNum, false, pageContentsAjaxDivId);

                    break;
                }
            }

            await parseManager.ParseInnerContentAsync(contentBuilder);

            //var parsedContent = StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo);
            //return pageInfo.HeadCodesHtml + pageInfo.BodyCodesHtml + parsedContent + pageInfo.FootCodesHtml;
            return(contentBuilder.ToString());
        }
Ejemplo n.º 29
0
        internal static string Parse(PageInfo pageInfo, ContextInfo contextInfo)
        {
            if (string.IsNullOrEmpty(contextInfo.InnerHtml))
            {
                return(string.Empty);
            }

            var innerBuilder = new StringBuilder(contextInfo.InnerHtml);

            StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
            var scrollHtml = innerBuilder.ToString();

            var scrollDelay = 40;
            var direction   = DirectionVertical;
            var width       = "width:100%;";
            var height      = string.Empty;

            foreach (var name in contextInfo.Attributes.AllKeys)
            {
                var value = contextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, ScrollDelay))
                {
                    scrollDelay = TranslateUtils.ToInt(value, 40);
                }
                else if (StringUtils.EqualsIgnoreCase(name, Direction))
                {
                    if (value.ToLower().Equals(DirectionHorizontal.ToLower()))
                    {
                        direction = DirectionHorizontal;
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, Width))
                {
                    value = value.Trim();
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (char.IsDigit(value[value.Length - 1]))
                        {
                            width = "width:" + value + "px;";
                        }
                        else
                        {
                            width = "width:" + value + ";";
                        }
                    }
                }
                else if (StringUtils.EqualsIgnoreCase(name, Height))
                {
                    value = value.Trim();
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (char.IsDigit(value[value.Length - 1]))
                        {
                            height = "height:" + value + "px;";
                        }
                        else
                        {
                            height = "height:" + value + ";";
                        }
                    }
                }
            }

            return(ParseImpl(pageInfo, scrollHtml, scrollDelay, direction, width, height));
        }
Ejemplo n.º 30
0
Archivo: StlValue.cs Proyecto: z-kf/cms
        public static async Task <object> ParseAsync(IParseManager parseManager)
        {
            var type         = string.Empty;
            var formatString = string.Empty;
            var startIndex   = 0;
            var length       = 0;
            var wordNum      = 0;
            var ellipsis     = Constants.Ellipsis;
            var replace      = string.Empty;
            var to           = string.Empty;
            var isClearTags  = false;
            var isReturnToBr = false;
            var isLower      = false;
            var isUpper      = false;

            foreach (var name in parseManager.ContextInfo.Attributes.AllKeys)
            {
                var value = parseManager.ContextInfo.Attributes[name];

                if (StringUtils.EqualsIgnoreCase(name, Type))
                {
                    type = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, FormatString))
                {
                    formatString = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, StartIndex))
                {
                    startIndex = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, Length))
                {
                    length = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, WordNum))
                {
                    wordNum = TranslateUtils.ToInt(value);
                }
                else if (StringUtils.EqualsIgnoreCase(name, Ellipsis))
                {
                    ellipsis = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, Replace))
                {
                    replace = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, To))
                {
                    to = value;
                }
                else if (StringUtils.EqualsIgnoreCase(name, IsClearTags))
                {
                    isClearTags = TranslateUtils.ToBool(value, false);
                }
                else if (StringUtils.EqualsIgnoreCase(name, IsReturnToBr))
                {
                    isReturnToBr = TranslateUtils.ToBool(value, false);
                }
                else if (StringUtils.EqualsIgnoreCase(name, IsLower))
                {
                    isLower = TranslateUtils.ToBool(value, true);
                }
                else if (StringUtils.EqualsIgnoreCase(name, IsUpper))
                {
                    isUpper = TranslateUtils.ToBool(value, true);
                }
            }

            return(await ParseImplAsync(parseManager, type, formatString, startIndex, length, wordNum, ellipsis, replace, to, isClearTags, isReturnToBr, isLower, isUpper));
        }