Exemplo n.º 1
0
        /// <summary>
        /// Fills the DataTable's DataSet with data from the stored procedure.
        /// </summary>
        /// <param name="dataSet">The DataSet to fill.</param>
        /// <param name="storedProcedureName">The stored procedure to execute.</param>
        /// <param name="parameterValues">The values to pass to the stored procedure.</param>
        /// <returns>The SqlParameters from the stored procedure.</returns>
        public static void LoadDataSet(DataSet dataSet, String strProcName, IDictionary listParamItems)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("DataSet");
            }
            if (strProcName == null)
            {
                throw new ArgumentNullException("localProcDetails");
            }
            CleanupParameters(listParamItems);
            SqlParameter[] inputParamList = null;

            try
            {
                if (!DataLayerRepository.CheckInputParams(listParamItems))
                {
                    // Get the parameters corresponding to this sproc
                    inputParamList = GetSpParameterSet(strProcName);
                    ////Commented the Calling method and recalled the mehod from same class
                    //SqlHelperParameterCache.GetSpParameterSet(tempStrDetails, strProcName);
                    // Populate the parameters with the values supplied
                    AssignSqlParameterValues(inputParamList, listParamItems);
                    // var tempType = "StoredProcedure"; //CommandType.StoredProcedure.ToString();
                    //// SqlHelper.FillDataset(connectionString, CommandType.StoredProcedure, storedProcedureName, dataSet, null, commandParameters);
                    TerraScan.UtilityWrapper.UtilityWrapper.FillingResultValue(strProcName, dataSet, null, inputParamList);
                }
            }
            catch (Exception)
            {
                throw;
            }
            //return (IList)inputParamList;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes this stored procedure with these parameters.
        /// </summary>
        /// <param name="storedProcedureName">The stored procedure to execute.</param>
        /// <param name="parameterValues">The SqlParameters to use.</param>
        /// <returns>List of parameters</returns>
        ///
        public static void ImplementProcedure(String localProcDetails, IDictionary listParam)
        {
            if (localProcDetails == null)
            {
                throw new ArgumentNullException("localProcDetails");
            }
            CleanupParameters(listParam);
            SqlParameter[] inputParamList = null;

            try
            {
                if (!DataLayerRepository.CheckInputParams(listParam))
                {
                    // Get the parameters corresponding to this sproc
                    inputParamList = GetSpParameterSet(localProcDetails);
                    ////Commented by purushotham and recalled the method from utility itself
                    //SqlHelperParameterCache.GetSpParameterSet(tempStrDetails, localProcDetails);
                    // Populate the parameters with the values supplied
                    AssignSqlParameterValues(inputParamList, listParam);
                    // var tempType = "StoredProcedure";
                    //  SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, storedProcedureName, commandParameters);
                    TerraScan.UtilityWrapper.UtilityWrapper.NonQueryResultMethod(localProcDetails, inputParamList);
                }
            }
            catch (Exception)
            {
                throw;
                //HandleException(storedProcedureName, e, commandParameters);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Fetches the sp object.
 /// </summary>
 /// <param name="localStr">The local STR.</param>
 /// <param name="procDetail">The proc detail.</param>
 /// <param name="paramAndValue">The param and value.</param>
 /// <returns></returns>
 public static object FetchSpObject(string procDetail, IDictionary listParamItems)
 {
     try
     {
         if (!DataLayerRepository.CheckInputParams(listParamItems))
         {
             return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperSALFetchSpObject(procDetail, listParamItems));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Excecutes the SP.
 /// </summary>
 /// <param name="localStr">The local STR.</param>
 /// <param name="procDetail">The proc detail.</param>
 /// <param name="listParamItems">The list param items.</param>
 /// <returns></returns>
 public static int LoadProcedureItem(string procDetail, IDictionary listParamItems)
 {
     try
     {
         if (!DataLayerRepository.CheckInputParams(listParamItems))
         {
             return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperSALExcecuteSP(procDetail, listParamItems));
         }
         else
         {
             return(0);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Fetches the SP execute output value.
 /// </summary>
 /// <param name="dataTable">The data table.</param>
 /// <param name="localProcDetails">The local proc details.</param>
 /// <param name="listParamItems">The list param items.</param>
 /// <returns></returns>
 public static IList FetchSPExecuteOutputValue(DataTable dataTable, string localProcDetails, IDictionary listParamItems)
 {
     try
     {
         if (!DataLayerRepository.CheckInputParams(listParamItems))
         {
             return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperFetchSPOutputValue(dataTable, localProcDetails, listParamItems));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Method to execute query and fetch value returned by stored procedure
 /// added output parameter and it will retrun new added record.
 /// </summary>
 /// <param name="storedProcedure">The name of the stored procedure to be executed.</param>
 /// <param name="paramAndValue">The parameters and value for them stored in Dictionary.</param>
 /// <returns>retruns the string</returns>
 public static string FetchSPExecuteXmlString(string localProcDetails, IDictionary listParamItems)
 {
     try
     {
         if (!DataLayerRepository.CheckInputParams(listParamItems))
         {
             return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperFetchSPXmlString(localProcDetails, listParamItems));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Common method to get single output parameter
 /// </summary>
 /// <param name="storedProcedure">Stored Procedure Name</param>
 /// <param name="paramAndValue">Parameter collection with value</param>
 /// <param name="outputParamName">Ouput parameter name</param>
 /// <returns>Output string returned from SP</returns>
 public static string FetchSingleOuputParameter(string localProcDetails, IDictionary listParamItems, string outputParamName)
 {
     try
     {
         if (!DataLayerRepository.CheckInputParams(listParamItems))
         {
             return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperFetchSingleOuputParameter(localProcDetails, listParamItems, outputParamName));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 8
0
 public static IList SPParameters(string localProcDetails, DataTable dataTable1, IDictionary listParamItems, DataTable dataTable)
 {
     try
     {
         if (!DataLayerRepository.CheckInputParams(listParamItems))
         {
             return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperSPParameters(localProcDetails, dataTable1, listParamItems, dataTable));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Method to execute query and fetch value returned by stored procedure
        /// </summary>
        /// <param name="storedProcedure">The name of the stored procedure to be executed.</param>
        /// <param name="paramAndValue">The parameters and value for them stored in Dictionary.</param>
        /// <returns>
        /// The return value(int) from the executed query result.
        /// </returns>


        public static int FetchSPOutput(string localProcDetails, IDictionary listParam)
        {
            try
            {
                if (!DataLayerRepository.CheckInputParams(listParam))
                {
                    return(TerraScan.UtilityWrapper.UtilityWrapper.WrapperFetchSPOutput(localProcDetails, listParam));
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Fills the DataTable's DataSet with data from the stored procedure.
        /// </summary>
        /// <param name="table">The DataTable to fill.</param>
        /// <param name="storedProcedureName">The stored procedure to execute.</param>
        /// <param name="parameterValues">The values to pass to the stored procedure.</param>
        /// <returns>The SqlParameters from the stored procedure.</returns>
        public static IList LoadDataSet(DataTable table, String localProcDetails, IDictionary listParam)
        {
            if (table == null)
            {
                throw new ArgumentNullException("DataTable");
            }
            if (localProcDetails == null)
            {
                throw new ArgumentNullException("localProcDetails");
            }
            CleanupParameters(listParam);
            SqlParameter[] inputParamList = null;

            try
            {
                if (!DataLayerRepository.CheckInputParams(listParam))
                {
                    // Get the parameters corresponding to this sproc
                    inputParamList = GetSpParameterSet(localProcDetails);
                    //SqlHelperParameterCache.GetSpParameterSet(tempStrDetails, localProcDetails);
                    // Populate the parameters with the values supplied
                    AssignSqlParameterValues(inputParamList, listParam);
                    string[] tableNames = { table.TableName };
                    // var tempType = "StoredProcedure";
                    // SqlHelper.FillDataset(connectionString, CommandType.StoredProcedure, storedProcedureName, table.DataSet, tableNames, commandParameters);
                    TerraScan.UtilityWrapper.UtilityWrapper.FillingResultValue(localProcDetails, table.DataSet, tableNames, inputParamList);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(inputParamList);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Returns a readable string for a SqlCommand.
        /// </summary>
        /// <param name="commandText">Command text</param>
        /// <param name="commandParameters">List of parameters</param>
        /// <returns>Sql command</returns>
        private static string CreateExecString(string instructionText, SqlParameter[] inputListValues)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("exec ");
            builder.Append(instructionText);
            builder.Append(" ");
            if (!DataLayerRepository.ValidateInputParams(inputListValues))
            {
                foreach (SqlParameter parameter in inputListValues)
                {
                    if (parameter.Value == DBNull.Value)
                    {
                        builder.AppendFormat(parameter.ParameterName);
                        builder.Append("= NULL,");
                        continue;
                    }
                    if (parameter.Direction != ParameterDirection.ReturnValue && parameter.Value != null)
                    {
                        builder.AppendFormat(parameter.ParameterName);

                        switch (parameter.SqlDbType)
                        {
                        case SqlDbType.VarChar:

                        case SqlDbType.Char:

                        case SqlDbType.NVarChar:

                        case SqlDbType.NChar:

                        case SqlDbType.UniqueIdentifier:

                        case SqlDbType.Text:

                        case SqlDbType.NText:

                        case SqlDbType.SmallDateTime:

                        case SqlDbType.DateTime:
                            builder.Append("= '");
                            builder.Append(parameter.Value);
                            builder.Append("', ");
                            break;

                        case SqlDbType.Int:
                            builder.Append("= ");
                            builder.Append(Convert.ToInt32(parameter.Value));
                            builder.Append(", ");
                            break;

                        default:
                            builder.Append("= ");
                            builder.Append(parameter.Value);
                            builder.Append(", ");
                            break;
                        }
                    }
                }
                return(builder.ToString(0, builder.Length - 2));
            }
            else
            {
                return(null);
            }
        }