public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string elementNameStartsWith = "rec"; const string code_attr = "CODE"; const string name_attr = "NAME"; foreach (var element in doc.Root.Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } TipStacionara obj = objSpace.FindObject <TipStacionara>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", element.Attribute(code_attr).Value)); if (obj == null) { obj = objSpace.CreateObject <TipStacionara>(); obj.Code = int.Parse(element.Attribute(code_attr).Value); obj.Name = element.Attribute(name_attr).Value; } } }
public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string elementsContainer = "ROWDATA"; const string elementNameStartsWith = "ROW"; const string id_attr = "id"; const string name_attr = "name"; const string inner_code_attr = "code"; const string diagn_id_attr = "diagn_id"; const string vid_preparat_id_attr = "vid_preparat_id"; const string lpu_id_attr = "lpu_id"; const string date_attr = "date_vnes_inf"; const string operator_id_attr = "operator_id"; const string pocket_id_attr = "pocket_id"; const string sort_attr = "sort"; foreach (var element in doc.Root.Element(elementsContainer).Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } Lgota obj = objSpace.FindObject <Lgota>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Id=?", element.Attribute(id_attr).Value)); if (obj == null) { obj = objSpace.CreateObject <Lgota>(); obj.Id = int.Parse(element.Attribute(id_attr).Value); obj.Name = element.Attribute(name_attr).Value; var innerCode = element.Attribute(inner_code_attr); obj.Code = (innerCode == null || innerCode.Value == "null") ? "" : innerCode.Value; var diagnoseId = element.Attribute(diagn_id_attr); obj.DiagnoseId = (diagnoseId == null || diagnoseId.Value == "null") ? null : diagnoseId.Value; var vidPreparat = element.Attribute(vid_preparat_id_attr); obj.VidPreparatId = (vidPreparat == null || vidPreparat.Value == "null") ? null : (int?)int.Parse(vidPreparat.Value); var lpu = element.Attribute(lpu_id_attr); obj.CodeLPU = (lpu == null || lpu.Value == "null") ? null : (int?)int.Parse(lpu.Value); var dateBegin = element.Attribute(date_attr); obj.DateBegin = (dateBegin == null || dateBegin.Value == "null") ? null : (DateTime?)DateTime.Parse(dateBegin.Value); var operatorId = element.Attribute(operator_id_attr); obj.OperatorId = (operatorId == null || operatorId.Value == "null") ? null : (int?)int.Parse(operatorId.Value); var pocketId = element.Attribute(pocket_id_attr); obj.PocketId = (pocketId == null || pocketId.Value == "null") ? null : (int?)int.Parse(pocketId.Value); var sort = element.Attribute(sort_attr); obj.Sort = (sort == null || sort.Value == "null") ? null : sort.Value; } } }
public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string elementsContainer = "ROWDATA"; const string elementNameStartsWith = "ROW"; const string code_attr = "uchactok_id"; const string name_attr = "uchactok"; const string doctor_full_id_attr = "full_doctor_id"; const string doctor_id_attr = "doctor_id"; const string doctor_fio_attr = "fio"; const string otdel_id_attr = "zena_oms"; const string otdel_name_attr = "otdel_id"; foreach (var element in doc.Root.Element(elementsContainer).Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } Uchastok obj = objSpace.FindObject <Uchastok>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", element.Attribute(code_attr).Value)); if (obj == null) { obj = objSpace.CreateObject <Uchastok>(); obj.Code = int.Parse(element.Attribute(code_attr).Value); obj.Name = element.Attribute(name_attr).Value; var doctorFullId = element.Attribute(doctor_full_id_attr); obj.DoctorFullId = (doctorFullId == null || doctorFullId.Value == "null") ? null : (int?)int.Parse(doctorFullId.Value); var doctorId = element.Attribute(doctor_id_attr); obj.DoctorId = (doctorId == null || doctorId.Value == "null") ? null : (int?)int.Parse(doctorId.Value); var otdelId = element.Attribute(otdel_id_attr); obj.OtdelId = (otdelId == null || otdelId.Value == "null") ? null : (int?)int.Parse(otdelId.Value); var doctorFio = element.Attribute(doctor_fio_attr); obj.DoctorFio = (doctorFio == null || doctorFio.Value == "null") ? null : doctorFio.Value; var otdelName = element.Attribute(otdel_name_attr); obj.OtdelName = (otdelName == null || otdelName.Value == "null") ? null : otdelName.Value; } else { if (obj.DoctorFullId != null) { var doctor = objSpace.FindObject <Doctor>(DevExpress.Data.Filtering.CriteriaOperator.Parse("InnerCode=?", obj.DoctorFullId)); if (doctor != null) { obj.Doctors.Add(doctor); } } } } }
//пример записи из XML // <rec1 IDRMP="101" RMPNAME="Выписан" DL_USLOV="1" DATEBEG="01.01.2011" DATEEND="" /> // <rec2 IDRMP="102" RMPNAME="Переведён в др. ЛПУ" DL_USLOV="1" DATEBEG="01.01.2011" DATEEND="" /> // <rec3 IDRMP="103" RMPNAME="Переведён в дневной стационар" DL_USLOV="1" DATEBEG="01.01.2011" DATEEND="" /> // <rec4 IDRMP="104" RMPNAME="Переведён на другой профиль коек" DL_USLOV="1" DATEBEG="01.01.2011" DATEEND="" /> public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); foreach (XElement el in doc.Root.Elements()) { V009 obj = objSpace.FindObject <V009>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", el.Attribute("IDRMP").Value)); if (obj == null) { obj = objSpace.CreateObject <V009>(); obj.Code = el.Attribute("IDRMP").Value; obj.DateBeg = el.Attribute("DATEBEG").Value == "" ? null : (DateTime?)Convert.ToDateTime(el.Attribute("DATEBEG").Value); obj.DateEnd = el.Attribute("DATEEND").Value == "" ? null : (DateTime?)Convert.ToDateTime(el.Attribute("DATEEND").Value); obj.Name = el.Attribute("RMPNAME").Value; obj.DlUslov = el.Attribute("DL_USLOV").Value; } } }
// Пример записи из XML // <WorkBook> // <WorkSheet> // <Table> // <Row> // <Cell><Data ss:Type="String">CODE_USL</Data></Cell> // <Cell><Data ss:Type="String">NAME</Data></Cell> // <Cell><Data ss:Type="String">TARIF</Data></Cell> // </Row> // <Row> // <Cell ss:StyleID="s16"><Data ss:Type="String">009101</Data></Cell> // <Cell ss:StyleID="s16"><Data ss:Type="String">кариес в ст. белого пятна 1-ое посещение</Data></Cell> // <Cell ss:StyleID="s18"><Data ss:Type="Number">1.5</Data></Cell> // </Row> public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); var ns = doc.Root.Name.Namespace; var rows = doc.Root.Descendants(ns + "Row"); foreach (var element in rows) { var data = element.Descendants(ns + "Data").ToList(); var code = data[0].Value; var name = data[1].Value; var rate = "0"; if (data.Count == 3) { rate = (data[2] == null || data[2].Value == "") ? "0" : data[2].Value; } // если текущий элемент строка с заголовком, то пропускаем if (code == "CODE_USL") { continue; } DoctorUslugi obj = objSpace.FindObject <DoctorUslugi>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", code)); if (obj == null) { obj = objSpace.CreateObject <DoctorUslugi>(); obj.Code = code; obj.Name = name; double parsedTarif = 0.0; double.TryParse(rate.Replace(".", ","), out parsedTarif); obj.Tarif = parsedTarif; } } }
/// <summary> /// Добавляет в базу классификаторы из файла XML /// </summary> /// <param name="updater">Пространство объектов ObjectSpace</param> /// <param name="xmlPath">Путь до файла классификатора</param> public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string code_attr = "IDDOC"; const string name_attr = "DOCNAME"; const string dateBeg_attr = "DATEBEG"; const string dateEnd_attr = "DATEEND"; foreach (XElement el in doc.Root.Elements()) { string id = el.Attribute(code_attr).Value; VidPolisa obj = objSpace.FindObject <VidPolisa>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", id)); if (obj == null) { obj = objSpace.CreateObject <VidPolisa>(); obj.Code = el.Attribute(code_attr).Value; obj.Name = el.Attribute(name_attr).Value; obj.DateBeg = el.Attribute(dateBeg_attr).Value == "" ? null : (DateTime?)Convert.ToDateTime(el.Attribute(dateBeg_attr).Value); obj.DateEnd = el.Attribute(dateEnd_attr).Value == "" ? null : (DateTime?)Convert.ToDateTime(el.Attribute(dateEnd_attr).Value); } } }
public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string elementsContainer = "ROWDATA"; const string elementNameStartsWith = "ROW"; const string code_attr = "id"; const string name_attr = "name"; const string inner_code_attr = "code"; const string code_oms_attr = "kod_oms"; const string lpu_id_attr = "lpu_id"; const string date_attr = "date_vnes_inf"; const string operator_id_attr = "operator_id"; const string pocket_id_attr = "pocket_id"; const string sort_attr = "sort"; const string uchastok_id_attr = "uchastok_id"; const string code_reestr_attr = "reestr_code"; foreach (var element in doc.Root.Element(elementsContainer).Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } Kategoriya obj = objSpace.FindObject <Kategoriya>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", element.Attribute(code_attr).Value)); if (obj == null) { obj = objSpace.CreateObject <Kategoriya>(); obj.Code = int.Parse(element.Attribute(code_attr).Value); obj.Name = element.Attribute(name_attr).Value; var innerCode = element.Attribute(inner_code_attr); obj.InnerCode = (innerCode == null || innerCode.Value == "null") ? 0 : int.Parse(innerCode.Value); var codeOms2 = element.Attribute(code_oms_attr); obj.CodeOMS = (codeOms2 == null || codeOms2.Value == "null") ? null : codeOms2.Value; var lpu = element.Attribute(lpu_id_attr); obj.CodeLPU = (lpu == null || lpu.Value == "null") ? null : (int?)int.Parse(lpu.Value); var dateBegin = element.Attribute(date_attr); obj.DateBegin = (dateBegin == null || dateBegin.Value == "null") ? null : (DateTime?)DateTime.Parse(dateBegin.Value); var operatorId = element.Attribute(operator_id_attr); obj.OperatorId = (operatorId == null || operatorId.Value == "null") ? null : (int?)int.Parse(operatorId.Value); var pocketId = element.Attribute(pocket_id_attr); obj.PocketId = (pocketId == null || pocketId.Value == "null") ? null : (int?)int.Parse(pocketId.Value); var sort = element.Attribute(sort_attr); obj.Sort = (sort == null || sort.Value == "null") ? null : sort.Value; var uchastokId = element.Attribute(uchastok_id_attr); obj.UchastokId = (uchastokId == null || uchastokId.Value == "null") ? null : (int?)int.Parse(uchastokId.Value); var codeReestr = element.Attribute(code_reestr_attr); obj.CodeReestr = (codeReestr == null || codeReestr.Value == "null") ? null : (int?)int.Parse(codeReestr.Value); } } }
public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string elementsContainer = "ROWDATA"; const string elementNameStartsWith = "ROW"; const string code_attr = "dolg_doctor_id"; const string name_attr = "dolg_doctor"; const string nagruzka_attr = "nagruzka"; const string name_file_attr = "name_file"; const string zena_oms_attr = "zena_oms"; const string zena_platno_attr = "zena_platno"; const string zena_inogorod_attr = "zena_inogorod"; const string flag_dolg_attr = "flag_dolg"; const string can_send_from_doctor_attr = "can_send_from_doctor"; const string max_days_can_send_attr = "max_days_can_send"; const string max_date_can_send_attr = "max_date_can_send"; const string eq_spec_fed_codes_id_attr = "eq_spec_fed_codes_id"; foreach (var element in doc.Root.Element(elementsContainer).Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } DoctorDolgnost obj = objSpace.FindObject <DoctorDolgnost>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", element.Attribute(code_attr).Value)); if (obj == null) { obj = objSpace.CreateObject <DoctorDolgnost>(); obj.Code = int.Parse(element.Attribute(code_attr).Value); obj.Name = element.Attribute(name_attr).Value; var nagruzka = element.Attribute(nagruzka_attr); obj.Nagruzka = (nagruzka == null || nagruzka.Value == "null") ? null : (int?)int.Parse(nagruzka.Value); var nameFile = element.Attribute(name_file_attr); obj.NameFile = (nameFile == null || nameFile.Value == "null") ? null : nameFile.Value; var zenaOms = element.Attribute(zena_oms_attr); obj.ZenaOms = (zenaOms == null || zenaOms.Value == "null") ? null : (decimal?)Decimal.Parse(zenaOms.Value); var zenaPlatno = element.Attribute(zena_platno_attr); obj.ZenaPlatno = (zenaPlatno == null || zenaPlatno.Value == "null") ? null : (decimal?)Decimal.Parse(zenaPlatno.Value); var zenaInogorod = element.Attribute(zena_inogorod_attr); obj.ZenaInogorod = (zenaInogorod == null || zenaInogorod.Value == "null") ? null : (decimal?)Decimal.Parse(zenaInogorod.Value); var flagDolg = element.Attribute(flag_dolg_attr); obj.FlagDolg = (flagDolg == null || flagDolg.Value == "null") ? 0 : int.Parse(flagDolg.Value); var canSendDoctor = element.Attribute(can_send_from_doctor_attr); obj.CanSendFromDoctor = (canSendDoctor == null || canSendDoctor.Value == "null") ? 0 : int.Parse(canSendDoctor.Value); var maxDays = element.Attribute(max_days_can_send_attr); obj.MaxDaysCanSend = (maxDays == null || maxDays.Value == "null") ? null : (int?)int.Parse(maxDays.Value); var maxDate = element.Attribute(max_date_can_send_attr); obj.MaxDateCanSend = (maxDate == null || maxDate.Value == "null") ? null : (DateTime?)DateTime.Parse(maxDate.Value); var eqSpec = element.Attribute(eq_spec_fed_codes_id_attr); obj.EqSpecFedCodesId = (eqSpec == null || eqSpec.Value == "null") ? null : (int?)int.Parse(eqSpec.Value); } } }
/* * FAM, IM, OT, DR - ФИО и ДР пациента. * W - пол (1 - м., 2 - ж.) * DOCTP - тип документа удост. личность * DOCS - серия * DOCN - номер * RN - код ОКАТО (Район) * NP, UL, DOM, KOR, KV - нас. пункт, улица, дом, корпус, квартира * PRN - Тоже какой-то код окато * Q - код страховой мед. организации * PRZ - Пункт регистрации застрахованного * SPOL - серия полиса * NPOL - номер полиса * OPDOC - тип полиса * DBEG - дата начала действия полиса * LPU - прикрепленное ЛПУ * LPUDT - дата прикрепления к ЛПУ * LPUAUTO - ? */ // пример записи из XML // <ROWDATA> // <ROW FAM="НЕТ" IM="БАЛАЖИНИМА" OT="НЕТ" DR="01.10.1947" W="1" DOCTP="14" DOCS="81 01" DOCN="141050" RN="81401373000" NP="Улан-Удэ" UL="СМОЛИНА" DOM="54" KOR="А" KV="2" PRN="81401373000" Q="03101" PRZ="137" SPOL="" NPOL="0369250848000218" OPDOC="3" DBEG="30.01.2015" LPU="032021" LPUDT="01.01.2011" LPUAUTO="0"/> public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument xDoc = XDocument.Load(xmlPath); const string elementsContainer = "ROWDATA"; const string elementNameStartsWith = "ROW"; int counter = 0; int countToLoad = 120; foreach (var element in xDoc.Root.Element(elementsContainer).Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } // ищем документ, удостоверяющий личность var docType = objSpace.FindObject <VidDocumenta>(CriteriaOperator.Parse("Code=?", element.Attribute("DOCTP").Value)); var docSerial = element.Attribute("DOCS").Value; var docNumber = element.Attribute("DOCN").Value; var document = objSpace.FindObject <Document>(CriteriaOperator.Parse("Type=? AND Serial=? AND Number=?", docType, docSerial, docNumber)); Pacient pacient = null; // если документ найден if (document != null) { // ищем пациента с таким документом pacient = objSpace.FindObject <Pacient>(CriteriaOperator.Parse("Document=?", document)); } else { document = objSpace.CreateObject <Document>(); document.Type = docType; document.Serial = docSerial; document.Number = docNumber; } // если пациент не найден (или не найден документ) if (pacient == null) { // создаем пациента pacient = objSpace.CreateObject <Pacient>(); counter++; } else { counter++; //continue; } // задаем данные или меняем, если пациент уже был pacient.LastName = element.Attribute("FAM").Value; pacient.FirstName = element.Attribute("IM").Value; pacient.MiddleName = element.Attribute("OT").Value; DateTime birthDate = DateTime.MinValue; DateTime.TryParse(element.Attribute("DR").Value, out birthDate); pacient.Birthdate = birthDate == DateTime.MinValue ? null : (DateTime?)birthDate; pacient.Gender = element.Attribute("W").Value == "1" ? Gender.Male : Gender.Female; pacient.Document = document; var SMO = objSpace.FindObject <StrahMedOrg>(CriteriaOperator.Parse("Code=?", element.Attribute("Q").Value)); pacient.Prikreplenie = objSpace.FindObject <MedOrg>(CriteriaOperator.Parse("Code=?", element.Attribute("LPU").Value)); pacient.PrikreplenieDate = (element.Attribute("LPUDT") == null || element.Attribute("LPUDT").Value == "") ? null : (DateTime?)DateTime.Parse(element.Attribute("LPUDT").Value); var polisType = objSpace.FindObject <VidPolisa>(CriteriaOperator.Parse("Code=?", element.Attribute("OPDOC").Value)); var polisSerial = element.Attribute("SPOL").Value; var polisNumber = element.Attribute("NPOL").Value; var polis = objSpace.FindObject <Polis>(CriteriaOperator.Parse("Type=? AND Serial=? AND Number=?", polisType, polisSerial, polisNumber)) ?? objSpace.CreateObject <Polis>(); polis.Type = polisType; polis.Serial = polisSerial; polis.Number = polisNumber; polis.PRZ = element.Attribute("PRZ").Value; polis.SMO = SMO; polis.DateBegin = (element.Attribute("DBEG") == null || element.Attribute("DBEG").Value == "") ? null : (DateTime?)DateTime.Parse(element.Attribute("DBEG").Value); if (pacient.Polises.Contains <Polis>(polis) == false) { pacient.Polises.Add(polis); } var okato = element.Attribute("RN").Value; pacient.Address = Address.GetAddressByOkato(objSpace, okato); if (pacient.Address != null) { var collection = new CriteriaOperatorCollection(); if (pacient.Address.Level1 != null) { collection.Add(new BinaryOperator("City", pacient.Address.Level1)); } if (pacient.Address.Level2 != null) { collection.Add(new BinaryOperator("City", pacient.Address.Level2)); } if (pacient.Address.Level3 != null) { collection.Add(new BinaryOperator("City", pacient.Address.Level3)); } if (pacient.Address.Level4 != null) { collection.Add(new BinaryOperator("City", pacient.Address.Level4)); } var street = objSpace.FindObject <Street>(CriteriaOperator.And( CriteriaOperator.Or(collection), CriteriaOperator.Parse(string.Format("Lower(Name) like '{0}%'", element.Attribute("UL").Value.ToLower()))) ); pacient.Address.Street = street; pacient.Address.House = element.Attribute("DOM").Value; pacient.Address.Build = element.Attribute("KOR").Value; pacient.Address.Flat = element.Attribute("KV").Value; } if (counter > countToLoad) { counter = 0; break; } } }
// пример записи из XML // <ROWDATA> // <ROW id="100000" lpu_id="03001" date_vnes_inf="2015-02-11 09:44:05.098924+08" operator_id="2469" pocket_id="null" code="136" sort="null" diagn="O12.0" ksg="1" name_ksg="Отеки, протеинурия, гипертензивные расстройства в период беременности, в родах и после родов" kz="0,82" name_profile="Акушерство и гинекология"/> // <ROW id="203001" lpu_id="03001" date_vnes_inf="2015-02-11 09:43:56.323753+08" operator_id="2469" pocket_id="null" code="136" sort="null" diagn="O12.2" ksg="1" name_ksg="Отеки, протеинурия, гипертензивные расстройства в период беременности, в родах и после родов" kz="0,82" name_profile="Акушерство и гинекология"/> public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); const string elementsContainer = "ROWDATA"; const string elementNameStartsWith = "ROW"; // диагноз в КСГ является уникальным, сверяем по нему. const string code_attr = "diagn"; StringBuilder log = new StringBuilder(); foreach (var element in doc.Root.Element(elementsContainer).Elements()) { if (element.Name.ToString().StartsWith(elementNameStartsWith) == false) { continue; } var diagnoseCode = element.Attribute(code_attr).Value; // ищем в справочнике диагнозов диагноз по коду. MKB10 diagnose = objSpace.FindObject <MKB10>(DevExpress.Data.Filtering.CriteriaOperator.Parse("MKB=?", diagnoseCode)); // если диагноз не найден if (diagnose == null) { log.AppendLine(string.Format("id: {1}. Не найден диагноз: {0}", diagnoseCode, element.Attribute("id").Value)); log.AppendLine("\tУдаляем точку в конце и ищем заново"); if (diagnoseCode[diagnoseCode.Length - 1].Equals('.')) { diagnose = objSpace.FindObject <MKB10>(DevExpress.Data.Filtering.CriteriaOperator.Parse("MKB=?", diagnoseCode.Substring(0, diagnoseCode.Length - 1))); if (diagnose == null) { log.AppendLine("\tНе найдено"); } else { log.AppendLine("\tНайдено"); } } continue; } ClinicStatGroups obj = objSpace.FindObject <ClinicStatGroups>(DevExpress.Data.Filtering.CriteriaOperator.Parse("MainDiagnose=?", diagnose)); if (obj == null) { obj = objSpace.CreateObject <ClinicStatGroups>(); obj.Name = element.Attribute("name_ksg").Value; obj.Number = int.Parse(element.Attribute("ksg").Value); obj.KoeffZatrat = double.Parse(element.Attribute("kz").Value); obj.Diagnose = diagnose; var codeProfil = element.Attribute("code").Value; obj.Profil = objSpace.FindObject <MedProfil>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", codeProfil)); } } if (log.Length > 0) { System.IO.File.AppendAllText(xmlPath + ".log", log.ToString(), Encoding.UTF8); } }
// пример записи из XML /* <REC * TF_OKATO="01000" * MCOD="220001" * NAM_MOP="КРАЕВОЕ ГОСУДАРСТВЕННОЕ БЮДЖЕТНОЕ УЧРЕЖДЕНИЕ ЗДРАВООХРАНЕНИЯ "АЛЕЙСКАЯ ЦЕНТРАЛЬНАЯ РАЙОННАЯ БОЛЬНИЦА"" * NAM_MOK="КГБУЗ "АЛЕЙСКАЯ ЦРБ"" * INN="2201002996" * OGRN="1022200509132" * KPP="220101001" * INDEX_J="658130" * ADDR_J="АЛТАЙСКИЙ КРАЙ, АЛЕЙСК, УЛ.ОЛЕШКО, 30" * OKOPF="72" * VEDPRI="2" * ORG="1" * FAM_RUK="ПАСТУХОВА" * IM_RUK="НАТАЛЬЯ" * OT_RUK="ИВАНОВНА" * PHONE="8(385-53) 22187" * FAX="8(385-53) 24195" * E_MAIL="*****@*****.**" * D_BEGIN="01.01.2011" * D_END="15.03.2013" * NAME_E="4" * N_DOC="ЛО-22-01-000130" * D_START="15.08.2008" * DATA_E="31.12.2099" * MP="1,2,3" * WWW="WWW.BUS.GOV.RU; ALEYSKAYA-CRB.RU" * DUVED="23.07.2013" * D_EDIT="01.08.2013" * /> */ public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); var splitChars = new char[] { ',' }; foreach (XElement element in doc.Root.Elements()) { string id = element.Attribute("MCOD").Value; MedOrg obj = objSpace.FindObject <MedOrg>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", id)); if (obj == null) { obj = objSpace.CreateObject <MedOrg>(); obj.Code = id; } obj.FullName = element.Attribute("NAM_MOP").Value; obj.ShortName = element.Attribute("NAM_MOK").Value; obj.License = element.Attribute("N_DOC").Value; // получаем список оказываемых организацией кодов видов помощи if (element.Attribute("MP") != null) { var mp = element.Attribute("MP").Value.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); // формируем список оказываемых видов помощи из кодов foreach (var mpCode in mp) { var vid = objSpace.FindObject <Dictionaries.VidMedPomoshi>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", mpCode)); if (obj.VidiPomoshi == null) { obj.VidiPomoshi = new List <Dictionaries.VidMedPomoshi>(); } if (vid != null && !obj.VidiPomoshi.Contains(vid)) { obj.VidiPomoshi.Add(vid); } } } obj.TF_OKATO = element.Attribute("TF_OKATO").Value; obj.INN = element.Attribute("INN").Value; obj.OGRN = element.Attribute("OGRN").Value; obj.OKOPF = element.Attribute("OKOPF").Value; obj.KPP = element.Attribute("KPP") == null ? string.Empty : element.Attribute("KPP").Value; obj.Ruk_LastName = (element.Attribute("FAM_RUK") == null) ? string.Empty : element.Attribute("FAM_RUK").Value; obj.Ruk_FirstName = (element.Attribute("IM_RUK") == null) ? string.Empty : element.Attribute("IM_RUK").Value; obj.Ruk_MiddleName = (element.Attribute("OT_RUK") == null) ? string.Empty : element.Attribute("OT_RUK").Value; obj.Fax = (element.Attribute("FAX") == null) ? string.Empty : element.Attribute("FAX").Value; obj.Phone = (element.Attribute("PHONE") == null) ? string.Empty : element.Attribute("PHONE").Value; obj.Email = (element.Attribute("E_MAIL") == null) ? string.Empty : element.Attribute("E_MAIL").Value; obj.WebSite = (element.Attribute("WWW") == null) ? string.Empty : element.Attribute("WWW").Value; obj.IndexJur = (element.Attribute("INDEX_J") == null) ? string.Empty : element.Attribute("INDEX_J").Value; obj.AddressJur = (element.Attribute("ADDR_J") == null) ? string.Empty : element.Attribute("ADDR_J").Value; obj.Org = (element.Attribute("ORG") == null) ? string.Empty : element.Attribute("ORG").Value; obj.Vedpri = (element.Attribute("VEDPRI") == null) ? string.Empty : element.Attribute("VEDPRI").Value; obj.Name_E = (element.Attribute("NAME_E") == null) ? string.Empty : element.Attribute("NAME_E").Value; var date = DateTime.MinValue; if (element.Attribute("DATA_E") != null) { DateTime.TryParse(element.Attribute("DATA_E").Value, out date); } obj.Data_E = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Attribute("D_BEGIN") != null) { DateTime.TryParse(element.Attribute("D_BEGIN").Value, out date); } obj.D_Begin = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Attribute("D_END") != null) { DateTime.TryParse(element.Attribute("D_END").Value, out date); } obj.D_End = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Attribute("D_START") != null) { DateTime.TryParse(element.Attribute("D_START").Value, out date); } obj.D_Start = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Attribute("D_EDIT") != null) { DateTime.TryParse(element.Attribute("D_EDIT").Value, out date); } obj.D_Edit = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Attribute("DUVED") != null) { DateTime.TryParse(element.Attribute("DUVED").Value, out date); } obj.Duved = date == DateTime.MinValue ? null : (DateTime?)date; } }
// пример записи из XML /* <insCompany> * <tf_okato>01000</tf_okato> * <smocod>22001</smocod> * <nam_smop>АЛТАЙСКИЙ ФИЛИАЛ ОБЩЕСТВА С ОГРАНИЧЕННОЙ ОТВЕТСТВЕННОСТЬЮ "СТРАХОВАЯ МЕДИЦИНСКАЯ КОМПАНИЯ РЕСО-МЕД"</nam_smop> * <nam_smok>АЛТАЙСКИЙ ФИЛИАЛ ООО "СМК РЕСО-МЕД"</nam_smok> * <inn>5035000265</inn> * <Ogrn>1025004642519</Ogrn> * <KPP>222302001</KPP> * <jurAddress> * <index_j>142500</index_j> * <addr_j>МОСКОВСКАЯ ОБЛАСТЬ, Г.ПАВЛОВСКИЙ ПОСАД, УЛ.УРИЦКОГО, 26</addr_j> * </jurAddress> * <pstAddress> * <index_f>656054</index_f> * <addr_f>АЛТАЙСКИЙ КРАЙ, Г.БАРНАУЛ, УЛ.ОСТРОВСКОГО, 29</addr_f> * </pstAddress> * <okopf>30002</okopf> * <fam_ruk>ОСИПОВ</fam_ruk> * <im_ruk>ЕВГЕНИЙ</im_ruk> * <ot_ruk>АНДРЕЕВИЧ</ot_ruk> * <phone>(385-2)243637</phone> * <fax>8(3852) 242972</fax> * <e_mail>[email protected]</e_mail> * <www>WWW.RESO-MED.COM</www> * <licenziy> * <n_doc>С №0879 50</n_doc> * <d_start>29.09.2008</d_start> * <data_e>31.12.2099</data_e> * </licenziy> * <org>2</org> * <insInclude> * <d_begin>01.01.2011</d_begin> * <d_end></d_end> * <name_e /> * <Nal_p></Nal_p> * </insInclude> * <insAdvice> * <YEAR_WORK>2015</YEAR_WORK> * <DUVED>16.07.2014</DUVED> * <kol_zl>1481134</kol_zl> * </insAdvice> * ... * <d_edit>23.01.2014</d_edit> * </insCompany> */ public static void UpdateDbFromXml(DevExpress.ExpressApp.IObjectSpace objSpace, string xmlPath) { XDocument doc = XDocument.Load(xmlPath); var splitChars = new char[] { ',' }; foreach (XElement element in doc.Root.Elements()) { string id = element.Element("smocod").Value; StrahMedOrg obj = objSpace.FindObject <StrahMedOrg>(DevExpress.Data.Filtering.CriteriaOperator.Parse("Code=?", id)); if (obj == null) { obj = objSpace.CreateObject <StrahMedOrg>(); obj.Code = id; } obj.FullName = element.Element("nam_smop").Value; obj.ShortName = element.Element("nam_smok").Value; obj.License = element.Element("licenziy").Element("n_doc").Value; obj.TF_OKATO = element.Element("tf_okato").Value; obj.INN = element.Element("inn").Value; obj.OGRN = element.Element("Ogrn").Value; obj.OKOPF = element.Element("okopf").Value; obj.KPP = element.Element("KPP") == null ? string.Empty : element.Element("KPP").Value; obj.Ruk_LastName = (element.Element("fam_ruk") == null) ? string.Empty : element.Element("fam_ruk").Value; obj.Ruk_FirstName = (element.Element("im_ruk") == null) ? string.Empty : element.Element("im_ruk").Value; obj.Ruk_MiddleName = (element.Element("ot_ruk") == null) ? string.Empty : element.Element("ot_ruk").Value; obj.Fax = (element.Element("fax") == null) ? string.Empty : element.Element("fax").Value; obj.Phone = (element.Element("phone") == null) ? string.Empty : element.Element("phone").Value; obj.Email = (element.Element("e_mail") == null) ? string.Empty : element.Element("e_mail").Value; obj.WebSite = (element.Element("www") == null) ? string.Empty : element.Element("www").Value; obj.IndexJur = (element.Element("jurAddress").Element("index_j") == null) ? string.Empty : element.Element("jurAddress").Element("index_j").Value; obj.AddressJur = (element.Element("jurAddress").Element("addr_j") == null) ? string.Empty : element.Element("jurAddress").Element("addr_j").Value; obj.IndexFact = (element.Element("pstAddress").Element("index_f") == null) ? string.Empty : element.Element("pstAddress").Element("index_f").Value; obj.AddressFact = (element.Element("pstAddress").Element("addr_f") == null) ? string.Empty : element.Element("pstAddress").Element("addr_f").Value; obj.Org = (element.Element("org") == null) ? string.Empty : element.Element("org").Value; obj.Name_E = (element.Element("insInclude").Element("name_e") == null) ? string.Empty : element.Element("insInclude").Element("name_e").Value; var date = DateTime.MinValue; date = DateTime.MinValue; if (element.Element("licenziy").Element("d_start") != null) { DateTime.TryParse(element.Element("licenziy").Element("d_start").Value, out date); } obj.D_Start = date == DateTime.MinValue ? null : (DateTime?)date; if (element.Element("licenziy").Element("data_e") != null) { DateTime.TryParse(element.Element("licenziy").Element("data_e").Value, out date); } obj.Data_E = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Element("insInclude").Element("d_begin") != null) { DateTime.TryParse(element.Element("insInclude").Element("d_begin").Value, out date); } obj.D_Begin = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Element("insInclude").Element("d_end") != null) { DateTime.TryParse(element.Element("insInclude").Element("d_end").Value, out date); } obj.D_End = date == DateTime.MinValue ? null : (DateTime?)date; date = DateTime.MinValue; if (element.Element("d_edit") != null) { DateTime.TryParse(element.Element("d_edit").Value, out date); } obj.D_Edit = date == DateTime.MinValue ? null : (DateTime?)date; } }