Esempio n. 1
0
        private static string GetAttributesHtml(NameValueCollection pageScripts, PublishmentSystemInfo publishmentSystemInfo, List <TableStyleInfo> styleInfoList)
        {
            if (styleInfoList == null)
            {
                return(string.Empty);
            }

            var output = new StringBuilder();

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.IsVisible == false)
                {
                    continue;
                }

                var helpHtml  = styleInfo.DisplayName + ":";
                var inputHtml = InputTypeParser.Parse(publishmentSystemInfo, styleInfo, styleInfo.AttributeName, pageScripts);
                output.Append($@"
<div>
    {helpHtml}
    {inputHtml}
</div>
");
            }

            return(output.ToString());
        }
Esempio n. 2
0
        protected string GetAttributesHtml(NameValueCollection pageScripts, PublishmentSystemInfo publishmentSystemInfo, List <TableStyleInfo> styleInfoList)
        {
            if (styleInfoList == null)
            {
                return(string.Empty);
            }

            var output = new StringBuilder();

            foreach (var styleInfo in styleInfoList)
            {
                if (styleInfo.IsVisible == false)
                {
                    continue;
                }

                var helpHtml       = styleInfo.DisplayName + ":";
                var formCollection = new NameValueCollection
                {
                    [styleInfo.AttributeName] = string.Empty
                };
                var inputHtml = InputTypeParser.Parse(publishmentSystemInfo, 0, styleInfo, ETableStyle.InputContent, styleInfo.AttributeName, formCollection, false, false, GetInnerAdditionalAttributes(styleInfo), pageScripts, true);
                output.Append($@"
<tr>
    <td style=""padding: 5px; width: 80px;"">{helpHtml}</td>
    <td style=""padding: 5px;"">{inputHtml}</td>
</tr>
");
            }

            return(output.ToString());
        }
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

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

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

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

                var contentInfo = ContentUtility.GetContentInfo(tableStyle);

                var postCollection = body.GetPostCollection();

                InputTypeParser.AddValuesToAttributes(tableStyle, tableName, publishmentSystemInfo, relatedIdentities, postCollection, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                contentInfo.IsChecked           = false;
                contentInfo.PublishmentSystemId = publishmentSystemId;
                contentInfo.NodeId           = nodeId;
                contentInfo.AddUserName      = adminUserName;
                contentInfo.WritingUserName  = user.UserName;
                contentInfo.LastEditUserName = adminUserName;
                contentInfo.AddDate          = DateTime.Now;
                contentInfo.LastEditDate     = DateTime.Now;

                var contentId = DataProvider.ContentDao.Insert(tableName, publishmentSystemInfo, contentInfo);

                LogUtils.AddUserLog(body.UserName, EUserActionType.WritingAdd, contentInfo.Title);

                return(Ok(new
                {
                    ID = contentId
                }));
            }
            catch (Exception ex)
            {
                //return InternalServerError(ex);
                return(InternalServerError(new Exception("程序错误")));
            }
        }
Esempio n. 4
0
        public GovInteractContentInfo GetContentInfo(PublishmentSystemInfo publishmentSystemInfo, int nodeId, NameValueCollection form)
        {
            var queryCode      = GovInteractApplyManager.GetQueryCode();
            var departmentId   = TranslateUtils.ToInt(form[GovInteractContentAttribute.DepartmentId]);
            var departmentName = string.Empty;

            if (departmentId > 0)
            {
                departmentName = DepartmentManager.GetDepartmentName(departmentId);
            }

            var ipAddress = PageUtils.GetIpAddress();

            var contentInfo = new GovInteractContentInfo();

            contentInfo.PublishmentSystemId = publishmentSystemInfo.PublishmentSystemId;
            contentInfo.NodeId         = nodeId;
            contentInfo.DepartmentName = departmentName;
            contentInfo.QueryCode      = queryCode;
            contentInfo.State          = EGovInteractState.New;
            contentInfo.AddUserName    = string.Empty;
            contentInfo.IpAddress      = ipAddress;
            contentInfo.AddDate        = DateTime.Now;

            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemInfo.PublishmentSystemId, nodeId);

            InputTypeParser.AddValuesToAttributes(ETableStyle.GovInteractContent, publishmentSystemInfo.AuxiliaryTableForGovInteract, publishmentSystemInfo, relatedIdentities, form, contentInfo.Attributes);

            //foreach (string name in form.AllKeys)
            //{
            //    if (!GovInteractContentAttribute.HiddenAttributes.Contains(name.ToLower()))
            //    {
            //        string value = form[name];
            //        if (!string.IsNullOrEmpty(value))
            //        {
            //            applyInfo.SetExtendedAttribute(name, value);
            //        }
            //    }
            //}

            return(contentInfo);
        }
Esempio n. 5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                PublishmentSystemInfo.PublishmentSystemName = TbPublishmentSystemName.Text;

                try
                {
                    InputTypeParser.AddValuesToAttributes(ETableStyle.Site, DataProvider.PublishmentSystemDao.TableName, PublishmentSystemInfo, _relatedIdentities, Page.Request.Form, PublishmentSystemInfo.Additional.Attributes);

                    DataProvider.PublishmentSystemDao.Update(PublishmentSystemInfo);

                    Body.AddSiteLog(PublishmentSystemId, "修改站点设置");

                    SuccessMessage("站点设置修改成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "站点设置修改失败!");
                }
            }
        }
Esempio n. 6
0
        private int SaveContentInfo(bool isAjaxSubmit, bool isPreview, out string errorMessage)
        {
            int savedContentId;

            errorMessage = string.Empty;
            var contentId = 0;

            if (!isPreview)
            {
                contentId = isAjaxSubmit ? TranslateUtils.ToInt(Request.Form["savedContentID"]) : Body.GetQueryInt("ID");
            }

            if (contentId == 0)
            {
                var contentInfo = ContentUtility.GetContentInfo(_tableStyle);
                try
                {
                    int nodeId = 0;
                    //contentInfo.NodeId = _nodeInfo.NodeId;
                    if (PhCategory.Visible == true)
                    {
                        nodeId = Convert.ToInt32(TbCategory.SelectedValue);
                    }
                    else
                    {
                        nodeId = _nodeInfo.NodeId;
                    }
                    contentInfo.NodeId = nodeId;
                    contentInfo.PublishmentSystemId = PublishmentSystemId;
                    contentInfo.AddUserName         = Body.AdministratorName;
                    if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year)
                    {
                        errorMessage = $"内容添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年";
                        return(0);
                    }
                    contentInfo.LastEditUserName = contentInfo.AddUserName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    //自动保存的时候,不保存编辑器的图片
                    var dic = new Dictionary <string, string>();
                    if (Body.GetQueryInt("ArticleId") > 0)
                    {
                        dic.Add("ExaminationPaperId", Body.GetQueryString("ArticleId"));
                    }
                    InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, !_isAjaxSubmit, dic);

                    StringCollection tagCollection;

                    if (isAjaxSubmit)
                    {
                        contentInfo.ContentGroupNameCollection = Request.Form[ContentAttribute.ContentGroupNameCollection];
                        tagCollection = TagUtils.ParseTagsString(Request.Form[ContentAttribute.Tags]);

                        contentInfo.CheckedLevel = LevelManager.LevelInt.CaoGao;
                        contentInfo.IsChecked    = false;
                    }
                    else
                    {
                        contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items);
                        tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                        if (PhContentAttributes.Visible)
                        {
                            foreach (ListItem listItem in CblContentAttributes.Items)
                            {
                                var value         = listItem.Selected.ToString();
                                var attributeName = listItem.Value;
                                contentInfo.SetExtendedAttribute(attributeName, value);
                            }
                        }

                        contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue);
                        contentInfo.IsChecked    = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel;
                    }
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    if (isPreview)
                    {
                        savedContentId = DataProvider.ContentDao.InsertPreview(_tableName, PublishmentSystemInfo, _nodeInfo, contentInfo);
                    }
                    else
                    {
                        savedContentId = DataProvider.ContentDao.Insert(_tableName, PublishmentSystemInfo, contentInfo);
                        //判断是不是有审核权限
                        int checkedLevelOfUser;
                        var isCheckedOfUser = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, contentInfo.NodeId, out checkedLevelOfUser);
                        if (LevelManager.IsCheckable(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.IsChecked, contentInfo.CheckedLevel, isCheckedOfUser, checkedLevelOfUser))
                        {
                            //添加审核记录
                            BaiRongDataProvider.ContentDao.UpdateIsChecked(_tableName, PublishmentSystemId, contentInfo.NodeId, new List <int> {
                                savedContentId
                            }, 0, true, Body.AdministratorName, contentInfo.IsChecked, contentInfo.CheckedLevel, "");
                        }

                        if (PhTags.Visible)
                        {
                            TagUtils.AddTags(tagCollection, PublishmentSystemId, savedContentId);
                        }
                    }

                    contentInfo.Id = savedContentId;
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    errorMessage = $"内容添加失败:{ex.Message}";
                    return(0);
                }

                if (!isAjaxSubmit)
                {
                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id);
                    }

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

                    ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), Body.AdministratorName);
                    string contentType = WebUtils.GetContentType(_nodeInfo.ContentModelId);
                    if (contentType.Equals("PageExamination"))
                    {
                        PageUtils.Redirect($@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID={Body.GetQueryString("PublishmentSystemID")}&NodeID={(string.IsNullOrEmpty(Body.GetQueryString("PNodeID")) ? Body.GetQueryString("NodeId") : Body.GetQueryString("PNodeID"))}&ArticleId={Body.GetQueryString("ArticleId")}");
                    }
                    PageUtils.Redirect(EContentModelTypeUtils.Equals(_nodeInfo.ContentModelId, EContentModelType.Photo)
                        ? PageContentPhotoUpload.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id,
                                                                Body.GetQueryString("ReturnUrl"))
                        : PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id,
                                                             ReturnUrl));
                }
            }
            else
            {
                var contentInfo = DataProvider.ContentDao.GetContentInfo(_tableStyle, _tableName, contentId);
                try
                {
                    var tagsLast = contentInfo.Tags;

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

                    //自动保存的时候,不保存编辑器的图片
                    InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes, !_isAjaxSubmit);

                    StringCollection tagCollection;
                    if (isAjaxSubmit)
                    {
                        contentInfo.ContentGroupNameCollection = Request.Form[ContentAttribute.ContentGroupNameCollection];
                        tagCollection = TagUtils.ParseTagsString(Request.Form[ContentAttribute.Tags]);
                    }
                    else
                    {
                        contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(CblContentGroupNameCollection.Items);
                        tagCollection = TagUtils.ParseTagsString(TbTags.Text);

                        if (PhContentAttributes.Visible)
                        {
                            foreach (ListItem listItem in CblContentAttributes.Items)
                            {
                                var value         = listItem.Selected.ToString();
                                var attributeName = listItem.Value;
                                contentInfo.SetExtendedAttribute(attributeName, value);
                            }
                        }

                        var checkedLevel = TranslateUtils.ToIntWithNagetive(RblContentLevel.SelectedValue);
                        if (checkedLevel != LevelManager.LevelInt.NotChange)
                        {
                            contentInfo.IsChecked    = checkedLevel >= PublishmentSystemInfo.CheckContentLevel;
                            contentInfo.CheckedLevel = checkedLevel;
                        }
                    }
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

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

                    if (PhTags.Visible)
                    {
                        TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, PublishmentSystemId, contentId);
                    }

                    if (!isAjaxSubmit)
                    {
                        ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(DdlTranslateType.SelectedValue), Body.AdministratorName);

                        if (EContentModelTypeUtils.Equals(_nodeInfo.ContentModelId, EContentModelType.Photo))
                        {
                            PageUtils.Redirect(PageContentPhotoUpload.GetRedirectUrl(PublishmentSystemId, _nodeInfo.NodeId, contentInfo.Id, Body.GetQueryString("ReturnUrl")));
                        }

                        //更新引用该内容的信息
                        //如果不是异步自动保存,那么需要将引用此内容的content修改
                        var sourceContentIdList = new List <int>
                        {
                            contentInfo.Id
                        };
                        var tableList = BaiRongDataProvider.TableCollectionDao.GetAuxiliaryTableListCreatedInDbByAuxiliaryTableType(EAuxiliaryTableType.BackgroundContent, EAuxiliaryTableType.JobContent, EAuxiliaryTableType.VoteContent);
                        foreach (var table in tableList)
                        {
                            var targetContentIdList = BaiRongDataProvider.ContentDao.GetReferenceIdList(table.TableEnName, sourceContentIdList);
                            foreach (int targetContentId in targetContentIdList)
                            {
                                var targetContentInfo = DataProvider.ContentDao.GetContentInfo(ETableStyleUtils.GetEnumType(table.AuxiliaryTableType.ToString()), table.TableEnName, targetContentId);
                                if (targetContentInfo != null && targetContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType) == ETranslateContentType.ReferenceContent.ToString())
                                {
                                    contentInfo.Id = targetContentId;
                                    contentInfo.PublishmentSystemId = targetContentInfo.PublishmentSystemId;
                                    contentInfo.NodeId      = targetContentInfo.NodeId;
                                    contentInfo.SourceId    = targetContentInfo.SourceId;
                                    contentInfo.ReferenceId = targetContentInfo.ReferenceId;
                                    contentInfo.Taxis       = targetContentInfo.Taxis;
                                    contentInfo.SetExtendedAttribute(ContentAttribute.TranslateContentType, targetContentInfo.GetExtendedAttribute(ContentAttribute.TranslateContentType));
                                    BaiRongDataProvider.ContentDao.Update(table.TableEnName, contentInfo);

                                    //资源:图片,文件,视频
                                    var targetPublishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(targetContentInfo.PublishmentSystemId);
                                    var bgContentInfo       = contentInfo as BackgroundContentInfo;
                                    var bgTargetContentInfo = targetContentInfo as BackgroundContentInfo;
                                    if (bgTargetContentInfo != null && bgContentInfo != null)
                                    {
                                        if (bgContentInfo.ImageUrl != bgTargetContentInfo.ImageUrl)
                                        {
                                            //修改图片
                                            var sourceImageUrl = PathUtility.MapPath(PublishmentSystemInfo, bgContentInfo.ImageUrl);
                                            CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl);
                                        }
                                        else if (bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)) != bgTargetContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)))
                                        {
                                            var sourceImageUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl)));

                                            foreach (string imageUrl in sourceImageUrls)
                                            {
                                                var sourceImageUrl = PathUtility.MapPath(PublishmentSystemInfo, imageUrl);
                                                CopyReferenceFiles(targetPublishmentSystemInfo, sourceImageUrl);
                                            }
                                        }
                                        if (bgContentInfo.FileUrl != bgTargetContentInfo.FileUrl)
                                        {
                                            //修改附件
                                            var sourceFileUrl = PathUtility.MapPath(PublishmentSystemInfo, bgContentInfo.FileUrl);
                                            CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl);
                                        }
                                        else if (bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)) != bgTargetContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)))
                                        {
                                            var sourceFileUrls = TranslateUtils.StringCollectionToStringList(bgContentInfo.GetExtendedAttribute(ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl)));

                                            foreach (string fileUrl in sourceFileUrls)
                                            {
                                                var sourceFileUrl = PathUtility.MapPath(PublishmentSystemInfo, fileUrl);
                                                CopyReferenceFiles(targetPublishmentSystemInfo, sourceFileUrl);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogUtils.AddErrorLog(ex);
                    errorMessage = $"内容修改失败:{ex.Message}";
                    return(0);
                }

                if (!isAjaxSubmit)
                {
                    if (contentInfo.IsChecked)
                    {
                        CreateManager.CreateContentAndTrigger(PublishmentSystemId, _nodeInfo.NodeId, contentId);
                    }

                    Body.AddSiteLog(PublishmentSystemId, _nodeInfo.NodeId, contentId, "修改内容",
                                    $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}");
                    string contentType = WebUtils.GetContentType(_nodeInfo.ContentModelId);
                    PageUtils.Redirect($@"/siteserver/cms/{contentType}.aspx?PublishmentSystemID={Body.GetQueryString("PublishmentSystemID")}&NodeID={(string.IsNullOrEmpty( Body.GetQueryString("PNodeID"))? Body.GetQueryString("NodeId"): Body.GetQueryString("PNodeID"))}");
                    //PageUtils.Redirect(ReturnUrl);
                }
                savedContentId = contentId;
            }

            return(savedContentId);
        }
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

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

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

                var contentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, id);

                var postCollection = body.GetPostCollection();
                var extendImageUrl = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                if (postCollection.AllKeys.Contains(StringUtils.LowerFirst(extendImageUrl)))
                {
                    postCollection[extendImageUrl] = postCollection[StringUtils.LowerFirst(extendImageUrl)];
                }
                //var postCollection2 = body.GetPostCollection(true);
                //var postCollection = new NameValueCollection();
                //foreach (string key in postCollection1)
                //{
                //    if (!postCollection.AllKeys.Contains(key))
                //    {
                //        postCollection.Add(key, postCollection1[key]);
                //    }
                //}
                //foreach (string key in postCollection2)
                //{
                //    if (!postCollection.AllKeys.Contains(key))
                //    {
                //        postCollection.Add(key, postCollection2[key]);
                //    }
                //}

                InputTypeParser.AddValuesToAttributes(tableStyle, tableName, publishmentSystemInfo, relatedIdentities, postCollection, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                contentInfo.LastEditDate = DateTime.Now;
                contentInfo.IsChecked    = false;

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

                LogUtils.AddUserLog(body.UserName, EUserActionType.WritingEdit, contentInfo.Title);

                return(Ok(new { }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Esempio n. 8
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()));
        }
Esempio n. 9
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var isChanged = false;

                try
                {
                    var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);

                    if (NodeIndexNameRow.Visible)
                    {
                        if (!nodeInfo.NodeIndexName.Equals(NodeIndexName.Text) && NodeIndexName.Text.Length != 0)
                        {
                            var nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId);
                            if (nodeIndexNameList.IndexOf(NodeIndexName.Text) != -1)
                            {
                                FailMessage("栏目修改失败,栏目索引已存在!");
                                return;
                            }
                        }
                    }

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

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

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

                    if (channelControl.Visible)
                    {
                        var extendedAttributes = new ExtendedAttributes();
                        var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
                        InputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes);
                        if (extendedAttributes.Attributes.Count > 0)
                        {
                            nodeInfo.Additional.SetExtendedAttribute(extendedAttributes.Attributes);
                        }
                    }

                    if (NodeNameRow.Visible)
                    {
                        nodeInfo.NodeName = NodeName.Text;
                    }
                    if (NodeIndexNameRow.Visible)
                    {
                        nodeInfo.NodeIndexName = NodeIndexName.Text;
                    }
                    if (FilePathRow.Visible)
                    {
                        nodeInfo.FilePath = FilePath.Text;
                    }

                    if (NodeGroupNameCollectionRow.Visible)
                    {
                        var list = new ArrayList();
                        foreach (ListItem item in NodeGroupNameCollection.Items)
                        {
                            if (item.Selected)
                            {
                                list.Add(item.Value);
                            }
                        }
                        nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                    }
                    if (ImageUrlRow.Visible)
                    {
                        nodeInfo.ImageUrl = tbImageUrl.Text;
                    }
                    if (ContentRow.Visible)
                    {
                        nodeInfo.Content = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor);
                    }
                    if (Keywords.Visible)
                    {
                        nodeInfo.Keywords = Keywords.Text;
                    }
                    if (Description.Visible)
                    {
                        nodeInfo.Description = Description.Text;
                    }



                    if (LinkUrlRow.Visible)
                    {
                        nodeInfo.LinkUrl = LinkUrl.Text;
                    }
                    if (LinkTypeRow.Visible)
                    {
                        nodeInfo.LinkType = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue);
                    }
                    if (ChannelTemplateIDRow.Visible)
                    {
                        nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0;
                    }
                    if (ContentTemplateIDRow.Visible)
                    {
                        nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0;
                    }

                    DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);

                    Body.AddSiteLog(PublishmentSystemId, _nodeId, 0, "修改栏目", $"栏目:{nodeInfo.NodeName}");

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

                if (isChanged)
                {
                    CreateManager.CreateChannel(PublishmentSystemId, _nodeId);

                    if (string.IsNullOrEmpty(_returnUrl))
                    {
                        PageUtils.CloseModalPage(Page);
                    }
                    else
                    {
                        PageUtils.CloseModalPageAndRedirect(Page, _returnUrl);
                    }
                }
            }
        }
Esempio n. 10
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                NodeInfo nodeInfo;
                try
                {
                    nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, _nodeId);
                    if (!nodeInfo.NodeIndexName.Equals(NodeIndexName.Text) && NodeIndexName.Text.Length != 0)
                    {
                        var nodeIndexNameList = DataProvider.NodeDao.GetNodeIndexNameList(PublishmentSystemId);
                        if (nodeIndexNameList.IndexOf(NodeIndexName.Text) != -1)
                        {
                            FailMessage("栏目属性修改失败,栏目索引已存在!");
                            return;
                        }
                    }

                    if (nodeInfo.ContentModelId != ContentModelID.SelectedValue)
                    {
                        nodeInfo.ContentModelId = ContentModelID.SelectedValue;
                        nodeInfo.ContentNum     = BaiRongDataProvider.ContentDao.GetCount(NodeManager.GetTableName(PublishmentSystemInfo, nodeInfo.ContentModelId), nodeInfo.NodeId);
                    }

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

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

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

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

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

                    var extendedAttributes = new ExtendedAttributes();
                    var relatedIdentities  = RelatedIdentities.GetChannelRelatedIdentities(PublishmentSystemId, _nodeId);
                    InputTypeParser.AddValuesToAttributes(ETableStyle.Channel, DataProvider.NodeDao.TableName, PublishmentSystemInfo, relatedIdentities, Request.Form, extendedAttributes.Attributes);
                    var attributes = extendedAttributes.Attributes;
                    foreach (string key in attributes)
                    {
                        nodeInfo.Additional.SetExtendedAttribute(key, attributes[key]);
                    }

                    nodeInfo.NodeName            = NodeName.Text;
                    nodeInfo.NodeIndexName       = NodeIndexName.Text;
                    nodeInfo.FilePath            = FilePath.Text;
                    nodeInfo.ChannelFilePathRule = ChannelFilePathRule.Text;
                    nodeInfo.ContentFilePathRule = ContentFilePathRule.Text;

                    var list = new ArrayList();
                    foreach (ListItem item in NodeGroupNameCollection.Items)
                    {
                        if (item.Selected)
                        {
                            list.Add(item.Value);
                        }
                    }
                    nodeInfo.NodeGroupNameCollection = TranslateUtils.ObjectCollectionToString(list);
                    nodeInfo.ImageUrl = NavigationPicPath.Text;
                    nodeInfo.Content  = StringUtility.TextEditorContentEncode(Request.Form[NodeAttribute.Content], PublishmentSystemInfo, PublishmentSystemInfo.Additional.IsSaveImageInTextEditor);

                    nodeInfo.Keywords    = Keywords.Text;
                    nodeInfo.Description = Description.Text;

                    nodeInfo.Additional.IsChannelAddable = TranslateUtils.ToBool(IsChannelAddable.SelectedValue);
                    nodeInfo.Additional.IsContentAddable = TranslateUtils.ToBool(IsContentAddable.SelectedValue);

                    nodeInfo.LinkUrl           = LinkUrl.Text;
                    nodeInfo.LinkType          = ELinkTypeUtils.GetEnumType(LinkType.SelectedValue);
                    nodeInfo.ChannelTemplateId = (ChannelTemplateID.Items.Count > 0) ? int.Parse(ChannelTemplateID.SelectedValue) : 0;
                    nodeInfo.ContentTemplateId = (ContentTemplateID.Items.Count > 0) ? int.Parse(ContentTemplateID.SelectedValue) : 0;

                    DataProvider.NodeDao.UpdateNodeInfo(nodeInfo);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, $"栏目修改失败:{ex.Message}");
                    LogUtils.AddErrorLog(ex);
                    return;
                }

                CreateManager.CreateChannel(PublishmentSystemId, nodeInfo.NodeId);

                Body.AddSiteLog(PublishmentSystemId, "修改栏目", $"栏目:{NodeName.Text}");

                SuccessMessage("栏目修改成功!");
                PageUtils.Redirect(_returnUrl);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Loads the given XML file and tries to parse it into XML.
        /// </summary>
        /// <param name="xmlFileName">The location of the XML file to load and parse.</param>
        void loadAndParseXML(string xmlFileName)
        {
            if (File.Exists(xmlFileName))
            {
                TestGeneration = TestGenerations.ValidateXML(xmlFileName);
                XmlDocument doc = new XmlDocument();
                using (FileStream fs = new FileStream(xmlFileName, FileMode.Open, FileAccess.Read))
                {
                    doc.Load(fs);
                    FileInfo fi = new FileInfo(xmlFileName);
                    switch (TestGeneration)
                    {
                    case TestGenerations.XML_FIRST_GENERATION:
                        // Dealing with the first typee, test(s) only
                        XmlNodeList testNodes = doc.SelectNodes("//test");
                        LoadedFileName = fi.Name.Replace(".xml", "");
                        foreach (XmlNode node in testNodes)
                        {
                            XmlNode sampleFile = node.SelectSingleNode("sample");
                            XmlNode command    = node.SelectSingleNode("cmd");
                            XmlNode resultFile = node.SelectSingleNode("result");
                            Entries.Add(
                                new TestEntry(
                                    ConvertFolderDelimiters(sampleFile.InnerText),
                                    command.InnerText,
                                    ConvertFolderDelimiters(resultFile.InnerText)
                                    )
                                );
                        }
                        break;

                    case TestGenerations.XML_SECOND_GENERATION:
                        // Dealing with multi file
                        foreach (XmlNode node in doc.SelectNodes("//testfile"))
                        {
                            String testFileLocation = ConvertFolderDelimiters(node.SelectSingleNode("location").InnerText);
                            testFileLocation = Path.Combine(fi.DirectoryName, testFileLocation);
                            MultiTest.Add(testFileLocation);
                        }
                        break;

                    case TestGenerations.XML_THIRD_GENERATION:
                        // Dealing with the newest version of tests
                        LoadedFileName = fi.Name.Replace(".xml", "");
                        foreach (XmlNode node in doc.SelectNodes("//entry"))
                        {
                            int id = int.Parse(node.Attributes["id"].Value);
                            // Get nodes for entry
                            XmlNode     command   = node.SelectSingleNode("command");
                            XmlNode     input     = node.SelectSingleNode("input");
                            XmlNode     output    = node.SelectSingleNode("output");
                            XmlNodeList compareTo = node.SelectSingleNode("compare").SelectNodes("file");
                            // Convert to appropriate values
                            string             ccx_command  = command.InnerText;
                            string             inputFile    = input.InnerText;
                            InputType          inputType    = InputTypeParser.parseString(input.Attributes["type"].Value);
                            OutputType         outputType   = OutputTypeParser.parseString(output.InnerText);
                            List <CompareFile> compareFiles = new List <CompareFile>();

                            foreach (XmlNode compareEntry in compareTo)
                            {
                                bool    ignore       = bool.Parse(compareEntry.Attributes["ignore"].Value);
                                int     compareId    = int.Parse(compareEntry.Attributes["id"].Value);
                                string  correct      = compareEntry.SelectSingleNode("correct").InnerText;
                                XmlNode expectedNode = compareEntry.SelectSingleNode("expected");
                                string  expected     = (expectedNode != null) ? expectedNode.InnerText : correct;
                                compareFiles.Add(new CompareFile(compareId, correct, expected, ignore));
                            }
                            // Add entry
                            Entries.Add(new TestEntry(id, inputFile, inputType, ccx_command, outputType, compareFiles));
                        }
                        break;

                    default:
                        break;
                    }
                }
                return;
            }
            throw new InvalidDataException("File does not exist");
        }
Esempio n. 12
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            if (_contentId != 0)
            {
                try
                {
                    var contentInfo = DataProvider.InputContentDao.GetContentInfo(_contentId);

                    InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, PublishmentSystemInfo, _relatedIdentities, Page.Request.Form, contentInfo.Attributes);

                    DataProvider.InputContentDao.Update(contentInfo);

                    var builder = new StringBuilder();

                    var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, _relatedIdentities);
                    foreach (var styleInfo in styleInfoList)
                    {
                        if (styleInfo.IsVisible == false)
                        {
                            continue;
                        }

                        var theValue = InputParserUtility.GetContentByTableStyle(contentInfo.GetExtendedAttribute(styleInfo.AttributeName), PublishmentSystemInfo, ETableStyle.InputContent, styleInfo);

                        builder.Append($@"{styleInfo.DisplayName}:{theValue},");
                    }

                    if (builder.Length > 0)
                    {
                        builder.Length = builder.Length - 1;
                    }

                    if (builder.Length > 60)
                    {
                        builder.Length = 60;
                    }

                    Body.AddSiteLog(PublishmentSystemId, "修改提交表单内容", $"提交表单:{_inputInfo.InputName},{builder}");
                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "信息修改失败:" + ex.Message);
                }
            }
            else
            {
                try
                {
                    var ipAddress = PageUtils.GetIpAddress();

                    var contentInfo = new InputContentInfo(0, _inputInfo.InputId, 0, true, string.Empty, ipAddress, DateTime.Now, string.Empty);

                    InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, PublishmentSystemInfo, _relatedIdentities, Page.Request.Form, contentInfo.Attributes);

                    DataProvider.InputContentDao.Insert(contentInfo);

                    var builder = new StringBuilder();

                    var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, _relatedIdentities);
                    foreach (var styleInfo in styleInfoList)
                    {
                        if (styleInfo.IsVisible == false)
                        {
                            continue;
                        }

                        var theValue = InputParserUtility.GetContentByTableStyle(contentInfo.GetExtendedAttribute(styleInfo.AttributeName), PublishmentSystemInfo, ETableStyle.InputContent, styleInfo);

                        builder.Append($@"{styleInfo.DisplayName}:{theValue},");
                    }

                    if (builder.Length > 0)
                    {
                        builder.Length = builder.Length - 1;
                    }

                    if (builder.Length > 60)
                    {
                        builder.Length = 60;
                    }

                    Body.AddSiteLog(PublishmentSystemId, "添加提交表单内容", $"提交表单:{_inputInfo.InputName},{builder}");
                    isChanged = true;
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "信息添加失败:" + ex.Message);
                }
            }

            if (isChanged)
            {
                PageUtils.CloseModalPageAndRedirect(Page, _returnUrl);
            }
        }
Esempio n. 13
0
        public void Main(int publishmentSystemId, int inputId)
        {
            var body = new RequestBody();

            var       publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            InputInfo inputInfo             = null;

            if (inputId > 0)
            {
                inputInfo = DataProvider.InputDao.GetInputInfo(inputId);
            }
            if (inputInfo != null)
            {
                var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputInfo.InputId);

                var ipAddress = PageUtils.GetIpAddress();

                var contentInfo = new InputContentInfo(0, inputInfo.InputId, 0, inputInfo.IsChecked, body.UserName, ipAddress, DateTime.Now, string.Empty);

                try
                {
                    if (!inputInfo.Additional.IsAnomynous && !body.IsUserLoggin)
                    {
                        throw new Exception("请先登录系统!");
                    }

                    InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, publishmentSystemInfo, relatedIdentities, HttpContext.Current.Request.Form, contentInfo.Attributes, false);

                    if (HttpContext.Current.Request.Files.Count > 0)
                    {
                        foreach (var attributeName in HttpContext.Current.Request.Files.AllKeys)
                        {
                            var myFile = HttpContext.Current.Request.Files[attributeName];
                            if (myFile == null || "" == myFile.FileName)
                            {
                                continue;
                            }

                            var fileUrl = UploadFile(publishmentSystemInfo, myFile);
                            contentInfo.SetExtendedAttribute(attributeName, fileUrl);
                        }
                    }

                    contentInfo.Id = DataProvider.InputContentDao.Insert(contentInfo);

                    if (inputInfo.Additional.IsAdministratorSmsNotify)
                    {
                        var keys =
                            TranslateUtils.StringCollectionToStringList(inputInfo.Additional.AdministratorSmsNotifyKeys);
                        if (keys.Count > 0)
                        {
                            var parameters = new NameValueCollection();
                            if (keys.Contains(InputContentAttribute.Id))
                            {
                                parameters.Add(InputContentAttribute.Id, contentInfo.Id.ToString());
                            }
                            if (keys.Contains(InputContentAttribute.AddDate))
                            {
                                parameters.Add(InputContentAttribute.AddDate, DateUtils.GetDateAndTimeString(contentInfo.AddDate));
                            }
                            var styleInfoList = TableStyleManager.GetTableStyleInfoList(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, relatedIdentities);
                            foreach (var styleInfo in styleInfoList)
                            {
                                if (keys.Contains(styleInfo.AttributeName))
                                {
                                    var value = contentInfo.GetExtendedAttribute(styleInfo.AttributeName);
                                    parameters.Add(styleInfo.AttributeName, value);
                                }
                            }

                            string errorMessage;
                            SmsManager.SendNotify(inputInfo.Additional.AdministratorSmsNotifyMobile,
                                                  inputInfo.Additional.AdministratorSmsNotifyTplId, parameters, out errorMessage);
                        }
                    }

                    HttpContext.Current.Response.Write(StlInput.GetPostMessageScript(inputId, true));
                    HttpContext.Current.Response.End();
                }
                catch (Exception)
                {
                    HttpContext.Current.Response.Write(StlInput.GetPostMessageScript(inputId, false));
                    HttpContext.Current.Response.End();
                }
            }
        }
Esempio n. 14
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var categoryChannelId    = TranslateUtils.ToInt(Request["categoryChannelID"]);
            var categoryDepartmentId = TranslateUtils.ToInt(Request["categoryDepartmentID"]);

            if (categoryChannelId == 0)
            {
                FailMessage("信息采集失败,必须要选择一个主题分类");
                return;
            }

            if (categoryDepartmentId == 0)
            {
                FailMessage("信息采集失败,必须要选择一个机构分类");
                return;
            }

            var categoryClassInfoArrayList = DataProvider.GovPublicCategoryClassDao.GetCategoryClassInfoArrayList(PublishmentSystemId, ETriState.False, ETriState.True);

            if (_contentId == 0)
            {
                var contentInfo = new GovPublicContentInfo();
                try
                {
                    InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                    contentInfo.NodeId        = categoryChannelId;
                    contentInfo.Description   = tbDescription.Text;
                    contentInfo.PublishDate   = dtbPublishDate.DateTime;
                    contentInfo.EffectDate    = dtbEffectDate.DateTime;
                    contentInfo.IsAbolition   = TranslateUtils.ToBool(rblIsAbolition.SelectedValue);
                    contentInfo.AbolitionDate = dtbAbolitionDate.DateTime;
                    contentInfo.DocumentNo    = tbDocumentNo.Text;
                    contentInfo.Publisher     = tbPublisher.Text;
                    contentInfo.Keywords      = tbKeywords.Text;

                    contentInfo.DepartmentId = categoryDepartmentId;
                    SetCategoryAttributes(contentInfo, categoryClassInfoArrayList);
                    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;

                    if (phContentAttributes.Visible)
                    {
                        foreach (ListItem listItem in ContentAttributes.Items)
                        {
                            var value         = listItem.Selected.ToString();
                            var attributeName = listItem.Value;
                            contentInfo.SetExtendedAttribute(attributeName, value);
                        }
                    }

                    contentInfo.CheckedLevel = TranslateUtils.ToIntWithNagetive(ContentLevel.SelectedValue);
                    contentInfo.IsChecked    = contentInfo.CheckedLevel >= PublishmentSystemInfo.CheckContentLevel;

                    contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(ContentGroupNameCollection.Items);
                    var tagCollection = TagUtils.ParseTagsString(Tags.Text);
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    contentInfo.Identifier = GovPublicManager.GetIdentifier(PublishmentSystemInfo, categoryChannelId, categoryDepartmentId, contentInfo);
                    var contentId = DataProvider.ContentDao.Insert(_tableName, PublishmentSystemInfo, contentInfo);

                    //更新分类内容数
                    foreach (GovPublicCategoryClassInfo categoryClassInfo in categoryClassInfoArrayList)
                    {
                        var categoryId = TranslateUtils.ToInt(contentInfo.GetExtendedAttribute(categoryClassInfo.ContentAttributeName));
                        if (categoryId > 0)
                        {
                            DataProvider.GovPublicCategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, categoryId);
                        }
                    }

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

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

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

                ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(ddlTranslateType.SelectedValue), Body.AdministratorName);

                PageUtils.Redirect(PageGovPublicContentAddAfter.GetRedirectUrl(PublishmentSystemId, categoryChannelId, contentInfo.Id, Request.QueryString["ReturnUrl"]));
            }
            else
            {
                var contentInfo = DataProvider.GovPublicContentDao.GetContentInfo(PublishmentSystemInfo, _contentId);
                try
                {
                    var oldNodeId = 0;
                    if (contentInfo.NodeId != categoryChannelId)
                    {
                        oldNodeId          = contentInfo.NodeId;
                        contentInfo.NodeId = categoryChannelId;
                    }

                    var identifier = contentInfo.Identifier;
                    InputTypeParser.AddValuesToAttributes(_tableStyle, _tableName, PublishmentSystemInfo, _relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                    contentInfo.DepartmentId = categoryDepartmentId;
                    SetCategoryAttributes(contentInfo, categoryClassInfoArrayList);

                    contentInfo.Description   = tbDescription.Text;
                    contentInfo.PublishDate   = dtbPublishDate.DateTime;
                    contentInfo.EffectDate    = dtbEffectDate.DateTime;
                    contentInfo.IsAbolition   = TranslateUtils.ToBool(rblIsAbolition.SelectedValue);
                    contentInfo.AbolitionDate = dtbAbolitionDate.DateTime;
                    contentInfo.DocumentNo    = tbDocumentNo.Text;
                    contentInfo.Publisher     = tbPublisher.Text;
                    contentInfo.Keywords      = tbKeywords.Text;

                    var contentAttributeNameWithCategoryId = SetCategoryAttributes(contentInfo, categoryClassInfoArrayList);
                    contentInfo.LastEditUserName = Body.AdministratorName;
                    contentInfo.LastEditDate     = DateTime.Now;

                    contentInfo.ContentGroupNameCollection = ControlUtils.SelectedItemsValueToStringCollection(ContentGroupNameCollection.Items);
                    var tagsLast      = contentInfo.Tags;
                    var tagCollection = TagUtils.ParseTagsString(Tags.Text);
                    contentInfo.Tags = TranslateUtils.ObjectCollectionToString(tagCollection, " ");

                    if (phContentAttributes.Visible)
                    {
                        foreach (ListItem listItem in ContentAttributes.Items)
                        {
                            var value         = listItem.Selected.ToString();
                            var attributeName = listItem.Value;
                            contentInfo.SetExtendedAttribute(attributeName, value);
                        }
                    }

                    var checkedLevel = TranslateUtils.ToIntWithNagetive(ContentLevel.SelectedValue);
                    if (checkedLevel != LevelManager.LevelInt.NotChange)
                    {
                        contentInfo.IsChecked    = checkedLevel >= PublishmentSystemInfo.CheckContentLevel;
                        contentInfo.CheckedLevel = checkedLevel;
                    }

                    if (string.IsNullOrEmpty(identifier))
                    {
                        identifier = GovPublicManager.GetIdentifier(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.DepartmentId, contentInfo);
                    }
                    else if (GovPublicManager.IsIdentifierChanged(categoryChannelId, categoryDepartmentId, dtbEffectDate.DateTime, contentInfo))
                    {
                        identifier = GovPublicManager.GetIdentifier(PublishmentSystemInfo, contentInfo.NodeId, contentInfo.DepartmentId, contentInfo);
                    }
                    contentInfo.Identifier = identifier;

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

                    if (phTags.Visible)
                    {
                        TagUtils.UpdateTags(tagsLast, contentInfo.Tags, tagCollection, PublishmentSystemId, _contentId);
                    }

                    ContentUtility.Translate(PublishmentSystemInfo, _nodeInfo.NodeId, contentInfo.Id, Request.Form["translateCollection"], ETranslateContentTypeUtils.GetEnumType(ddlTranslateType.SelectedValue), Body.AdministratorName);

                    //更新分类内容数
                    foreach (GovPublicCategoryClassInfo categoryClassInfo in categoryClassInfoArrayList)
                    {
                        if (!string.IsNullOrEmpty(contentAttributeNameWithCategoryId[categoryClassInfo.ContentAttributeName]))
                        {
                            var oldCategoryId = TranslateUtils.ToInt(contentAttributeNameWithCategoryId[categoryClassInfo.ContentAttributeName]);
                            var newCategoryId = TranslateUtils.ToInt(contentInfo.GetExtendedAttribute(categoryClassInfo.ContentAttributeName));

                            if (oldCategoryId > 0)
                            {
                                DataProvider.GovPublicCategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, oldCategoryId);
                            }
                            if (newCategoryId > 0)
                            {
                                DataProvider.GovPublicCategoryDao.UpdateContentNum(PublishmentSystemInfo, categoryClassInfo.ContentAttributeName, newCategoryId);
                            }
                        }
                    }

                    if (oldNodeId > 0)
                    {
                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, oldNodeId, true);
                        DataProvider.NodeDao.UpdateContentNum(PublishmentSystemInfo, categoryChannelId, true);
                    }
                }
                catch (Exception ex)
                {
                    FailMessage(ex, $"内容修改失败:{ex.Message}");
                    LogUtils.AddErrorLog(ex);
                    return;
                }

                if (contentInfo.IsChecked)
                {
                    CreateManager.CreateContentAndTrigger(PublishmentSystemId, categoryChannelId, _contentId);
                }

                Body.AddSiteLog(PublishmentSystemId, categoryChannelId, _contentId, "修改内容",
                                $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},内容标题:{contentInfo.Title}");

                PageUtils.Redirect(ReturnUrl);
            }
        }
Esempio n. 15
0
        public void Main(int publishmentSystemId, int inputId)
        {
            var body = new RequestBody();

            var       publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
            InputInfo inputInfo             = null;

            if (inputId > 0)
            {
                inputInfo = DataProvider.InputDao.GetInputInfo(inputId);
            }
            if (inputInfo != null)
            {
                var relatedIdentities = RelatedIdentities.GetRelatedIdentities(ETableStyle.InputContent, publishmentSystemId, inputInfo.InputId);

                var ipAddress = PageUtils.GetIpAddress();

                var contentInfo = new InputContentInfo(0, inputInfo.InputId, 0, inputInfo.IsChecked, body.UserName, ipAddress, DateTime.Now, string.Empty);

                try
                {
                    if (!inputInfo.Additional.IsAnomynous && !body.IsUserLoggin)
                    {
                        throw new Exception("请先登录系统!");
                    }

                    InputTypeParser.AddValuesToAttributes(ETableStyle.InputContent, DataProvider.InputContentDao.TableName, publishmentSystemInfo, relatedIdentities, HttpContext.Current.Request.Form, contentInfo.Attributes, false);

                    if (HttpContext.Current.Request.Files.Count > 0)
                    {
                        foreach (var attributeName in HttpContext.Current.Request.Files.AllKeys)
                        {
                            var myFile = HttpContext.Current.Request.Files[attributeName];
                            if (myFile == null || "" == myFile.FileName)
                            {
                                continue;
                            }

                            var fileUrl = UploadFile(publishmentSystemInfo, myFile);
                            contentInfo.SetExtendedAttribute(attributeName, fileUrl);
                        }
                    }

                    DataProvider.InputContentDao.Insert(contentInfo);

                    string message;
                    if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["successTemplateString"]))
                    {
                        if (string.IsNullOrEmpty(inputInfo.Additional.MessageSuccess))
                        {
                            message = "表单提交成功,正在审核。";
                            if (contentInfo.IsChecked)
                            {
                                message = "表单提交成功。";
                            }
                        }
                        else
                        {
                            message = inputInfo.Additional.MessageSuccess;
                        }
                    }
                    else
                    {
                        message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["successTemplateString"]);
                    }

                    HttpContext.Current.Response.Write(InputTemplate.GetInputCallbackScript(publishmentSystemInfo, inputId, true, message));
                    HttpContext.Current.Response.End();

                    //if (contentInfo.IsChecked == EBoolean.True)
                    //{
                    //    FileSystemObject FSO = new FileSystemObject(base.PublishmentSystemID);
                    //    FSO.CreateImmediately(EChangedType.Add, ETemplateTypeUtils.GetEnumType(templateType), channelID, contentID, fileTemplateID);
                    //}
                }
                catch (Exception ex)
                {
                    string message;
                    if (string.IsNullOrEmpty(HttpContext.Current.Request.Form["failureTemplateString"]))
                    {
                        if (string.IsNullOrEmpty(inputInfo.Additional.MessageFailure))
                        {
                            message = "表单提交失败," + ex.Message;
                        }
                        else
                        {
                            message = inputInfo.Additional.MessageFailure;
                        }
                    }
                    else
                    {
                        message = TranslateUtils.DecryptStringBySecretKey(HttpContext.Current.Request.Form["failureTemplateString"]);
                    }

                    HttpContext.Current.Response.Write(InputTemplate.GetInputCallbackScript(publishmentSystemInfo, inputId, false, message));
                    HttpContext.Current.Response.End();
                }
            }
        }
Esempio n. 16
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);
                }
            }
        }