Esempio n. 1
0
        public override bool SaveData()
        {
            TableEntity entity = new TableEntity();

            entity.ProjectID       = Convert.ToInt32(Global.GetCurrentProjectID());
            entity.TableName       = this.txtTableName.Text.Trim();
            entity.Attr            = this.txtAttr.Text.Trim();
            entity.Remark          = this.txtRemark.Text.Trim();
            entity.DataKey         = this.cboDataKey.Text.Trim();
            entity.Enabled         = true;
            entity.DataKeyType     = StringHelper.ToEnum <WSH.CodeBuilder.DispatchServers.DataKeyType>(this.cboDataKeyType.Text);
            entity.DefaultSortMode = StringHelper.ToEnum <WSH.CodeBuilder.DispatchServers.SortMode>(this.cboSortMode.Text);
            entity.DefaultSortName = this.cboSortName.Text.Trim();
            TableName = entity.TableName;
            if (service.ExistsTableName(TableName, Global.GetCurrentProjectID(), this.RecordID))
            {
                throw new Exception("表名已经存在!");
            }
            if (string.IsNullOrEmpty(this.RecordID))
            {
                int id = service.AddTable(entity);
                if (id > 0)
                {
                    this.RecordID = id.ToString();
                    return(true);
                }
                return(false);
            }
            else
            {
                entity.ID = Convert.ToInt32(this.RecordID);
                return(service.UpdateTable(entity));
            }
        }
Esempio n. 2
0
        protected List <TableEntity> ReaderTables(List <TableInfo> tables)
        {
            List <TableEntity> entitys = new List <TableEntity>();

            foreach (TableInfo table in tables)
            {
                //检测表是否存在
                try
                {
                    TableEntity tableEntity = service.GetTableByName(Project.ID.ToString(), table.TableName);
                    if (tableEntity == null)
                    {
                        tableEntity = new TableEntity();
                    }
                    tableEntity.TableName = table.TableName;
                    tableEntity.Attr      = table.Attr;
                    tableEntity.Remark    = table.Remark;
                    tableEntity.ProjectID = Project.ID;
                    tableEntity.Enabled   = true;
                    if (tableEntity.ID > 0)
                    {
                        service.UpdateTable(tableEntity);
                    }
                    else
                    {
                        tableEntity.ID = service.AddTable(tableEntity);
                    }
                    if (tableEntity.ID > 0)
                    {
                        entitys.Add(tableEntity);
                        ReaderColumns(tableEntity, table.Columns);
                    }
                }
                catch (Exception ex)
                {
                    Error.AppendLine("读取数据表—" + table.TableName + "出错!" + ex.Message);
                    continue;
                }
            }
            return(entitys);
        }