public ActionResult AddBook() { var profileData = Session["UserProfile"] as UserSession; if (profileData == null) { return(RedirectToAction("Index", "Home")); } var publicationRepository = new PublicationRepository(); var contentRatingRepository = new ContentRatingRepository(); var authorRepository = new AuthorRepository(); var bookDetail = new BookDetails(); var bookModel = new BookModel(); ModelState.Clear(); bookModel.PublicationList = publicationRepository.GetAllPublication(); bookModel.ContentRatingList = contentRatingRepository.GetAllContentRating(); bookModel.BookTypeList = new List <String>() { "Reference Book", "Loan Book" }; bookDetail.BookModel = bookModel; bookDetail.AuthorList = authorRepository.GetAllAuthor(); return(View(bookDetail)); }
public ActionResult DeletePublication(int id) { var profileData = Session["UserProfile"] as UserSession; if (profileData == null) { return(RedirectToAction("Index", "Home")); } try { PublicationRepository PubRepo = new PublicationRepository(); if (PubRepo.DeletePublication(id)) { ViewBag.AlertMsg = "Publication details deleted successfully"; } var logModel = new LogModel { UserId = profileData.UserID, TableName = "Publication User", Activity = "Deleted Publication", LogDate = DateTime.Now }; var logRepository = new logRepository(); logRepository.AddLog(logModel); return(RedirectToAction("GetAllPublicationDetails")); } catch { return(RedirectToAction("GetAllPublicationDetails")); } }
private async Task UpdateProductPublication(ReleaseResponse buildEngineRelease, Product product, bool success) { var publication = await PublicationRepository.Get().Where(p => p.ReleaseId == buildEngineRelease.Id && p.ProductId == product.Id).FirstOrDefaultAsync(); if (publication == null) { throw new Exception($"Failed to find ProductPublish: ReleaseId={buildEngineRelease.Id}"); } publication.Success = success; publication.LogUrl = buildEngineRelease.ConsoleText; await PublicationRepository.UpdateAsync(publication); if (success) { var publishUrlFile = buildEngineRelease.Artifacts.Where(pa => pa.Key == "publishUrl").FirstOrDefault(); if (publishUrlFile.Value != null) { var value = WebClient.DownloadString(publishUrlFile.Value); if (!string.IsNullOrEmpty(value)) { var publishUrl = value.Trim(); product.PublishLink = publishUrl; await ProductRepository.UpdateAsync(product); } } } }
protected async Task CreateBuildEngineReleaseAsync(Product product, Dictionary <string, object> paramsDictionary, PerformContext context) { var channel = GetChannel(paramsDictionary); var targets = GetTargets(paramsDictionary, "google-play"); var environment = GetEnvironment(paramsDictionary); environment["PRODUCT_ID"] = product.Id.ToString(); environment["PROJECT_ID"] = product.ProjectId.ToString(); var release = new Release { Channel = channel, Targets = targets, Environment = environment }; ClearRecurringJob(product.Id); ReleaseResponse releaseResponse = null; if (SetBuildEngineEndpoint(product.Project.Organization)) { releaseResponse = BuildEngineApi.CreateRelease(product.WorkflowJobId, product.WorkflowBuildId, release); } if ((releaseResponse != null) && (releaseResponse.Id != 0)) { product.WorkflowPublishId = releaseResponse.Id; await ProductRepository.UpdateAsync(product); var build = await BuildRepository.Get().Where(b => b.BuildId == product.WorkflowBuildId).FirstOrDefaultAsync(); if (build == null) { throw new Exception($"Failed to find ProductBuild: {product.WorkflowBuildId}"); } var publish = new ProductPublication { ProductId = product.Id, ProductBuildId = build.Id, ReleaseId = releaseResponse.Id, Channel = channel }; await PublicationRepository.CreateAsync(publish); var monitorJob = Job.FromExpression <BuildEngineReleaseService>(service => service.CheckRelease(product.Id)); RecurringJobManager.AddOrUpdate(GetHangfireToken(product.Id), monitorJob, "* * * * *"); } else { var messageParms = new Dictionary <string, object>() { { "projectName", product.Project.Name }, { "productName", product.ProductDefinition.Name } }; await SendNotificationOnFinalRetryAsync(context, product.Project.Organization, product.Project.Owner, "releaseFailedUnableToCreate", messageParms); // Throw Exception to force retry throw new Exception("Create release failed"); } }
public ExclusionLogic(PublicationRepository publicationRepository, ExclusionCriterionRepository exclusionCriterionRepository, StudyRepository studyRepository) { _publicationRepository = publicationRepository; _exclusionCriterionRepository = exclusionCriterionRepository; _studyRepository = studyRepository; }
public PubmedEngine() { publicationRepository = new PublicationRepository(); diseaseRepository = new DiseaseRepository(); Publications = new ConcurrentBag <Publication>(); monDocActuel = new XmlDocument(); client = new HttpClient(); urlEfetch = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi"; urlESearch = $"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?" + $"db=pmc" + $"&sort=relevance" + $"&retmax={1000}" + $"{ConfigurationManager.Instance.config.ParametersAPI}"; defaultParameters = new Dictionary <string, string> { { "db", "pmc" }, { "retstart", "0" }, { "retmax", "500" }, { "rettype", "xml" }, { "retmode", "xml" }, { "api_key", $"{ConfigurationManager.Instance.config.API_Key}" }, { "email", $"{ConfigurationManager.Instance.config.Email}" }, { "tool", $"{ConfigurationManager.Instance.config.Tool}" }, { "id", "" } }; m = new Mutex(); }
public ActionResult AddPublication(PublicationModel publication) { try { if (ModelState.IsValid) { PublicationRepository publicationRepository = new PublicationRepository(); publicationRepository.AddPublication(publication); var profileData = Session["UserProfile"] as UserSession; var logModel = new LogModel { UserId = profileData.UserID, TableName = "Publication", Activity = "Added Publication", LogDate = DateTime.Now }; var logRepository = new logRepository(); logRepository.AddLog(logModel); } return(RedirectToAction("GetAllPublicationDetails")); } catch { return(RedirectToAction("GetAllPublicationDetails")); } }
public LibraryService(string connection) { _bookRepository = new BookRepository(connection); _brochureRepository = new BrochureRepository(connection); _gournalRepository = new GournalRepository(connection); _publicationRepository = new PublicationRepository(connection); }
public BundlesController(ILoggingService loggingService, ITaskRunner taskRunner, BundleRepository bundleRepository, ProjectRepository projectRepository, SourceRepository sourceRepository, PublicationRepository publicationRepository) : base(loggingService) { this.taskRunner = taskRunner; this.bundleRepository = bundleRepository; this.projectRepository = projectRepository; this.sourceRepository = sourceRepository; this.publicationRepository = publicationRepository; }
public void TestEntityGetAllUser() { var mockTeste = new Mock <IGetDB <Publication> >(); var publicationRepository = new PublicationRepository(mockTeste.Object); publicationRepository.GetAll(); mockTeste.Verify(x => x.GetAllRegister()); }
public ActionResult SearchPublication(SearchandUser searchedPublication) { PublicationRepository publicationRepository = new PublicationRepository(); List <SearchandUser> publicationList = new List <SearchandUser>(); publicationList = publicationRepository.searchPublisherByName(searchedPublication.Publication.PublicationName); return(View(publicationList)); }
public async void LatestReleaseCorrectlyReportedInPublication() { var latestReleaseId = Guid.NewGuid(); var notLatestReleaseId = Guid.NewGuid(); var topicId = Guid.NewGuid(); var contextId = Guid.NewGuid().ToString(); using (var context = InMemoryApplicationDbContext(contextId)) { context.Add(new Topic { Id = topicId, Publications = new List <Publication> { new Publication { Id = Guid.NewGuid(), Title = "Publication", TopicId = topicId, Releases = new List <Release> { new Release { Id = notLatestReleaseId, ReleaseName = "2019", TimePeriodCoverage = TimeIdentifier.December, Published = DateTime.UtcNow }, new Release { Id = latestReleaseId, ReleaseName = "2020", TimePeriodCoverage = TimeIdentifier.June, Published = DateTime.UtcNow } } } } }); context.SaveChanges(); } using (var context = InMemoryApplicationDbContext(contextId)) { var publicationService = new PublicationRepository(context, AdminMapper()); // Method under test - this return a list of publication for a user. The releases in the publication // should correctly report whether they are the latest or not. Note that this is dependent on the mapper // that we are passing in. var publications = await publicationService.GetAllPublicationsForTopicAsync(topicId); var releases = publications.Single().Releases; Assert.True(releases.Exists(r => r.Id == latestReleaseId && r.LatestRelease)); Assert.True(releases.Exists(r => r.Id == notLatestReleaseId && !r.LatestRelease)); } }
public PublicationService(string connection) { _publicationRepository = new PublicationRepository(connection); _authorRepository = new AuthorRepository(connection); _redactionRepository = new RedactionRepository(connection); _imageHelper = new ImageHelper(); }
public void TestEntityGetById() { var mockTeste = new Mock <IGetDB <Publication> >(); var publicationRepository = new PublicationRepository(mockTeste.Object); publicationRepository.GetById(Guid.NewGuid()); mockTeste.Verify(x => x.GetRegisterById(It.IsAny <Guid>())); }
public JsonpResult GetPrintMaterialList() { using (var pRepo = new PublicationRepository()) { return(new JsonpResult() { Data = pRepo.GetInUseList(), JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public BookService() { _applicationContext = new ApplicationContext(); _bookRepository = new BookRepository(_applicationContext); _publishingHouseRepository = new PublishingHouseRepository(_applicationContext); _publicationInPublisihngHouseRepository = new PublicationInPublisihngHouseRepository(_applicationContext); _publicationRepository = new PublicationRepository(_applicationContext); _publicationInPublisihngHouses = _publicationInPublisihngHouseRepository.Get(/*includeProperties: "PublishingHouse, Publication"*/).ToList(); _books = _bookRepository.Get(includeProperties: "Publication").ToList(); _publishingHouses = _publishingHouseRepository.Get().ToList(); _publications = _publicationRepository.Get().ToList(); }
public void TestEntityDelete() { var pub = PublicationBuilder.New().Build(); var mockTeste = new Mock <IDeleteDB <Publication> >(); var publicationRepository = new PublicationRepository(mockTeste.Object); publicationRepository.Delete(pub); mockTeste.Verify(x => x.DeleteRegister(It.IsAny <Publication>())); }
public ActionResult EditPublicationDetails(int id) { var profileData = Session["UserProfile"] as UserSession; if (profileData == null) { return(RedirectToAction("Index", "Home")); } PublicationRepository pubRepo = new PublicationRepository(); return(View(pubRepo.GetAllPublication().Find(pub => pub.PublicationId == id))); }
public UnitOfWork(ApplicationContext moviesContext) { this.moviesContext = moviesContext; Publications = new PublicationRepository(moviesContext); CaseTypes = new CaseTypeRepository(moviesContext); CompanyRoleTypes = new CompanyRoleTypeRepository(moviesContext); PublicationCompanyRoles = new PublicationCompanyRoleRepository(moviesContext); Companies = new CompanyRepository(moviesContext); ProductionTypes = new ProductionTypeRepository(moviesContext); PublicationItems = new PublicationItemRepository(moviesContext); Persons = new PersonRepository(moviesContext); Productions = new ProductionRepository(moviesContext); }
public ActionResult GetAllPublicationDetails() { var profileData = Session["UserProfile"] as UserSession; if (profileData == null) { return(RedirectToAction("Index", "Home")); } PublicationRepository pubRepo = new PublicationRepository(); ModelState.Clear(); return(View(pubRepo.GetAllPublication())); }
public GeneralService() { _applicationContext = new ApplicationContext(); _bookRepository = new BookRepository(_applicationContext); _magazineRepository = new MagazineRepository(_applicationContext); _brochureRepository = new BrochureRepository(_applicationContext); _publishingHouseRepository = new PublishingHouseRepository(_applicationContext); _publicationInPublisihngHouseRepository = new PublicationInPublisihngHouseRepository(_applicationContext); _publicationRepository = new PublicationRepository(_applicationContext); _publicationInPublisihngHouses = _publicationInPublisihngHouseRepository.Get().ToList(); _books = _bookRepository.Get(includeProperties: "Publication").ToList(); _publishingHouses = _publishingHouseRepository.Get().ToList(); _publications = _publicationRepository.Get().ToList(); }
public ActionResult GetBook(int id) { var profileData = Session["UserProfile"] as UserSession; if (profileData == null) { return(RedirectToAction("Index", "Home")); } BookRepository bookRepository = new BookRepository(); BookAuthorRepository bookAuthorRepository = new BookAuthorRepository(); AuthorRepository authorRepository = new AuthorRepository(); PublicationRepository publicationRepository = new PublicationRepository(); ContentRatingRepository contentRatingRepository = new ContentRatingRepository(); List <BookAuthorModel> bookAuthorList = new List <BookAuthorModel>(); BookDetails bookDetail = new BookDetails(); BookModel book = new BookModel(); book = bookRepository.SearchBookById(id); bookDetail.BookModel = book; bookAuthorList = bookAuthorRepository.GetByBookId(book.BookId); if (bookAuthorList.Count == 1) { bookDetail.AuthorInfo1 = authorRepository.GetByAuthorId(bookAuthorList[0].AuthorId); } else if (bookAuthorList.Count == 2) { bookDetail.AuthorInfo1 = authorRepository.GetByAuthorId(bookAuthorList[0].AuthorId); bookDetail.AuthorInfo2 = authorRepository.GetByAuthorId(bookAuthorList[1].AuthorId); } else { bookDetail.AuthorInfo1 = authorRepository.GetByAuthorId(bookAuthorList[0].AuthorId); bookDetail.AuthorInfo2 = authorRepository.GetByAuthorId(bookAuthorList[1].AuthorId); bookDetail.AuthorInfo3 = authorRepository.GetByAuthorId(bookAuthorList[2].AuthorId); } bookDetail.PublicationModel = publicationRepository.GetByPublicationId(book.PublicationId); bookDetail.ContentRatingModel = contentRatingRepository.GetByContentId(book.ContentRatingId); return(View(bookDetail)); }
public Task EFetch5(long retstart, int maxBatch, Disease disease, List <long> idList) { return(new Task(() => { //Update parameters defaultParameters["retstart"] = $"{ retstart}"; defaultParameters["retmax"] = $"{ maxBatch}"; defaultParameters["id"] = String.Join(", ", idList.ToArray()); var urlContent = new FormUrlEncodedContent(defaultParameters); //Make the request and deserialization using (HttpResponseMessage res = client.PostAsync(urlEfetch, urlContent).Result) using (HttpContent content = res.Content) //using (var stream = await content.ReadAsStreamAsync()) { string stringRes = content.ReadAsStringAsync().Result; try { monDocActuel.LoadXml(stringRes); //Into db PublicationRepository publicationRepository = new PublicationRepository(); //Conversion //List<Publication> lst_publications = new List<Publication>(); List <Publication> lst_publications = ConvertFromPubmedArticleSetToPublications3(monDocActuel, disease); if (lst_publications.Count != 0) { publicationRepository.insertListLessFast(lst_publications); } lst_publications = null; } catch (Exception e) { Console.WriteLine("Error on disease: " + disease.Name + ", orphaNumber: " + disease.OrphaNumber); Console.WriteLine(e); //Console.WriteLine(stringRes);//2 } stringRes = null; } } )); }
public Efetch(int retstart, int maxBatch, Disease diseaseP, List <long> ids, HttpClient clientP, string urlEfetchP, PublicationRepository publicationRepositoryP) { urlContent = new FormUrlEncodedContent( new Dictionary <string, string> { { "db", "pmc" }, { "retstart", $"{retstart}" }, { "retmax", $"{maxBatch}" }, { "rettype", "xml" }, { "retmode", "xml" }, { "api_key", $"{ConfigurationManager.Instance.config.API_Key}" }, { "email", $"{ConfigurationManager.Instance.config.Email}" }, { "tool", $"{ConfigurationManager.Instance.config.Tool}" }, { "id", String.Join(", ", ids.ToArray()) } } ); disease = diseaseP; client = clientP; urlEfetch = urlEfetchP; publicationRepository = publicationRepositoryP; monDocActuel = new XmlDocument(); }
public ActionResult EditPublicationDetails(int id, PublicationModel obj) { try { PublicationRepository publicationRepository = new PublicationRepository(); publicationRepository.UpdatePublication(obj); var profileData = Session["UserProfile"] as UserSession; var logModel = new LogModel { UserId = profileData.UserID, TableName = "Publication", Activity = "Updated Publication", LogDate = DateTime.Now }; var logRepository = new logRepository(); logRepository.AddLog(logModel); return(RedirectToAction("GetAllPublicationDetails")); } catch { return(RedirectToAction("GetAllPublicationDetails")); } }
/// <summary> /// Initializes a new instance of the <see cref="PublicationService"/> class. /// </summary> /// <param name="publicationRepository">The publication repository.</param> public PublicationService(PublicationRepository publicationRepository) : base(publicationRepository) { }
public HomeService() { _applicationContext = new ApplicationContext(); _publicationRepository = new PublicationRepository(_applicationContext); }
public Task PubmedCrawlerFetch3(long retstart, int maxBatch, Disease disease, List <long> idList) { return(new Task(async() => { //Initialization HttpClient client = new HttpClient(); //URL and parameters string url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi"; var parameters = new Dictionary <string, string> { { "db", "pmc" }, { "retstart", $"{retstart}" }, { "retmax", $"{maxBatch}" }, { "rettype", "xml" }, { "retmode", "xml" }, { "api_key", $"{ConfigurationManager.Instance.config.API_Key}" }, { "email", $"{ConfigurationManager.Instance.config.Email}" }, { "tool", $"{ConfigurationManager.Instance.config.Tool}" }, { "id", String.Join(", ", idList.ToArray()) } }; var urlContent = new FormUrlEncodedContent(parameters); //Make the request and deserialization using (HttpResponseMessage res = await client.PostAsync(url, urlContent)) using (HttpContent content = res.Content) //using (var stream = await content.ReadAsStreamAsync()) { string stringRes = await content.ReadAsStringAsync();//2 try { XmlDocument monDoc = new XmlDocument(); monDoc.LoadXml(stringRes);//2 //monDoc.Load(stream);//1 //Into db PublicationRepository publicationRepository = new PublicationRepository(); Console.WriteLine("Lancement conversion efetch......."); //Conversion Console.WriteLine("Debut parsing"); //List<Publication> lst_publications = new List<Publication>(); List <Publication> lst_publications = ConvertFromPubmedArticleSetToPublications3(monDoc, disease); Console.WriteLine("Fin parsing"); Console.WriteLine("Fin conversion efetch !!"); if (lst_publications.Count != 0) { publicationRepository.insertListLessFast(lst_publications); } lst_publications = null; } catch (Exception e) { Console.WriteLine("Error on disease: " + disease.Name + ", orphaNumber: " + disease.OrphaNumber); Console.WriteLine(e); //Console.WriteLine(stringRes);//2 } stringRes = null; } })); }
public async void ReleasesCorrectlyOrdered() { var topicId = Guid.NewGuid(); var contextId = Guid.NewGuid().ToString(); using (var context = InMemoryApplicationDbContext(contextId)) { context.Add(new Topic { Id = topicId, Publications = new List <Publication> { new Publication { Id = Guid.NewGuid(), Title = "Publication", TopicId = topicId, Releases = new List <Release> { new Release { Id = Guid.NewGuid(), ReleaseName = "2000", TimePeriodCoverage = TimeIdentifier.Week1, Published = DateTime.UtcNow }, new Release { Id = Guid.NewGuid(), ReleaseName = "2000", TimePeriodCoverage = TimeIdentifier.Week11, Published = DateTime.UtcNow }, new Release { Id = Guid.NewGuid(), ReleaseName = "2000", TimePeriodCoverage = TimeIdentifier.Week3, Published = DateTime.UtcNow }, new Release { Id = Guid.NewGuid(), ReleaseName = "2000", TimePeriodCoverage = TimeIdentifier.Week2, Published = DateTime.UtcNow }, new Release { Id = Guid.NewGuid(), ReleaseName = "2001", TimePeriodCoverage = TimeIdentifier.Week1, Published = DateTime.UtcNow }, new Release { Id = Guid.NewGuid(), ReleaseName = "1999", TimePeriodCoverage = TimeIdentifier.Week1, Published = DateTime.UtcNow } } } } }); context.SaveChanges(); } using (var context = InMemoryApplicationDbContext(contextId)) { var publicationService = new PublicationRepository(context, AdminMapper()); var publications = await publicationService.GetAllPublicationsForTopicAsync(topicId); var releases = publications.Single().Releases; Assert.Equal("Week 1 2001", releases[0].Title); Assert.Equal("Week 11 2000", releases[1].Title); Assert.Equal("Week 3 2000", releases[2].Title); Assert.Equal("Week 2 2000", releases[3].Title); Assert.Equal("Week 1 2000", releases[4].Title); Assert.Equal("Week 1 1999", releases[5].Title); } }
public static Task DoTheRequestAsync2(List <long> maListe2, Disease disease) { return(new Task(async() => { //Initialization HttpClient client = new HttpClient(); List <Publication> results = new List <Publication>(); //URL and parameters string url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc"; string ids = String.Join(", ", maListe2.ToArray()); string jsonInString = JsonConvert.SerializeObject(new { //db = "pmc", retstart = $"{0}", retmax = $"{500}", rettype = "xml", retmode = "xml", api_key = $"{ConfigurationManager.Instance.config.API_Key}", email = $"{ConfigurationManager.Instance.config.Email}", tool = $"{ConfigurationManager.Instance.config.Tool}", id = ids }); var parameters = new Dictionary <string, string> { { "db", "pmc" }, { "retstart", "0" }, { "retmax", "500" }, { "rettype", "xml" }, { "retmode", "xml" }, { "api_key", $"{ConfigurationManager.Instance.config.API_Key}" }, { "email", $"{ConfigurationManager.Instance.config.Email}" }, { "tool", $"{ConfigurationManager.Instance.config.Tool}" }, { "id", ids } }; var urlContent = new FormUrlEncodedContent(parameters); Console.WriteLine(urlContent); //Make the request and deserialization XmlSerializer serializer = new XmlSerializer(typeof(Pmcarticleset)); using (HttpResponseMessage res = await client.PostAsync(url, urlContent)) using (HttpContent content = res.Content) using (var stream = await content.ReadAsStreamAsync()) //using (var reader = XmlReader.Create(stream, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore }))//1 { string stringRes = await content.ReadAsStringAsync(); //2 var reader = new StreamReader(stream, Encoding.UTF8); //2 string resString = reader.ReadToEnd(); //2 //var reader = XmlReader.Create(stream, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore });//1 try { //var pmcArticleSet = serializer.Deserialize(reader) as Pmcarticleset;//1 XmlDocument monDoc = new XmlDocument(); monDoc.LoadXml(resString); //Into db PublicationRepository publicationRepository = new PublicationRepository(); List <Publication> lst_publications = ConvertFromPubmedArticleSetToPublications3(monDoc, disease); if (lst_publications.Count != 0) { publicationRepository.insertListLessFast(lst_publications); } } catch (Exception e) { Console.WriteLine("Error on disease: " + disease.Name + ", orphaNumber: " + disease.OrphaNumber); Console.WriteLine(e); } } })); }