/// <summary> /// 检查用户登录 /// </summary> /// <param name="userInfo">用户名</param> /// <returns></returns> public bool CheckLogin(ViewUserLogin userInfo) { bool validate = false; userInfo.UserPwd = userInfo.UserPwd.GetMD5FromString(); var userName = StringHelp.FilterSql(userInfo.UserName); var userPwd = StringHelp.FilterSql(userInfo.UserPwd); var user = userBll.FirstOrDefault <Sys_User>(x => x.UserNickName.Equals(userName) && x.Password.Equals(userPwd)); if (user != null) { //var session = HttpContext.Session[ConstString.SysUserLoginId]; //if (session == null) //{ SessionManager.Add(ConstString.SysUserLoginId, user.UserId); string browser = NetworkHelper.GetBrowser(); string hostIP = NetworkHelper.GetIp() != "0.0.0.0" ? NetworkHelper.GetIp() : ZHttp.ClientIP; string hostName = ZHttp.IsLanIP(ZHttp.ClientIP) ? ZHttp.ClientHostName : string.Empty; //如果是内网就获取,否则出错获取不到,且影响效率 loginHistoryBLL.AddEntity(Sys_LoginHistory.CreateInstance(user.UserId, hostName, hostIP, userInfo.City, browser)); SetUserCache(user); SetCookie(user.UserId); //} validate = true; } return(validate); }
/// <summary> /// 检查楼层 /// </summary> /// <param name="sumFloor">总楼层</param> /// <param name="nowFloor">当前楼层</param> /// <returns></returns> public static bool CheckHouseFloor(string sumFloor, string nowFloor) { sumFloor = StringHelp.TrimBlank(sumFloor); if (string.IsNullOrEmpty(sumFloor)) { return(true); } nowFloor = StringHelp.TrimBlank(nowFloor); if (string.IsNullOrEmpty(nowFloor)) { return(true); } if (!StringHelp.IsInteger(sumFloor)) { return(false); } if (!StringHelp.IsInteger(nowFloor)) { return(false); } int _nowFloor = Convert.ToInt32(nowFloor); int _sumFloor = Convert.ToInt32(sumFloor); if (_nowFloor > _sumFloor) { return(false); } return(true); }
/// <summary> /// 获取楼盘名模糊下拉(正式库楼盘) /// </summary> /// <returns></returns> public ActionResult GetFxtProjectByLikeAndCityName_Api() { string q = Request["q"]; string limit = Request["limit"]; string cityName = null; int maxCount = 10; if (!string.IsNullOrEmpty(limit) && StringHelp.IsInteger(limit)) { maxCount = Convert.ToInt32(limit); } if (Request["cityName"] != null) { cityName = Convert.ToString(Request["cityName"]).DecodeField(); } if (maxCount > 100) { maxCount = 100; } string[] strings = ProjectApiManager.GetProjectInfoStringsByLikeNameAndCityName(q, cityName, maxCount); StringBuilder sb = new StringBuilder(""); if (strings != null) { foreach (string str in strings) { sb.Append(str).Append("\n"); } } string result = sb.ToString(); Response.Write(result); Response.End(); return(null); }
/// <summary> /// 转换户型中的字符 /// </summary> /// <param name="houseType"></param> /// <returns></returns> public string GetConvertToHouseType(string houseType) { houseType = Regex.Replace(houseType, @"(\d*厨|\d*卫)", "", RegexOptions.IgnoreCase); houseType = houseType.Replace("室", "房"); houseType = StringHelp.NumberConvertToChinese(houseType); return(houseType); }
/// <summary> /// 模糊获取片区 /// </summary> /// <returns></returns> public ActionResult GetSubAreaByLikeAndCityId_Api() { string q = Request["q"]; string limit = Request["limit"]; int cityId = 0; int maxCount = 10; if (!string.IsNullOrEmpty(limit) && StringHelp.IsInteger(limit)) { maxCount = Convert.ToInt32(limit); } if (Request["cityId"] != null && StringHelp.IsInteger(Request["cityId"])) { cityId = Convert.ToInt32(Request["cityId"]); } if (maxCount > 100) { maxCount = 100; } List <SysData_SubArea> list = SubAreaManager.GetSubAreaByLikeAndCityId(q, cityId, maxCount); StringBuilder sb = new StringBuilder(""); if (list != null) { foreach (SysData_SubArea subArea in list) { sb.Append(subArea.SubAreaName).Append("\n"); } } string result = sb.ToString(); Response.Write(result); Response.End(); return(null); }
/// <summary> /// 检查用户登录 /// </summary> /// <param name="userName">用户名</param> /// <param name="password">密码</param> /// <returns></returns> public bool CheckLogin(string userName, string password) { bool validate = false; //防止注入 userName = StringHelp.FilterSql(userName); password = StringHelp.FilterSql(password); var user = userBll.FirstOrDefault <Sys_User>(x => x.UserNickName.Equals(userName) && x.Password.Equals(password)); if (user != null) { //登录成功,添加Session SessionManager.Add(ConstString.UserLoginId, user.UserId); //验证ip,浏览器 string IP = NetworkHelper.GetIp(); string Browser = NetworkHelper.GetBrowser(); //查询站内未读消息条数,并加入缓存 //添加登录日志表,记录登录日志 int m_guid = (user.UserId + Guid.NewGuid().ToString()).GetHashCode(); //添加cookie消息 CookiesManager.Add(ConstString.SysUserLoginGuid, user.UserId, DateTime.Now.AddDays(1)); validate = true; } return(validate); }
private void DataBind(string TitleType) { entity_News news = bll.GetEntity(TitleType); this.title.Text = news.title; this.Content.Text = StringHelp.TextToHTMl(news.Content); this.ReleaseDate.Text = news.CreateTime; }
public static bool CheckHouseObj(HouseDto house, out string message) { message = ""; // string unitno = string.IsNullOrEmpty(house.UnitNo) ? null : house.UnitNo.DecodeField(); if (unitno != null && unitno.Length > 20) { message = "请输入房号单元名称字符长度不能大于20"; return(false); } // //object floorno = jobj["floorno"] == null ? null : jobj.Value<JValue>("floorno").Value; //int fno = 0; //if (floorno == null || !int.TryParse(floorno.ToString().DecodeField(), out fno)) //{ // message = "请输入起始楼层"; // return false; //} // //string housename = jobj["housename"] == null ? null : jobj.Value<string>("housename").DecodeField(); //if (housename == null) //{ // message = "请输入房号"; // return false; //} //if (housename.Length > 20) //{ // message = "请输入房号字符长度不能大于20"; // return false; //} // if (!house.FrontCode.HasValue || !StringHelp.CheckInteger(house.FrontCode.Value.ToString().DecodeField())) { message = "请输入朝向"; return(false); } // if (house.BuildArea.HasValue && !StringHelp.CheckDecimal(house.BuildArea.Value.ToString().DecodeField())) { message = "请输入正确的面积格式"; return(false); } // if (house.HouseTypeCode.HasValue && !StringHelp.CheckInteger(house.HouseTypeCode.Value.ToString().DecodeField())) { message = "请输入正确的户型"; return(false); } // if (house.SightCode.HasValue && !StringHelp.CheckInteger(house.SightCode.Value.ToString().DecodeField())) { message = "请输入景观"; return(false); } return(true); }
public ActionResult EditUser_SubmitData_Api(string userName, string truename, string departmentId, string roleIds) { string json = ""; int? _departmentId = null; int[] _roleIds = null; if (string.IsNullOrEmpty(userName)) { Response.Write(json.MvcResponseJson(result: 0, message: "请填写用户名")); Response.End(); return(null); } //获取提交数据 UserCenter_LoginUserInfo loginUserInfo = WebUserHelp.GetNowLoginUser(); int cityId = WebUserHelp.GetNowCityId(); int companyId = loginUserInfo.FxtCompanyId; string loginusername = loginUserInfo.UserName; string loginsignname = loginUserInfo.SignName; if (StringHelp.CheckInteger(departmentId) && departmentId != "0") { _departmentId = Convert.ToInt32(departmentId); } _roleIds = roleIds.ConvertToInts(','); //提交数据 string message = ""; bool result = UserInfoManager.SetUserInfo(cityId, companyId, userName, truename, _departmentId, _roleIds, out message); if (!result) { Response.Write(json.MvcResponseJson(result: 0, message: "提交失败:" + message)); Response.End(); return(null); } IList <SYSRole> roleList = SYSRoleManager.GetSYSRoleByRoleIds(_roleIds); StringBuilder roleNameSb = new StringBuilder(""); string departmentName = ""; foreach (SYSRole roleInfo in roleList) { roleNameSb.Append(roleInfo.RoleName).Append(","); } if (Convert.ToInt32(_departmentId) > 0) { PriviDepartment pd = PriviDepartmentManager.GetDepartmentById(Convert.ToInt32(_departmentId)); if (pd != null) { departmentName = pd.DepartmentName; } } json = string.Format("{{\"username\":\"{0}\",\"truename\":\"{1}\",\"departmentname\":\"{2}\",\"rolename\":\"{3}\"}}", userName, truename, departmentName, roleNameSb.ToString()); Response.Write(json.MvcResponseJson(result: 1, message: "")); Response.End(); return(null); }
public string 转换建筑年代(string _value_jznd) { if (string.IsNullOrEmpty(_value_jznd)) { return(""); } if (!StringHelp.IsInteger(_value_jznd)) { return(""); } return(DateTime.Now.AddYears(0 - Convert.ToInt32(_value_jznd)).ToString("yyyy")); }
public static decimal?CaseColumnConvertToDecimal(string str) { if (string.IsNullOrEmpty(str)) { return(null); } if (StringHelp.CheckDecimal(str)) { return(Convert.ToDecimal(str)); } return(null); }
public static int?CaseColumnConvertToInt(string str) { if (string.IsNullOrEmpty(str)) { return(null); } if (StringHelp.IsInteger(str)) { return(Convert.ToInt32(str)); } return(null); }
public void start() { RegexInfo 总条数正则 = new RegexInfo("共找到<strong class=\"number orange\">([\\d]*)</strong>条", "$1"); RegexInfo cityRegexInfo = new RegexInfo("<div class=\"onCont\" id=\"c01\"[^<>]*>((?:(?!</div>).)*)</div>", "$1"); RegexInfo cityRegexInfo2 = new RegexInfo("(<a href=\"[^\"]+\"[^<>]*>[^<>]+</a>)", "$1"); Dictionary <string, RegexInfo> cityRegexDic = new Dictionary <string, RegexInfo>(); cityRegexDic.Add("城市列表Text", cityRegexInfo); Dictionary <string, List <string> > dicCitylistText = SpiderHelp.GetHtmlByRegex("http://soufun.com/SoufunFamily.htm", "utf-8", cityRegexDic, WebsiteManager.GetWebById(WebsiteManager.搜房网_ID), CityId); string cityText = dicCitylistText["城市列表Text"].Count > 0 ? dicCitylistText["城市列表Text"][0] : ""; cityRegexDic.Add("城市列表", cityRegexInfo2); Dictionary <string, List <string> > dicCitylist = SpiderHelp.GetStrByRegex(cityText, cityRegexDic); List <string> cityList = dicCitylist["城市列表"]; StringBuilder citySb = new StringBuilder(); cityRegexDic.Add("总条数", 总条数正则); List <string> list2 = new List <string>(); foreach (string cityInfoStr in cityList) { RegexInfo regexCityName = new RegexInfo("<a href=\"[^\"]+\"[^<>]*>([^<>]+)</a>", "$1"); RegexInfo regexCityUrl = new RegexInfo("<a href=\"([^\"]+)\"[^<>]*>[^<>]+</a>", "$1"); Dictionary <string, RegexInfo> cityRegexDic2 = new Dictionary <string, RegexInfo>(); cityRegexDic2.Add("regexCityName", regexCityName); cityRegexDic2.Add("regexCityUrl", regexCityUrl); Dictionary <string, List <string> > dicCityInfo = SpiderHelp.GetStrByRegex(cityInfoStr, cityRegexDic2); string cityName = StringHelp.TrimBlank(dicCityInfo["regexCityName"].Count > 0 ? dicCityInfo["regexCityName"][0] : ""); string cityUrl = dicCityInfo["regexCityUrl"].Count > 0 ? dicCityInfo["regexCityUrl"][0] : ""; string execStr = " exec 往网站爬取配置表添加配置信息 '{0}','{1}','{2}','{3}','{4}',{5},{6}"; 城市表 city = CityManager.Get城市_byLike城市名称(cityName); if (city != null && SpiderWebConfigManager.get网站爬取配置_by城市ID_网站ID(city.ID, WebsiteManager.搜房网_ID) == null)//&& { string houseUrl1 = cityUrl.Replace("http://", "http://esf.").TrimEnd('/'); if (city.城市名称.Contains("北京")) { houseUrl1 = houseUrl1.Replace("bj.", ""); } string houseUrl2 = houseUrl1 + "/house/h316-j3100-w32/"; Dictionary <string, List <string> > dicCountlistText = SpiderHelp.GetHtmlByRegex(houseUrl2, "gbk", cityRegexDic, WebsiteManager.GetWebById(WebsiteManager.搜房网_ID), CityId); string count = dicCountlistText["总条数"].Count > 0 ? dicCountlistText["总条数"][0] : ""; if (!string.IsNullOrEmpty(count)) { execStr = string.Format(execStr, WebsiteManager.搜房网, city.城市名称, houseUrl1, houseUrl2, "", "4000", "2000"); citySb.Append(execStr).Append("\r\n"); list2.Add(execStr); } } } string result = citySb.ToString(); }
/// <summary> /// 获取最大子级菜单编号 /// </summary> /// <returns></returns> public string maxSubMenuId(string parentMenId) { string maxMenuId = string.Empty; var subLevelMenus = _menuShare.LoadEntities(x => x.ParentMenId.Equals(parentMenId)); if (subLevelMenus == null) { return($"{parentMenId}001"); } var menuIds = subLevelMenus.Select(x => x.MenuId.Replace(parentMenId, "")).ToList(); return($"{parentMenId}{(StringHelp.ChartToInteger(menuIds).Max() + 1).ToString().PadLeft(3, '0')}");; }
private void cboxCity_SelectedIndexChanged(object sender, EventArgs e) { string selectCityId = Convert.ToString(cboxCity.SelectedValue); if (!string.IsNullOrEmpty(selectCityId) && StringHelp.IsInteger(selectCityId)) { List <网站表> list = WebsiteManager.GetWebByCityId(Convert.ToInt32(selectCityId)); 网站表 obj = new 网站表 { ID = -1, 网站名称 = "全部" }; list.Insert(0, obj); cb网站.DataSource = list; } }
public void start() { 网站表 webObj = WebsiteManager.GetWebById(WebsiteManager.城市房产_ID); RegexInfo 总页数正则 = new RegexInfo("<div class=\"[^\"]*\"><span class='fl mr'>\\d+/(\\d+)</span>", "$1"); Dictionary <string, RegexInfo> 根页面正则字典集合 = new Dictionary <string, RegexInfo>(); 根页面正则字典集合.Add("总页数", 总页数正则); RegexInfo cityRegexInfo = new RegexInfo("(<a[^<>]+href=[\",']{1,1}http\\://[^\\.]+.cityhouse.cn[\",']{1,1}[^<>]*>[^<>]+</a>)", "$1"); //cityRegexInfo.RegexInfoList.Add(new RegexInfo("(<a[^<>]+href='http\\://[^\\.]+.cityhouse.cn'[^<>]*>[^<>]+</a>)", "$1")); Dictionary <string, RegexInfo> cityRegexDic = new Dictionary <string, RegexInfo>(); cityRegexDic.Add("城市列表", cityRegexInfo); Dictionary <string, List <string> > dicCitylistText = SpiderHelp.GetHtmlByRegex("http://www.cityhouse.cn/city.html", "utf-8", cityRegexDic, WebsiteManager.GetWebById(WebsiteManager.城市房产_ID), CityId); List <string> cityList = dicCitylistText["城市列表"]; StringBuilder citySb = new StringBuilder(); StringBuilder citySb2 = new StringBuilder(); foreach (string cityInfoStr in cityList) { RegexInfo regexCityName = new RegexInfo("<a[^<>]+href=[\",']{1,1}http\\://[^\\.]+.cityhouse.cn[\",']{1,1}[^<>]*>([^<>]+)</a>", "$1"); RegexInfo regexCityUrl = new RegexInfo("<a[^<>]+href=[\",']{1,1}(http\\://[^\\.]+.cityhouse.cn)[\",']{1,1}[^<>]*>[^<>]+</a>", "$1"); Dictionary <string, RegexInfo> cityRegexDic2 = new Dictionary <string, RegexInfo>(); cityRegexDic2.Add("regexCityName", regexCityName); cityRegexDic2.Add("regexCityUrl", regexCityUrl); Dictionary <string, List <string> > dicCityInfo = SpiderHelp.GetStrByRegex(cityInfoStr, cityRegexDic2); string cityName = StringHelp.TrimBlank(dicCityInfo["regexCityName"].Count > 0 ? dicCityInfo["regexCityName"][0] : ""); string cityUrl = dicCityInfo["regexCityUrl"].Count > 0 ? dicCityInfo["regexCityUrl"][0] : ""; string execStr = " exec 往网站爬取配置表添加配置信息 '{0}','{1}','{2}','{3}','{4}',{5},{6}"; 城市表 city = CityManager.Get城市_byLike城市名称(cityName); if (city != null && !citySb2.ToString().Contains(city.城市名称) && !citySb.ToString().Contains(city.城市名称) && SpiderWebConfigManager.get网站爬取配置_by城市ID_网站ID(city.ID, WebsiteManager.城市房产_ID) == null) { Dictionary <string, List <string> > 根页面正则字典集合结果 = SpiderHelp.GetHtmlByRegex(cityUrl + "/forsale/flist.html?ob=10", "utf-8", 根页面正则字典集合, webObj, CityId, referer: cityUrl + "/forsale/flist.html?ob=10"); execStr = string.Format(execStr, WebsiteManager.城市房产, city.城市名称, cityUrl, cityUrl + "/forsale/flist.html?ob=10", "", "2000", "2000"); if (根页面正则字典集合结果["总页数"].Count() < 1) { citySb2.Append(execStr).Append("\r\n"); continue; } citySb.Append(execStr).Append("\r\n"); } } string result = citySb.ToString(); string result2 = citySb2.ToString(); 导出任务计划配置文件(); }
/// <summary> /// 获取最大父级菜单编号 /// </summary> /// <returns></returns> public string maxParentMenuId() { string maxMenuId = string.Empty; var parentLevelMenus = _menuShare.LoadEntities(x => x.Level.Equals(1)); if (parentLevelMenus == null) { maxMenuId = "01"; } else { var menuIds = parentLevelMenus.Select(i => i.MenuId); maxMenuId = $"{(StringHelp.ChartToInteger(menuIds).Max() + 1).ToString().PadLeft(2, '0')}"; } return(maxMenuId); }
public static 案例信息 爬取信息数据格式计算整理(案例信息 ent, string 案例时间, string 城市名称) { //整理数据字符串 ent.总楼层String = StringHelp.TrimBlank(ent.总楼层String).ToRemoveSpe(); ent.总楼层 = CaseColumnConvertToInt(ent.总楼层String); ent.所在楼层String = StringHelp.TrimBlank(ent.所在楼层String).ToRemoveSpe(); ent.所在楼层 = CaseColumnConvertToInt(ent.所在楼层String); ent.建筑形式 = StringHelp.TrimBlank(ent.建筑形式).ToRemoveSpe(); ent.楼盘名 = StringHelp.TrimBlank(ent.楼盘名).ToRemoveSpe(); ent.行政区 = StringHelp.TrimBlank(ent.行政区.Trim().ToRemoveSpe()); ent.总价String = StringHelp.TrimBlank(ent.总价String).ToRemoveSpe(); ent.总价 = CaseColumnConvertToDecimal(ent.总价String); ent.用途 = StringHelp.TrimBlank(ent.用途).ToRemoveSpe(); ent.朝向 = SpiderHelp.处理朝向字符(StringHelp.TrimBlank(ent.朝向).ToRemoveSpe()); if (朝向Manager.Get朝向_根据名称(ent.朝向) < 1) { ent.朝向 = ""; } ent.电话 = StringHelp.TrimBlank(ent.电话).ToRemoveSpe(); ent.面积String = Regex.Replace(ent.面积String, @"\..*", "", RegexOptions.IgnoreCase); ent.面积 = CaseColumnConvertToDecimal(ent.面积String); ent.单价String = Regex.Replace(ent.单价String, @"\..*", "", RegexOptions.IgnoreCase); ent.单价 = CaseColumnConvertToDecimal(ent.单价String); ent.花园面积String = Regex.Replace(ent.花园面积String, @"\..*", "", RegexOptions.IgnoreCase); ent.花园面积 = CaseColumnConvertToDecimal(ent.花园面积String); ent.地下室面积String = Regex.Replace(ent.地下室面积String, @"\..*", "", RegexOptions.IgnoreCase); ent.地下室面积 = CaseColumnConvertToDecimal(ent.地下室面积String); ent.车位数量String = StringHelp.TrimBlank(ent.车位数量String).ToRemoveSpe(); ent.车位数量 = CaseColumnConvertToInt(ent.车位数量String); ent.结构 = StringHelp.TrimBlank(ent.结构.Replace("平层", 结构Manager.平面)); ent.户型 = Regex.Replace(ent.户型, @"(\d*厨|\d*卫)", "", RegexOptions.IgnoreCase); ent.户型 = ent.户型.Replace("室", "房"); ent.户型 = StringHelp.NumberConvertToChinese(ent.户型); ent.案例类型 = StringHelp.TrimBlank(string.IsNullOrEmpty(ent.案例类型) ? 案例类型Manager.买卖报盘 : ent.案例类型); ent.币种 = StringHelp.TrimBlank(string.IsNullOrEmpty(ent.币种) ? 币种Manager.人民币 : ent.币种); ent.信息 = Regex.Replace(ent.信息, @"\\&[a-z0-9A-Z_]*;", "", RegexOptions.IgnoreCase); ent.地址 = Regex.Replace(ent.地址, @"\\&[a-z0-9A-Z_]*;", "", RegexOptions.IgnoreCase); //计算数据 ent.结构 = SpiderHelp.获取户型结构(ent.结构); ent.建筑类型 = SpiderHelp.GetBuildingType(Convert.ToString(ent.总楼层)); //获取计算建筑类型; ent.用途 = SpiderHelp.GetHousePurposes(ent.用途, 城市名称, Convert.ToString(ent.单价), Convert.ToString(ent.面积), Convert.ToString(ent.总楼层), Convert.ToString(ent.所在楼层), ent.建筑形式, ent.建筑类型); //获取计算用途 ent.户型 = SpiderHelp.GetHouseType(ent.户型).ToRemoveSpe(); 案例时间 = 案例时间 != null?案例时间.Trim() : 案例时间; ent.装修 = SpiderHelp.获取装修类型(ent.装修); if (!StringHelp.CheckStrIsDate(案例时间)) { ent.案例时间 = DateTime.Now; } else { ent.案例时间 = Convert.ToDateTime(案例时间); } return(ent); }
/// <summary> /// Verifica se o número da CNH é válido. /// </summary> /// <param name="cnh"></param> /// <returns></returns> public static bool IsCnh(string cnh) { if (cnh.Length != 11) { return(false); } if (StringHelp.AllCharsEquals(cnh)) { return(false); } int[] _peso1 = { 9, 8, 7, 6, 5, 4, 3, 2, 1 }; int[] _peso2 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int soma = 0; for (int i = 0; i < _peso1.Length; ++i) { soma += _peso1[i] * int.Parse(cnh[i].ToString()); } int d1 = soma % 11; if (d1 > 9 || d1 == 1) { d1 = 0; } soma = 0; for (int i = 0; i < _peso2.Length; ++i) { soma += _peso2[i] * int.Parse(cnh[i].ToString()); } int d2 = soma % 11; if (d2 > 9 || d2 == 1) { d2 = 0; } string digitos = d1.ToString() + d2.ToString(); return(cnh.EndsWith(digitos)); }
/// <summary> /// API检查用户登录 /// </summary> /// <param name="userInfo"></param> /// <returns></returns> public Tuple <bool, string> APICheckLogin(ViewUserLogin userInfo) { bool validate = false; userInfo.UserPwd = userInfo.UserPwd.GetMD5FromString(); var userName = StringHelp.FilterSql(userInfo.UserName); var userPwd = StringHelp.FilterSql(userInfo.UserPwd); var user = userBll.FirstOrDefault <Sys_User>(x => x.UserNickName.Equals(userName) && x.Password.Equals(userPwd)); string userId = string.Empty; if (user != null) { userId = user.UserId; SetUserCacheAPI(user); validate = true; } return(new Tuple <bool, string>(validate, userId)); }
/// <summary> /// 检查房屋面积(1000>area>15) /// </summary> /// <param name="area"></param> /// <returns></returns> public static bool CheckHouseArea(string area) { if (string.IsNullOrEmpty(area)) { return(false); } area = StringHelp.TrimBlank(area); if (!StringHelp.IsInteger(area)) { return(false); } int _area = Convert.ToInt32(area); if (_area > 15 && _area < 1000) { return(true); } return(false); }
/// <summary> /// 检查单价范围(100000>unitPrice>3000) /// </summary> /// <param name="unitPrice"></param> /// <returns></returns> public static bool CheckHouseUnitPrice(string unitPrice) { if (string.IsNullOrEmpty(unitPrice)) { return(false); } unitPrice = StringHelp.TrimBlank(unitPrice); if (!StringHelp.IsInteger(unitPrice)) { return(false); } int _unitPrice = Convert.ToInt32(unitPrice); if (_unitPrice > 100 && _unitPrice < 200000) { return(true); } return(false); }
/// <summary> /// 文件在线浏览地址 :TODO /// </summary> /// <param name="file"></param> /// <returns></returns> public static string FileViewURL(IFile file) { if (file is Attachment) { file = file as Attachment; } else if (file is IESFile) { file = file as IESFile; } else if (file is IES.Resource.Model.File) { file = file as IES.Resource.Model.File; } string ext = StringHelp.GetFileNameExt(file.FileName).ToLower(); ResourceServer server = StoreServie.ResourceServer_Get(file.ServerID); return(string.Format(downurl, server.Host, server.NginxPort, server.NginxFolder, file.FileName)); }
/// <summary> /// 获取楼盘名模糊下拉(爬取库楼盘) /// </summary> /// <param name="likeName"></param> /// <returns></returns> public ActionResult GetProjectNameByLike_Api() { string q = Request["q"]; string limit = Request["limit"]; int? cityId = null; int maxCount = 10; if (!string.IsNullOrEmpty(limit) && StringHelp.IsInteger(limit)) { maxCount = Convert.ToInt32(limit); } if (StringHelp.IsInteger(Request["cityId"])) { cityId = Convert.ToInt32(Request["cityId"]); } if (maxCount > 100) { maxCount = 100; } string[] strings = CaseManager.GetProjectInfoStringsByLike(q, maxCount, cityId: cityId); StringBuilder sb = new StringBuilder(""); if (strings != null) { foreach (string str in strings) { sb.Append(str).Append("\n"); } } string result = sb.ToString(); Response.Write(result); Response.End(); return(null); }
/// <summary> /// Verifica se o número do PIS é válido. /// </summary> /// <param name="pis"></param> /// <returns></returns> public static bool IsPis(string pis) { int[] multiplicador = new int[10] { 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 }; if (pis.Trim().Length != 11) { return(false); } if (StringHelp.AllCharsEquals(pis)) { return(false); } pis = pis.Trim(); pis = pis.Replace("-", "").Replace(".", "").PadLeft(11, '0'); int soma = 0; for (int i = 0; i < 10; i++) { soma += int.Parse(pis[i].ToString()) * multiplicador[i]; } int resto = soma % 11; if (resto < 2) { resto = 0; } else { resto = 11 - resto; } return(pis.EndsWith(resto.ToString())); }
public void start() { RegexInfo cityRegexInfo = new RegexInfo("<dl id=\"clist\">((?:(?!</dl>).)*)</dl>", "$1"); RegexInfo cityRegexInfo2 = new RegexInfo("(<a href=\"[^\"]+\" onclick=\"co\\([^\"]+\">[^<>]+</a>)", "$1"); Dictionary <string, RegexInfo> cityRegexDic = new Dictionary <string, RegexInfo>(); cityRegexDic.Add("城市列表Text", cityRegexInfo); Dictionary <string, List <string> > dicCitylistText = SpiderHelp.GetHtmlByRegex("http://www.58.com/ershoufang/changecity/", "utf-8", cityRegexDic, WebsiteManager.GetWebById(WebsiteManager.五八同城_ID), CityId); string cityText = dicCitylistText["城市列表Text"].Count > 0 ? dicCitylistText["城市列表Text"][0] : ""; cityRegexDic.Add("城市列表", cityRegexInfo2); Dictionary <string, List <string> > dicCitylist = SpiderHelp.GetStrByRegex(cityText, cityRegexDic); List <string> cityList = dicCitylist["城市列表"]; StringBuilder citySb = new StringBuilder(); foreach (string cityInfoStr in cityList) { RegexInfo regexCityName = new RegexInfo("<a href=\"[^\"]+\" onclick=\"co\\([^\"]+\">([^<>]+)</a>", "$1"); RegexInfo regexCityUrl = new RegexInfo("<a href=\"([^\"]+)\" onclick=\"co\\([^\"]+\">[^<>]+</a>", "$1"); Dictionary <string, RegexInfo> cityRegexDic2 = new Dictionary <string, RegexInfo>(); cityRegexDic2.Add("regexCityName", regexCityName); cityRegexDic2.Add("regexCityUrl", regexCityUrl); Dictionary <string, List <string> > dicCityInfo = SpiderHelp.GetStrByRegex(cityInfoStr, cityRegexDic2); string cityName = StringHelp.TrimBlank(dicCityInfo["regexCityName"].Count > 0 ? dicCityInfo["regexCityName"][0] : ""); string cityUrl = dicCityInfo["regexCityUrl"].Count > 0 ? dicCityInfo["regexCityUrl"][0] : ""; string execStr = " exec 往网站爬取配置表添加配置信息 '{0}','{1}','{2}','{3}','{4}',{5},{6}"; 城市表 city = CityManager.Get城市_byLike城市名称(cityName); if (city != null && SpiderWebConfigManager.get网站爬取配置_by城市ID_网站ID(city.ID, WebsiteManager.五八同城_ID) == null) { execStr = string.Format(execStr, WebsiteManager.五八同城, city.城市名称, cityUrl.Replace("/ershoufang", ""), cityUrl.TrimEnd('/') + "/", "", "2000", "2000"); citySb.Append(execStr).Append("\r\n"); } } string result = citySb.ToString(); 导出任务计划配置文件(); }
public static string 获取户型结构(string jg) { jg = StringHelp.TrimBlank(jg); jg = string.IsNullOrEmpty(jg) ? 结构Manager.平面 : jg; if (jg.Contains("平")) { jg = 结构Manager.平面; } else if (jg.Contains("跃")) { jg = 结构Manager.跃式; } else if (jg.Contains("复")) { jg = 结构Manager.式; } else if (jg.Contains("错")) { jg = 结构Manager.错层; } return(jg); }
/// <summary> /// 获取建筑类型 /// </summary> /// <param name="sumL">总楼层</param> /// <returns></returns> public static string GetBuildingType(string sumL) { sumL = StringHelp.TrimBlank(sumL); if (!StringHelp.IsInteger(sumL)) { return(""); } int _sumL = Convert.ToInt32(sumL); if (_sumL >= 18) { return(建筑类型Manager.高层); } if (_sumL >= 9) { return(建筑类型Manager.小高层); } if (_sumL > 3) { return(建筑类型Manager.多层); } return(建筑类型Manager.低层); }
/// <summary> /// 根据详细页url获取信息 /// </summary> /// <param name="url">详细页url</param> public void GetHouseByUrl(string url) { //url = "http://esf.hd.zhijia.com/374810.html"; try { //设置各字段规则(正则) Dictionary <string, RegexInfo> dicRegexInfo = new Dictionary <string, RegexInfo>(); dicRegexInfo.Add("*regex_lpm", regex_lpm); dicRegexInfo.Add("*regex_xzq", regex_xzq); dicRegexInfo.Add("regex_pq", regex_pq); dicRegexInfo.Add("regex_hx", regex_hx); dicRegexInfo.Add("*regex_mj", regex_mj); dicRegexInfo.Add("*regex_dj", regex_dj); dicRegexInfo.Add("*regex_zj", regex_zj); dicRegexInfo.Add("regex_jznd", regex_jznd); dicRegexInfo.Add("regex_cx", regex_cx); dicRegexInfo.Add("regex_szlc", regex_szlc); dicRegexInfo.Add("regex_zlc", regex_zlc); dicRegexInfo.Add("regex_jg", regex_jg); dicRegexInfo.Add("regex_yt", regex_yt); dicRegexInfo.Add("regex_zx", regex_zx); dicRegexInfo.Add("regex_title", regex_title); dicRegexInfo.Add("regex_phone", regex_phone); dicRegexInfo.Add("*regex_address", regex_address); dicRegexInfo.Add("regex_datetime", regex_datetime); dicRegexInfo.Add("regex_comName", regex_comName); dicRegexInfo.Add("regex_comArea", regex_comArea); Dictionary <string, List <string> > dicRegexInfo_List = new Dictionary <string, List <string> >(); //根据规则获取数据 dicRegexInfo_List = SpiderHelp.GetHtmlByRegex(url, "utf-8", dicRegexInfo, WebObj, CityId, keepAlive: true); string value_title = dicRegexInfo_List["regex_title"].Count < 1 ? "" : dicRegexInfo_List["regex_title"][0].Replace(" ", ""); string value_lpm = dicRegexInfo_List["*regex_lpm"].Count < 1 ? "" : dicRegexInfo_List["*regex_lpm"][0].TrimBlank(); string value_xzq = dicRegexInfo_List["*regex_xzq"].Count < 1 ? "" : dicRegexInfo_List["*regex_xzq"][0].TrimBlank(); string value_pq = dicRegexInfo_List["regex_pq"].Count < 1 ? "" : dicRegexInfo_List["regex_pq"][0].TrimBlank(); string value_hx = dicRegexInfo_List["regex_hx"].Count < 1 ? "" : dicRegexInfo_List["regex_hx"][0].TrimBlank(); string value_mj = dicRegexInfo_List["*regex_mj"].Count < 1 ? "" : dicRegexInfo_List["*regex_mj"][0].TrimBlank(); string value_dj = dicRegexInfo_List["*regex_dj"].Count < 1 ? "" : dicRegexInfo_List["*regex_dj"][0].TrimBlank(); string value_zj = dicRegexInfo_List["*regex_zj"].Count < 1 ? "" : dicRegexInfo_List["*regex_zj"][0].TrimBlank(); string value_jznd = dicRegexInfo_List["regex_jznd"].Count < 1 ? "" : dicRegexInfo_List["regex_jznd"][0].TrimBlank().Replace(" ", ""); string value_cx = dicRegexInfo_List["regex_cx"].Count < 1 ? "" : dicRegexInfo_List["regex_cx"][0].TrimBlank().Replace(" ", "");; string value_szlc = dicRegexInfo_List["regex_szlc"].Count < 1 ? "" : dicRegexInfo_List["regex_szlc"][0].TrimBlank(); string value_zlc = dicRegexInfo_List["regex_zlc"].Count < 1 ? "" : dicRegexInfo_List["regex_zlc"][0].TrimBlank(); string value_jg = dicRegexInfo_List["regex_jg"].Count < 1 ? "" : dicRegexInfo_List["regex_jg"][0].TrimBlank(); string value_yt = dicRegexInfo_List["regex_yt"].Count < 1 ? "" : dicRegexInfo_List["regex_yt"][0].TrimBlank(); string value_zx = dicRegexInfo_List["regex_zx"].Count < 1 ? "" : dicRegexInfo_List["regex_zx"][0].TrimBlank().Replace(" ", "");; string value_phone = dicRegexInfo_List["regex_phone"].Count < 1 ? "" : dicRegexInfo_List["regex_phone"][0].TrimBlank(); string value_address = dicRegexInfo_List["*regex_address"].Count < 1 ? "" : dicRegexInfo_List["*regex_address"][0].TrimBlank(); string value_datetime = dicRegexInfo_List["regex_datetime"].Count < 1 ? "" : dicRegexInfo_List["regex_datetime"][0].Trim(); string value_comName = dicRegexInfo_List["regex_comName"].Count < 1 ? "" : dicRegexInfo_List["regex_comName"][0]; string value_comArea = dicRegexInfo_List["regex_comArea"].Count < 1 ? "" : dicRegexInfo_List["regex_comArea"][0]; if (value_zx.Contains("无")) { value_zx = ""; } if (value_cx.Contains("无")) { value_cx = ""; } value_dj = value_dj.Replace(",", ""); //如果所在楼层和总楼层顺序颠倒 if (StringHelp.IsInteger(value_zlc.TrimBlank()) && StringHelp.IsInteger(value_szlc.TrimBlank())) { if (Convert.ToInt32(value_szlc.TrimBlank()) > Convert.ToInt32(value_zlc.TrimBlank())) { string a = value_szlc.TrimBlank(); value_szlc = value_zlc.TrimBlank(); value_zlc = a; } } //将数据添加到字典 用于excel NewHouse newHouse = new NewHouse(value_lpm, GetCaseDate(value_datetime), value_xzq, value_pq, "", "", value_yt, value_mj, value_dj, "", value_jg, "", value_zj, value_szlc, value_zlc, value_hx, value_cx, value_zx, value_jznd, value_title, value_phone, url, "", 网站名称, value_address, "", "", "", "", "", "", value_comName, value_comArea); //当前数据为一天前的数据时 newHouse.Alsj = newHouse.Alsj != null?newHouse.Alsj.Trim() : newHouse.Alsj; if (!newHouse.Alsj.CheckStrIsDate()) { newHouse.Alsj = DateTime.Now.AddDays(-1).ToString(); } //获取刚开始爬取时的小时单位 int nowH = Convert.ToInt32(nowDate.ToString("HH")); if (nowH < 12)//如果是在12点之前开始 则析取昨天的数据 { if (Convert.ToDateTime(newHouse.Alsj) < Convert.ToDateTime(nowDate.ToString("yyyy-MM-dd")).AddDays(-1)) { isNowPageStop = true; } } else //如果是在12点之后开始 则析取当天的数据 { if (Convert.ToDateTime(newHouse.Alsj) < Convert.ToDateTime(nowDate.ToString("yyyy-MM-dd"))) { isNowPageStop = true; } } isNowPageStop = false; //保存数据 SaveNowData(newHouse); log.Debug(string.Format("{0}-数据保存完成url:{1}--cityname:{2}--value_title:{3}--value_lpm{4}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), url, CityName, value_title, value_lpm)); } catch (Exception ex) { log.Error(string.Format("GetHouseByUrl()异常,url:{0}, cityName:{1}", url, CityName), ex); } }
/// <summary> /// 任务流 /// </summary> /// <returns></returns> private int TestTaskFlow() { int ret = -1; //string pattern = null; //eidRead = "NULL"; //两种情况进入此处:1、超时跳出了do while,2、按了空格确认上电 if (readWriteIdHandle.IsTimeOut) { frmMain.DisplayLog("测试超时\r\n"); return(ret); } do { frmMain.DisplayLog("测试中...\r\n"); CmdProcess cmdProcess = new CmdProcess(); //cmd类 tool = new ThirdPartyTool() { ToolDirectory = "Microsoft Azure Sphere SDK", ToolName = "InitializeCommandPrompt", Cmd = "azsphere device wifi show-status" }; string strRet; #region //获取OS版本 //strRet = cmdProcess.ExeCommand("", "azsphere device show-ota-status");//"azsphere device wifi show-status" //if (strRet.Contains("error: Could not connect to the device.")) //{ // frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} //if (strRet.Contains("is not a valid value")) //{ // frmMain.DisplayLog(string.Format("未claim设备 获取OS版本失败 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} #endregion //对比模块MAC地址-标签MAC地址 strRet = cmdProcess.ExeCommand("", "azsphere device wifi show-status");//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } //ret = DeviceCheck(tool, out strRet); //if (ret!=0) //{ // frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} string mouduleMac = cmdProcess.GetValueByKeyword(strRet, "MAC Address"); if (mouduleMac != labelSn) { frmMain.DisplayLog(string.Format("MAC检查:模块{0},标签{1} 对比不一致 FAIL\r\n", mouduleMac, labelSn)); break; } frmMain.DisplayLog(string.Format("MAC检查:模块{0},标签{1} 对比一致 PASS\r\n", mouduleMac, labelSn)); //检查是否有测试程序 //azsphere device sideload show-status //azsphere device sideload delete //azsphere device sideload deploy -p mt_app.img //删除当前程序 frmMain.DisplayLog("当前程序删除中...\r\n"); strRet = cmdProcess.ExeCommand("", "azsphere device sideload delete");//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } if (!strRet.Contains("Command completed successfully")) { frmMain.DisplayLog(string.Format("当前程序删除: 失败 FAIL\r\n详细:{0} \r\n", strRet)); break; } frmMain.DisplayLog("当前程序删除:成功 PASS\r\n"); Thread.Sleep(500); //Side load(加载测试固件) frmMain.DisplayLog("测试固件加载中...\r\n"); strRet = cmdProcess.ExeCommand("", string.Format("azsphere device sideload deploy -p ../app/{0}", TestAppName));//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } //tool.Cmd = "azsphere device sideload deploy -p mt_app.img"; //ret = DeviceCheck(tool, out strRet); //if (ret != 0) //{ // frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} if (!strRet.Contains("Command completed successfully")) { frmMain.DisplayLog(string.Format("加载测试固件:失败 FAIL\r\n详细:{0} \r\n", strRet)); break; } frmMain.DisplayLog(string.Format("加载测试固件:成功 PASS\r\n", strRet)); string pinTestRetinfo; //Socket复位 frmMain.DisplayLog("复位测试中...\r\n"); //成功 为有效信息 bool pinTestRet = PinTestBySocket("reset_tests", out pinTestRetinfo); frmMain.DisplayLog(pinTestRetinfo + "\r\n"); //失败 为错误信息 if (!pinTestRet) { frmMain.DisplayLog("复位测试:失败 FAIL\r\n");//失败 为错误信息 break; } frmMain.DisplayLog("复位测试:合格 PASS\r\n");//成功 为有效信息 //Socket GPIO检查 frmMain.DisplayLog("GPIO测试中...\r\n"); pinTestRet = PinTestBySocket("get_gpios", out pinTestRetinfo); frmMain.DisplayLog(pinTestRetinfo + "\r\n");//失败 为错误信息 if (!pinTestRet) { frmMain.DisplayLog("GPIO测试:测试失败 FAIL\r\n");//失败 为错误信息 break; } string errorStr; bool gpioRet = GetGIPOResultBySocketRet(pinTestRetinfo, out errorStr); //展示返回的GPIO数据 //strRet = strRet.Replace("P", "PASS").Replace("F", "FAIL") + "\r\n"; //frmMain.DisplayLog(strRet); //GPIO结果显示 if (!gpioRet) { frmMain.DisplayLog("GPIO测试: 不合格 FAIL \r\n"); break; } frmMain.DisplayLog("GPIO测试:合格 PASS\r\n");//成功 为有效信息 #region 串口测试 复位和GPIO ////串口发送Reset System\r\n //strRet = readWriteIdHandle.Read(ATReadCmd.ReadIdType.Reset); //if (string.IsNullOrEmpty(strRet)) //{ // frmMain.DisplayLog(string.Format("复位命令未得到回应 串口失败 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} ////if (!strRet.Contains("Get RST command")) ////{ //// frmMain.DisplayLog(string.Format("复位未得到回应 串口失败 FAIL\r\n详细:{0} \r\n", strRet)); //// break; ////} ////复位命令得到回应 //frmMain.DisplayLog(string.Format("复位中... \r\n")); ////跳出循环说明复位成功 //readWriteIdHandle.ReadRestInfo("init completed"); //frmMain.DisplayLog(string.Format("复位成功 PASS\r\n")); ////GPIO测试 ////串口发送Reset System\r\n //Thread.Sleep(1000); //strRet = readWriteIdHandle.Read(ATReadCmd.ReadIdType.GPIOTest); //if (string.IsNullOrEmpty(strRet)) //{ // frmMain.DisplayLog("GPIO测试命令未得到回应 串口失败 FAIL\r\n"); // break; //} ////GPIO测试命令得到回应 ////frmMain.DisplayLog("GPIO测试中... \r\n"); ////string errorInfo; ////bool gpioRet = checkGIPOResult(strRet, out errorInfo); //////展示返回的GPIO数据 ////strRet = strRet.Replace("P", "PASS").Replace("F", "FAIL") + "\r\n"; ////frmMain.DisplayLog(strRet); //////GPIO结果显示 ////if (!gpioRet) ////{ //// frmMain.DisplayLog(string.Format("GPIO测试:失败 FAIL \r\n详细:{0}\r\n", errorInfo)); //// break; ////} ////frmMain.DisplayLog("GPIO测试:成功 PASS\r\n"); #endregion //删除APPtest frmMain.DisplayLog("测试固件删除中...\r\n"); strRet = cmdProcess.ExeCommand("", "azsphere device sideload delete");//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } //tool.Cmd = "azsphere device sideload deploy -p mt_app.img"; //ret = DeviceCheck(tool, out strRet); //if (ret != 0) //{ // frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} if (!strRet.Contains("Command completed successfully")) { frmMain.DisplayLog(string.Format("测试固件删除:失败 FAIL\r\n详细:{0} \r\n", strRet)); break; } frmMain.DisplayLog("测试固件删除:成功 PASS\r\n"); frmMain.DisplayLog("Wifi列表网络检查中...\r\n"); //检查网络 wifi表 strRet = cmdProcess.ExeCommand("", "azsphere device wifi list");//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } if (!strRet.Contains("No networks found") && strRet.Contains("ID")) { //Get ID string[] wifiIdList = cmdProcess.GetListByKeyword(strRet, "ID").ToArray(); foreach (var item in wifiIdList) { frmMain.DisplayLog("WIFI列表检查:含有WIFI列表ID,删除中...\r\n"); //不为空 if (!string.IsNullOrEmpty(item)) { //删除ID strRet = cmdProcess.ExeCommand("", string.Format("azsphere device wifi delete –i {0}", item));//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); return(ret); } //不包含成功信息且不包含 if (!strRet.Contains("Successfully removed network") && !strRet.Contains("Command completed successfully")) { frmMain.DisplayLog(string.Format("WIFI列表ID删除:失败 FAIL\r\n详细:{0} \r\n", strRet)); return(ret); } } } } frmMain.DisplayLog("WIFI列表检查:PASS\r\n"); //性能测试 frmMain.DisplayLog("capabilties测试中...\r\n"); Capability: strRet = cmdProcess.ExeCommand("", "azsphere device capability show-attached");//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } if (!strRet.Contains("Command completed successfully")) { frmMain.DisplayLog(string.Format("capabilties测试:失败 FAIL\r\n详细:{0} \r\n", strRet)); break; } List <string> capabilitiesList = cmdProcess.GetListCapabilitiesKeyword(strRet, "Enable"); if (capabilitiesList.Count > 0) { //manufacture set complete status,只能设置一次,设置后就不能够RF测试和校准了,测试阶段不要轻易尝试。 #region if (IsManufactureComplete == 1) { strRet = cmdProcess.ExeCommand("", "manufacture set complete status");//"azsphere device wifi show-status" if (strRet.Contains("error: Could not connect to the device.")) { frmMain.DisplayLog(string.Format("未上电连接上设备,请检查连接或驱动 FAIL\r\n详细:{0} \r\n", strRet)); break; } frmMain.DisplayLog(string.Format("已设置制作完成状态,继续测试capabilties中... \r\n详细:{0} \r\n", strRet)); goto Capability; } #endregion frmMain.DisplayLog(string.Format("capabilties测试:失败 FAIL\r\n详细:{0} \r\n", strRet)); break; } frmMain.DisplayLog("capabilties测试:PASS\r\n"); //E-fuse测试 tool = new ThirdPartyTool() { ToolDirectory = "RFToolCli", Cmd = string.Format("RfSettingsTool check --expected ../bin/{0}", EfuseBin) }; //strRet = cmdProcess.ExeCommand(tool);//"azsphere device wifi show-status" //if (strRet.Contains("error")) //{ // frmMain.DisplayLog(string.Format("E-fuse测试:失败 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} //python //tool.Cmd = "python RunHeaderTest.py ";//reset_system //tool.ToolDirectory = "PC"; //strRet = cmdProcess.ExeCommand(tool, ""); //if (strRet.Contains("error")) //{ // frmMain.DisplayLog(string.Format("E-fuse测试:失败 FAIL\r\n详细:{0} \r\n", strRet)); // break; //} //E-fuse具体测试内容 frmMain.DisplayLog("e-fuse测试中...\r\n"); strRet = cmdProcess.ExeCommand(tool, ""); string hasReadFlag = "Comparing configurations."; string startFlag = "Reading configuration data from device."; string erroInfo = StringHelp.SubCentre(strRet, startFlag, "\r\n\r\n"); if (!strRet.Contains(hasReadFlag)) { frmMain.DisplayLog(string.Format("E-fuse测试:命令失败 \r\n详细:{0} \r\n", erroInfo)); break; } strRet = StringHelp.SubCentre(strRet, hasReadFlag, "\r\n\r\n"); frmMain.DisplayLog(strRet + "\r\n"); if (strRet.Contains("ERROR") || strRet.Contains("异常")) { frmMain.DisplayLog("E-fuse测试结果: FAIL \r\n"); break; } frmMain.DisplayLog("E-fuse测试:PASS\r\n"); ret = 0; //cd RFToolCli //List<string> listValue = readWriteIdHandle.ReadId(); //if (listValue.Count <= 3) //{ // break; //} ////多组:1,1,01,01,,,40,0*61 //int sum = 0; //string[] arryData; //try //{ // foreach (string strData in listValue) // { // arryData = strData.Split(','); // 应滤除其他可视卫星 // int cn0Value = int.Parse(arryData[6]); // sum += cn0Value; // } //} //catch (Exception ex) //{ // frmMain.DisplayLog(string.Format("数据解析错误:{0}\r\n", ex.Message)); // break; //} //int argVale = sum / listValue.Count; //frmMain.DisplayLog(string.Format("获取C/N0值:{0}\r\n", argVale)); //if (argVale < StandardCN01) //{ // frmMain.DisplayLog(string.Format("C/N0值:{0},小于设定范围{1} FAIL\r\n", argVale, StandardCN01)); // break; //} //frmMain.DisplayLog(string.Format("C/N0值:{0},大于设定范围{1} PASS\r\n", argVale,StandardCN01)); //ret = 0; ////从芯片获取eid ////eidRead = "081603FFFFF35293" + eidlast.ToString("X").PadLeft(4,'0'); //eidRead = readWriteIdHandle.ReadId(ATReadCmd.ReadIdType.EidRead); //pattern = @"[0-9A-Z]{20}"; //if (string.IsNullOrEmpty(eidRead) || !Regex.IsMatch(eidRead, pattern)) //{ // frmMain.DisplayLog("EID读取失败\r\n"); // break; //} //frmMain.DisplayLog(string.Format("已获取模块EID:{0}\r\n", eidRead)); //frmMain.SetText(AllForms.EnumControlWidget.txtEid.ToString(), eidRead, false); } while (false); ProductionInfo.SystemType systemType = ProductionInfo.Type; //使用do..while(false)的原因,是为了当测试流程为fail时,使用break跳出该结构,仍然执行结果上报 return(ret); }