/// <summary> /// 正则表达式取出内容 2013-07-16 /// </summary> private int GetHashLineContent(string hashline, ref HASHITEM item1) { //从http://torrage.com/sync下载的文件解析 if (hashline.Length < 50) { if (hashline.Length == 40) { item1.hashKey = hashline.Trim(); item1.recvTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); item1.recvIp = "127.0.0.1"; item1.recvPort = 8080; return(1); } else { } } else { //自己定义的文件格式下载 string pattern = @"ash\[(.*)\] Time\#(.*)\# ip\:(.*)\:(.*)\.(.*)\#"; Match usermatch = Regex.Match(hashline, pattern, RegexOptions.IgnoreCase); if (usermatch.Groups.Count >= 4 && recvthreadison) { item1.hashKey = usermatch.Groups[1].Value.ToString(); item1.recvTime = Convert.ToDateTime(usermatch.Groups[2].Value.ToString()); item1.recvIp = usermatch.Groups[3].Value.ToString(); item1.recvPort = Convert.ToInt32(usermatch.Groups[4].Value.ToString()); return(1); } } return(0); }
/// <summary> /// ����һ��HASH��¼ /// </summary> public static int AddNewHash(HASHTYPE thetype,HASHITEM thehash,int thedetailID,int isHanzhi) { try { StringBuilder strSql = new StringBuilder(); { //��ӹ����ƻ� string tempstr = string.Format("insert into H31_DHT_TYPE_{0}_{1} (", (int)thetype * 100 + 1, isHanzhi); strSql.Append(tempstr); strSql.Append("hashKey,recvTime,updateTime,keyContent,KeyWords,keyType,recvTimes,fileCnt,filetotalSize,Detail)"); strSql.Append(" values ("); strSql.Append("@hashKey,@recvTime,@updateTime,@keyContent,@KeyWords,@keyType,@recvTimes,@fileCnt,@filetotalSize,@Detail)"); DbParameter[] cmdParms = { dbsql.CreateInDbParameter("@hashKey",DbType.String,40,thehash.hashKey), dbsql.CreateInDbParameter("@recvTime", DbType.DateTime,thehash.recvTime), dbsql.CreateInDbParameter("@updateTime", DbType.DateTime,thehash.recvTime), dbsql.CreateInDbParameter("@keyContent", DbType.String,thehash.keyContent), dbsql.CreateInDbParameter("@KeyWords", DbType.String,thehash.keyWords), dbsql.CreateInDbParameter("@keyType", DbType.Int32,thehash.keyType), dbsql.CreateInDbParameter("@recvTimes", DbType.Int32,thehash.recvTimes), dbsql.CreateInDbParameter("@fileCnt", DbType.Int32,thehash.fileCnt), dbsql.CreateInDbParameter("@filetotalSize", DbType.Double,Convert.ToDouble(thehash.filetotalSize)), dbsql.CreateInDbParameter("@Detail", DbType.Int32,thedetailID) }; int res=dbsql.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms); if (res == 1) { string tempstr2 = string.Format("select top 1 id from H31_DHT_TYPE_{0}_{1} where hashKey='{2}' order by id desc", (int)thetype * 100 + 1, isHanzhi, thehash.hashKey); object countid = dbsql.ExecuteScalar(CommandType.Text, tempstr2.ToString(), null); if (countid == null) return 0; return (int)countid; } } } catch (System.Exception ex) { H31Debug.PrintLn(ex.StackTrace); } return -1; }
/// <summary> /// 读取线程 2013-06-16 /// </summary> private void GetTheDataDelegate() { if (recvthreadison) { try { MainStatusText.Text = string.Format("开始读取:{0}", DateTime.Now.ToString()); if (m_reader==null) { int res2=GetOneFileDataToMDB(); if (m_reader != null) { m_reader.Close(); m_reader.Dispose(); } } m_reader = new StreamReader(m_localPath+"\\"+m_readFilename, Encoding.Default); long pos = m_reader.BaseStream.Seek(m_readPos, SeekOrigin.Begin); Int32 ticktime1 = System.Environment.TickCount; string[] strlist = new string[100]; string str1 = m_reader.ReadLine(); int i = 0; while (i < 100 && str1 != null) { if (str1.Length > 1) { if (str1.Length == 40) m_readPos = m_readPos + str1.Length+1; else m_readPos = m_readPos + str1.Length + 5; strlist[i] = str1; i++; } str1 = m_reader.ReadLine(); } m_reader.Close(); m_doWorkCnt = m_doWorkCnt + i; int value1=Convert.ToInt32(m_readPos / 100); MainProgressBar.Value = value1 > MainProgressBar.Maximum ? MainProgressBar.Maximum : value1; Int32 ticktime2 = System.Environment.TickCount; if (m_doWorkCnt % 10000 == 0) { SaveSetting(); LogTheAction(0, 1, "存储到BadList" + m_downBadList.Count.ToString() + "个成功."); } if (i == 0) { LogTheAction(0, 1,m_readFilename+ "读取文件完成"); m_fileOKList[m_readFilename] = m_readPos; int res2 = GetOneFileDataToMDB(); recvthreadison = false; return; } //开始处理 for (int k = 0; k < i&&recvthreadison; k++) { HASHITEM item1 = new HASHITEM(); int res11=GetHashLineContent(strlist[k], ref item1); if(res11==1) { if (m_downBadList.ContainsKey(item1.hashKey)) continue; Int32 ticktime3 = System.Environment.TickCount; //先检查数据库里面是否有这一条,如果没有则需要插入,如果有,则需要直接更新次数和日志表 int tableid = 0; int keytype = 0; int ishanzi = 0; if (m_downOKList.ContainsKey(item1.hashKey)) { keytype = m_downOKList[item1.hashKey] / 1000; continue; } //int res2 = H31SQL.CheckHashItemExist(item1.hashKey, ref keytype, ref tableid,ref ishanzi); //if (tableid > 0) //{ // H31SQL.UpdateHashCount(keytype, item1, tableid,ishanzi); // m_downOKList[item1.hashKey] = keytype; // Int32 ticktime4 = System.Environment.TickCount; // //LogTheAction(2, 2, ">>>>" + item1.hashKey + "更新到数据库" + item1.keyType.ToString() + "成功" + keytype.ToString() + "TIME:" + (ticktime2 - ticktime1).ToString() + "-" + (ticktime4 - ticktime3).ToString()); //} //else { Int32 ticktime4 = System.Environment.TickCount; //插入一条数据 HASHFILEITEM[] filelist=null; int res=GetHashDetail(item1.hashKey, ref item1, ref filelist); if (res==0||(res==1&&item1.keyContent.Contains("�"))) continue; Int32 ticktime5 = System.Environment.TickCount; if (filelist!=null&&res == 1 &&filelist.Length <= MAX_FILEDETAIL_COUNT) { item1.keyWords = ""; ishanzi = ISChineseAndEnglist(item1.keyContent); int hashID = H31SQL.AddNewHash((HASHTYPE)item1.keyType, item1, m_nowTableID,ishanzi); Int32 ticktime6 = System.Environment.TickCount; if (hashID > 0) { m_downOKList[item1.hashKey] = item1.keyType*1000+10+ishanzi; int real_add = 0; for (int m = 0; m < filelist.Length; m++) { filelist[m].hashID = hashID; filelist[m].recvTime = item1.recvTime; if (filelist[m].filesize == 0 || (filelist[m].filename).ToLower().Contains("Thumbs.db")) continue; int dotpos = filelist[m].filename.LastIndexOf('.'); string str2 = filelist[m].filename.Substring(dotpos+1, filelist[m].filename.Length - dotpos-1); if (str2.ToLower() == "url") continue; string str3 = filelist[m].filename.Substring(filelist[m].filename.Length - 1, 1); if (str3 == "_") continue; if ((item1.keyType == (int)HASHTYPE.MOVIE||filelist.Length>30) && (str2.ToLower() == "mht" || str2.ToLower() == "html" || str2.ToLower() == "htm" || str2.ToLower() == "txt")) continue; filelist[m].filename = GetOneGoodString(filelist[m].filename); int resid = H31SQL.AddNewHashDetail(item1.keyType, filelist[m], m_nowTableID); real_add = real_add+1; } m_nowTableCount = m_nowTableCount + real_add; GetDetailFileTableID(); Int32 ticktime7 = System.Environment.TickCount; LogTheAction(2, 1, ">>>>"+item1.keyContent + "插入数据库" + (item1.keyType*1000+10+ishanzi).ToString()+ "成功" + filelist.Length.ToString()+"个文件 TIME:"+ (ticktime2 - ticktime1).ToString() + "-" + (ticktime4 - ticktime3).ToString() + "-" + (ticktime5 - ticktime4).ToString() + "-" + (ticktime6 - ticktime5).ToString() + "-" + (ticktime7 - ticktime6).ToString()); } } } Application.DoEvents(); //让系统在百忙之中来响应其他事件 } } } catch (System.Exception ex) { H31Debug.PrintLn("GetTheDataDelegate:" + ex.StackTrace); } } else { Thread.Sleep(100); isFirstTimeCheck = true; } this.Text = "已经读取"+ m_readFilename+":"+ m_doWorkCnt.ToString() + "行"; MainStatusText.Text = string.Format("读取完成:{0}", DateTime.Now.ToString()); recvthreadison = false; }
/// <summary> /// 正则表达式取出内容 2013-07-16 /// </summary> private int GetHashLineContent(string hashline, ref HASHITEM item1) { if (hashline.Length < 50) { if (hashline.Length == 40) { item1.hashKey = hashline.Trim(); item1.recvTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); item1.recvIp = "127.0.0.1"; item1.recvPort = 8080; return 1; } else { int a = 0; } } else { string pattern = @"ash\[(.*)\] Time\#(.*)\# ip\:(.*)\:(.*)\."; Match usermatch = Regex.Match(hashline, pattern, RegexOptions.IgnoreCase); if (usermatch.Groups.Count == 0) { pattern = @"ash\[(.*)\] Time\#(.*)\# ip\:(.*)\:(.*)\.(.*)\#"; usermatch = Regex.Match(hashline, pattern, RegexOptions.IgnoreCase); } if (usermatch.Groups.Count >= 4 && recvthreadison) { item1.hashKey = usermatch.Groups[1].Value.ToString(); item1.recvTime = Convert.ToDateTime(usermatch.Groups[2].Value.ToString()); item1.recvIp = usermatch.Groups[3].Value.ToString(); item1.recvPort = Convert.ToInt32(usermatch.Groups[4].Value.ToString()); return 1; } } return 0; }
/// <summary> /// 读取线程 2013-06-16 /// </summary> private int GetHashDetail(string hashname, ref HASHITEM item1, ref HASHFILEITEM[] filelist) { Int32 ticktime1 = System.Environment.TickCount; try { int res1 = 0; TorrentFile myFile = null; if (checkBox_Torrent.Checked) { res1 = m_downLoad.DownLoadFileByHashToFile(hashname); Application.DoEvents(); //让系统在百忙之中来响应其他事件 if (res1 == 1) { string filename = m_localPath+"\\Torrent\\" +hashname.Substring(hashname.Length-1,1)+"\\"+ hashname + ".torrent"; myFile = new TorrentFile(filename); Int32 ticktime2 = System.Environment.TickCount; if (myFile == null || myFile.TorrentName.Length == 0) { m_downBadList[hashname] = System.Environment.TickCount / 1000; if (checkBox_Torrent.Checked) { //File.Delete(filename); File.Move(filename, m_localPath + "\\Torrent\\BAD\\" + hashname + ".torrent"); LogTheAction(1, 1, hashname + "下载文件不对,删除" + "-" + (ticktime2 - ticktime1).ToString()); } return 0; } } } else { byte[] data = m_downLoad.DownLoadFileByHashToByte(hashname); if (data != null) res1 = 1; myFile = new TorrentFile(data); } if (res1 == 1) { if (myFile == null || myFile.TorrentName.Length == 0 || myFile.TorrentFileInfo.Count == 0 || myFile.TorrentFileInfo.Count > MAX_FILEDETAIL_COUNT) { Int32 ticktime2 = System.Environment.TickCount; LogTheAction(1, 2, hashname + ">>下载成功,但使用失败." + "-" + (ticktime2 - ticktime1).ToString()); m_downBadList[hashname] = System.Environment.TickCount / 1000; return 0; } else { item1.keyType=(int)GetHashFileKeyType(ref myFile); item1.fileCnt = myFile.TorrentFileInfo.Count; item1.filetotalSize = myFile.TorrentPieceLength; item1.keyContent = GetOneGoodString(myFile.TorrentName); filelist = new HASHFILEITEM[myFile.TorrentFileInfo.Count]; for (int m = 0; m < myFile.TorrentFileInfo.Count; m++) { filelist[m].filename = myFile.TorrentFileInfo[m].Path; filelist[m].filesize = myFile.TorrentFileInfo[m].Length; } Int32 ticktime2 = System.Environment.TickCount; LogTheAction(1, 3, myFile.TorrentName + ">>下载成功:" + myFile.TorrentFileInfo.Count + "-" + (ticktime2 - ticktime1).ToString()); return 1; } } else { Int32 ticktime2 = System.Environment.TickCount; m_downBadList[hashname] = System.Environment.TickCount / 1000; LogTheAction(1, 4, hashname + ">>下载失败" + "-" + (ticktime2 - ticktime1).ToString()); } } catch (System.Exception ex) { //错误日志记录 H31Debug.PrintLn("GetHashDetail:" + ex.StackTrace); } return 0; }
/// <summary> /// 下载种子文件并进行解析读取 /// </summary> private int GetDownAndReaHashDetail(string hashname, ref HASHITEM item1, ref HASHFILEITEM[] filelist) { Int32 ticktime1 = System.Environment.TickCount; try { int res1 = 0; TorrentFile myFile = null; if (checkBox_Torrent.Checked) { res1 = m_downLoad.DownLoadFileByHashToFile(hashname); Application.DoEvents(); //让系统在百忙之中来响应其他事件 if (res1 == 1) { string filename = Path.Combine(Path.Combine(Path.Combine(m_localPath, "Torrent"), hashname.Substring(hashname.Length - 2, 2)), hashname + ".torrent"); myFile = new TorrentFile(filename); Int32 ticktime2 = System.Environment.TickCount; if (myFile == null || myFile.TorrentName.Length == 0) { m_downBadList[hashname] = System.Environment.TickCount / 1000; //解析不了的文件就直接备份 if (checkBox_Torrent.Checked) { File.Move(filename, Path.Combine(Path.Combine(m_localPath, "Torrent\\BAD"), hashname + ".torrent")); LogTheAction(1, 1, hashname + "下载文件不对,删除" + "-" + (ticktime2 - ticktime1).ToString()); } return(0); } } } else { //不用存储文件,直接在内存中操作 byte[] data = m_downLoad.DownLoadFileByHashToByte(hashname); if (data != null) { res1 = 1; } myFile = new TorrentFile(data); } //如果解析成功就进行赋值返回 if (res1 == 1) { if (myFile == null || myFile.TorrentName.Length == 0 || myFile.TorrentFileInfo.Count == 0 || myFile.TorrentFileInfo.Count > MAX_FILEDETAIL_COUNT) { Int32 ticktime2 = System.Environment.TickCount; LogTheAction(1, 2, hashname + ">>下载成功,但使用失败." + "-" + (ticktime2 - ticktime1).ToString()); m_downBadList[hashname] = System.Environment.TickCount / 1000; return(0); } else { //通过文件列表对文件是哪类进行分析判断 item1.keyType = (int)GetHashFileKeyType(ref myFile); item1.fileCnt = myFile.TorrentFileInfo.Count; item1.filetotalSize = myFile.TorrentPieceLength; //提取正确的文件名字,过滤一些网址信息 item1.keyContent = GetOneGoodString(myFile.TorrentName); filelist = new HASHFILEITEM[myFile.TorrentFileInfo.Count]; for (int m = 0; m < myFile.TorrentFileInfo.Count; m++) { filelist[m].filename = myFile.TorrentFileInfo[m].Path; filelist[m].filesize = myFile.TorrentFileInfo[m].Length; } Int32 ticktime2 = System.Environment.TickCount; LogTheAction(1, 3, myFile.TorrentName + ">>下载成功:" + myFile.TorrentFileInfo.Count + "-" + (ticktime2 - ticktime1).ToString()); return(1); } } else { Int32 ticktime2 = System.Environment.TickCount; m_downBadList[hashname] = System.Environment.TickCount / 1000; LogTheAction(1, 4, hashname + ">>下载失败" + "-" + (ticktime2 - ticktime1).ToString()); } } catch (System.Exception ex) { H31Debug.PrintLn("GetHashDetail:" + ex.StackTrace); } return(0); }
/// <summary> /// 读取线程主函数 2013-06-16 /// </summary> private void GetTheDataDelegate() { if (recvthreadison) { //检测网络状态 if (!isConnected()) { LogTheAction(0, 1, "网络不通,请等待."); recvthreadison = false; return; } try { MainStatusText.Text = string.Format("开始读取:{0}", DateTime.Now.ToString()); if (m_reader == null) { int res2 = GetOneFileDataToMDB(); if (m_reader != null) { m_reader.Close(); m_reader.Dispose(); } } if (string.IsNullOrEmpty(m_readFilename)) { return; } //定位到上次文件读取的地方 m_reader = new StreamReader(Path.Combine(resourceDir, m_readFilename), Encoding.Default); long pos = m_reader.BaseStream.Seek(m_readPos, SeekOrigin.Begin); Int32 ticktime1 = System.Environment.TickCount; string[] strlist = new string[100]; string str1 = m_reader.ReadLine(); int i = 0; while (i < 100 && str1 != null) { if (str1.Length > 1) { if (str1.Length == 40) { m_readPos = m_readPos + str1.Length + 1; } else { m_readPos = m_readPos + str1.Length + 4; } strlist[i] = str1; i++; } str1 = m_reader.ReadLine(); } m_reader.Close(); m_doWorkCnt = m_doWorkCnt + i; int value1 = Convert.ToInt32(m_readPos / 100); MainProgressBar.Value = value1 > MainProgressBar.Maximum ? MainProgressBar.Maximum : value1; Int32 ticktime2 = System.Environment.TickCount; if (m_doWorkCnt % 10000 == 0) { SaveSetting(); LogTheAction(0, 1, "存储到BadList" + m_downBadList.Count.ToString() + "个成功."); } if (i == 0) { LogTheAction(0, 1, m_readFilename + "读取文件完成"); m_fileOKList[m_readFilename] = m_readPos; int res2 = GetOneFileDataToMDB(); recvthreadison = false; return; } //开始处理那么多条HASH for (int k = 0; k < i && recvthreadison; k++) { HASHITEM item1 = new HASHITEM(); //通过正则表达式获取几种不同类型的HASH文件 int res11 = GetHashLineContent(strlist[k], ref item1); if (res11 == 1) { if (m_downBadList.ContainsKey(item1.hashKey)) { continue; } Int32 ticktime3 = System.Environment.TickCount; int detailTableid = 0; int keytype = 0; int ishanzi = 0; bool findexist = false; //先检查本地HASH列表里面是否有,没有就查询数据库里面是否有这一条,如果没有则需要插入,如果有,则需要直接更新次数和日志表 if (m_downOKList.ContainsKey(item1.hashKey)) { if (m_downOKList[item1.hashKey] > 0) { findexist = true; keytype = m_downOKList[item1.hashKey] / 1000; detailTableid = m_downOKList[item1.hashKey] / 10 % 100; ishanzi = m_downOKList[item1.hashKey] % 10; } } if (findexist == false) { int res2 = H31SQL.CheckHashItemExist(item1.hashKey, ref keytype, ref detailTableid, ref ishanzi); } if (detailTableid > 0) { H31SQL.UpdateHashCount(keytype, item1, detailTableid, ishanzi); m_downOKList[item1.hashKey] = keytype * 1000 + detailTableid * 10 + ishanzi; Int32 ticktime4 = System.Environment.TickCount; //LogTheAction(2, 2, ">>>>" + item1.hashKey + "更新到数据库" + item1.keyType.ToString() + "成功" + keytype.ToString() + "TIME:" + (ticktime2 - ticktime1).ToString() + "-" + (ticktime4 - ticktime3).ToString()); } else { Int32 ticktime4 = System.Environment.TickCount; HASHFILEITEM[] filelist = null; //首先去下载种子文件并进行读取 int res = GetDownAndReaHashDetail(item1.hashKey, ref item1, ref filelist); if (res == 0 || (res == 1 && item1.keyContent.Contains("�"))) { continue; } Int32 ticktime5 = System.Environment.TickCount; if (filelist != null && res == 1 && filelist.Length <= MAX_FILEDETAIL_COUNT) { item1.keyWords = ""; ishanzi = ISChineseAndEnglist(item1.keyContent); //插入新的一条HASH数据 int hashID = H31SQL.AddNewHash((HASHTYPE)item1.keyType, item1, m_nowTableID, ishanzi); Int32 ticktime6 = System.Environment.TickCount; if (hashID > 0) { m_downOKList[item1.hashKey] = item1.keyType * 1000 + m_nowTableID * 10 + ishanzi; int real_add = 0; //插入文件列表 for (int m = 0; m < filelist.Length; m++) { filelist[m].hashID = hashID; filelist[m].recvTime = item1.recvTime; //过滤一些没有用的介绍性文件 if (filelist[m].filesize == 0 || (filelist[m].filename).ToLower().Contains("Thumbs.db")) { continue; } int dotpos = filelist[m].filename.LastIndexOf('.'); string str2 = filelist[m].filename.Substring(dotpos + 1, filelist[m].filename.Length - dotpos - 1); if (str2.ToLower() == "url") { continue; } string str3 = filelist[m].filename.Substring(filelist[m].filename.Length - 1, 1); if (str3 == "_") { continue; } //如果是视频就直接不需要一些文件 if ((item1.keyType == (int)HASHTYPE.MOVIE || filelist.Length > 30) && (str2.ToLower() == "mht" || str2.ToLower() == "html" || str2.ToLower() == "htm" || str2.ToLower() == "txt")) { continue; } //过滤文件名字中的网址 filelist[m].filename = GetOneGoodString(filelist[m].filename); int resid = H31SQL.AddNewHashDetail(item1.keyType * 1000 + 10 + ishanzi, filelist[m], m_nowTableID); real_add = real_add + 1; } m_nowTableCount = m_nowTableCount + real_add; GetDetailFileTableID(); Int32 ticktime7 = System.Environment.TickCount; LogTheAction(2, 1, ">>>>" + item1.keyContent + "插入数据库" + (item1.keyType * 1000 + 10 + ishanzi).ToString() + "成功" + filelist.Length.ToString() + "个文件 TIME:" + (ticktime2 - ticktime1).ToString() + "-" + (ticktime4 - ticktime3).ToString() + "-" + (ticktime5 - ticktime4).ToString() + "-" + (ticktime6 - ticktime5).ToString() + "-" + (ticktime7 - ticktime6).ToString()); } } } Application.DoEvents(); //让系统在百忙之中来响应其他事件 } } } catch (System.Exception ex) { H31Debug.PrintLn("GetTheDataDelegate:" + ex.StackTrace); } } else { Thread.Sleep(100); isFirstTimeCheck = true; } this.Text = "已经读取" + m_readFilename + ":" + m_doWorkCnt.ToString() + "行"; MainStatusText.Text = string.Format("读取完成:{0}", DateTime.Now.ToString()); recvthreadison = false; }
/// <summary> /// 增加一条HASH纪录的日志文件 /// </summary> public static int AddNewHashLOG(HASHITEM thehash, int thedetailID) { try { StringBuilder strSql = new StringBuilder(); { ////添加工作计划 //string tempstr = string.Format("insert into H31_DHT_TYPE{0} (", thedetailID); //strSql.Append(tempstr); //strSql.Append("hashKey,recvTime,updateTime,keyContent,KeyWords,keyType,recvTimes,fileCnt,filetotalSize,Detail)"); //strSql.Append(" values ("); //strSql.Append("@hashKey,@recvTime,@updateTime,@keyContent,@KeyWords,@keyType,@recvTimes,@fileCnt,@filetotalSize,@Detail)"); //DbParameter[] cmdParms = { //dbsql.CreateInDbParameter("@hashKey",DbType.String,40,thehash.hashKey), //dbsql.CreateInDbParameter("@recvTime", DbType.DateTime,thehash.recvTime), //dbsql.CreateInDbParameter("@updateTime", DbType.DateTime,thehash.recvTime), //dbsql.CreateInDbParameter("@keyContent", DbType.String,thehash.keyContent), //dbsql.CreateInDbParameter("@KeyWords", DbType.String,thehash.keyWords), //dbsql.CreateInDbParameter("@keyType", DbType.Int32,thehash.keyType), //dbsql.CreateInDbParameter("@recvTimes", DbType.Int32,thehash.recvTimes), //dbsql.CreateInDbParameter("@fileCnt", DbType.Int32,thehash.fileCnt), //dbsql.CreateInDbParameter("@filetotalSize", DbType.Int32,thehash.filetotalSize), //dbsql.CreateInDbParameter("@Detail", DbType.Int32,thedetailID) //}; //return dbsql.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms); } } catch (System.Exception ex) { H31Debug.PrintLn(ex.StackTrace); } return -1; }
/// <summary> /// 更新HASH纪录次 /// </summary> public static int UpdateHashCount(int thetype, HASHITEM thehash, int thedetailID, int isHanzhi) { try { StringBuilder strSql = new StringBuilder(); string tempstr = string.Format("update H31_DHT_TYPE_{0}_{1} set recvTimes=recvTimes+1 where hashKey='{2}'", thetype*100+1,isHanzhi, thehash.hashKey); strSql.Append(tempstr); return dbsql.ExecuteNonQuery(CommandType.Text, strSql.ToString(), null); } catch (System.Exception ex) { H31Debug.PrintLn(ex.StackTrace); } return -1; }