public override void Export() { VufindXMLWriter vfWriter = new VufindXMLWriter("CERF");//Jewish Book House vfWriter.StartVufindXML(@"D:\VGBIL\" + Fund.ToLower() + ".xml"); //string[] JHB = File.ReadAllLines(@"D:\HOME\ВГБИЛ\jbh_source_pasted.txt"); HtmlDocument BooksDocument = new HtmlDocument(); BooksDocument.Load(@"d:\VGBIL\WATERBEAR\waterbear.htm"); //HtmlDocument ExemplarsDocument = new HtmlDocument(); //ExemplarsDocument.Load(@"d:\VGBIL\WATERBEAR\waterbear (exemplaires).htm"); //Linq var books = BooksDocument.DocumentNode.Descendants("tr"); idbook = 0; foreach (HtmlNode book in books) { if (idbook > 0) { VufindDoc doc = this.CreateVufindDocument(book); vfWriter.AppendVufindDoc(doc); //OnRecordExported VuFindConverterEventArgs args = new VuFindConverterEventArgs(); args.RecordId = doc.id; OnRecordExported(args); } idbook++; } vfWriter.FinishWriting(); }
private void AddHierarchyFields(int ParentPIN, int CurrentPIN, VufindDoc vfDoc) { DataTable table = BJLoader.GetBJRecord(ParentPIN); int TopHierarchyId = GetTopId(ParentPIN); //AddField("hierarchy_top_id", this.Fund + "_" + TopHierarchyId); vfDoc.hierarchy_top_id.ValueList.Add(this.Fund + "_" + TopHierarchyId); string hierarchy_top_title = BJLoader.GetTitle(TopHierarchyId); vfDoc.hierarchy_top_title.ValueList.Add(hierarchy_top_title); vfDoc.hierarchy_parent_id.ValueList.Add(this.Fund + "_" + ParentPIN); string hierarchy_parent_title = BJLoader.GetTitle(ParentPIN); vfDoc.hierarchy_parent_title.ValueList.Add(hierarchy_parent_title); if (vfDoc.is_hierarchy_id.ValueList.Count == 0) { vfDoc.is_hierarchy_id.ValueList.Add(this.Fund + "_" + CurrentPIN); } string is_hierarchy_title = BJLoader.GetTitle(CurrentPIN); if (is_hierarchy_title != null) { if (vfDoc.is_hierarchy_title.ValueList.Count == 0) { vfDoc.is_hierarchy_title.ValueList.Add(is_hierarchy_title); } } }
private void StartExportFrom(int previous) { int step = 1; int MaxIDMAIN = BJLoader.GetMaxIDMAIN(); VufindDoc vfDoc = new VufindDoc(); for (int i = previous; i < MaxIDMAIN; i += step) { _lastID = i; //DataTable record = BJLoader.GetBJRecord(_lastID); //if (record.Rows.Count == 0) continue; //если сводный уровень, то пропускаем пока. тут ещё может пин не существовать try { vfDoc = CreateVufindDocument(i); if (vfDoc == null) { continue; //одна из причин - все экземпляры списаны и нет электронного экземпляра } } catch (Exception ex) { errors.Add(this.Fund + "_" + i); continue; } writer.AppendVufindDoc(vfDoc); VuFindConverterEventArgs args = new VuFindConverterEventArgs(); args.RecordId = this.Fund + "_" + i; OnRecordExported(args); } writer.FinishWriting(); File.WriteAllLines(@"e:\import\importErrors\" + this.Fund + "Errors.txt", errors.ToArray()); }
public string GetView(BJBookInfo book) { BJVuFindConverter converter = new BJVuFindConverter(book.Fund); VufindDoc vfDoc = converter.CreateVufindDocument(book.ID); string json = JsonConvert.SerializeObject(book, Formatting.Indented); return(json); }
public override void Export() { /////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////// JBH ///////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// VufindXMLWriter vfWriter = new VufindXMLWriter("JBH");//Jewish Book House vfWriter.StartVufindXML(@"D:\HOME\ВГБИЛ\" + Fund.ToLower() + ".xml"); string[] JHB = File.ReadAllLines(@"D:\HOME\ВГБИЛ\jbh_source_pasted.txt"); List <VufindDoc> docs = new List <VufindDoc>(); foreach (string line in JHB) { VufindDoc doc = new VufindDoc(); if (doc.id != line)//если встретили новый ID { docs.Add(doc); doc = new VufindDoc(); } doc.id = "JHB_000001"; doc.id = "JHB_" + line; string FieldCode = line.Substring(0, line.IndexOf(":") - 1); string FieldValue = line.Substring(line.IndexOf(":")); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); JsonWriter writer = new JsonTextWriter(sw); switch (FieldCode) { case "700": doc.author.Add(FieldValue); break; case "200": doc.title.Add(FieldValue); break; case "901": break; } vfWriter.AppendVufindDoc(doc); //OnRecordExported VuFindConverterEventArgs args = new VuFindConverterEventArgs(); args.RecordId = "JBH_" + doc.id; OnRecordExported(args); docs.Add(doc); } vfWriter.FinishWriting(); //добавили новый комментарий. }
public override void ExportSingleRecord(int idmain) { VufindXMLWriter writer = new VufindXMLWriter(this.Fund); VufindDoc vfDoc = new VufindDoc(); //DataTable record = BJLoader.GetBJRecord(idmain); vfDoc = CreateVufindDocument(idmain); if (vfDoc == null) { MessageBox.Show("Запись не имеет экземпляров."); return; } writer.WriteSingleRecord(vfDoc); MessageBox.Show("Завершено"); }
public override void Export() { ///////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////Pearson//////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// VufindXMLWriter vfWriter = new VufindXMLWriter("pearson"); vfWriter.StartVufindXML(@"F:\import\" + Fund.ToLower() + ".xml"); string Pearson = File.ReadAllText(@"f:/pearson_source.json"); JArray desPearson = (JArray)JsonConvert.DeserializeObject(Pearson); string tmp = desPearson.First["licensePackage"].ToString(); tmp = desPearson.First["catalog"]["options"]["Supported platforms"].ToString(); int cnt = 1; VufindDoc vfDoc = new VufindDoc(); StringBuilder AllFields = new StringBuilder(); foreach (JToken token in desPearson) { vfDoc = new VufindDoc(); vfDoc.title.Add(token["catalog"]["title"]["default"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.title); vfDoc.title_short.Add(token["catalog"]["title"]["default"].ToString()); vfDoc.title_sort.Add(token["catalog"]["title"]["default"].ToString()); if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Authors"] != null) { vfDoc.author.Add(token["catalog"]["options"]["Authors"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.author); vfDoc.author_sort.Add(token["catalog"]["options"]["Authors"].ToString()); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Country of publication"] != null) { vfDoc.Country.Add(token["catalog"]["options"]["Country of publication"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.Country); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Publisher"] != null) { vfDoc.publisher.Add(token["catalog"]["options"]["Publisher"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.publisher); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Publishing date"] != null) { vfDoc.publishDate.Add(token["catalog"]["options"]["Publishing date"].ToString().Split('.')[2]); AllFields.AppendFormat(" {0}", vfDoc.publishDate); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["ISBN"] != null) { vfDoc.isbn.Add(token["catalog"]["options"]["ISBN"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.isbn); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Number of pages"] != null) { vfDoc.Volume.Add(token["catalog"]["options"]["Number of pages"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.Volume); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Desk"] != null) { vfDoc.Annotation.Add(token["catalog"]["options"]["Desk"].ToString() + " ; " + token["catalog"]["description"]["default"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.Annotation); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Subject"] != null) { vfDoc.genre.Add(token["catalog"]["options"]["Subject"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.genre); vfDoc.genre_facet.Add(token["catalog"]["options"]["Subject"].ToString()); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Catalogue section"] != null) { vfDoc.topic.Add(token["catalog"]["options"]["Catalogue section"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.topic); vfDoc.topic_facet.Add(token["catalog"]["options"]["Catalogue section"].ToString()); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Collection"] != null) { vfDoc.collection.Add(token["catalog"]["options"]["Collection"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.collection); } } if (token["catalog"]["options"] != null) { if (token["catalog"]["options"]["Language"] != null) { vfDoc.language.Add(token["catalog"]["options"]["Language"].ToString()); AllFields.AppendFormat(" {0}", vfDoc.language); } } vfDoc.allfields = AllFields.ToString(); //описание экземпляра Пирсон StringBuilder sb = new StringBuilder(); StringWriter strwriter = new StringWriter(sb); JsonWriter writer = new JsonTextWriter(strwriter); writer.WriteStartObject(); writer.WritePropertyName("1"); writer.WriteStartObject(); writer.WritePropertyName("exemplar_carrier"); //writer.WriteValue("Электронная книга"); writer.WriteValue("3012"); writer.WritePropertyName("exemplar_access"); writer.WriteValue("1008"); writer.WritePropertyName("exemplar_access_group"); writer.WriteValue(KeyValueMapping.AccessCodeToGroup[1008]); //writer.WriteValue("Для прочтения онлайн необходимо перейти по ссылке"); writer.WritePropertyName("exemplar_hyperlink"); writer.WriteValue("https://ebooks.libfl.ru/catalog/knigi/" + token["id"].ToString() + @"/"); writer.WritePropertyName("exemplar_copyright"); writer.WriteValue("Да"); writer.WritePropertyName("exemplar_id"); writer.WriteValue("ebook"); writer.WritePropertyName("exemplar_location"); writer.WriteValue("2042"); writer.WriteEndObject(); writer.WriteEndObject(); vfDoc.MethodOfAccess.Add("4002"); vfDoc.Location.Add("2042"); vfDoc.ExemplarsJSON = sb.ToString(); vfDoc.id = "Pearson_" + token["id"].ToString(); vfDoc.HyperLink.Add("https://ebooks.libfl.ru/catalog/knigi/" + token["id"].ToString() + @"/"); vfDoc.fund = "5008"; vfDoc.Level = "Монография"; vfDoc.format.Add("3012"); vfWriter.AppendVufindDoc(vfDoc); //OnRecordExported cnt++; VuFindConverterEventArgs args = new VuFindConverterEventArgs(); args.RecordId = "Pearson_" + token["id"].ToString(); OnRecordExported(args); } vfWriter.FinishWriting(); }
public override VufindDoc CreateVufindDocument(object Record) { HtmlNode row = (HtmlNode)Record; string Imagette, Imag, Titre, Titre_s, Auteur, Editeur, Collection, Annee; var td_elements = row.SelectNodes("td"); Imag = td_elements[0].InnerHtml.ToString(); //Imagette = td_elements[0].InnerText; Titre = td_elements[1].InnerText.Trim(' '); Auteur = td_elements[2].InnerText; Editeur = td_elements[3].InnerText; Collection = td_elements[4].InnerText; Annee = td_elements[5].InnerText; //' ', '*', '.', ';' , ':', '-', '"' char[] arr = Titre.ToCharArray(); arr = Array.FindAll <char>(arr, c => char.IsLetterOrDigit(c)); Titre_s = new string(arr); VufindDoc result = new VufindDoc(); result.id = "CERF_" + idbook.ToString(); result.fund = this.Fund; result.allfields = Titre + " " + Auteur + " " + Annee + " " + Editeur; result.title.Add(Titre); result.title_short.Add(Titre); result.title_sort.Add(Titre_s); // артикли и ??? result.author.Add(Auteur); result.author_sort.Add(Auteur.Replace("L' ", "").Replace("D' ", "").Replace(" d'", "").Replace(" l'", "").Replace(" ", "")); result.publishDate.Add(Annee); result.publisher.Add(Editeur); result.language.Add("Французский"); if (Imag.IndexOf("img src=") > 0) { Imag = Imag.Substring(10).Remove(Imag.Length - 12); result.HyperLink.Add(Imag); } ////////////////////////////////////////////////////////////////// //описание экземпляра Litres StringBuilder sb = new StringBuilder(); StringWriter strwriter = new StringWriter(sb); JsonWriter writer = new JsonTextWriter(strwriter); string exTitre, barcode, description, cote, doctype, library, section, place, status, messages, liability; int k = 1; HtmlDocument ExemplarsDocument = new HtmlDocument(); ExemplarsDocument.Load(@"d:\VGBIL\WATERBEAR\waterbear (exemplaires).htm"); var exemplars = ExemplarsDocument.DocumentNode.Descendants("tr"); foreach (HtmlNode exemplar in exemplars) { var td_exemplar = exemplar.SelectNodes("td"); exTitre = td_exemplar[1].InnerText.Trim(' '); if (exTitre.StartsWith(Titre) == true) { writer.WriteStartObject(); writer.WritePropertyName(k.ToString()); //"1" writer.WriteStartObject(); writer.WritePropertyName("exemplar_carrier"); //writer.WriteValue("Электронная книга"); writer.WriteValue("3001"); writer.WritePropertyName("exemplar_access"); //writer.WriteValue("Для прочтения онлайн необходимо перейти по ссылке"); writer.WriteValue("1007"); writer.WritePropertyName("exemplar_access_group"); writer.WriteValue(KeyValueMapping.AccessCodeToGroup[1007]); barcode = td_exemplar[0].InnerText.Trim(' '); // code barre writer.WritePropertyName("exemplar_id"); writer.WriteValue(barcode); //вообще это iddata, но тут любой можно,поскольку всегда свободно "1" writer.WritePropertyName("exemplar_location"); writer.WriteValue("2046"); //description = td_exemplar[1].InnerText.Trim(' '); // notice cote = td_exemplar[2].InnerHtml.ToString(); //cote: exemplar_placing_cipher if (cote.IndexOf("value=\"") > 0) // { cote = cote.Substring(cote.IndexOf("value=\"") + 7); cote = cote.Remove(cote.IndexOf("\">")); writer.WritePropertyName("exemplar_placing_cipher"); writer.WriteValue(cote); } doctype = td_exemplar[3].InnerHtml.ToString(); // type doc: CD, DVD,Livre, Revue if (doctype.IndexOf("selected=\"selected\">") > 0) // exemplar_carrier { doctype = doctype.Substring(doctype.IndexOf("selected=\"selected\">") + 20); doctype = doctype.Remove(doctype.IndexOf("</option>")); if (doctype == "Livre") { doctype = "бумага"; } writer.WritePropertyName("exemplar_carrier"); writer.WriteValue(doctype); } library = td_exemplar[4].InnerHtml.ToString(); // bibliotheque: if (library.IndexOf("selected=\"selected\">") > 0) { library = library.Substring(library.IndexOf("selected=\"selected\">") + 20); library = library.Remove(library.IndexOf("</option>")); } section = td_exemplar[5].InnerHtml.ToString(); // section: Adulte, Jeunesse if (section.IndexOf("selected=\"selected\">") > 0) { section = section.Substring(section.IndexOf("selected=\"selected\">") + 20); section = section.Remove(section.IndexOf("</option>")); } place = td_exemplar[6].InnerHtml.ToString(); // emplacement: exemplar_location if (place.IndexOf("selected=\"selected\">") > 0) { place = place.Substring(place.IndexOf("selected=\"selected\">") + 20); place = place.Remove(place.IndexOf("</option>")); } status = td_exemplar[7].InnerHtml.ToString(); if (status.IndexOf("selected=\"selected\">") > 0) { status = status.Substring(status.IndexOf("selected=\"selected\">") + 20); status = status.Remove(status.IndexOf("</option>")); } messages = td_exemplar[8].InnerText.Trim(' '); // message liste liability = td_exemplar[9].InnerText.Trim(' '); // prêt en cours //Exemplar; exemplar_rack_location //Exemplar; exemplar_placing_cipher //Exemplar; exemplar_inventory_number writer.WriteEndObject(); writer.WriteEndObject(); k++; } } result.MethodOfAccess.Add("4002"); result.Location.Add("2046"); result.ExemplarsJSON = sb.ToString(); result.fund = "5010"; result.Level = "Монография"; //result.ExemplarsJSON = ""; return(result); }
public override VufindDoc CreateVufindDocument(object Record)//здесь принимаем int { int ID_BJ = (int)Record; BJBookLoader loader = new Books.BJBooks.Loaders.BJBookLoader(this.Fund); DataTable record = loader.GetBJRecord(ID_BJ); if (record.Rows.Count == 0) { return(null); } int currentIDMAIN = (int)record.Rows[0]["IDMAIN"]; if (!SpecialFilter(currentIDMAIN, record)) { return(null); } string level = record.Rows[0]["Level"].ToString(); string level_id = record.Rows[0]["level_id"].ToString(); int lev_id = int.Parse(level_id); if (lev_id < 0) { return(null); } StringBuilder allFields = new StringBuilder(); AuthoritativeFile AF_all = new AuthoritativeFile(); bool wasTitle = false; //встречается ошибка: два заглавия в одном пине bool wasAuthor = false; //был ли автор. если был, то сортировочное поле уже заполнено string description = ""; //все 3хх поля string Annotation = ""; int CarrierCode; VufindDoc result = new VufindDoc(); string add = string.Empty; #region field analyse //BJBookInfo book = new BJBookInfo(); foreach (DataRow r in record.Rows) { allFields.AppendFormat(" {0}", r["PLAIN"].ToString()); switch (r["code"].ToString()) { //=======================================================================Родные поля вуфайнд======================= case "200$a": if (wasTitle) { break; } result.title.Add(r["PLAIN"].ToString()); result.title_short.Add(r["PLAIN"].ToString()); result.title_sort.Add(r["SORT"].ToString()); wasTitle = true; break; case "700$a": result.author.Add(r["PLAIN"].ToString()); if (!wasAuthor) { //AddField("author_sort", r["SORT"].ToString()); result.author_sort.Add(r["SORT"].ToString()); } wasAuthor = true; //забрать все варианты написания автора из авторитетного файла и вставить в скрытое, но поисковое поле break; case "701$a": result.author2.Add(r["PLAIN"].ToString()); break; case "710$a": result.author_corporate.Add(r["PLAIN"].ToString()); break; case "710$4": result.author_corporate_role.Add(r["PLAIN"].ToString()); break; case "700$4": result.author_role.Add(r["PLAIN"].ToString()); break; case "701$4": result.author2_role.Add(r["PLAIN"].ToString()); break; case "921$a": CarrierCode = KeyValueMapping.CarrierNameToCode.GetValueOrDefault(r["PLAIN"].ToString(), 3001); result.format.Add(CarrierCode.ToString()); break; case "922$e": result.genre.Add(r["PLAIN"].ToString()); result.genre_facet.Add(r["PLAIN"].ToString()); break; case "10$a": add = BJLoader.Clarify_10a((int)r["IDDATA"], r["PLAIN"].ToString()); result.isbn.Add(add); break; case "11$a": result.issn.Add(r["PLAIN"].ToString()); break; case "101$a": add = BJLoader.Clarify_101a((int)r["IDINLIST"], r["PLAIN"].ToString()); result.language.Add(add); break; case "2100$d": result.publishDate.Add(r["PLAIN"].ToString()); break; case "210$c": result.publisher.Add(r["PLAIN"].ToString()); break; case "517$a": add = BJLoader.Clarify_517a((int)r["IDDATA"], r["PLAIN"].ToString()); result.title_alt.Add(add); break; //=======================================================================добавленные поля в Вуфайнд======================= case "210$a": result.PlaceOfPublication.Add(r["PLAIN"].ToString()); break; case "200$6": result.Title_another_chart.Add(r["PLAIN"].ToString()); break; case "200$b": result.Title_same_author.Add(r["PLAIN"].ToString()); break; case "200$d": result.Parallel_title.Add(r["PLAIN"].ToString()); break; case "200$e": result.Info_pertaining_title.Add(r["PLAIN"].ToString()); break; case "200$f": result.Responsibility_statement.Add(r["PLAIN"].ToString()); break; case "200$h": result.Part_number.Add(r["PLAIN"].ToString()); break; case "200$i": result.Part_title.Add(r["PLAIN"].ToString()); break; case "200$z": result.Language_title_alt.Add(r["PLAIN"].ToString()); break; case "500$a": result.Title_unified.Add(r["PLAIN"].ToString()); break; case "500$3": //$3 is deprecated!!! AF_all = BJLoader.GetAFAll((int)r["AFLINKID"], "AFHEADERVAR"); result.Title_unified.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "517$e": result.Info_title_alt.Add(r["PLAIN"].ToString()); break; case "517$z": result.Language_title_alt.Add(r["PLAIN"].ToString()); break; case "700$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFNAMESVAR"); foreach (string av in AF_all.AFValues) { result.author_variant.Add(av); } allFields.AppendFormat(" {0}", AF_all); break; case "701$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFNAMESVAR"); result.Another_author_AF_all.Add(AF_all.ToString()); //хранить но не отображать allFields.AppendFormat(" {0}", AF_all); break; case "501$a": result.Another_title.Add(r["PLAIN"].ToString()); break; case "501$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFHEADERVAR"); result.Another_title_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "503$a": result.Unified_Caption.Add(r["PLAIN"].ToString()); break; case "503$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFHEADERVAR"); result.Unified_Caption_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "700$6": result.Author_another_chart.Add(r["PLAIN"].ToString()); break; case "702$a": result.Editor.Add(r["PLAIN"].ToString()); break; case "702$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFNAMESVAR"); result.Editor_AF_all.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "702$4": result.Editor_role.Add(r["PLAIN"].ToString()); break; case "710$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFORGSVAR"); result.Collective_author_all.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "710$9": result.Organization_nature.Add(r["PLAIN"].ToString()); break; case "11$9": result.Printing.Add(r["PLAIN"].ToString()); break; case "205$a": string PublicationInfo = BJLoader.Clarify_205a((int)r["IDDATA"], r["PLAIN"].ToString()); result.Publication_info.Add(PublicationInfo); break; case "921$b": result.EditionType.Add(r["PLAIN"].ToString()); break; case "102$a": result.Country.Add(r["PLAIN"].ToString()); break; case "210$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFORGSVAR"); result.PlaceOfPublication_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "2110$g": result.PrintingHouse.Add(r["PLAIN"].ToString()); break; case "2110$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFORGSVAR"); result.PrintingHouse_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "2111$e": result.GeoNamePlaceOfPublication.Add(r["PLAIN"].ToString()); break; case "2111$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFGEOVAR"); result.GeoNamePlaceOfPublication_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "10$z": result.IncorrectISBN.Add(r["PLAIN"].ToString()); break; case "11$z": result.IncorrectISSN.Add(r["PLAIN"].ToString()); break; case "11$y": result.CanceledISSN.Add(r["PLAIN"].ToString()); break; case "101$b": result.IntermediateTranslateLanguage.Add(r["PLAIN"].ToString()); break; case "101$d": result.SummaryLanguage.Add(r["PLAIN"].ToString()); break; case "101$e": result.TableOfContentsLanguage.Add(r["PLAIN"].ToString()); break; case "101$f": result.TitlePageLanguage.Add(r["PLAIN"].ToString()); break; case "101$g": result.BasicTitleLanguage.Add(r["PLAIN"].ToString()); break; case "101$i": result.AccompayingMaterialLanguage.Add(r["PLAIN"].ToString()); break; case "215$a": result.Volume.Add(r["PLAIN"].ToString()); break; case "215$b": result.Illustrations.Add(r["PLAIN"].ToString()); break; case "215$c": result.Dimensions.Add(r["PLAIN"].ToString()); break; case "215$d": result.AccompayingMaterial.Add(r["PLAIN"].ToString()); break; case "225$a": if (r["PLAIN"].ToString() == "") { break; } if (r["PLAIN"].ToString() == "-1") { break; } //AddHierarchyFields(Convert.ToInt32(r["PLAIN"]), Convert.ToInt32(r["IDMAIN"]), result); break; case "225$h": result.NumberInSeries.Add(r["PLAIN"].ToString()); break; case "225$v": result.NumberInSubseries.Add(r["PLAIN"].ToString()); break; case "300$a": case "301$a": case "316$a": case "320$a": case "326$a": case "336$a": case "337$a": description += r["PLAIN"].ToString() + " ; "; break; case "327$a": case "330$a": Annotation += r["PLAIN"].ToString() + " ; "; break; case "830$a": result.CatalogerNote.Add(r["PLAIN"].ToString()); break; case "831$a": result.DirectoryNote.Add(r["PLAIN"].ToString()); break; case "924$a": result.AdditionalBibRecord.Add(r["PLAIN"].ToString()); break; case "940$a": result.HyperLink.Add(r["PLAIN"].ToString()); break; case "606$a": //"""""" • """""" add = Clarify606a(r["SORT"].ToString()); result.topic.Add(add); result.topic_facet.Add(add); break; case "3000$a": result.OwnerPerson.Add(r["PLAIN"].ToString()); break; case "3000$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFNAMESVAR"); result.OwnerPerson_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "3001$a": result.OwnerOrganization.Add(r["PLAIN"].ToString()); break; case "3001$3": AF_all = GetAFAll((int)r["AFLINKID"], "AFORGSVAR"); result.OwnerOrganization_AF_All.Add(AF_all.ToString()); allFields.AppendFormat(" {0}", AF_all); break; case "3002$a": result.Ownership.Add(r["PLAIN"].ToString()); break; case "3003$a": result.OwnerExemplar.Add(r["PLAIN"].ToString()); break; case "3200$a": result.IllustrationMaterial.Add(r["PLAIN"].ToString()); break; } } #endregion result.id = this.Fund + "_" + currentIDMAIN; string rusFund = GetFundId(this.Fund); result.fund = rusFund; result.allfields = allFields.ToString(); result.Level = level; result.Level_id = level_id; result.Annotation.Add(Annotation); if (description != "") { result.description.Add(description); } if (int.Parse(result.Level_id) < 0) { return(result); } AddExemplarFields(currentIDMAIN, result, this.Fund); if ((result.Exemplars.Count == 0))//все экземпляры отсеялись сами собой. { return(null); } return(result); }
private void AddExemplarFields(int idmain, VufindDoc result, string fund) { DataTable table = BJLoader.GetIdDataOfAllExemplars(idmain); if (table.Rows.Count == 0) { if (!BJLoader.IsElectronicCopyExists(idmain)) { return;//все списано и нет электронных копий. } } int IDMAIN = idmain; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); JsonWriter writer = new JsonTextWriter(sw); writer.WriteStartObject(); DataTable exemplar; int cnt = 1; string CarrierCode = ""; List <DateTime> ExemplarsCreatedDateList = new List <DateTime>(); foreach (DataRow iddata in table.Rows) { exemplar = BJLoader.GetExemplar((int)iddata["IDDATA"]); BJExemplarInfo bjExemplar = BJExemplarInfo.GetExemplarByIdData((int)iddata["IDDATA"], this.Fund); if (bjExemplar.ExemplarAccess.Access == 1020)//экстремистская литература. не выгружаем такое. { continue; } writer.WritePropertyName(cnt++.ToString()); writer.WriteStartObject(); //ExemplarInfo bjExemplar = new ExemplarInfo((int)iddata["IDDATA"]); BJExemplarInfo Convolute = null; #region FieldAnalyse foreach (DataRow r in exemplar.Rows) { string code = r["MNFIELD"].ToString() + r["MSFIELD"].ToString(); switch (code) { case "899$a": string plain = r["PLAIN"].ToString(); string check = r["NAME"].ToString(); string UL = KeyValueMapping.UnifiedLocation.GetValueOrDefault(r["NAME"].ToString(), "отсутствует в словаре"); int LocationCode = KeyValueMapping.UnifiedLocationCode.GetValueOrDefault(UL, 2999); writer.WritePropertyName("exemplar_location"); writer.WriteValue(LocationCode); result.Location.Add(LocationCode.ToString()); break; case "482$a": writer.WritePropertyName("exemplar_interlaced_to"); writer.WriteValue(r["PLAIN"].ToString()); writer.WritePropertyName("exemplar_convolute"); Convolute = BJExemplarInfo.GetExemplarByInventoryNumber(r["PLAIN"].ToString(), this.Fund); if (Convolute == null) { writer.WriteValue("Ошибка заполнения библиографического описания конволюта"); errors.Add(this.Fund + "_" + idmain); } else { writer.WriteValue(this.Fund + "_" + Convolute.IDMAIN); } break; case "899$b": //тут надо оставить только коллекции string fnd = r["PLAIN"].ToString(); writer.WritePropertyName("exemplar_collection"); writer.WriteValue(r["PLAIN"].ToString()); break; case "899$c": writer.WritePropertyName("exemplar_rack_location"); writer.WriteValue(r["PLAIN"].ToString()); break; case "899$d": writer.WritePropertyName("exemplar_direction_temporary_storage"); writer.WriteValue(r["PLAIN"].ToString()); break; case "899$j": result.PlacingCipher.Add(r["PLAIN"].ToString()); writer.WritePropertyName("exemplar_placing_cipher"); writer.WriteValue(r["PLAIN"].ToString()); break; case "899$p": writer.WritePropertyName("exemplar_inventory_number"); writer.WriteValue(r["PLAIN"].ToString()); ExemplarsCreatedDateList.Add((DateTime)r["Created"]); break; case "899$w": writer.WritePropertyName("exemplar_barcode"); writer.WriteValue(r["PLAIN"].ToString()); ExemplarsCreatedDateList.Add((DateTime)r["Created"]); break; case "899$x": writer.WritePropertyName("exemplar_inv_note"); writer.WriteValue(r["PLAIN"].ToString()); break; case "921$a": writer.WritePropertyName("exemplar_carrier"); CarrierCode = KeyValueMapping.CarrierNameToCode.GetValueOrDefault(r["PLAIN"].ToString(), 3001).ToString(); writer.WriteValue(CarrierCode); break; case "921$c": writer.WritePropertyName("exemplar_class_edition"); writer.WriteValue(r["PLAIN"].ToString()); break; case "921$d": break; //case "922$b": //Exemplar += "Трофей\\Принадлежность к:" + r["PLAIN"].ToString() + "#"; //writer.WritePropertyName("exemplar_trophy"); // writer.WriteValue(r["PLAIN"].ToString()); // break; case "3300$a": writer.WritePropertyName("exemplar_binding_kind"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$b": writer.WritePropertyName("exemplar_binding_age"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$c": writer.WritePropertyName("exemplar_binding_type"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$d": writer.WritePropertyName("exemplar_cover_material"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$e": writer.WritePropertyName("exemplar_material_on_cover"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$f": writer.WritePropertyName("exemplar_spine_material"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$g": writer.WritePropertyName("exemplar_bandages"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$h": writer.WritePropertyName("exemplar_stamping_on_cover"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$i": writer.WritePropertyName("exemplar_embossing_on_spine"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$j": writer.WritePropertyName("exemplar_fittings"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$k": writer.WritePropertyName("exemplar_bugs"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$l": writer.WritePropertyName("exemplar_forth"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$m": writer.WritePropertyName("exemplar_cutoff"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$n": writer.WritePropertyName("exemplar_condition"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$o": writer.WritePropertyName("exemplar_case"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$p": writer.WritePropertyName("exemplar_embossing_on_edge"); writer.WriteValue(r["PLAIN"].ToString()); break; case "3300$r": writer.WritePropertyName("exemplar_binding_note"); writer.WriteValue(r["PLAIN"].ToString()); break; } } #endregion //Exemplar += "exemplar_id:" + ds.Tables["t"].Rows[0]["IDDATA"].ToString() + "#"; writer.WritePropertyName("exemplar_id"); writer.WriteValue(iddata["IDDATA"].ToString()); result.MethodOfAccess.Add(bjExemplar.ExemplarAccess.MethodOfAccess.ToString()); writer.WritePropertyName("exemplar_access"); writer.WriteValue(bjExemplar.ExemplarAccess.Access); writer.WritePropertyName("exemplar_access_group"); writer.WriteValue(KeyValueMapping.AccessCodeToGroup[bjExemplar.ExemplarAccess.Access]); result.Exemplars.Add(bjExemplar); writer.WriteEndObject(); } //смотрим есть ли гиперссылка и запись в таблице электронных копий table = BJLoader.GetHyperLink(IDMAIN); //здесь надо сделать так, чтобы просто строка возвращалась DataTable hyperLinkTable = BJLoader.GetBookScanInfo(IDMAIN); //здесь надо сделать так, чтобы возвращалась структура сканИнфо if (table.Rows.Count == 1 && hyperLinkTable.Rows.Count == 1) //если есть - вставляем отдельным экземпляром. после электронной инвентаризации этот кусок можно будет убрать { //ExemplarInfo bjExemplar = new ExemplarInfo(-1); writer.WritePropertyName(cnt++.ToString()); writer.WriteStartObject(); writer.WritePropertyName("exemplar_electronic_copy"); writer.WriteValue("да"); writer.WritePropertyName("exemplar_hyperlink"); writer.WriteValue(table.Rows[0]["PLAIN"].ToString()); writer.WritePropertyName("exemplar_hyperlink_newviewer"); writer.WriteValue("/Bookreader/Viewer?bookID=" + result.id + "&view_mode=HQ"); result.HyperLinkNewViewer.Add("/Bookreader/Viewer?bookID=" + result.id + "&view_mode=HQ"); BJElectronicExemplarAvailabilityCodes ElectronincAccessLevel = BJLoader.GetElectronicExemplarAccessLevel(IDMAIN, 1);//IDProject = 1 это значит для библиотеки. 2 - для НЭБ writer.WritePropertyName("exemplar_copyright"); writer.WriteValue((ElectronincAccessLevel == BJElectronicExemplarAvailabilityCodes.vloginview) ? "есть" : "нет"); writer.WritePropertyName("exemplar_old_original"); writer.WriteValue(((hyperLinkTable.Rows[0]["OldBook"].ToString() == "1") ? "да" : "нет")); writer.WritePropertyName("exemplar_PDF_exists"); writer.WriteValue(((hyperLinkTable.Rows[0]["PDF"].ToString() == "1") ? "да" : "нет")); writer.WritePropertyName("exemplar_access"); writer.WriteValue( (ElectronincAccessLevel == BJElectronicExemplarAvailabilityCodes.vloginview) ? "1002" : "1001"); //"Для прочтения онлайн необходимо положить в корзину и заказать через личный кабинет"); //"Для прочтения онлайн необходимо перейти по ссылке" writer.WritePropertyName("exemplar_access_group"); writer.WriteValue((ElectronincAccessLevel == BJElectronicExemplarAvailabilityCodes.vloginview) ? KeyValueMapping.AccessCodeToGroup[1002] : KeyValueMapping.AccessCodeToGroup[1001]); writer.WritePropertyName("exemplar_carrier"); writer.WriteValue("3011"); result.format.Add("3011"); writer.WritePropertyName("exemplar_id"); writer.WriteValue("ebook");//для всех у кого есть электронная копия. АПИ когда это значение встретит, сразу вернёт "доступно" writer.WritePropertyName("exemplar_location"); writer.WriteValue("2030"); writer.WriteEndObject(); result.MethodOfAccess.Add("4002"); BJElectronicExemplarInfo ElExemplar = new BJElectronicExemplarInfo(idmain, fund);//фейковый электронный экземпляр. если его не добавить и если бумажных экземпляров нет, то будет 0 экземпляров и документ не попадёт в индекс, хотя етсь электронный экземпляр result.Exemplars.Add(ElExemplar); //определить структуру, в которую полностью запись ложится и здесь её проверять, чтобы правильно вычисляемые поля проставить. } writer.WriteEndObject(); writer.Flush(); writer.Close(); result.ExemplarsJSON = sb.ToString(); if (ExemplarsCreatedDateList.Count != 0) { result.NewArrivals = ExemplarsCreatedDateList.Min(); } }