public ActionResult FetchFromDivaApi(int yearFrom, int yearTo) { var request = WebRequest.Create( String.Format( ConfigurationManager.AppSettings["DivaApiUrl"], yearFrom, yearTo) ); request.ContentType = "text/csv"; request.Method = "GET"; using (var response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) { ViewBag.Error = string.Format("Error fetching data. Server returned status code: {0}", response.StatusCode); } else { Dictionary <string, string>[] divaRecords = MatchWoSToDiva.PrepareDivaFile(new StreamReader(response.GetResponseStream()), false).ToArray(); Session["DivaRecords"] = divaRecords; } } return(RedirectToAction("MatchingSplash")); }
// Test-controller för Wos-Mods-överföring // Filnamn: article.txt savedrecs.txt testsearch.txt WoS_SU_2011_ar-re_1-88_new_120227.txt public ActionResult WosToMods(string id) { var filePath = Server.MapPath(path + "\\" + (string.IsNullOrWhiteSpace(id) ? "testsearch4.txt" : id + ".txt")); var f = new FileInfo(filePath); Dictionary <string, string>[] wosRecords = null; using (var sr = new StreamReader(filePath)) { wosRecords = MatchWoSToDiva.PrepareWosFile(sr).ToArray(); } XNamespace xmlns = "http://www.loc.gov/mods/v3"; XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance"; XNamespace xlink = "http://www.w3.org/1999/xlink"; XNamespace schemaLocation = "http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"; // Konverterar postvis, resultatet ska bäddas in i ModsCollection. var modsCollection = new XElement(xmlns + "modsCollection", new XAttribute("xmlns", "http://www.loc.gov/mods/v3"), new XAttribute("version", "3.2"), new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"), new XAttribute(XNamespace.Xmlns + "xlink", "http://www.w3.org/1999/xlink"), new XAttribute(xsi + "schemaLocation", "http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")); foreach (var wosRecord in wosRecords) { modsCollection.Add(WoSRecordWriter.ModsRecord(wosRecord, int.Parse(ConfigurationManager.AppSettings["MaxAuthorCount"]), ConfigurationManager.AppSettings["OnlyFirstLastAndLocalAuthors"] == "1")); } return(new XmlActionResult(modsCollection)); }
public ActionResult MatchResults() { ViewBag.Title = "Resultat av matchningen"; var wosRecords = (Dictionary <string, string>[])Session["WosRecords"]; var divaRecords = (Dictionary <string, string>[])Session["DivaRecords"]; Tuple <Dictionary <string, string>, Dictionary <string, string>, int>[] matchResult = MatchWoSToDiva.StartMatching(divaRecords, wosRecords).ToArray(); string[] matchedWosIds = matchResult.Select(a => a.Item2["UT"]).ToArray(); string[] matchedDivaIds = matchResult.Select(a => a.Item1["PID"]).ToArray(); Session["MatchResult"] = matchResult; //Get List of unmatched WoS records ViewBag.UnmatchedWos = wosRecords.Where(a => !matchedWosIds.Contains(a["UT"])); //Get List of unmatched DiVA records ViewBag.UnmatchedDivas = divaRecords.Where(a => !matchedDivaIds.Contains(a["PID"])); ViewBag.MatchResult = matchResult; var viewModel = new MatchResultViewModel { MatchLevel = -1 }; return(View(viewModel)); }
public ActionResult Index(HttpPostedFileBase WoSFile) { Session["WosRecords"] = null; using (var sr = new StreamReader(WoSFile.InputStream)) { Dictionary <string, string>[] wosRecords = MatchWoSToDiva.PrepareWosFile(sr).ToArray(); Session["WosRecords"] = wosRecords; } return(RedirectToAction("PostDiVAFile")); }
public ActionResult PostDiVAFile(HttpPostedFileBase divaFile) { ViewBag.YearFrom = DateTime.Now.Year - 1; ViewBag.YearTo = DateTime.Now.Year; Session["DivaRecords"] = null; using (var fileStream = divaFile.InputStream) { Dictionary <string, string>[] divaRecords = MatchWoSToDiva.PrepareDivaFile(new StreamReader(fileStream), true).ToArray(); Session["DivaRecords"] = divaRecords; } return(RedirectToAction("MatchingSplash")); }
public ActionResult Index(string SelectedFileName) { if (string.IsNullOrEmpty(SelectedFileName)) { var dir = Directory.EnumerateFiles(Server.MapPath(path)).Select(a => a.Substring(a.LastIndexOf('\\') + 1)); ViewBag.Files = dir; ViewBag.Title = "Ladda upp poster från WoS"; return(View()); } else { var filePath = Server.MapPath(path + "\\" + SelectedFileName); var f = new FileInfo(filePath); Session["WosRecords"] = null; using (var sr = new StreamReader(filePath)) { Dictionary <string, string>[] wosRecords = MatchWoSToDiva.PrepareWosFile(sr).ToArray(); Session["WosRecords"] = wosRecords; } return(RedirectToAction("PostDiVAFile")); } }