// 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 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 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")); } }