Esempio n. 1
0
        private void InsertCodeDomainLevel3(IList <mdmExcelRawEntity> codesyslist, string connstr)
        {
            var domains = codesyslist.Where(p => !string.IsNullOrEmpty(p.级域)).Select(p => new { levelcode = p.级域代码, levelname = p.级域, levl1code = p.一级域代码, levl1name = p.一级域, levl2code = p.二级域代码, levl2name = p.二级域 }).Distinct();

            using (NpgsqlConnection conn = new NpgsqlConnection(connstr))
            {
                foreach (var item in domains)
                {
                    var codedomain = new code_domain_entity
                    {
                        //domain_id = "168",
                        domain_code      = item.levelcode,
                        domain_name      = item.levelname,
                        spell_code       = " ",
                        wb_code          = " ",
                        parent_domain_id = 0,
                        note             = "3",
                        oper_id          = 2,
                        oper_time        = DateTime.Now,
                        etl_time         = DateTime.Now,
                        tenant_id        = 0
                    };

                    var parentdomid = conn.Query <int>($"select domain_id from mdm.code_domain where  note = '{"2"}' and domain_code = '{item.levl2code}'").FirstOrDefault();

                    codedomain.parent_domain_id = parentdomid;


                    var result = conn.Insert <code_domain_entity>(codedomain, commandTimeout: 15);
                }
            }
        }
Esempio n. 2
0
        private void InsertCodeDomainLevel1(IList <mdmExcelRawEntity> codesyslist, string connstr)
        {
            var domains = codesyslist.Select(p => new { levelcode = p.一级域代码, levelname = p.一级域 }).Distinct();

            using (NpgsqlConnection conn = new NpgsqlConnection(connstr))
            {
                foreach (var item in domains)
                {
                    var codedomain = new code_domain_entity
                    {
                        //domain_id = "168",
                        domain_code      = item.levelcode,
                        domain_name      = item.levelname,
                        spell_code       = " ",
                        wb_code          = " ",
                        parent_domain_id = 0,
                        note             = "1",
                        oper_id          = 2,
                        oper_time        = DateTime.Now,
                        etl_time         = DateTime.Now,
                        tenant_id        = 0
                    };

                    var result = conn.Insert <code_domain_entity>(codedomain, commandTimeout: 15);
                }
            }
        }