示例#1
0
    void RenderGraph(string id)
    {
        DivGraph.Visible      = true;
        HeaderGraph.InnerText = "Graph" + id + " members";
        HtmlTableBuilder viewsBuilder = new HtmlTableBuilder();

        viewsBuilder.Table = TableGraphViews;


        Type    t = ServiceManager.GetGraphType(id);
        PXGraph g;

        try
        {
            g = (PXGraph)PXGraph.CreateInstance(t);
        }
        catch
        {
            if (this.Context.User.Identity.IsAuthenticated)
            {
                throw;
            }

            PX.Export.Authentication.FormsAuthenticationModule.RedirectToLoginPage();
            return;
        }

        #region views
        MemberInfo[] views = ServiceManager.GetViews(t);
        foreach (FieldInfo view in views)
        {
            viewsBuilder.AddRow();
            viewsBuilder.AddCell("View" + view.Name);

            PXView v     = g.Views[view.Name];
            Type[] items = v.GetItemTypes();

            viewsBuilder.AddCell(null);

            foreach (Type row in items)
            {
                try
                {
                    string    apiName = ServiceManager.GetTableNameFromType(row);
                    HyperLink h       = new HyperLink();
                    h.NavigateUrl = GetUrl("row", apiName);
                    h.Text        = "[" + apiName + "]";
                    viewsBuilder.Cell.Controls.Add(h);
                    continue;
                }
                catch
                {
                }

                HyperLink hyperLink = new HyperLink();
                hyperLink.Text = row.Name;
                viewsBuilder.Cell.Controls.Add(hyperLink);
            }
            string strParams             = "";
            List <PXViewParameter> pinfo = v.EnumParameters();

            List <string> list = new List <string>();
            foreach (PXViewParameter p in pinfo)
            {
                string opt = "";

                string type = GetParamTypeName(g, p);
                if (p.Bql != null && p.Bql.HasDefault)
                {
                    opt = "opt ";
                }


                list.Add(String.Format("{0}{1} {2}", opt, type, p.Name));
            }
            //var parameters = v.GetParameterNames();


            if (pinfo.Count > 0)
            {
                strParams = "(" + String.Join(", ", list.ToArray()) + ")";
            }

            viewsBuilder.AddCell(strParams);
        }
        #endregion

        #region actions
        HtmlTableBuilder actionsBuilder = new HtmlTableBuilder();
        actionsBuilder.Table = TableGraphActions;

        string[] actions = ServiceManager.GetActions(t);
        foreach (string action in actions)
        {
            actionsBuilder.AddRow();
            actionsBuilder.AddCell("Action" + action);
            PXAction a     = g.Actions[action];
            Type     r     = a.GetRowType();
            string   table = ServiceManager.GetTableNameFromType(r);

            actionsBuilder.AddCell(table);
        }

        #endregion
    }