Exemple #1
0
        protected override PM getPM(OleDbDataReader reader, out String err)
        {
            err = String.Empty;
            ZWQK_PM pm = new ZWQK_PM();
            if (hasFormatTable)
            {
                pm.sybm = reader["索引编码"].ToString().Trim();
                pm.wjm = reader["文件名"].ToString().Trim();
                pm.ywjm = reader["原文件名"].ToString().Trim();
                pm.nf = reader["年份"].ToString().Trim();
                pm.qh = reader["期号"].ToString().Trim();
                pm.zwpm = reader["中文篇名"].ToString().Trim();
                pm.wwpm = reader["外文篇名"].ToString().Trim();
                pm.zz = reader["作者"].ToString().Trim();
                pm.zzdw = reader["作者单位"].ToString().Trim();
                pm.kb = reader["开本"].ToString().Trim();
                try
                {
                    pm.ys = int.Parse(reader["页数"].ToString());
                }
                catch (Exception)
                {
                    pm.ys = 0;
                    err += pm.ywjm +"页数\"" + reader["页数"] + "\"出错,置为0\n";
                }
                pm.zwwz = reader["中文文摘"].ToString().Trim();
                pm.wwwz = reader["外文文摘"].ToString().Trim();
                pm.zwztc = reader["中文主题词"].ToString().Trim();
                pm.wwztc = reader["外文主题词"].ToString().Trim();
                pm.gtfl = reader["国图分类"].ToString().Trim();
                pm.wxbs = reader["文献标识"].ToString().Trim();
            }
            else
            {
                if (allSYML == null || allSYML.Count == 0)
                {
                    allSYML = zwqkDAO.getAllZwqkSYML();
                }

                String KanMing = reader["刊名"].ToString();
                pm.sybm = null;
                foreach (ZWQK_SYML syml in allSYML)
                {
                    if (KanMing.Equals(syml.zwmc))
                    {
                        pm.sybm = syml.sybm;
                        break;
                    }
                }

                /* 特殊处理 */
                if (pm.sybm == null)
                {
                    if (KanMing.IndexOf('(') >= 0)
                        KanMing = KanMing.Split('(')[0];

                    foreach (ZWQK_SYML syml in allSYML)
                    {
                        if (syml.zwmc.IndexOf(KanMing) >= 0)
                        {
                            pm.sybm = syml.sybm;
                            break;
                        }
                    }
                }

                pm.ywjm = reader["PDF全文"].ToString();
                pm.nf = reader["年"].ToString();
                pm.qh = reader["期"].ToString();
                pm.zwpm = reader["论文标题"].ToString();
                pm.wwpm = reader["英文标题E"].ToString();
                pm.zz = reader["作者"].ToString();
                pm.zzdw = reader["作者单位"].ToString();
                pm.kb = "";
                pm.zwwz = reader["摘要"].ToString();
                pm.wwwz = reader["英文摘要"].ToString();
                pm.zwztc = reader["关键词"].ToString();
                pm.wwztc = reader["英文关键词E"].ToString();
                pm.gtfl = reader["分类号"].ToString();
                pm.wxbs = "";

                /* 可能出现字段过长 */
                pm.wwpm = CutString(pm.wwpm, 255);
                pm.wwztc = CutString(pm.wwztc, 255);

                if (pm.sybm == null)
                {
                    err += "刊名《" + KanMing + "》不存在 " + pmKeyInfo(pm);
                }
            }
            pm.dlr = user.name;
            pm.fillEmptyStringAsNull();

            return pm;
        }
Exemple #2
0
        /// <summary>
        /// 进行数据的规范,同时进行来自万方数据的查重
        /// </summary>
        /// <param name="pm"></param>
        /// <returns></returns>
        public override string formatData(PM pm)
        {
            //反馈信息
            String result = String.Empty;

            String Empty = "NULL";
            ZWQK_PM zwqk = (ZWQK_PM)pm;

            zwqk.zz = GlobalMethod.Semicolon(zwqk.zz);
            zwqk.zzdw = GlobalMethod.Semicolon(zwqk.zzdw);

            if (zwqk.zzdw.IndexOf(';') >= 0)
                zwqk.zzdw = zwqk.zzdw.Split(';')[0];

            zwqk.zwztc = GlobalMethod.Semicolon(zwqk.zwztc);
            zwqk.wwztc = GlobalMethod.Semicolon(zwqk.wwztc);
            zwqk.gtfl = GlobalMethod.Semicolon(zwqk.gtfl);

            zwqk.dlr = user.name;

            if (Empty.Equals(zwqk.zwpm) && Empty.Equals(zwqk.wwpm))
            {
                result += "论文标题(中、英)为空 ";
            }
            if (Empty.Equals(zwqk.nf))
            {
                result += "年份为空 ";
            }
            if (Empty.Equals(zwqk.qh))
            {
                result += "期号为空 ";
            }
            else
            {
                if (zwqk.qh.Length < 2)
                {
                    zwqk.qh = "0" + zwqk.qh;
                }
            }

            /* 排序前提下的本地查重 */
            if (result.Equals(String.Empty))
            {
                if (null != prevPM)
                {
                    if (prevPM.sybm.Equals(zwqk.sybm) && prevPM.nf.Equals(zwqk.nf)
                        && prevPM.qh.Equals(zwqk.qh) && prevPM.zwpm.Equals(zwqk.zwpm)
                        && prevPM.ywjm.Equals(zwqk.ywjm))
                    {
                        result += "该篇名存在重复 ";
                        zwqk.isValid = false;
                    }
                }
            }

            /* 更新 */
            prevPM = zwqk;
            zwqk.gxrq = DateTime.Now;

            /* 存在规范好的表,跳过下面操作 */
            if (hasFormatTable)
            {
            #if nodef
                //测试生成所需要的文件
                try
                {
                    if (!File.Exists(fileFolder + zwqk.wjm))
                    {
                        String filePDF = fileFolder + zwqk.wjm;

                        if (!Directory.Exists(Path.GetDirectoryName(filePDF)))
                            Directory.CreateDirectory(Path.GetDirectoryName(filePDF));

                        File.Copy(fileFolder + "exp.pdf", fileFolder + zwqk.wjm);
                    }
                }
                catch
                {
                }
            #endif
                if (!result.Equals(String.Empty))
                {
                    result += pmKeyInfo(pm);
                }

                return result;
            }

            zwqk.wjm = "自动生成";

            if (Empty.Equals(zwqk.ywjm))
            {
                result += "原文件名(PDF全文)为空 ";
            }
            else
            {
            #if nodef
                //测试生成所需要的文件
                try
                {
                    if (!File.Exists(fileFolder + zwqk.ywjm))
                    {
                        String filePDF = fileFolder + zwqk.ywjm;

                        if (!Directory.Exists(Path.GetDirectoryName(filePDF)))
                            Directory.CreateDirectory(Path.GetDirectoryName(filePDF));

                        File.Copy(fileFolder + "exp.pdf", fileFolder + zwqk.ywjm);
                    }
                }
                catch
                {
                }
            #endif
                if (!File.Exists(fileFolder + zwqk.ywjm))
                {
                    result += zwqk.ywjm + " PDF文件不存在 ";
                }
                else
                {
                    /* 查找目录文件,并自动添加该记录 */
                    String folderDir = Path.GetDirectoryName(fileFolder + zwqk.ywjm);
                    if (!dir_hash.ContainsKey(folderDir))
                    {
                        dir_hash.Add(folderDir, 1);
                        /* 存在目录文件 */
                        if (File.Exists(folderDir + "/ml.pdf"))
                        {
                            ZWQK_PM mlPM = new ZWQK_PM();

                            int idx = zwqk.ywjm.LastIndexOf('/');

                            mlPM.ywjm = zwqk.ywjm.Substring(0, idx+1) + "ml.pdf";
                            mlPM.wjm = zwqk.wjm;
                            mlPM.nf = zwqk.nf;
                            mlPM.qh = zwqk.qh;
                            mlPM.zwpm = zwqk.nf + "年第" + zwqk.qh + "期 目录";
                            mlPM.sybm = zwqk.sybm;
                            mlPM.gxrq = zwqk.gxrq;
                            mlPM.dlr = zwqk.dlr;
                            mlPM.isValid = true;
                            mlPM.fillEmptyStringAsNull();

                            mlList.Add(mlPM);
                        }
                    }

                    try
                    {
                        pdf = new PdfReader(fileFolder + zwqk.ywjm);
                        if (null != pdf)
                        {
                            zwqk.ys = pdf.NumberOfPages;
                        }
                        else
                        {
                            zwqk.ys = 0;
                        }
                        pdf.Close();
                    }
                    catch
                    {
                        result += zwqk.ywjm + " PDF文件打开错误 ";
                    }
                }
            }

            if (!result.Equals(String.Empty))
            {
                result += pmKeyInfo(pm);
            }

            return result;
        }