public Server(int port) { Version = 1; Methods = new Methods(); Subscriptions = new Subscriptions(); Publications = new Publications(); new PublicationMethods(this).AttachMethods(); var messageMethods = new MessageMethods(this).GetMethods(); var messageProcessor = new MessageProcessor(messageMethods); _messageQueue = new ResultQueue<KeyValuePair<IWebSocketConnection, string>>(messageProcessor); _connector = new Connector(this, "127.0.0.1", port); }
public async Task <IActionResult> Create([Bind("Id,Books_Copies,Publisher_detailId,Books_detailId")] Publications publications) { if (ModelState.IsValid) { _context.Add(publications); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Books_detailId"] = new SelectList(_context.Books, "Id", "Tittle", publications.Books_detailId); ViewData["Publisher_detailId"] = new SelectList(_context.Publisher, "Id", "Publisher_Name", publications.Publisher_detailId); return(View(publications)); }
public void UpdateRatingForPublication(int publicationId) { var publication = Publications.Include(pub => pub.Reviews).Where(p => p.Id == publicationId).FirstOrDefault(); if (publication.Reviews.Count > 0) { publication.Rating = publication.Reviews.Average(rev => rev.Rating); } else { publication.Rating = 0; } Publications.Update(publication); }
private void ListBook_Load(object sender, EventArgs e) { inpu = new List <Input>(); Books books = new Books(); inpu = books.selected(); int currentX = 20, currentY = 5; // MessageBox.Show(inpu.Count()+""); for (int i = 0; i <= inpu.Count() - 1; i++) { ListOfData lsd = new ListOfData(); lsd.namee = inpu[i].Title; Authors authors = new Authors(); // MessageBox.Show(inpu[i].Isbn + ""); authorsId = authors.selectedAuthorId(inpu[i].Isbn); if (authorsId.Count() != 0) { for (int c = 0; c <= authorsId.Count() - 1; c++) { authorsName.Add(authors.selectedAuthorName(authorsId[c])); //MessageBox.Show("m " + authorsId[c] + " authorsId[c] " + authorsName[c]+" authorsName[c]"); inpu[i].Name = inpu[i].Name + "|" + authorsName[c]; } lsd.family = "..." + authorsName[0]; } // MessageBox.Show(inpu[i].Name + ""); Publications publications = new Publications(); publicId = publications.selectedpublicationsId(inpu[i].Isbn); inpu[i].Family = publications.selectedpublicationName(publicId); lsd.code = inpu[i].Family; lsd.number = inpu[i].Isbn; lsd.btnTagDelete = inpu[i].Isbn + "*"; lsd.btnTagDetails = i; authorsName.Clear(); if (i % 2 == 0) { lsd.colour = "#EDF0FC"; } else { lsd.colour = "#ffffff"; } lsd.Location = new Point(currentX, currentY); this.panel5.Controls.Add(lsd); currentY = currentY + 50; } }
// GET: Publications/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Publications publications = db.Publications.Find(id); if (publications == null) { return(HttpNotFound()); } return(View(publications)); }
public async Task <JsonResult> OnPostGetPDF([FromBody] Publications publication) { var token = HttpContext.Session.GetString("token"); var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault(); var l = await this._aS.RefreshToken(id, CultureInfo.CurrentCulture.Name, "SUPPLIER", token); if (l.Error == null) { HttpContext.Session.SetString("token", l.Token); } var refreshToken = "Token refreshed"; return(new JsonResult(refreshToken)); }
public async Task <ActionResult <Users> > AddPublication() { try { using (var reader = new StreamReader(Request.Body)) { var body = reader.ReadToEnd(); dynamic data = JsonConvert.DeserializeObject(body); Publications publication = new Publications(); publication.Date = data["date"]; publication.Description = data["description"]; publication.Userid = data["userId"]; _context.Publications.Add(publication); await _context.SaveChangesAsync(); var files = data["files"]; foreach (var file in files) { Contents content = new Contents(); content.Format = file["format"]; content.Src = file["src"]; _context.Contents.Add(content); await _context.SaveChangesAsync(); var contentId = content.Id; PublicationContents publicationContent = new PublicationContents(); publicationContent.Contentid = contentId; publicationContent.Pubid = publication.Id; _context.PublicationContents.Add(publicationContent); await _context.SaveChangesAsync(); } return(Json(new { success = true, pubId = publication.Id })); } } catch (System.Exception e) { System.Diagnostics.Debug.Write(e); return(Json(new { success = false, message = "Could not add user to the Data Base" })); } }
public Publications LoadPublications(string fileName) { Publications publications = null; using (TextReader textReader = new StreamReader(fileName)) { using (XmlTextReader reader = new XmlTextReader(textReader)) { reader.Namespaces = false; XmlSerializer serializer = new XmlSerializer(typeof(Publications)); publications = (Publications)serializer.Deserialize(reader); } } return(publications); }
public void TestLongGrantID() { Publication p = new Publication(); Assert.IsNull(p.Grants); Publications.ProcessMedlineTag(ref p, "GR - GM 28356/GM/NIGMS", pubTypes); Publications.ProcessMedlineTag(ref p, "GR - AM18811/AM/NIADDK", pubTypes); Publications.ProcessMedlineTag(ref p, "GR - HD09690/HD/NICHD", pubTypes); Publications.ProcessMedlineTag(ref p, "GR - AG11624/AG/NIA", pubTypes); Publications.ProcessMedlineTag(ref p, "GR - AG20557/AG/NIA", pubTypes); Assert.IsTrue(p.Grants.Count == 5); foreach (string Grant in new string[] { "GM 28356/GM/NIGMS", "AM18811/AM/NIADDK", "HD09690/HD/NICHD", "AG11624/AG/NIA", "AG20557/AG/NIA" }) { Assert.IsTrue(p.Grants.Contains(Grant)); } }
public override int GetHashCode() { unchecked { var hashCode = (Basics != null ? Basics.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Work != null ? Work.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Volunteer != null ? Volunteer.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Education != null ? Education.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Awards != null ? Awards.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Publications != null ? Publications.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Skills != null ? Skills.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Languages != null ? Languages.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Interests != null ? Interests.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (References != null ? References.GetHashCode() : 0); return(hashCode); } }
private void UpdatePublications(List <Publication> newList, bool isOffline = false) { bool isDataChanged = false; if (Publications != null) { if (newList == null) { Publications = null; isDataChanged = true; } else { var newCollection = new List <PublicationViewModel>(); foreach (var publication in newList) { var currrentPublicaton = Publications.FirstOrDefault(x => x.BookId == publication.BookId); if (currrentPublicaton != null) { if (currrentPublicaton.Version != publication.CurrentVersion.ToString() || isOffline) { currrentPublicaton.UpdateData(publication); isDataChanged = true; } newCollection.Add(currrentPublicaton); } else { newCollection.Add(new PublicationViewModel(publication)); isDataChanged = true; } } Publications = newCollection; } } else { Publications = newList == null ? null : newList.Select(x => new PublicationViewModel(x)).ToList(); isDataChanged = true; } if (isDataChanged) { FilterData(); SessionService.SessionState[ALL_PUBLICATIONS_SESSION_KEY] = Publications; } }
public void EmptyPublicationList() { string emptySearchResults = @"<?xml version=""1.0"" encoding=""UTF-8""?> <eFetchResult> <ERROR>Empty result - nothing to do</ERROR> </eFetchResult>"; PublicationTypes ptc = new PublicationTypes( AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes", "PublicationTypes.csv" ); Publications mpr = new Publications(emptySearchResults, ptc); Assert.IsNull(mpr.PublicationList); }
// GET: Publications/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Publications publications = db.Publications.Find(id); Student student = publications.Student; if (publications == null) { return(HttpNotFound()); } ViewBag.PubMonthId = new SelectList(db.CommonFields.Where(o => o.Category == "Months"), "ID", "Name", publications.PubMonthId); ViewBag.Student = student; ViewBag.StudentID = student.Id; return(View(publications)); }
// GET: Publications/Delete/5 public ActionResult Delete(int?id) { if (id == null) { TempData["msg"] = "<script>alert('Sorry! No record found to delete.')</script>"; return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Publications publications = db.Publications.Find(id); if (publications == null) { TempData["msg"] = "<script>alert('Sorry! No record found to delete.')</script>"; return(HttpNotFound()); } int sendId = (int)id; return(DeleteConfirmed(sendId)); }
public async Task <IActionResult> Create([Bind("PublicationId,GameId,PublisherId")] Publications publications) { bool duplicate = await _context.Publications.AnyAsync(l => l.GameId.Equals(publications.GameId) && l.PublisherId.Equals(publications.PublisherId)); if (duplicate) { ModelState.AddModelError("", "Така публікація вже додана"); } if (ModelState.IsValid) { _context.Add(publications); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.Games, "GameId", "Name", publications.GameId); ViewData["PublisherId"] = new SelectList(_context.Publishers, "PublisherId", "Name", publications.PublisherId); return(View(publications)); }
private void button4_Click(object sender, EventArgs e) { if (n_e == false) { string name = txtName.Text; string family = txtFamily.Text; Authors authores = new Authors(); authores.name = txtName.Text; authores.family = txtFamily.Text; authores.insert(); fill_datagridview_nevisande_select(); } else { Publications publications = new Publications(); publications.name = txtName.Text; publications.insert(); fill_datagridview_entesharat_select(); } }
public void TestCreateFromDatabase() { // Add a publication to the database Database DB = new Database("Publication Harvester Unit Test"); Harvester harvester = new Harvester(DB); harvester.CreateTables(); Publication write = CreateTestPublication(); PublicationTypes ptc = new PublicationTypes( AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes", "PublicationTypes.csv" ); Publications.WriteToDB(write, DB, ptc, new string[] { "eng" }); // Read it back Publication read; Assert.IsTrue(Publications.GetPublication(DB, 15904469, out read, false)); TestCreatedPublication(read); }
private void button1_Click(object sender, EventArgs e) { Calender cl = new Calender(); DateTime d1 = DateTime.Now; string dateShamse = cl.MilliTimeStamp(d1); if (txtTitle.Text != "" && txtYear.Text != "" && txtNumber.Text != "" && txtIsbn.Text != "" && txtPublication.Text != "" && txtC.Text != "" && panel10.Enabled) { Books books = new Books(); books.isbn = txtIsbn.Text; books.title = txtTitle.Text; books.yearPublication = Convert.ToInt16(txtYear.Text); books.numberBook = Convert.ToInt16(txtNumber.Text); books.picture = pic.Tag.ToString(); books.date = dateShamse; int i = books.insert(); for (int c = 0; c < A_id.Count(); c++) { Authors authors = new Authors(); authors.insertToBook_Writtenby(A_id[c], txtIsbn.Text); } A_id.Clear(); Publications publications = new Publications(); publications.insertToBooks_published(P_id, txtIsbn.Text); if (i == 1) { MessageBox.Show("با موفقیت ثبت شد "); //each(2); } else { MessageBox.Show(" خطا در ثبت "); } } else { MessageBox.Show("لطفا اطلاعات را کامل وارد کنید ", "هشدار"); } }
private void FilterData() { readyForReorder = false; FiltedPublications.Clear(); if (Publications != null) { switch (SelectedFilter) { case FILTER_VALUE_ALL: Publications.ForEach(x => FiltedPublications.Add(x)); break; case FILTER_VALUE_LOAN: Publications.ForEach(x => { if (x.IsLoan) { FiltedPublications.Add(x); } }); break; case FILTER_VALUE_SUBSCRIPTION: Publications.ForEach(x => { if (!x.IsLoan) { FiltedPublications.Add(x); } }); break; } } PublicationCount = FiltedPublications.Count(); readyForReorder = true; }
public async Task <Task> Publicar([FromBody] Offert oferta) { Publications resultado = new Publications() { Error = new Exception("Invalid offert") }; resultado = await this._aS.OfferPublication(oferta, oferta.Token); if (resultado.Errors != null) { return(Clients.Caller.SendAsync("Publications", resultado)); } if (resultado.Error != null) { return(Clients.Caller.SendAsync("Publications", resultado)); } resultado.Bids = new List <Bids>() { new Bids() { Factor = new People() { Id = oferta.Factor_id } } }; if (oferta.Factor_id == resultado.Bids[0].Factor_id) { resultado.isOffered = true; } return(Clients.Group(resultado.Invoice.Country.Value + "").SendAsync("Publications", resultado)); }
public static void Main() { Contanct[] contacts = new Contanct[6]; contacts[0] = new Contact( "Dick", "Traci", "123 Main St., Spokane, WA 99037", "123-123-1234" ); //... // 클래스는 지원되는 인터페이스로 암시적 변환된다. catacts.List(Contact.Headers); Console.WriteLine(); Publication[] publications = new Publication[3] { new Publication("Celebration of Discipline", "Richard Foster", 1978), new Publication("Orthodoxy", "G.K. Chesterton", 1908), new Publication("The Hitchhiker's Guide to thr Galaxy", "Douglas Adams", 1979) }; Publications.List(Publication.Headers); }
async Task ExecuteLoadGivesCommand() { IsBusy = true; try { Publications.Clear(); var publications = await DataStoreGive.GetItemsAsync(true); foreach (var publication in publications) { Publications.Add(publication); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task <JsonResult> OnPostOfertar([FromBody] Offert oferta) { var token = HttpContext.Session.GetString("token"); Publications data = new Publications(); oferta.Factor_id = this._signInManager.UserManager.GetUserId(User); data = await this._aS.OfferPublication(oferta, token); if (data.Error == null) { var id = User.Claims.Where(x => x.Type == "Id").Select(x => x.Value).SingleOrDefault(); var l = await this._authS.RefreshToken(id, CultureInfo.CurrentCulture.Name, "FACTOR", token); if (l.Error == null) { HttpContext.Session.SetString("token", l.Token); } } return(new JsonResult(data)); }
public async Task <IActionResult> Edit(int id, [Bind("PublicationId,GameId,PublisherId")] Publications publications) { bool duplicate = await _context.Publications.AnyAsync(l => l.GameId.Equals(publications.GameId) && l.PublisherId.Equals(publications.PublisherId) && !l.PublicationId.Equals(publications.PublicationId)); if (duplicate) { ModelState.AddModelError("", "Така публікація вже додана"); } if (id != publications.PublicationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(publications); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PublicationsExists(publications.PublicationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GameId"] = new SelectList(_context.Games, "GameId", "Name", publications.GameId); ViewData["PublisherId"] = new SelectList(_context.Publishers, "PublisherId", "Name", publications.PublisherId); return(View(publications)); }
public virtual IPublication Publish(IComputed computed) { ThrowIfDisposedOrDisposing(); var spinWait = new SpinWait(); while (true) { var p = Publications.GetOrAddChecked( computed.Input, (key, arg) => { var(this1, computed1) = arg; var id = this1.PublicationIdGenerator.Next(); var p1 = this1.PublicationFactory.Create(this1.PublicationGeneric, this1, computed1, id, Clock); this1.PublicationsById[id] = p1; p1.RunAsync(); return(p1); }, (this, computed)); if (p.Touch()) { return(p); } spinWait.SpinOnce(); } }
private async Task ReorderPublications() { if (SelectedFilter == FILTER_VALUE_ALL) { for (int i = 0; i < FiltedPublications.Count; i++) { Publications[i] = FiltedPublications[i]; } } else { int j = 0; foreach (var p in FiltedPublications) { while (Publications[j].IsLoan != p.IsLoan) { j++; } Publications[j] = p; j++; } } await PublicationUtil.Instance.OrganiseDlsOrder(Publications.Select(x => x.BookId).ToList()); }
static void Run1() { Console.Write("hello \n"); string authorstxt = @"C:\Users\jakub\Documents\Visual Studio 2017\dblp-reducer\data\Authors_short.txt"; string authorsxml = @"C:\dblp_result\636733187090414687\Authors.xml"; string publicationsxml = @"C:\dblp_result\636733187090414687\Publications.xml"; // TODO: load list of restricted authors List <string> AuthorsName = Loader.TextListLoader.LoadAuthors(authorstxt); // TODO: load authors.xml Loader.XmlLoader XmlParser = new Loader.XmlLoader(); Authors parsedData = XmlParser.LoadAuthors(authorsxml); // TODO: Find authors from restricted list in xml file and return list of ids List <Author> AuthorsList = parsedData.AuthorsList; int TotalCount = AuthorsName.Count; HashSet <Author> FoundAuthorsList = new HashSet <Author>(); Dictionary <string, string> FoundNames = new Dictionary <string, string>(); foreach (string queryName in AuthorsName) { var item = AuthorsList.Where(x => Compare(x.Name, queryName)).FirstOrDefault(); if (item != null && !FoundNames.ContainsKey(queryName)) { FoundNames.Add(queryName, item.Name); FoundAuthorsList.Add(item); } } bool Compare(string nameA, string nameB) { if (nameA == nameB) { return(true); } else { int LastSpaceIndexA = nameA.LastIndexOf(' '); int LastSpaceIndexB = nameB.LastIndexOf(' '); if (LastSpaceIndexA > 0 && LastSpaceIndexB > 0) { string nameALastName = nameA.Substring(LastSpaceIndexA, (nameA.Length - LastSpaceIndexA)); string nameBLastName = nameB.Substring(LastSpaceIndexB, (nameB.Length - LastSpaceIndexB)); if (nameALastName == nameBLastName) { if (nameA.Substring(0, (nameA.IndexOf(' '))) == nameB.Substring(0, (nameB.IndexOf(' ')))) { return(true); } } } } return(false); } // TODO: Print stats Console.WriteLine("Count of found = " + FoundAuthorsList.Count + " of " + TotalCount); foreach (KeyValuePair <string, string> kvp in FoundNames) { Console.WriteLine(kvp.Key + " - " + kvp.Value); } Console.WriteLine("-------------------"); foreach (string name in AuthorsName) { if (!FoundNames.ContainsKey(name)) { Console.WriteLine(name); } } // TODO: Load publications.xml Publications publications = XmlParser.LoadPublications(publicationsxml); // TODO: Walkthrou publications and find coauthors. bool first = true; Dictionary <int, List <int> > CooperationNetwork = new Dictionary <int, List <int> >(); foreach (Publication publication in publications.PublicationsList) { first = true; foreach (Author author in publication.AuthorsList) { if (FoundAuthorsList.Contains(author)) { if (first) { CooperationNetwork.Add(publication.Id, new List <int>()); CooperationNetwork[publication.Id].Add(author.Id); first = false; } else { CooperationNetwork[publication.Id].Add(author.Id); } } } } Dictionary <int, List <int> > AnotherDic = new Dictionary <int, List <int> >(); Dictionary <int, int> NodeToIndexDict = new Dictionary <int, int>(); Dictionary <int, int> IndexToNodeDict = new Dictionary <int, int>(); int index = 0; foreach (KeyValuePair <int, List <int> > item in CooperationNetwork) { if (item.Value.Count >= 2) { AnotherDic.Add(item.Key, item.Value); foreach (int author in item.Value) { if (!NodeToIndexDict.ContainsKey(author)) { NodeToIndexDict.Add(author, index); IndexToNodeDict.Add(index, author); index++; } } } } int[,] WeightedAdjacencyMatrix = new int[NodeToIndexDict.Count, NodeToIndexDict.Count]; foreach (KeyValuePair <int, List <int> > item in CooperationNetwork) { for (int i = 0; i < item.Value.Count - 1; i++) { WeightedAdjacencyMatrix[NodeToIndexDict[item.Value[i]], NodeToIndexDict[item.Value[i + 1]]]++; } } // TODO: Export network of coauthors to file GmlExporter exporter = new GmlExporter(); exporter.Export("stanford.gml", FoundAuthorsList.ToList(), WeightedAdjacencyMatrix, IndexToNodeDict); Console.WriteLine("DONE"); }
public void TestPubsReportRow() { // Set up the database with test publications (and don't forget to add the // publication types!) DB = new Database("Publication Harvester Unit Test"); Harvester harvester = new Harvester(DB); harvester.CreateTables(); PublicationTypes PubTypes = new PublicationTypes( AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes", "PublicationTypes.csv" ); PubTypes.WriteToDB(DB); reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls"); Assert.IsTrue(reports.Weights.Count == 10); TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22); people = new People(DB); foreach (Person person in people.PersonList) { Publications pubs = new Publications(DB, person, false); if (pubs.PublicationList != null) { foreach (Publication pub in pubs.PublicationList) { DataRow Row = WriteAndReadBackCSVRow(reports.PubsReportRow(person, pub)); switch (pub.PMID) { case 15249795: // 0. setnb Assert.IsTrue(Row.ItemArray[0].ToString() == "A5401532"); // 1. pmid Assert.IsTrue(Row.ItemArray[1].ToString() == "15249795"); // 2. journal_name Assert.IsTrue(Row.ItemArray[2].ToString() == "J Clin Hypertens (Greenwich)"); // 3. year Assert.IsTrue(Row.ItemArray[3].ToString() == "2004"); // 4. Month Assert.IsTrue(Row.ItemArray[4].ToString() == "Jul"); // 5. day Assert.IsTrue(Row.ItemArray[5].ToString() == ""); // 6. title Assert.IsTrue(Row.ItemArray[6].ToString() == "Interview with Louis Tobian, MD. Interview by Marvin Moser."); // 7. Volume Assert.IsTrue(Row.ItemArray[7].ToString() == "6"); // 8. issue Assert.IsTrue(Row.ItemArray[8].ToString() == "7"); // 9. position Assert.IsTrue(Row.ItemArray[9].ToString() == "1"); // 10. nbauthors Assert.IsTrue(Row.ItemArray[10].ToString() == "1"); // 11. Bin Assert.IsTrue(Row.ItemArray[11].ToString() == "0"); // 12. Pages Assert.IsTrue(Row.ItemArray[12].ToString() == "391-2"); // 13. Publication_type Assert.IsTrue(Row.ItemArray[13].ToString() == "Historical Article"); break; } } } } }
public void TestPeopleReportRows() { // Set up the database with test publications (and don't forget to add the // publication types!) DB = new Database("Publication Harvester Unit Test"); Harvester harvester = new Harvester(DB); harvester.CreateTables(); PublicationTypes PubTypes = new PublicationTypes( AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes", "PublicationTypes.csv" ); PubTypes.WriteToDB(DB); reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls"); Assert.IsTrue(reports.Weights.Count == 10); TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22); people = new People(DB); foreach (Person person in people.PersonList) { Publications pubs = new Publications(DB, person, false); switch (person.Setnb) { case "A6009400": // Van Eys has two publications in 1998, both have zero weight DataRow Row = WriteAndReadBackCSVRow(reports.ReportRow(person, pubs, 1998)); Assert.IsTrue(Row.ItemArray.Length == 74); Assert.IsTrue(Row.ItemArray[0].ToString() == "A6009400"); Assert.IsTrue(Row.ItemArray[1].ToString() == "1998"); // Verify that all values are zero, except for pubcount (#3), // pubcount_pos1 (#5), 123pubcount (#15), 123pubcount_pos1 (#17), // 3pubcount (#51), 3pubcount_pos1 (#53) for (int i = 2; i <= 73; i++) { if ((i == 2) || (i == 4) || (i == 14) || (i == 16) || (i == 50) || (i == 52)) { Assert.IsTrue(Row.ItemArray[i].ToString() == "2", "Failed at i == " + i.ToString()); } else { Assert.IsTrue(Row.ItemArray[i].ToString() == "0", "Failed at i == " + i.ToString()); } } break; case "A5401532": // Tobian has two publications in 1997 of type 3 with a // combined weight of 4.602 Row = WriteAndReadBackCSVRow(reports.ReportRow(person, pubs, 1997)); Assert.IsTrue(Row.ItemArray.Length == 74); Assert.IsTrue(Row.ItemArray[0].ToString() == "A5401532"); Assert.IsTrue(Row.ItemArray[1].ToString() == "1997"); // Verify that all values are zero, except for pubcount (#3), // pubcount_pos1 (#5), 123pubcount (#15), 123pubcount_pos1 (#17), // 3pubcount (#51), 3pubcount_pos1 (#53), which should be 2 // // and wghtd_pubcount (#4), wghtd_pubcount_pos1 (#6), // wghtd_123pubcount (#16), wghtd_123pubcount_pos1 (#18), // wghtd_3pubcount (#52), wghtd_3pubcount_pos1 (#54), // which should be 4.602 for (int i = 2; i <= 73; i++) { if ((i == 2) || (i == 4) || (i == 14) || (i == 16) || (i == 50) || (i == 52)) { Assert.IsTrue(Row.ItemArray[i].ToString() == "2", "Failed at i == " + i.ToString()); } else if ((i == 3) || (i == 5) || (i == 15) || (i == 17) || (i == 51) || (i == 53)) { Assert.IsTrue(Row.ItemArray[i].ToString() == "4.602", "Failed at i == " + i.ToString()); } else { Assert.IsTrue(Row.ItemArray[i].ToString() == "0", "Failed at i == " + i.ToString()); } } break; } } }
private Tool ExtractPublications(Tool info) { if (info == null) { return(null); } foreach (var filename in info.XMLFiles) { Logger.LogDebug( $"Extracting publication info from XML file " + $"`{Path.GetFileNameWithoutExtension(filename)}` " + $"of tool `{info.Name}`."); try { XElement toolDoc = XElement.Load(filename); foreach (var item in toolDoc.Elements("citations").Descendants()) { if (item.Attribute("type") != null) { switch (item.Attribute("type").Value.Trim().ToUpperInvariant()) { case "DOI": if (!Publications.ContainsKey(info.ID)) { Publications.TryAdd(info.ID, new List <Publication>()); } Publications[info.ID].Add(new Publication() { DOI = item.Value }); /// Some tools have one BibItem that contains only DOI, and /// another BibItem that contains publication info. There should /// be only one BibItem per publication contains both DOI and /// publication info. Therefore, for tools with two bibitems, /// we consider only the one containing DOI. continue; case "BIBTEX": try { if (TryParseBibitem(item.Value, out Publication pub)) { if (!Publications.ContainsKey(info.ID)) { Publications.TryAdd(info.ID, new List <Publication>()); } Publications[info.ID].Add(pub); } } catch (ArgumentException e) { Logger.LogDebug( $"Error extracting publication from XML file of tool " + $"`{info.Name}`:{e.Message}"); } break; } } } Logger.LogDebug( $"Successfully extract publication info from XML file " + $"`{Path.GetFileNameWithoutExtension(filename)}` " + $"of tool `{info.Name}`."); } catch (System.Xml.XmlException e) { /// This exception may happen if the XML /// file has multiple roots. Logger.LogDebug( $"Failed extracting publication info from XML file " + $"`{Path.GetFileNameWithoutExtension(filename)}`" + $" of tool `{info.Name}`: {e.Message}"); return(null); } } return(info); }
/// <summary> /// Add five extra articles to the database for Tobian and Bunn /// </summary> public static void CreateExtraArticlesForTobianAndBunn(Database DB, PublicationTypes PubTypes, string[] Languages) { // Create people objects for Tobian and Bunn Person Tobian = new Person("A5401532", "Louis", "", "Tobian", true, new String[] { "tobian l", "tobian l jr", "tobian lj" }, "(\"tobian l\"[au] OR \"tobian l jr\"[au] OR \"tobian lj\"[au])"); Person Bunn = new Person("A4800524", "PAUL", "A.", "BUNN", true, new String[] { "bunn p jr", "bunn pa jr", "bunn pa", "bunn p" }, "((\"bunn pa jr\"[au] or \"bunn p jr\"[au]) or ((\"bunn p\"[au] or \"bunn pa\"[au]) and (lymphoma or cancer)) and 1970:2005[dp])"); // First, add a few more publications to the colleague. Publication pub = new Publication(); string[] Authors = new String[] { "TOBIAN L", "BUNN P" }; pub.Year = 1993; pub.Journal = "Fake Journal"; pub.Authors = Authors; pub.PMID = 22222222; pub.Title = "Fake article #1"; pub.Language = "eng"; pub.PubType = "Journal Article"; Publications.WriteToDB(pub, DB, PubTypes, Languages); Publications.WritePeoplePublicationsToDB(DB, Tobian, pub); ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" }); pub = new Publication(); Authors = new String[] { "BUNN P", "TOBIAN L" }; pub.Year = 1996; pub.Journal = "Xenotransplantation"; pub.Authors = Authors; pub.PMID = 12345678; pub.Title = "Fake article #2"; pub.Language = "eng"; pub.PubType = "Journal Article"; Publications.WriteToDB(pub, DB, PubTypes, Languages); Publications.WritePeoplePublicationsToDB(DB, Tobian, pub); ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" }); pub = new Publication(); Authors = new String[] { "TOBIAN L", "BUNN P" }; pub.Year = 1996; pub.Journal = "Fake Journal"; pub.Authors = Authors; pub.PMID = 98765432; pub.Title = "Fake article #3"; pub.Language = "eng"; pub.PubType = "Journal Article"; Publications.WriteToDB(pub, DB, PubTypes, Languages); Publications.WritePeoplePublicationsToDB(DB, Tobian, pub); ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" }); pub = new Publication(); Authors = new String[] { "TOBIAN L", "BUNN P", "SCHMOE J" }; pub.Year = 2001; pub.Journal = "Nature"; pub.Authors = Authors; pub.PMID = 55555555; pub.Title = "Fake article #4"; pub.Language = "eng"; pub.PubType = "Journal Article"; Publications.WriteToDB(pub, DB, PubTypes, Languages); Publications.WritePeoplePublicationsToDB(DB, Tobian, pub); ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" }); }