From c63b40452aeaf1b46ef716da9f5dc9e8c2a843a6 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 13 七月 2022 20:30:33 +0800
Subject: [PATCH] 生产开报工提交

---
 VueWebApi/Tools/DapperHelper.cs |   74 ++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 1 deletions(-)

diff --git a/VueWebApi/Tools/DapperHelper.cs b/VueWebApi/Tools/DapperHelper.cs
index 132be16..fced6ea 100644
--- a/VueWebApi/Tools/DapperHelper.cs
+++ b/VueWebApi/Tools/DapperHelper.cs
@@ -29,8 +29,9 @@
             return connection;
         }
 
+
         /// <summary>
-        /// Dapper鏌ヨ杩斿洖List<T>
+        /// Dapper鏌ヨ杩斿洖List
         /// </summary>
         /// <typeparam name="T">闇�瑕佽繑鍥炵殑瀵硅薄绫诲瀷</typeparam>
         /// <param name="sql">Sql璇彞</param>
@@ -275,6 +276,41 @@
         }
 
         /// <summary>
+        /// Dapper鎵ц瀛樺偍杩囩▼杩斿洖datatable鏁版嵁(甯﹀弬鏁�)
+        /// </summary>
+        /// <param name="sql">瀛樺偍杩囩▼鍚�</param>
+        /// <param name="parm">鍙傛暟</param>
+        /// <returns></returns>
+        public static bool IsProcedure(string sql, Object parm)
+        {
+            bool result;
+            //sql璇彞
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    DataTable table = new DataTable();
+                    //var data = conn.ExecuteReader(sql, parm);
+                    var res = conn.ExecuteReader(sql, parm, commandType: CommandType.StoredProcedure);//sql 瀛樺偍杩囩▼ 
+                    result = true;
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    result = false;
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+                return result;
+            }
+        }
+
+        /// <summary>
         /// Dapper鏌ヨ杩斿洖鏁版嵁鏉℃暟
         /// </summary>
         /// <param name="sql"></param>
@@ -374,6 +410,42 @@
             }
         }
 
+        /// <summary>
+        /// 澧炲姞锛屽垹闄わ紝淇敼浣跨敤鐨� 浜嬪姟鏂规硶  Sqllist涓轰緷娆℃墽琛�
+        /// </summary>
+        /// <param name="sqlList"></param>
+        /// <returns></returns>
+        public static int DoTransactionCont(List<object> sqlList)
+        {
+            int result = 0;
+            IDbTransaction tranction = null;
+            using (IDbConnection conn = sqlConnection())
+            {
+                try
+                {
+                    tranction = conn.BeginTransaction();
+                    for (int i = 0; i < sqlList.Count; i++)
+                    {
+                        result += conn.Execute(sqlList[i].GetType().GetProperty("str").GetValue(sqlList[i], null).ToString(), sqlList[i].GetType().GetProperty("parm").GetValue(sqlList[i], null), tranction);
+                    }
+                    tranction.Commit();
+                }
+                catch (Exception ex)
+                {
+                    //鍒涘缓鏃ュ織璁板綍缁勪欢瀹炰緥
+                    LogHelper.WriteLog(ex);
+                    tranction.Rollback();
+                    throw ex;
+                }
+                finally
+                {
+                    conn.Dispose();
+                    conn.Close();
+                }
+                return result;
+            }
+        }
+
 
         /// <summary>
         /// Dapper鎻掑叆 杩斿洖鑷涓婚敭Id

--
Gitblit v1.9.3