尋尋覓覓

共同奉獻

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  36 随笔 :: 1 文章 :: 3 评论 :: 0 引用

置顶随笔 #

摘要: 笑完之后不妨来我店逛逛热销包包~*^*~· 韩版手提包斜跨包双肩背包42.00元 2011最新 高档 潮流 韩版58.00元 单肩斜挎包 多用包 80.00元 真皮信封包 流苏花朵女包 88.00元 PU配真皮机车包手提包 43.00元 正品压花皮 肩挎 手拿 42.00元 秋冬菱格子 40.00元 (正品)单挎 肩挎 手拿 56.00元阅读全文
posted @ 2011-01-06 22:33 ★海戰鷹 阅读(93) 评论(0) 编辑

2012年2月9日 #

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Caching;
using System.Collections;

namespace CommonLibrary.Utility
{
    public class CacheHelper
    {
        public static bool AddToCache(string key, object item)
        {
            RemoveFromCache(key);
            HttpRuntime.Cache.Add(key, item, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            return true;
        }

        public static object GetFromCache(string key)
        {
            return HttpRuntime.Cache[key];
        }

        public static bool RemoveFromCache(string key)
        {
            if (GetFromCache(key) != null)
            {
                HttpRuntime.Cache.Remove(key);
            }
            return true;
        }

        public static object GetCache(string CacheKey)
        {
            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            return objCache[CacheKey];
        }

        public static void SetCache(string CacheKey, object objObject)
        {
            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            objCache.Insert(CacheKey, objObject);
        }

        public static void SetCache(string key, object obj, DateTime absolute_expiration)
        {
            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            objCache.Insert(key, obj, null, absolute_expiration, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);
        }

        public static void RemoveAllCache()
        {
            System.Web.Caching.Cache _cache = HttpRuntime.Cache;
            IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
            ArrayList al = new ArrayList();
            while (CacheEnum.MoveNext())
            {
                al.Add(CacheEnum.Key);
            }
            foreach (string key in al)
            {
                _cache.Remove(key);
            }
        }

        public enum RemoveCacheType
        {
            StartWith,
            EndWith,
            Like,
            Equal,
            All,
        }
        public static void RemoveCaches(string key, RemoveCacheType type)
        {
            switch (type)
            {
                case RemoveCacheType.Equal:
                    RemoveCache(key);
                    return;
                case RemoveCacheType.All:
                    RemoveAllCache();
                    return;
                default:
                    break;
            }
            System.Web.Caching.Cache _cache = HttpRuntime.Cache;
            IDictionaryEnumerator CacheEnum = _cache.GetEnumerator();
            ArrayList al = new ArrayList();
            while (CacheEnum.MoveNext())
            {
                switch (type)
                {
                    case RemoveCacheType.StartWith:
                        if (CacheEnum.Key.ToString().StartsWith(key))
                            al.Add(CacheEnum.Key);
                        break;
                    case RemoveCacheType.EndWith:
                        if (CacheEnum.Key.ToString().EndsWith(key))
                            al.Add(CacheEnum.Key);
                        break;
                    case RemoveCacheType.Like:
                        if (CacheEnum.Key.ToString().IndexOf(key) > -1)
                            al.Add(CacheEnum.Key);
                        break;
                    default:
                        break;
                }
            }
            foreach (string k in al)
            {
                _cache.Remove(k);
            }
        }

        public static void RemoveCache(string key)
        {
            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            objCache.Remove(key);
        }
    }
}
posted @ 2012-02-09 10:51 ★海戰鷹 阅读(4) 评论(0) 编辑

2011年12月21日 #

C#中使用TripleDESCryptoServiceProvider类
 
 

//C#中使用TripleDESCryptoServiceProvider类

using System;
using System.Text;
using System.Collections;
using System.IO;
using System.Security.Cryptography;
namespace ImageAnimatorExample
{
    class TripleDESCryptoServiceProviderDemo
    {
        public static void Main(String[] args)
        {
            //加密
            string myID = "435-86-0985-021";
            TripleDESCryptoServiceProvider key = new TripleDESCryptoServiceProvider();
            MemoryStream ms = new MemoryStream();
            CryptoStream encStream = new CryptoStream(ms, key.CreateEncryptor(), CryptoStreamMode.Write);
            StreamWriter sw = new StreamWriter(encStream);
            sw.WriteLine(myID);
            sw.Close();
            //获取加密后的字节
            byte[] buffer = ms.ToArray();
            //解密
            ms = new MemoryStream(buffer);
            encStream = new CryptoStream(ms, key.CreateDecryptor(), CryptoStreamMode.Read);
            StreamReader sr = new StreamReader(encStream);
            //输出解密后的内容
            Console.WriteLine(sr.ReadLine());
            key.Clear();
            sr.Close();
            Console.ReadLine();
        }

 

 #region 3DES加密

        public static string Encrypt3DES(string a_strString, string a_strKey, string a_strIV)
        {
            System.Security.Cryptography.TripleDESCryptoServiceProvider des = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
            byte[] inputByteArray = System.Text.Encoding.UTF8.GetBytes(a_strString);
            des.Key = System.Text.Encoding.UTF8.GetBytes(a_strKey);
            des.IV = System.Text.Encoding.UTF8.GetBytes(a_strIV);
            des.Mode = System.Security.Cryptography.CipherMode.CBC;
            des.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
            System.IO.StreamWriter swEncrypt = new System.IO.StreamWriter(cs);
            swEncrypt.WriteLine(a_strString);
            swEncrypt.Close();
          
            //把内存流转换成字节数组,内存流现在已经是密文了
            byte[] bytesCipher = ms.ToArray();
            //内存流关闭
          
            string base64String= System.Convert.ToBase64String(bytesCipher);
            //string by = "";
            //foreach (byte b in bytesCipher)
            //{
            //    by += b.ToString() + " ";
            //}
            //SbeLogger.info("【3DESBytes】" + by);
            //byte[] FromBase64String = Convert.FromBase64String(base64String);
            //ms = new MemoryStream(FromBase64String);
            //cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);
            //StreamReader sr = new StreamReader(cs);
            ////输出解密后的内容
            //string DecryptString = sr.ReadLine();
          
            //加密流关闭
            cs.Close();
            des.Clear();
            ms.Close();
           

            return base64String;
        }


        public static string Decrypt3DES(string a_strString, string a_strKey, string a_strIV)
        {
            TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
            byte[] inputByteArray = Encoding.UTF8.GetBytes(a_strString);
            des.Key = System.Text.Encoding.UTF8.GetBytes(a_strKey);
            des.IV = System.Text.Encoding.UTF8.GetBytes(a_strIV);
            des.Mode = CipherMode.CBC;
            des.Padding = PaddingMode.PKCS7;
            MemoryStream ms = new MemoryStream();
            CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);           
            byte[] FromBase64String = Convert.FromBase64String(a_strString);
            ms = new MemoryStream(FromBase64String);
            cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);
            StreamReader sr = new StreamReader(cs);
            //输出解密后的内容
            string DecryptString = sr.ReadLine();
            //加密流关闭
            cs.Close();
            des.Clear();
            ms.Close();
            sr.Close();
            return DecryptString;
           
        }
       
        #endregion


    }
}

 

 

posted @ 2011-12-21 09:20 ★海戰鷹 阅读(57) 评论(0) 编辑

2011年9月4日 #

通过Package Manager Console 向VS2010安装 EntityFramework

尝试用VS2010--工具--Library Package Manager--Add Library Package Reference的online搜索 EntityFramework,

再找到的结果中,点选该Package的Install,

却提示错误:

"This package (or one of its dependencies) contains powershell scripts and needs to be installed from the package manager console."

 

根据提示改用Package Manager Console来安装,

打开VS2010--工具--Library Package Manager--Package Manager Console,

PM > get-package -remote -filter entityframework

Id                                      Version                                Description                           
--                                      -------                                -----------                           
BinbinMemberShipEntityFrameworkCodeF... 1.0.0.0                                membership entityframework codefirst  
BinbinMemberShipEntityFrameworkCodeF... 1.0.0.1                                2011-08-15:添加类...                     
Check_My_Box_Packages                   1.1.0.2                                This Package uses MvcScaffolding, E...
Check_My_Box_Packages                   1.1.0.3                                This Package uses MvcScaffolding, E...
EFCodeFirst                             1.0                                    Legacy package, Code First is now i...
EFCodeFirst                             1.1                                    Legacy package, Code First is now i...
EntityFramework                         4.1.10311.0                            DbContext API and Code First workfl...
EntityFramework                         4.1.10331.0                            DbContext API and Code First workfl...
EntityFramework                         4.1.10715.0                            DbContext API and Code First workfl...
EntityFramework.Extensions              0.0.1                                  A couple useful extensions for crea...
EntityFramework.Extensions              0.0.2                                  A couple useful extensions for crea...
EntityFramework.Patterns                0.2                                    Provides different patterns to be u...
EntityFramework.Patterns                0.5                                    EntityFramework.Patterns provides d...
EntityFramework.Preview                 4.2.0.0                                Entity Framework 4.2 Beta 1. DbCont...
EntityFramework.Sample                  4.1                                    This sample blog model demonstrates...
EntityFramework.SqlMigrations           0.5.10727.0                            Preview of Code First Migrations fo...
EntityFramework.SqlServerCompact        4.1.8482.1                             Allows SQL Server Compact 4.0 to be...
EntityFramework.SqlServerCompact        4.1.8482.2                             Allows SQL Server Compact 4.0 to be...
EntityFrameworkProfiler                 1.0.0.912                              EntityFramework Profiler is a real-...
FSRepository                            1.0.0.0                                FSRepository provides a quick way o...
FSRepository                            2.0.0.0                                FSRepository provides a quick way o...
ImtModelsStarter                        0.5.6                                  .Net models starter project that se...
ImtModelsStarter                        0.5.7                                  .Net models starter project that se...
ImtModelsStarter                        0.5.8                                  .Net models starter project that se...
ImtModelsStarter                        0.5.9                                  .Net models starter project that se...
NCommon.EntityFramework                 1.2                                    NCommon data adapter for Entity Fra...
NContext.Persistence.EntityFramework    1.0                                    Entity Framework 4.1 support for NC...
NContext.Persistence.EntityFramework    1.1                                    Entity Framework 4.1 support for NC...
netfx-Patterns.DomainContext.EF         1.0.0.0                                Implements the Domain Context patte...
RIAServices.EntityFramework             4.1.60629.0                            WCF RIA Services EntityFramework 4....
RIAServices.EntityFramework             4.1.60730.0                            WCF RIA Services Toolkit- WCF RIA S...
RiaServices.EntityFramework.Scaffolding 0.1                                    Scaffolds a WCF RIA DbDomainService...
RIAServices.Toolkit.All                 4.1.60730.0                            WCF RIA Services Toolkit - All NuGe...
RIAServices.Toolkit.All                 4.1.60730.1                            WCF RIA Services Toolkit - All NuGe...
RiaServicesContrib.EntityFramework.S... 0.2                                    Scaffolds a WCF RIA DbDomainService...
Unity.Mvc3.EntityFramework.Quickstart   0.5                                    Quickstart sample for using Unity a...
Unity.Mvc3.EntityFramework.Quickstart   0.6                                    Legacy package. Please use this pac...
Unity.Mvc3.EntityFramework.Quickstart   0.7                                    Legacy package. Please use this pac...


PM> install-package -id EntityFramework -Version 4.1.10311.0
You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkID=211009. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
已成功安装“EntityFramework 4.1.10311.0”
已成功将“EntityFramework 4.1.10311.0”添加到 MvcMovie

 

posted @ 2011-09-04 11:43 ★海戰鷹 阅读(156) 评论(1) 编辑

2011年9月1日 #

SBE
摘要: ///<summary>///令牌申请///</summary>///<returns></returns>///需要引用的命名空间///usingcom.travelsky.sbeclient.authorization;///usingcom.travelsky.sbeclient;publicstringapplyToken(){stringSbeID="linkoskyTest";stringSbePWD="123456";AuthorizationRequestauthRequest=newAut阅读全文
posted @ 2011-09-01 09:39 ★海戰鷹 阅读(8) 评论(0) 编辑

2011年8月29日 #

关于windows IIS日志时间与系统时间相差8小时的问题

很多做过网站的朋友在分析IIS日志的时候会发现IIS日志的时间与计算机的系统时间不符,比如在中国时区就会相差8小时。具体原因是什么呢?网 上搜索的结果十有八九让人做如下操作解决:

在IIS日志属性“常 规”标签下,找到“文件命名和创建使用当地时间”,在其前打勾。实际上,这种方法并不能解决时差问题。
真正的原因是因为IIS默认 采用W3C 扩展日志文件格式,而W3C 扩展日志文件定义日志采用GMT时间(即格林尼治标准时间),而中国在GMT +8时区,自然就相差八个小时了。要真正解决,有两个办法:
1:活动日志格式更改为 “Microsoft IIS 日志文件格式”。此时时间一致。但是。。IIS日志文件格式记录的日志文档 内容不如W3C扩展日志文件格式的文档丰富,比如cs(User-Agent)段的信息就不会有,如果你很重视这些,那不要用此方法了。
2: 使用转化工具转化,如Convlog.exe 实用程序, 位于 Winnt\System 32 文件夹,由微软提供。在命令提示符处, 键入: convlog - IE LogFileName - t ncsa +/- GMTOffset : 其中 LogFileName 是对转换文件和 GMTOffset 名称是的要更正小时数。 即本地时间与GMT时间差。 例如, 来转换文件命名为 " Logfile.log, " 和更正有关东部标准时间, 请使用以下命令: convlog - IE Logfile.log - t ncsa -0500:
附上命令详解:

用法: convlog [options] LogFile

选项:

-i<i|n|e> = 输入日志文件类型

    i - MS Internet 标准日志文件格式

    n - NCSA 公用日志文件格式

    e - W3C 扩展日志文件格式

-t <ncsa[:GMTOffset] | none> 默认值是 ncsa

-o <output directory> 默认值 = 当前目录

-x 将非 www 数据项保存到 .dmp 日志文件

-d = 将 IP  地址转换成 DNS

-l<0|1|2> = MS Internet 标准日期格式

    0 - 月/日/年(默认值,如美国)

    1 - 年/月/日(如中国)

    2 - 日.月.年(如德国)

-c = 即使发现格式不正确,也继续执行

如:

convlog -ii in*.log -d -t ncsa:+0800

convlog -in ncsa*.log -d

convlog -ii jra*.log -t none

posted @ 2011-08-29 11:04 ★海戰鷹 阅读(406) 评论(0) 编辑

2011年8月15日 #

摘要: netstat -s -P tcp 命令可查看所有可用的 TCP 参数[root@localhost ~]# netstat -n | awk '/^tcp.*7787/ {++S[$NF]} END {for(a in S) print a, S[a]}' netstat -n | awk '/^tcp / {++S[$NF]} END {for(a in S) print a, S[a]}'阅读全文
posted @ 2011-08-15 11:16 ★海戰鷹 阅读(8) 评论(0) 编辑

2011年8月14日 #

摘要: usingSystem;usingSystem.Net;usingSystem.Text;usingSystem.Net.Sockets;usingSystem.Collections.Generic;namespaceCustomLibraries.Threading{publicstaticclassConnectionPool{///<summary>///Queueofavailablesocketconnections.///</summary>privatestaticQueue<CustomSocket>availableSockets=nul阅读全文
posted @ 2011-08-14 16:11 ★海戰鷹 阅读(27) 评论(0) 编辑

摘要: 多线程 非安全实例usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading;namespaceThreadSample{classProgram{staticvoidMain(string[]args){intnumThreads=20;ShareStatestate=newShareState();Thread[]threads=newThread[numThreads];for(inti=0;i<numThreads;i++){threads[阅读全文
posted @ 2011-08-14 13:03 ★海戰鷹 阅读(18) 评论(0) 编辑

2011年2月12日 #

摘要: Congratulations, you have8600available points and are eligible to redeem up to5rewards!Select your reward:Quantity:0 Points will be deducted from your account.Redeem阅读全文
posted @ 2011-02-12 14:06 ★海戰鷹 阅读(185) 评论(0) 编辑

2011年1月6日 #

摘要: 笑完之后不妨来我店逛逛热销包包~*^*~· 韩版手提包斜跨包双肩背包42.00元 2011最新 高档 潮流 韩版58.00元 单肩斜挎包 多用包 80.00元 真皮信封包 流苏花朵女包 88.00元 PU配真皮机车包手提包 43.00元 正品压花皮 肩挎 手拿 42.00元 秋冬菱格子 40.00元 (正品)单挎 肩挎 手拿 56.00元阅读全文
posted @ 2011-01-06 22:33 ★海戰鷹 阅读(93) 评论(0) 编辑