예제 #1
0
        /// <summary>
        /// ErpWriteback
        /// </summary>
        /// <param name="logAppendToForms"></param>
        /// <param name="writebackParam"></param>
        /// <returns></returns>
        public bool ErpWriteback(Log4netUtil.LogAppendToForms logAppendToForms, Model.WritebackParam writebackParam)
        {
            string logMessage     = string.Empty;
            string procedureName  = writebackParam.ProcedureName;
            string targetDatabase = writebackParam.TargetDatabase;

            IDAL.IDBHelper _idbHelper = DALFactory.DBHelperFactory.CreateInstance(targetDatabase);//创建接口
            System.Data.Common.DbParameter[] cmdParams = { _idbHelper.CreateInParam(targetDatabase, ":i_WritebackType", writebackParam.WritebackType),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_BillCodes",     string.IsNullOrEmpty(writebackParam.BillCodes)?string.Empty:writebackParam.BillCodes),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_Type",          string.IsNullOrEmpty(writebackParam.Type)?string.Empty:writebackParam.Type),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_Status",        writebackParam.Status),
                                                           _idbHelper.CreateInParam(targetDatabase, ":i_WritebackInfo", string.IsNullOrEmpty(writebackParam.WritebackInfo)?string.Empty:writebackParam.WritebackInfo) };
            try
            {
                writebackParam.IsDebug = true;
                int r = _idbHelper.ExecuteNonQuery(System.Data.CommandType.StoredProcedure, procedureName, targetDatabase, cmdParams);
                if (r > 0)
                {
                    string jsonSql = Util.DbSqlLog.SqlToJson("0000", procedureName, cmdParams);
                    logMessage = string.Format("ErpWriteback回写成功!!!{0}", string.Empty);
                    Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                    resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("0000"));
                    resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                    resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                    logMessage = string.Format("【{0}_{1}】 {2}", writebackParam.jobInfo.JobCode, writebackParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                    Log4netUtil.Log4NetHelper.LogMessage(logAppendToForms, writebackParam.IsDebug, logMessage, @"Database");
                    return(true);
                }
                else
                {
                    string jsonSql = Util.DbSqlLog.SqlToJson("9999", procedureName, cmdParams);
                    logMessage = string.Format("ErpWriteback回写失败!!!!{0}", string.Empty);
                    Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                    resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                    resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                    resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                    logMessage = string.Format("【{0}_{1}】 {2}", writebackParam.jobInfo.JobCode, writebackParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                    Log4netUtil.Log4NetHelper.LogError(logAppendToForms, writebackParam.IsDebug, logMessage, @"Database");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                string jsonSql = Util.DbSqlLog.SqlToJson("9999", procedureName, cmdParams);
                logMessage = string.Format("ErpWriteback回写失败!!!原因:{0};", ex.Message);
                Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                logMessage = string.Format("【{0}_{1}】 {2}", writebackParam.jobInfo.JobCode, writebackParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                Log4netUtil.Log4NetHelper.LogError(logAppendToForms, writebackParam.IsDebug, logMessage, @"Database");
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// GetDgvDtAll
        /// </summary>
        /// <param name="logAppendToForms"></param>
        /// <param name="searchParam"></param>
        /// <returns></returns>
        public System.Data.DataTable GetDgvDtAll(Log4netUtil.LogAppendToForms logAppendToForms, Model.SearchParam searchParam)
        {
            string storedProcedureName = searchParam.ProcedureName;
            string targetDatabase      = searchParam.TargetDatabase;
            string logMessage          = string.Empty;

            IDAL.IDBHelper _idbHelper = DALFactory.DBHelperFactory.CreateInstance(targetDatabase);//创建接口
            System.Data.Common.DbParameter[] cmdParams = { _idbHelper.CreateInParam(targetDatabase,  ":i_ModuleID",   searchParam.ModuleID),
                                                           _idbHelper.CreateInParam(targetDatabase,  ":i_IsMaintain", searchParam.IsMaintain),
                                                           _idbHelper.CreateInParam(targetDatabase,  ":i_FilterFlag", searchParam.FilterFlag),
                                                           _idbHelper.CreateInParam(targetDatabase,  ":i_StartDate",  searchParam.StartDate),
                                                           _idbHelper.CreateInParam(targetDatabase,  ":i_EndDate",    searchParam.EndDate),
                                                           _idbHelper.CreateInParam(targetDatabase,  ":i_Logogram",   searchParam.Logogram),
                                                           _idbHelper.CreateInParam(targetDatabase,  ":i_BillCode",   searchParam.BillCode),
                                                           _idbHelper.CreateOutParam(targetDatabase, ":o_return",     System.Data.DbType.Object) };
            System.Data.DataTable            dt = null;
            try
            {
                dt = _idbHelper.ExecuteNQuery(System.Data.CommandType.StoredProcedure, storedProcedureName, targetDatabase, cmdParams);//调用接口的方法
                string jsonSql = Util.DbSqlLog.SqlToJson("0000", storedProcedureName, cmdParams);
                logMessage = string.Format("GetDgvDtAll  获取数据 执行ExecuteNQuery成功!{0}", string.Empty);
                Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("0000"));
                resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                logMessage = string.Format("【{0}_{1}】 {2}", searchParam.jobInfo.JobCode, searchParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                Log4netUtil.Log4NetHelper.LogMessage(logAppendToForms, searchParam.IsDebug, logMessage, @"Database");
            }
            catch (Exception ex)
            {
                string jsonSql = Util.DbSqlLog.SqlToJson("9999", storedProcedureName, cmdParams);
                logMessage = string.Format("GetDgvDtAll  获取数据 执行ExecuteNQuery失败;失败原因:{0}", ex.Message);
                Newtonsoft.Json.Linq.JObject resultJObject = new Newtonsoft.Json.Linq.JObject();
                resultJObject.Add("code", new Newtonsoft.Json.Linq.JValue("9999"));
                resultJObject.Add("msg", new Newtonsoft.Json.Linq.JValue(logMessage));
                resultJObject.Add("sql", new Newtonsoft.Json.Linq.JObject(Newtonsoft.Json.Linq.JObject.Parse(jsonSql)));
                logMessage = string.Format("【{0}_{1}】 {2}", searchParam.jobInfo.JobCode, searchParam.jobInfo.JobName.ToString(), Util.NewtonsoftCommon.SerializeObjToJson(resultJObject));
                Log4netUtil.Log4NetHelper.LogError(logAppendToForms, searchParam.IsDebug, logMessage, @"Database");
                dt = null;
            }
            return(dt);
        }