public void Import(IClinicsData data) { this.ImportTitles(data); this.ImportProcedures(data); this.ImportSpecialties(data); this.ImportSpecialists(data); this.ImportClinics(data); data.SaveChanges(); }
public void Import(IClinicsData data, string fileName) { string zipPath = fileName; string tempFolder = string.Format("{0}{1}", Directory.GetCurrentDirectory(), TempFolderName); string currentReportDate = string.Empty; ZipArchive archive = ZipFile.OpenRead(zipPath); using (archive) { foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.EndsWith("/")) { currentReportDate = entry.FullName.TrimEnd('/'); } else { if (!Directory.Exists(tempFolder)) { Directory.CreateDirectory(tempFolder); } entry.ExtractToFile(Path.Combine(tempFolder, TempFileName), true); DataTable excelData = this.ReadExcelData(string.Format("{0}{1}", tempFolder, TempFileName)); foreach (DataRow row in excelData.Rows) { var patientNumber = row["PatientNumber"].ToString(); if (patientNumber != string.Empty) { var patient = data .Patients.All() .Where(p => p.PatientNumber == patientNumber) .FirstOrDefault(); if (patient == null) { patient = this.CreateNewPatient(row); data.Patients.Add(patient); } Manipulation currentManipulation = this.CreateNewManipulation(data, currentReportDate, row, patient); patient.Manipulations.Add(currentManipulation); } } } } } data.SaveChanges(); }
public void Import(IClinicsData data, string fileName) { this.doc.Load(fileName); XmlNode rootNode = this.doc.DocumentElement; foreach (XmlNode node in rootNode.ChildNodes) { var name = this.GetValue(node, "name"); var price = decimal.Parse(this.GetValue(node, "price")); var information = this.GetValue(node, "information"); this.InportInMongo(name, price, information); this.ImportInSql(data, name, price, information); } data.SaveChanges(); }