/// <summary> /// 获取网页验证码图片 /// </summary> /// <param name="url"></param> /// <param name="cookie"></param> /// <returns></returns> public static Image GetWebImage(string url, CookieContainer cookie) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); //request.Referer = referer; request.UserAgent = userAgent; request.Accept = "image/webp,*/*;q=0.8"; if (cookie != null) { request.CookieContainer = cookie; } //request.ContentType = "multipart/form-data; boundary=" + boundary; request.ContentType = MimeMapping.GetContentTypeByUrl(url);// contentType; request.KeepAlive = true; request.UseDefaultCredentials = true; // request.Proxy = null; Stream stream = request.GetResponse().GetResponseStream(); Image image = Image.FromStream(stream); return(image); }catch (Exception ex) { Cs.Error("74==" + url + "==" + ex.ToString()); } return(null); }
/// <summary> /// 获取list页的数据源 /// 支持主模块的链接 /// 支持枚举量 /// 支持时间格式 /// </summary> /// <param name="f1"></param> /// <returns></returns> public string GetHtmlList(DataBaseField f1, ITableImplement this1) { if (!f1.Desc.af_Enable) { return(""); //是否可用 } if (!f1.Desc.af_Visable) { return(""); //是否可见 } string html = ""; string tableName = f1.TableName; AttributeItem attr1 = AttributeItem.Factory(f1); object value1 = (this1.GetValue(attr1)); DataBaseTable dt1 = f1.DataBaseTable; //DataBaseField f1; try { DataBaseField id1 = dt1.IDField; DataBaseField name1 = dt1.NameField; if (f1 == dt1.IDField) { //html = "<a href='index.aspx?id=" + this1.GetValue(dt1.FieldID.FieldName) + "'>" + html + "</a>"; } else if (f1 == dt1.NameField) // != null && dt1.NameField.FieldName == f1.FieldName)//本模块name详细链接 { string showUrl = "../" + dt1.TableName + "/show.aspx"; if (!Exist(showUrl)) { showUrl = "show.aspx"; } html = "<a href='" + showUrl + "?id=" + this1.GetValue(id1) + "&moduleName=" + tableName + "' target='_blank'>" + value1 + "</a>"; } else if (isSelect(f1)) //枚举量 { html = BaseFormHelper.Factory(this1.ConnectKey).GetOptionText(attr1, value1); } else if (isChaZhao(f1)) //父表 { DataBaseField f2 = f1.DataBaseTable.FatherTable_ChaZhao[0].DataBaseTable.NameField; AttributeItem attr2 = AttributeItem.Factory(f2); html = Convert.ToString(this1.GetValue(attr2)); } else if (f1.Desc.Switch_CtrlType == BaseCtrlType.FileUpImage) { html = "<img src ='" + value1 + "' style='height:40px' />"; } } catch (Exception ex) { Cs.Error(ex.ToString()); } if (html == "") { html = Convert.ToString(value1); } return(html); }
/// <summary> /// 查找html /// </summary> /// <returns></returns> protected string getFinder() { StringBuilder sb = new StringBuilder(); try { foreach (DataBaseField f1 in valObj.af_GetAvailableDataBaseField()) { //条件对象有赋值 if (finderObj.IsNotNull()) { AttributeItem attr1 = new AttributeItem(f1); if (finderObj.GetInitialized(attr1)) { f1.Value = Convert.ToString(finderObj.GetValue(attr1)); } } string attrHtml = Finder; BuildByTag b1 = new BuildByTag(BuildType.ForHtmlValue); b1.ParseForSwitch标签(ref attrHtml, f1); sb.Append("<dl><dt>").Append(f1.Desc.ZhName).Append(":</dt><!--").Append(f1.FieldName) .Append("--><dd><span>"); sb.Append(attrHtml); sb.Append("</span></dd></dl>"); } } catch (Exception ex) { Cs.Error("34" + ex.ToString()); } return(sb.ToString()); }
/// <summary> /// 查找html /// </summary> /// <returns></returns> protected string getFinder() { StringBuilder sb = new StringBuilder(); try { foreach (DataBaseField f1 in fieldList) { f1.Value = null; bool isNull1 = finderObj.IsNotNull(); bool isInit1 = false; //条件对象有赋值 if (isNull1) { AttributeItem attr1 = new AttributeItem(f1); isInit1 = finderObj.GetInitialized(attr1); if (isInit1) { f1.Value = Convert.ToString(finderObj.GetValue(attr1)); } } if (f1.ZhName == "多选数量") { "".ToString(); } string attrHtml = Finder; //jinsj foreach (string table1 in f1.Desc.OutSource_ChaZhao.Keys) { string selModuleUrl = null; if (f1.Desc.Switch_CtrlType == BaseCtrlType.SelectMultiple) { selModuleUrl = "Sels.aspx?moduleName=" + table1 + "&r=" + DateTime.Now.Ticks; } else { selModuleUrl = "Sel.aspx?moduleName=" + table1 + "&r=" + DateTime.Now.Ticks; } attrHtml = attrHtml.Replace("{首字母大写关联表名}", selModuleUrl); } BuildByTag b1 = new BuildByTag(BuildType.ForHtmlValue); b1.ParseForSwitch标签(ref attrHtml, f1); if (isChaZhao(f1)) { attrHtml = attrHtml.Replace("{字段显示值}", Convert.ToString(finderObj.GetValue(f1.TableName, f1.Desc.FieldCtrlName + "_NAME"))); } sb.Append("<dl><dt>").Append(f1.Desc.ZhName).Append(":</dt><!--").Append(f1.FieldName) .Append("--><dd><span>"); sb.Append(attrHtml); sb.Append("</span></dd></dl>"); } } catch (Exception ex) { Cs.Error("34" + ex.ToString()); } return(sb.ToString()); }
public string GetUrltoHtml2(string uri, Encoding Encoding1) { if (string.IsNullOrEmpty(uri) || string.IsNullOrEmpty(uri.Trim())) { return(""); } //wc = new CookieAwareWebClient(); wc.Encoding = Encoding1; //html1 = ""; //get1(uri); //while (html1 == "") //{ // Wait(100); // //Wait(2000); //} //return html1; Console.WriteLine("Sending an HTTP GET request to " + uri); //Application.DoEvents(); Thread.Sleep(10); //Application.DoEvents(); Stream st = null; StreamReader sr = null; try { st = wc.OpenRead(uri); sr = new StreamReader(st); string res = sr.ReadToEnd(); return(res); } catch (Exception ex1) { Cs.Error(ex1.ToString()); } finally { if (sr != null) { sr.Close(); } if (st != null) { st.Close(); } } Console.WriteLine("HTTP Response is "); //Console.WriteLine(res); return(""); }
/// <summary> /// 根据已存在的表,将物理字段,保存入 TF_TB_FIELD 表中 /// </summary> /// <param name="tb1"></param> /// <param name="tbObj"></param> /// <returns></returns> public int SaveToTF_TB_FIELD(string TB_NAME, int TB_ID, ref string errMsg) { errMsg = ""; string tbname = TB_NAME; DataBaseTable tb1 = null; DataBaseTable tb2 = new DataBaseTable(); DataBaseTable tb3 = new DataBaseTable(); if (DataBase.Factory(conn).TryGetValue(tbname, out tb1))//如果表不存在,则新建表,带默认字段 { foreach (DataBaseField f2 in tb1.DataFields) { DataBase.Factory(conn).Master().TryGetValue("af_GROUP_WF_2014", out tb2); DataBase.Factory(conn).Master().TryGetValue("af_GROUP_WF_MX_2014", out tb3); if (!tb2.DataFields.Contains(f2.FieldName) && !tb3.DataFields.Contains(f2.FieldName)) { TF_TB_FIELD f1 = Parse(f2); f1.TB_ID = TB_ID; int count1 = 0; TF_TB_FIELD cond1 = new TF_TB_FIELD(); cond1.TB_ID = f1.TB_ID; cond1.FIELD_NAME = f1.FIELD_NAME; //count1 = BLLTable<TF_TB_FIELD>.Factory(conn).SaveOrUpdate(f1, cond1, TF_TB_FIELD.Attribute.FIELD_ID); if (BLLTable <TF_TB_FIELD> .Factory(conn).Exists(cond1)) { count1 = BLLTable <TF_TB_FIELD> .Factory(conn).Update(f1, TF_TB_FIELD.Attribute.FIELD_ID); } else { count1 = BLLTable <TF_TB_FIELD> .Factory(conn).Insert(f1, TF_TB_FIELD.Attribute.FIELD_ID); } if (count1 < 1) { Cs.Error("插入 TF_TB_FIELD 失败"); } } } return(1); } return(-1); }
private void SaveState() { #region 获取条件 finderObj = new ITableImplement(); foreach (DataBaseField f1 in valObj.af_GetAvailableDataBaseField()) { string fieldValue = null; AttributeItem attr1 = null; try { if (isChaZhao(f1)) { if (TryGetRequest(f1.Desc.FieldCtrlName + "_NAME", out fieldValue)) { attr1 = new AttributeItem(f1.TableName, f1.Desc.FieldCtrlName + "_NAME"); finderObj.SetValue(attr1, fieldValue); } } if (TryGetRequest(f1, out fieldValue)) { attr1 = new AttributeItem(f1); finderObj.SetValue(attr1, fieldValue); if (!string.IsNullOrEmpty(fieldValue)) { condObj.Like(attr1, fieldValue); } } } catch (Exception ex) { Cs.Error(ex.ToString()); litWarn.Text = ex.Message + ":" + attr1.LongName + "=" + fieldValue; } } //hidVal.Value = valObj111.ToJson(20); //hidCondition.Value = condObj111.ToJson(20); hidFind.Value = finderObj.ToJson(20); //if (hidCondition.Value != "") //{ // condObj111 = JsonServiceBase.FromJson<ITableImplement>(hidCondition.Value); //} #endregion }
/// <summary> /// 查找html /// </summary> /// <returns></returns> protected string getFinder() { StringBuilder sb = new StringBuilder(); try { foreach (DataBaseField f1 in fieldList) { f1.Value = null; bool isNull1 = finderObj.IsNotNull(); bool isInit1 = false; //条件对象有赋值 if (isNull1) { AttributeItem attr1 = new AttributeItem(f1); isInit1 = finderObj.GetInitialized(attr1); if (isInit1) { f1.Value = Convert.ToString(finderObj.GetValue(attr1)); } } string attrHtml = Finder; BuildByTag b1 = new BuildByTag(BuildType.ForHtmlValue); b1.ParseForSwitch标签(ref attrHtml, f1); if (isChaZhao(f1)) { attrHtml = attrHtml.Replace("{字段显示值}", Convert.ToString(finderObj.GetValue(f1.TableName, f1.Desc.FieldCtrlName + "_NAME"))); } sb.Append("<dl><dt>").Append(f1.Desc.ZhName).Append(":</dt><!--").Append(f1.FieldName) .Append("--><dd><span>"); sb.Append(attrHtml); sb.Append("</span></dd></dl>"); } } catch (Exception ex) { Cs.Error("34" + ex.ToString()); } return(sb.ToString()); }
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); }
/// <summary> /// Category_ids 1,2,3 Category_names 中国,互联网 /// </summary> /// <param name="category"></param> /// <param name="Category_ids"></param> /// <param name="Category_names"></param> /// <returns></returns> public int Split_category(string category, ref StringBuilder Category_ids, ref StringBuilder Category_names) { int count1 = 0; if (string.IsNullOrEmpty(category)) { return(count1); } string[] category1 = category.Split(','); foreach (string v1 in category1) { if (string.IsNullOrEmpty(v1) || v1 == "0") { continue; } string[] category2 = v1.Split('_'); if (category2.Length == 2) { count1++; string id = category2[0]; string name = category2[1]; Category_ids.Append(id).Append(","); Category_names.Append(name).Append(","); } else { Cs.Error("异常" + v1); } } if (Category_names.Length > 0) { Category_names.Remove(Category_names.Length - 1, 1); } if (Category_ids.Length > 0) { Category_ids.Remove(Category_ids.Length - 1, 1); } return(count1); }
public static TiMuXuanZe From(string s1) { TiMuXuanZe t1 = new TiMuXuanZe(); try { if (s1.Contains("题型:2")) { } t1.sourcefile = (StringHelper.CutString(s1, "|源件:", "|源件").Trim('\n').Trim()); t1.sourceid = (StringHelper.CutString(s1, "|源件id:", "|章节").Trim('\n').Trim()); t1.zhangjie = (StringHelper.CutString(s1, "|章节:", "|编号").Trim('\n').Trim()); t1.id = (StringHelper.CutString(s1, "|编号:", "|题型").Trim('\n').Trim()); t1.tixing = (StringHelper.CutString(s1, "|题型:", "|考题").Trim('\n').Trim()); t1.questionstr = StringHelper.CutString(s1, "|考题:", "|选项").Trim('\n').Trim(); t1.optionstr = StringHelper.CutString(s1, "|选项:", "|答案").Trim('\n').Replace("|A", "A").Trim(); t1.answerstr = StringHelper.CutString(s1, "|答案:", "|解析").Trim('\n').Trim(); t1.jiexi = StringHelper.CutString(s1, "|解析:", "").Trim('\n').Trim(); } catch (Exception ex) { Cs.Error(ex.ToString()); } if (t1.id == "") { return(null); } if (t1.questionstr == "") { return(null); } if ((t1.tixing == "0" || t1.tixing == "1") && t1.optionstr == "") { return(null); } if (t1.answerstr == "") { return(null); } return(t1); }
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); }
/// <summary> /// ÊäÈëhtml /// </summary> /// <returns></returns> protected string getInput() { StringBuilder sb = new StringBuilder(); try { foreach (DataBaseField f1 in fieldList) { if (f1.TableName.ToLower() == valObj._TableName.ToLower())//±¾±í×ֶΠ{ AttributeItem attr1 = new AttributeItem(f1); f1.Value = Convert.ToString(resultObj.GetValue(attr1)); if (f1.ZhName == "¶àÑ¡ÊýÁ¿") { "".ToString(); } if (f1.ZhName == "¹Ø¼ü´Ê") { "".ToString(); } string attrHtml = Input; BuildByTag b1 = new BuildByTag(BuildType.ForHtmlValue); b1.ParseForSwitch±êÇ©(ref attrHtml, f1); if (isChaZhao(f1)) { DataBaseField f2 = f1.DataBaseTable.FatherTable_ChaZhao[0].DataBaseTable.NameField; AttributeItem attr11 = AttributeItem.Factory(f2); string html = Convert.ToString(resultObj.GetValue(attr11)); attrHtml = attrHtml.Replace("{×Ö¶ÎÏÔʾֵ}", html); } else if (f1.Desc.CtrlType == BaseCtrlType.SelectDrop) { string[] strs = null; if (f1.Value.Contains(",")) { strs = f1.Value.Split(','); foreach (string s in strs) { string str = "value='" + s + "'"; attrHtml = attrHtml.Replace(str, str + " selected"); } } } else if (f1.Desc.CtrlType == BaseCtrlType.FileUpUpDoc) { if (!f1.Value.Equals(" ")) { string val = Convert.ToString(f1.Value); string[] strs = val.Split(';'); string html = ""; for (int i = 0; i < strs.Length - 1; i++) { string[] ss = strs[i].Split(','); string title = ss[0]; string url = ss[1]; string hidId = ss[2]; html += "<div>" + title + "<a href=\"javascript:\" flag=\"delete\" url=\"" + url + "\" onclick=\"deleteFileName(this,'" + hidId + "')\"><img src=\"../../Themes/WEC/del-icon.png\"></a></div>"; } attrHtml = attrHtml.Replace("<div id='files' style='margin-bottom:10px;'></div>", "<div id='files' style='margin-bottom:10px;'>" + html + "</div>"); } } sb.Append("<dl><dt>").Append(f1.Desc.ZhName).Append("£º</dt><!--").Append(f1.FieldName) .Append("--><dd><span>"); sb.Append(attrHtml); sb.Append("</span></dd></dl>"); } } } catch (Exception ex) { Cs.Error("34" + ex.ToString()); } return(sb.ToString()); }
/// <summary> /// 输入html /// </summary> /// <returns></returns> protected string getInput() { StringBuilder sb = new StringBuilder(); string strChazhaoID = ""; try { DataBaseField[] flist = valObj.af_GetAvailableDataBaseField(); foreach (DataBaseField f1 in flist) { string block = "基础信息"; block = f1.Desc.af_BlockName; string blockid = f1.Desc.af_BlockID; if (f1.TableName != resultObj._TableName) //说明不是本表字段 { block = f1.TableName; //布局名,就是 关联表的父表 表名 if (resultObj.IsOnlyForModuleIDName == true) { break; } else { } } f1.Value = Convert.ToString(resultObj.GetValue(f1)); string attrHtml = Input; BuildByTag b1 = new BuildByTag(BuildType.ForHtmlValue); b1.ParseForSwitch标签(ref attrHtml, f1); if (isChaZhao(f1)) { DataBaseField f2 = f1.DataBaseTable.FatherTable_ChaZhao[0].DataBaseTable.NameField; string html = Convert.ToString(resultObj.GetValue(f2)); attrHtml = attrHtml.Replace("{字段显示值}", html); strChazhaoID = f1.Value; } else if (isSelect(f1))//枚举量 { AttributeItem attr2 = AttributeItem.Factory(f1); string html = BaseFormHelper.Factory(resultObj.ConnectKey).GetOptionText(attr2, f1.Value); attrHtml = html; } else if (f1.Desc.Switch_CtrlType == BaseCtrlType.FileUpImage) { attrHtml = "<img style='height:19px;top:5px;postion:relative;' src ='" + f1.Value + "' style='height:40px' />"; } sb.Append("<dl class=\"dl-horizontal\"><dt><span>").Append(f1.Desc.ZhName).Append("</span></dt><!--").Append(f1.FieldName) .Append("--><dd><span>"); sb.Append(attrHtml); sb.Append("</span></dd></dl>"); } } catch (Exception ex) { Cs.Error("34" + ex.ToString()); } return(sb.ToString()); }
/// <summary> /// 获取list页的数据源 /// 支持主模块的链接 /// 支持枚举量 /// 支持时间格式 /// </summary> /// <param name="f1"></param> /// <returns></returns> public string GetHtmlList(DataBaseField f1, ITableImplement this1) { string html = ""; try { DataBaseTable dt1 = f1.DataBaseTable; if (f1 != dt1.IDField && f1 != dt1.NameField) { if (!f1.Desc.af_Enable) { return(""); //是否可用 } if (!f1.Desc.af_Visable) { return(""); //是否可见 } } AttributeItem attr1 = AttributeItem.Factory(f1); object value1 = (this1.GetValue(attr1)); //DataBaseField f1; DataBaseField id1 = dt1.IDField; DataBaseField name1 = dt1.NameField; if (f1 == dt1.IDField)//编号字段 { //html = "<a href='index.aspx?id=" + this1.GetValue(dt1.FieldID.FieldName) + "'>" + html + "</a>"; } else if (f1 == dt1.NameField)// != null && dt1.NameField.FieldName == f1.FieldName)//本模块name详细链接 { string showUrl = "../" + f1.TableName + "/show.aspx"; if (!Exist(showUrl)) { showUrl = "show.aspx"; } html = "<a href='" + showUrl + "?id=" + this1.GetValue(id1) + "&moduleName=" + f1.TableName + "' target='_blank'>" + value1 + "</a>"; } else if (isSelect(f1))//枚举量 { string str = Convert.ToString(value1); if (str.Contains(",")) { //多选 string[] strs = str.Split(','); List <object> valueList = new List <object>(strs); List <object> nameList = BaseFormHelper.Factory(this1.ConnectKey).GetOptionText(attr1, valueList); StringBuilder sb = new StringBuilder(); foreach (object s in nameList) { String ss = Convert.ToString(s); sb.Append(ss + ","); } html = sb.ToString(); html = html.Substring(0, html.LastIndexOf(",")); } else { //单选 html = BaseFormHelper.Factory(this1.ConnectKey).GetOptionText(attr1, value1); } } else if (isChaZhao(f1))//父表 { DataBaseField f2 = f1.DataBaseTable.FatherTable_ChaZhao[0].DataBaseTable.NameField; AttributeItem attr2 = AttributeItem.Factory(f2); html = Convert.ToString(this1.GetValue(attr2)); //为关联的表的name设置链接 string showUrl = "../" + f1.TableName + "/show.aspx"; if (!Exist(showUrl)) { showUrl = "show.aspx"; } html = "<a href='" + showUrl + "?id=" + this1.GetValue(id1) + "&moduleName=" + f1.TableName + "' target='_blank'>" + html + "</a>"; } else if (f1.Desc.Switch_CtrlType == BaseCtrlType.FileUpImage) { html = "<img src ='" + value1 + "' style='height:40px' />"; } else if (f1.Desc.Switch_CtrlType == BaseCtrlType.FileUpUpDoc) {// if (!value1.Equals(" ")) { string val = Convert.ToString(value1); string[] strs = val.Split(';'); for (int i = 0; i < strs.Length - 1; i++) { string[] ss = strs[i].Split(','); string title = ss[0]; string url = ss[1]; html += "<span>" + title + " <a href='Back.aspx?moduleName=" + ModuleName + "&download=true&filename=" + url + "'>下载</a></span>"; } } } if (html == "") { html = Convert.ToString(value1); } } catch (Exception ex) { Cs.Error(ex.ToString()); } return(html);//.TrimEnd('\n').TrimEnd('\r').Trim(); }