public static void SaveSpisInstanceSettings(string dbName, SpisInstanceSettings settings) { try { using (var stmDbContext = new StmDbContext()) { stmDbContext.init(dbName); var current = stmDbContext.SpisInstanceSettings.FirstOrDefault(); if (current == null) { stmDbContext.SpisInstanceSettings.Add(settings); } else { current.ClientCertificate = settings.ClientCertificate; current.Password = settings.Password; current.ServiceId = settings.ServiceId; current.ServiceName = settings.ServiceName; current.StmModuleUrl = settings.StmModuleUrl; current.IMO = settings.IMO; current.MMSI = settings.MMSI; current.ApiKey = settings.ApiKey; current.ApplicationId = settings.ApplicationId; current.UseHMACAuthentication = settings.UseHMACAuthentication; } stmDbContext.SaveChanges(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static bool AddInstance(string dbName) { try { var conString = ConfigurationManager.ConnectionStrings["StmConnectionString"].ConnectionString; using (var con = new SqlConnection(conString.Replace("Initial Catalog={database};", ""))) { con.Open(); using (var command = new SqlCommand()) { command.Connection = con; command.CommandTimeout = 180; var sql = string.Format( "CREATE DATABASE " + dbName); command.CommandText = sql; command.ExecuteNonQuery(); } } var stmDbContext = new StmDbContext(); stmDbContext.init(dbName); stmDbContext.ReInitializeDatabase(); return(true); } catch (Exception ex) { MessageBox.Show("Error when creating database" + Environment.NewLine + ex.Message, "Add instance", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } }
public AcknowledgementController(StmDbContext context, INotificationService notificationService, IIdentityService identityService) { _context = context; _notificationService = notificationService; _identityService = identityService; }
public AreaController(StmDbContext context, IUploadedMessageService uploadedMessageService, IIdentityService identityService, IMessageTypeService messageTypeService, INotificationService notificationService) { _context = context; _uploadedMessageService = uploadedMessageService; _identityService = identityService; _messageTypeService = messageTypeService; _notificationService = notificationService; }
public static SpisInstanceSettings GetSpisInstanceSettings(string dbName) { var result = new SpisInstanceSettings(); try { var stmDbContext = new StmDbContext(); stmDbContext.init(dbName); result = stmDbContext.SpisInstanceSettings.FirstOrDefault(); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(result); }
public TextMessageController(StmDbContext context, IPublishedRtzMessageService publishedMessageService, IACLObjectService aclObjectService, IIdentityService identityService, IVisSubscriptionService subscriptionService, IMessageTypeService messageTypeService, IUploadedMessageService uploadedMessageService, INotificationService notificationService) { _context = context; _publishedMessageService = publishedMessageService; _aclObjectService = aclObjectService; _identityService = identityService; _subscriptionService = subscriptionService; _messageTypeService = messageTypeService; _uploadedMessageService = uploadedMessageService; _notificationService = notificationService; InstanceContext.ServiceId = ConfigurationManager.AppSettings["MyIdentity"]; }
public VoyagePlanController(StmDbContext context, IPublishedRtzMessageService publishedMessageService, IACLObjectService aclObjectService, IIdentityService identityService, IVisSubscriptionService subscriptionService, IMessageTypeService messageTypeService, IUploadedMessageService uploadedMessageService, INotificationService notificationService, ISccPrivateService sscService, IConnectionInformationService connectionInformationService) { _context = context; _publishedMessageService = publishedMessageService; _aclObjectService = aclObjectService; _identityService = identityService; _subscriptionService = subscriptionService; _messageTypeService = messageTypeService; _uploadedMessageService = uploadedMessageService; _notificationService = notificationService; _sscService = sscService; _connectionInformationService = connectionInformationService; }
public void Init() { _dbContext = new StmDbContext(); }
public void Init() { _dbContext = new StmDbContext(); _logContext = new LogDbContext(); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="notificationService"></param> public StmModuleService(StmDbContext context, INotificationService notificationService) { _context = context; _notificationService = notificationService; }