/// <summary> /// 生成日志信息 /// </summary> /// <param name="zwqkPM">中文篇名信息</param> /// <param name="opType">操作类型</param> /// <param name="uname">用户名</param> /// <returns></returns> private OperationLogItem GetOperationLogItem(ZWQK_PM zwqkPM, String opType, String uname) { if (null == zwqkPM) { return null; } OperationLogItem operationLogItem = new OperationLogItem(); //操作类型 operationLogItem.opType = opType; //数据库表 operationLogItem.opTable = "ZWQK_PM"; //全文页数 operationLogItem.opPageCount = zwqkPM.ys; operationLogItem.opObjectID = "中文期刊"; // 操作涉及的书刊 operationLogItem.opBookIn = "中文期刊"; // 时间 operationLogItem.opDate = DateTime.Now; // 操作员 operationLogItem.opPerson = uname; //记录操作模式,判断是否属于批量操作。取值范围SINGLE/BATCH。 operationLogItem.opMode = "SINGLE"; //操作的内容 String content = "('" + zwqkPM.sybm + "','" + zwqkPM.wjm + "','" + zwqkPM.ywjm + "','" + zwqkPM.nf + "','" + zwqkPM.qh + "','" + zwqkPM.zwpm + "','" + zwqkPM.wwpm + "','" + zwqkPM.zz + "','" + zwqkPM.zzdw + "','" + zwqkPM.kb + "','" + zwqkPM.ys + "','" + zwqkPM.zwwz + "','" + zwqkPM.zwztc + "','" + zwqkPM.wwwz + "','" + zwqkPM.wwztc + "','" + zwqkPM.gtfl + "','" + zwqkPM.wxbs + "','" + zwqkPM.dlr + "','" + zwqkPM.gxrq + "')"; operationLogItem.opContent = content; return operationLogItem; }
/// <summary> /// 插入中文期刊篇名信息。 /// </summary> /// <param name="pm"></param> public void insertZwqkPM(ZWQK_PM pm) { String startYear, endYear; OperationLogItem operationLog = null; operationLog = this.GetOperationLogItem(pm, "INSERT", pm.dlr); if (null != operationLog) { this.operationLogDAO.insertLogItem(operationLog); } sqlMapper.Insert("InsertZWQK_PM", pm); ZWQK_SYML syml = this.getZwqkSYMLBySybm(pm.sybm); if (syml == null) { return; } try { startYear = syml.slnf.Substring(0, 4); endYear = syml.slnf.Substring(5, 4); bool changed = false; if (pm.nf.CompareTo(startYear) < 0) { syml.slnf = pm.nf + syml.slnf.Substring(4); changed = true; } else if (pm.nf.CompareTo(endYear) > 0) { syml.slnf = syml.slnf.Substring(0, 5) + pm.nf; syml.zxnf = int.Parse(pm.nf); changed = true; } if (changed) { this.updateZwqkSYMLBySYBM(syml); } } catch { return; } }
/// <summary> /// 按文件名更新篇名信息。 /// 文件名为主键。 /// </summary> /// <param name="pm"></param> /// <returns></returns> public bool updateZwqkPMByWJM(ZWQK_PM pm, String uname) { OperationLogItem operationLog = null; operationLog = this.GetOperationLogItem(pm, "UPDATE", uname); bool result; try { sqlMapper.BeginTransaction(); sqlMapper.Update("UpdateZWQK_PM", pm); sqlMapper.CommitTransaction(); this.operationLogDAO.insertLogItem(operationLog); result = true; } catch { sqlMapper.RollBackTransaction(); result = false; } return result; }
private bool IsZwqkEqual(ZWQK_PM a, ZWQK_PM b) { bool ret = false; if (null != a.zwpm && !"".Equals(a.zwpm) && !"NULL".Equals(a.zwpm)) { if (a.zwpm.Equals(b.zwpm)) ret = true; } else if (null != a.wwpm && !"".Equals(a.wwpm) && !"NULL".Equals(a.wwpm)) { if (a.wwpm.Equals(b.wwpm)) ret = true; } return ret; }
/// <summary> /// 从页面中读取片名的信息 /// </summary> /// <returns>返回片名对象</returns> private ZWQK_PM GetZWQK_PM() { User user = (User)Session["login"]; //登陆超时则退到登录页 if (null == user) { Response.Write(" <script> top.location = '" + GlobalResource.LOGIN_PAGE + "' </script> "); return null; } ZWQK_PM zwqkPM = new ZWQK_PM(); //登录人 zwqkPM.dlr = user.name; //索引编码 zwqkPM.sybm = this.sybmTextBox.Text.Trim(); //年份 zwqkPM.nf = this.nfTextBox.Text.Trim(); //期号 zwqkPM.qh = this.qhTextBox.Text.Trim(); //页数 try { zwqkPM.ys = Int32.Parse(this.ysTextBox.Text.Trim()); } catch (Exception) { } //文件名 zwqkPM.wjm = this.wjmHyperLink.Text.Trim(); //原文件名 zwqkPM.ywjm = this.ywjmHiddenField.Value.Trim(); //中文篇名 zwqkPM.zwpm = this.zwpmTextBox.Text.Trim(); //外文篇名 zwqkPM.wwpm = this.wwpmTextBox.Text.Trim(); //作者 zwqkPM.zz = this.zzTextBox.Text.Trim(); //作者单位 zwqkPM.zzdw = this.zzdwTextBox.Text.Trim(); //开本 zwqkPM.kb = this.kbTextBox.Text.Trim(); //中文文摘 zwqkPM.zwwz = this.zwwzTextBox.Text.Trim(); //外文文摘 zwqkPM.wwwz = this.wwwzTextBox.Text.Trim(); //中文主题词 zwqkPM.zwztc = this.zwztcTextBox.Text.Trim(); //外文主题词 zwqkPM.wwztc = this.wwztcTextBox.Text.Trim(); //国图分类 zwqkPM.gtfl = this.gtflTextBox.Text.Trim(); //文献标识 zwqkPM.wxbs = this.wxbsTextBox.Text.Trim(); //更新日期 try { zwqkPM.gxrq = DateTime.Parse(this.gxrqTextBox.Text.Trim()); } catch { zwqkPM.gxrq = DateTime.Today; } return zwqkPM; }
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; }
private String DeleteWF(ZWQK_PM zwqk) { int back; String err = String.Empty; this.openOleDbConnection(); //sql语句 sqlcmd.CommandText = @"delete from " + pmTableName + " where [年]=@年 and [PDF全文]=@PDF全文"; sqlcmd.Connection = this.ObjConnection; sqlcmd.Parameters.Add(new OleDbParameter("年", zwqk.nf)); sqlcmd.Parameters.Add(new OleDbParameter("PDF全文", zwqk.wjm_old)); if (null != zwqk.zwpm && !zwqk.zwpm.Equals("NULL") && !zwqk.zwpm.Equals("")) { sqlcmd.CommandText += " and [论文标题]=@论文标题"; sqlcmd.Parameters.Add(new OleDbParameter("论文标题", zwqk.zwpm)); } else if (null != zwqk.wwpm && !zwqk.wwpm.Equals("NULL") && !zwqk.wwpm.Equals("")) { sqlcmd.CommandText += " and [英文标题E]=@英文标题E"; sqlcmd.Parameters.Add(new OleDbParameter("英文标题E", zwqk.wwpm)); } try { back = sqlcmd.ExecuteNonQuery(); } catch (Exception e) { err = "删除万方记录异常(" + e.Message + ")" + pmKeyInfo(zwqk); } sqlcmd.Parameters.Clear(); return err; }
public override String insertPMwithUpdateWJM(PM pm) { String err = String.Empty; ZWQK_PM zwqk = (ZWQK_PM)pm; int index; index = zwqk.ywjm.LastIndexOf('/'); if (index < 0) index = -1; int serial; if ("ml".Equals(zwqk.ywjm.Substring(index + 1, 2)) || isOldML(zwqk.wjm)) { serial = 0; } else { /* 与上一篇属于同一年份和同一期刊号 */ if (null != prevPM && prevPM.sybm.Equals(zwqk.sybm) && prevPM.nf.Equals(zwqk.nf) && prevPM.qh.Equals(zwqk.qh) && !prevPM.wjm.Equals("自动生成")) { int pos = prevPM.wjm.LastIndexOf('-'); serial = int.Parse(prevPM.wjm.Substring(pos + 1, 3)) + 1; } else { string snq = zwqk.sybm + zwqk.nf + zwqk.qh; if (sybm_nf_qh_hash.ContainsKey(snq)) { if (null == sybm_nf_qh_hash[snq]) serial = 1; else { ZWQK_PM maxPM = ((IList<ZWQK_PM>)sybm_nf_qh_hash[snq]).First(); int pos = maxPM.wjm.LastIndexOf('-'); int oldSerial = int.Parse(maxPM.wjm.Substring(pos + 1, 3)); if (oldSerial == 999 && ((IList<ZWQK_PM>)sybm_nf_qh_hash[snq]).Count > 1) { maxPM = ((IList<ZWQK_PM>)sybm_nf_qh_hash[snq])[1]; pos = maxPM.wjm.LastIndexOf('-'); } serial = int.Parse(maxPM.wjm.Substring(pos + 1, 3)) + 1; } } else serial = 1; } } index = zwqk.ywjm.LastIndexOf('.'); String suffixStr; if (index >= 0) suffixStr = zwqk.ywjm.Substring(index); else suffixStr = String.Empty; String serialStr = "0000" + serial.ToString(); if (hasFormatTable) zwqk.wjm_old = zwqk.wjm; /* 进行备份 */ else zwqk.wjm_old = zwqk.ywjm; zwqk.wjm = zwqk.sybm + "-" + zwqk.nf + "-" + zwqk.qh + "-" + serialStr.Substring(serialStr.Length - 3) + suffixStr; index = zwqk.ywjm.LastIndexOf('/'); if (index < 0) index = -1; zwqk.ywjm = zwqk.ywjm.Substring(index+1); try { zwqkDAO.insertZwqkPM(zwqk); } catch (Exception e) { err += "主库插入记录异常(" + e.Message + ")" + pmKeyInfo(pm); } /* 进行更新 */ prevPM = zwqk; return err; }
/// <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; }
public string BackupPM(ZWQK_PM zwqk, String tblName) { string err = String.Empty; int back; //打开连接 this.openOleDbConnection(); if (!tblHash.ContainsKey(tblName)) { return "表\"" + tblName + "\"不存在" + pmKeyInfo(zwqk); } //sql语句 sqlcmd.CommandText = @"insert into " + tblName + @"(索引编码,文件名,原文件名,年份,期号,中文篇名,外文篇名,作者,作者单位,开本,页数,中文文摘,外文文摘,中文主题词,外文主题词,国图分类,文献标识,登录人,更新日期) values(@索引编码,@文件名,@原文件名,@年份,@期号,@中文篇名,@外文篇名,@作者,@作者单位,@开本,@页数,@中文文摘,@外文文摘,@中文主题词,@外文主题词,@国图分类,@文献标识,@登录人,@更新日期)"; sqlcmd.Connection = this.ObjConnection; sqlcmd.Parameters.Add(new OleDbParameter("索引编码", zwqk.sybm)); sqlcmd.Parameters.Add(new OleDbParameter("文件名", zwqk.wjm)); sqlcmd.Parameters.Add(new OleDbParameter("原文件名", zwqk.ywjm)); sqlcmd.Parameters.Add(new OleDbParameter("年份", zwqk.nf)); sqlcmd.Parameters.Add(new OleDbParameter("期号", zwqk.qh)); sqlcmd.Parameters.Add(new OleDbParameter("中文篇名", zwqk.zwpm)); sqlcmd.Parameters.Add(new OleDbParameter("外文篇名", zwqk.wwpm)); sqlcmd.Parameters.Add(new OleDbParameter("作者", zwqk.zz)); sqlcmd.Parameters.Add(new OleDbParameter("作者单位", zwqk.zzdw)); sqlcmd.Parameters.Add(new OleDbParameter("开本", zwqk.kb)); sqlcmd.Parameters.Add(new OleDbParameter("页数", zwqk.ys)); sqlcmd.Parameters.Add(new OleDbParameter("中文文摘", zwqk.zwwz)); sqlcmd.Parameters.Add(new OleDbParameter("外文文摘", zwqk.wwwz)); sqlcmd.Parameters.Add(new OleDbParameter("中文主题词", zwqk.zwztc)); sqlcmd.Parameters.Add(new OleDbParameter("外文主题词", zwqk.wwztc)); sqlcmd.Parameters.Add(new OleDbParameter("国图分类", zwqk.gtfl)); sqlcmd.Parameters.Add(new OleDbParameter("文献标识", zwqk.wxbs)); sqlcmd.Parameters.Add(new OleDbParameter("登录人", zwqk.dlr)); OleDbParameter parameter = new OleDbParameter("更新日期", OleDbType.DBDate); parameter.Value = zwqk.gxrq; sqlcmd.Parameters.Add(parameter); try { back = sqlcmd.ExecuteNonQuery(); } catch (Exception e) { err = "插入表\"" + tblName + "\"异常(" + e.Message + ")" + pmKeyInfo(zwqk); } sqlcmd.Parameters.Clear(); return err; }
/// <summary> /// 插入中文期刊篇名信息。 /// </summary> /// <param name="pm"></param> public void insertZwqkPM(ZWQK_PM pm) { OperationLogItem operationLog = null; operationLog = this.GetOperationLogItem(pm, "INSERT", pm.dlr); if (null != operationLog) { this.operationLogDAO.insertLogItem(operationLog); } sqlMapper.Insert("InsertZWQK_PM", pm); }
/// <summary> /// 按文件名更新篇名信息。 /// 文件名为主键。 /// </summary> /// <param name="pm"></param> /// <returns></returns> public bool updateZwqkPMByWJM(ZWQK_PM pm, String uname, String newWjm = "") { /* 存在更新Wjm关键词的情况 */ if ("".Equals(newWjm)) { pm.newWjm = pm.wjm; } else pm.newWjm = newWjm; OperationLogItem operationLog = null; operationLog = this.GetOperationLogItem(pm, "UPDATE", uname); bool result; try { sqlMapper.BeginTransaction(); sqlMapper.Update("UpdateZWQK_PM", pm); sqlMapper.CommitTransaction(); this.operationLogDAO.insertLogItem(operationLog); result = true; } catch { sqlMapper.RollBackTransaction(); result = false; } return result; }