Ejemplo n.º 1
0
        public IRAPJsonResult GetDataTableWithSQL(
            string sqlCmd,
            out int errCode,
            out string errText)
        {
            string strProcedureName =
                string.Format(
                    "{0}.{1}",
                    className,
                    MethodBase.GetCurrentMethod().Name);

            WriteLog.Instance.WriteBeginSplitter(strProcedureName);
            try
            {
                DataTable rlt = new DataTable("PrintData");

                #region 创建数据库调用参数组,并赋值
                WriteLog.Instance.Write(
                    string.Format("调用SQL命令[{0}]", sqlCmd),
                    strProcedureName);
                #endregion

                #region 执行数据库函数或存储过程
                try
                {
                    using (IRAPSQLConnection conn = new IRAPSQLConnection())
                    {
                        rlt = conn.QuerySQL(sqlCmd);
                        if (rlt != null)
                        {
                            errCode = 0;
                            errText =
                                string.Format(
                                    "调用成功!获得 {0} 条记录",
                                    (rlt as DataTable).Rows.Count);
                            WriteLog.Instance.Write(errText, strProcedureName);
                        }
                        else
                        {
                            errCode = 99999;
                            errText = "未得到返回的结果集";
                            rlt     = new DataTable("PrintData");
                        }
                        return(Json(rlt));
                    }
                }
                catch (Exception error)
                {
                    errCode = 99000;
                    errText = string.Format("调用失败:{0}", error.Message);
                    WriteLog.Instance.Write(errText, strProcedureName);
                    return(Json(rlt));
                }
                #endregion
            }
            finally
            {
                WriteLog.Instance.WriteEndSplitter(strProcedureName);
                WriteLog.Instance.Write("");
            }
        }
Ejemplo n.º 2
0
        public IRAPJsonResult ufn_OLTP_StringValid(
            string menuParameters,
            int processLeaf,
            int workUnitLeaf,
            string inputStr,
            string opNodes,
            string tvCtrlParameters,
            int tabOrderID,
            long sysLogID,
            out int errCode,
            out string errText)
        {
            string strProcedureName =
                string.Format(
                    "{0}.{1}",
                    className,
                    MethodBase.GetCurrentMethod().Name);

            WriteLog.Instance.WriteBeginSplitter(strProcedureName);
            try
            {
                DataTable rlt    = new DataTable("PrintData");
                string    sqlCmd =
                    string.Format(
                        "SELECT * FROM ufn_OLTP_{0}(@ProcessLeaf, @WorkUnitLeaf, " +
                        "@InputStr, @OpNodes, @TVCtrlParameters, @TabOrderID, " +
                        "@SysLogID) ORDER BY Ordinal",
                        menuParameters);

                #region 创建数据库调用参数组,并赋值
                IList <IDataParameter> paramList = new List <IDataParameter>();
                paramList.Add(new IRAPProcParameter("@ProcessLeaf", DbType.Int32, processLeaf));
                paramList.Add(new IRAPProcParameter("@WorkUnitLeaf", DbType.Int32, workUnitLeaf));
                paramList.Add(new IRAPProcParameter("@InputStr", DbType.String, inputStr));
                paramList.Add(new IRAPProcParameter("@OpNodes", DbType.String, opNodes));
                paramList.Add(new IRAPProcParameter("@TVCtrlParameters", DbType.String, tvCtrlParameters));
                paramList.Add(new IRAPProcParameter("@TabOrderID", DbType.Int32, tabOrderID));
                paramList.Add(new IRAPProcParameter("@SysLogID", DbType.Int64, sysLogID));
                WriteLog.Instance.Write(
                    string.Format(
                        "调用SQL命令[{0}],参数:" +
                        "ProcessLeaf={1}|WorkUnitLeaf={2}|InputStr={3}|" +
                        "OpNodes={4}|TVCtrlParameters={5}|TabOrderID={6}|" +
                        "SysLogID={7}",
                        sqlCmd, processLeaf, workUnitLeaf, inputStr, opNodes,
                        tvCtrlParameters, tabOrderID, sysLogID),
                    strProcedureName);
                #endregion

                #region 执行数据库函数或存储过程
                try
                {
                    using (IRAPSQLConnection conn = new IRAPSQLConnection())
                    {
                        rlt = conn.QuerySQL(sqlCmd);
                        if (rlt != null && rlt.Rows.Count > 0)
                        {
                            DataRow dr = rlt.Rows[0];
                            errCode = Convert.ToInt32(dr["ErrCode"].ToString());
                            errText = dr["ErrText"].ToString();
                        }
                        else
                        {
                            errCode = -1;
                            errText = "校验函数没有返回校验结果!";
                        }
                        WriteLog.Instance.Write(errText, strProcedureName);
                        return(Json(""));
                    }
                }
                catch (Exception error)
                {
                    errCode = 99000;
                    errText = string.Format("调用失败:{0}", error.Message);
                    WriteLog.Instance.Write(errText, strProcedureName);
                    return(Json(""));
                }
                #endregion
            }
            finally
            {
                WriteLog.Instance.WriteEndSplitter(strProcedureName);
                WriteLog.Instance.Write("");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 调用加载存储过程
        /// </summary>
        /// <param name="communityID">社区标识</param>
        /// <param name="t19LeafID">导入导出叶标识</param>
        /// <param name="treeID">导入关联树标识</param>
        /// <param name="txLeafID">导出导出关联树叶标识</param>
        /// <param name="importLogID"></param>
        /// <param name="sysLogID">系统登录标识</param>
        /// <param name="blName"></param>
        /// <param name="loadName">验证存储过程名</param>
        /// <param name="IncludeAll">是否导入全量</param>
        /// <param name="MigrateImportLog">加载后是否迁移导入日志</param>
        /// <param name="isLoad">是否是加载</param>
        /// <returns></returns>
        public IRAPJsonResult ProcOnLoad(int communityID, int t19LeafID, int treeID, int txLeafID, long importLogID, long sysLogID,
                                         string blName, string loadName, int isLaodAll, int isLoadLog, bool isLoad, out int errCode, out string errText)
        {
            string strProcedureName = string.Format("{0}.{1}", className, MethodBase.GetCurrentMethod().Name);

            WriteLog.Instance.WriteBeginSplitter(strProcedureName);

            DataTable dt = new DataTable("grid");

            try
            {
                #region 创建数据库调用参数组,并赋值
                IList <IDataParameter> paramList = new List <IDataParameter>();
                paramList.Add(new IRAPProcParameter("@communityID", DbType.Int32, communityID));
                paramList.Add(new IRAPProcParameter("@t19LeafID", DbType.Int32, t19LeafID));
                paramList.Add(new IRAPProcParameter("@treeID", DbType.Int32, treeID));
                paramList.Add(new IRAPProcParameter("@txLeafID", DbType.Int32, txLeafID));
                paramList.Add(new IRAPProcParameter("@importLogID", DbType.Int64, importLogID));
                paramList.Add(new IRAPProcParameter("@blName", DbType.String, blName));
                paramList.Add(new IRAPProcParameter("@sysLogID", DbType.Int64, sysLogID));
                paramList.Add(new IRAPProcParameter("@ErrCode", DbType.Int32, ParameterDirection.Output, 8));
                paramList.Add(new IRAPProcParameter("@ErrText", DbType.String, ParameterDirection.Output, 800));
                if (isLoad)
                {
                    paramList.Add(new IRAPProcParameter("@isLaodAll", DbType.Boolean, isLaodAll));
                    paramList.Add(new IRAPProcParameter("@MigrateImportLog ", DbType.Boolean, isLoadLog));
                    WriteLog.Instance.Write(
                        string.Format(
                            "调用存储过程{0},参数:communityID={1}|t19LeafID={2}|treeID={3}|txLeafID={4}|importLogID={5}|blName={6}|sysLogID={7}|isLaodAll={8}|isLoadLog={9}",
                            loadName, communityID, t19LeafID, treeID, txLeafID, importLogID, blName, sysLogID, isLaodAll, isLoadLog), strProcedureName);
                }
                else
                {
                    WriteLog.Instance.Write(
                        string.Format(
                            "调用存储过程{0},参数:communityID={1}|t19LeafID={2}|treeID={3}|txLeafID={4}|importLogID={5}|blName={6}|sysLogID={7}",
                            loadName, communityID, t19LeafID, treeID, txLeafID, importLogID, blName, sysLogID), strProcedureName);
                }
                #endregion

                #region 执行数据库函数或存储过程
                try
                {
                    using (IRAPSQLConnection conn = new IRAPSQLConnection())
                    {
                        var err = conn.CallProc("IRAPDPA.." + loadName + "", ref paramList);
                        errCode = 0;
                        errText = string.Format("调用存储过程{0}成功", loadName);
                        WriteLog.Instance.Write(errText, strProcedureName);

                        dt = conn.QuerySQL(string.Format("select * from IRAPDPA..{0} where PartitioningKey={1} and ImportLogID={2}", blName, communityID * 10000, importLogID));
                        return(Json(dt));
                    }
                }
                catch (Exception ex)
                {
                    IRAPError errInfo = new IRAPError(9999, ex.Message);
                    errCode = 9999;
                    errText = string.Format("调用存储过程{0}异常:{1}", loadName, ex.Message);
                    WriteLog.Instance.Write(errText, strProcedureName);
                    WriteLog.Instance.Write(ex.StackTrace, strProcedureName);
                }


                #endregion
            }
            finally
            {
                WriteLog.Instance.WriteEndSplitter(strProcedureName);
            }
            return(Json(dt));
        }