Exemplo n.º 1
0
        /// <summary>
        /// 取得後端作業選項身分授權的巢狀清單
        /// </summary>
        public List <OperationWithRoleAuth> GetOperationWithRoleAuthNestedList(string roleName)
        {
            List <OperationWithRoleAuth> entities = null;

            using (EmployeeAuthorityDataAccess empAuthDao = new EmployeeAuthorityDataAccess())
            {
                List <Operations> topOps = empAuthDao.GetList <Operations>(op => op.ParentId == null && !op.IsHideSelf)
                                           .OrderBy(op => op.SortNo).ToList();
                List <Operations> subOps = empAuthDao.GetList <Operations>(op => op.ParentId != null && !op.IsHideSelf)
                                           .OrderBy(op => op.SortNo).ToList();
                List <EmployeeRoleOperationsDesc> roleAuthItems = empAuthDao.GetList <EmployeeRoleOperationsDesc>(ro => ro.RoleName == roleName)
                                                                  .ToList();

                if (topOps != null && subOps != null && roleAuthItems != null)
                {
                    entities = topOps.ConvertAll <OperationWithRoleAuth>(op =>
                    {
                        // top item
                        OperationWithRoleAuth opAuth = new OperationWithRoleAuth();
                        opAuth.ImportDataFrom(op);

                        EmployeeRoleOperationsDesc roleAuthItem = roleAuthItems.Find(ro => ro.OpId == op.OpId);

                        if (roleAuthItem != null)
                        {
                            opAuth.ImportDataFrom(roleAuthItem);
                        }

                        // sub item
                        opAuth.SubItems = subOps.Where(subOp => subOp.ParentId == op.OpId)
                                          .Select(subOp =>
                        {
                            OperationWithRoleAuth subOpAuth = new OperationWithRoleAuth();
                            subOpAuth.ImportDataFrom(subOp);

                            EmployeeRoleOperationsDesc subRoleAuthItem = roleAuthItems.Find(ro => ro.OpId == subOp.OpId);

                            if (subRoleAuthItem != null)
                            {
                                subOpAuth.ImportDataFrom(subRoleAuthItem);
                            }

                            return(subOpAuth);
                        }).ToList();

                        return(opAuth);
                    });
                }

                dbErrMsg = empAuthDao.GetErrMsg();
            }

            return(entities);
        }
Exemplo n.º 2
0
    protected void rptOpItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
        {
            return;
        }

        OperationWithRoleAuth opAuth = (OperationWithRoleAuth)e.Item.DataItem;

        int    opId           = opAuth.OpId;
        string opSubject      = opAuth.OpSubject;
        string englishSubject = opAuth.EnglishSubject;
        bool   isNewWindow    = opAuth.IsNewWindow;
        string encodedUrl     = opAuth.LinkUrl;
        string linkUrl        = c.DecodeUrlOfMenu(encodedUrl);

        if (useEnglishSubject && !string.IsNullOrEmpty(englishSubject))
        {
            opSubject = englishSubject;
        }

        HtmlGenericControl OpItemArea = (HtmlGenericControl)e.Item.FindControl("OpItemArea");

        OpItemArea.Attributes.Add("opId", opId.ToString());

        HtmlAnchor btnOpItem = (HtmlAnchor)e.Item.FindControl("btnOpItem");

        btnOpItem.Title = opSubject;

        if (isNewWindow)
        {
            btnOpItem.Target = "_blank";
            btnOpItem.Title += Resources.Lang.HintTail_OpenNewWindow;
        }

        if (linkUrl != "")
        {
            if (linkUrl.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) ||
                linkUrl.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
            {
                //外部網址
                if (!isNewWindow)
                {
                    linkUrl = "~/Embedded-Content.aspx?url=" + Server.UrlEncode(encodedUrl);
                }
            }
            else
            {
                linkUrl = "~/" + linkUrl;
            }

            btnOpItem.HRef = linkUrl;
        }

        HtmlImage imgOpItem = (HtmlImage)e.Item.FindControl("imgOpItem");

        imgOpItem.Alt = opSubject;
        imgOpItem.Src = "~/BPimages/icon/data.gif";
        string iconImageFile = opAuth.IconImageFile;

        if (!string.IsNullOrEmpty(iconImageFile))
        {
            imgOpItem.Src = string.Format("~/BPimages/icon/{0}", iconImageFile);
        }

        Literal ltrOpItemSubject = (Literal)e.Item.FindControl("ltrOpItemSubject");

        ltrOpItemSubject.Text = opSubject;

        //檢查授權
        bool canRead = opAuth.CanRead;

        OpItemArea.Visible = canRead;
    }
Exemplo n.º 3
0
    protected void rptOpMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
        {
            return;
        }

        OperationWithRoleAuth opAuth = (OperationWithRoleAuth)e.Item.DataItem;

        int    opId           = opAuth.OpId;
        string opSubject      = opAuth.OpSubject;
        string englishSubject = opAuth.EnglishSubject;
        bool   isNewWindow    = opAuth.IsNewWindow;
        string encodedUrl     = opAuth.LinkUrl;
        string linkUrl        = c.DecodeUrlOfMenu(encodedUrl);

        if (useEnglishSubject && !string.IsNullOrEmpty(englishSubject))
        {
            opSubject = englishSubject;
        }

        HtmlGenericControl OpHeaderArea = (HtmlGenericControl)e.Item.FindControl("OpHeaderArea");

        OpHeaderArea.Attributes.Add("opId", opId.ToString());

        HtmlAnchor btnOpHeader = (HtmlAnchor)e.Item.FindControl("btnOpHeader");

        btnOpHeader.Title = opSubject;

        if (isNewWindow)
        {
            btnOpHeader.Target = "_blank";
            btnOpHeader.Title += Resources.Lang.HintTail_OpenNewWindow;
        }

        if (linkUrl != "")
        {
            if (linkUrl.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) ||
                linkUrl.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
            {
                //外部網址
                if (!isNewWindow)
                {
                    linkUrl = "~/Embedded-Content.aspx?url=" + Server.UrlEncode(encodedUrl);
                }
            }
            else
            {
                linkUrl = "~/" + linkUrl;
            }

            btnOpHeader.HRef = linkUrl;
        }

        HtmlImage imgOpHeader = (HtmlImage)e.Item.FindControl("imgOpHeader");

        imgOpHeader.Alt = opSubject;
        imgOpHeader.Src = "~/BPimages/icon/data.gif";
        string iconImageFile = opAuth.IconImageFile;

        if (!string.IsNullOrEmpty(iconImageFile))
        {
            imgOpHeader.Src = string.Format("~/BPimages/icon/{0}", iconImageFile);
        }

        Literal ltrOpHeaderSubject = (Literal)e.Item.FindControl("ltrOpHeaderSubject");

        ltrOpHeaderSubject.Text = opSubject;

        if (opIdOfArticleMgmt != 0 && opId == opIdOfArticleMgmt)
        {
            string noticeIconOfHoverToExpand = "<span class='hover-intent-notice float-right' title='hover to expand' style='display:none;'><i class='fa fa-hand-o-up'></i><i class='fa fa-hourglass-start'></i></span>";
            ltrOpHeaderSubject.Text += noticeIconOfHoverToExpand;
        }

        //檢查授權
        bool canRead = opAuth.CanRead;

        OpHeaderArea.Visible = canRead;
        Repeater rptOpItems  = (Repeater)e.Item.FindControl("rptOpItems");
        Repeater rptArticles = (Repeater)e.Item.FindControl("rptArticles");

        if (opIdOfArticleMgmt != 0 && opId == opIdOfArticleMgmt)
        {
            // articles
            rptOpItems.Visible = false;

            List <ArticleMultiLangForOpMenu> subitems = GetSubitemsOfArticle(Guid.Empty);  //Guid.Empty: root articleId

            if (subitems != null)
            {
                rptArticles.Visible    = true;
                rptArticles.DataSource = subitems;
                rptArticles.DataBind();
            }
        }
        else
        {
            // sub-operations
            rptOpItems.DataSource = opAuth.SubItems;
            rptOpItems.DataBind();
        }
    }
Exemplo n.º 4
0
    protected void rptOperations_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        OperationWithRoleAuth opAuth = (OperationWithRoleAuth)e.Item.DataItem;

        int    opId                   = opAuth.OpId;
        string opSubject              = opAuth.OpSubject;
        bool   canRead                = opAuth.CanRead;
        bool   canEdit                = opAuth.CanEdit;
        bool   canReadSubItemOfSelf   = opAuth.CanReadSubItemOfSelf;
        bool   canEditSubItemOfSelf   = opAuth.CanEditSubItemOfSelf;
        bool   canAddSubItemOfSelf    = opAuth.CanAddSubItemOfSelf;
        bool   canDelSubItemOfSelf    = opAuth.CanDelSubItemOfSelf;
        bool   canReadSubItemOfCrew   = opAuth.CanReadSubItemOfCrew;
        bool   canEditSubItemOfCrew   = opAuth.CanEditSubItemOfCrew;
        bool   canDelSubItemOfCrew    = opAuth.CanDelSubItemOfCrew;
        bool   canReadSubItemOfOthers = opAuth.CanReadSubItemOfOthers;
        bool   canEditSubItemOfOthers = opAuth.CanEditSubItemOfOthers;
        bool   canDelSubItemOfOthers  = opAuth.CanDelSubItemOfOthers;

        if (c.seCultureNameOfBackend == "en")
        {
            opSubject = opAuth.EnglishSubject;
        }

        string   lastMdfAccount = "";
        DateTime?lastMdfDate    = null;

        if (opAuth.MdfDate.HasValue)
        {
            lastMdfAccount = opAuth.MdfAccount;
            lastMdfDate    = opAuth.MdfDate;
        }
        else if (opAuth.PostDate.HasValue)
        {
            lastMdfAccount = opAuth.PostAccount;
            lastMdfDate    = opAuth.PostDate;
        }

        HtmlTableRow OpArea = (HtmlTableRow)e.Item.FindControl("OpArea");

        OpArea.Attributes.Add("opid", opId.ToString());

        Literal ltrSeqno = (Literal)e.Item.FindControl("ltrSeqno");

        if (sender == rptOperations)
        {
            OpArea.Attributes["class"] += " lv1";
            tempLv1Seqno  = e.Item.ItemIndex + 1;
            ltrSeqno.Text = tempLv1Seqno.ToString();
        }
        else
        {
            OpArea.Attributes["class"] += " lv2";
            ltrSeqno.Text = string.Format("{0}-{1}", tempLv1Seqno, e.Item.ItemIndex + 1);
        }

        HtmlImage imgOpItem = (HtmlImage)e.Item.FindControl("imgOpItem");

        imgOpItem.Alt = opSubject;
        imgOpItem.Src = "~/BPimages/icon/data.gif";
        string iconImageFile = opAuth.IconImageFile;

        if (!string.IsNullOrEmpty(iconImageFile))
        {
            imgOpItem.Src = string.Format("~/BPimages/icon/{0}", iconImageFile);
        }

        Literal ltrOpItemSubject = (Literal)e.Item.FindControl("ltrOpItemSubject");

        ltrOpItemSubject.Text = opSubject;

        if (lastMdfDate.HasValue)
        {
            Literal ltrLastUpdateInfo = (Literal)e.Item.FindControl("ltrLastUpdateInfo");

            string modificationInfo = string.Format(
                "<span class='mdf-info text-info' title='{0}: {1}, {2:yyyy-MM-dd HH:mm:ss}'><i class='fa fa-info-circle'></i></span>",
                Resources.Lang.Col_LastUpdate, lastMdfAccount, lastMdfDate);
            ltrLastUpdateInfo.Text = " " + modificationInfo;
        }

        Literal         ltrPvgOfItem = (Literal)e.Item.FindControl("ltrPvgOfItem");
        HtmlInputHidden hidPvgOfItem = (HtmlInputHidden)e.Item.FindControl("hidPvgOfItem");
        int             pvgOfItem    = 0;

        if (!canRead)
        {
            ltrPvgOfItem.Text += tagHtmlNotAllowed;
        }

        if (canRead)
        {
            ltrPvgOfItem.Text += tagHtmlRead;
            pvgOfItem         |= 1;
            hidPvgOfItem.Value = pvgOfItem.ToString();
        }

        if (canEdit)
        {
            ltrPvgOfItem.Text += tagHtmlEdit;
            pvgOfItem         |= 2;
            hidPvgOfItem.Value = pvgOfItem.ToString();
        }

        Literal         ltrPvgOfSubitemSelf = (Literal)e.Item.FindControl("ltrPvgOfSubitemSelf");
        HtmlInputHidden hidPvgOfSubitemSelf = (HtmlInputHidden)e.Item.FindControl("hidPvgOfSubitemSelf");
        int             pvgOfSubitemSelf    = 0;

        if (!canReadSubItemOfSelf)
        {
            ltrPvgOfSubitemSelf.Text += tagHtmlNotAllowed;
        }

        if (canReadSubItemOfSelf)
        {
            ltrPvgOfSubitemSelf.Text += tagHtmlRead;
            pvgOfSubitemSelf         |= 1;
            hidPvgOfSubitemSelf.Value = pvgOfSubitemSelf.ToString();
        }

        if (canEditSubItemOfSelf)
        {
            ltrPvgOfSubitemSelf.Text += tagHtmlEdit;
            pvgOfSubitemSelf         |= 2;
            hidPvgOfSubitemSelf.Value = pvgOfSubitemSelf.ToString();
        }

        if (canAddSubItemOfSelf)
        {
            ltrPvgOfSubitemSelf.Text += tagHtmlAdd;
            pvgOfSubitemSelf         |= 4;
            hidPvgOfSubitemSelf.Value = pvgOfSubitemSelf.ToString();
        }

        if (canDelSubItemOfSelf)
        {
            ltrPvgOfSubitemSelf.Text += tagHtmlDelete;
            pvgOfSubitemSelf         |= 8;
            hidPvgOfSubitemSelf.Value = pvgOfSubitemSelf.ToString();
        }

        Literal         ltrPvgOfSubitemCrew = (Literal)e.Item.FindControl("ltrPvgOfSubitemCrew");
        HtmlInputHidden hidPvgOfSubitemCrew = (HtmlInputHidden)e.Item.FindControl("hidPvgOfSubitemCrew");
        int             pvgOfSubitemCrew    = 0;

        if (!canReadSubItemOfCrew)
        {
            ltrPvgOfSubitemCrew.Text += tagHtmlNotAllowed;
        }

        if (canReadSubItemOfCrew)
        {
            ltrPvgOfSubitemCrew.Text += tagHtmlRead;
            pvgOfSubitemCrew         |= 1;
            hidPvgOfSubitemCrew.Value = pvgOfSubitemCrew.ToString();
        }

        if (canEditSubItemOfCrew)
        {
            ltrPvgOfSubitemCrew.Text += tagHtmlEdit;
            pvgOfSubitemCrew         |= 2;
            hidPvgOfSubitemCrew.Value = pvgOfSubitemCrew.ToString();
        }

        if (canDelSubItemOfCrew)
        {
            ltrPvgOfSubitemCrew.Text += tagHtmlDelete;
            pvgOfSubitemCrew         |= 8;
            hidPvgOfSubitemCrew.Value = pvgOfSubitemCrew.ToString();
        }

        Literal         ltrPvgOfSubitemOthers = (Literal)e.Item.FindControl("ltrPvgOfSubitemOthers");
        HtmlInputHidden hidPvgOfSubitemOthers = (HtmlInputHidden)e.Item.FindControl("hidPvgOfSubitemOthers");
        int             pvgOfSubitemOthers    = 0;

        if (!canReadSubItemOfOthers)
        {
            ltrPvgOfSubitemOthers.Text += tagHtmlNotAllowed;
        }

        if (canReadSubItemOfOthers)
        {
            ltrPvgOfSubitemOthers.Text += tagHtmlRead;
            pvgOfSubitemOthers         |= 1;
            hidPvgOfSubitemOthers.Value = pvgOfSubitemOthers.ToString();
        }

        if (canEditSubItemOfOthers)
        {
            ltrPvgOfSubitemOthers.Text += tagHtmlEdit;
            pvgOfSubitemOthers         |= 2;
            hidPvgOfSubitemOthers.Value = pvgOfSubitemOthers.ToString();
        }

        if (canDelSubItemOfOthers)
        {
            ltrPvgOfSubitemOthers.Text += tagHtmlDelete;
            pvgOfSubitemOthers         |= 8;
            hidPvgOfSubitemOthers.Value = pvgOfSubitemOthers.ToString();
        }

        Repeater rptSubOperations = (Repeater)e.Item.FindControl("rptSubOperations");

        if (rptSubOperations != null)
        {
            rptSubOperations.DataSource = opAuth.SubItems;
            rptSubOperations.DataBind();
        }
    }