Exemplo n.º 1
0
        /// <summary>
        /// 获取查询
        /// </summary>
        /// <param name="db"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataSet SqlQuery(AbpvNextHISInterfaceDbContext db, string sql)
        {
            //创建Oracle连接对象
            OracleConnection conn = db.Database.GetDbConnection() as OracleConnection;

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            //创建操作对象
            OracleCommand command   = conn.CreateCommand();
            DataSet       dataTable = new DataSet();

            command.CommandText = string.Format(sql);
            OracleDataAdapter oradata = new OracleDataAdapter();

            oradata.SelectCommand = command;
            oradata.Fill(dataTable);

            command.Parameters.Clear();
            conn.Close();
            int count = dataTable.Tables[0].Rows.Count;

            return(dataTable);
        }
Exemplo n.º 2
0
 public IPBController(AbpvNextHISInterfaceDbContext dB, IConfiguration configuration, ICheckSqlConn conn, IZHYYDbMethods zhyyservice, ILoggerService logger)
 {
     this.db          = dB;
     this.conn        = conn;
     this.zhyyservice = zhyyservice;
     this.logger      = logger;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 查询sql返回datatable
        /// </summary>
        /// <param name="db"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataTable QuerySql(AbpvNextHISInterfaceDbContext db, string sql)
        {
            OracleConnection conn = db.Database.GetDbConnection() as OracleConnection; DataTable ds = new DataTable();

            try
            {
                conn.Open();
                OracleDataAdapter oda = new OracleDataAdapter(sql, conn);
                OracleCommand     cmd = new OracleCommand(sql, conn);
                DataTable         dt  = new DataTable();
                cmd.Parameters.Clear();
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 999;
                var reader = cmd.ExecuteReader();
                dt.Load(reader);
                reader.Close();
                return(dt);

                // ds.Load(reader);
            }
            catch
            {
                return(null);
            }
            finally
            {
                conn.Close();
            }
            return(ds);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 调用存储过程获取方法
        /// </summary>
        /// <param name="db"></param>
        /// <param name="spName"></param>
        /// <param name="paramsters"></param>
        /// <returns></returns>
        public static DataSet SqlQuery(AbpvNextHISInterfaceDbContext db, string spName, params OracleParameter[] paramsters)
        {
            OracleConnection connection = db.Database.GetDbConnection() as OracleConnection;
            ////OracleConnection connection = new OracleConnection(db.Database.GetDbConnection().ConnectionString);//db.Database.GetDbConnection() as OracleConnection
            //if (connection.State==ConnectionState.Closed)
            //{
            //    connection.Open();
            //}
            OracleDataAdapter adapter = null;
            DataSet           set     = null;

            using (OracleCommand command = new OracleCommand(spName, connection))
            {
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = spName;
                command.Parameters.AddRange(paramsters);
                adapter = new OracleDataAdapter(command);

                set = new DataSet();
                adapter.Fill(set);
                adapter.SelectCommand.Parameters.Clear();
                adapter.Dispose();
                command.Parameters.Clear();
                command.Dispose();
                connection.Close();
                connection.Dispose();
                return(set);
            }
        }
Exemplo n.º 5
0
 public OPBController(AbpvNextHISInterfaceDbContext db, IConfiguration configuration, ICheckSqlConn conn, ILoggerService logger)
 {
     this.db            = db;
     this.configuration = configuration;
     this.conn          = conn;
     this.logger        = logger;
 }
Exemplo n.º 6
0
 public COMtestController(AbpvNextHISInterfaceDbContext db, IConfiguration configuration, ICheckSqlConn Conn, IZHYYDbMethods zhyyservice, IDbConnection dbConnection)
 {
     this.db            = db;
     this.configuration = configuration;
     this.conn          = Conn;
     this.zhyyservice   = zhyyservice;
     this.dbConnection  = dbConnection;
 }
Exemplo n.º 7
0
        /// <summary>
        /// 绑定查询sql的服务
        /// </summary>
        /// <param name="ServiceName"></param>
        /// <param name="ServiceModule"></param>
        /// <param name="jobj"></param>
        /// <returns></returns>
        public IActionResult BindServiceForSql(AbpvNextHISInterfaceDbContext db, string ServiceName, string ServiceModule, JObject jobj)
        {
            COM_ZHYY_CONFIG myconfig = this.GetServiceConfigAsync(ServiceName, ServiceModule).Result;

            if (myconfig == null)
            {
                return(new ObjectResult(new { msg = "请求失败", data = $"服务名为{ServiceModule}/{ServiceName}未配置不可使用!", code = "500" }));
            }
            if (myconfig.VALID_FALG == "0")
            {
                return(new ObjectResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}该服务的已被作废!", code = "500" }));
            }
            string[]      inparameters   = myconfig.INPARAMETERNAMES == null ? new string[0] : myconfig.INPARAMETERNAMES.Split('|');
            string[]      intypes        = myconfig.INPARAMETERTYPES == null ? new string[0] : myconfig.INPARAMETERTYPES.Split('|');
            string[]      procedureprops = myconfig.INPROCEDUREPROP == null ? new string[0] : myconfig.INPROCEDUREPROP.Split('|');
            string[]      outparameters  = myconfig.OUTPARAMETERNAMES == null ? new string[0] : myconfig.OUTPARAMETERNAMES.Split('|');
            string[]      outtypes       = myconfig.OUTPARAMETERTYPES == null ? new string[0] : myconfig.OUTPARAMETERTYPES.Split('|');
            List <object> objlist        = new List <object>();

            for (int i = 0; i < inparameters.Length; i++)
            {
                if (myconfig.SERVICENAME == "QueryZBInfoByDate" && inparameters[i] == "date")
                {
                    objlist.Add(Convert.ToDateTime(jobj.GetValue(inparameters[i]).ToString()).ToString("yyyy-MM-01"));
                }
                else
                {
                    objlist.Add(jobj.GetValue(inparameters[i]).ToString());
                }
            }
            ObjectResult res = new ObjectResult("");
            string       Sql = string.Format(myconfig.PROCEDURENAME, objlist.ToArray());

            db = db == null ? dbContext : db;
            var       dt  = this.QuerySql(db, Sql);
            ArrayList arr = this.getJObject(dt);

            if (Convert.ToInt32(myconfig.ISFY) == (int)SonShowType.微生物查询)
            {
                res = GetWswList(arr);
            }
            else
            {
                res = new ObjectResult(new { msg = $"查询成功!", data = arr, code = 200 });
            }
            if (arr == null)
            {
                res = new ObjectResult(new { msg = $"{ServiceModule}/{ServiceName}没有找到如何数据的信息!", data = "查询结果为空", code = 404 });
            }
            if (arr.Count == 0)
            {
                res = new ObjectResult(new { msg = $"{ServiceModule}/{ServiceName}没有找到如何数据的信息!", data = "查询结果为空", code = 404 });
            }
            return(res);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 切换数据库的方法
        /// </summary>
        /// <param name="SqlType"></param>
        private void UpdateSql(string SqlType)
        {
            switch (SqlType.ToUpper())
            {
            case "HIS":
                this.db = conn.GetHISDBZSK(db);
                break;

            case "LIS":
                this.db = conn.GetLISDB(db);
                break;

            case "PACS":
                this.db = conn.GetPacsDB(db);
                break;

            default:
                this.db = db;
                break;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// 连接Pacs数据库
 /// </summary>
 /// <param name="dB"></param>
 /// <returns></returns>
 public static AbpvNextHISInterfaceDbContext GetPacsDB(AbpvNextHISInterfaceDbContext dB)
 {
     dB.Database.GetDbConnection().ConnectionString = root["OrclDBPacs"].ToString();
     return(dB);
 }
Exemplo n.º 10
0
 public IPBtesttestController(AbpvNextHISInterfaceDbContext dB, IConfiguration configuration, ICheckSqlConn conn, IZHYYDbMethods zhyyservice)
 {
     this.db          = dB;
     this.conn        = conn;
     this.zhyyservice = zhyyservice;
 }
Exemplo n.º 11
0
 /// <summary>
 /// 连接LIS数据库
 /// </summary>
 /// <param name="dB"></param>
 /// <returns></returns>
 public AbpvNextHISInterfaceDbContext GetLISDB(AbpvNextHISInterfaceDbContext dB)
 {
     dB.Database.GetDbConnection().ConnectionString = Root["OrclDBLis"].ToString();
     return(dB);
 }
Exemplo n.º 12
0
 public OPBtestController(AbpvNextHISInterfaceDbContext db, IConfiguration configuration, ICheckSqlConn conn)
 {
     this.db            = db;
     this.configuration = configuration;
     this.conn          = conn;
 }
Exemplo n.º 13
0
        /// <summary>
        /// 绑定数据库中配置的服务
        /// </summary>
        /// <param name="ServiceName"></param>
        /// <param name="ServiceModule"></param>
        public IActionResult BindService(AbpvNextHISInterfaceDbContext db, string ServiceName, string ServiceModule, JObject jobj)
        {
            COM_ZHYY_CONFIG myconfig = this.GetServiceConfigAsync(ServiceName, ServiceModule).Result;

            if (myconfig == null)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"服务名为{ServiceModule}/{ServiceName}未配置不可使用!", code = "500" }));
            }
            if (myconfig.VALID_FALG == "0")
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}该服务的已被作废!", code = "500" }));
            }
            string[] inparameters   = myconfig.INPARAMETERNAMES == null ? new string[0] : myconfig.INPARAMETERNAMES.Split('|');
            string[] intypes        = myconfig.INPARAMETERTYPES == null ? new string[0] : myconfig.INPARAMETERTYPES.Split('|');
            string[] procedureprops = myconfig.INPROCEDUREPROP == null ? new string[0] : myconfig.INPROCEDUREPROP.Split('|');
            string[] outparameters  = myconfig.OUTPARAMETERNAMES == null ? new string[0] : myconfig.OUTPARAMETERNAMES.Split('|');
            string[] outtypes       = myconfig.OUTPARAMETERTYPES == null ? new string[0] : myconfig.OUTPARAMETERTYPES.Split('|');
            if (inparameters.Length != intypes.Length)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}入参和入参的类型无法对应,请检查com_zhyy_config表中的配置", code = "500" }));
            }
            else if (inparameters.Length != procedureprops.Length)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}入参和数据库入参无法对应,请检查com_zhyy_config表中的配置", code = "500" }));
            }
            else if (outparameters.Length != outtypes.Length)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}出参和出参类型无法对应,请检查com_zhyy_config表中的配置", code = "500" }));
            }
            //输入参数
            List <OracleParameter> parems = new List <OracleParameter>();

            try
            {
                for (int i = 0; i < inparameters.Length; i++)
                {
                    parems.Add(GetInput(procedureprops[i], (OracleDbType)Int32.Parse(intypes[i]), GetParameterByType((OracleDbType)Int32.Parse(intypes[i]), jobj.GetValue(inparameters[i]).ToString())));
                }
            }
            catch (Exception)
            {
                return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}请检查您所传递的参数是否有误!", code = "500" }));
            }
            //输出参数(绑定数据库中的配置表)
            for (int i = 0; i < outparameters.Length; i++)
            {
                int len = Int32.Parse(outtypes[i]) == 121 ? 1024 : (Int32.Parse(outtypes[i]) == 112 ? 200 : 200);
                parems.Add(GetOutput(outparameters[i], (OracleDbType)Int32.Parse(outtypes[i]), len));
            }
            //parems.Add(GetOutput("ResultSet", (OracleDbType)121, 1024));
            //parems.Add(GetOutput("ReturnCode", (OracleDbType)112, 200));
            //parems.Add(GetOutput("ErrorMsg", (OracleDbType)126, 200));
            db = db == null ? dbContext : db;
            var          ds  = SqlQuery(db, myconfig.PROCEDURENAME, parems.ToArray());
            ObjectResult obj = GetResult(parems, ds, outparameters, outtypes);

            if (myconfig.ISFY == "1")
            {
                if (!jobj.ContainsKey("Page"))
                {
                    return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}此接口需要分页,没有找到参数名为Page的参数!", code = "500" }));
                }
                if (!jobj.ContainsKey("pageSize"))
                {
                    return(new JsonResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}此接口需要分页,没有找到参数名为pageSize的参数!", code = "500" }));
                }
                int page      = int.Parse(jobj.GetValue("Page", StringComparison.OrdinalIgnoreCase).ToString());
                int pageCount = int.Parse(jobj.GetValue("pageSize", StringComparison.OrdinalIgnoreCase).ToString());
                obj = GetResult(parems, ds, page, pageCount);
            }
            if (Convert.ToInt32(myconfig.ISSONSHOW) == (int)SonShowType.科室查询)
            {
                obj = GetResultAndHaveSon(parems, ds);
            }
            else if (Convert.ToInt32(myconfig.ISSONSHOW) == (int)SonShowType.微生物查询)
            {
            }
            else if (Convert.ToInt32(myconfig.ISSONSHOW) == (int)SonShowType.费用查询)
            {
                if (!jobj.ContainsKey("type"))
                {
                    obj = new ObjectResult(new { msg = "请求失败", data = $"{ServiceModule}/{ServiceName}没有找到参数名为type的参数!", code = "500" });
                }
                if (jobj.GetValue("type").ToString() == "2")
                {
                    obj = this.GetHosListGroup(ds);
                }
                else if (jobj.GetValue("type").ToString() == "3")
                {
                    obj = this.GetHosListGroup(ds);
                }
                else
                {
                    //Console.WriteLine("返回参数:\n" + JsonConvert.SerializeObject(Methods.GetResult(parems, ds)));
                    obj = GetResult(parems, ds, outparameters, outtypes);
                }
            }
            return(obj);
        }
Exemplo n.º 14
0
 public ZHYYDbMethods(AbpvNextHISInterfaceDbContext dbContext)
 {
     this.dbContext = dbContext;
 }