Example #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _styleId    = Body.GetQueryInt("StyleID");
            _tableStyle = ETableStyleUtils.GetEnumType(Body.GetQueryString("TableStyle"));
            var relatedIdentity = Body.GetQueryInt("RelatedIdentity");
            var tagStyleInfo    = DataProvider.TagStyleDao.GetTagStyleInfo(_styleId);

            if (_tableStyle == ETableStyle.GovInteractContent)
            {
                _mailSmsInfo = new TagStyleGovInteractApplyInfo(tagStyleInfo.SettingsXML);
            }

            if (!IsPostBack)
            {
                ltlTips2.Text =
                    $"[{ContentAttribute.AddDate}]代表提交时间,[{GovInteractContentAttribute.QueryCode}]代表查询码,";

                var styleInfoList = RelatedIdentities.GetTableStyleInfoList(PublishmentSystemInfo, _tableStyle, relatedIdentity);
                foreach (var styleInfo in styleInfoList)
                {
                    if (styleInfo.IsVisible)
                    {
                        ltlTips2.Text += $@"[{styleInfo.AttributeName}]代表{styleInfo.DisplayName},";
                    }
                }

                ltlTips2.Text = ltlTips2.Text.TrimEnd(',');

                //短信

                ControlUtils.SelectListItemsIgnoreCase(rblIsSMS, _mailSmsInfo.IsSMS.ToString());
                rblIsSMS_SelectedIndexChanged(null, EventArgs.Empty);

                ControlUtils.SelectListItemsIgnoreCase(rblSMSReceiver, ETriStateUtils.GetValue(_mailSmsInfo.SMSReceiver));
                rblSMSReceiver_SelectedIndexChanged(null, EventArgs.Empty);

                tbSMSTo.Text = _mailSmsInfo.SMSTo;

                foreach (var styleInfo in styleInfoList)
                {
                    if (styleInfo.IsVisible)
                    {
                        var listItem = new ListItem(styleInfo.DisplayName + "(" + styleInfo.AttributeName + ")", styleInfo.AttributeName);
                        if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, _mailSmsInfo.SMSFiledName))
                        {
                            listItem.Selected = true;
                        }
                        ddlSMSFiledName.Items.Add(listItem);
                    }
                }

                ControlUtils.SelectListItemsIgnoreCase(rblIsSMSTemplate, _mailSmsInfo.IsSMSTemplate.ToString());
                rblIsSMSTemplate_SelectedIndexChanged(null, EventArgs.Empty);

                tbSMSContent.Text = _mailSmsInfo.SMSContent;

                if (string.IsNullOrEmpty(tbSMSContent.Text))
                {
                    tbSMSContent.Text = MessageManager.GetSmsContent(styleInfoList);
                }
            }
        }
Example #2
0
        public string GetFileInputTemplate()
        {
            var content = FileUtils.ReadText(SiteFilesAssets.GetPath("govinteractapply/inputTemplate.html"), ECharset.utf_8);

            var regex        = "<!--parameters:(?<params>[^\"]*)-->";
            var paramstring  = RegexUtils.GetContent("params", regex, content);
            var parameters   = TranslateUtils.ToNameValueCollection(paramstring);
            var tdNameClass  = parameters["tdNameClass"];
            var tdInputClass = parameters["tdInputClass"];

            if (parameters.Count > 0)
            {
                content = content.Replace($"<!--parameters:{paramstring}-->\r\n", string.Empty);
            }

            content = $@"<link href=""{SiteFilesAssets.GovInteractApply.GetStyleUrl(_publishmentSystemInfo.Additional.ApiUrl)}"" type=""text/css"" rel=""stylesheet"" />
" + content;

            var builder       = new StringBuilder();
            var styleInfoList = RelatedIdentities.GetTableStyleInfoList(_publishmentSystemInfo, ETableStyle.GovInteractContent, _nodeId);

            var pageScripts = new NameValueCollection();

            var isPreviousSingleLine = true;
            var isPreviousLeftColumn = false;

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.IsVisible)
                {
                    var value = InputTypeParser.Parse(_publishmentSystemInfo, _nodeId, styleInfo, ETableStyle.GovInteractContent, styleInfo.AttributeName, null, false, false, null, pageScripts, styleInfo.Additional.IsValidate);

                    if (builder.Length > 0)
                    {
                        if (isPreviousSingleLine)
                        {
                            builder.Append("</tr>");
                        }
                        else
                        {
                            if (!isPreviousLeftColumn)
                            {
                                builder.Append("</tr>");
                            }
                            else if (styleInfo.IsSingleLine)
                            {
                                builder.Append(
                                    $@"<td class=""{tdNameClass}""></td><td class=""{tdInputClass}""></td></tr>");
                            }
                        }
                    }

                    //this line

                    if (styleInfo.IsSingleLine || isPreviousSingleLine || !isPreviousLeftColumn)
                    {
                        builder.Append("<tr>");
                    }

                    builder.Append(
                        $@"<td class=""{tdNameClass}"">{styleInfo.DisplayName}</td><td {(styleInfo.IsSingleLine
                            ? @"colspan=""3"""
                            : string.Empty)} class=""{tdInputClass}"">{value}</td>");


                    if (styleInfo.IsSingleLine)
                    {
                        isPreviousSingleLine = true;
                        isPreviousLeftColumn = false;
                    }
                    else
                    {
                        isPreviousSingleLine = false;
                        isPreviousLeftColumn = !isPreviousLeftColumn;
                    }
                }
            }

            if (builder.Length > 0)
            {
                if (isPreviousSingleLine || !isPreviousLeftColumn)
                {
                    builder.Append("</tr>");
                }
                else
                {
                    builder.Append($@"<td class=""{tdNameClass}""></td><td class=""{tdInputClass}""></td></tr>");
                }
            }

            if (content.Contains("<!--提交表单循环-->"))
            {
                content = content.Replace("<!--提交表单循环-->", builder.ToString());
            }

            return(content.Replace("[nodeID]", _nodeId.ToString()));
        }
Example #3
0
        public string GetWhereStringBySearchOutput(PublishmentSystemInfo publishmentSystemInfo, int nodeId, ETableStyle tableStyle, string word, StringCollection typeCollection, string channelId, string dateFrom, string dateTo, string date, string dateAttribute, string excludeAttributes, NameValueCollection form)
        {
            var whereBuilder = new StringBuilder();

            if (typeCollection.Count == 0)
            {
                typeCollection.Add(ContentAttribute.Title);
                if (tableStyle == ETableStyle.BackgroundContent)
                {
                    typeCollection.Add(BackgroundContentAttribute.Content);
                }
                else if (tableStyle == ETableStyle.JobContent)
                {
                    typeCollection.Add(JobContentAttribute.Location);
                    typeCollection.Add(JobContentAttribute.Department);
                    typeCollection.Add(JobContentAttribute.Requirement);
                    typeCollection.Add(JobContentAttribute.Responsibility);
                }
            }

            whereBuilder.Append($"(PublishmentSystemID = {publishmentSystemInfo.PublishmentSystemId}) ");
            if (!string.IsNullOrEmpty(word))
            {
                whereBuilder.Append(" AND (");
                foreach (var attributeName in typeCollection)
                {
                    whereBuilder.Append($"[{attributeName}] like '%{PageUtils.FilterSql(word)}%' OR ");
                }
                whereBuilder.Length = whereBuilder.Length - 3;
                whereBuilder.Append(")");
            }
            if (!string.IsNullOrEmpty(channelId))
            {
                var theChannelId = TranslateUtils.ToInt(channelId);
                if (theChannelId > 0 && theChannelId != publishmentSystemInfo.PublishmentSystemId)
                {
                    whereBuilder.Append(" AND ");
                    var nodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(theChannelId);
                    nodeIdList.Add(theChannelId);
                    whereBuilder.Append(nodeIdList.Count == 1
                        ? $"(NodeID = {nodeIdList[0]}) "
                        : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) ");
                }
            }
            if (!string.IsNullOrEmpty(dateFrom))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} >= '{dateFrom}' ");
            }
            if (!string.IsNullOrEmpty(dateTo))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} <= '{dateTo}' ");
            }
            if (!string.IsNullOrEmpty(date))
            {
                var days = TranslateUtils.ToInt(date);
                if (days > 0)
                {
                    whereBuilder.Append(" AND ");
                    whereBuilder.Append(SqlUtils.GetDateDiffLessThanDays(dateAttribute, days.ToString()));
                }
            }

            var styleInfoList = RelatedIdentities.GetTableStyleInfoList(publishmentSystemInfo, tableStyle, nodeId);
            var tableName     = RelatedIdentities.GetTableName(publishmentSystemInfo, tableStyle, nodeId);

            var arraylist = TranslateUtils.StringCollectionToStringList(excludeAttributes);

            foreach (string key in form.Keys)
            {
                if (arraylist.Contains(key.ToLower()))
                {
                    continue;
                }
                if (!string.IsNullOrEmpty(form[key]))
                {
                    var value = StringUtils.Trim(form[key]);
                    if (!string.IsNullOrEmpty(value))
                    {
                        if (TableManager.IsAttributeNameExists(tableStyle, tableName, key))
                        {
                            whereBuilder.Append(" AND ");
                            whereBuilder.Append($"([{key}] LIKE '%{value}%')");
                        }
                        else
                        {
                            foreach (var tableStyleInfo in styleInfoList)
                            {
                                if (StringUtils.EqualsIgnoreCase(tableStyleInfo.AttributeName, key))
                                {
                                    whereBuilder.Append(" AND ");
                                    whereBuilder.Append($"({ContentAttribute.SettingsXml} LIKE '%{key}={value}%')");
                                    break;
                                }
                            }
                        }

                        if (tableStyle == ETableStyle.GovPublicContent)
                        {
                            if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.DepartmentId))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                            else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category1Id))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                            else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category2Id))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                            else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category3Id))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                            else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category4Id))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                            else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category5Id))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                            else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category6Id))
                            {
                                whereBuilder.Append(" AND ");
                                whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                            }
                        }
                    }
                }
            }
            return(whereBuilder.ToString());
        }
Example #4
0
        public string GetWhereStringByStlSearch(bool isAllSites, string siteName, string siteDir, string siteIds, string channelIndex, string channelName, string channelIds, string type, string word, string dateAttribute, string dateFrom, string dateTo, string since, int publishmentSystemId, List <string> excludeAttributes, NameValueCollection form, out bool isDefaultCondition)
        {
            isDefaultCondition = true;
            var whereBuilder = new StringBuilder();

            PublishmentSystemInfo publishmentSystemInfo = null;

            if (!string.IsNullOrEmpty(siteName))
            {
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoBySiteName(siteName);
            }
            else if (!string.IsNullOrEmpty(siteDir))
            {
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfoByDirectory(siteDir);
            }
            if (publishmentSystemInfo == null)
            {
                publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            }

            var channelId = StlCacheManager.NodeId.GetNodeIdByChannelIdOrChannelIndexOrChannelName(publishmentSystemId, publishmentSystemId, channelIndex, channelName);
            var nodeInfo  = NodeManager.GetNodeInfo(publishmentSystemId, channelId);

            if (isAllSites)
            {
                whereBuilder.Append("(PublishmentSystemID > 0) ");
            }
            else if (!string.IsNullOrEmpty(siteIds))
            {
                whereBuilder.Append($"(PublishmentSystemID IN ({TranslateUtils.ToSqlInStringWithoutQuote(TranslateUtils.StringCollectionToIntList(siteIds))})) ");
            }
            else
            {
                whereBuilder.Append($"(PublishmentSystemID = {publishmentSystemInfo.PublishmentSystemId}) ");
            }

            if (!string.IsNullOrEmpty(channelIds))
            {
                whereBuilder.Append(" AND ");
                var nodeIdList = new List <int>();
                foreach (var nodeId in TranslateUtils.StringCollectionToIntList(channelIds))
                {
                    nodeIdList.Add(nodeId);
                    nodeIdList.AddRange(DataProvider.NodeDao.GetNodeIdListForDescendant(nodeId));
                }
                whereBuilder.Append(nodeIdList.Count == 1
                    ? $"(NodeID = {nodeIdList[0]}) "
                    : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) ");
            }
            else if (channelId != publishmentSystemId)
            {
                whereBuilder.Append(" AND ");
                var nodeIdList = DataProvider.NodeDao.GetNodeIdListForDescendant(channelId);
                nodeIdList.Add(channelId);
                whereBuilder.Append(nodeIdList.Count == 1
                    ? $"(NodeID = {nodeIdList[0]}) "
                    : $"(NodeID IN ({TranslateUtils.ToSqlInStringWithoutQuote(nodeIdList)})) ");
            }

            var typeList = new List <string>();

            if (string.IsNullOrEmpty(type))
            {
                typeList.Add(ContentAttribute.Title);
            }
            else
            {
                typeList = TranslateUtils.StringCollectionToStringList(type);
            }

            if (!string.IsNullOrEmpty(word))
            {
                whereBuilder.Append(" AND (");
                foreach (var attributeName in typeList)
                {
                    whereBuilder.Append($"[{attributeName}] LIKE '%{PageUtils.FilterSql(word)}%' OR ");
                }
                whereBuilder.Length = whereBuilder.Length - 3;
                whereBuilder.Append(")");
            }

            if (string.IsNullOrEmpty(dateAttribute))
            {
                dateAttribute = ContentAttribute.AddDate;
            }

            if (!string.IsNullOrEmpty(dateFrom))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} >= '{dateFrom}' ");
            }
            if (!string.IsNullOrEmpty(dateTo))
            {
                whereBuilder.Append(" AND ");
                whereBuilder.Append($" {dateAttribute} <= '{dateTo}' ");
            }
            if (!string.IsNullOrEmpty(since))
            {
                var sinceDate = DateTime.Now.AddHours(-DateUtils.GetSinceHours(since));
                whereBuilder.Append($" AND {dateAttribute} BETWEEN '{DateUtils.GetDateAndTimeString(sinceDate)}' AND {SqlUtils.GetDefaultDateString()} ");
            }

            var tableStyle    = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
            var tableName     = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
            var styleInfoList = RelatedIdentities.GetTableStyleInfoList(publishmentSystemInfo, tableStyle, nodeInfo.NodeId);

            foreach (string key in form.Keys)
            {
                if (excludeAttributes.Contains(key.ToLower()))
                {
                    continue;
                }
                if (string.IsNullOrEmpty(form[key]))
                {
                    continue;
                }

                var value = StringUtils.Trim(form[key]);
                if (string.IsNullOrEmpty(value))
                {
                    continue;
                }

                if (TableManager.IsAttributeNameExists(tableStyle, tableName, key))
                {
                    whereBuilder.Append(" AND ");
                    whereBuilder.Append($"({key} LIKE '%{value}%')");
                }
                else
                {
                    foreach (var tableStyleInfo in styleInfoList)
                    {
                        if (StringUtils.EqualsIgnoreCase(tableStyleInfo.AttributeName, key))
                        {
                            whereBuilder.Append(" AND ");
                            whereBuilder.Append($"({ContentAttribute.SettingsXml} LIKE '%{key}={value}%')");
                            break;
                        }
                    }
                }

                if (tableStyle == ETableStyle.GovPublicContent)
                {
                    if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.DepartmentId))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category1Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category2Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category3Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category4Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category5Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                    else if (StringUtils.EqualsIgnoreCase(key, GovPublicContentAttribute.Category6Id))
                    {
                        whereBuilder.Append(" AND ");
                        whereBuilder.Append($"([{key}] = {TranslateUtils.ToInt(value)})");
                    }
                }
            }

            if (whereBuilder.ToString().Contains(" AND "))
            {
                isDefaultCondition = false;
            }

            return(whereBuilder.ToString());
        }