Пример #1
0
        private IReadOnlyDictionary <string, Type> ConvertTables(Report report)
        {
            var graph      = new PXGraph();
            var tableTypes = new Dictionary <string, Type>(StringComparer.OrdinalIgnoreCase);

            foreach (var table in Base.Tables.Select().RowCast <GITable>()
                     .Where(t => !String.IsNullOrEmpty(t.Name) && !String.IsNullOrEmpty(t.Alias)))
            {
                Type type = PXBuildManager.GetType(table.Name, false);
                if (type == null)
                {
                    continue;
                }

                tableTypes[table.Alias] = type;
            }

            foreach (var type in tableTypes.Values.Distinct())
            {
                var reportTable = new ReportTable(type.Name)
                {
                    FullName = type.FullName,
                };

                PXCache cache = graph.Caches[type];
                foreach (string field in cache.Fields)
                {
                    var fieldInfo = ApiFieldInfo.Create(cache, field);
                    if (fieldInfo == null)
                    {
                        continue;
                    }
                    var      reportField = new ReportField(field);
                    TypeCode typeCode    = Type.GetTypeCode(fieldInfo.DataType);
                    if (typeCode != TypeCode.Empty)
                    {
                        reportField.DataType = typeCode;
                    }
                    reportTable.Fields.Add(reportField);
                }

                report.Tables.Add(reportTable);
            }

            return(tableTypes);
        }
Пример #2
0
    void RenderRow(string id)
    {
        DivMembers.Visible      = true;
        HeaderMembers.InnerText = String.Format("Row{0} members", id);
        HtmlTableBuilder b = new HtmlTableBuilder();

        b.Table = TableMembers;


        Type    table = ServiceManager.GetTableType(id);
        PXGraph g     = new PXGraph();
        PXCache cache = g.Caches[table];
        bool    isOdd = false;

        foreach (string field in cache.Fields)
        {
            ApiFieldInfo f = ApiFieldInfo.Create(cache, field);
            if (f == null)
            {
                continue;
            }



            b.AddRow();
            isOdd = !isOdd;
            if (isOdd)
            {
                b.Row.Style.Add("background-color", "white");
            }
            b.AddCell(field);

            string descr = "";

            PXFieldState state = (PXFieldState)cache.GetStateExt(null, field);
            if (state != null)
            {
                StringBuilder doc = new StringBuilder();
                if (state.PrimaryKey)
                {
                    doc.Append("PrimaryKey ");
                }
                if (state.PrimaryKey)
                {
                    b.Cell.Style.Add("font-weight", "bold");
                }
                if (state.Required == true)
                {
                    doc.Append("Required ");
                }
                if (!state.Enabled)
                {
                    doc.Append("NotEnabled ");
                }
                if (!state.Enabled)
                {
                    b.Cell.Style.Add("font-style", "italic");
                }
                if (state.IsReadOnly)
                {
                    doc.Append("IsReadOnly ");
                }
                //if (f.Visible) doc.Append("Visible ");
                doc.Append(f.Visibility + " ");
                descr = doc.ToString();
            }
            b.AddCell(f.DataType.Name);

            b.AddCell(descr);
            b.AddCell(state == null? "" :state.DisplayName);

            b.AddCell(Customization.RuntimeUtils.GetDacFieldAttributes(table, field));
        }
    }