예제 #1
0
        public override bool Import()
        {
            string s = Sr.ReadToEnd();

            TemplateHelper tmph = new TemplateHelper("");

            string[]            arys = regRowSplit.Split(s);
            List <DAL.ShowBase> sbs  = new List <DAL.ShowBase>();
            List <DAL.STPa>     pas  = new List <DAL.STPa>();
            List <DAL.STIV>     ivs  = new List <DAL.STIV>();
            List <DAL.STIpc>    ipcs = new List <DAL.STIpc>();
            List <DAL.STPR>     prs  = new List <DAL.STPR>();
            List <DAL.STDT>     dts  = new List <DAL.STDT>();
            List <DAL.STQY>     qys  = new List <DAL.STQY>();

            int count = arys.Length - 1;

            SetMaxProcess(this, count);
            Thimport = new Thread(() =>
            {
                //第一行为空
                for (int i = 1; i <= arys.Length - 1; i++)
                {
                    string tmp = regspace.Replace(regcharRNT.Replace(arys[i].Trim(), ""), "");
                    foreach (string x in otherstring)
                    {
                        tmp = tmp.Replace(x, "");
                    }
                    tmp = RemoveZaoZi(tmp);
                    MatchCollection mhs = rowRege.Matches(tmp);
                    ShowBase sb         = new ShowBase();
                    sb.ZTID             = ZTId;
                    sb.ImportDate       = DateTime.Now;

                    foreach (Match m in mhs)
                    {
                        string colname        = m.Groups["colname"].Value;
                        string val            = m.Groups["colval"].Value.Trim().Trim('\t');
                        string mappingcolname = tmph.getMappingColumnName(colname);
                        switch (mappingcolname)
                        {
                        case "申请号":
                            sb.An  = val;
                            sb.SiD = val;
                            break;

                        case "发明名称":
                            sb.Title = val;
                            break;

                        case "摘要":
                            sb.ABs = val;
                            break;

                        case "权利要求":
                            sb.ClM = val;
                            break;

                        case "国际分类号":
                            sb.Ipc = val;
                            break;

                        case "范畴分类号":
                            sb.FCfL = val;
                            break;

                        case "国家/省市":
                            sb.ShEng = val;
                            break;

                        case "申请人":
                            sb.Pa = val;
                            break;

                        case "联系地址":
                            sb.AddR = val;
                            break;

                        case "邮编":
                            sb.Zip = val;
                            break;

                        case "代理机构":
                            sb.DLJG = val;
                            break;

                        case "代理人":
                            sb.DLr = val;
                            break;

                        case "代理机构地址":
                            sb.DLJGAddR = val;
                            break;

                        case "发明人":
                            sb.IV = val;
                            break;

                        case "申请日":
                            sb.Ad = val;
                            break;

                        case "公开号":
                            sb.PN = val;
                            break;

                        case "公开日":
                            sb.PD = val;
                            break;

                        //case "授权公告日":
                        //    sb.Gd = val;
                        //    break;
                        case "公告日":
                            sb.Gd = val;
                            break;

                        //case "授权日":
                        //    sb.Gd = val;
                        //    break;
                        case "公告号":
                            sb.GN = val;
                            break;

                        case "优先权":
                            sb.PR = val;
                            break;

                        case "审批历史":
                            sb.LG = val;
                            break;

                        case "附图数":
                            sb.PiCSum = val;
                            break;

                        case "页数":
                            sb.DesPageSum = val;
                            break;

                        case "权利要求项数":
                            sb.ClMSum = val;
                            break;
                        }
                    }
                    if (CheckExist(sb.SiD))
                    {
                        if (Skip)
                        {
                            Skip_sum++;
                            continue;
                        }
                        else
                        {
                            DelExist(sb.ZTID.ToString(), sb.SiD.ToString());
                            Overwrite_sum++;
                        }
                    }
                    else
                    {
                        Sids.Add(sb.SiD, true);
                    }
                    sbs.Add(sb);

                    List <STPa> pa   = new List <STPa>();
                    List <STIV> iv   = new List <STIV>();
                    List <STIpc> ipc = new List <STIpc>();
                    List <STPR> pr   = new List <STPR>();
                    List <STQY> qy   = new List <STQY>();
                    dts.Add(CPRSIndex.AutoIndex(sb, out pa, out iv, out ipc, out pr, out qy));
                    pas.AddRange(pa);
                    ivs.AddRange(iv);
                    ipcs.AddRange(ipc);
                    prs.AddRange(pr);
                    qys.AddRange(qy);

                    if (i % 100 == 0)
                    {
                        //Thread.Sleep(1000);
                        //todo:标引
                        //todo:标引信息入库

                        //todo:基本信息入库
                        BulkInsert(sbs, pas, ivs, ipcs, prs, dts, qys);
                        sbs.Clear();
                        pas.Clear();
                        ivs.Clear();
                        ipcs.Clear();
                        prs.Clear();
                        dts.Clear();
                        qys.Clear();
                        ShowProcess(this, i, Skip_sum, Overwrite_sum, "导入");
                    }
                }
                if (sbs.Count > 0)
                {
                    BulkInsert(sbs, pas, ivs, ipcs, prs, dts, qys);
                    sbs.Clear();
                    pas.Clear();
                    ivs.Clear();
                    ipcs.Clear();
                    prs.Clear();
                    dts.Clear();
                    qys.Clear();
                }

                log.Info(string.Format("导入完毕: 专题库:{0},ID:{1},类型:,{2}总量:{3},跳过:{4}", ztName, ZTId, Type, count, Skip_sum));
                ShowProcess(this, count, Skip_sum, Overwrite_sum, "导入完毕");

                Sr.Close();
                Sr.Dispose();
            });
            Thimport.Start();
            return(true);
        }
예제 #2
0
        public bool Import()
        {
            string         s    = sr.ReadToEnd().Replace(kunkaojin, "");
            TemplateHelper tmph = new TemplateHelper("");

            string[]            arys = regRowSplit.Split(s);
            List <DAL.ShowBase> sbs  = new List <DAL.ShowBase>();
            List <DAL.STPa>     pas  = new List <DAL.STPa>();
            List <DAL.STIV>     ivs  = new List <DAL.STIV>();
            List <DAL.STIpc>    ipcs = new List <DAL.STIpc>();
            List <DAL.STPR>     prs  = new List <DAL.STPR>();
            List <DAL.STDT>     dts  = new List <DAL.STDT>();
            int count = arys.Length - 1;

            SetMaxProcess(this, count);
            thimport = new Thread(() =>
            {
                //第一行为空
                for (int i = 1; i <= arys.Length - 1; i++)
                {
                    string tmp          = regspace.Replace(regcharRNT.Replace(arys[i].Trim(), ""), "");
                    MatchCollection mhs = rowRege.Matches(tmp);
                    ShowBase sb         = new ShowBase();
                    sb.ZTID             = zid;
                    sb.ImportDate       = DateTime.Now;

                    foreach (Match m in mhs)
                    {
                        string colname        = m.Groups["colname"].Value;
                        string val            = m.Groups["colval"].Value.Trim().Trim('\t');
                        string mappingcolname = tmph.getMappingColumnName(colname);
                        switch (mappingcolname)
                        {
                        case "申请号":
                            sb.An  = val;
                            sb.SiD = val;
                            break;

                        case "发明名称":
                            sb.Title = val;
                            break;

                        case "摘要":
                            sb.ABs = val;
                            break;

                        case "权利要求":
                            sb.ClM = val;
                            break;

                        case "国际分类号":
                            sb.Ipc = val;
                            break;

                        case "范畴分类号":
                            sb.FCfL = val;
                            break;

                        case "国家/省市":
                            sb.ShEng = val;
                            break;

                        case "申请人":
                            sb.Pa = val;
                            break;

                        case "联系地址":
                            sb.AddR = val;
                            break;

                        case "邮编":
                            sb.Zip = val;
                            break;

                        case "代理机构":
                            sb.DLJG = val;
                            break;

                        case "代理人":
                            sb.DLr = val;
                            break;

                        case "代理机构地址":
                            sb.DLJGAddR = val;
                            break;

                        case "发明人":
                            sb.IV = val;
                            break;

                        case "申请日":
                            sb.Ad = val;
                            break;

                        case "公开号":
                            sb.PN = val;
                            break;

                        case "公开日":
                            sb.PD = val;
                            break;

                        case "授权公告日":
                            sb.Gd = val;
                            break;

                        case "公告日":
                            sb.Gd = val;
                            break;

                        case "授权日":
                            sb.Gd = val;
                            break;

                        case "公告号":
                            sb.GN = val;
                            break;

                        case "优先权":
                            sb.PR = val;
                            break;

                        case "审批历史":
                            sb.LG = val;
                            break;

                        case "附图数":
                            sb.PiCSum = val;
                            break;

                        case "页数":
                            sb.DesPageSum = val;
                            break;

                        case "权利要求项数":
                            sb.ClMSum = val;
                            break;
                        }
                    }
                    sbs.Add(sb);

                    List <STPa> pa   = new List <STPa>();
                    List <STIV> iv   = new List <STIV>();
                    List <STIpc> ipc = new List <STIpc>();
                    List <STPR> pr   = new List <STPR>();
                    dts.Add(CPRSIndex.AutoIndex(sb, out pa, out iv, out ipc, out pr));
                    pas.AddRange(pa);
                    ivs.AddRange(iv);
                    ipcs.AddRange(ipc);
                    prs.AddRange(pr);

                    if (i % 100 == 0)
                    {
                        //Thread.Sleep(1000);
                        //todo:标引
                        //todo:标引信息入库

                        //todo:基本信息入库
                        BulkInsert(sbs, pas, ivs, ipcs, prs, dts);
                        sbs.Clear();
                        pas.Clear();
                        ivs.Clear();
                        ipcs.Clear();
                        prs.Clear();
                        dts.Clear();
                        ShowProcess(this, i, "导入");
                    }
                }
                if (sbs.Count > 0)
                {
                    BulkInsert(sbs, pas, ivs, ipcs, prs, dts);
                    sbs.Clear();
                    pas.Clear();
                    ivs.Clear();
                    ipcs.Clear();
                    prs.Clear();
                    dts.Clear();
                }


                ShowProcess(this, count, "导入完毕");

                sr.Close();
                sr.Dispose();
            });
            thimport.Start();
            return(true);
        }