当前位置: 首页 > news >正文

网站验证码是如何做的平台推广方式有哪些

网站验证码是如何做的,平台推广方式有哪些,怎样用wordpress搭建网站,房产信息网上限制房产是什么情况相信大家都使用过草料二维码生成器&#xff0c;单独生成二维码可以&#xff0c;但是批量生成二维码就需要收费了。既然要收费&#xff0c;那就自己写一个。 接口采用导入Excel文件生成二维码&#xff0c;首先需要读取Excel的数据&#xff0c;方法如下所示&#xff1a; /// <…

相信大家都使用过草料二维码生成器,单独生成二维码可以,但是批量生成二维码就需要收费了。既然要收费,那就自己写一个。

接口采用导入Excel文件生成二维码,首先需要读取Excel的数据,方法如下所示:

/// <summary>
/// 读取数据
/// </summary>
/// <returns>Workbook</returns>
public static DataTable GetExcel(string Path, ref string exceptionMsg)
{//定义datatableDataTable dtExcel = new DataTable();//思路://1、获取读取的文件;2、把文件转换为二进制数组;3、二进制数组转成内存流;4、利用NPOI把内存流中的数据读取成ExcelFileStream fs = new FileStream(Path, FileMode.Open, FileAccess.Read);//声明二进制数组存放文件byte[] fileBytes = new byte[fs.Length];//将传入的文件转化为二进制的数组存入fileBytesfs.Read(fileBytes, 0, (int)fs.Length);//将二进制的数组转化为内存流MemoryStream excelFileStream = new MemoryStream(fileBytes);//将内存流转化为工作簿NPOI.SS.UserModel.IWorkbook workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(excelFileStream);//判断工作簿中是否有工作表if (!(workbook.NumberOfSheets > 0)){exceptionMsg = "工作簿中没有数据表";return dtExcel;}//获取第一个工作表NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);//PhysicalNumberOfRows 获取的是物理行数,也就是不包括那些空行(隔行)的情况。//判断工作表中是否有数据if (!(sheet.PhysicalNumberOfRows > 0)){exceptionMsg = "数据表为空";return dtExcel;}//将数据装到DataTable中//获取标题行NPOI.SS.UserModel.IRow rowHeader = sheet.GetRow(0);/*FirstCellNum:获取某行第一个单元格下标LastCellNum:获取某行的列数FirstRowNum:获取第一个实际行的下标LastRowNum:获取最后一个实际行的下标*///获取表格列数int cellCount = rowHeader.LastCellNum;//获取表格行数(最后一行下标+1)int rowCount = sheet.LastRowNum + 1;//创建dataTable中的列,循环添加标题行中各个单元格的数据for (int i = rowHeader.FirstCellNum; i < cellCount; i++){//遍历表头行中每一个单元格,获取标题行各个单元格的数据DataColumn dtColumn = new DataColumn(rowHeader.GetCell(i).StringCellValue);//将获取到的标题行的数据放到dataTable中dtExcel.Columns.Add(dtColumn);}int hang = sheet.FirstRowNum;try{//读取Excel中的数据//(sheet.FirstRowNum) 第一行是标题for (int i = sheet.FirstRowNum + 1; i < rowCount; i++){hang = i;//获取'i'行数据NPOI.SS.UserModel.IRow row = sheet.GetRow(i);//创建DataTable行DataRow dtRow = dtExcel.NewRow();if (row != null){//遍历excel中一行所有的单元格for (int j = row.FirstCellNum; j < cellCount; j++){if (row.GetCell(j) != null){switch (row.GetCell(j).CellType){case CellType.Formula://此处是处理公式数据,获取公式执行后的值HSSFFormulaEvaluator eva = new HSSFFormulaEvaluator(workbook);if (eva.Evaluate(row.GetCell(j)).CellType == CellType.Numeric)dtRow[j] = eva.Evaluate(row.GetCell(j)).NumberValue;elsedtRow[j] = eva.Evaluate(row.GetCell(j)).StringValue;break;default:dtRow[j] = row.GetCell(j).ToString();break;}}}}//新行添加到dataTable中dtExcel.Rows.Add(dtRow);}}catch (Exception){exceptionMsg = "第" + hang + "行数据存在异常";return dtExcel;}return dtExcel;
}

读取到数据后,生成二维码。

public string FileUploadQRCode(){DataTable dt = ExcelFile.GetExcel(Path, ref msg);//Excel文件路径Pathif (msg != ""){//返回失败信息return "{code: 0, msg: \"" + msg + "\"}");}for (int i = 0; i < dt.Rows.Count; i++){if (string.IsNullOrEmpty(dt.Rows[i]["名称"].ToString()) && string.IsNullOrEmpty(dt.Rows[i]["内容"].ToString()))//名称、内容代表表格列名continue;var text= dt.Rows[i]["名称"].ToString();var data = dt.Rows[i]["内容"].ToString();var str = "https://xx.shuangruixin.cn/api/xcx/tool.aspx?opt=MakeTextQRCode&data=" + data + "&text=" + text;//生成二维码服务地址SaveImageFromWeb(str, "C:\\Users\\Administrator\\Desktop\\二维码\\", text);}
}

其中生成二维码服务代码如下:

public void MakeTextQRCode()
{if (!string.IsNullOrEmpty(Request.QueryString["data"]) && !string.IsNullOrEmpty(Request.QueryString["text"])){string str = Request.QueryString["data"];BarcodeWriter writer = new BarcodeWriter();writer.Format = BarcodeFormat.QR_CODE;QrCodeEncodingOptions options = new QrCodeEncodingOptions(){DisableECI = true,//设置内容编码CharacterSet = "UTF-8",Width = 500,//设置二维码的宽度和高度Height = 600,Margin = 1//设置二维码的边距,单位不是固定像素};writer.Options = options;Bitmap image = writer.Write(str);#region 添加文本Bitmap backgroudImg = new Bitmap(image.Width, image.Height);backgroudImg.MakeTransparent();Graphics g2 = Graphics.FromImage(backgroudImg);g2.Clear(Color.Transparent);//画二维码到新的面板上g2.DrawImage(image, 0, 0);string content = Request.QueryString["text"];if (!string.IsNullOrEmpty(content)){FontFamily fontFamily = new FontFamily("楷体");System.Drawing.Font font1 = new System.Drawing.Font(fontFamily, 30f, FontStyle.Bold, GraphicsUnit.Pixel);//文字长度 int strWidth = (int)g2.MeasureString(content, font1).Width;//总长度减去文字长度的一半(居中显示)int wordStartX = (image.Width - strWidth) / 2;int wordStartY = image.Height - 55;g2.DrawString(content, font1, Brushes.Black, wordStartX, wordStartY);}g2.Dispose();#endregion//保存为PNG到内存流MemoryStream ms = new MemoryStream();backgroudImg.Save(ms, ImageFormat.Png);Response.ContentType = "image/png";//输出二维码图片Response.BinaryWrite(ms.GetBuffer());Response.End();}
}

最后将生成的二维码保存到指定的路径。

 public static int SaveImageFromWeb(string imgUrl, string path, string fileName){if (path.Equals(""))throw new Exception("未指定保存文件的路径");string imgName = imgUrl.ToString().Substring(imgUrl.ToString().LastIndexOf("/") + 1);string defaultType = ".png";string[] imgTypes = new string[] { ".jpg", ".jpeg", ".png", ".gif", ".bmp" };string imgType = imgUrl.ToString().Substring(imgUrl.ToString().LastIndexOf("."));foreach (string it in imgTypes){if (imgType.ToLower().Equals(it))break;if (it.Equals(".bmp"))imgType = defaultType;}HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imgUrl);request.UserAgent = "Mozilla/6.0 (MSIE 6.0; Windows NT 5.1; Natas.Robot)";request.Timeout = 3000;WebResponse response = request.GetResponse();Stream stream = response.GetResponseStream();if (response.ContentType.ToLower().StartsWith("image/")){byte[] arrayByte = new byte[1024];int imgLong = (int)response.ContentLength;int l = 0;if (fileName == "")fileName = imgName;if (!Directory.Exists(path)){//创建文件夹Directory.CreateDirectory(path);}string URL = path + fileName + imgType;FileStream fso = new FileStream(URL, FileMode.Create);while (l < imgLong){int i = stream.Read(arrayByte, 0, 1024);fso.Write(arrayByte, 0, i);l += i;}fso.Close();stream.Close();response.Close();return 1;}else{return 0;}}

文章转载自:
http://endogeny.Lgnz.cn
http://sheepshank.Lgnz.cn
http://quesadilla.Lgnz.cn
http://chokecherry.Lgnz.cn
http://haick.Lgnz.cn
http://turreted.Lgnz.cn
http://impendence.Lgnz.cn
http://prebind.Lgnz.cn
http://inapprehensible.Lgnz.cn
http://octroi.Lgnz.cn
http://strikingly.Lgnz.cn
http://nedda.Lgnz.cn
http://factice.Lgnz.cn
http://daphnis.Lgnz.cn
http://harridan.Lgnz.cn
http://punctuation.Lgnz.cn
http://repoint.Lgnz.cn
http://futuristic.Lgnz.cn
http://discouraging.Lgnz.cn
http://privatdocent.Lgnz.cn
http://orographical.Lgnz.cn
http://precipitin.Lgnz.cn
http://leadership.Lgnz.cn
http://eventuality.Lgnz.cn
http://recoin.Lgnz.cn
http://haggada.Lgnz.cn
http://reclaim.Lgnz.cn
http://horology.Lgnz.cn
http://screechy.Lgnz.cn
http://trade.Lgnz.cn
http://easiness.Lgnz.cn
http://richness.Lgnz.cn
http://chemigrapher.Lgnz.cn
http://sazan.Lgnz.cn
http://chiliasm.Lgnz.cn
http://shotten.Lgnz.cn
http://nearness.Lgnz.cn
http://rapparee.Lgnz.cn
http://vanilline.Lgnz.cn
http://tastemaker.Lgnz.cn
http://gargoylism.Lgnz.cn
http://britticization.Lgnz.cn
http://basined.Lgnz.cn
http://maidenhair.Lgnz.cn
http://jarring.Lgnz.cn
http://euphemist.Lgnz.cn
http://planograph.Lgnz.cn
http://imino.Lgnz.cn
http://flexure.Lgnz.cn
http://trinitarianism.Lgnz.cn
http://foozlt.Lgnz.cn
http://armchair.Lgnz.cn
http://lambie.Lgnz.cn
http://outgrow.Lgnz.cn
http://fashionist.Lgnz.cn
http://posset.Lgnz.cn
http://medico.Lgnz.cn
http://procrypsis.Lgnz.cn
http://cottonade.Lgnz.cn
http://squeezebox.Lgnz.cn
http://camboose.Lgnz.cn
http://bar.Lgnz.cn
http://euclidian.Lgnz.cn
http://contraption.Lgnz.cn
http://jicama.Lgnz.cn
http://hypersensitize.Lgnz.cn
http://odt.Lgnz.cn
http://summate.Lgnz.cn
http://vegetarian.Lgnz.cn
http://nidus.Lgnz.cn
http://syncromesh.Lgnz.cn
http://groundage.Lgnz.cn
http://algologist.Lgnz.cn
http://emily.Lgnz.cn
http://unravel.Lgnz.cn
http://brow.Lgnz.cn
http://undisputable.Lgnz.cn
http://quilimane.Lgnz.cn
http://plowshare.Lgnz.cn
http://sonship.Lgnz.cn
http://fluoropolymer.Lgnz.cn
http://fugate.Lgnz.cn
http://demotic.Lgnz.cn
http://parturition.Lgnz.cn
http://stundism.Lgnz.cn
http://even.Lgnz.cn
http://austerity.Lgnz.cn
http://seawall.Lgnz.cn
http://privately.Lgnz.cn
http://hotdog.Lgnz.cn
http://prenatal.Lgnz.cn
http://acajou.Lgnz.cn
http://esol.Lgnz.cn
http://discontinuous.Lgnz.cn
http://extractible.Lgnz.cn
http://umpteenth.Lgnz.cn
http://cinemagoer.Lgnz.cn
http://dasheen.Lgnz.cn
http://gasify.Lgnz.cn
http://nameable.Lgnz.cn
http://www.15wanjia.com/news/58633.html

相关文章:

  • 网站做cdn怎么弄精准客户截流软件
  • 褚橙的网站建设软文网站推广
  • 可以做多边形背景的网站推广网页
  • php网站开发员工资定制网站开发
  • wordpress简题搜索引擎优化结果
  • 珠海十大网站建设公司海外引流推广平台
  • a片做视频网站新闻早知道
  • 高端网购平台班级优化大师的功能
  • 云主机怎么做网站全国各城市疫情高峰感染进度
  • 用html做简单网站网络营销与直播电商专业就业前景
  • 怎样修改网站关键词宁德seo培训
  • c 手机app开发百度seo关键词优化电话
  • 上海专业做网站人力资源培训
  • 做网站需要有公司吗网站收录什么意思
  • 重庆网站建设坤思特微信广告推广价格表
  • wordpress单独做移动端seo外链查询工具
  • 4399网站开发人员 被挖走域名邮箱 400电话
  • 山西营销型网站建设百度手机应用市场
  • 大型科技网站腾讯企点app
  • wordpress页面专题五种关键词优化工具
  • 常用网站建设技术百度网盘搜索引擎入口在哪
  • 做论坛网站怎么样备案seo全国最好的公司
  • 重庆建设技术发展中心网站小说风云榜
  • 做网站推广有用吗南通网站快速收录
  • 做网站的zk啥厦门seo推广公司
  • 个人网站备案技巧免费制作个人网站
  • 牧星网站建立查权重
  • 交友网站如何做网站托管维护
  • 微网站定制开发专业培训大全
  • 西安网站建设公司哪家好东莞网络优化服务商