Пример #1
0
        public static ResultArgs FetchData <T>(OracleParameter[] param, string sSQL, EnumCommand.DataSource dataSourceType, string sAcademicYear = "") where T : new()
        {
            ResultArgs resultArgs = new ResultArgs();
            DataValue  dv         = new DataValue();

            dv.Clear();
            try
            {
                if (string.IsNullOrEmpty(sSQL))
                {
                    resultArgs.Success = false;
                    resultArgs.Message = Common.Message.QueryIsEmpty;
                    return(resultArgs);
                }
                if (sAcademicYear != string.Empty)
                {
                    sSQL = sSQL.Replace(Common.Delimiter.QUS + "", sAcademicYear);
                }
                //if (param != null)
                //{
                //    DataValue Construction
                //    foreach (var prop in obj.GetType().GetProperties())
                //    {
                //        objValue = prop.GetValue(obj, null);
                //        objValue = (objValue == null) ? string.Empty : objValue.ToString();
                //        dv.Add(prop.Name, objValue.ToString(), EnumCommand.DataType.String);
                //    }
                //}
                if (dataSourceType == EnumCommand.DataSource.list)
                {
                    using (OracleHelper objHelper = new OracleHelper())
                    {
                        resultArgs = objHelper.FecthDataAsList <T>(sSQL, param, EnumCommand.SQLType.StoredProcedure);
                    }
                }
                else
                {
                    using (OracleHelper objHelper = new OracleHelper())
                    {
                        resultArgs = objHelper.FetchData(sSQL, dataSourceType, param, EnumCommand.SQLType.StoredProcedure);
                    }
                }
            }
            catch (System.Exception ex)
            {
                using (ErrorLog objlog = new ErrorLog())
                {
                    objlog.WriteError("OracleHelper", "FetchData", sSQL, ex.Message);
                }
                resultArgs.Success = false;
            }
            return(resultArgs);
        }