void dgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            var mechanismDao = new MechanismDao();

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var publishmentSystemID   = (int)e.Item.DataItem;
                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemID);
                if (publishmentSystemInfo != null)
                {
                    var ltlPublishmentSystemName   = e.Item.FindControl("ltlPublishmentSystemName") as Literal;
                    var ltlPublishmentSystemType   = e.Item.FindControl("ltlPublishmentSystemType") as Literal;
                    var ltlPublishmentSystemAdress = e.Item.FindControl("ltlPublishmentSystemAdress") as Literal;
                    var ltlOperation = e.Item.FindControl("ltlOperation") as Literal;
                    //var ltlChangeType = e.Item.FindControl("ltlChangeType") as Literal;
                    //var ltlDelete = e.Item.FindControl("ltlDelete") as Literal;

                    //var ltUpLink = e.Item.FindControl("ltUpLink") as Literal;
                    //var ltDownLink = e.Item.FindControl("ltDownLink") as Literal;

                    ltlPublishmentSystemName.Text   = GetPublishmentSystemNameHtml(publishmentSystemInfo);
                    ltlPublishmentSystemAdress.Text = publishmentSystemInfo.Address;
                    ltlPublishmentSystemType.Text   = mechanismDao.GetMechanismTypeTextById(publishmentSystemInfo.OrganizationTypeId); //publishmentSystemInfo.OrganizationTypeId.ToString()+"--类型表未建立,此数字代表id";
                    if (HasWebsitePermissions(AppManager.Cms.Permission.WebSite.SiteEdit))
                    {
                        ltlOperation.Text = $@"<a href=""PageSiteEdit.aspx?PublishmentSystemId={publishmentSystemInfo.PublishmentSystemId}"" target=""content"">操作</a>";
                    }
                    else
                    {
                        ltlOperation.Text = $@"<a href=""javascript:void(0)"" target=""content"">无</a>";
                    }

                    var upUrl = PageUtils.GetSysUrl(nameof(PagePublishmentSystem), new NameValueCollection
                    {
                        { "Up", "True" },
                        { "PublishmentSystemID", publishmentSystemID.ToString() }
                    });
                    //ltUpLink.Text = $@"<a href=""{upUrl}""><img src=""../Pic/icon/up.gif"" border=""0"" alt=""上升""/></a>";

                    var downUrl = PageUtils.GetSysUrl(nameof(PagePublishmentSystem), new NameValueCollection
                    {
                        { "Down", "True" },
                        { "PublishmentSystemID", publishmentSystemID.ToString() }
                    });
                    //ltDownLink.Text = $@"<a href=""{downUrl}""><img src=""../Pic/icon/down.gif"" border=""0"" alt=""下降""/></a>";

                    //if (publishmentSystemInfo.ParentPublishmentSystemId == 0 && (_hqSiteId == 0 || publishmentSystemID == _hqSiteId))
                    //{
                    //    ltlChangeType.Text = GetChangeHtml(publishmentSystemID, publishmentSystemInfo.IsHeadquarters);
                    //}

                    //if (publishmentSystemInfo.IsHeadquarters == false)
                    //{
                    //    ltlDelete.Text = $@"<a href=""{PagePublishmentSystemDelete.GetRedirectUrl(publishmentSystemID)}"">删除</a>";
                    //}
                }
            }
        }
Esempio n. 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            var mechanismDao = new MechanismDao();

            if (IsForbidden)
            {
                return;
            }
            if (!HasWebsitePermissions(AppManager.Cms.Permission.WebSite.SiteEdit))
            {
                FailMessage("无站点修改权限");
                return;
            }
            if (!IsPostBack)
            {
                var currentPublishmentSystemId = Body.GetQueryInt("PublishmentSystemId");
                var publishmentSystemInfo      = PublishmentSystemManager.GetPublishmentSystemInfo(currentPublishmentSystemId);
                PublishmentSystemArea.Text = publishmentSystemInfo.Area;
                PublishmentSystemName.Text = publishmentSystemInfo.PublishmentSystemName;
                //PublishmentSystemType.Items.Add(new ListItem(mechanismDao.GetMechanismTypeTextById(PublishmentSystemInfo.OrganizationTypeId), PublishmentSystemInfo.OrganizationTypeId.ToString()));
                //PublishmentSystemCategory.Items.Add(new ListItem((mechanismDao.GetMechanismCategoryTextById(PublishmentSystemInfo.OrganizationCategory)), PublishmentSystemInfo.OrganizationCategory.ToString()));
                TelePhone.Text      = publishmentSystemInfo.TelePhone;
                Address.Text        = publishmentSystemInfo.Address;
                BasicFacts.Text     = publishmentSystemInfo.BasicFacts;
                ImageUrl.Text       = publishmentSystemInfo.ImageUrl;
                Characteristic.Text = publishmentSystemInfo.Characteristic;
                var administratorInfo = BaiRongDataProvider.AdministratorDao.GetByAccount(publishmentSystemInfo.AdministratorAccount);
                AdministratorAccount.Text    = administratorInfo.UserName;
                AdministratorAccount.Enabled = false;
                //AdministratorPassWord.Text = administratorInfo.Password;
                var typeDic     = DataProvider.MechanismDao.GetMechanismTypeAll();
                var categoryDic = DataProvider.MechanismDao.GetMechanismCategoryAll();
                foreach (var type in typeDic)
                {
                    var listItem = new ListItem(type.Value, type.Key.ToString());
                    if (type.Key == publishmentSystemInfo.OrganizationTypeId)
                    {
                        listItem.Selected = true;
                    }
                    CblPublishmentSystemType.Items.Add(listItem);
                }
                foreach (var category in categoryDic)
                {
                    var listItem = new ListItem(category.Value, category.Key.ToString());
                    if (category.Key == publishmentSystemInfo.OrganizationCategory)
                    {
                        listItem.Selected = true;
                    }
                    CblPublishmentSystemCategory.Items.Add(listItem);
                }

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

                List <PermissionConfig> webSitePermissions = new List <PermissionConfig>();
                //var currentWebsitePermissions=
                foreach (PermissionConfig permission in PermissionConfigManager.Instance.WebsitePermissions)
                {
                    //if (permission.Name == websitePermission)
                    //{
                    //    WebsitePermissionsPlaceHolder.Visible = true;
                    //    var listItem = new ListItem(permission.Text, permission.Name);
                    //    WebsitePermissions.Items.Add(listItem);
                    //}
                    if (StringUtils.EqualsIgnoreCase(permission.Type, "party"))
                    {
                        webSitePermissions.Add(permission);
                    }
                }
                rptWebSite.DataSource = webSitePermissions;
                rptWebSite.DataBind();
                for (int i = 0; i < rptWebSite.Items.Count; i++)
                {
                    CheckBoxList cblActionType = (CheckBoxList)rptWebSite.Items[i].FindControl("cblWebSiteType");
                    for (int n = 0; n < cblActionType.Items.Count; n++)
                    {
                        foreach (List <string> list in webSitePermission.Values)
                        {
                            if (list.Contains(cblActionType.Items[n].Value))
                            {
                                cblActionType.Items[n].Selected = true;
                            }
                        }
                    }
                }
            }
        }