随笔分类 - C#
摘要:就是把现有文件转移到隔离空间即可代码如下private async void CopyDB() { StorageFile fage = await ApplicationData.Current.LocalFolder.GetFileAsync("Logos.png"); if (!File.Exists(fage.Path)) { StorageFile storageFile = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Logos.png"); var path =
阅读全文
摘要:判断缓存是否存在 if (HttpRuntime.Cache[key] == null) { }插入缓存 缓存过期时间为2个小时NoAbsoluteExpiration:相对过期时间,生成缓存后若在没有过期的时间段被取,则过期时间后推10分钟,例如:11:1分钟时生成的 在11:5分钟时被取了,则过期时间为11:15分钟HttpRuntime.Cache.Insert(key.ToUpper(), dic, null,System.Web.Caching.Cache.NoAbsoluteExpiration,TimeSpan.FromMinutes(10));NoSlidingExpirat.
阅读全文
摘要:/// <summary> /// dataTable转换成Json格式 /// </summary> /// <param name="dt"></param> /// <returns></returns> public static string ToJson(DataTable dt) { if (dt != null && dt.Rows.Count > 0) { StringBuilder jsonBuilder = new StringBuilder(); jsonB
阅读全文
摘要:static string str = "|add|and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join|"; public static bool DataVerify() { string type = HttpContext.Current.Request.RequestType.ToLower(); bool flag = true; if (type == "post") { for (int i = 0; i < HttpCon
阅读全文
摘要:public static object Invokewebservice(string url, string @namespace, string classname, string methodname, object[] args) { try { WebClient wc = new WebClient(); Stream stream = wc.OpenRead(url + "?wsdl"); ServiceDescription sd = ServiceDescription.Read(stream); ServiceDescriptionImporter s
阅读全文
摘要:上篇我们说了接口工厂,接下来我们看看抽象工厂 抽象类用abstract修饰, 抽象类不能被实例化,抽象方法必须声明在抽象类中,抽象类型不一定不需存在抽象方法,具体派生类必须覆盖基类的抽象方法,抽象派生类可以覆盖基类的抽象方法也可以不覆盖 这样我们就实现了在基类中添加error方法,子类中无需添加,只需要传error信息就行 调用方法: ICarStract carStract = TcFactory_.GetCarInstance("BenzStract"); carStract.run(); carStract.stop(); carStract.error("
阅读全文
摘要:接口工厂模式: 定义接口用Interface,且接口中只能包含属性、方法和索引器,而且成员上不能有任何修饰符即使是public也不行,因为接口总是公开的。 首先我们定义一个汽车接口 public interface ICar { void run(); void stop(); //void error(); } 这里我们再定义一个Jeep车类和宝马车类都继承汽车接口,实现接口 public class Jeep:ICar {public void run(){ HttpContext.Current.Response.Write("Jeep run<br/>"
阅读全文
摘要:在读取的数据集进行跳跃查询,关键方法Skip().Take(); Skip跳过序列中指定的元素 Take从序列的开头返回指定数量的连续元素 var select = from n in entities.lib_reportinfo join e in entities.lib_enterprise on n.Ep_Guid equals e.Guid into temp_ne from tt in temp_ne.DefaultIfEmpty() select new { guid = n.Guid, epName = tt.Ep_Name, epTrade = tt.Ep_Trade, .
阅读全文
摘要:C#的委托是每个程序员需要掌握的知识,它更好的处理了面向对象的开发。但是很多时候学习起来不是那么易入门,所以有必要和大家分享一下委托的知识 委托就就好比一个代理公司,它只做中间处理,个人和企业不需要知道他是怎么处理的。1:定义 2:声明 3:实例化 4:作为参数传递 5:使用委托 这个概念比较抽象,我们还是直接看实例吧 要做一个计算器 1包括四种算法 加减乘除 protected void JiaF(int a, int b) { Response.Write("+:" + (a + b).ToString() + "<br>"); } pr
阅读全文
摘要:本文转载发明的博客园 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;privateXmlDocumentxmlDoc;//loadxmlfileprivatev
阅读全文
摘要:主要用到递归循环获取子结点 /// <summary> /// 生成根节点 /// </summary> /// <param name="treeview"></param> protected void BindTreeView(long ID, TreeView treeview) { DataTable dt = menuLogic.GetMenu2(ID, User.Identity.Name); treeview.Nodes.Clear(); DataRow[] parentrow = dt.Select(&quo
阅读全文
摘要:------生成方法一pageload(object sender, eventarges e){string chkCode = string.Empty; //颜色列表,用于验证码、噪线、噪点 Color[] color = { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Brown, Color.Brown, Color.DarkBlue }; //字体列表,用于验证码 string[] font = { "Times New Roman", "MS Mincho&
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.IO;using System.Text;/// <summary>///DownLoad 的摘要说明/// </summary>public class FileHelper{ public FileHelper() { // //TODO: 在此处添加构造函数逻辑 // } /// <summary> /// 文件上传到的路径 /// </summary>
阅读全文
摘要:关于margin-top的高度在不同浏览器下高度不等,不考虑IE8的问题,在布局时首先考虑在FireFox下正常,然后调试IE6、IE7直接上代码margin-top: 70px; /* firefox*/*margin-top: 63px; /*IE7*/_margin-top: 63px; /*IE6*/
阅读全文
摘要:转载于http://blog.csdn.net/hzjsoft2003/article/details/6186853region 得到所有本地网络中可使用的SQL服务器列表 /// <summary> /// 得到所有本地网络中可使用的SQL服务器列表 /// </summary> /// <param name= "p_strServerList "> 服务器列表 </param> /// <returns> </returns> public static bool GetServers(ref
阅读全文
摘要:Bitmap bmp = new Bitmap(allow_fileStream); //文件路径 allowUpload = stringHelper.IsCMYK(bmp) == "true" ? false : true; //返回true字符串则图片不是RGB模式的 public string IsCMYK(System.Drawing.Image img) { string isCmyk; if ((GetImageFlags(img).IndexOf("Ycck") > -1) || (GetImageFlags(img).IndexO
阅读全文
摘要:ajax代码$.ajax({ type: "post", url: "AjaxHandler.ashx", data: {"value1":'万事如意',"value2":'心想事成',"value3":'牛牛牛'},//参数要对应 success: function(result) { alert(result); } });一般处理程序操作ashx获取参数值 string value1 = context.Request.Form["
阅读全文
摘要:webservice 存在新数据时访问数据库,不存在时访问session,减少了对数据库的访问次数 /// <summary> /// 返回开标信息数据集 /// </summary> /// <param name="tenderId"></param> /// <returns></returns> [WebMethod(EnableSession = true)] public List<string> GetInformation(string tenderId) { string
阅读全文
摘要:先展示图片效果:1:在App_Code下添加类文件,命名为ImageSY 文件内容如下public class ImageSY : IHttpHandler{ public ImageSY() { // //TODO: 在此处添加构造函数逻辑 // } #region IHttpHandler 成员 public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { //获得请求的物理图片路径 string imagePath = context.Request.Ph
阅读全文
摘要:#region MD5算法public string md5(string str, int code){if (code == 32) //32位加密{return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, “MD5″).ToLower();}else //16位MD5加密(取32位加密的9~25字符){return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,
阅读全文