using System; using System.Collections.Generic; using System.Linq; using System.Text; using SteamWare; using System.Reflection; using System.Data.SqlClient; namespace C2P_Data { public class DtProxy { #region area protected protected DtProxy() { // inizializzo i table adapters avvioTableAdapters(); setupConnectionString(); // aggiunta x gestione timeout esteso (ove necessario)! fixCommandTimeout(); } /// /// sistemazione timeout comandi nei tableadapter /// private void fixCommandTimeout() { //SetAllCommandTimeouts(taQL, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taQFQ, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taQRM, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taRMD, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taSCL, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taVSCli, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taVSItm, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taVSRM, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taRPT, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taO4I, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taOH, memLayer.ML.confReadInt("sqlLongCommandTimeout")); //SetAllCommandTimeouts(taSC2C, memLayer.ML.confReadInt("sqlLongCommandTimeout")); SetAllCommandTimeouts(taImpTL, memLayer.ML.confReadInt("sqlLongCommandTimeout")); } void SetAllCommandTimeouts(object adapter, int timeout) { var commands = adapter.GetType().InvokeMember( "CommandCollection", BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, adapter, new object[0]); var sqlCommand = (SqlCommand[])commands; foreach (var cmd in sqlCommand) { cmd.CommandTimeout = timeout; } } /// /// procedura di avvio dei tableAdapter /// protected virtual void avvioTableAdapters() { taAgent = new DS_QuotesTableAdapters.AgentsDetTableAdapter(); taCVQ = new DS_QuotesTableAdapters.stp_checkValidQuoteTableAdapter(); taCLQ = new DS_QuotesTableAdapters.stp_chekLastRevQuoteTableAdapter(); taPD = new DS_QuotesTableAdapters.PackagDetTableAdapter(); taPlant = new DS_QuotesTableAdapters.PlantsDetTableAdapter(); taPQuot = new DS_QuotesTableAdapters.prtQuoteTableAdapter(); taQL = new DS_QuotesTableAdapters.QuoteListTableAdapter(); taQFQ = new DS_QuotesTableAdapters.QuoteFull_QTableAdapter(); taQRM = new DS_QuotesTableAdapters.QuoteRMTableAdapter(); taRMD = new DS_QuotesTableAdapters.RawMatDetTableAdapter(); taSCL = new DS_QuotesTableAdapters.StdCostListTableAdapter(); taCost2Plant = new DS_QuotesTableAdapters.Cost2PlantTableAdapter(); taUtils = new DS_QuotesTableAdapters.UtilitiesTableAdapter(); taDGD = new DS_UtilityTableAdapters.DiesGroupDetTableAdapter(); taILog = new DS_UtilityTableAdapters.Import_LogTableAdapter(); taTCD = new DS_UtilityTableAdapters.TranspCostDetTableAdapter(); taVSCli = new DS_UtilityTableAdapters.v_selClientTableAdapter(); taVSItm = new DS_UtilityTableAdapters.v_selItemsTableAdapter(); taVSRM = new DS_UtilityTableAdapters.v_selRawMatTableAdapter(); taRPT = new DS_UtilityTableAdapters.ReportPrintTicketTableAdapter(); taO4I = new DS_UtilityTableAdapters.Offers4ItemTableAdapter(); taOH = new DS_UtilityTableAdapters.OrderHistTableAdapter(); taSC2C = new DS_UtilityTableAdapters.StdCost2createTableAdapter(); taImpTL = new DS_UtilityTableAdapters.Import_TicketListTableAdapter(); taListVal = new DS_UtilityTableAdapters.ListValuesTableAdapter(); taSelCli = new DS_UtilityTableAdapters.v_selClientTableAdapter(); taSelItm = new DS_UtilityTableAdapters.v_selItemsTableAdapter(); } /// /// effettua setup dei connection strings da web.config della singola applicazione /// protected virtual void setupConnectionString() { string connStr = memLayer.ML.confReadString("C2PConnectionString"); // connections del db vocabolario taAgent.Connection.ConnectionString = connStr; taCVQ.Connection.ConnectionString = connStr; taCLQ.Connection.ConnectionString = connStr; taPD.Connection.ConnectionString = connStr; taPlant.Connection.ConnectionString = connStr; taPQuot.Connection.ConnectionString = connStr; taQL.Connection.ConnectionString = connStr; taQFQ.Connection.ConnectionString = connStr; taQRM.Connection.ConnectionString = connStr; taRMD.Connection.ConnectionString = connStr; taSCL.Connection.ConnectionString = connStr; taCost2Plant.Connection.ConnectionString = connStr; taUtils.Connection.ConnectionString = connStr; taDGD.Connection.ConnectionString = connStr; taILog.Connection.ConnectionString = connStr; taTCD.Connection.ConnectionString = connStr; taVSCli.Connection.ConnectionString = connStr; taVSItm.Connection.ConnectionString = connStr; taVSRM.Connection.ConnectionString = connStr; taRPT.Connection.ConnectionString = connStr; taO4I.Connection.ConnectionString = connStr; taOH.Connection.ConnectionString = connStr; taSC2C.Connection.ConnectionString = connStr; taImpTL.Connection.ConnectionString = connStr; taListVal.Connection.ConnectionString = connStr; taSelCli.Connection.ConnectionString = connStr; taSelItm.Connection.ConnectionString = connStr; } #endregion #region area public public DS_QuotesTableAdapters.AgentsDetTableAdapter taAgent; public DS_QuotesTableAdapters.stp_checkValidQuoteTableAdapter taCVQ; public DS_QuotesTableAdapters.stp_chekLastRevQuoteTableAdapter taCLQ; public DS_QuotesTableAdapters.PackagDetTableAdapter taPD; public DS_QuotesTableAdapters.PlantsDetTableAdapter taPlant; public DS_QuotesTableAdapters.prtQuoteTableAdapter taPQuot; public DS_QuotesTableAdapters.QuoteListTableAdapter taQL; public DS_QuotesTableAdapters.QuoteFull_QTableAdapter taQFQ; public DS_QuotesTableAdapters.QuoteRMTableAdapter taQRM; public DS_QuotesTableAdapters.RawMatDetTableAdapter taRMD; public DS_QuotesTableAdapters.StdCostListTableAdapter taSCL; public DS_QuotesTableAdapters.Cost2PlantTableAdapter taCost2Plant; public DS_QuotesTableAdapters.UtilitiesTableAdapter taUtils; public DS_UtilityTableAdapters.DiesGroupDetTableAdapter taDGD; public DS_UtilityTableAdapters.Import_LogTableAdapter taILog; public DS_UtilityTableAdapters.v_selClientTableAdapter taVSCli; public DS_UtilityTableAdapters.v_selItemsTableAdapter taVSItm; public DS_UtilityTableAdapters.v_selRawMatTableAdapter taVSRM; public DS_UtilityTableAdapters.ReportPrintTicketTableAdapter taRPT; public DS_UtilityTableAdapters.Offers4ItemTableAdapter taO4I; public DS_UtilityTableAdapters.OrderHistTableAdapter taOH; public DS_UtilityTableAdapters.StdCost2createTableAdapter taSC2C; public DS_UtilityTableAdapters.Import_TicketListTableAdapter taImpTL; public DS_UtilityTableAdapters.ListValuesTableAdapter taListVal; public DS_UtilityTableAdapters.v_selClientTableAdapter taSelCli; public DS_UtilityTableAdapters.v_selItemsTableAdapter taSelItm; public DS_UtilityTableAdapters.TranspCostDetTableAdapter taTCD; public static DtProxy man = new DtProxy(); #endregion } }