예제 #1
0
        public JsonResultModel TableList(string dbName)
        {
            JsonResultModel response = new JsonResultModel();

            List <DesignTableEntity> tableEntityList = null;

            using (var savoryDesignDB = new SavoryDesignDBContext())
            {
                tableEntityList = (from table in savoryDesignDB.DesignTable where table.DBName.Equals(dbName) select table).ToList();
            }

            if (tableEntityList != null && tableEntityList.Count > 0)
            {
                List <TableVo> tableVoList = new List <TableVo>();

                foreach (var tableEntity in tableEntityList)
                {
                    var tableVo = new TableVo();

                    tableVo.TableName      = tableEntity.TableName;
                    tableVo.Description    = tableEntity.Description;
                    tableVo.SchemaVersion  = tableEntity.SchemaVersion;
                    tableVo.CreateTime     = tableEntity.CreateTime;
                    tableVo.LastUpdateTime = tableEntity.LastUpdateTime;

                    tableVoList.Add(tableVo);
                }

                response.Data = tableVoList;
            }

            return(response);
        }
예제 #2
0
        public JsonResultModel CreateTable(string dbName, TableVo tableVo)
        {
            JsonResultModel response = new JsonResultModel();

            CreateTableResult returnValue = RealCreateTable(dbName, tableVo);

            response.Status  = (int)returnValue;
            response.Message = EnumExtension.GetDescription(returnValue);

            return(response);
        }
예제 #3
0
        private CreateTableResult RealCreateTable(string dbName, TableVo tableVo)
        {
            if (string.IsNullOrWhiteSpace(dbName))
            {
                return(CreateTableResult.DBNameRequired);
            }

            if (tableVo == null)
            {
                return(CreateTableResult.RequestBodyRequired);
            }

            if (string.IsNullOrWhiteSpace(tableVo.TableName))
            {
                return(CreateTableResult.TableNameRequired);
            }

            if (string.IsNullOrWhiteSpace(tableVo.Description))
            {
                return(CreateTableResult.DescriptionRequired);
            }

            using (var savoryDesignDB = new SavoryDesignDBContext())
            {
                var existingTable = savoryDesignDB.DesignTable.FirstOrDefault(v => v.DBName.Equals(dbName, StringComparison.OrdinalIgnoreCase) && v.TableName.Equals(tableVo.TableName, StringComparison.OrdinalIgnoreCase) && v.DataStatus == 1);

                if (existingTable != null)
                {
                    return(CreateTableResult.TableExisted);
                }

                var designTable = new DesignTableEntity();
                designTable.DBName         = "dbname";
                designTable.DBName         = dbName;
                designTable.TableName      = tableVo.TableName;
                designTable.Description    = tableVo.Description;
                designTable.SchemaVersion  = 0;
                designTable.DataStatus     = 1;
                designTable.CreateUser     = "******";
                designTable.CreateTime     = DateTime.Now;
                designTable.LastUpdateUser = "******";
                designTable.LastUpdateTime = DateTime.Now;
                savoryDesignDB.DesignTable.Add(designTable);

                savoryDesignDB.SaveChanges();
            }

            return(CreateTableResult.Success);
        }
예제 #4
0
    public override void HandleNotice(INotice notice)
    {
        switch (notice.GetType())
        {
        case Command.Command_Show:
            TableVo vo = notice.GetBody <TableVo>();
            SetViewObj(vo);
            ShowSubPage(viewObj.index);
            break;

        case Command.Command_Reactive:
            LoadViewObj();
            break;
        }
        base.HandleNotice(notice);
    }