protected void Page_Load(object sender, EventArgs e) { object re = null; try { string IPCurl = ConfigurationManager.ConnectionStrings["IPCurl"].ToString(); //聚合中心地址 string GX_shibie = Request["yewuming"].ToString(); //用进程池名称作为标识 FMWScenter wsd = new FMWScenter(IPCurl + "?wsdl"); re = wsd.ExecuteQuery("GetGX_from_GX_shibie", new object[] { GX_shibie }); if (re == null) { Page.ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('获取失败,得到了null!');history.go(-1);</script>"); return; } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(); ((DataSet)re).WriteXml(ms, XmlWriteMode.WriteSchema); Response.Clear(); // 下载附件的名字 Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(GX_shibie, System.Text.Encoding.UTF8) + "_IPClist.config"); // 下载附件的大小,以便让浏览器显示进度条 Response.AddHeader("Content-Length", ms.Length.ToString()); // 指定浏览器为下载模式 Response.ContentType = "application/octet-stream"; // 发送到客户端 byte[] b = ms.ToArray(); Response.OutputStream.Write(b, 0, b.Length); Response.End(); } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('获取失败!'" + ex.ToString() + ");history.go(-1);</script>"); return; } }
//对选中的项目执行通知更新 protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i].FindControl("IP_chkItem"); if (ckb.Checked) { showmsg.InnerHtml = showmsg.InnerHtml + "====" + GridView1.Rows[i].Cells[1].Text.Trim() + "[" + GridView1.Rows[i].Cells[2].Text.ToString() + "][" + GridView1.Rows[i].Cells[3].Text.ToString() + "]===<br />"; //找到IPC登记的有效接口,进行批量通知。 object re = null; try { string IPCurl = "http://" + GridView1.Rows[i].Cells[2].Text.ToString() + ":" + GridView1.Rows[i].Cells[3].Text.ToString() + "/OrderFormIPC.asmx"; FMWScenter wsd = new FMWScenter(IPCurl + "?wsdl"); re = wsd.ExecuteQuery("ReSetThisWebServices", new object[] { "" }); if (re == null) { showmsg.InnerHtml = showmsg.InnerHtml + "结果:发送通知出错" + "<br />"; } else { showmsg.InnerHtml = showmsg.InnerHtml + "结果:" + re.ToString() + "<br />"; } } catch (Exception ex) { showmsg.InnerHtml = showmsg.InnerHtml + i + "结果:" + ex.ToString() + "<br />"; } showmsg.InnerHtml = showmsg.InnerHtml + "==============================================<br />"; } } if (showmsg.InnerHtml.ToString().Trim() == "") { Page.ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('未选中任何项!');</script>"); return; } }
//处理异步队列 private void RunQueue() { RedisClient RC = FMDBHelperClass.RedisClass.GetRedisClient(null); while (runing) { Thread.Sleep(1); string LeftOneGUID = "0"; try { //队列中,从左边开始,取出1个,按顺序进行处理 //从这里直接连接Redis,写入异步处理队列 //取出并删除最左边的元素。没有的话,会阻塞这个线程和此项目的连接。 LeftOneGUID = RC.BlockingRemoveStartFromList("L:queIPC:RUN", new TimeSpan(0, 5, 0)); if (LeftOneGUID == null) { } else { //根据这个GUID,获取接口数据进行调用。 调用完成且接口没返回null(不代表业务成功),就删除。否则保留下来。 //调用目标的基本信息 Dictionary <string, string> FF = RC.GetAllEntriesFromHash("H:queIPC:FF:" + LeftOneGUID); //参数 byte[][] CS = RC.ZRange("Z:queIPC:CS:" + LeftOneGUID, 0, -1); int CScount = CS.Count(); object[] objectCS = new object[CScount]; for (int i = 0; i < CScount; i++) { MemoryStream ms = new MemoryStream(CS[i]); IFormatter bf = new BinaryFormatter(); objectCS[i] = bf.Deserialize(ms); ms.Close(); ms.Dispose(); } //开始调用 object re = null; string Durls = "http://" + FF["JKhost"] + "/" + FF["JKpath"]; FMWScenter wsd = new FMWScenter(Durls + "?wsdl"); re = wsd.ExecuteQuery(FF["FFname"], objectCS); if (re != null) { //异步执行完成没有返回null,删除关联数据 RC.Del(new string[] { "H:queIPC:FF:" + LeftOneGUID, "Z:queIPC:CS:" + LeftOneGUID }); } else { //异步执行返回了null,通常都是没有成功 RC.PushItemToList("L:queIPC:RUNERR", LeftOneGUID); } } } catch (Exception ex) { //发生了错误,记录一下。目前只是简单的记录。以后再说 RC.PushItemToList("L:queIPC:RUNERR", LeftOneGUID); } } MessageBox.Show("。。。。。停了。。。。。。"); // }