示例#1
0
        public GetDbInfoReturn GetDbInfo(string dbIns, int CurUserId, string CurUserIden)
        {
            base.SetHeader();
            CurUserIden = CPAppContext.FormatSqlPara(CurUserIden);
            GetDbInfoReturn re = new GetDbInfoReturn();

            if (this.CheckUserIden(CurUserId, CurUserIden) == false)
            {
                re.Result   = false;
                re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!";
                return(re);
            }
            re.Result = true;
            try
            {
                re.DbName = CPAppContext.GetDbName(dbIns);
                List <CPDbTable> tableCol = CPAppContext.GetTable(dbIns);
                re.TableCol = new List <GetDbInfoReturnItem>();
                tableCol.ForEach(t =>
                {
                    GetDbInfoReturnItem i = new GetDbInfoReturnItem();
                    i.TableName           = t.TableName;
                    i.PKNames             = t.PKNames;
                    re.TableCol.Add(i);
                });
                List <CPDbTable> viewCol = CPAppContext.GetView(dbIns);
                viewCol.ForEach(t =>
                {
                    GetDbInfoReturnItem i = new GetDbInfoReturnItem();
                    i.TableName           = t.TableName;
                    i.PKNames             = t.PKNames;
                    re.TableCol.Add(i);
                });
                re.TableCol = re.TableCol.OrderBy(c => c.TableName).ToList();
                return(re);
            }
            catch (Exception ex)
            {
                re.Result   = false;
                re.ErrorMsg = ex.Message.ToString();
                return(re);
            }
        }