static BLL3() { //大类类名 dicBigZhEn.Add("会计", "kj"); dicBigZhEn.Add("司法", "sf"); //其他科目 dicZhEn.Add("马克思", "mks"); dicZhEn.Add("思修", "sx"); dicZhEn.Add("近代史", "jds"); dicZhEn.Add("毛概", "mg"); //英语 dicZhEn.Add("考研英语", "kyyy"); dicZhEn.Add("英语四级", "yysj"); dicZhEn.Add("英语六级", "yylj"); //专业课 dicZhEn.Add("金融题库", "jrtk"); //瓯江 dicZhEn.Add("军事理论", "jsll"); //瓯江 //医学 dicZhEn.Add("胞生题库", "bstk"); dicZhEn.Add("西医综合", "xyzh"); //会计 //dicZhEn.Add("会计考试", "kjks"); //dicZhEn.Add("会计从业2016", "kjcy2016"); dicZhEn.Add("会计电算化", "kjdsh"); dicZhEn.Add("会计基础", "kjjc"); dicZhEn.Add("会计财经法规", "kjcjfg"); dicZhEn.Add("会计信息系统", "kjxxxx"); //司法 //dicZhEn.Add("司法考试", "sfks"); foreach (string zh in dicZhEn.Keys) { dicEnZh.Add(dicZhEn[zh], zh); } foreach (string zh in dicBigZhEn.Keys) { dicBigEnZh.Add(dicBigZhEn[zh], zh); } }
/// <summary> /// 查找 会计 开头的课程 /// </summary> public static AFDictionary <string, string> getSubKcName(string kcName) { AFDictionary <string, string> dic1 = new AFDictionary <string, string>(); foreach (string key in dicEnZh.Keys) { if (key.StartsWith(kcName)) { dic1.Add(key, dicEnZh[key]); } } return(dic1); }
public static AFDictionary <string, TiMuXuanZe> fromTxt(string fileName) { AFDictionary <string, TiMuXuanZe> timulist = new AFDictionary <string, TiMuXuanZe>(); try { if (File.Exists(fileName)) { string content1 = File.ReadAllText(fileName, System.Text.Encoding.Default); content1 = content1.Replace("\r\n", "\n").Replace("\r\n\r\n", ""); string[] clist = StringHelper.Split(content1, "/**********/"); foreach (string s1 in clist) { if (s1.Contains("题型:2")) { } TiMuXuanZe t1 = From(s1); if (t1 != null) { t1.id = (timulist.Count + 1).ToString(); try { if (!timulist.ContainsKey(t1.id)) { timulist.Add(t1.id, t1); } } catch (Exception ex2) { Cs.Error(ex2.ToString()); } } } Cs.Warn(fileName + ",读题目:" + timulist.Count); } } catch (Exception ex) { Cs.Error(ex.ToString()); } return(timulist); }
public static AFDictionary <string, string> getScOld() { if (dic1.Count > 0) { return(dic1); } string sc2sc = @"196=1952 198=1953 205=2042 208=2072 246=2162 235=2252 236=2253 350=3102 351=3103 352=3122 342=3123 360=3202 747=7462 797=7872 795=7912 796=7913 "; foreach (string s1 in sc2sc.Split('\n')) { if (!string.IsNullOrEmpty(s1)) { string[] s2s = s1.Split('='); if (s2s.Length == 2) { if (!dic1.ContainsKey(s2s[0])) { dic1.Add(s2s[0], s2s[1]); } } } } return(dic1); }
public static AFDictionary <string, St_TTimuDaXue> Init(string sc, string kemuId, ref AFDictionary <string, int> dic1) { initDaxue(); readInt++; if (true)//每100次重新加载一次题目。 { if (listMks.Count > 0 && DateTime.Now.Subtract(now1).TotalSeconds < 120) { now1 = DateTime.Now; readInt = 0; return(listMks); } } St_TTimuDaXue cond1 = new St_TTimuDaXue(); cond1.Sc = StringHelper.GetNumeric(sc); cond1.KemuId = Convert.ToInt32(kemuId); List <St_TTimuDaXue> list1 = BLLTable <St_TTimuDaXue> .Select(new St_TTimuDaXue(), cond1); int jj = 0; foreach (St_TTimuDaXue tt in list1) { jj++; listMks.Add(jj.ToString(), tt); } #region 其他题型 AFDictionary <string, St_TTimuDaXue> listMks1 = new AFDictionary <string, St_TTimuDaXue>(); AFDictionary <string, St_TTimuDaXue> listMks2 = new AFDictionary <string, St_TTimuDaXue>(); AFDictionary <string, St_TTimuDaXue> listMks3 = new AFDictionary <string, St_TTimuDaXue>(); AFDictionary <string, St_TTimuDaXue> listMks4 = new AFDictionary <string, St_TTimuDaXue>(); AFDictionary <string, int> list2Mks = new AFDictionary <string, int>(); AFDictionary <string, int> list2Mks1 = new AFDictionary <string, int>(); AFDictionary <string, int> list2Mks2 = new AFDictionary <string, int>(); AFDictionary <string, int> list2Mks3 = new AFDictionary <string, int>(); AFDictionary <string, int> list2Mks4 = new AFDictionary <string, int>(); int i = -1; foreach (string id in listMks.Keys) { i++; list2Mks.Add(id, i); if (listMks[id].OptionType == "0") { listMks1.Add(id, listMks[id]); list2Mks1.Add(id, list2Mks1.Count); } if (listMks[id].OptionType == "1") { listMks2.Add(id, listMks[id]); list2Mks2.Add(id, list2Mks2.Count); } if (listMks[id].OptionType == "2") { listMks3.Add(id, listMks[id]); list2Mks3.Add(id, list2Mks3.Count); } if (listMks[id].OptionType == "3") { listMks4.Add(id, listMks[id]); list2Mks4.Add(id, list2Mks4.Count); } } string file1 = GetFile(sc, kemuId); if (dicDicTiMu.ContainsKey(file1)) { dicDicTiMu[file1] = listMks; } else { dicDicTiMu.Add(file1, listMks); } if (dicDicTiMu1.ContainsKey(file1)) { dicDicTiMu1[file1] = listMks1; } else { dicDicTiMu1.Add(file1, listMks1); } if (dicDicTiMu2.ContainsKey(file1)) { dicDicTiMu2[file1] = listMks2; } else { dicDicTiMu2.Add(file1, listMks2); } if (dicDicTiMu3.ContainsKey(file1)) { dicDicTiMu3[file1] = listMks3; } else { dicDicTiMu3.Add(file1, listMks3); } if (dicDicTiMu4.ContainsKey(file1)) { dicDicTiMu4[file1] = listMks4; } else { dicDicTiMu4.Add(file1, listMks4); } ///// if (dic2DicTiMu.ContainsKey(file1)) { dic2DicTiMu[file1] = list2Mks; } else { dic2DicTiMu.Add(file1, list2Mks); } if (dic2DicTiMu1.ContainsKey(file1)) { dic2DicTiMu1[file1] = list2Mks1; } else { dic2DicTiMu1.Add(file1, list2Mks1); } if (dic2DicTiMu2.ContainsKey(file1)) { dic2DicTiMu2[file1] = list2Mks2; } else { dic2DicTiMu2.Add(file1, list2Mks2); } if (dic2DicTiMu3.ContainsKey(file1)) { dic2DicTiMu3[file1] = list2Mks3; } else { dic2DicTiMu3.Add(file1, list2Mks3); } if (dic2DicTiMu4.ContainsKey(file1)) { dic2DicTiMu4[file1] = list2Mks4; } else { dic2DicTiMu4.Add(file1, list2Mks4); } #endregion 其他题型 if (dicDicTiMu.ContainsKey(file1)) { return(dicDicTiMu[file1]); } if (dic2DicTiMu.ContainsKey(file1)) { dic1 = dic2DicTiMu[file1]; } return(new AFDictionary <string, St_TTimuDaXue>()); }
public static void initDaxue() { if (daxue_NumDic.Count > 0) { return; } #region 初始化大学列表 List <TscWxInfo> list1 = BLLTable <TscWxInfo> .Select(new TscWxInfo()); foreach (TscWxInfo tsc in list1) { //792 北京邮电大学 //北邮//17758129465 if (string.IsNullOrEmpty(tsc.Sc_name) || string.IsNullOrEmpty(tsc.Sc_id)) { continue; } string strNumDaxueDesc = tsc.Sc_id + tsc.Sc_name + tsc.Sc_description; string strNumDaxue = tsc.Sc_id + tsc.Sc_name; string strDaxue = tsc.Sc_name; if (!daxue_BieMingDic.ContainsKey(strDaxue)) { daxue_BieMingDic.Add(strDaxue, new List <string>());//str3s[i], ); } daxue_BieMingDic[strDaxue].Add(strNumDaxueDesc); if (string.IsNullOrEmpty(strDaxue) || string.IsNullOrEmpty(strNumDaxue)) { continue; } if (strNumDaxue.Contains("瓯江")) { } string py2 = pinyin.convertShouZiMu(strNumDaxue).ToLower(); if (!pinyin_NumDaxueDic.ContainsKey(py2)) { pinyin_NumDaxueDic.Add(py2, strNumDaxue); } else { errMsg += ("\r\n 大学列表 存在重复:" + strDaxue); } if (!daxue_NumDaxueDic.ContainsKey(strDaxue)) { daxue_NumDaxueDic.Add(strDaxue, strNumDaxue); } else { errMsg += ("\r\n 大学列表 存在重复:" + strDaxue); } if (!NumDaxue_daxueDic.ContainsKey(strNumDaxue)) { NumDaxue_daxueDic.Add(strNumDaxue, strDaxue); } else { errMsg += ("\r\n 大学列表 存在重复:" + strNumDaxue); } if (!daxue_NumDic.ContainsKey(strDaxue)) { daxue_NumDic.Add(strDaxue, StringHelper.GetNumericLianXu(strNumDaxue)); } if (!Num_DaxueDic.ContainsKey(tsc.Sc_id)) { Num_DaxueDic.Add(tsc.Sc_id, StringHelper.GetHanZi(strNumDaxue)); } } Cs.WriteLine("总数 " + daxue_NumDaxueDic.Count); foreach (string str2 in NumDaxue_daxueDic.Keys) { string str1 = NumDaxue_daxueDic[str2]; //3浙大,浙大 //chklist1.Items.Add(new DataForList(str2, str1), false); } Cs.Warn("data大学 总数 " + NumDaxue_daxueDic.Count); #endregion 初始化大学列表 }
public static AFDictionary <string, FileInfo> btnReNameFile_Click(string txtRename1) { if (template_files2.Count > 0) { return(template_files2); } renameInt = 0; if (!Directory.Exists(txtRename1)) { return(template_files2); } //string[] files = FileService.GetFile(txtRename1); int count = 1; SortedList <string, FileInfo> template_files1 = FileService.GetFile(txtRename1, "*", ref count); bool ret1 = false; foreach (string file in template_files1.Keys) { ret1 = false; string f1 = Path.GetFileNameWithoutExtension(file); if (f1.StartsWith("~") || f1.StartsWith("=")) { continue; } if (f1.Contains("树大")) { "".ToLower(); } string f1DaXue = StringHelper.GetHanZiLianXu(f1); if (string.IsNullOrEmpty(f1DaXue)) { continue; } string f1Num = StringHelper.GetNumericLianXu(f1); bool ret2 = false; string daxue11 = ""; if (daxue_NumDaxueDic.ContainsKey(f1DaXue)) { ret2 = true; daxue11 = daxue_NumDaxueDic[f1DaXue]; } else { foreach (string daxue1 in daxue_NumDaxueDic.Keys) { if (string.IsNullOrEmpty(daxue1)) { continue; } if (daxue1 == "南大") { daxue1.ToString(); } daxue11 = daxue_NumDaxueDic[daxue1]; List <string> f1Daxue2 = new List <string>(); f1Daxue2.Add(daxue1); if (daxue_BieMingDic.ContainsKey(daxue1)) { f1Daxue2.AddRange(daxue_BieMingDic[daxue1]); } //ret2 = isSameDaXue(f1DaXue, f1Daxue2); if (ret2) { break; } } } if (ret2) { string f2 = f1.Replace(f1Num + f1DaXue, daxue11); if (!template_files2.ContainsKey(daxue11))//f1Num + daxue1 { template_files2.Add(daxue11, template_files1[file]); } if (f1 != "" && f2 != "" && f1 != f2) { string f3 = file.Replace(@"\" + f1, @"\" + f2); if (File.Exists(file)) { try { renameInt++; FileService.Copy(file, f3, true); if (File.Exists(f3)) { File.Delete(file); } } catch (Exception ex1) { Cs.Fatal(ex1.Message); } } ret1 = true; } } if (file.EndsWith(".jpg") && !ret1) { "".ToLower(); Cs.Warn(f1 + ",没有找到重命名"); } } return(template_files2); }
public string GetWebByHeader(string url, string header, string cookieStr, string requestForm) { if (srcList.Count == 0) { Cs.Green("链接:" + url); } if (srcList.ContainsKey(url) && srcList[url] != "") { return(""); } srcList.Add(url, ""); string paramUrl = StringHelper.CutString(url, "?", ""); string rootUrl1 = StringHelper.CutString(url.Replace("http://", "").Replace("https://", ""), "", "/"); if (string.IsNullOrEmpty(rootUrl1)) { rootUrl1 = url; } string url11 = url.Replace("http://", "").Replace("https://", ""); if (url11.Contains("?")) { url11 = StringHelper.CutString(url, "", "?"); } string midUrl1 = StringHelper.CutString(url11, "/", ""); string fileName1 = Path.Combine(rootDir1, midUrl1); Directory.CreateDirectory(Path.GetDirectoryName(fileName1)); string htmlSource = null; List <string> csslist = new List <string>(); List <string> jslist = new List <string>(); List <string> imglist = new List <string>(); List <string> hreflist = new List <string>(); if (string.IsNullOrEmpty(header)) { header = @"GET http://api.qess.me/recommendbooks/1/41 HTTP/1.1 Host: api.qess.me Connection: keep-alive Accept: */* Origin: http://mp.qess.me OriginType: mp User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/6.5.2.501 NetType/WIFI WindowsWechat QBCore/3.43.27.400 QQBrowser/9.0.2524.400 token: b8dc2e6e0b7d634bcf67be3e4093ef84 version: 2.0 Referer: http://mp.qess.me/pages/indexPage_textbookList.html?recommendId=39&type=1&winzoom=1 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.8,en-us;q=0.6,en;q=0.5;q=0.4 "; } try { System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(RemoteCertificateValidationCallback); //图片和视频———— string ContentType = MimeMapping.GetContentTypeByUrl(url); Encoding Encoding1 = Encoding.UTF8; if (ContentType.Contains("image") || url.EndsWith(".png") || url.EndsWith(".jpg") || url.EndsWith(".jpeg") || url.EndsWith(".gif")) { if (imgSave) { Image img1 = GetWebImage(url, null); if (img1 != null) { img1.Save(fileName1); } } } else if (ContentType.Contains("mpeg")) { string path = GetUrltoFile(url, fileName1); } else { //html代码-- HttpWebRequest request = getRequest(url, header, cookieStr, requestForm); if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password)) { request.Credentials = new NetworkCredential(Username, Password); } //request.CookieContainer.Add(); //request.ContentType = MimeMapping.GetContentTypeByUrl(url);// contentType; request.KeepAlive = true; //request.UseDefaultCredentials = true; // request.Proxy = null; //if (url.EndsWith(".png") || url.EndsWith(".jpg") || url.EndsWith(".gif")) //{ // request.Accept = "image/webp,*/*;q=0.8"; // request.ContentType = MimeMapping.GetContentTypeByUrl(url);// contentType; // //request.KeepAlive = true; //} bool retFailed = true; if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password)) { try { wc.Credentials = new NetworkCredential(Username, Password); wc.Encoding = Encoding.UTF8; htmlSource = wc.DownloadString(url); retFailed = false; } catch (Exception ex1) { retFailed = true; Cs.Warn(ex1.ToString()); } } if (retFailed) { try { //接收响应 firefox HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Console.Write("."); Stream stream = response.GetResponseStream(); //if (url.EndsWith(".png") || url.EndsWith(".jpg") || url.EndsWith(".jpeg") || url.EndsWith(".gif")) //{ // if (imgSave) // { // Image image = Image.FromStream(stream); // //if(url.EndsWith("jpg")) // image.Save(fileName1); // } // return fileName1; //} //else { System.IO.StreamReader sr = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8); //htmlSource = (sr.ReadToEnd()); htmlSource = ""; byte[] buf = new byte[1024]; while (true) { int len = stream.Read(buf, 0, buf.Length); if (len <= 0)//[2011-8-22] 修改len < 0 =》 len <= 0 解决死循环 { break; } //.GetEncoding("utf-8") htmlSource += System.Text.Encoding.UTF8.GetString(buf, 0, len); } srcList.Add(url, htmlSource); if (txtSave) { if (!Path.GetFileName(fileName1.Trim('/').Trim('\\')).Contains(".")) { fileName1 = fileName1.Trim('/').Trim('\\') + ".html"; File.WriteAllText(fileName1.Trim('/').Trim('\\'), htmlSource); } } } } catch (Exception ex1) { retFailed = true; Cs.Warn(ex1.ToString()); } } srcList.Add(url, htmlSource); if (url.EndsWith(".css") || url.EndsWith(".js")) { return(htmlSource); } if (txtSave) { //如果是网页,需要获取页面上所有其他资源 csslist = StringHelper.CutStringForAll(htmlSource, "<link ", ">"); foreach (string css1 in csslist) { string css2 = StringHelper.CutString(css1, "href=\"", "\""); if (!string.IsNullOrEmpty(css2)) { string url2 = getAbsoluteUrl(css2, url); //string html2 = GetUrltoHtml2(url2, Encoding.UTF8); string html3 = GetWebByHeader(url2, header, cookieStr, requestForm); } } jslist = StringHelper.CutStringForAll(htmlSource, "<script ", "></script>"); foreach (string js1 in jslist) { string js2 = StringHelper.CutString(js1, "src=\"", "\""); if (!string.IsNullOrEmpty(js2)) { string url2 = getAbsoluteUrl(js2, url); string html2 = GetWebByHeader(url2, header, cookieStr, requestForm); } } } if (imgSave) { imglist = StringHelper.CutStringForAll(htmlSource, "<img ", ">"); foreach (string img1 in imglist) { string img2 = StringHelper.CutString(img1, "src=\"", "\""); if (!string.IsNullOrEmpty(img2)) { if (img2.EndsWith(".jpg") || img2.EndsWith(".png") || img2.EndsWith(".jpeg")) { string url2 = getAbsoluteUrl(img2, url); string html3 = GetWebByHeader(url2, header, cookieStr, requestForm); } } } } if (checkAll) { hreflist = StringHelper.CutStringForAll(htmlSource, "<a ", ">"); foreach (string href1 in hreflist) { string href2 = StringHelper.CutString(href1, "href=\"", "\""); if (!string.IsNullOrEmpty(href2.Trim('/').Trim('\\'))) { string url2 = getAbsoluteUrl(href2, url); Cs.Green("子链接:" + url2); if (".zip.rar.sit.xml.mpeg.".Contains(Path.GetExtension(url2))) { } else if (url2.Contains("miibeian.gov.cn/") || url2.Contains("baidu.com")) { } else if (!srcList.ContainsKey(url2)) { string html2 = GetWebByHeader(url2, header, cookieStr, requestForm); } else { } } } } } } catch (Exception ex) { Cs.Error("74==" + url + "==" + ex.ToString()); } return(htmlSource); }