private EmployeeCredit getLimitCredit(String CountryAbbrev, String Email) { EmployeeCredit LimitCredit = new EmployeeCredit(); String sQuery = string.Empty; DataAccess.NET.RemoteData oDataAccess = new DataAccess.NET.RemoteData(); DataSet dsLimit = new DataSet(); try { Log.writeLog("Iniciando obtencion de conectionString para " + CountryAbbrev + " , LongDate: " + DateTime.Now.ToLongDateString() + ", LongTime: " + DateTime.Now.ToLongTimeString(), System.Diagnostics.EventLogEntryType.Information); stopwatch.Start(); loadConnectionString(CountryAbbrev); Log.writeLog(String.Format(" Duracion Total : {0:hh\\:mm\\:ss}", stopwatch.Elapsed), System.Diagnostics.EventLogEntryType.Information); stopwatch.Restart(); oDataAccess.ConnectionString = this.connectionString; Log.writeLog("conectando a la base de datos " + connectionString + " , LongDate: " + DateTime.Now.ToLongDateString() + ", LongTime: " + DateTime.Now.ToLongTimeString(), System.Diagnostics.EventLogEntryType.Information); sQuery = " select isnull(ct.CreditLimit,0)-isnull(ct.TotalRewards,0) as CreditAvailable from " + "CUSTOMER c "; sQuery += " inner join Customer_totals ct on c.customerNo= ct.customerNo "; sQuery += " where CustomerType='E' and Email='" + Email + "' and StatusCode='A' "; oDataAccess.GetDataSetQry(sQuery, "LimitCredit", ref dsLimit); Log.writeLog(String.Format(" Duracion Total : {0:hh\\:mm\\:ss}", stopwatch.Elapsed), System.Diagnostics.EventLogEntryType.Information); LimitCredit.CreditAvailable = dsLimit.Tables[0].Rows[0]["CreditAvailable"].ToString().Trim(); } catch (Exception ex) { Log.writeLog(" Message : " + ex.Message + " , StackTrace : " + ex.StackTrace + " sQuery : " + sQuery, System.Diagnostics.EventLogEntryType.Error); } finally { oDataAccess = null; dsLimit = null; } return(LimitCredit); }
private void loadConnectionString(String CountryAbbrev) { DataAccess.NET.RemoteData oRemoteData = new DataAccess.NET.RemoteData(); DataSet ds = new DataSet(); String SQuery = String.Empty; String sDataSource = String.Empty; String sDBName = String.Empty; try { oRemoteData.ConnectionString = this.connectionString; SQuery = "select * from belcorpdata..country where abbrev ='"+ CountryAbbrev + "'"; oRemoteData.GetDataSetQry(SQuery, "", ref ds); sDataSource = ds.Tables[0].Rows[0]["DataSource"].ToString(); sDBName = ds.Tables[0].Rows[0]["DBName"].ToString(); } catch (Exception ex) { Log.writeLog(" Message : " + ex.Message + " , StackTrace : " + ex.StackTrace + " Query : " + SQuery, System.Diagnostics.EventLogEntryType.Error); throw new Exception("Fallo coneccion Admin", ex); } finally { oRemoteData = null; ds = null; } this.connectionString = "uid=RetailUser;password=retail;database=" + sDBName + ";server=" + sDataSource + ";Connect Timeout=180;pooling=false"; }