protected virtual void InitializeDatabaseSettings <D>(
            DatabaseAppSettings settings,
            Type userLinqToSqlType,
            Type serverActionLinqToSqlType,
            Type serverErrorLinqToSqlType) where D : DataContext
        {
            LinqFunnelSettings linqFunnelSettings = new LinqFunnelSettings(settings.DatabaseConnectionString, settings.DatabaseCommandTimeout);

            GOCWindows.Instance.AddByTypeName(linqFunnelSettings); //Adds an object to Global Object Cache with the key being the name of the type.
            string linqToSqlAssemblyFilePath = Path.Combine(InformationWindows.GetExecutingDirectory(), settings.LinqToSQLClassesAssemblyFileName);

            //Grab the LinqToSql context from the specified assembly and load it in the GOC to be used from anywhere in the application.
            //The point of doing this is that you can rebuild the context if the schema changes and reload without having to reinstall the web service. You just stop the service and overwrite the EOH.RainMaker.ORM.dll with the new one.
            //It also allows the NKit Service Toolkit to be business data agnostic.
            GOCWindows.Instance.LinqToClassesAssembly     = Assembly.LoadFrom(linqToSqlAssemblyFilePath);
            GOCWindows.Instance.LinqToSQLClassesNamespace = settings.LinqToSQLClassesNamespace;
            GOCWindows.Instance.SetLinqToSqlDataContextType <D>();
            if (userLinqToSqlType != null)
            {
                GOCWindows.Instance.UserLinqToSqlType = userLinqToSqlType;
            }
            if (serverActionLinqToSqlType != null)
            {
                GOCWindows.Instance.ServerActionLinqToSqlType = serverActionLinqToSqlType;
            }
            if (serverErrorLinqToSqlType != null)
            {
                GOCWindows.Instance.ServerErrorLinqToSqlType = serverErrorLinqToSqlType;
            }
            GOCWindows.Instance.DatabaseTransactionScopeOption             = settings.DatabaseTransactionScopeOption;
            GOCWindows.Instance.DatabaseTransactionIsolationLevel          = settings.DatabaseTransactionIsolationLevel;
            GOCWindows.Instance.DatabaseTransactionTimeoutSeconds          = settings.DatabaseTransactionTimeoutSeconds;
            GOCWindows.Instance.DatabaseTransactionDeadlockRetryAttempts   = settings.DatabaseTransactionDeadlockRetryAttempts;
            GOCWindows.Instance.DatabaseTransactionDeadlockRetryWaitPeriod = settings.DatabaseTransactionDeadlockRetryWaitPeriod;
        }
 public BcEntityContext(
     DataContext db,
     LinqFunnelSettings settings,
     bool handleExceptions,
     Type userLinqToSqlType,
     Type serverActionLinqToSqlType,
     Type serverErrorLinqToSqlType)
     : base(db, settings, handleExceptions, userLinqToSqlType, serverActionLinqToSqlType, serverErrorLinqToSqlType)
 {
 }
        internal void Initialize(bool startWebService)
        {
            GOC.Instance.ShowMessageBoxOnException = false;
            BcServiceSettings settings = Settings;

            GOC.Instance.ApplicationName = settings.ApplicationName;

            GOC.Instance.Logger = new Logger(//Creates a global Logger to be used throughout the application to be stored in the Global Object Cache which is a singleton.
                settings.LogToFile,
                settings.LogToWindowsEventLog,
                settings.LogToConsole,
                settings.LoggingLevel,
                settings.LogFileName,
                settings.EventSourceName,
                settings.EventLogName);
            GOC.Instance.JsonSerializer.IncludeOrmTypeNamesInJsonResponse = false;
            GOC.Instance.SetEncoding(settings.TextResponseEncoding);

            LinqFunnelSettings linqFunnelSettings = new LinqFunnelSettings(settings.DatabaseConnectionString, settings.DatabaseCommandTimeout);

            GOC.Instance.AddByTypeName(linqFunnelSettings); //Adds an object to Global Object Cache with the key being the name of the type.
            string linqToSqlAssemblyFilePath = Path.Combine(Information.GetExecutingDirectory(), settings.LinqToSQLClassesAssemblyFileName);

            GOC.Instance.Logger.LogMessage(new LogMessage(string.Format("Attemping to load {0}", settings.LinqToSQLClassesAssemblyFileName), LogMessageType.Information, LoggingLevel.Maximum));
            GOC.Instance.UserLinqToSqlType         = typeof(User);
            GOC.Instance.ServerActionLinqToSqlType = typeof(ServerAction);
            GOC.Instance.ServerErrorLinqToSqlType  = typeof(ServerError);

            //Grab the LinqToSql context from the specified assembly and load it in the GOC to be used from anywhere in the application.
            //The point of doing this is that you can rebuild the context if the schema changes and reload without having to reinstall the web service. You just stop the service and overwrite the EOH.RainMaker.ORM.dll with the new one.
            //It also allows the Figlut Service Toolkit to be business data agnostic.
            GOC.Instance.LinqToClassesAssembly     = Assembly.LoadFrom(linqToSqlAssemblyFilePath);
            GOC.Instance.LinqToSQLClassesNamespace = settings.LinqToSQLClassesNamespace;
            GOC.Instance.SetLinqToSqlDataContextType <BinaryCalendarDataContext>();

            EmailNotifier.Instance.Initialize(new EmailSender(
                                                  settings.EnableEmailNotifications,
                                                  settings.EmailType,
                                                  settings.LocalSmtpServer,
                                                  settings.LocalSmtpUserName,
                                                  settings.LocalSmtpPassword,
                                                  settings.LocalSmtpPort,
                                                  settings.LocalSmtpEnableSsl,
                                                  settings.GMailSMTPServer,
                                                  settings.GMailSmtpUserName,
                                                  settings.GMailSmtpPassword,
                                                  settings.GMailSmtpPort,
                                                  settings.SenderEmailAddress,
                                                  settings.SenderDisplayName));

            if (startWebService)
            {
                InitializeServiceHost(settings);
            }
        }