コード例 #1
0
ファイル: Service.cs プロジェクト: Godoy/CMS
        public Service(RepositoryManager repositoryManager, SchemaManager schemaManager, TextFolderManager textFolderManager, SiteManager siteManager
            , IIncomeDataManager incomeDataManager, ITextContentProvider textContentProvider)
        {
            _textFolderManager = textFolderManager;
            _repositoryManager = repositoryManager;
            _schemaManager = schemaManager;
            _incomeDataManager = incomeDataManager;

            _siteManager = siteManager;
            _textContentProvider = textContentProvider;
        }
コード例 #2
0
        public bool IsSiteExisted(string nextUrl, SiteManager.SiteData[] onPremSiteCollectionList)
        {
            foreach (SiteManager.SiteData siteData in onPremSiteCollectionList)
            {
                if (siteData.Url.Equals(nextUrl, StringComparison.InvariantCultureIgnoreCase))
                {
                    return true;
                }
            }

            return false;
        }
コード例 #3
0
 public ClientUserSitesPermissions(SiteManager siteManager, UserManager userManager, SecurityClaimManager claimsManager)
 {
     _userManager   = userManager;
     _siteManager   = siteManager;
     _claimsManager = claimsManager;
 }
コード例 #4
0
        public async void Main()
        {
            var request = new Request();

            var siteId   = request.GetQueryInt("siteId");
            var siteInfo = SiteManager.GetSiteInfo(siteId);

            try
            {
                var channelId = request.GetQueryInt("channelId");
                if (channelId == 0)
                {
                    channelId = siteId;
                }
                var contentId      = request.GetQueryInt("contentId");
                var fileTemplateId = request.GetQueryInt("fileTemplateId");
                var isRedirect     = TranslateUtils.ToBool(request.GetQueryString("isRedirect"));

                var nodeInfo  = ChannelManager.GetChannelInfo(siteId, channelId);
                var tableName = ChannelManager.GetTableName(siteInfo, nodeInfo);

                if (fileTemplateId != 0)
                {
                    await FileSystemObjectAsync.ExecuteAsync(siteId, ECreateType.File, 0, 0, fileTemplateId);
                }
                else if (contentId != 0)
                {
                    await FileSystemObjectAsync.ExecuteAsync(siteId, ECreateType.Content, channelId, contentId, 0);
                }
                else if (channelId != 0)
                {
                    await FileSystemObjectAsync.ExecuteAsync(siteId, ECreateType.Channel, channelId, 0, 0);
                }
                else if (siteId != 0)
                {
                    await FileSystemObjectAsync.ExecuteAsync(siteId, ECreateType.Channel, siteId, 0, 0);
                }

                if (isRedirect)
                {
                    var redirectUrl = string.Empty;
                    if (fileTemplateId != 0)
                    {
                        redirectUrl = PageUtility.GetFileUrl(siteInfo, fileTemplateId, false);
                    }
                    else if (contentId != 0)
                    {
                        var contentInfo = DataProvider.ContentDao.GetContentInfo(tableName, contentId);
                        redirectUrl = PageUtility.GetContentUrl(siteInfo, contentInfo, false);
                    }
                    else if (channelId != 0)
                    {
                        redirectUrl = PageUtility.GetChannelUrl(siteInfo, nodeInfo, false);
                    }
                    else if (siteId != 0)
                    {
                        redirectUrl = PageUtility.GetIndexPageUrl(siteInfo, false);
                    }

                    if (!string.IsNullOrEmpty(redirectUrl))
                    {
                        var parameters = new NameValueCollection();
                        var returnUrl  = request.GetQueryString("returnUrl");
                        if (!string.IsNullOrEmpty(returnUrl))
                        {
                            if (returnUrl.StartsWith("?"))
                            {
                                parameters = TranslateUtils.ToNameValueCollection(returnUrl.Substring(1));
                            }
                            else
                            {
                                redirectUrl = returnUrl;
                            }
                        }

                        parameters["__r"] = StringUtils.GetRandomInt(1, 10000).ToString();

                        PageUtils.Redirect(PageUtils.AddQueryString(redirectUrl, parameters));
                        return;
                    }
                }
            }
            catch
            {
                var redirectUrl = PageUtility.GetIndexPageUrl(siteInfo, false);
                PageUtils.Redirect(redirectUrl);
                return;
            }

            HttpContext.Current.Response.Write(string.Empty);
            HttpContext.Current.Response.End();
        }
コード例 #5
0
ファイル: StlRequest.cs プロジェクト: zerojuls/cms-3
        public StlRequest()
        {
            Request         = new AuthRequest(AccessTokenManager.ScopeStl);
            IsApiAuthorized = Request.IsApiAuthorized;

            if (!IsApiAuthorized)
            {
                return;
            }

            var siteId  = Request.GetQueryInt("siteId");
            var siteDir = Request.GetQueryString("siteDir");

            var channelId = Request.GetQueryInt("channelId");
            var contentId = Request.GetQueryInt("contentId");

            if (siteId > 0)
            {
                SiteInfo = SiteManager.GetSiteInfo(siteId);
            }
            else if (!string.IsNullOrEmpty(siteDir))
            {
                SiteInfo = SiteManager.GetSiteInfoByDirectory(siteDir);
            }
            else
            {
                SiteInfo = SiteManager.GetSiteInfoByIsRoot();
                if (SiteInfo == null)
                {
                    var siteInfoList = SiteManager.GetSiteInfoList();
                    if (siteInfoList != null && siteInfoList.Count > 0)
                    {
                        SiteInfo = siteInfoList[0];
                    }
                }
            }

            if (SiteInfo == null)
            {
                return;
            }

            if (channelId == 0)
            {
                channelId = SiteInfo.Id;
            }

            var templateInfo = new TemplateInfo(0, SiteInfo.Id, string.Empty, TemplateType.IndexPageTemplate, string.Empty, string.Empty, string.Empty, ECharset.utf_8, true);

            PageInfo = new PageInfo(channelId, contentId, SiteInfo, templateInfo, new Dictionary <string, object>())
            {
                UniqueId = 1000,
                UserInfo = Request.UserInfo
            };

            var attributes = TranslateUtils.NewIgnoreCaseNameValueCollection();

            foreach (var key in Request.QueryString.AllKeys)
            {
                attributes[key] = Request.QueryString[key];
            }

            ContextInfo = new ContextInfo(PageInfo)
            {
                IsStlEntity = true,
                Attributes  = attributes,
                InnerHtml   = string.Empty
            };
        }
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId             = request.GetPostInt("siteId");
                var channelId          = request.GetPostInt("channelId");
                var contentIdList      = TranslateUtils.StringCollectionToIntList(request.GetPostString("contentIds"));
                var checkedLevel       = request.GetPostInt("checkedLevel");
                var isTranslate        = request.GetPostBool("isTranslate");
                var translateChannelId = request.GetPostInt("translateChannelId");
                var reasons            = request.GetPostString("reasons");

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentCheck))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var isChecked = checkedLevel >= siteInfo.Additional.CheckContentLevel;
                if (isChecked)
                {
                    checkedLevel = 0;
                }
                var tableName = ChannelManager.GetTableName(siteInfo, channelInfo);

                var contentInfoList = new List <ContentInfo>();
                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    contentInfo.Set(ContentAttribute.CheckUserName, request.AdminName);
                    contentInfo.Set(ContentAttribute.CheckDate, DateTime.Now);
                    contentInfo.Set(ContentAttribute.CheckReasons, reasons);

                    contentInfo.IsChecked    = isChecked;
                    contentInfo.CheckedLevel = checkedLevel;

                    if (isTranslate && translateChannelId > 0)
                    {
                        var translateChannelInfo = ChannelManager.GetChannelInfo(siteId, translateChannelId);
                        contentInfo.ChannelId = translateChannelInfo.Id;
                        DataProvider.ContentDao.Update(siteInfo, translateChannelInfo, contentInfo);
                    }
                    else
                    {
                        DataProvider.ContentDao.Update(siteInfo, channelInfo, contentInfo);
                    }

                    contentInfoList.Add(contentInfo);

                    var checkInfo = new ContentCheckInfo(0, tableName, siteId, contentInfo.ChannelId, contentInfo.Id, request.AdminName, isChecked, checkedLevel, DateTime.Now, reasons);
                    DataProvider.ContentCheckDao.Insert(checkInfo);
                }

                if (isTranslate && translateChannelId > 0)
                {
                    ContentManager.RemoveCache(tableName, channelId);
                    var translateTableName = ChannelManager.GetTableName(siteInfo, translateChannelId);
                    ContentManager.RemoveCache(translateTableName, translateChannelId);
                }

                request.AddSiteLog(siteId, "批量审核内容");

                foreach (var contentInfo in contentInfoList)
                {
                    CreateManager.CreateContent(siteId, contentInfo.ChannelId, contentInfo.Id);
                }
                CreateManager.TriggerContentChangedEvent(siteId, channelId);
                if (isTranslate && translateChannelId > 0)
                {
                    CreateManager.TriggerContentChangedEvent(siteId, translateChannelId);
                }

                return(Ok(new
                {
                    Value = contentIdList
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #7
0
        public string GetItemHtml(int parentContentNum)
        {
            var htmlBuilder = new StringBuilder();

            for (var i = 0; i < _parentsCount; i++)
            {
                htmlBuilder.Append($"<img align=\"absmiddle\" src=\"{_iconEmptyUrl}\"/>");
            }

            if (_isDisplay)
            {
                if (_hasChildren)
                {
                    if (_selected)
                    {
                        htmlBuilder.Append(
                            $"<img align=\"absmiddle\" style=\"cursor:pointer;\" onClick=\"displayChildren(this);\" isOpen=\"true\" src=\"{_iconMinusUrl}\"/>");
                    }
                    else
                    {
                        htmlBuilder.Append(
                            $"<img align=\"absmiddle\" style=\"cursor:pointer;\" onClick=\"displayChildren(this);\" isOpen=\"false\" src=\"{_iconPlusUrl}\"/>");
                    }
                }
                else
                {
                    htmlBuilder.Append($"<img align=\"absmiddle\" src=\"{_iconEmptyUrl}\"/>");
                }
            }
            else
            {
                if (_hasChildren)
                {
                    htmlBuilder.Append(
                        $"<img align=\"absmiddle\" style=\"cursor:pointer;\" onClick=\"displayChildren(this);\" isOpen=\"false\" src=\"{_iconPlusUrl}\"/>");
                }
                else
                {
                    htmlBuilder.Append($"<img align=\"absmiddle\" src=\"{_iconEmptyUrl}\"/>");
                }
            }

            if (!string.IsNullOrEmpty(_iconFolderUrl))
            {
                if (_channelId > 0)
                {
                    htmlBuilder.Append(
                        $"<a href=\"{PageRedirect.GetRedirectUrlToChannel(_siteId, _channelId)}\" target=\"_blank\" title='浏览页面'><img align=\"absmiddle\" border=\"0\" src=\"{_iconFolderUrl}\"/></a>");
                }
                else
                {
                    htmlBuilder.Append($"<img align=\"absmiddle\" src=\"{_iconFolderUrl}\"/>");
                }
            }

            htmlBuilder.Append("&nbsp;");

            if (_enabled)
            {
                if (!string.IsNullOrEmpty(_linkUrl))
                {
                    var targetHtml      = (string.IsNullOrEmpty(_target)) ? string.Empty : $"target='{_target}'";
                    var clickChangeHtml = (_isClickChange) ? "onclick='openFolderByA(this);'" : string.Empty;

                    htmlBuilder.Append(
                        $"<a href='{_linkUrl}' {targetHtml} {clickChangeHtml} isTreeLink='true'>{_text}</a>");
                }
                else if (!string.IsNullOrEmpty(_onClickUrl))
                {
                    htmlBuilder.Append(
                        $@"<a href=""javascript:;"" onClick=""{_onClickUrl}"" title='快速编辑栏目' isTreeLink='true'>{_text}</a>");
                }
                else
                {
                    htmlBuilder.Append(_text);
                }
            }
            else
            {
                htmlBuilder.Append(_text);
            }

            if (_isNodeTree && _siteId != 0)
            {
                var siteInfo = SiteManager.GetSiteInfo(_siteId);

                htmlBuilder.Append("&nbsp;");
                htmlBuilder.Append(ChannelManager.GetNodeTreeLastImageHtml(siteInfo, ChannelManager.GetChannelInfo(_siteId, _channelId)));

                if (_contentNum >= 0)
                {
                    htmlBuilder.Append("&nbsp;");
                    htmlBuilder.Append(
                        $"<span style=\"font-size:8pt;font-family:arial\" class=\"gray\">(总共:{parentContentNum},本级:{_contentNum})</span>");
                }
            }

            return(htmlBuilder.ToString());
        }
コード例 #8
0
 public static void DeletePage(int companyId, int pageId)
 {
     using (var siteManager = new SiteManager(null))
         siteManager.Delete(siteManager.GetWebPage(companyId, pageId));
 }
コード例 #9
0
        private string GetTopMenuSitesHtml()
        {
            var siteIdList = ProductPermissionsManager.Current.SiteIdList;

            if (!_permissions.IsSystemAdministrator && siteIdList.Count == 0)
            {
                return(string.Empty);
            }

            //操作者拥有的站点列表
            var mySystemInfoList = new List <SiteInfo>();

            var parentWithChildren = new Dictionary <int, List <SiteInfo> >();

            if (ProductPermissionsManager.Current.IsSystemAdministrator)
            {
                foreach (var siteId in siteIdList)
                {
                    AddToMySystemInfoList(mySystemInfoList, parentWithChildren, siteId);
                }
            }
            else
            {
                ICollection channelIdCollection = ProductPermissionsManager.Current.ChannelPermissionDict.Keys;
                ICollection siteIdCollection    = ProductPermissionsManager.Current.WebsitePermissionDict.Keys;
                foreach (var siteId in siteIdList)
                {
                    var showSite = IsShowSite(siteId, siteIdCollection, channelIdCollection);
                    if (showSite)
                    {
                        AddToMySystemInfoList(mySystemInfoList, parentWithChildren, siteId);
                    }
                }
            }

            var builder = new StringBuilder();

            if (_hqSiteInfo != null || mySystemInfoList.Count > 0)
            {
                if (_hqSiteInfo != null)
                {
                    AddSite(builder, _hqSiteInfo, parentWithChildren, 0);
                }

                if (mySystemInfoList.Count > 0)
                {
                    var count = 0;
                    foreach (var siteInfo in mySystemInfoList)
                    {
                        if (siteInfo.IsRoot == false)
                        {
                            count++;
                            AddSite(builder, siteInfo, parentWithChildren, 0);
                        }
                        if (count == 13)
                        {
                            builder.Append(
                                $@"<li><a href=""javascript:;"" onclick=""{ModalSiteSelect.GetOpenLayerString(SiteId)}"">列出全部站点...</a></li>");
                            break;
                        }
                    }
                }
            }

            var clazz    = "has-submenu";
            var menuText = "站点管理";

            if (_siteInfo != null && _siteInfo.Id > 0)
            {
                clazz    = "has-submenu active";
                menuText = _siteInfo.SiteName;
                if (_siteInfo.ParentId > 0)
                {
                    menuText += $" ({SiteManager.GetSiteLevel(_siteInfo.Id) + 1}级)";
                }
            }

            return($@"<li class=""{clazz}"">
              <a href=""javascript:;""><i class=""ion-earth""></i>{menuText}</a>
              <ul class=""submenu"">
                {builder}
              </ul>
            </li>");
        }
コード例 #10
0
ファイル: ConfigurationIe.cs プロジェクト: zhangjingpu/cms-1
        public void Export()
        {
            var psInfo = SiteManager.GetSiteInfo(_siteId);

            var feed = AtomUtility.GetEmptyFeed();

            AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> {
                SiteAttribute.Id, "PublishmentSystemId"
            }, psInfo.Id.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> {
                SiteAttribute.SiteName, "PublishmentSystemName"
            }, psInfo.SiteName);
            AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> {
                SiteAttribute.SiteDir, "PublishmentSystemDir"
            }, psInfo.SiteDir);
            AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> {
                SiteAttribute.TableName, "AuxiliaryTableForContent"
            }, psInfo.TableName);
            AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> {
                SiteAttribute.IsRoot, "IsHeadquarters"
            }, psInfo.IsRoot.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, new List <string> {
                SiteAttribute.ParentId, "ParentPublishmentSystemId"
            }, psInfo.ParentId.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, SiteAttribute.Taxis, psInfo.Taxis.ToString());
            AtomUtility.AddDcElement(feed.AdditionalElements, SiteAttribute.SettingsXml, psInfo.Additional.ToString());

            var indexTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.IndexPageTemplate);

            if (indexTemplateId != 0)
            {
                var indexTemplateName = TemplateManager.GetTemplateName(_siteId, indexTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultIndexTemplateName, indexTemplateName);
            }

            var channelTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.ChannelTemplate);

            if (channelTemplateId != 0)
            {
                var channelTemplateName = TemplateManager.GetTemplateName(_siteId, channelTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultChannelTemplateName, channelTemplateName);
            }

            var contentTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.ContentTemplate);

            if (contentTemplateId != 0)
            {
                var contentTemplateName = TemplateManager.GetTemplateName(_siteId, contentTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultContentTemplateName, contentTemplateName);
            }

            var fileTemplateId = TemplateManager.GetDefaultTemplateId(psInfo.Id, TemplateType.FileTemplate);

            if (fileTemplateId != 0)
            {
                var fileTemplateName = TemplateManager.GetTemplateName(psInfo.Id, fileTemplateId);
                AtomUtility.AddDcElement(feed.AdditionalElements, DefaultFileTemplateName, fileTemplateName);
            }

            var channelGroupInfoList = DataProvider.ChannelGroupDao.GetGroupInfoList(psInfo.Id);

            channelGroupInfoList.Reverse();

            foreach (var channelGroupInfo in channelGroupInfoList)
            {
                var entry = ChannelGroupIe.Export(channelGroupInfo);
                feed.Entries.Add(entry);
            }

            var contentGroupInfoList = DataProvider.ContentGroupDao.GetContentGroupInfoList(psInfo.Id);

            contentGroupInfoList.Reverse();

            foreach (var contentGroupInfo in contentGroupInfoList)
            {
                var entry = ContentGroupIe.Export(contentGroupInfo);
                feed.Entries.Add(entry);
            }

            feed.Save(_filePath);
        }
コード例 #11
0
ファイル: ConfigurationIe.cs プロジェクト: zhangjingpu/cms-1
        public void Import()
        {
            if (!FileUtils.IsFileExists(_filePath))
            {
                return;
            }

            var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(_filePath));

            var siteInfo = SiteManager.GetSiteInfo(_siteId);

            siteInfo.SettingsXml = AtomUtility.GetDcElementContent(feed.AdditionalElements, SiteAttribute.SettingsXml, siteInfo.SettingsXml);

            siteInfo.Additional.IsSeparatedWeb      = false;
            siteInfo.Additional.IsCreateDoubleClick = false;

            DataProvider.SiteDao.Update(siteInfo);

            var indexTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultIndexTemplateName);

            if (!string.IsNullOrEmpty(indexTemplateName))
            {
                var indexTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.IndexPageTemplate, indexTemplateName);
                if (indexTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(siteInfo.Id, indexTemplateId);
                }
            }

            var channelTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultChannelTemplateName);

            if (!string.IsNullOrEmpty(channelTemplateName))
            {
                var channelTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.ChannelTemplate, channelTemplateName);
                if (channelTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(siteInfo.Id, channelTemplateId);
                }
            }

            var contentTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultContentTemplateName);

            if (!string.IsNullOrEmpty(contentTemplateName))
            {
                var contentTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.ContentTemplate, contentTemplateName);
                if (contentTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(siteInfo.Id, contentTemplateId);
                }
            }

            var fileTemplateName = AtomUtility.GetDcElementContent(feed.AdditionalElements, DefaultFileTemplateName);

            if (!string.IsNullOrEmpty(fileTemplateName))
            {
                var fileTemplateId = TemplateManager.GetTemplateIdByTemplateName(siteInfo.Id, TemplateType.FileTemplate, fileTemplateName);
                if (fileTemplateId != 0)
                {
                    DataProvider.TemplateDao.SetDefault(siteInfo.Id, fileTemplateId);
                }
            }

            foreach (AtomEntry entry in feed.Entries)
            {
                if (!ChannelGroupIe.Import(entry, siteInfo.Id))
                {
                    ContentGroupIe.Import(entry, siteInfo.Id);
                }
            }
        }
コード例 #12
0
 public DeadlockManager(SiteManager siteManager, Clock clock)
 {
     SiteManager = siteManager;
     Clock       = clock;
 }
コード例 #13
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            if (IsPostBack)
            {
                return;
            }

            VerifySystemPermissions(ConfigManager.SettingsPermissions.Site);

            if (SiteInfo.IsRoot)
            {
                PhParentId.Visible = false;
            }
            else
            {
                PhParentId.Visible = true;

                DdlParentId.Items.Add(new ListItem("<无上级站点>", "0"));
                var siteIdList            = SiteManager.GetSiteIdList();
                var mySystemInfoArrayList = new ArrayList();
                var parentWithChildren    = new Hashtable();
                foreach (var siteId in siteIdList)
                {
                    if (siteId == SiteId)
                    {
                        continue;
                    }
                    var siteInfo = SiteManager.GetSiteInfo(siteId);
                    if (siteInfo.IsRoot == false)
                    {
                        if (siteInfo.ParentId == 0)
                        {
                            mySystemInfoArrayList.Add(siteInfo);
                        }
                        else
                        {
                            var children = new ArrayList();
                            if (parentWithChildren.Contains(siteInfo.ParentId))
                            {
                                children = (ArrayList)parentWithChildren[siteInfo.ParentId];
                            }
                            children.Add(siteInfo);
                            parentWithChildren[siteInfo.ParentId] = children;
                        }
                    }
                }
                foreach (SiteInfo siteInfo in mySystemInfoArrayList)
                {
                    AddSite(DdlParentId, siteInfo, parentWithChildren, 0);
                }
                ControlUtils.SelectSingleItem(DdlParentId, SiteInfo.ParentId.ToString());
            }

            var tableNameList = SiteManager.GetSiteTableNames();

            if (tableNameList.Count > 0)
            {
                RblTableRule.Items.Add(ETableRuleUtils.GetListItem(ETableRule.Choose, true));
                RblTableRule.Items.Add(ETableRuleUtils.GetListItem(ETableRule.HandWrite, false));

                PhTableChoose.Visible    = true;
                PhTableHandWrite.Visible = false;

                foreach (var tableName in tableNameList)
                {
                    DdlTableChoose.Items.Add(new ListItem(tableName, tableName));
                }
            }
            else
            {
                RblTableRule.Items.Add(ETableRuleUtils.GetListItem(ETableRule.HandWrite, false));

                PhTableChoose.Visible    = false;
                PhTableHandWrite.Visible = false;
            }

            TbTaxis.Text = SiteInfo.Taxis.ToString();

            RblIsCheckContentUseLevel.Items.Add(new ListItem("默认审核机制", false.ToString()));
            RblIsCheckContentUseLevel.Items.Add(new ListItem("多级审核机制", true.ToString()));

            if (SiteInfo == null)
            {
                PageUtils.RedirectToErrorPage("站点不存在,请确认后再试!");
                return;
            }
            TbSiteName.Text = SiteInfo.SiteName;
            ControlUtils.SelectSingleItem(RblIsCheckContentUseLevel, SiteInfo.Additional.IsCheckContentLevel.ToString());
            if (SiteInfo.Additional.IsCheckContentLevel)
            {
                ControlUtils.SelectSingleItem(DdlCheckContentLevel, SiteInfo.Additional.CheckContentLevel.ToString());
                PhCheckContentLevel.Visible = true;
            }
            else
            {
                PhCheckContentLevel.Visible = false;
            }
            if (!string.IsNullOrEmpty(SiteInfo.SiteDir))
            {
                TbSiteDir.Text = PathUtils.GetDirectoryName(SiteInfo.SiteDir, false);
            }
            if (SiteInfo.IsRoot)
            {
                PhSiteDir.Visible = false;
            }

            ControlUtils.SelectSingleItem(DdlTableChoose, SiteInfo.TableName);

            BtnSubmit.Attributes.Add("onclick", PageLoading());
        }
コード例 #14
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            SiteInfo.SiteName = TbSiteName.Text;
            SiteInfo.Taxis    = TranslateUtils.ToInt(TbTaxis.Text);
            SiteInfo.Additional.IsCheckContentLevel = TranslateUtils.ToBool(RblIsCheckContentUseLevel.SelectedValue);
            if (SiteInfo.Additional.IsCheckContentLevel)
            {
                SiteInfo.Additional.CheckContentLevel = TranslateUtils.ToInt(DdlCheckContentLevel.SelectedValue);
            }

            var isTableChanged = false;

            var tableName = string.Empty;
            var tableRule = ETableRuleUtils.GetEnumType(RblTableRule.SelectedValue);

            if (tableRule == ETableRule.Choose)
            {
                tableName = DdlTableChoose.SelectedValue;
            }
            else if (tableRule == ETableRule.HandWrite)
            {
                tableName = TbTableHandWrite.Text;
                if (!DataProvider.DatabaseDao.IsTableExists(tableName))
                {
                    DataProvider.ContentDao.CreateContentTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                }
                else
                {
                    DataProvider.DatabaseDao.AlterSystemTable(tableName, DataProvider.ContentDao.TableColumnsDefault);
                }
            }

            if (StringUtils.EqualsIgnoreCase(SiteInfo.TableName, tableName))
            {
                isTableChanged     = true;
                SiteInfo.TableName = tableName;
            }

            if (SiteInfo.IsRoot == false)
            {
                if (!StringUtils.EqualsIgnoreCase(PathUtils.GetDirectoryName(SiteInfo.SiteDir, false), TbSiteDir.Text))
                {
                    var list = DataProvider.SiteDao.GetLowerSiteDirList(SiteInfo.ParentId);
                    if (list.IndexOf(TbSiteDir.Text.ToLower()) != -1)
                    {
                        FailMessage("站点修改失败,已存在相同的发布路径!");
                        return;
                    }

                    var parentPsPath = WebConfigUtils.PhysicalApplicationPath;
                    if (SiteInfo.ParentId > 0)
                    {
                        var parentSiteInfo = SiteManager.GetSiteInfo(SiteInfo.ParentId);
                        parentPsPath = PathUtility.GetSitePath(parentSiteInfo);
                    }
                    DirectoryUtility.ChangeSiteDir(parentPsPath, SiteInfo.SiteDir, TbSiteDir.Text);
                }

                if (PhParentId.Visible && SiteInfo.ParentId != TranslateUtils.ToInt(DdlParentId.SelectedValue))
                {
                    var newParentId = TranslateUtils.ToInt(DdlParentId.SelectedValue);
                    var list        = DataProvider.SiteDao.GetLowerSiteDirList(newParentId);
                    if (list.IndexOf(TbSiteDir.Text.ToLower()) != -1)
                    {
                        FailMessage("站点修改失败,已存在相同的发布路径!");
                        return;
                    }

                    DirectoryUtility.ChangeParentSite(SiteInfo.ParentId, TranslateUtils.ToInt(DdlParentId.SelectedValue), SiteId, TbSiteDir.Text);
                    SiteInfo.ParentId = newParentId;
                }

                SiteInfo.SiteDir = TbSiteDir.Text;
            }

            DataProvider.SiteDao.Update(SiteInfo);
            if (isTableChanged)
            {
                ContentManager.RemoveCountCache(tableName);
            }

            AuthRequest.AddAdminLog("修改站点属性", $"站点:{SiteInfo.SiteName}");

            SuccessMessage("站点修改成功!");
            AddWaitAndRedirectScript(PageSite.GetRedirectUrl());
        }
コード例 #15
0
        internal static string Parse(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo)
        {
            var parsedContent = string.Empty;

            if (contextInfo.ContentId != 0)
            {
                try
                {
                    if (contextInfo.ContentInfo != null && contextInfo.ContentInfo.ReferenceId > 0 && contextInfo.ContentInfo.SourceId > 0 && contextInfo.ContentInfo.GetString(ContentAttribute.TranslateContentType) != ETranslateContentType.ReferenceContent.ToString())
                    {
                        var targetChannelId = contextInfo.ContentInfo.SourceId;
                        //var targetSiteId = DataProvider.ChannelDao.GetSiteId(targetChannelId);
                        var targetSiteId   = Node.GetSiteId(targetChannelId);
                        var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
                        var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);

                        var tableName = ChannelManager.GetTableName(targetSiteInfo, targetNodeInfo);
                        //var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contextInfo.ContentInfo.ReferenceId);
                        var targetContentInfo = Cache.Content.GetContentInfo(tableName, contextInfo.ContentInfo.ReferenceId);
                        if (targetContentInfo != null && targetContentInfo.ChannelId > 0)
                        {
                            //标题可以使用自己的
                            targetContentInfo.Title = contextInfo.ContentInfo.Title;

                            contextInfo.ContentInfo = targetContentInfo;
                        }
                    }

                    var entityName    = StlParserUtility.GetNameFromEntity(stlEntity);
                    var attributeName = entityName.Substring(9, entityName.Length - 10);

                    if (StringUtils.EqualsIgnoreCase(ContentAttribute.Id, attributeName))//内容ID
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.ReferenceId > 0 ? contextInfo.ContentInfo.ReferenceId.ToString() : contextInfo.ContentInfo.Id.ToString();
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Id);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(Title, attributeName))//内容标题
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.Title;
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(FullTitle, attributeName))//内容标题全称
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.Title;
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Title);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(NavigationUrl, attributeName))//内容链接地址
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, contextInfo.ContentInfo, pageInfo.IsLocal);
                        }
                        else
                        {
                            var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId);
                            parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, nodeInfo, contextInfo.ContentId, pageInfo.IsLocal);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(ImageUrl, attributeName))//内容图片地址
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.ImageUrl);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.ImageUrl);
                        }

                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(VideoUrl, attributeName))//内容视频地址
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.VideoUrl);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.VideoUrl);
                        }

                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(FileUrl, attributeName))//内容附件地址
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl);
                        }

                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(DownloadUrl, attributeName))//内容附件地址(可统计下载量)
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.FileUrl);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.FileUrl);
                        }

                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            parsedContent = ApiRouteActionsDownload.GetUrl(pageInfo.ApiUrl, pageInfo.SiteId, contextInfo.ChannelId, contextInfo.ContentId, parsedContent);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(AddDate, attributeName))//内容添加日期
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = DateUtils.Format(contextInfo.ContentInfo.AddDate, string.Empty);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId);
                            //parsedContent = DateUtils.Format(DataProvider.ContentDao.GetAddDate(tableName, contextInfo.ContentId), string.Empty);
                            parsedContent = DateUtils.Format(Cache.Content.GetAddDate(tableName, contextInfo.ContentId), string.Empty);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(LastEditDate, attributeName))//替换最后修改日期
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = DateUtils.Format(contextInfo.ContentInfo.LastEditDate, string.Empty);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId);
                            //parsedContent = DateUtils.Format(DataProvider.ContentDao.GetLastEditDate(tableName, contextInfo.ContentId), string.Empty);
                            parsedContent = DateUtils.Format(Cache.Content.GetLastEditDate(tableName, contextInfo.ContentId), string.Empty);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(Content, attributeName))//内容正文
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.GetString(BackgroundContentAttribute.Content);
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, BackgroundContentAttribute.Content);
                        }
                        parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                    }
                    else if (StringUtils.EqualsIgnoreCase(Group, attributeName))//内容组别
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.GroupNameCollection;
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.ContentGroupNameCollection);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, ContentAttribute.GroupNameCollection);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(Tags, attributeName))//标签
                    {
                        if (contextInfo.ContentInfo != null)
                        {
                            parsedContent = contextInfo.ContentInfo.Tags;
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Tags);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, ContentAttribute.Tags);
                        }
                    }
                    else if (StringUtils.EqualsIgnoreCase(AddUserName, attributeName))
                    {
                        string addUserName;
                        if (contextInfo.ContentInfo != null)
                        {
                            addUserName = contextInfo.ContentInfo.AddUserName;
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contextInfo.ChannelId));
                            //addUserName = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName);
                            addUserName = Cache.Content.GetValue(tableName, contextInfo.ContentId, ContentAttribute.AddUserName);
                        }
                        if (!string.IsNullOrEmpty(addUserName))
                        {
                            //var displayName = DataProvider.AdministratorDao.GetDisplayName(addUserName);
                            var displayName = Administrator.GetDisplayName(addUserName);
                            parsedContent = string.IsNullOrEmpty(displayName) ? addUserName : displayName;
                        }
                    }
                    else if (StringUtils.StartsWithIgnoreCase(attributeName, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null)
                    {
                        parsedContent = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, attributeName, contextInfo).ToString();
                    }
                    else
                    {
                        int contentChannelId;
                        if (contextInfo.ContentInfo != null)
                        {
                            contentChannelId = contextInfo.ContentInfo.ChannelId;
                            if (contextInfo.ContentInfo.ContainsKey(attributeName))
                            {
                                parsedContent = contextInfo.ContentInfo.GetString(attributeName);
                            }
                        }
                        else
                        {
                            var tableName = ChannelManager.GetTableName(pageInfo.SiteInfo, contextInfo.ChannelId);
                            //contentChannelId = DataProvider.ContentDao.GetChannelId(tableName, contextInfo.ContentId);
                            contentChannelId = Cache.Content.GetChannelId(tableName, contextInfo.ContentId);
                            tableName        = ChannelManager.GetTableName(pageInfo.SiteInfo, ChannelManager.GetChannelInfo(pageInfo.SiteId, contentChannelId));
                            //parsedContent = DataProvider.ContentDao.GetValue(tableName, contextInfo.ContentId, attributeName);
                            parsedContent = Cache.Content.GetValue(tableName, contextInfo.ContentId, attributeName);
                        }

                        if (!string.IsNullOrEmpty(parsedContent))
                        {
                            var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(pageInfo.SiteId, contentChannelId);
                            var styleInfo         = TableStyleManager.GetTableStyleInfo(pageInfo.SiteInfo.TableName, attributeName, relatedIdentities);

                            //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式
                            parsedContent = InputParserUtility.GetContentByTableStyle(parsedContent, ",", pageInfo.SiteInfo, styleInfo, string.Empty, null, string.Empty, true);
                        }
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(parsedContent);
        }
コード例 #16
0
 public Task<string> GetPasswordAsync(Stream keypadImageStream, IList<MapAreaInfo> mapAreas, SiteManager site)
 {
     var tcs = new TaskCompletionSource<string>();
     var adb = new AlertDialog.Builder(Context);
     using (var inflater = LayoutInflater.From(adb.Context))
     {
         var view = inflater.Inflate(Resource.Layout.XjtuCardPassword, null);
         var passwordView = view.FindViewById<TextView>(Resource.Id.passwordTextView);
         var padTable = view.FindViewById<TableLayout>(Resource.Id.passwordPadTable);
         var currentPassword = "";
         Action updatePasswordDisplay = () =>
         {
             passwordView.Text = new string('#', currentPassword.Length);
         };
         //生成按键。
         var keypadBitmap = BitmapFactory.DecodeStream(keypadImageStream);
         for (var row = 0; row < 4; row++)
         {
             var tr = new TableRow(adb.Context)
             {
                 LayoutParameters = new ViewGroup.LayoutParams(
                     ViewGroup.LayoutParams.WrapContent,
                     ViewGroup.LayoutParams.WrapContent)
             };
             padTable.AddView(tr);
             for (var col = 0; col < 3; col++)
             {
                 var index = row * 3 + col;
                 var indexExpr = Convert.ToString(index);
                 View buttonView = null;
                 if (index <= 9)
                 {
                     var area = mapAreas.First(a => a.Value == indexExpr);
                     var button = new ImageButton(adb.Context)
                     {
                         LayoutParameters = new TableRow.LayoutParams(
                             ViewGroup.LayoutParams.WrapContent,
                             ViewGroup.LayoutParams.WrapContent),
                     };
                     button.SetMinimumWidth(DroidUtility.DipToPixelsX(64));
                     button.SetMinimumHeight(DroidUtility.DipToPixelsY(64));
                     button.SetImageBitmap(Bitmap.CreateBitmap(keypadBitmap, area.X1, area.Y1, area.Width, area.Height));
                     button.SetScaleType(ImageView.ScaleType.FitCenter);
                     button.Click += (_, e) =>
                     {
                         currentPassword += indexExpr;
                         updatePasswordDisplay();
                     };
                     buttonView = button;
                 } else if (index == 10)
                 {
                     var button = new Button(adb.Context)
                     {
                         Text = "更正",
                         LayoutParameters = new TableRow.LayoutParams(
                             ViewGroup.LayoutParams.MatchParent,
                             ViewGroup.LayoutParams.WrapContent)
                         {
                             Span = 2,
                             Gravity = GravityFlags.CenterVertical
                         }
                     };
                     button.Click += (_, e) =>
                     {
                         currentPassword = "";
                         updatePasswordDisplay();
                     };
                     buttonView = button;
                 }
                 if (buttonView != null)
                 {
                     tr.AddView(buttonView);
                 }
             }
         }
         //初始化界面。
         updatePasswordDisplay();
         adb.SetView(view)
             .SetPositiveButton("确定", (_, e) =>
             {
                 tcs.SetResult(currentPassword);
             })
             .SetNegativeButton("取消", (_, e) =>
             {
                 tcs.SetResult(null);
             })
             .Show();
     }
     return tcs.Task;
 }
		protected void btnGo_OnClick([NotNull] object sender, [NotNull] EventArgs e)
		{
			var site = Factory.GetSite(this.ddSites.SelectedItem.Text);

			var siteItem = this.MasterDatabase.GetItem(site.RootPath);
			var siteBlueprintItem = siteItem.Parent;

			var manager = new SiteManager();
			var results = manager.RemoveSite(siteBlueprintItem.Name, siteItem.Name);
			this.ltrlSiteInfo.Text = string.Empty;
			this.txtResults.Text = results.Log.ToString();
			this.ltrlSiteInfo.Text = string.Empty;
		}
コード例 #18
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _permissions = PermissionsManager.GetPermissions(Body.AdminName);

            var siteId = SiteId;

            if (siteId == 0)
            {
                siteId = Body.AdministratorInfo.SiteId;
            }

            var siteIdList = ProductPermissionsManager.Current.SiteIdList;

            //站点要判断是否存在,是否有权限
            if (siteId == 0 || !SiteManager.IsExists(siteId) || !siteIdList.Contains(siteId))
            {
                if (siteIdList != null && siteIdList.Count > 0)
                {
                    siteId = siteIdList[0];
                }
            }

            _siteInfo = SiteManager.GetSiteInfo(siteId);

            if (_siteInfo != null && _siteInfo.Id > 0)
            {
                if (SiteId == 0)
                {
                    PageUtils.Redirect(GetRedirectUrl(_siteInfo.Id));
                    return;
                }

                var showSite = false;

                var permissionList = new List <string>();
                if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(_siteInfo.Id))
                {
                    var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[_siteInfo.Id];
                    if (websitePermissionList != null)
                    {
                        showSite = true;
                        permissionList.AddRange(websitePermissionList);
                    }
                }

                ICollection channelIdCollection = ProductPermissionsManager.Current.ChannelPermissionDict.Keys;
                foreach (int channelId in channelIdCollection)
                {
                    if (ChannelManager.IsAncestorOrSelf(_siteInfo.Id, _siteInfo.Id, channelId))
                    {
                        showSite = true;
                        var list = ProductPermissionsManager.Current.ChannelPermissionDict[channelId];
                        permissionList.AddRange(list);
                    }
                }

                var siteIdHashtable = new Hashtable();
                if (siteIdList != null)
                {
                    foreach (var theSiteId in siteIdList)
                    {
                        siteIdHashtable.Add(theSiteId, theSiteId);
                    }
                }

                if (!siteIdHashtable.Contains(SiteId))
                {
                    showSite = false;
                }

                if (!showSite)
                {
                    PageUtils.RedirectToErrorPage("您没有此发布系统的操作权限!");
                    return;
                }

                LtlTopMenus.Text  = GetTopMenuSitesHtml();
                LtlTopMenus.Text += GetTopMenuLinksHtml();
                if (_permissions.IsConsoleAdministrator || _permissions.PermissionList.Count > 0)
                {
                    LtlTopMenus.Text += GetTopMenusHtml();
                }

                PhSite.Visible = true;

                LtlCreateStatus.Text = $@"
<script type=""text/javascript"">
function {LayerUtils.OpenPageCreateStatusFuncName}() {{
    {PageCreateStatus.GetOpenLayerString(_siteInfo.Id)}
}}
</script>
<a href=""javascript:;"" onclick=""{LayerUtils.OpenPageCreateStatusFuncName}()"">
    <i class=""ion-wand""></i>
    <span id=""progress"" class=""badge badge-xs badge-pink"">0</span>
</a>
";

                NtLeftManagement.TopId          = ConfigManager.IdSite;
                NtLeftManagement.SiteId         = _siteInfo.Id;
                NtLeftManagement.PermissionList = permissionList;

                NtLeftFunctions.TopId          = string.Empty;
                NtLeftFunctions.SiteId         = _siteInfo.Id;
                NtLeftFunctions.PermissionList = permissionList;

                ClientScriptRegisterClientScriptBlock("NodeTreeScript", NodeNaviTreeItem.GetNavigationBarScript());
            }
            else
            {
                if (_permissions.IsSystemAdministrator)
                {
                    PageUtils.Redirect(PageSiteAdd.GetRedirectUrl());
                    return;
                }
            }

            if (_siteInfo != null && _siteInfo.Id > 0 && Body.AdministratorInfo.SiteId != _siteInfo.Id)
            {
                DataProvider.AdministratorDao.UpdateSiteId(Body.AdminName, _siteInfo.Id);
            }
        }
コード例 #19
0
        public IHttpActionResult GetUnCheckedList()
        {
            try
            {
                var request = new RequestImpl();
                if (!request.IsAdminLoggin)
                {
                    return(Unauthorized());
                }

                var unCheckedList = new List <object>();

                if (request.AdminPermissionsImpl.IsConsoleAdministrator)
                {
                    foreach (var siteInfo in SiteManager.GetSiteInfoList())
                    {
                        var count = ContentManager.GetCount(siteInfo, false);
                        if (count > 0)
                        {
                            unCheckedList.Add(new
                            {
                                Url = PageContentSearch.GetRedirectUrlCheck(siteInfo.Id),
                                siteInfo.SiteName,
                                Count = count
                            });
                        }
                    }
                }
                else if (request.AdminPermissionsImpl.IsSystemAdministrator)
                {
                    foreach (var siteId in TranslateUtils.StringCollectionToIntList(request.AdminInfo.SiteIdCollection))
                    {
                        var siteInfo = SiteManager.GetSiteInfo(siteId);
                        if (siteInfo == null)
                        {
                            continue;
                        }

                        var count = ContentManager.GetCount(siteInfo, false);
                        if (count > 0)
                        {
                            unCheckedList.Add(new
                            {
                                Url = PageContentSearch.GetRedirectUrlCheck(siteInfo.Id),
                                siteInfo.SiteName,
                                Count = count
                            });
                        }
                    }
                }

                return(Ok(new
                {
                    Value = unCheckedList
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
コード例 #20
0
 private void GetPersonaInfo(SiteManager user)
 {
     txtprivateEmail.Text = user.Email;
 }
コード例 #21
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId        = request.GetQueryInt("siteId");
                var channelId     = request.GetQueryInt("channelId");
                var contentIdList = TranslateUtils.StringCollectionToIntList(request.GetQueryString("contentIds"));

                if (!request.IsUserLoggin ||
                    !request.UserPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                       ConfigManager.ChannelPermissions.ContentCheck))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var retVal = new List <Dictionary <string, object> >();
                foreach (var contentId in contentIdList)
                {
                    var contentInfo = ContentManager.GetContentInfo(siteInfo, channelInfo, contentId);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    var dict = contentInfo.ToDictionary();
                    dict["checkState"] =
                        CheckManager.GetCheckState(siteInfo, contentInfo);
                    retVal.Add(dict);
                }

                var isChecked     = CheckManager.GetUserCheckLevel(request.AdminPermissionsImpl, siteInfo, channelId, out var checkedLevel);
                var checkedLevels = CheckManager.GetCheckedLevels(siteInfo, isChecked, checkedLevel, true);

                var allChannels =
                    ChannelManager.GetChannels(siteId, request.AdminPermissionsImpl, ConfigManager.ChannelPermissions.ContentAdd);

                return(Ok(new
                {
                    Value = retVal,
                    CheckedLevels = checkedLevels,
                    CheckedLevel = checkedLevel,
                    AllChannels = allChannels
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #22
0
        private void Seed()
        {
            using (var context = new ProcurementDbContext(ContextOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                var manager1 = new SiteManager {
                    StaffId = "EMP1", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                };

                context.SiteManagers.Add(manager1);
                context.SiteManagers.Add(new SiteManager {
                    StaffId = "EMP2", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });
                context.SiteManagers.Add(new SiteManager {
                    StaffId = "EMP3", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });

                context.ManagementStaff.Add(new ManagementStaff {
                    StaffId = "EMP11", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });
                context.ManagementStaff.Add(new ManagementStaff {
                    StaffId = "EMP12", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });
                context.ManagementStaff.Add(new ManagementStaff {
                    StaffId = "EMP13", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });

                context.AccountingStaff.Add(new AccountingStaff {
                    StaffId = "EMP21", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });
                context.AccountingStaff.Add(new AccountingStaff {
                    StaffId = "EMP22", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });
                context.AccountingStaff.Add(new AccountingStaff {
                    StaffId = "EMP23", FirstName = "FirstName", LastName = "LastName", MobileNo = "0718956874"
                });

                var site1 = new Site {
                    SiteCode = "SITE001", SiteName = "SLIIT Campus Site", SiteAddress = "Malabe", Description = "Malabe SLIIT Campus working site", SiteOfficeNo = "0115489657", SiteManager = manager1
                };

                context.Sites.Add(site1);

                var supplier1 = new Supplier {
                    SupplierCode = "SP1", SupplierName = "MAS Holdings", Address1 = "Colombo 3", CompanyNo = "011548795", MobileNo = "077485698", Email = "*****@*****.**"
                };

                context.Supplier.Add(supplier1);
                context.Supplier.Add(new Supplier {
                    SupplierCode = "SP2", SupplierName = "MAS Holdings", Address1 = "Colombo 3", CompanyNo = "011548795", MobileNo = "077485698", Email = "*****@*****.**"
                });
                context.Supplier.Add(new Supplier {
                    SupplierCode = "SP3", SupplierName = "MAS Holdings", Address1 = "Colombo 3", CompanyNo = "011548795", MobileNo = "077485698", Email = "*****@*****.**"
                });

                var item1 = new Item {
                    ItemId = "IT001", ItemName = "Roofing Sheets", ItemPrice = 200.20, Description = "Roof sheets"
                };
                var item2 = new Item {
                    ItemId = "IT002", ItemName = "Roofing Sheets", ItemPrice = 200.20, Description = "Roof sheets"
                };
                var item3 = new Item {
                    ItemId = "IT003", ItemName = "Roofing Sheets", ItemPrice = 200.20, Description = "Roof sheets"
                };
                context.Items.Add(item1);
                context.Items.Add(item2);
                context.Items.Add(item3);
                var itemSupplier1 = new ItemSuppliers {
                    Item = item1, Supplier = supplier1
                };
                var itemSupplier2 = new ItemSuppliers {
                    Item = item2, Supplier = supplier1
                };
                var itemSupplier3 = new ItemSuppliers {
                    Item = item3, Supplier = supplier1
                };
                context.Add(itemSupplier1);
                context.Add(itemSupplier2);
                context.Add(itemSupplier3);

                var requisition1 = new PurchaseRequisition
                {
                    RequisitionNo   = 1,
                    ShippingAddress = "Malabe",
                    TotalCost       = 2000.00,
                    Status          = "Pending",
                    SiteManager     = manager1,
                    Supplier        = supplier1,
                    Site            = site1
                };
                context.PurchaseRequisitions.Add(requisition1);
                var requisitionItem1 = new PurchaseRequisitionItems {
                    Item = item1, PurchaseRequisition = requisition1, ItemCount = 3
                };
                var requisitionItem2 = new PurchaseRequisitionItems {
                    Item = item2, PurchaseRequisition = requisition1, ItemCount = 2
                };
                var requisitionItem3 = new PurchaseRequisitionItems {
                    Item = item3, PurchaseRequisition = requisition1, ItemCount = 1
                };
                context.Add(requisitionItem1);
                context.Add(requisitionItem2);
                context.Add(requisitionItem3);

                var order1 = new PurchaseOrder
                {
                    OrderReference  = 1,
                    ShippingAddress = "Malabe",
                    TotalCost       = 2000.00,
                    OrderStatus     = "IN PROCESS",
                    SiteManager     = manager1,
                    Supplier        = supplier1,
                    Site            = site1
                };
                context.PurchaseOrders.Add(order1);
                var orderItems1 = new PurchaseOrderItems {
                    Item = item1, PurchaseOrder = order1, ItemCount = 3
                };
                var orderItems2 = new PurchaseOrderItems {
                    Item = item2, PurchaseOrder = order1, ItemCount = 2
                };
                var orderItems3 = new PurchaseOrderItems {
                    Item = item3, PurchaseOrder = order1, ItemCount = 1
                };
                context.Add(orderItems1);
                context.Add(orderItems2);
                context.Add(orderItems3);

                var enquiry1 = new Enquiry {
                    EnquiryId = 1, Description = "Why order is late?", EnquiryStatus = "Pending", OrderReference = order1, SiteManager = manager1
                };
                var enquiry2 = new Enquiry {
                    EnquiryId = 2, Description = "Why order is late?", EnquiryStatus = "Pending", OrderReference = order1, SiteManager = manager1
                };
                var enquiry3 = new Enquiry {
                    EnquiryId = 3, Description = "Why order is late?", EnquiryStatus = "Pending", OrderReference = order1, SiteManager = manager1
                };
                context.Add(enquiry1);
                context.Add(enquiry2);
                context.Add(enquiry3);

                var delivery1 = new Delivery {
                    DeliveryId = "DL001", OnSiteDelivery = true, DeliveryStatus = "On Process", IsFullDelivery = true, Site = site1, PurchaseOrder = order1
                };
                context.Deliveries.Add(delivery1);

                var goodsReceipt1 = new GoodsReceipt {
                    ReceiptId = 1, PurchaseOrder = order1, Supplier = supplier1, Site = site1, Delivery = delivery1
                };
                context.GoodsReceipt.Add(goodsReceipt1);

                var invoice1 = new Invoice {
                    InvoiceId = "INV001", NetAmount = 2000.00, Description = "Order 1 invoice", GoodsReceipt = goodsReceipt1, Supplier = supplier1, InvoiceStatus = "Payment Due"
                };
                context.Invoice.Add(invoice1);

                context.SaveChanges();
            }
        }
コード例 #23
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId            = request.GetPostInt("siteId");
                var channelId         = request.GetPostInt("channelId");
                var isFirstLineTitle  = request.GetPostBool("isFirstLineTitle");
                var isFirstLineRemove = request.GetPostBool("isFirstLineRemove");
                var isClearFormat     = request.GetPostBool("isClearFormat");
                var isFirstLineIndent = request.GetPostBool("isFirstLineIndent");
                var isClearFontSize   = request.GetPostBool("isClearFontSize");
                var isClearFontFamily = request.GetPostBool("isClearFontFamily");
                var isClearImages     = request.GetPostBool("isClearImages");
                var checkedLevel      = request.GetPostInt("checkedLevel");
                var fileNames         = TranslateUtils.StringCollectionToStringList(request.GetPostString("fileNames"));

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                        ConfigManager.ChannelPermissions.ContentAdd))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var tableName     = ChannelManager.GetTableName(siteInfo, channelInfo);
                var styleInfoList = TableStyleManager.GetContentStyleInfoList(siteInfo, channelInfo);
                var isChecked     = checkedLevel >= siteInfo.Additional.CheckContentLevel;

                var contentIdList = new List <int>();

                foreach (var fileName in fileNames)
                {
                    if (string.IsNullOrEmpty(fileName))
                    {
                        continue;
                    }

                    var formCollection = WordUtils.GetWordNameValueCollection(siteId, isFirstLineTitle, isFirstLineRemove, isClearFormat, isFirstLineIndent, isClearFontSize, isClearFontFamily, isClearImages, fileName);

                    if (string.IsNullOrEmpty(formCollection[ContentAttribute.Title]))
                    {
                        continue;
                    }

                    var dict = BackgroundInputTypeParser.SaveAttributes(siteInfo, styleInfoList, formCollection, ContentAttribute.AllAttributes.Value);

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

                    contentInfo.LastEditUserName = contentInfo.AddUserName;
                    contentInfo.LastEditDate     = contentInfo.AddDate;
                    contentInfo.IsChecked        = isChecked;
                    contentInfo.CheckedLevel     = checkedLevel;

                    contentInfo.Title = formCollection[ContentAttribute.Title];

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

                    contentIdList.Add(contentInfo.Id);
                }

                if (isChecked)
                {
                    foreach (var contentId in contentIdList)
                    {
                        CreateManager.CreateContent(siteId, channelInfo.Id, contentId);
                    }
                    CreateManager.TriggerContentChangedEvent(siteId, channelInfo.Id);
                }

                return(Ok(new
                {
                    Value = contentIdList
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #24
0
 public ImportObject(int siteId, string adminName)
 {
     _siteInfo  = SiteManager.GetSiteInfo(siteId);
     _sitePath  = PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, _siteInfo.SiteDir);
     _adminName = adminName;
 }
コード例 #25
0
ファイル: StlContent.cs プロジェクト: ym1100/siteserver-cms
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, string leftText, string rightText, string formatString, string no, string separator, int startIndex, int length, int wordNum, string ellipsis, string replace, string to, bool isClearTags, string isReturnToBrStr, bool isLower, bool isUpper, bool isOriginal, string type, ContentInfo contentInfo, int contentId)
        {
            if (contentInfo == null)
            {
                return(string.Empty);
            }

            var parsedContent = string.Empty;

            if (string.IsNullOrEmpty(type))
            {
                type = ContentAttribute.Title.ToLower();
            }

            var isReturnToBr = false;

            if (string.IsNullOrEmpty(isReturnToBrStr))
            {
                if (BackgroundContentAttribute.Summary.ToLower().Equals(type))
                {
                    isReturnToBr = true;
                }
            }
            else
            {
                isReturnToBr = TranslateUtils.ToBool(isReturnToBrStr, true);
            }

            if (isOriginal)
            {
                if (contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0 && contentInfo.GetString(ContentAttribute.TranslateContentType) == ETranslateContentType.Reference.ToString())
                {
                    var targetChannelId = contentInfo.SourceId;
                    //var targetSiteId = DataProvider.ChannelDao.GetSiteId(targetChannelId);
                    var targetSiteId   = StlChannelCache.GetSiteId(targetChannelId);
                    var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
                    var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);

                    //var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId);
                    var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contentInfo.ReferenceId);
                    if (targetContentInfo != null && targetContentInfo.ChannelId > 0)
                    {
                        //标题可以使用自己的
                        targetContentInfo.Title = contentInfo.Title;
                        contentInfo             = targetContentInfo;
                    }
                }
            }

            if (!string.IsNullOrEmpty(formatString))
            {
                formatString = formatString.Trim();
                if (!formatString.StartsWith("{0"))
                {
                    formatString = "{0:" + formatString;
                }
                if (!formatString.EndsWith("}"))
                {
                    formatString = formatString + "}";
                }
            }

            if (contentId != 0)
            {
                if (ContentAttribute.Title.ToLower().Equals(type))
                {
                    var nodeInfo          = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentInfo.ChannelId);
                    var relatedIdentities = TableStyleManager.GetRelatedIdentities(nodeInfo);
                    var tableName         = ChannelManager.GetTableName(pageInfo.SiteInfo, nodeInfo);

                    var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, type, relatedIdentities);
                    parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo.Title, separator, pageInfo.SiteInfo, styleInfo, formatString, contextInfo.Attributes, contextInfo.InnerHtml, false);
                    parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);

                    if (!isClearTags && !string.IsNullOrEmpty(contentInfo.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title))))
                    {
                        parsedContent = ContentUtility.FormatTitle(contentInfo.GetString(ContentAttribute.GetFormatStringAttributeName(ContentAttribute.Title)), parsedContent);
                    }

                    if (pageInfo.SiteInfo.Additional.IsContentTitleBreakLine)
                    {
                        parsedContent = parsedContent.Replace("  ", !contextInfo.IsInnerElement ? "<br />" : string.Empty);
                    }
                }
                else if (BackgroundContentAttribute.Summary.ToLower().Equals(type))
                {
                    parsedContent = InputTypeUtils.ParseString(InputType.TextArea, contentInfo.GetString(BackgroundContentAttribute.Summary), replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                }
                else if (BackgroundContentAttribute.Content.ToLower().Equals(type))
                {
                    parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.Content), pageInfo.IsLocal);

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }

                    if (!string.IsNullOrEmpty(formatString))
                    {
                        parsedContent = string.Format(formatString, parsedContent);
                    }
                }
                else if (ContentAttribute.PageContent.ToLower().Equals(type))
                {
                    //if (contextInfo.IsInnerElement)
                    // {
                    parsedContent = ContentUtility.TextEditorContentDecode(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.Content), pageInfo.IsLocal);

                    if (isClearTags)
                    {
                        parsedContent = StringUtils.StripTags(parsedContent);
                    }

                    if (!string.IsNullOrEmpty(replace))
                    {
                        parsedContent = StringUtils.Replace(replace, parsedContent, to);
                    }

                    if (wordNum > 0 && !string.IsNullOrEmpty(parsedContent))
                    {
                        parsedContent = StringUtils.MaxLengthText(parsedContent, wordNum, ellipsis);
                    }

                    if (!string.IsNullOrEmpty(formatString))
                    {
                        parsedContent = string.Format(formatString, parsedContent);
                    }
                }
                else if (ContentAttribute.AddDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.AddDate, formatString);
                }
                else if (ContentAttribute.LastEditDate.ToLower().Equals(type))
                {
                    parsedContent = DateUtils.Format(contentInfo.LastEditDate, formatString);
                }
                else if (BackgroundContentAttribute.ImageUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        //第一条
                        sbParsedContent.Append(contextInfo.IsStlEntity
                            ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo,
                                                             contentInfo.GetString(BackgroundContentAttribute.ImageUrl), pageInfo.IsLocal)
                            : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo,
                                                                     contentInfo.GetString(BackgroundContentAttribute.ImageUrl),
                                                                     contextInfo.Attributes, false));
                        //第n条
                        var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                        var extendValues        = contentInfo.GetString(extendAttributeName);
                        if (!string.IsNullOrEmpty(extendValues))
                        {
                            foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                            {
                                var newExtendValue = extendValue;
                                sbParsedContent.Append(contextInfo.IsStlEntity
                                    ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, newExtendValue, pageInfo.IsLocal)
                                    : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo,
                                                                             newExtendValue, contextInfo.Attributes, false));
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no, 0);
                        if (num <= 1)
                        {
                            parsedContent = contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.ImageUrl), contextInfo.Attributes, false);
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.ImageUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    var newExtendValue = extendValue;
                                    if (index == num)
                                    {
                                        parsedContent = contextInfo.IsStlEntity ? PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, newExtendValue, pageInfo.IsLocal) : InputParserUtility.GetImageOrFlashHtml(pageInfo.SiteInfo, newExtendValue, contextInfo.Attributes, false);
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.VideoUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        //第一条
                        sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.VideoUrl), contextInfo.Attributes, contextInfo.IsStlEntity));

                        //第n条
                        var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl);
                        var extendValues        = contentInfo.GetString(extendAttributeName);
                        if (!string.IsNullOrEmpty(extendValues))
                        {
                            foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                            {
                                sbParsedContent.Append(InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity));
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no, 0);
                        if (num <= 1)
                        {
                            parsedContent = InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, contentInfo.GetString(BackgroundContentAttribute.VideoUrl), contextInfo.Attributes, contextInfo.IsStlEntity);
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.VideoUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    if (index == num)
                                    {
                                        parsedContent = InputParserUtility.GetVideoHtml(pageInfo.SiteInfo, extendValue, contextInfo.Attributes, contextInfo.IsStlEntity);
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (BackgroundContentAttribute.FileUrl.ToLower().Equals(type))
                {
                    if (no == "all")
                    {
                        var sbParsedContent = new StringBuilder();
                        if (contextInfo.IsStlEntity)
                        {
                            //第一条
                            sbParsedContent.Append(contentInfo.GetString(BackgroundContentAttribute.FileUrl));
                            //第n条
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    sbParsedContent.Append(extendValue);
                                }
                            }
                        }
                        else
                        {
                            //第一条
                            sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.GetString(BackgroundContentAttribute.FileUrl), contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper));
                            //第n条
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    sbParsedContent.Append(InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, extendValue, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper));
                                }
                            }
                        }

                        parsedContent = sbParsedContent.ToString();
                    }
                    else
                    {
                        var num = TranslateUtils.ToInt(no, 0);
                        if (contextInfo.IsStlEntity)
                        {
                            if (num <= 1)
                            {
                                parsedContent = contentInfo.GetString(BackgroundContentAttribute.FileUrl);
                            }
                            else
                            {
                                var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                                var extendValues        = contentInfo.GetString(extendAttributeName);
                                if (!string.IsNullOrEmpty(extendValues))
                                {
                                    var index = 2;
                                    foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                    {
                                        if (index == num)
                                        {
                                            parsedContent = extendValue;
                                            break;
                                        }
                                        index++;
                                    }
                                }
                            }

                            if (!string.IsNullOrEmpty(parsedContent))
                            {
                                parsedContent = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, parsedContent, pageInfo.IsLocal);
                            }
                        }
                        else
                        {
                            if (num <= 1)
                            {
                                parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, contentInfo.GetString(BackgroundContentAttribute.FileUrl), contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper);
                            }
                            else
                            {
                                var extendAttributeName = ContentAttribute.GetExtendAttributeName(BackgroundContentAttribute.FileUrl);
                                var extendValues        = contentInfo.GetString(extendAttributeName);
                                if (!string.IsNullOrEmpty(extendValues))
                                {
                                    var index = 2;
                                    foreach (string extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                    {
                                        if (index == num)
                                        {
                                            parsedContent = InputParserUtility.GetFileHtmlWithCount(pageInfo.SiteInfo, contentInfo.ChannelId, contentInfo.Id, extendValue, contextInfo.Attributes, contextInfo.InnerHtml, false, isLower, isUpper);
                                            break;
                                        }
                                        index++;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (ContentAttribute.NavigationUrl.ToLower().Equals(type))
                {
                    parsedContent = PageUtility.GetContentUrl(pageInfo.SiteInfo, contentInfo, pageInfo.IsLocal);
                }
                else if (ContentAttribute.Tags.ToLower().Equals(type))
                {
                    parsedContent = contentInfo.Tags;
                }
                else if (StringUtils.StartsWithIgnoreCase(type, StlParserUtility.ItemIndex) && contextInfo.ItemContainer?.ContentItem != null)
                {
                    var itemIndex = StlParserUtility.ParseItemIndex(contextInfo.ItemContainer.ContentItem.ItemIndex, type, contextInfo);
                    parsedContent = !string.IsNullOrEmpty(formatString) ? string.Format(formatString, itemIndex) : itemIndex.ToString();
                }
                else if (ContentAttribute.AddUserName.ToLower().Equals(type))
                {
                    if (!string.IsNullOrEmpty(contentInfo.AddUserName))
                    {
                        parsedContent = contentInfo.AddUserName;
                    }
                }
                else
                {
                    var nodeInfo = ChannelManager.GetChannelInfo(pageInfo.SiteId, contentInfo.ChannelId);

                    if (contentInfo.ContainsKey(type))
                    {
                        if (!StringUtils.ContainsIgnoreCase(ContentAttribute.AllAttributes.Value, type))
                        {
                            var relatedIdentities = TableStyleManager.GetRelatedIdentities(nodeInfo);
                            var tableName         = ChannelManager.GetTableName(pageInfo.SiteInfo, nodeInfo);
                            var styleInfo         = TableStyleManager.GetTableStyleInfo(tableName, type, relatedIdentities);

                            //styleInfo.IsVisible = false 表示此字段不需要显示 styleInfo.TableStyleId = 0 不能排除,因为有可能是直接辅助表字段没有添加显示样式
                            var num = TranslateUtils.ToInt(no);
                            parsedContent = InputParserUtility.GetContentByTableStyle(contentInfo, separator, pageInfo.SiteInfo, styleInfo, formatString, num, contextInfo.Attributes, contextInfo.InnerHtml, false);
                            parsedContent = InputTypeUtils.ParseString(styleInfo.InputType, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                        else
                        {
                            parsedContent = contentInfo.GetString(type);
                            parsedContent = InputTypeUtils.ParseString(InputType.Text, parsedContent, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(parsedContent))
                {
                    parsedContent = leftText + parsedContent + rightText;
                }
            }

            return(parsedContent);
        }
コード例 #26
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();
                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.SiteAdd))
                {
                    return(Unauthorized());
                }

                var siteTemplates = SiteTemplateManager.Instance.GetSiteTemplateSortedList();

                var siteList = new List <KeyValuePair <int, string> >
                {
                    new KeyValuePair <int, string>(0, "<无上级站点>")
                };

                var siteIdList         = SiteManager.GetSiteIdList();
                var siteInfoList       = new List <SiteInfo>();
                var parentWithChildren = new Dictionary <int, List <SiteInfo> >();
                foreach (var siteId in siteIdList)
                {
                    var siteInfo = SiteManager.GetSiteInfo(siteId);
                    if (siteInfo.IsRoot == false)
                    {
                        if (siteInfo.ParentId == 0)
                        {
                            siteInfoList.Add(siteInfo);
                        }
                        else
                        {
                            var children = new List <SiteInfo>();
                            if (parentWithChildren.ContainsKey(siteInfo.ParentId))
                            {
                                children = parentWithChildren[siteInfo.ParentId];
                            }
                            children.Add(siteInfo);
                            parentWithChildren[siteInfo.ParentId] = children;
                        }
                    }
                }
                foreach (SiteInfo siteInfo in siteInfoList)
                {
                    AddSite(siteList, siteInfo, parentWithChildren, 0);
                }

                var tableNameList = SiteManager.GetSiteTableNames();

                var isRootExists = SiteManager.GetSiteInfoByIsRoot() != null;

                return(Ok(new
                {
                    Value = siteTemplates.Values,
                    IsRootExists = isRootExists,
                    SiteList = siteList,
                    TableNameList = tableNameList
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
コード例 #27
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId", "RootPath", "CurrentRootPath", "HiddenClientID");

            _rootPath        = AuthRequest.GetQueryString("RootPath").TrimEnd('/');
            _currentRootPath = AuthRequest.GetQueryString("CurrentRootPath");
            _hiddenClientId  = AuthRequest.GetQueryString("HiddenClientID");

            if (string.IsNullOrEmpty(_currentRootPath))
            {
                _currentRootPath = SiteInfo.Additional.ConfigSelectFileCurrentUrl.TrimEnd('/');
            }
            else
            {
                SiteInfo.Additional.ConfigSelectFileCurrentUrl = _currentRootPath;
                DataProvider.SiteDao.Update(SiteInfo);
            }
            _currentRootPath = _currentRootPath.TrimEnd('/');

            _directoryPath = PathUtility.MapPath(SiteInfo, _currentRootPath);
            DirectoryUtils.CreateDirectoryIfNotExists(_directoryPath);
            if (!DirectoryUtils.IsDirectoryExists(_directoryPath))
            {
                PageUtils.RedirectToErrorPage("文件夹不存在!");
                return;
            }

            if (Page.IsPostBack)
            {
                return;
            }

            BtnUpload.Attributes.Add("onclick", ModalUploadFile.GetOpenWindowStringToList(SiteId, EUploadType.File, _currentRootPath));

            DdlListType.Items.Add(new ListItem("显示缩略图", "Image"));
            DdlListType.Items.Add(new ListItem("显示详细信息", "List"));
            if (AuthRequest.IsQueryExists("ListType"))
            {
                ControlUtils.SelectSingleItem(DdlListType, AuthRequest.GetQueryString("ListType"));
            }

            var previousUrls = Session["PreviousUrls"] as ArrayList ?? new ArrayList();
            var currentUrl   = GetRedirectUrl(_currentRootPath);

            if (previousUrls.Count > 0)
            {
                var url = previousUrls[previousUrls.Count - 1] as string;
                if (!string.Equals(url, currentUrl))
                {
                    previousUrls.Add(currentUrl);
                    Session["PreviousUrls"] = previousUrls;
                }
            }
            else
            {
                previousUrls.Add(currentUrl);
                Session["PreviousUrls"] = previousUrls;
            }

            var navigationBuilder   = new StringBuilder();
            var directoryNames      = _currentRootPath.Split('/');
            var linkCurrentRootPath = _rootPath;

            foreach (var directoryName in directoryNames)
            {
                if (!string.IsNullOrEmpty(directoryName))
                {
                    if (directoryName.Equals("~"))
                    {
                        navigationBuilder.Append($"<a href='{GetRedirectUrl(_rootPath)}'>根目录</a>");
                    }
                    else if (directoryName.Equals("@"))
                    {
                        navigationBuilder.Append(
                            $"<a href='{GetRedirectUrl(_rootPath)}'>{SiteManager.GetSiteInfo(SiteId).SiteDir}</a>");
                    }
                    else
                    {
                        linkCurrentRootPath += "/" + directoryName;
                        navigationBuilder.Append($"<a href='{GetRedirectUrl(linkCurrentRootPath)}'>{directoryName}</a>");
                    }
                    navigationBuilder.Append("\\");
                }
            }
            LtlCurrentDirectory.Text = navigationBuilder.ToString();

            FillFileSystems(false);
        }
コード例 #28
0
ファイル: SiteApi.cs プロジェクト: zhangjingpu/cms-1
 public List <int> GetSiteIdList()
 {
     return(SiteManager.GetSiteIdList());
 }
コード例 #29
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId            = request.GetQueryInt("siteId");
                var channelId         = request.GetQueryInt("channelId");
                var channelContentIds =
                    MinContentInfo.ParseMinContentInfoList(request.GetQueryString("channelContentIds"));

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasChannelPermissions(siteId, channelId,
                                                                        ConfigManager.ChannelPermissions.ContentTranslate))
                {
                    return(Unauthorized());
                }

                var siteInfo = SiteManager.GetSiteInfo(siteId);
                if (siteInfo == null)
                {
                    return(BadRequest("无法确定内容对应的站点"));
                }

                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);
                if (channelInfo == null)
                {
                    return(BadRequest("无法确定内容对应的栏目"));
                }

                var retVal = new List <Dictionary <string, object> >();
                foreach (var channelContentId in channelContentIds)
                {
                    var contentChannelInfo = ChannelManager.GetChannelInfo(siteId, channelContentId.ChannelId);
                    var contentInfo        = ContentManager.GetContentInfo(siteInfo, contentChannelInfo, channelContentId.Id);
                    if (contentInfo == null)
                    {
                        continue;
                    }

                    var dict = contentInfo.ToDictionary();
                    dict["checkState"] =
                        CheckManager.GetCheckState(siteInfo, contentInfo);
                    retVal.Add(dict);
                }

                var sites    = new List <object>();
                var channels = new List <object>();

                var siteIdList = request.AdminPermissions.GetSiteIdList();
                foreach (var permissionSiteId in siteIdList)
                {
                    var permissionSiteInfo = SiteManager.GetSiteInfo(permissionSiteId);
                    sites.Add(new
                    {
                        permissionSiteInfo.Id,
                        permissionSiteInfo.SiteName
                    });
                }

                var channelIdList = request.AdminPermissions.GetChannelIdList(siteInfo.Id,
                                                                              ConfigManager.ChannelPermissions.ContentAdd);
                foreach (var permissionChannelId in channelIdList)
                {
                    var permissionChannelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, permissionChannelId);
                    channels.Add(new
                    {
                        permissionChannelInfo.Id,
                        ChannelName = ChannelManager.GetChannelNameNavigation(siteInfo.Id, permissionChannelId)
                    });
                }

                return(Ok(new
                {
                    Value = retVal,
                    Sites = sites,
                    Channels = channels,
                    Site = siteInfo
                }));
            }
            catch (Exception ex)
            {
                LogUtils.AddErrorLog(ex);
                return(InternalServerError(ex));
            }
        }
コード例 #30
0
ファイル: SiteApi.cs プロジェクト: zhangjingpu/cms-1
 public ISiteInfo GetSiteInfo(int siteId)
 {
     return(SiteManager.GetSiteInfo(siteId));
 }
コード例 #31
0
 public Task<string> RecognizeAsync(Stream imageStream, SiteManager site)
 {
     var tcs = new TaskCompletionSource<string>();
     var adb = new AlertDialog.Builder(Context);
     using (var inflater = LayoutInflater.From(adb.Context))
     {
         var view = inflater.Inflate(Resource.Layout.VerificationCodeInput, null);
         var imageView = view.FindViewById<ImageView>(Resource.Id.verificationImageView);
         var editText = view.FindViewById<EditText>(Resource.Id.verificationEditText);
         imageView.SetImageBitmap(BitmapFactory.DecodeStream(imageStream));
         adb.SetView(view)
             .SetPositiveButton("确定", (_, e) =>
             {
                 tcs.SetResult(editText.Text);
             })
             .SetNegativeButton("取消", (_, e) =>
             {
                 tcs.SetResult(null);
             })
             .Show();
         editText.RequestFocus();
     }
     return tcs.Task;
 }
コード例 #32
0
ファイル: SiteApi.cs プロジェクト: zhangjingpu/cms-1
 public List <ISiteInfo> GetSiteInfoList(string adminName)
 {
     return(SiteManager.GetWritingSiteInfoList(adminName));
 }
コード例 #33
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (string.IsNullOrEmpty(AuthRequest.GetQueryString("startDate")))
            {
                _begin = DateTime.Now.AddMonths(-1);
                _end   = DateTime.Now;
            }
            else
            {
                _begin = TranslateUtils.ToDateTime(AuthRequest.GetQueryString("startDate"));
                _end   = TranslateUtils.ToDateTime(AuthRequest.GetQueryString("endDate"));
            }
            var siteIdList = SiteManager.GetSiteIdListOrderByLevel();

            if (SiteId == 0 && siteIdList.Count > 0)
            {
                PageUtils.Redirect(GetRedirectUrl(siteIdList[0], DateUtils.GetDateAndTimeString(_begin), DateUtils.GetDateAndTimeString(_end)));
                return;
            }

            if (IsPostBack)
            {
                return;
            }

            VerifySystemPermissions(ConfigManager.SettingsPermissions.Chart);

            foreach (var siteId in siteIdList)
            {
                var siteInfo = SiteManager.GetSiteInfo(siteId);
                DdlSiteId.Items.Add(new ListItem(siteInfo.SiteName, siteId.ToString()));
            }
            ControlUtils.SelectSingleItem(DdlSiteId, SiteId.ToString());

            TbStartDate.Text = DateUtils.GetDateAndTimeString(_begin);
            TbEndDate.Text   = DateUtils.GetDateAndTimeString(_end);

            if (SiteInfo == null)
            {
                PhAnalysis.Visible = false;
                return;
            }

            var ds = DataProvider.ContentDao.GetDataSetOfAdminExcludeRecycle(SiteInfo.TableName, SiteId, _begin, _end);

            if (ds == null || ds.Tables.Count <= 0)
            {
                return;
            }

            var dt = ds.Tables[0];

            if (dt.Rows.Count <= 0)
            {
                return;
            }

            foreach (DataRow dr in dt.Rows)
            {
                SetXHashtableUser(dr["userName"].ToString(), dr["userName"].ToString());
                SetYHashtableUser(dr["userName"].ToString(), TranslateUtils.ToInt(dr["addCount"].ToString()), YTypeNew);
                SetYHashtableUser(dr["userName"].ToString(), TranslateUtils.ToInt(dr["updateCount"].ToString()), YTypeUpdate);
            }

            foreach (var key in _userNameList)
            {
                var yValueNew    = GetYHashtableUser(key, YTypeNew);
                var yValueUpdate = GetYHashtableUser(key, YTypeUpdate);
                StrArray += $@"
xArrayNew.push('{GetXHashtableUser(key)}');
yArrayNew.push('{yValueNew}');
yArrayUpdate.push('{yValueUpdate}');";
            }

            SpContents.ControlToPaginate = RptContents;
            RptContents.ItemDataBound   += RptContents_ItemDataBound;
            SpContents.ItemsPerPage      = Constants.PageSize;
            SpContents.SortField         = "UserName";
            SpContents.SortMode          = SortMode.DESC;

            SpContents.SelectCommand = DataProvider.ContentDao.GetSqlStringOfAdminExcludeRecycle(SiteInfo.TableName, SiteId, _begin, _end);

            SpContents.DataBind();
        }
コード例 #34
0
    public void LoadPermissionsView(string categoryId, string categoryName)
    {
        lblCategoryName.Text = categoryName;

        const string allGroupsLabel    = "All Groups";
        const string allLocationsLabel = "All Sites";

        IList <string> viewingItems      = new List <string>();
        IList <string> editingItems      = new List <string>();
        IList <string> contributingItems = new List <string>();

        if (!string.IsNullOrEmpty(categoryId))
        {
            foreach (Access access in AccessManager.GetItemAccess(categoryId))
            {
                string personType = string.Empty;
                string site       = string.Empty;

                if (access.AllPersonTypes)
                {
                    personType = allGroupsLabel;
                }
                else
                {
                    if (!string.IsNullOrEmpty(access.PersonTypeId))
                    {
                        personType = PersonManager.GetPersonTypeById(access.PersonTypeId).Name;
                    }
                }

                if (access.AllSites)
                {
                    site = allLocationsLabel;
                }
                else
                {
                    if (!string.IsNullOrEmpty(access.SiteId))
                    {
                        site = SiteManager.GetSiteById(access.SiteId).Name;
                    }
                }

                if (!string.IsNullOrEmpty(personType) && !string.IsNullOrEmpty(site))
                {
                    string listItem = string.Format("{0} from {1}", personType, site);
                    if (access.AccessType == AccessType.View)
                    {
                        viewingItems.Add(listItem);
                    }
                    else if (access.AccessType == AccessType.Edit)
                    {
                        editingItems.Add(listItem);
                    }
                    else if (access.AccessType == AccessType.Contribute)
                    {
                        contributingItems.Add(listItem);
                    }
                }
            }
        }

        lstSummaryViewing.DataSource = viewingItems;
        lstSummaryViewing.DataBind();
        lstSummaryEditing.DataSource = editingItems;
        lstSummaryEditing.DataBind();
        lstSummaryContributing.DataSource = contributingItems;
        lstSummaryContributing.DataBind();
    }
コード例 #35
0
 private void CreateHomePage(Company company, int userId)
 {
     var manager = new SiteManager(this);
     manager.Save(new WebPage
                      {
                          CompanyId = company.CompanyId,
                          Name = "Página Principal",
                          IsPublished = true,
                          PublishedDate = DateTime.Now,
                          ModifiedDate = DateTime.Now,
                          IsMainPage = true,
                          UserId = userId
                      }, null);
 }
コード例 #36
0
ファイル: StlDynamic.cs プロジェクト: supadmins/cms-1
        public static string ParseDynamicContent(int siteId, int channelId, int contentId, int templateId, bool isPageRefresh, string templateContent, string pageUrl, int pageIndex, string ajaxDivId, NameValueCollection queryString, IUserInfo userInfo)
        {
            var templateInfo = TemplateManager.GetTemplateInfo(siteId, templateId);
            //TemplateManager.GetTemplateInfo(siteID, channelID, templateType);
            var siteInfo = SiteManager.GetSiteInfo(siteId);
            var pageInfo = new PageInfo(channelId, contentId, siteInfo, templateInfo, new Dictionary <string, object>())
            {
                UniqueId = 1000,
                UserInfo = userInfo
            };
            var contextInfo = new ContextInfo(pageInfo);

            templateContent = StlRequestEntities.ParseRequestEntities(queryString, templateContent);
            var contentBuilder = new StringBuilder(templateContent);
            var stlElementList = StlParserUtility.GetStlElementList(contentBuilder.ToString());

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

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

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, false);
                        contentBuilder.Replace(stlPageContentsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

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

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

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageChannelsElementParser.Parse(currentPageIndex, pageCount);
                        contentBuilder.Replace(stlPageChannelsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

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

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

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        var pageHtml = pageSqlContentsElementParser.Parse(currentPageIndex, pageCount);
                        contentBuilder.Replace(stlPageSqlContentsElementReplaceString, pageHtml);

                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, ajaxDivId);

                        break;
                    }
                }
            }

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

                for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
                {
                    if (currentPageIndex == pageIndex)
                    {
                        StlParserManager.ReplacePageElementsInDynamicPage(contentBuilder, pageInfo, stlElementList, pageUrl, pageInfo.PageChannelId, currentPageIndex, pageCount, totalNum, isPageRefresh, pageContentsAjaxDivId);

                        break;
                    }
                }
            }

            StlParserManager.ParseInnerContent(contentBuilder, pageInfo, contextInfo);

            //var parsedContent = StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo);
            //return pageInfo.HeadCodesHtml + pageInfo.BodyCodesHtml + parsedContent + pageInfo.FootCodesHtml;
            return(StlParserUtility.GetBackHtml(contentBuilder.ToString(), pageInfo));
        }
		/// <summary>
		///     Assembles the data for SiteManager and attempts to create a new Site.
		/// </summary>
		private void CreateNewSite()
		{
			IList<ID> languages = (from ListItem item in this.cblLanguages.Items where item.Selected select global::Sitecore.Data.ID.Parse(item.Value)).ToList();

			var newSite = new NewSiteSettings(
				this.txtSiteName.Text,
				this.ddSiteBlueprint.SelectedValue,
				this.ddSiteType.SelectedValue,
				this.txtVirtualFolderName.Text,
				global::Sitecore.Data.ID.Parse(this.ddDefaultLanguage.SelectedValue),
				languages);

			var result = new SiteManager().CreateSite(newSite);

			this.txtResults.Text = result.Log;
			this.txtConfigs.Text = string.Join("\n\n", result.SiteConfigFileChanges);

			this.Results.Text = result.Success ?
					@"<div class=""alert-success""><strong>Success!</strong> Site Created Successfully.</div>" :
					@"<div class=""alert-error""><strong>Error!</strong> Please check log for more information.</div>";
		}
コード例 #38
0
        private static string ParseImpl(PageInfo pageInfo, ContextInfo contextInfo, HtmlImage stlImage, bool isGetPicUrlFromAttribute, string channelIndex, string channelName, int upLevel, int topLevel, string type, int no, bool isOriginal, string src, string altSrc)
        {
            var parsedContent = string.Empty;

            var contentId = 0;

            //判断是否图片地址由标签属性获得
            if (!isGetPicUrlFromAttribute)
            {
                contentId = contextInfo.ContentId;
            }
            var contextType = contextInfo.ContextType;

            var picUrl = string.Empty;

            if (!string.IsNullOrEmpty(src))
            {
                picUrl = src;
            }
            else
            {
                if (contextType == EContextType.Undefined)
                {
                    contextType = contentId != 0 ? EContextType.Content : EContextType.Channel;
                }

                if (contextType == EContextType.Content)//获取内容图片
                {
                    var contentInfo = contextInfo.ContentInfo;

                    if (isOriginal)
                    {
                        if (contentInfo != null && contentInfo.ReferenceId > 0 && contentInfo.SourceId > 0)
                        {
                            var targetChannelId = contentInfo.SourceId;
                            //var targetSiteId = DataProvider.ChannelDao.GetSiteId(targetChannelId);
                            var targetSiteId   = StlChannelCache.GetSiteId(targetChannelId);
                            var targetSiteInfo = SiteManager.GetSiteInfo(targetSiteId);
                            var targetNodeInfo = ChannelManager.GetChannelInfo(targetSiteId, targetChannelId);

                            //var targetContentInfo = DataProvider.ContentDao.GetContentInfo(tableStyle, tableName, contentInfo.ReferenceId);
                            var targetContentInfo = ContentManager.GetContentInfo(targetSiteInfo, targetNodeInfo, contentInfo.ReferenceId);
                            if (targetContentInfo != null && targetContentInfo.ChannelId > 0)
                            {
                                contentInfo = targetContentInfo;
                            }
                        }
                    }

                    if (contentInfo == null)
                    {
                        contentInfo = ContentManager.GetContentInfo(pageInfo.SiteInfo, contextInfo.ChannelId, contentId);
                    }

                    if (contentInfo != null)
                    {
                        if (no <= 1)
                        {
                            picUrl = contentInfo.GetString(type);
                        }
                        else
                        {
                            var extendAttributeName = ContentAttribute.GetExtendAttributeName(type);
                            var extendValues        = contentInfo.GetString(extendAttributeName);
                            if (!string.IsNullOrEmpty(extendValues))
                            {
                                var index = 2;
                                foreach (var extendValue in TranslateUtils.StringCollectionToStringList(extendValues))
                                {
                                    if (index == no)
                                    {
                                        picUrl = extendValue;
                                        break;
                                    }
                                    index++;
                                }
                            }
                        }
                    }
                }
                else if (contextType == EContextType.Channel)//获取栏目图片
                {
                    var channelId = StlDataUtility.GetChannelIdByLevel(pageInfo.SiteId, contextInfo.ChannelId, upLevel, topLevel);

                    channelId = StlDataUtility.GetChannelIdByChannelIdOrChannelIndexOrChannelName(pageInfo.SiteId, channelId, channelIndex, channelName);

                    var channel = ChannelManager.GetChannelInfo(pageInfo.SiteId, channelId);

                    picUrl = channel.ImageUrl;
                }
                else if (contextType == EContextType.Each)
                {
                    picUrl = contextInfo.ItemContainer.EachItem.DataItem as string;
                }
            }

            if (string.IsNullOrEmpty(picUrl))
            {
                picUrl = altSrc;
            }

            if (!string.IsNullOrEmpty(picUrl))
            {
                var extension = PathUtils.GetExtension(picUrl);
                if (EFileSystemTypeUtils.IsFlash(extension))
                {
                    parsedContent = StlFlash.Parse(pageInfo, contextInfo);
                }
                else if (EFileSystemTypeUtils.IsPlayer(extension))
                {
                    parsedContent = StlPlayer.Parse(pageInfo, contextInfo);
                }
                else
                {
                    stlImage.Src  = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, picUrl, pageInfo.IsLocal);
                    parsedContent = ControlUtils.GetControlRenderHtml(stlImage);
                }
            }

            return(parsedContent);
        }