03 2012 档案

摘要:public partial class Form1 : Form {[DllImport("wininet.dll")]private extern static bool getInterState(out int conn, int val);public Form1(){InitializeComponent(); getNet(); } //判断当前是否连接入Internet网络 private void getNet() { int Out; if (getInterState(out Out, 0) == true) { label1.Text = " 阅读全文
posted @ 2012-03-20 17:10 Chaoa 阅读(355) 评论(0) 推荐(0)
摘要:利用 MSMQ(Microsoft Message Queue),应用程序开发人员可以通过发送和接收消息方便地与应用程序进行快速可靠的通信。消息处理为您提供了有保障的消息传递和执行许多业务处理的可靠的防故障方法。MSMQ与XML Web Services和.Net Remoting一样,是一种分布式开发技术。但是在使用XML Web Services或.Net Remoting组件时,Client端需要和Server端实时交换信息,Server需要保持联机。MSMQ则可以在Server离线的情况下工作,将Message临时保存在Client端的消息队列中,以后联机时再发送到Server端处理。 阅读全文
posted @ 2012-03-13 16:00 Chaoa 阅读(902) 评论(1) 推荐(0)
摘要:ASP.NET读取Excel文件方法一:采用OleDB读取Excel文件:把Excel文件当做一个数据源来进行数据的读取操作,实例如下:publicDataSetExcelToDS(stringPath){stringstrConn="Provider=Microsoft.Jet.OLEDB.4.0;"+"DataSource="+Path+";"+"ExtendedProperties=Excel8.0;";OleDbConnectionconn=newOleDbConnection(strConn);conn. 阅读全文
posted @ 2012-03-09 09:38 Chaoa 阅读(414) 评论(0) 推荐(0)
摘要:C#中Cookies的存取 c#中cookies的存取操作c#中cookies的存取cookies的创建:在客户端创建一个username的cookies,其值为oneday,有效期为1天.方法1:Response.Cookies["username"].Value="admin";Response.Cookies["username"].Expires=DateTime.Now.AddDays(1);方法2:System.Web.HttpCookie newcookie=newHttpCookie("username&qu 阅读全文
posted @ 2012-03-09 09:36 Chaoa 阅读(335) 评论(0) 推荐(0)
摘要:导出成EXCEL:Excel.Application excel=newExcel.Application(); excel.Application.Workbooks.Add(true); excel.Visible=true;for(inti=0; i<this.dataGridView1.ColumnCount; i++) { excel.Cells[1, i+1]=this.dataGridView1.Columns[i].HeaderText; }for(inti=0; i<this.dataGridView1.RowCount-1; i++) {for(intj=0; 阅读全文
posted @ 2012-03-09 08:33 Chaoa 阅读(521) 评论(0) 推荐(0)
摘要:这种方法的优势在于发布之前压缩aspx,无须浪费web server的cpu两种方法实现:1)一行一行的读取aspx文件然后处理2)一次性读取aspx文件然后处理处理逻辑:替换" "为" "(将两个空格替换为一个空格),将所有的换行符替换为空字符(极限压缩)注意事项:1)一行一行处理在极限压缩的情况下需要额外的处理服务端控件换行的情况,比如Line 1:<asp:Label runat="server"Line 2: ID="lb1" ....Line 3:.../>这种情况 一行一行处理会出问题2) 阅读全文
posted @ 2012-03-09 08:31 Chaoa 阅读(847) 评论(0) 推荐(0)
摘要:usingSystem;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Web;usingSystem.Web.SessionState;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.HtmlControls;usingSystem.Xml;privateXmlDocument xmlDoc;//load xml fileprivatevoidLoadX 阅读全文
posted @ 2012-03-09 08:30 Chaoa 阅读(205) 评论(0) 推荐(0)
摘要:protectedvoidApplication_BeginRequest(objectsender, EventArgs e){stringurl=Request.RawUrl.ToString();if(url.ToLower().IndexOf("page/bloglist/")>-1&&url.IndexOf("?")<0){intlastg=url.LastIndexOf("/");intlastdot=url.LastIndexOf(".aspx");stringnurl=S 阅读全文
posted @ 2012-03-09 08:28 Chaoa 阅读(708) 评论(0) 推荐(0)
摘要:在Asp.Net中后台实现中实现定时器功能,每过指定的时间自动执行函数功能代码如下:Global.asax 启动定时器voidApplication_Start(objectsender,EventArgse){//在应用程序启动时运行的代码System.Timers.TimermyTimer=newSystem.Timers.Timer(60000);myTimer.Elapsed+=newSystem.Timers.ElapsedEventHandler(OnTimedEvent);myTimer.Interval=60000;myTimer.Enabled=true;}privatest 阅读全文
posted @ 2012-03-09 08:26 Chaoa 阅读(401) 评论(0) 推荐(0)
摘要://写一个类public class SplictPage{public static string bind(string content, string Id){string thisnr = "";string thispage = "";string[] temp = content.Trim().Split(<a href="mailto:'{@cpbcw}');">'{$cpbcw$}');</a>if (System.Web.HttpContext.Current. 阅读全文
posted @ 2012-03-09 08:26 Chaoa 阅读(315) 评论(0) 推荐(0)
摘要:ServerOS = Environment.OSVersion.ToString();//操作系统:CpuSum = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS");//CPU个数:CpuType = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");//CPU类型:ServerSoft = Request.ServerVariables["SERVER_SOFTWARE"];//信息服务软件:M 阅读全文
posted @ 2012-03-09 08:24 Chaoa 阅读(408) 评论(0) 推荐(0)
摘要:usingSystem.IOvoidDownload(){System.IO.FileStream r=newSystem.IO.FileStream(FileName, System.IO.FileMode.Open);//文件下载实例化//设置基本信息Response.Buffer=false;Response.AddHeader("Connection","Keep-Alive");Response.ContentType="application/octet-stream";Response.AddHeader("C 阅读全文
posted @ 2012-03-09 08:22 Chaoa 阅读(2606) 评论(1) 推荐(0)
摘要:using System.Web; public string GetLeaderInfo(string symbol){//获取高管信息的路径 XElement ele = XElement.Load("path.xml");string path = ele.Element("leader").Value;//首次读取缓存string jsoncache = HttpRuntime.Cache.Get(symbol) as string;if (jsoncache == null || jsoncache.Equals("")){ 阅读全文
posted @ 2012-03-09 08:20 Chaoa 阅读(388) 评论(0) 推荐(0)
摘要:首先添加对程序集System.Management的引用usingSystem;usingSystem.Management;namespaceConsoleApplication1{classProgram{staticvoidMain(string[]args){ManagementClassmc=newManagementClass("Win32_NetworkAdapterConfiguration");ManagementObjectCollectionnics=mc.GetInstances();foreach(ManagementObjectnicinnics 阅读全文
posted @ 2012-03-09 08:08 Chaoa 阅读(1085) 评论(0) 推荐(0)
摘要:在页面上用了iframe带来方便的同时也带来了麻烦,在IE6里能正常显示的iframe在其他的浏览器里确十分丑陋而不方便。为了解决 IE,Firefox,chrome,safari中iframe显示高度自适应问题上网海找了一遍,试了好几个方案都不妥,最后发现了一个可以正常解决的方案。首先加入以下的JS代码:functionstateChangeIE(_frame){if(_frame.readyState=="complete")//state:loading,interactive,complete{AutoHeight();}}functionstateChangeFi 阅读全文
posted @ 2012-03-09 08:04 Chaoa 阅读(1753) 评论(0) 推荐(0)
摘要://通过Google API 获取天气数据 并读取存入 XML中private void CreateXML() { XmlNodeList weekList = GetWeatherXML(); string strXml = "<weather></weather>"; doc.LoadXml(strXml);foreach (var obj in weekList) { XmlNode xmlNode = obj as XmlNode; XmlElement newElem = doc.CreateElement("forecast_ 阅读全文
posted @ 2012-03-06 17:15 Chaoa 阅读(1143) 评论(0) 推荐(0)
摘要://中英混合字符串截断 public static string getStr(string s, int l) { string temp = s; if (Regex.Replace(temp, "[\u4e00-\u9fa5]", "zz", RegexOptions.IgnoreCase).Length <= l) { return temp; } for (int i = temp.Length; i >= 0; i--) { temp = temp.Substring(0, i); if (Regex.Replace(temp, 阅读全文
posted @ 2012-03-01 11:41 Chaoa 阅读(495) 评论(0) 推荐(0)