Beispiel #1
0
        public IRAPJsonResult InsertTempTableData(string tableName, DataTable data, out int errCode, out string errText)
        {
            string strProcedureName = string.Format("{0}.{1}", className, MethodBase.GetCurrentMethod().Name);

            WriteLog.Instance.WriteBeginSplitter(strProcedureName);
            List <IRAPError> result = new List <IRAPError>();

            try
            {
                #region 创建数据库调用参数组,并赋值
                WriteLog.Instance.Write(
                    string.Format("将数据插入临时表{0}中", tableName),
                    strProcedureName);
                #endregion

                #region 执行数据库函数或存储过程
                try
                {
                    using (IRAPSQLConnection conn = new IRAPSQLConnection())
                    {
                        var errInfo = conn.BulkBatchInsert(data, "IRAPDPA.." + tableName + "");
                        errCode = errInfo.ErrCode;
                        errText = errInfo.ErrText;
                        WriteLog.Instance.Write(errInfo.ErrText, strProcedureName);
                        result.Add(errInfo);
                    }
                }
                catch (Exception ex)
                {
                    IRAPError errInfo = new IRAPError(9999, ex.Message);
                    errCode = 9999;
                    errText = string.Format("插入表{1}中的数据发生异常:{0}", ex.Message, tableName);
                    WriteLog.Instance.Write(errText, strProcedureName);
                    WriteLog.Instance.Write(ex.StackTrace, strProcedureName);
                    result.Add(errInfo);
                }
                #endregion
            }
            finally
            {
                WriteLog.Instance.WriteEndSplitter(strProcedureName);
            }
            return(Json(result));
        }