private void InitProcess() { LogBook.Write("SqlConnectionString:" + connString); _target = new AlarmInitializer(); LogBook.Write("new AlarmInitializer called"); try { /* Added on 02/28/2011 To set server time */ _target.SetServerTime(); } catch (Exception ex) { LogBook.Write("Unable to set server time to message boards", ex, "CooperAtkins.NotificationClient.Service.NotificationClientService"); } /* if service restarts, this operation will resumes previously lost notification*/ _target.ResumeNotificationProcess(); LogBook.Write("ResumeNotificationProcess Completed"); /* Stating the process. */ StartProcess(); LogBook.Write("StartProcess(); Completed"); /* listening to external source. */ UDPListener(); LogBook.Write("UDPListener(); Completed"); }
private void InitProcess() { //Configure Enterprise Model Library EnterpriseModel.Net.LibConfig.Instance.Config = new CooperAtkins.NotificationClient.Generic.DataAccess .EnterpriseModelConfig(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString); EnterpriseModelConfig config = new EnterpriseModelConfig(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString); bool connectionOpened = false; int lastAttemptMins = 5 * 1000; while (!connectionOpened) { EnterpriseModel.Net.DataAccess dataAccess = null; try { dataAccess = config.GetDbGateway(); dataAccess.Initialize(); dataAccess.Connection.Open(); connectionOpened = true; dataAccess.Connection.Close(); } catch { LogBook.Write("Unable to open database connection, SqlConnectionString:" + ""); LogBook.Write("Attempting to connect after:" + (lastAttemptMins / 1000).ToString() + " Seconds"); Thread.Sleep(lastAttemptMins); lastAttemptMins += lastAttemptMins; } finally { if (dataAccess != null) { dataAccess.Dispose(); } } } target = new AlarmInitializer(); try { //target.SetServerTime(); } catch { } /* if user restarts the service, this operation will resumes previously lost notification*/ target.ResumeNotificationProcess(); button1_Click(null, null); UDPListener(); }