Beispiel #1
0
        public ActionResult Create(long scId, string stmt, string user, string objtype, string objname, string way, string result)
        {
            JsonResult ret = new JsonResult();

            try
            {
                //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
                StringBuilder sbSql = new StringBuilder();
                sbSql.AppendFormat("audit {0} on {1}.{2} by {3}",
                                   stmt, user, objname, way);
                if (result != "ALL")
                {
                    sbSql.AppendFormat(" whenever {0}", result);
                }
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    dal.ExecuteNonQuery(sbSql.ToString());
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = ""
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
            }
            return(ret);
        }
        // GET: OrChanglogManage
        public ActionResult Index(long id)
        {
            ViewBag.SCID = id;
            SetModuleAuthority();
            var sc = db.SessionConnection.Find(id);
            List <DbMonitor.Domain.Dictionary> dic = null;

            if (sc != null)
            {
                if (sc.SCDBType == "ORACLE")
                {
                    using (OracleDAL dal = new OracleDAL(GetSessionConnStr(id)))
                    {
                        ViewBag.Users = dal.GetAllUsers();
                    }
                    dic = (from d in db.Dictionary
                           where d.DTypeCode == "OracleObjectType" && d.DEnable == 1
                           select d).OrderBy(s => s.DCode).ToList();
                }
                else if (sc.SCDBType == "DM")
                {
                    using (var dal = new DmDAL(GetSessionConnStr(id)))
                    {
                        ViewBag.Users = dal.GetAllUsers();
                    }
                    dic = (from d in db.Dictionary
                           where d.DTypeCode == "DmObjectType" && d.DEnable == 1
                           select d).OrderBy(s => s.DCode).ToList();
                }
                ViewBag.DBType = sc.SCDBType;
            }
            return(View(dic));
        }
Beispiel #3
0
        public ActionResult Delete(long scId, string option, string user, string objname)
        {
            JsonResult ret = new JsonResult();

            try
            {
                //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
                StringBuilder sbSql = new StringBuilder();
                sbSql.AppendFormat("noaudit {0} on {1}.{2}", option, user, objname);
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    dal.ExecuteNonQuery(sbSql.ToString());
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = ""
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
            }
            return(ret);
        }
        // GET: OrDataCompare
        public ActionResult Index(long id)
        {
            ViewBag.SCID = id;
            SetModuleAuthority();

            List <Domain.Dictionary> dic = null;
            var sc = db.SessionConnection.Find(id);

            if (sc.SCDBType == "ORACLE")
            {
                using (var dal = new OracleDAL(GetSessionConnStr(id)))
                {
                    ViewBag.Users = dal.GetAllUsers().OrderBy(s => s).ToList();
                }
                dic = db.Dictionary.Where(d => d.DTypeCode == "OracleObjectType" && d.DEnable == 1).ToList();
            }
            else
            {
                using (var dal = new DmDAL(GetSessionConnStr(id)))
                {
                    ViewBag.Users = dal.GetAllUsers().OrderBy(s => s).ToList();
                }
                dic = db.Dictionary.Where(d => d.DTypeCode == "DmObjectType" && d.DEnable == 1).ToList();
            }
            return(View(dic));
        }
Beispiel #5
0
        public ActionResult Delete(long scId, string user, string objname, string policy)
        {
            JsonResult ret = new JsonResult();

            try
            {
                //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    dal.ExecuteProcedureNonQuery("dbms_fga.drop_policy",
                                                 new OracleParameter("object_schema", user),
                                                 new OracleParameter("object_name", objname),
                                                 new OracleParameter("policy_name", policy));
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = ""
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #6
0
 public ActionResult Edit(Domain.MonitorManagement manage, FormCollection collection)
 {
     if (manage.MMOpen == 1)
     {
         JsonResult ret = new JsonResult();
         try
         {
             //加载数据
             var dmExample = db.Dictionary.Where(d => d.DTypeCode == "DmExample" && d.DEnable == 1).ToList();
             var sql       = "";
             using (var dal = new OracleDAL(GetSessionConnStr(manage.SCID.Value)))
             {
                 sql = dmExample.Where(d => d.DCode == "临时表").FirstOrDefault().DName;
                 dal.ExecuteNonQuery(sql);
                 sql = dmExample.Where(d => d.DCode == "包说明").FirstOrDefault().DName;
                 dal.ExecuteNonQuery(sql);
                 sql = dmExample.Where(d => d.DCode == "包体").FirstOrDefault().DName;
                 dal.ExecuteNonQuery(sql);
             }
         }
         catch (Exception ex)
         {
             ret.Data = JsonConvert.SerializeObject(new
             {
                 status  = 1,
                 message = ex.Message
             });
             RecordException(ex);
             return(ret);
         }
     }
     return(EditModel(manage));
 }
Beispiel #7
0
        public ActionResult GetObjectName(long scId, string user, string objtype = "TABLE")
        {
            JsonResult ret = new JsonResult();

            try
            {
                List <string> objs = new List <string>();
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    //视图与表
                    objs.AddRange(dal.GetAllTables(user));
                    objs.AddRange(dal.GetObjectName(user, "VIEW"));
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status = 0,
                    data   = objs
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #8
0
        /// <summary>
        /// 获取所有用户
        /// </summary>
        /// <param name="dal"></param>
        /// <returns></returns>
        public static List <string> GetAllUsers(this OracleDAL dal)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.AppendFormat("select USERNAME from dba_users where ACCOUNT_STATUS =  'OPEN' ORDER BY USERNAME ASC");

            return(dal.GetOneColumnValue(sbSql.ToString()));
        }
Beispiel #9
0
        /// <summary>
        /// 获取所有对象类型
        /// </summary>
        /// <param name="dal"></param>
        /// <returns></returns>
        public static List <string> GetAllObjectTypes(this OracleDAL dal)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.AppendFormat("select object_type from dba_objects group by object_type ORDER BY object_type");

            return(dal.GetOneColumnValue(sbSql.ToString()));
        }
Beispiel #10
0
        /// <summary>
        /// 获取某种所有对象
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="user"></param>
        /// <param name="objtype"></param>
        /// <returns></returns>
        public static List <string> GetObjectName(this OracleDAL dal, string user, string objtype)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.AppendFormat("select object_name from dba_objects where owner = '{0}' and object_type = '{1}'",
                               user, objtype);

            return(dal.GetOneColumnValue(sbSql.ToString()));
        }
Beispiel #11
0
        /// <summary>
        /// 获取某个对象的所有列名
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="user"></param>
        /// <param name="objname"></param>
        /// <returns></returns>
        public static List <string> GetColumnName(this OracleDAL dal, string user, string objname)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.AppendFormat("select column_name from dba_tab_columns where owner='{0}' and TABLE_NAME = '{1}'",
                               user, objname);

            return(dal.GetOneColumnValue(sbSql.ToString()));
        }
Beispiel #12
0
        public ActionResult List(long scId, int page = 1, int limit = 20, string user = "", string option = "")
        {
            JsonResult ret = new JsonResult();

            ret.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            try
            {
                StringBuilder sbCount = new StringBuilder();
                StringBuilder sbSql   = new StringBuilder();
                string        tv      = "DBA_PRIV_AUDIT_OPTS";
                sbCount.AppendFormat("SELECT COUNT(1) FROM {0} ", tv);
                sbSql.AppendFormat("SELECT * FROM (SELECT ROWNUM AS ROWNO, t.* FROM {0} t WHERE ", tv);
                //筛选条件
                if (!string.IsNullOrWhiteSpace(user))
                {
                    sbSql.AppendFormat("USER_NAME LIKE '%{0}%' AND ", user);
                    sbCount.AddCondition(string.Format("USER_NAME LIKE '%{0}%'", user));
                }
                if (!string.IsNullOrWhiteSpace(option))
                {
                    sbSql.AppendFormat("PRIVILEGE LIKE '%{0}%' AND ", option.ToUpper());
                    sbCount.AddCondition(string.Format("PRIVILEGE LIKE '%{0}%'", option.ToUpper()));
                }
                sbSql.AppendFormat("ROWNUM <= {0}) table_alias WHERE table_alias.ROWNO > {1}",
                                   page * limit, (page - 1) * limit);

                int       count = 0;
                DataTable dt    = null;
                //string connStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));Persist Security Info=True;User ID=sys;Password=sys;DBA Privilege=SYSDBA;";
                string connStr = GetSessionConnStr(scId);
                using (OracleDAL dal = new OracleDAL(connStr))
                {
                    count = Convert.ToInt32(dal.ExecuteScalar(sbCount.ToString()));
                    dt    = dal.ExecuteQuery(sbSql.ToString());
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = "",
                    total   = count,
                    data    = dt
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = "发生异常:" + ex.Message,
                    total   = 0,
                    data    = ""
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #13
0
 public ActionResult Create(long scId)
 {
     //用户
     using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
     {
         ViewBag.User = dal.GetAllUsers();
     }
     return(View(scId));
 }
Beispiel #14
0
 /// <summary>
 /// Generates the code.
 /// </summary>
 private void GenerateCode()
 {
     try
     {
         txtCode.Text = OracleDAL
                        .GenerateCode(txtTablespace.Text, cmbTables.Text, txtNameSpace.Text, cbDataLength.Checked, cbComments.Checked)
         ;
     }
     catch (Exception ex) { Alert(TpAlert.error, ex.Message); }
 }
 // GET: OrHistoryDataQuery
 public ActionResult Index(long id)
 {
     ViewBag.SCID = id;
     SetModuleAuthority();
     using (var dal = new OracleDAL(GetSessionConnStr(id)))
     {
         ViewBag.Users = dal.GetAllUsers();
     }
     return(View());
 }
Beispiel #16
0
        /// <summary>
        /// 查询一列值并以List<string>返回
        /// </summary>
        /// <param name="dal"></param>
        /// <param name="sqlText"></param>
        /// <returns></returns>
        public static List <string> GetOneColumnValue(this OracleDAL dal, string sqlText)
        {
            List <string> ret = new List <string>();
            var           dt  = dal.ExecuteQuery(sqlText);

            foreach (DataRow row in dt.Rows)
            {
                ret.Add(row[0].ToString());
            }
            return(ret);
        }
 // GET: OrAuditRecord
 public ActionResult Index(long id)
 {
     ViewBag.SCID = id;
     SetModuleAuthority();
     using (OracleDAL dal = new OracleDAL(GetSessionConnStr(id)))
     {
         ViewBag.Users       = dal.GetAllUsers();
         ViewBag.ObjectTypes = dal.GetAllObjectTypes();
         ViewBag.STMT        = dal.GetOneColumnValue("select statement_type from DBA_COMMON_AUDIT_TRAIL GROUP BY statement_type ORDER BY statement_type");
     }
     return(View());
 }
Beispiel #18
0
        // GET: OrStatementAudit
        public ActionResult Index(long id)
        {
            ViewBag.SCID = id;
            SetModuleAuthority();
            using (OracleDAL dal = new OracleDAL(GetSessionConnStr(id)))
            {
                ViewBag.Users = dal.GetAllUsers();
            }
            var dic = db.Dictionary.Where(d => d.DTypeCode == "OracleAuditPrivilege" && d.DEnable == 1).
                      OrderBy(d => d.DCode).ToList();

            return(View(dic));
        }
Beispiel #19
0
        public void TestMethod3()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <DBManager>();
            builder.RegisterType <SqlDAL>().Named <IDAL>("SQL");
            builder.RegisterType <OracleDAL>().Named <IDAL>("ORACLE");
            using (var container = builder.Build())
            {
                SqlDAL    sqlDAL    = (SqlDAL)container.ResolveNamed <IDAL>("SQL");
                OracleDAL oracleDAL = (OracleDAL)container.ResolveNamed <IDAL>("ORACLE");
            }
        }
        //SELECT * FROM STUDENT AS OF TIMESTAMP TO_TIMESTAMP('2018-12-19 16:00:16','YYYY-MM-DD hh24:mi:ss')
        public ActionResult List(long scId, string user, string objname, string endtime, int page = 1, int limit = 20)
        {
            JsonResult ret = new JsonResult();

            ret.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            try
            {
                StringBuilder sbCount = new StringBuilder();
                StringBuilder sbSql   = new StringBuilder();
                string        tv      = string.Format("{0}.{1}", user, objname);
                if (string.IsNullOrWhiteSpace(endtime))
                {
                    endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                sbCount.AppendFormat("SELECT COUNT(1) FROM {0} AS OF TIMESTAMP TO_TIMESTAMP('{1}','YYYY-MM-DD hh24:mi:ss')", tv, endtime);
                sbSql.AppendFormat("SELECT * FROM (SELECT ROWNUM AS ROWNO, t.* FROM {0} AS OF TIMESTAMP TO_TIMESTAMP('{1}','YYYY-MM-DD hh24:mi:ss') t WHERE ", tv, endtime);


                sbSql.AppendFormat("ROWNUM <= {0}) table_alias WHERE table_alias.ROWNO > {1}",
                                   page * limit, (page - 1) * limit);

                int       count = 0;
                DataTable dt    = null;
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    count = Convert.ToInt32(dal.ExecuteScalar(sbCount.ToString()));
                    dt    = dal.ExecuteQuery(sbSql.ToString());
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = "",
                    total   = count,
                    data    = dt
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = "发生异常:" + ex.Message,
                    total   = 0,
                    data    = ""
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #21
0
        public ActionResult List(long scId, int page = 1, int limit = 20, string username = "")
        {
            JsonResult ret = new JsonResult();

            ret.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

            try
            {
                StringBuilder sbSql = new StringBuilder();
                sbSql.AppendFormat(@"select 'Statement' ITEM, count(1) ALL_COUNT,count(1) ENABLE_COUNT,0 DISABLE_COUNT from DBA_STMT_AUDIT_OPTS
                                    UNION ALL
                                    select 'Object' Item, count(1) ALL_COUNT,count(1) ENABLE_COUNT,0 DISABLE_COUNT from DBA_OBJ_AUDIT_OPTS
                                    UNION ALL
                                    select 'Privilege' Item, count(1) ALL_COUNT,count(1) ENABLE_COUNT,0 DISABLE_COUNT from DBA_PRIV_AUDIT_OPTS
                                    UNION ALL
                                    Select * from 
                                    (select 'FGA' Item, count(1) ALL_COUNT from DBA_AUDIT_POLICIES
                                    ),
                                    (select COUNT(1) ENABLE_COUNT from DBA_AUDIT_POLICIES WHERE ENABLED = 'YES'),
                                    (select COUNT(1) DISABLE_COUNT from DBA_AUDIT_POLICIES WHERE ENABLED = 'NO')");

                int       count = 4;
                DataTable dt    = null;
                //string connStr = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));Persist Security Info=True;User ID=sys;Password=sys;DBA Privilege=SYSDBA;";
                string connStr = GetSessionConnStr(scId);
                using (OracleDAL dal = new OracleDAL(connStr))
                {
                    dt = dal.ExecuteQuery(sbSql.ToString());
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = "",
                    total   = count,
                    data    = dt
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = "发生异常:" + ex.Message,
                    total   = 0,
                    data    = ""
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #22
0
 public ActionResult Create(long scId)
 {
     //语句
     string[] arrStatement = { "ALTER", "AUDIT", "COMMENT", "DELETE", "EXECUTE", "FLASHBACK", "GRANT", "INDEX", "INSERT", "LOCK", "READ", "RENAME", "SELECT", "UPDATE" };
     ViewBag.STMT = (from d in db.Dictionary
                     where d.DTypeCode == "OracleAuditObject" && d.DEnable == 1
                     select d.DCode).OrderBy(c => c).ToList();
     //用户
     using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
     {
         //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
         StringBuilder sbSql = new StringBuilder();
         ViewBag.User = dal.GetAllUsers().OrderBy(u => u).ToList();
     }
     ViewBag.ObjectTypes = db.Dictionary.Where(d => d.DTypeCode == "OracleObjectType" && d.DEnable == 1)
                           .OrderBy(d => d.DCode).ToList();
     return(View(scId));
 }
Beispiel #23
0
        static void GrabOracleData(MonitorManagement mm)
        {
            //采集SQL
            StringBuilder sbSql = new StringBuilder();

            sbSql.Append("SELECT INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,DATABASE_STATUS FROM V$INSTANCE");
            DataTable dt      = null;
            string    connStr = DataGraber.GetSessionConnStr(mm.SCID.Value);

            using (OracleDAL dal = new OracleDAL(connStr))
            {
                dt = dal.ExecuteQuery(sbSql.ToString());
            }
            var grabTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            using (var ctx = new DbMonitorEntities())
            {
                //把上一次数据设成历史数据
                var ds = ctx.DatabaseStatus.Where(s => s.REALTIME == 1);
                foreach (var s in ds)
                {
                    s.REALTIME    = 0;
                    s.EditingTime = grabTime;
                }
                ctx.SaveChanges();
                foreach (DataRow dr in dt.Rows)
                {
                    DatabaseStatus status = ctx.DatabaseStatus.Create();
                    status.SCID            = mm.SCID;
                    status.INSTANCE_NAME   = dr["INSTANCE_NAME"].ToString();
                    status.HOST_NAME       = dr["HOST_NAME"].ToString();
                    status.VERSION         = dr["VERSION"].ToString();
                    status.STARTUP_TIME    = dr["STARTUP_TIME"].ToString();
                    status.STATUS          = dr["STATUS"].ToString();
                    status.DATABASE_STATUS = dr["DATABASE_STATUS"].ToString();
                    status.REALTIME        = 1;
                    status.CreationTime    = grabTime;

                    ctx.DatabaseStatus.Add(status);
                }
                ctx.SaveChanges();
                Console.WriteLine("id:{0} oracle-status-grab {1} items", mm.ID, dt.Rows.Count);
            }
        }
Beispiel #24
0
 public ActionResult Create(long scId)
 {
     //语句
     string[] arrPrivilege = { "CREATE EXTERNAL JOB",         "CREATE ANY JOB",       "GRANT ANY OBJECT PRIVILEGE", "EXEMPT ACCESS POLICY",
                               "CREATE ANY LIBRARY",          "GRANT ANY PRIVILEGE",  "DROP PROFILE",               "ALTER PROFILE",       "DROP ANY PROCEDURE",
                               "ALTER ANY PROCEDURE",         "CREATE ANY PROCEDURE", "ALTER DATABASE",             "GRANT ANY ROLE",
                               "CREATE PUBLIC DATABASE LINK", "DROP ANY TABLE",       "ALTER ANY TABLE",            "CREATE ANY TABLE",
                               "DROP USER",                   "ALTER USER",           "CREATE USER",                "CREATE SESSION",      "AUDIT SYSTEM", "ALTER SYSTEM" };
     ViewBag.STMT = (from d in db.Dictionary
                     where d.DTypeCode == "OracleAuditPrivilege" && d.DEnable == 1
                     orderby d.DTypeCode
                     select d.DCode).OrderBy(c => c).ToList();
     //用户
     using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
     {
         ViewBag.User = dal.GetAllUsers().OrderBy(u => u).ToList();
     }
     return(View(scId));
 }
        public ActionResult GetColumnName(long scId, string user, string objname)
        {
            JsonResult ret = new JsonResult();

            ret.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            try
            {
                List <string> colNames = new List <string>();
                if (!string.IsNullOrWhiteSpace(user) && !string.IsNullOrWhiteSpace(objname))
                {
                    string    sql = string.Format("SELECT * FROM {0}.{1} WHERE ROWNUM <= 1", user, objname);
                    DataTable dt  = null;
                    using (var dal = new OracleDAL(GetSessionConnStr(scId)))
                    {
                        dt = dal.ExecuteQuery(sql);
                    }
                    if (dt != null)
                    {
                        foreach (DataColumn col in dt.Columns)
                        {
                            colNames.Add(col.ColumnName);
                        }
                    }
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = "",
                    data    = colNames
                });;
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = "发生异常:" + ex.Message,
                    data    = ""
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #26
0
 public ActionResult Create(long scId)
 {
     //语句
     string[] arrStatement = { "ALTER SEQUENCE",  "ALTER TABLE",       "COMMENT TABLE",    "DELETE TABLE",  "EXECUTE PROCEDURE",
                               "GRANT DIRECTORY", "GRANT PROCEDURE",   "GRANT SEQUENCE",   "GRANT TABLE",   "GRANT TYPE",
                               "INSERT TABLE",    "LOCK TABLE",        "SELECT SEQUENCE",  "SELECT TABLE",  "UPDATE TABLE",
                               "ALTER SYSTEM",    "CLUSTER",           "CONTEXT",          "DATABASE LINK", "DIMENSION",        "DIRECTORY",
                               "INDEX",           "MATERIALIZED VIEW", "NOT EXISTS",       "PROCEDURE",     "PROFILE",          "PUBLIC DATABASE LINK",
                               "PUBLIC SYNONYM",  "ROLE",              "ROLLBACK SEGMENT", "SEQUENCE",      "SESSION",          "SYNONYM",
                               "SYSTEM AUDIT",    "SYSTEM GRANT",      "TABLE",            "TABLESPACE",    "TRIGGER",          "TYPE",                 "USER", "VIEW" };
     ViewBag.STMT = (from d in db.Dictionary
                     where d.DTypeCode == "OracleAuditSTMT" && d.DEnable == 1
                     select d.DCode).OrderBy(c => c).ToList();
     //用户
     using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
     {
         ViewBag.User = dal.GetAllUsers().OrderBy(u => u).ToList();
     }
     return(View(scId));
 }
Beispiel #27
0
        public ActionResult Create(long scId)
        {
            CreateAcion();
            var sc  = db.SessionConnection.Find(scId);
            var dic = db.Dictionary.Where(d => d.DTypeCode == "OracleExport" && d.DCode == "backup_dir").FirstOrDefault();

            Domain.MirrorExport me = new Domain.MirrorExport()
            {
                SCID         = scId,
                MEUser       = sc.SCUser,
                MEPassword   = sc.SCPassword,
                MEDirectory  = dic.DName,
                MESchemas    = sc.SCUser,
                MEExportTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")
            };
            using (var dal = new OracleDAL(GetSessionConnStr(scId)))
            {
                ViewBag.Users = dal.GetAllUsers();
            }
            return(View(me));
        }
        public ActionResult GetObjectName(long scId, string user, string objtype)
        {
            JsonResult ret = new JsonResult();

            try
            {
                List <string> objs = new List <string>();
                var           sc   = db.SessionConnection.Find(scId);
                if (sc.SCDBType == "ORACLE")
                {
                    using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                    {
                        objs = dal.GetObjectName(user, objtype).OrderBy(s => s).ToList();
                    }
                }
                else
                {
                    using (DmDAL dal = new DmDAL(GetSessionConnStr(scId)))
                    {
                        objs = dal.GetObjectName(user, objtype).OrderBy(s => s).ToList();
                    }
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status = 0,
                    data   = objs
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #29
0
        public ActionResult GetColumnName(long scId, string user, string objname)
        {
            JsonResult ret = new JsonResult();

            try
            {
                List <string> objs = new List <string>();
                //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
                StringBuilder sbSql = new StringBuilder();
                sbSql.AppendFormat("select column_name from dba_tab_columns where owner='{0}' and TABLE_NAME = '{1}'",
                                   user, objname);
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    DataTable dt = dal.ExecuteQuery(sbSql.ToString());

                    foreach (DataRow row in dt.Rows)
                    {
                        var u = row.ItemArray[0].ToString();
                        objs.Add(u);
                    }
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status = 0,
                    data   = objs
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
                RecordException(ex);
            }
            return(ret);
        }
Beispiel #30
0
        public ActionResult Delete(long scId, FormCollection collection)
        {
            JsonResult ret = new JsonResult();

            try
            {
                //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
                StringBuilder sbSql     = new StringBuilder();
                var           username  = collection["USER_NAME"];
                var           privilege = collection["PRIVILEGE"];

                //查询语句结尾不要逗号,否则报错:ORA-00911: 无效字符
                sbSql.AppendFormat("noaudit {0}", privilege);
                if (!string.IsNullOrWhiteSpace(username))
                {
                    sbSql.AppendFormat(" by {0}", username);
                }
                using (OracleDAL dal = new OracleDAL(GetSessionConnStr(scId)))
                {
                    dal.ExecuteNonQuery(sbSql.ToString());
                }
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 0,
                    message = ""
                });
            }
            catch (Exception ex)
            {
                ret.Data = JsonConvert.SerializeObject(new
                {
                    status  = 1,
                    message = ex.Message
                });
                RecordException(ex);
            }
            return(ret);
        }