Esempio n. 1
0
        public static void View(CremaDataTable dataTable, TextWriter writer)
        {
            var columns          = GetColumns();
            var tableDataBuilder = new TableDataBuilder(columns);
            var count            = 0;
            var rows             = ViewProperties.Sort == string.Empty ? dataTable.Select(ViewProperties.Expression) : dataTable.Select(ViewProperties.Expression, ViewProperties.Sort);

            foreach (var item in rows)
            {
                var items = columns.Select(i => $"{item[i]}").ToArray();
                if (ViewProperties.Limit >= 0 && ViewProperties.Limit <= count)
                {
                    break;
                }
                tableDataBuilder.Add(items);
                count++;
            }

            writer.WriteLine();
            writer.PrintTableData(tableDataBuilder.Data, true);
            writer.WriteLine();

            string[] GetColumns()
            {
                var query = from item in dataTable.Columns
                            where item.IsKey || StringUtility.GlobMany(item.ColumnName, ViewProperties.Columns)
                            select item.ColumnName;

                if (ColumnLimit <= 0)
                {
                    return(query.ToArray());
                }
                return(query.Take(ColumnLimit).ToArray());
            }
        }
Esempio n. 2
0
        public void ViewCategory(string categoryPath, long revision = -1)
        {
            var category       = this.GetCategory(categoryPath);
            var builderList    = new List <TableDataBuilder>();
            var authentication = this.CommandContext.GetAuthentication(this);

            category.Dispatcher.Invoke(() =>
            {
                var dataSet = category.GetDataSet(authentication, revision);
                foreach (var item in dataSet.Types)
                {
                    builderList.Add(BuildTableData(item));
                }
            });

            foreach (var item in builderList)
            {
                this.Out.Print(item);
            }

            TableDataBuilder BuildTableData(CremaDataType dataType)
            {
                var builder = new TableDataBuilder(CremaSchema.Name, CremaSchema.Value, CremaSchema.Comment);

                foreach (var item in dataType.Members)
                {
                    builder.Add(item.Name, item.Value, item.Comment);
                }
                return(builder);
            }
        }
Esempio n. 3
0
        public void Info(Guid domainID)
        {
            var domain         = this.GetDomain(domainID);
            var authentication = this.CommandContext.GetAuthentication(this);
            var metaData       = domain.Dispatcher.Invoke(() => domain.GetMetaData(authentication));
            var domainInfo     = metaData.DomainInfo;
            var dataBaseName   = this.cremaHost.Dispatcher.Invoke(() => this.cremaHost.DataBases[domainInfo.DataBaseID].Name);

            var items = new Dictionary <string, object>
            {
                { $"{nameof(domainInfo.DomainID)}", domainInfo.DomainID },
                { $"{nameof(domainInfo.DataBaseID)}", domainInfo.DataBaseID },
                { $"DataBaseName", dataBaseName },
                { $"{nameof(domainInfo.DomainType)}", domainInfo.DomainType },
                { $"{nameof(domainInfo.ItemType)}", domainInfo.ItemType },
                { $"{nameof(domainInfo.ItemPath)}", domainInfo.ItemPath },
                { $"{nameof(domainInfo.CreationInfo)}", domainInfo.CreationInfo.ToLocalValue() },
                { $"{nameof(domainInfo.ModificationInfo)}", domainInfo.ModificationInfo.ToLocalValue() },
                { $"UserList", string.Empty },
            };

            this.Out.WriteLine();
            this.Out.Print <object>(items);

            var tableDataBuilder = new TableDataBuilder(nameof(DomainUserInfo.UserID), nameof(DomainUserInfo.UserName), nameof(DomainUserState), nameof(DomainUserInfo.AccessType));

            foreach (var item in metaData.Users)
            {
                tableDataBuilder.Add(item.DomainUserInfo.UserID, item.DomainUserInfo.UserName, item.DomainUserState, item.DomainUserInfo.AccessType);
            }
            this.Out.PrintTableData(tableDataBuilder.Data, true);

            this.Out.WriteLine();
        }
Esempio n. 4
0
        public void View(string typeName, long revision = -1)
        {
            var type      = this.GetType(typeName);
            var tableData = type.Dispatcher.Invoke(() =>
            {
                var authentication   = this.CommandContext.GetAuthentication(this);
                var dataSet          = type.GetDataSet(authentication, revision);
                var dataType         = dataSet.Types[type.Name, type.Category.Path];
                var tableDataBuilder = new TableDataBuilder(CremaSchema.Name, CremaSchema.Value, CremaSchema.Comment);
                foreach (var item in dataType.Members)
                {
                    tableDataBuilder.Add(item.Name, item.Value, item.Comment);
                }
                return(tableDataBuilder);
            });

            this.Out.Print(tableData);
        }
Esempio n. 5
0
        public void List(string filter = "")
        {
            var items = this.GetLogList();

            if (DetailProperties.IsDetail == true)
            {
                var tableData = new TableDataBuilder(nameof(ILogService.Name), nameof(ILogService.Verbose), nameof(ILogService.FileName));
                foreach (var item in this.GetLogList())
                {
                    tableData.Add(item.Name, item.Verbose, item.FileName);
                }
                this.Out.PrintTableData(tableData.Data, true);
            }
            else
            {
                foreach (var item in this.GetLogList())
                {
                    this.Out.WriteLine(item.Name);
                }
            }
        }
Esempio n. 6
0
        public void ColumnList(string tableName)
        {
            var table      = this.GetTable(tableName);
            var tableInfo  = table.Dispatcher.Invoke(() => table.TableInfo);
            var headerList = new List <string>(new string[] { "IsKey", CremaSchema.Name, "DataType", CremaSchema.Comment, });

            if (ColumnInfoProperties.ID == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.ID));
            }
            if (ColumnInfoProperties.AllowNull == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.AllowNull));
            }
            if (ColumnInfoProperties.ReadOnly == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.ReadOnly));
            }
            if (ColumnInfoProperties.Unique == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.Unique));
            }
            if (ColumnInfoProperties.AutoIncrement == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.AutoIncrement));
            }
            if (ColumnInfoProperties.Tags == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.Tags));
            }
            if (ColumnInfoProperties.DefaultValue == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(ColumnInfoProperties.DefaultValue));
            }
            if (ColumnInfoProperties.SignatureDate == true || ColumnInfoProperties.All)
            {
                headerList.Add(nameof(Data.ColumnInfo.CreationInfo));
                headerList.Add(nameof(Data.ColumnInfo.ModificationInfo));
            }

            var tableDataBuilder = new TableDataBuilder(headerList.ToArray());

            foreach (var item in tableInfo.Columns)
            {
                var objectList = new List <object>(new object[] { item.IsKey ? "O" : string.Empty, item.Name, item.DataType, item.Comment });

                if (ColumnInfoProperties.ID == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.ID);
                }
                if (ColumnInfoProperties.AllowNull == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.AllowNull);
                }
                if (ColumnInfoProperties.ReadOnly == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.ReadOnly);
                }
                if (ColumnInfoProperties.Unique == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.IsUnique);
                }
                if (ColumnInfoProperties.AutoIncrement == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.AutoIncrement);
                }
                if (ColumnInfoProperties.Tags == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.DerivedTags);
                }
                if (ColumnInfoProperties.DefaultValue == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.DefaultValue);
                }
                if (ColumnInfoProperties.SignatureDate == true || ColumnInfoProperties.All)
                {
                    objectList.Add(item.CreationInfo);
                    objectList.Add(item.ModificationInfo);
                }

                tableDataBuilder.Add(objectList.ToArray());
            }

            this.Out.PrintTableData(tableDataBuilder.Data, true);
            this.Out.WriteLine();
        }