public string Set(ArrayList param, string SPName, out long ReturnValue, int CompanyIndex = 0) { ReturnValue = 0L; try { if (General.DataBase.Equals("SQL")) { SQLDBResult dbResult = SQLAdapter.Execute(SPName, param, SQLAdapter.GetConnection(CompanyIndex)); ReturnValue = Convert.ToInt64(dbResult.Parameters[(object)"@RETURN_VALUE"]); this.LogException(param, SPName, CompanyIndex, dbResult, "", ReturnValue); if (dbResult.Contents != null) { if (dbResult.Contents.Tables.Count > 0) { if (dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows.Count > 0) { if (dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Columns.Contains("ErrorMessage")) { return(dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows[0]["ErrorMessage"].ToString()); } else if (dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Columns.Contains("DOCNAME")) { return(dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows[0]["DOCNAME"].ToString()); } } } } } } catch (Exception ex) { this.LogException(param, SPName, CompanyIndex, (SQLDBResult)null, ex.Message, ReturnValue); } return(string.Empty); }
public string Get(ArrayList param, string SPName, out string OutputParameterName, int iFlg, int CompanyIndex = 0) { OutputParameterName = ""; long ReturnValue = 0; try { if (General.DataBase.Equals("SQL")) { SQLDBResult dbResult = SQLAdapter.Execute(SPName, param, SQLAdapter.GetConnection(CompanyIndex)); if (dbResult.Parameters.ContainsKey((object)"@CodeGenerated")) { OutputParameterName = dbResult.Parameters[(object)"@CodeGenerated"].ToString(); } ReturnValue = Convert.ToInt64(dbResult.Parameters[(object)"@RETURN_VALUE"]); this.LogException(param, SPName, CompanyIndex, dbResult, "", ReturnValue); return(OutputParameterName); } } catch (Exception ex) { this.LogException(param, SPName, CompanyIndex, (SQLDBResult)null, ex.Message, ReturnValue); } return(""); }
public DataSet SetWithDataSet(ArrayList param, string SPName, out long ReturnValue, int CompanyIndex = 0) { ReturnValue = 0L; try { if (General.DataBase.Equals("SQL")) { SQLDBResult dbResult = SQLAdapter.Execute(SPName, param, SQLAdapter.GetConnection(CompanyIndex)); ReturnValue = Convert.ToInt64(dbResult.Parameters[(object)"@RETURN_VALUE"]); this.LogException(param, SPName, CompanyIndex, dbResult, "", ReturnValue); return(dbResult.Contents); } } catch (Exception ex) { this.LogException(param, SPName, CompanyIndex, (SQLDBResult)null, ex.Message, ReturnValue); } return(new DataSet()); }
public static SQLDBResult Execute(string procedureName, ArrayList procedureParameters, string strConnection) { SQLDBResult sqldbResult = (SQLDBResult)null; SqlConnection connection = (SqlConnection)null; try { connection = new SqlConnection(strConnection); connection.Open(); SqlCommand selectCommand = SQLAdapter.Procedure(connection, procedureName, (SqlTransaction)null).Command(connection, procedureParameters); selectCommand.CommandTimeout = 0; sqldbResult = new SQLDBResult(); new SqlDataAdapter(selectCommand).Fill(sqldbResult.Contents); foreach (SqlParameter sqlParameter in (DbParameterCollection)selectCommand.Parameters) { switch (sqlParameter.Direction) { case ParameterDirection.Output: case ParameterDirection.InputOutput: case ParameterDirection.ReturnValue: sqldbResult.Parameters[(object)sqlParameter.ParameterName] = sqlParameter.Value; continue; default: continue; } } } catch (Exception ex) { throw new SQLAdapter.DbUtilException(ex.Message, ex); } finally { if (connection != null && connection.State == ConnectionState.Open) { connection.Close(); } } return(sqldbResult); }
public DataSet Get(ArrayList param, string SPName, int CompanyIndex = 0) { DataSet dataSet = new DataSet(); long ReturnValue = 0L; try { if (General.DataBase.Equals("SQL")) { SQLDBResult dbResult = SQLAdapter.Execute(SPName, param, SQLAdapter.GetConnection(CompanyIndex)); dataSet = dbResult.Contents; ReturnValue = Convert.ToInt64(dbResult.Parameters[(object)"@RETURN_VALUE"]); //if (SPName == "sp_GetUserDetails") // throw new Exception(); this.LogException(param, SPName, CompanyIndex, dbResult, "", ReturnValue); } } catch (Exception ex) { this.LogException(param, SPName, CompanyIndex, (SQLDBResult)null, ex, ReturnValue); } return(dataSet); }
private void LogException(ArrayList param, string SPName, int CompanyIndex, SQLDBResult dbResult, string Message, long ReturnValue) { PLog.Info(this.GetParamString(param) + " : SPName:" + SPName); //PLog.Error(this.GetParamString(param) +""+,); //if (dbResult != null) //{ // if (dbResult.Contents.Tables.Count > 0 && dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Columns.Contains("ServerMessage") && dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows.Count > 0) // { // Logger.Instance(); // Logger.DebugLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName, "paramerters" + this.GetParamString(param) + " message=" + dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows[0]["ServerMessage"].ToString()); // } // if (dbResult.Contents.Tables.Count > 0 && dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Columns.Contains("ErrorMessage") && dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows.Count > 0) // { // Logger.Instance(); // Logger.DebugLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName, "paramerters" + this.GetParamString(param) + " message=" + dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows[0]["ErrorMessage"].ToString()); // } // else // { // Logger.Instance(); // Logger.DebugLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName, "paramerters" + this.GetParamString(param)); // } // if (ReturnValue != -999L || dbResult.Contents.Tables.Count <= 0 || dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows.Count <= 0) // return; // Logger.Instance(); // Logger.InfoLog("OnStartup: Logger Instance Created Successfully"); // Logger.InfoLog("OnStartup: Application Starting..."); // if (dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Columns.Contains("ServerMessage")) // Logger.ErrorLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName + "Parameters :" + this.GetParamString(param), dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows[0]["ServerMessage"].ToString()); // else if (dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Columns.Contains("ErrorMessage")) // Logger.ErrorLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName + "Parameters :" + this.GetParamString(param), dbResult.Contents.Tables[dbResult.Contents.Tables.Count - 1].Rows[0]["ErrorMessage"].ToString()); // else // Logger.ErrorLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName + "Parameters :" + this.GetParamString(param), ""); //} //else // Logger.ErrorLog("General Service", ":: Set CompanyIndex:" + CompanyIndex.ToString() + " SpName:" + SPName + "Parameters :" + this.GetParamString(param), Message); }
private void LogException(ArrayList param, string SPName, int CompanyIndex, SQLDBResult dbResult, Exception ex, long ReturnValue) { PLog.Error(this.GetParamString(param) + " : SPName:" + SPName, ex); }