Exemplo n.º 1
0
 static public int wrap(Func <OracleConnection, int> func)
 {
     using (OracleConnection conn = new OracleConnection(ConnStr.getConnStr()))
     {
         try
         {
             conn.ConnectionString = ConnStr.getConnStr();
             conn.Open();
             var re = func(conn);
             conn.Close();
             return(re);
         }
         catch (Exception e)
         {
             return(-1);
         }
     }
 }
Exemplo n.º 2
0
        static public async Task <Boolean> wrap(Func <OracleConnection, Task <Boolean> > func)
        {
            using (OracleConnection conn = new OracleConnection(ConnStr.getConnStr()))
            {
                try
                {
                    conn.ConnectionString = ConnStr.getConnStr();
                    conn.Open();
                    var re = await func(conn);

                    conn.Close();
                    return(re);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
        static public async Task <UserController.UserPublicInfo> wrap(Func <OracleConnection, Task <UserController.UserPublicInfo> > func)
        {
            using (OracleConnection conn = new OracleConnection(ConnStr.getConnStr()))
            {
                try
                {
                    conn.ConnectionString = ConnStr.getConnStr();
                    conn.Open();
                    var re = await func(conn);

                    conn.Close();
                    return(re);
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
        }
Exemplo n.º 4
0
 static public IActionResult wrap(Func <OracleConnection, IActionResult> func)
 {
     using (OracleConnection conn = new OracleConnection(ConnStr.getConnStr()))
     {
         try
         {
             conn.ConnectionString = ConnStr.getConnStr();
             conn.Open();
             var re = func(conn);
             conn.Close();
             return(re);
         }
         catch (Exception e)
         {
             RestfulResult.RestfulData rr = new RestfulResult.RestfulData(500, "fail");
             Console.Write(e.Message);
             Console.Write(e.StackTrace);
             return(new JsonResult(rr));
         }
     }
 }