public ProjectService(GNEntityModelContainer db, IdentityModelContainer identityDB) : base(db) { base.db = db; this.aspNetRoleService = new AspNetRoleService(identityDB); this.teamService = new TeamService(db, identityDB); }
private static void GetCurrentProject(ActionExecutingContext filterContext, GNEntityModelContainer db) { try { GNProject currentProject = null; string projectId = filterContext.HttpContext.Request["projectId"]; if (!string.IsNullOrEmpty(projectId)) { currentProject = db.GNProjects.Find(Guid.Parse(projectId)); } if (currentProject != null) { filterContext.Controller.ViewBag.CurrentProject = currentProject; } else { filterContext.Controller.ViewBag.CurrentProject = null; } } catch (Exception e) { LogUtil.Error(logger, "Unable to retrieve Current Project!!", e); } }
private static void GetCurrentSample(ActionExecutingContext filterContext, GNEntityModelContainer db) { try { GNSample currentSample = null; string sampleId = filterContext.HttpContext.Request["sampleId"]; if (string.IsNullOrEmpty(sampleId)) { sampleId = filterContext.HttpContext.Request["GNLeftSampleId"]; } if (!string.IsNullOrEmpty(sampleId)) { currentSample = db.GNSamples.Find(Guid.Parse(sampleId)); } if (currentSample != null) { filterContext.Controller.ViewBag.CurrentSample = currentSample; } else { filterContext.Controller.ViewBag.CurrentSample = null; } } catch (Exception e) { LogUtil.Error(logger, "Unable to retrieve Current Sample!!", e); } }
public CloudFileService(GNEntityModelContainer db, IdentityModelContainer identityDB) : base(db) { base.db = db; this.aspNetRoleService = new AspNetRoleService(identityDB); this.transactionService = new TransactionService(db); }
public TeamService(GNEntityModelContainer db, IdentityModelContainer identityDB) { base.db = db; this.aspNetRoleService = new AspNetRoleService(identityDB); this.aspNetUserRoleService = new AspNetUserRoleService(identityDB); }
public ActiveDirectoryService(GNEntityModelContainer db, IdentityModelContainer identityDB) { base.db = db; this.aspNetRoleService = new AspNetRoleService(identityDB); this.aspNetUserRolesService = new AspNetUserRoleService(identityDB); }
public SampleService(GNEntityModelContainer db, IdentityModelContainer identityDB) : base(db) { base.db = db; this.aspNetRoleService = new AspNetRoleService(identityDB); this.teamService = new TeamService(db, identityDB); this.cloudFileService = new CloudFileService(db, identityDB); }
public AWSComputeEnvironmentService(GNEntityModelContainer db) : base(db) { base.db = db; AWSConfig awsConfig = db.AWSConfigs.FirstOrDefault(); cloudComputeService = new GNCloudComputeService(awsConfig.Id); analysisRequestService = new AnalysisRequestService(db, new Data.IdentityModel.IdentityModelContainer()); }
private async Task <int> CreateNewInvoices() { int result = 1; if (DateTime.Now.Day == DAY_TO_CREATE_INVOICES) { LogUtil.Info(logger, "CreateNewInvoices()..."); System.Console.WriteLine("\nCreateNewInvoices()..."); var db = new GNEntityModelContainer(); InvoiceService invoiceService = new InvoiceService(db); InvoiceDetailService invoiceDetailService = new InvoiceDetailService(db); TransactionService transactionService = new TransactionService(db); AccountService orgAccountService = new AccountService(db); foreach (var orgAccount in await orgAccountService.FindAll()) { try { LogUtil.Info(logger, "Account = " + orgAccount.Organization.Name); System.Console.WriteLine("\nAccount = " + orgAccount.Organization.Name); //get user contact GNContact userContact = orgAccount.AccountOwner; if (userContact == null) { userContact = db.GNContacts.Where(c => c.GNOrganizationId == orgAccount.Organization.Id).FirstOrDefault(); } if (userContact != null) { string thisCycle = String.Format("{0:yyyyMM}", DateTime.Now); GNInvoice newInvoiceMonth = invoiceService.GetInvoiceForDateTime(userContact, thisCycle); if (newInvoiceMonth == null) { newInvoiceMonth = await invoiceService.CreateInvoiceForCurrentMonth(userContact, orgAccount); } System.Console.WriteLine("\nInvoice for Cycle " + thisCycle + " for Organization " + orgAccount.Organization.Name + " is " + newInvoiceMonth.Id); LogUtil.Info(logger, "Invoice for Cycle " + thisCycle + " for Organization " + orgAccount.Organization.Name + " is " + newInvoiceMonth.Id); } } catch (Exception ex) { result = 0; LogUtil.Warn(logger, ex.Message, ex); System.Console.WriteLine(ex.Message); } } } return(result); }
private void GetNavBarInfo(ActionExecutingContext filterContext) { if (filterContext != null && filterContext.Controller != null && filterContext.Controller.GetType().GetProperties().Count(p => p.Name == "db") != 0) { GNEntityModelContainer db = (GNEntityModelContainer)filterContext.Controller.GetType().GetProperty("db").GetValue(filterContext.Controller); GetCurrentTeam(filterContext, db); GetCurrentProject(filterContext, db); GetCurrentAnalysisRequest(filterContext, db); GetCurrentSample(filterContext, db); GetRemainingBudget(filterContext, db); } }
public AuditService(GNEntityModelContainer db) : base(db) { base.db = db; AWSConfig AWSConfigEntity = db.AWSConfigs.FirstOrDefault(); Amazon.RegionEndpoint regionEndpoint = Amazon.RegionEndpoint.GetBySystemName(AWSConfigEntity.AWSRegionSystemName); dynamoClient = new AmazonDynamoDBClient( AWSConfigEntity.AWSAccessKeyId, AWSConfigEntity.AWSSecretAccessKey, regionEndpoint); }
/* * private async Task<double> GetRemainingBudget(ActionExecutingContext filterContext, GNEntityModelContainer db) * { * GNContact userContact = (GNContact)filterContext.Controller.ViewBag.ContactForUser; * * if (userContact != null * && (userContact.IsInRole("GN_ADMIN") || userContact.IsInRole("ORG_MANAGER"))) * { * var myAccount = db.GNAccounts * .Where(a => a.Organization.Id == userContact.GNOrganizationId) * .FirstOrDefault(); * * if (myAccount != null) * { * bool result = await (new InvoiceService(db)).fetchCurrentInvoice(userContact); * * filterContext.Controller.ViewBag.MyRemainingBudget =// myAccount.AvailableCredits; * (new AccountService(db)).GetRemainingBudget(userContact, myAccount); * } * } * return filterContext.Controller.ViewBag.MyRemainingBudget; * } */ private static void GetRemainingBudget(ActionExecutingContext filterContext, GNEntityModelContainer db) { GNContact userContact = (GNContact)filterContext.Controller.ViewBag.ContactForUser; if (userContact != null && (userContact.IsInRole("GN_ADMIN") || userContact.IsInRole("ORG_MANAGER"))) { var myAccount = db.GNAccounts .Where(a => a.Organization.Id == userContact.GNOrganizationId) .FirstOrDefault(); if (myAccount != null) { filterContext.Controller.ViewBag.MyRemainingBudget =// myAccount.AvailableCredits; (new AccountService(db)).GetRemainingBudget(userContact, myAccount); } } }
private void InitServices() { LogUtil.LogMethod(logger, MethodBase.GetCurrentMethod()); //get mark analysis in error feature setting bool.TryParse( System.Configuration.ConfigurationManager.AppSettings["MarkAnalysisInErrorFeatureActive"], out MARK_ANALYSIS_IN_ERROR_FEATURE_ACTIVE); //get restart feature setting bool.TryParse( System.Configuration.ConfigurationManager.AppSettings["TerminateInstanceFeatureActive"], out TERMINATE_INSTANCE_FEATURE_ACTIVE); //get restart feature setting bool.TryParse( System.Configuration.ConfigurationManager.AppSettings["RestartAnalysisFeatureActive"], out RESTART_ANALYSIS_FEATURE_ACTIVE); //get force restart feature setting bool.TryParse( System.Configuration.ConfigurationManager.AppSettings["ForceRestartAnalysis"], out FORCE_RESTART_ANALYSIS); if (cloudComputeService == null) { LogUtil.Info(logger, GetType().Name + ".InitServices()..."); System.Console.WriteLine("\n" + GetType().Name + ".InitServices()..."); try { AWSConfig awsConfig = new GNEntityModelContainer().AWSConfigs.FirstOrDefault(); cloudComputeService = new GNCloudComputeService(awsConfig.Id); } catch (Exception ex) { LogUtil.Warn(logger, ex.Message, ex); System.Console.WriteLine(ex.Message); } } }
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 public void ConfigureAuth(IAppBuilder app) { // Configure the db context and user manager to use a single instance per request app.CreatePerOwinContext(GNIdentityDbContext.Create); app.CreatePerOwinContext <ApplicationUserManager>(ApplicationUserManager.Create); // JLS: Ensure that, by default, the system will authenticate requests with our configured CookieAuthentication. app.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ApplicationCookie); //JLS: *********************************************** app.UseWsFederationAuthentication( new WsFederationAuthenticationOptions { AuthenticationType = "Sanford", Wtrealm = ConfigurationManager.AppSettings["Sanford:Wtrealm"], MetadataAddress = ConfigurationManager.AppSettings["Sanford:Metadata"], Notifications = new WsFederationAuthenticationNotifications { AuthenticationFailed = context => { context.HandleResponse(); //JLS: ToDo: Replace this target of this redirect with the appropriate URL for the GenomeNext application. context.Response.Redirect("Home/Error?message=" + context.Exception.Message); return(Task.FromResult(-1)); }, //SecurityTokenReceived SecurityTokenValidated = context => { var userEmail = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.Email).Value; var identityDB = new IdentityModelContainer(); var db = new GNEntityModelContainer(); GNContact contact; AspNetUser user = identityDB.AspNetUsers.Where(a => a.Email.ToLower().Equals(userEmail.ToLower())).FirstOrDefault(); if (user != null) { //exists contact = db.GNContacts.Where(a => a.User.Id.Equals(user.Id) && a.IsInviteAccepted == true).FirstOrDefault(); } else { //create new String ssoEmail = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.Email).Value; GNOrganization organization = db.GNOrganizations.Where(a => a.Name.Contains("Sanford")).FirstOrDefault(); AspNetUser newUser = new AspNetUser { Id = Guid.NewGuid().ToString(), Email = ssoEmail, IsAdmin = false, Password = "******", UserName = ssoEmail, EmailConfirmed = true }; identityDB.AspNetUsers.Add(newUser); contact = new GNContact { Id = Guid.NewGuid(), AspNetUserId = newUser.Id, CreateDateTime = DateTime.Now, Email = ssoEmail, FirstName = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.GivenName).Value }; db.GNContacts.Add(contact); identityDB.SaveChanges(); db.SaveChanges(); } var applicationUserIdentity = new ClaimsIdentity(); applicationUserIdentity.AddClaim(new Claim(ClaimTypes.Name, contact.FullName, "")); applicationUserIdentity.AddClaim(new Claim(ClaimTypes.Email, user.Email, "")); context.OwinContext.Authentication.User.AddIdentity(applicationUserIdentity); context.Response.Redirect("Home"); return(Task.FromResult(0)); } } } ); //JLS: *********************************************** // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure the sign in cookie app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), ExpireTimeSpan = TimeSpan.FromMinutes(30), Provider = new CookieAuthenticationProvider { OnValidateIdentity = SecurityStampValidator.OnValidateIdentity <ApplicationUserManager, ApplicationUser>( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } }); }
public override IGNCloudMessageService <BamViewer> GetService() { AWSConfig awsConfig = new GNEntityModelContainer().AWSConfigs.FirstOrDefault(); return(new AnalysisBamViewerService(awsConfig.Id, AnalysisBamViewerService.QUEUE_NAME)); }
public ReplicateService(GNEntityModelContainer db) : base(db) { base.db = db; }
public override IGNCloudMessageService <NotificationMessage> GetService() { AWSConfig awsConfig = new GNEntityModelContainer().AWSConfigs.FirstOrDefault(); return(new NotificationCloudMessageService(awsConfig.Id, NotificationCloudMessageService.QUEUE_NAME)); }
public NotificationTopicSubscriberService(GNEntityModelContainer db) : base(db) { base.db = db; }
public NotificationSuppressionListsService(GNEntityModelContainer db) : base(db) { base.db = db; }
public NotificationTopicAddresseeService(GNEntityModelContainer db) : base(db) { base.db = db; }
public InviteCodeService(GNEntityModelContainer db) : base(db) { base.db = db; }
public SampleQualifierGroupService(GNEntityModelContainer db) : base(db) { base.db = db; }
private async Task <int> ProcessStorageCarryOverFees() { int result = 1; if (DateTime.Now.Day == DAY_TO_PROCESS_STORAGE_CARRYOVER_FEES) { LogUtil.Info(logger, "ProcessStorageCarryOverFees()..."); System.Console.WriteLine("\nProcessStorageCarryOverFees()..."); var db = new GNEntityModelContainer(); InvoiceService invoiceService = new InvoiceService(db); InvoiceDetailService invoiceDetailService = new InvoiceDetailService(db); TransactionService transactionService = new TransactionService(db); AccountService orgAccountService = new AccountService(db); foreach (var orgAccount in await orgAccountService.FindAll()) { try { LogUtil.Info(logger, "Account = " + orgAccount.Organization.Name); System.Console.WriteLine("\nAccount = " + orgAccount.Organization.Name); //get user contact GNContact userContact = orgAccount.AccountOwner; if (userContact == null) { userContact = db.GNContacts.Where(c => c.GNOrganizationId == orgAccount.Organization.Id).FirstOrDefault(); } if (userContact != null) { //get last month invoice GNInvoice lastMonthInvoice = invoiceService.GetInvoiceForLastMonth(userContact); if (lastMonthInvoice != null) { string txnKey = "STORAGE_S3_CARRYOVER"; //get invoice to update GNInvoice invoiceToUpdate = null; if (lastMonthInvoice.Status != GNInvoice.InvoiceStatus.PAID.ToString() && lastMonthInvoice.Status != GNInvoice.InvoiceStatus.VOID.ToString()) { invoiceToUpdate = lastMonthInvoice; } else { invoiceToUpdate = await invoiceService.GetInvoiceForCurrentMonth(orgAccount.AccountOwner); } if (invoiceToUpdate != null) { //get storage carryover detail GNInvoiceDetail storageCarryOverInvoiceDetail = db.GNInvoiceDetails .Where(invd => (invd.GNInvoiceId == invoiceToUpdate.Id && invd.Description == txnKey)) .FirstOrDefault(); //add invoice detail, if missing if (storageCarryOverInvoiceDetail == null) { storageCarryOverInvoiceDetail = db.GNInvoiceDetails.Add(new GNInvoiceDetail { Id = Guid.NewGuid(), Description = txnKey, GNInvoiceId = invoiceToUpdate.Id, Quantity = 0.0, SubTotal = 0.0, DiscountAmount = orgAccount.DefaultDiscountAmount, DiscountType = orgAccount.DefaultDiscountType, Total = 0.0, UnitCost = 0.0, UnitPrice = 0.0, CreateDateTime = DateTime.Now, CreatedBy = orgAccount.AccountOwner.Id }); await db.SaveChangesAsync(); storageCarryOverInvoiceDetail = db.GNInvoiceDetails.Find(storageCarryOverInvoiceDetail.Id); } if (storageCarryOverInvoiceDetail != null) { //get txn count int txnCount = db.GNTransactions.Count(t => (t.GNInvoiceDetailId == storageCarryOverInvoiceDetail.Id && t.TransactionType.Name == txnKey)); if (txnCount == 0) { //get storage balance for month //all uploads minus all downloads up until end of last month var storageUsed = orgAccountService.CalcStorageUsed(orgAccount.Id, lastMonthInvoice.InvoiceEndDate.AddDays(1)); //get storage carryover product GNProduct storageCarryOverProduct = db.GNProducts.Where(p => p.Name == txnKey).FirstOrDefault(); //calc storage carryover cost var totalCarryOverCost = storageUsed * storageCarryOverProduct.Price; //add storage cost transaction string txnTypeKey = txnKey; string description = storageUsed + "GB"; double valueUsed = storageUsed; string valueUnits = "GB"; int updateResult = 0; GNTransaction txn = await transactionService.CreateTransaction( userContact, txnTypeKey, description, valueUsed, valueUnits, targetInvoice : invoiceToUpdate); if (txn != null) { updateResult = 1; } //update invoice totals //int updateResult = await invoiceDetailService.UpdateInvoiceDetailTotals( // invDetailToUpdate.Id, invDetailToUpdate.GNInvoiceId, invDetailToUpdate.Invoice.GNAccountId); LogUtil.Info(logger, "Update result = " + updateResult); System.Console.WriteLine("\nUpdate result = " + updateResult); } } } } } } catch (Exception ex) { result = 0; LogUtil.Warn(logger, ex.Message, ex); System.Console.WriteLine(ex.Message); } } } return(result); }
private void GetContactForUser(ActionExecutingContext filterContext) { try { if (filterContext != null && filterContext.Controller != null && filterContext.Controller.GetType().GetProperties().Count(p => p.Name == "identityDB") != 0 && filterContext.Controller.GetType().GetProperties().Count(p => p.Name == "db") != 0) { IdentityModelContainer identityDB = (IdentityModelContainer)filterContext.Controller.GetType().GetProperty("identityDB").GetValue(filterContext.Controller); GNEntityModelContainer db = (GNEntityModelContainer)filterContext.Controller.GetType().GetProperty("db").GetValue(filterContext.Controller); var requestUser = filterContext.HttpContext.User; GNContact contact = null; if (requestUser != null && requestUser.Identity != null && requestUser.Identity.IsAuthenticated) { var user = identityDB.AspNetUsers.Where(u => u.UserName == requestUser.Identity.Name).FirstOrDefault(); if (user != null) { Guid defaultOrganizationIdGuid = Guid.Empty; if (!string.IsNullOrEmpty(user.DefaultOrganizationId)) { defaultOrganizationIdGuid = Guid.Parse(user.DefaultOrganizationId); contact = db.GNContacts .Where(c => (c.AspNetUserId == user.Id && c.GNOrganizationId == defaultOrganizationIdGuid)) .FirstOrDefault(); } else { contact = db.GNContacts .Where(c => (c.AspNetUserId == user.Id)) .FirstOrDefault(); if (contact != null) { user.DefaultOrganizationId = contact.GNOrganizationId.ToString(); identityDB.Entry(user).State = System.Data.Entity.EntityState.Modified; user.Password = "******"; user.PasswordConfirm = "."; identityDB.SaveChanges(); } } if (contact != null && user != null) { contact.User = user; } if (contact != null && contact.GNContactRoles != null) { foreach (var contactRole in contact.GNContactRoles) { contactRole.AspNetRole = identityDB.AspNetRoles.Find(contactRole.AspNetRoleId); } } } } if (contact != null) { //set contact filterContext.Controller.ViewBag.ContactForUser = contact; //set organizations for user contact filterContext.Controller.ViewBag.OrganizationsForUser = db.GNContacts .Where(c => c.AspNetUserId == contact.AspNetUserId) .Select(c => c.GNOrganization) .Where(o => o.Id != contact.GNOrganizationId) .ToList(); //get org settings template for user var orgConfigSettingsTemplate = db.GNSettingsTemplates .Include(t => t.GNSettingsTemplateConfigs) .Where(t => t.GNOrganizations.Any(o => o.Id == contact.GNOrganizationId)) .FirstOrDefault(); if (orgConfigSettingsTemplate != null && orgConfigSettingsTemplate.GNSettingsTemplateConfigs != null && orgConfigSettingsTemplate.GNSettingsTemplateConfigs.Count != 0) { filterContext.Controller.ViewBag.OrgConfigSettings = orgConfigSettingsTemplate.GNSettingsTemplateConfigs.ToList(); } } else { filterContext.Controller.ViewBag.ContactForUser = null; } } } catch (Exception e) { LogUtil.Error(logger, "Unable to Get Contact User!!", e); } }
public SampleTypeService(GNEntityModelContainer db) : base(db) { base.db = db; }
public GeneService(GNEntityModelContainer db) : base(db) { base.db = db; }
public SampleRelationshipService(GNEntityModelContainer db) : base(db) { base.db = db; }
public SequencerJobService(GNEntityModelContainer db) : base(db) { base.db = db; }
public override IGNCloudMessageService <StartVcfStatsReport> GetService() { AWSConfig awsConfig = new GNEntityModelContainer().AWSConfigs.FirstOrDefault(); return(new StartQcReportService(awsConfig.Id, StartQcReportService.QUEUE_NAME)); }
public override IGNCloudMessageService <NewSampleBatch> GetService() { AWSConfig awsConfig = new GNEntityModelContainer().AWSConfigs.FirstOrDefault(); return(new SampleBatchRequestService(awsConfig.Id, SampleBatchRequestService.QUEUE_NAME)); }