/// <summary> /// læser dataset indhold og tilføjer dem /// til en class til dagbog data /// </summary> private fileInput GetFileValues(DataSet readxml, string filename) { fileInput fileData = new fileInput(); fileData.filename = filename; if (readxml.Tables.Contains("indhold")) { fileData.name = readxml.Tables["indhold"].Rows[0]["navn"].ToString(); fileData.cpr = readxml.Tables["indhold"].Rows[0]["cvr"].ToString(); } if (readxml.Tables.Contains("log")) { for (int i = 0; i < readxml.Tables["log"].Rows.Count; i++) { fileData.dato.Add(readxml.Tables["log"].Rows[i]["date"].ToString()); fileData.freeText.Add(readxml.Tables["log"].Rows[i]["text"].ToString()); } } if (readxml.Tables.Contains("files")) { for (int i = 0; i < readxml.Tables["files"].Rows.Count; i++) { Model.FileClass.Links newLink = new Links(); int fileIndex = int.Parse(readxml.Tables["files"].Rows[i]["index"].ToString()); newLink.name = readxml.Tables["files"].Rows[i]["name"].ToString(); newLink.path = readxml.Tables["files"].Rows[i]["path"].ToString(); newLink.isLink = bool.Parse(readxml.Tables["files"].Rows[i]["isLink"].ToString()); for (int a = fileData.files.Count; a <= fileIndex; a++) { fileData.files.Add(new List <Links>()); } fileData.files[fileIndex].Add(newLink); } } return(fileData); }
/// <summary> /// Gemmer dagbog data class til fil af xml type /// </summary> public void SaveFile() { if (!Directory.Exists("Saves")) { Directory.CreateDirectory("Saves"); } fileInput input = Inc.Settings.fileInput; string fileName = input.filename; if (fileName == "") { int fileCount = Directory.GetFiles("Saves").Count(); fileCount++; fileName = "saves-" + fileCount + ".xml"; input.filename = fileName; } DataSet writeXml = new DataSet(); #region createTemplate writeXml.Tables.Add("general"); writeXml.Tables["general"].Columns.Add("version"); writeXml.Tables.Add("indhold"); writeXml.Tables["indhold"].Columns.Add("navn"); writeXml.Tables["indhold"].Columns.Add("cvr"); writeXml.Tables.Add("log"); writeXml.Tables["log"].Columns.Add("date"); writeXml.Tables["log"].Columns.Add("text"); writeXml.Tables.Add("files"); writeXml.Tables["files"].Columns.Add("index"); writeXml.Tables["files"].Columns.Add("name"); writeXml.Tables["files"].Columns.Add("path"); writeXml.Tables["files"].Columns.Add("isLink"); #endregion #region AddValues writeXml.Tables["general"].Rows.Add(Inc.Settings._version.ToString()); writeXml.Tables["indhold"].Rows.Add( input.name, //navn input.cpr //cvr ); for (int i = 0; i < input.freeText.Count; i++) { writeXml.Tables["log"].Rows.Add( input.dato[i], //dato input.freeText[i] //fri tekst ); } for (int i = 0; i < input.files.Count; i++) { foreach (var item in input.files[i]) { writeXml.Tables["files"].Rows.Add( i.ToString(), //index item.name, //name item.path, //path item.isLink.ToString() //isLink ); } } #endregion FileStream XMLCreate = new FileStream("Saves/" + fileName, FileMode.Create, FileAccess.Write); writeXml.WriteXml(XMLCreate, XmlWriteMode.WriteSchema); XMLCreate.Close(); }
/// <summary> /// Gemmer lærepladsens data class til fil af xml type /// </summary> public void SaveFile() { if (!Directory.Exists("Saves")) { Directory.CreateDirectory("Saves"); } fileInput input = Inc.Settings.fileInput; string fileName = input.filename; if (fileName == "") { int fileCount = Directory.GetFiles("Saves").Count(); do { fileCount++; fileName = "saves-" + fileCount + ".xml"; } while (File.Exists(Directory.GetCurrentDirectory() + @"\Saves\" + fileName)); input.filename = fileName; } DataSet writeXml = new DataSet(); #region createTemplate writeXml.Tables.Add("general"); writeXml.Tables["general"].Columns.Add("version"); writeXml.Tables.Add("kontaktPerson"); writeXml.Tables["kontaktPerson"].Columns.Add("navn"); writeXml.Tables["kontaktPerson"].Columns.Add("mobil"); writeXml.Tables["kontaktPerson"].Columns.Add("email"); writeXml.Tables["kontaktPerson"].Columns.Add("stilling"); writeXml.Tables["kontaktPerson"].Columns.Add("print"); //1.5 writeXml.Tables.Add("kandidater"); writeXml.Tables["kandidater"].Columns.Add("navn"); writeXml.Tables.Add("uddannelsesaftale1"); writeXml.Tables["uddannelsesaftale1"].Columns.Add("checkbox"); writeXml.Tables.Add("uddannelsesaftale2"); writeXml.Tables["uddannelsesaftale2"].Columns.Add("checkbox"); writeXml.Tables.Add("FirmaØnsker"); //1.6 writeXml.Tables["FirmaØnsker"].Columns.Add("checkbox"); //1.6 writeXml.Tables.Add("sproglige"); writeXml.Tables["sproglige"].Columns.Add("value"); writeXml.Tables.Add("record"); writeXml.Tables["record"].Columns.Add("value"); writeXml.Tables.Add("files"); writeXml.Tables["files"].Columns.Add("name"); writeXml.Tables["files"].Columns.Add("path"); writeXml.Tables["files"].Columns.Add("link"); writeXml.Tables.Add("andet"); writeXml.Tables["andet"].Columns.Add("virsomhed"); writeXml.Tables["andet"].Columns.Add("CVR"); writeXml.Tables["andet"].Columns.Add("adresse"); //1.5 writeXml.Tables["andet"].Columns.Add("andetTjenestested"); //1.5 writeXml.Tables["andet"].Columns.Add("virsomhedProfil"); writeXml.Tables["andet"].Columns.Add("uddannelses_lager"); //1.5 writeXml.Tables["andet"].Columns.Add("uddannelses_chauffor"); //1.5 writeXml.Tables["andet"].Columns.Add("uddannelses_lufthavn"); //1.5 writeXml.Tables["andet"].Columns.Add("other"); writeXml.Tables["andet"].Columns.Add("antalAftaler"); writeXml.Tables["andet"].Columns.Add("datoFrist"); writeXml.Tables["andet"].Columns.Add("antalKandidater"); writeXml.Tables["andet"].Columns.Add("startDato"); writeXml.Tables["andet"].Columns.Add("jobBeskrivelse"); writeXml.Tables["andet"].Columns.Add("alder"); writeXml.Tables["andet"].Columns.Add("straffet"); writeXml.Tables["andet"].Columns.Add("koerekort"); writeXml.Tables["andet"].Columns.Add("fysiske"); writeXml.Tables["andet"].Columns.Add("matematiske"); writeXml.Tables["andet"].Columns.Add("bemaerkninger"); writeXml.Tables["andet"].Columns.Add("VUF"); writeXml.Tables["andet"].Columns.Add("aftaleHvem"); #endregion #region AddValues writeXml.Tables["general"].Rows.Add(Inc.Settings._version.ToString()); foreach (var item in input.contactPerson) { writeXml.Tables["kontaktPerson"].Rows.Add(item.name, item.mobile, item.mail, item.post, item.print ); } foreach (var item in input.candidates) { writeXml.Tables["kandidater"].Rows.Add(item); } foreach (var item in input.uddannelsesCheckBoxs) { writeXml.Tables["uddannelsesaftale1"].Rows.Add(item); } foreach (var item in input.agreementType) { writeXml.Tables["uddannelsesaftale2"].Rows.Add(item); } foreach (var item in input.files) { writeXml.Tables["files"].Rows.Add(item.name, item.path, item.link.ToString()); } foreach (var item in input.language) { writeXml.Tables["sproglige"].Rows.Add(item); } foreach (var item in input.record) { writeXml.Tables["record"].Rows.Add(item); } foreach (var item in input.firmReceive.Checkbox) { writeXml.Tables["FirmaØnsker"].Rows.Add(item); } writeXml.Tables["andet"].Rows.Add( input.name, //virsomhed input.cvr, //CVR input.adresse, //andresse input.tjenestested, //andetTjenestested input.profil, //virsomhedProfil input.uddannelses_lager, //uddannelses_lager input.uddannelses_chauffor, //uddannelses_chauffor input.uddannelses_lufthavn, //uddannelses_ludthavn input.firmReceive.andet, //other input.firmReceive.antalAftaler, //antalAftaler input.firmReceive.lastDay, //datoFrist input.firmReceive.antalPersoner, //antalKandidater input.firmReceive.StartDate, //startDato input.jobDescription, //jobBeskrivelse input.age, //alder input.driverLicense, //koerekort input.physical, //fysiske input.math, //matematiske input.other, //bemaerkninger input.VUF, //VUF input.signedBy //aftaleHvem ); #endregion FileStream XMLCreate = new FileStream("Saves/" + fileName, FileMode.Create, FileAccess.Write); writeXml.WriteXml(XMLCreate, XmlWriteMode.WriteSchema); XMLCreate.Close(); }
/// <summary> /// læser dataset indhold og tilføjer dem /// til en class til data /// </summary> private fileInput GetFilesValues(DataSet readxml, string filename) { fileInput fileData = new fileInput(); fileData.filename = filename; if (readxml.Tables.Contains("kontaktPerson")) { for (int i = 0; i < readxml.Tables["kontaktPerson"].Rows.Count; i++) { contactPerson contactPer = new contactPerson(); contactPer.name = readxml.Tables["kontaktPerson"].Rows[i]["navn"].ToString(); contactPer.mobile = readxml.Tables["kontaktPerson"].Rows[i]["mobil"].ToString(); contactPer.mail = readxml.Tables["kontaktPerson"].Rows[i]["email"].ToString(); contactPer.post = readxml.Tables["kontaktPerson"].Rows[i]["stilling"].ToString(); contactPer.print = bool.Parse(readxml.Tables["kontaktPerson"].Rows[i]["print"].ToString()); fileData.contactPerson.Add(contactPer); } } if (readxml.Tables.Contains("kandidater")) { for (int i = 0; i < readxml.Tables["kandidater"].Rows.Count; i++) { fileData.candidates.Add(readxml.Tables["kandidater"].Rows[i]["navn"].ToString()); } } if (readxml.Tables.Contains("uddannelsesaftale1")) { for (int i = 0; i < readxml.Tables["uddannelsesaftale1"].Rows.Count; i++) { fileData.uddannelsesCheckBoxs.Add(readxml.Tables["uddannelsesaftale1"].Rows[i]["checkbox"].ToString()); } } if (readxml.Tables.Contains("uddannelsesaftale2")) { for (int i = 0; i < readxml.Tables["uddannelsesaftale2"].Rows.Count; i++) { fileData.agreementType.Add(readxml.Tables["uddannelsesaftale2"].Rows[i]["checkbox"].ToString()); } } if (readxml.Tables.Contains("files")) { for (int i = 0; i < readxml.Tables["files"].Rows.Count; i++) { files newFile = new files(); newFile.name = readxml.Tables["files"].Rows[i]["name"].ToString(); newFile.path = readxml.Tables["files"].Rows[i]["path"].ToString(); newFile.link = bool.Parse(readxml.Tables["files"].Rows[i]["link"].ToString()); fileData.files.Add(newFile); } } if (readxml.Tables.Contains("sproglige")) { for (int i = 0; i < readxml.Tables["sproglige"].Rows.Count; i++) { string value = readxml.Tables["sproglige"].Rows[i]["value"].ToString(); fileData.language.Add(value); } } if (readxml.Tables.Contains("record")) { for (int i = 0; i < readxml.Tables["record"].Rows.Count; i++) { string value = readxml.Tables["record"].Rows[i]["value"].ToString(); fileData.record.Add(value); } } if (readxml.Tables.Contains("FirmaØnsker")) { for (int i = 0; i < readxml.Tables["FirmaØnsker"].Rows.Count; i++) { string value = readxml.Tables["FirmaØnsker"].Rows[i]["checkbox"].ToString(); fileData.firmReceive.Checkbox.Add(value); } } if (readxml.Tables.Contains("andet")) { fileData.name = readxml.Tables["andet"].Rows[0]["virsomhed"].ToString(); fileData.cvr = readxml.Tables["andet"].Rows[0]["CVR"].ToString(); fileData.adresse = readxml.Tables["andet"].Rows[0]["adresse"].ToString(); fileData.tjenestested = readxml.Tables["andet"].Rows[0]["andetTjenestested"].ToString(); fileData.profil = readxml.Tables["andet"].Rows[0]["virsomhedProfil"].ToString(); fileData.uddannelses_lager = readxml.Tables["andet"].Rows[0]["uddannelses_lager"].ToString(); fileData.uddannelses_chauffor = readxml.Tables["andet"].Rows[0]["uddannelses_chauffor"].ToString(); fileData.uddannelses_lufthavn = readxml.Tables["andet"].Rows[0]["uddannelses_lufthavn"].ToString(); fileData.firmReceive.andet = readxml.Tables["andet"].Rows[0]["other"].ToString(); fileData.firmReceive.antalAftaler = readxml.Tables["andet"].Rows[0]["antalAftaler"].ToString(); fileData.firmReceive.lastDay = readxml.Tables["andet"].Rows[0]["datoFrist"].ToString(); fileData.firmReceive.antalPersoner = readxml.Tables["andet"].Rows[0]["antalKandidater"].ToString(); fileData.firmReceive.StartDate = readxml.Tables["andet"].Rows[0]["startDato"].ToString(); fileData.jobDescription = readxml.Tables["andet"].Rows[0]["jobBeskrivelse"].ToString(); fileData.age = readxml.Tables["andet"].Rows[0]["alder"].ToString(); fileData.driverLicense = readxml.Tables["andet"].Rows[0]["koerekort"].ToString(); fileData.physical = readxml.Tables["andet"].Rows[0]["fysiske"].ToString(); fileData.math = readxml.Tables["andet"].Rows[0]["matematiske"].ToString(); fileData.other = readxml.Tables["andet"].Rows[0]["bemaerkninger"].ToString(); fileData.VUF = readxml.Tables["andet"].Rows[0]["VUF"].ToString(); fileData.signedBy = readxml.Tables["andet"].Rows[0]["aftaleHvem"].ToString(); } return(fileData); }