public void LoadFromXml( string tp_file, TPImportGroup tp_group, string ent_file, string tp_dir, string tp_prefix = "TC") { #if DEBUG OpenLogSession(); Log("Начало загрузки"); #endif //OnImporting(); ClearLoadData(); //OnTpImporting(); LoadTPList(tp_file, tp_group); LoadEntities(ent_file); LoadTpDir(tp_dir, tp_prefix); //UpdateTpLinks(); #if DEBUG Log("Окончание загрузки"); CloseLogSession(); #endif }
private void LoadTPList(string tp_file, TPImportGroup group) { #if DEBUG Log("Загрузка списка ТП"); #endif tp_objects = new Dictionary <decimal, decimal>(); XDocumentExt tp_doc = new XDocumentExt(tp_file); XDocument xdoc = tp_doc.Document; XElement tp_element = xdoc.Root; XName techpr = tp_doc.GetXName("TechProcess"); XName articles = tp_doc.GetXName("Articles"); OracleCommand sq_cmd = new OracleCommand(); sq_cmd.Connection = obj_lib.Module.Connection; sq_cmd.CommandText = "select sq_sepo_tech_processes.nextval from dual"; OracleCommand tp_cmd = new OracleCommand(); tp_cmd.Connection = obj_lib.Module.Connection; tp_cmd.CommandText = @"insert into sepo_tech_processes (id, key_, designation, name, doc_id, kind, production_id, version_key) values (:id, :key_, :designation, :name, :doc_id, :kind, :production_id, :version_key)"; OracleParameter p_id = new OracleParameter("id", OracleDbType.Decimal); OracleParameter p_key = new OracleParameter("key_", OracleDbType.Decimal); OracleParameter p_designation = new OracleParameter("designation", OracleDbType.Varchar2); OracleParameter p_name = new OracleParameter("name", OracleDbType.Varchar2); OracleParameter p_doc_id = new OracleParameter("doc_id", OracleDbType.Decimal); OracleParameter p_kind = new OracleParameter("kind", OracleDbType.Int16); OracleParameter p_production_id = new OracleParameter("production_id", OracleDbType.Decimal); OracleParameter p_version_key = new OracleParameter("version_key", OracleDbType.Decimal); tp_cmd.Parameters.AddRange(new OracleParameter[] { p_id, p_key, p_designation, p_name, p_doc_id, p_kind, p_production_id, p_version_key }); OracleCommand art_cmd = new OracleCommand(); art_cmd.Connection = obj_lib.Module.Connection; art_cmd.CommandText = @"insert into sepo_tp_to_dce (id_tp, key_, designation, name, art_id) values (:id_tp, :key_, :designation, :name, :art_id)"; OracleParameter p_art_id = new OracleParameter("art_id", OracleDbType.Decimal); art_cmd.Parameters.AddRange(new OracleParameter[] { p_id, p_key, p_designation, p_name, p_art_id }); XElement xarticles = null; foreach (var tp in tp_element.Elements()) { p_id.Value = sq_cmd.ExecuteScalar(); p_key.Value = tp.Attribute("Key").Value; p_designation.Value = tp.Attribute("Designation").Value; p_name.Value = tp.Attribute("Name").Value; p_doc_id.Value = tp.Attribute("DocId").Value; p_kind.Value = tp.Attribute("Kind").Value; p_production_id.Value = tp.Attribute("ProductionId").Value; p_version_key.Value = tp.Attribute("VersionKey").Value; tp_cmd.ExecuteNonQuery(); tp_objects.Add((decimal)p_id.Value, decimal.Parse(p_key.Value.ToString())); xarticles = tp.Element(articles); if (xarticles != null) { foreach (var art in xarticles.Elements()) { p_key.Value = art.Attribute("Key").Value; p_designation.Value = art.Attribute("Designation").Value; p_name.Value = art.Attribute("Name").Value; p_art_id.Value = art.Attribute("ArtId").Value; art_cmd.ExecuteNonQuery(); } } } }