原文《Install Mplayer and Multimedia Codecs (libdvdcss2,w32codecs,w64codecs) in Ubuntu 10.04 (Lucid Lynx)

Mplayer 是一个功能强大的媒体播放器。支持的编码方式有:MPEG 1/2/4、DivX 3/4/5、Windows Media 7/8/9、RealAudio/Video(9以下)、Quicktime 5/6 以及 Vivo 1/2。它支持很多针对MX/SSE (2)/3Dnow(Ex)优化的视频/音频编码……(以下略)

在Ubuntu 10.04 (Lucid) 里安装 Mplayer。

首先在软件源的设置里启用“社区维护的开源软件(universe)”和“有版权和合法性问题的软件(multiverse)”
然后刷新软件源:
    sudo apt-get update
用下面这行命令安装:
    sudo aptitude install mplayer-gui
或者点击下面的链接:
    apt://mplayer
现在您可以在 应用程影音 里找到 Mplayer Movie Player

在Ubuntu 10.04 (Lucid)里安装 w32codecs 和 libdvdcss2

w32codecs 用于支持WMV、RealMedia和一些其他格式。但是由于版权和法律方面的原因,这个软件包没有包含在Ubuntu的软件仓库里。而libdvdcss2 软件包在播放加密的DVD的时候是必须的。
下面的命令将把 Medibuntu 的软件仓库添加到 Ubuntu,并同时把 Medibuntu 的 GPG 密钥添加到您的密码环,以便于验证 Medibuntu 软件包。
    sudo wget http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list --output-document=/etc/apt/sources.list.d/medibuntu.list
    sudo apt-get -q update
    sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring
   
sudo apt-get -q update
i386 用户用下面这条命令安装 Codecs:
    sudo apt-get install w32codecs libdvdcss2
amd64 用户用下面这条命令安装 Codecs:
    sudo apt-get install w64codecs libdvdcss2
上面这个下载地址可用于安装大多数适用于 ubuntu 的解码器包。

本日志由 hooperzao 于 2010-06-29 08:52:28 发表到 操作技巧 中,目前已经被浏览 126 次,评论 0 次;

htmlAttributes可用“对象初始化器”来创建,如引用一个CSS类,new { @class = "myClass" },因为class为C#关键字,前加@就可以拿来做自己变量的名字,也可以把@class直接写成Class,C#区分大小写,Class不为C#关键字,

new { Class= "myClass" },

实例:

.myClass
{
     color:Red;
}

<%= Html.TextBox("DLID", item.DLID, new { @class = "myClass" })%>

当然你也可以设置其它任何有效的htmlAttributes的值。如

new {style="color:red",width="12px",height="10px"}。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/loveyou128144/archive/2009/07/09/4336227.aspx

本日志由 hooperzao 于 2010-06-28 15:24:36 发表到 ASP.NET MVC 中,目前已经被浏览 122 次,评论 0 次;

在表单中写:<input id="cbx" type="checkbox" />

脚本判断选中还是没选中。 

  1. <script type="text/javascript">  
  2.     $(document).ready(function() {       
  3.         $("input[type='checkbox']").attr("checked"false)  
  4.     });  
  5.       
  6.     $("#cbx").click(function()   
  7.     {   
  8.       
  9.         if ($("#cbx").attr("checked"))  
  10.          {            
  11.             $("input[type='checkbox']").attr("checked",true)  
  12.         }  
  13.          else   
  14.         {        
  15.             $("input[type='checkbox']").attr("checked"false)  
  16.         }  
  17.  
  18.        });  
  19.  
  20.     var strid = "";  
  21.  
  22. </script>  
  23.  
  24.      function delMeetingNotice(action) {  
  25.          
  26.          var strDocumentid = "";  
  27.          var selectNum = $("input[type='checkbox'][id!='cbx']").size();  
  28.          var selectedNum = $("input[type='checkbox'][id!='cbx'][checked=true]").size();          
  29.          if (selectedNum == 0) {  
  30.              alert("请选择删除项!");  
  31.              return false;  
  32.           }        
  33.          for (var i = 0; i < selectNum; i++)  
  34.          {  
  35.              if ($("input[type='checkbox'][id!='cbx']").eq(i).attr("checked")) {  
  36.  
  37.                  strDocumentid = strDocumentid + $("input[type='checkbox'][id!='cbx']").next().eq(i).val() + ",";                  
  38.              }  
  39.          }    
  40.  
  41. switch (action) {  
  42.  
  43.              case "delete":  
  44.                  return confirm('您真的要删除选中信息吗?') ? doaction('<%=Url.Action(MVC.Oa.MeetingNotice.Delete()) %>''Delete', strDocumentid) : false;  
  45.                  break;  
  46.              case "remove":  
  47.                  return confirm('您真的要删除选中信息吗?') ? doaction('<%=Url.Action(MVC.Oa.MeetingNotice.Remove())%>''Post', strDocumentid) : false;                      
  48.      }    

本日志由 hooperzao 于 2010-06-25 17:11:31 发表到 ASP.NET MVC 中,目前已经被浏览 155 次,评论 0 次;

在安装TFS2010时遇到以下错误:

[ Reporting ] TF255455: SQL Server Reporting Services is configured to require a secure connection. However, no HTTPS URL is configured with a valid certificate. Use the Reporting Services Configuration Manager to configure or remove HTTPS support. For more information see http://go.microsoft.com/fwlink/?LinkId=179982

解决的方法是:

编辑以下文件:
C:\Program Files\Microsoft SQL Server\MSRS10.<ServerInstance>\Reporting Services\ReportServer\rsreportserver.config

修改
<Add Key="SecureConnectionLevel" Value="2"/>  (将值修改为0)

3:最安全的,使用SSL的绝对一切。
2:安全,使用SSL的渲染和方法,通过证书,但不坚持它为所有的SOAP调用。
1:基本安全,接受HTTP,但拒绝在任何可能涉及的凭据传递调用。
0:最不安全的,不使用SSL。

转自 http://social.msdn.microsoft.com/Forums/zh-TW/tfssetup/thread/494a0753-c128-49a0-967d-32e27de5bb87

本日志由 hooperzao 于 2010-06-21 15:23:14 发表到 敏捷开发 中,目前已经被浏览 138 次,评论 0 次;

XP下使用2003的“管理工具”中的“远程桌面”

方法一:
安装2003中的adminpak.msi,远程桌面可用了,但是附带也安装了一大堆的管理工具;

方法二:
1、从Windows Server 2003 %systemroot%\system32\下拷贝 mstsmmc.dll 和 mstsmhst.dll 到 Windows XP System32目录下;
2、在Windows XP 上运行: Regsvr32 mstsmmc.dll 和 Regsvr32 mstsmhst.dll,确认注册DLL文件成功;
3、在Windows XP 上运行 MMC,然后添加“远程桌面”管理单元即可使用,可以保存MSC文件以备后用。

方法三:
用远程桌面连接输入了完全的信息和设置后,你可以将其另存为rdp文件,然后用记事本或者其他文本编辑程序直接打开该rdp程序,修改rdp文件,将头部几行替换为

screen mode id:i:1
desktopwidth:i:1000
desktopheight:i:700
session bpp:i:15
winposstr:s:0,1,1,11,9999,9999

保存后,然后打开这个rdp文件就能够直接连接到服务器,并且用自己指定长宽度,像这个信息里面就是让远程桌面连接窗口为1000*700,这样在1024*768的桌面环境上,打开一堆1000*700的窗口还是挺方便切换的

注意上文中“远程桌面”和“远程桌面连接”是两个不同的工具。

Win7下使用2003的“管理工具”中的“远程桌面”

1.去MS中国下载“Windows 7 远程服务器管理工具”,KB958850,200多M,下载地址 http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=7d2f6ad7-656b-4313-a005-4e344e43997d

2.安装完成后依次打开“控制面板”-“程序和功能”-“打开或关闭Windows功能”-“远程服务器管理工具”-“角色管理工具”,勾选下面的“远程桌面服务工具”;

3.此时重新打开MMC控制台,添加管理单元时就可以选择并添加“远程桌面”管理单元了。

本日志由 hooperzao 于 2010-06-15 21:13:54 发表到 操作技巧 中,目前已经被浏览 96 次,评论 0 次;

  1. <%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="生成实体类。" ResponseEncoding="UTF-8" %>  
  2. <%@ Property Name="EntityName" Type="System.String" Category="Context" Description="实体名称。" %>  
  3. <%@ Property Name="NameSpace" Type="System.String" Category="Context" Description="命名空间。" %>  
  4. <%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="数据表。" %>  
  5. <%@ Property Name="ProjectName" Type="System.String" Category="Context" Description="项目名称。" %>  
  6. <%@ Assembly Name="SchemaExplorer" %>  
  7. <%@ Assembly Name="System.Data" %>  
  8. <%@ Import Namespace="SchemaExplorer" %>  
  9. <%@ Import Namespace="System.Data" %>  
  10. using System;  
  11. using System.Collections.Generic;  
  12.  
  13. namespace <%=NameSpace%>  
  14. {  
  15.     /// <summary>  
  16.     /// 实体类:<%=EntityName%>。  
  17.     ///</summary>  
  18.     [Serializable]  
  19.     public class En<%= GetClassName(SourceTable) %>  
  20.     {  
  21.         #region 存储字段。  
  22.         <% foreach (ColumnSchema column in SourceTable.Columns) { %>  
  23.         private <%= GetCSharpVariableType(column) %> <%=GetCamelCaseName(column.Name)%>;  
  24.         <% } %>  
  25.         #endregion  
  26.  
  27.         #region 初始化 En<%= GetClassName(SourceTable) %> 类的新实例。  
  28.         /// <summary>  
  29.         /// 初始化 <see cref="En<%= GetClassName(SourceTable) %>" /> 类的新实例。  
  30.         ///</summary>  
  31.         public En<%= GetClassName(SourceTable) %>()  
  32.         {  
  33.             <% foreach (ColumnSchema column in SourceTable.Columns) { %>  
  34.             <%=GetCamelCaseName(column.Name)%> = En<%=ProjectName%>.Base<%= GetBaseType(GetCSharpVariableType(column)) %>;  
  35.             <% } %>  
  36.         }  
  37.         #endregion  
  38.  
  39.         <% foreach (ColumnSchema column in SourceTable.Columns) { %>  
  40.         #region 获取或设置<%=column.Description%>  
  41.         ///<summary>  
  42.         ///获取或设置<%=column.Description%>  
  43.         ///</summary>  
  44.         ///<value><%=column.Description%></value>  
  45.         public <%= GetCSharpVariableType(column) %> <%=column.Name%>  
  46.         {  
  47.             get { return <%=GetCamelCaseName(column.Name)%>; }  
  48.             set { <%=GetCamelCaseName(column.Name)%> = value; }  
  49.         }  
  50.         #endregion  
  51.  
  52.         <% } %>  
  53.     }  
  54.  
  55.     /// <summary>  
  56.     /// 实体类:<%=EntityName%>集合。  
  57.     ///</summary>  
  58.     [Serializable]  
  59.     public class En<%= GetClassName(SourceTable) %>List  
  60.     {  
  61.         #region 存储字段。  
  62.         private List<En<%= GetClassName(SourceTable) %>> <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%>;  
  63.         #endregion  
  64.  
  65.         #region 初始化 En<%= GetClassName(SourceTable) %>List 类的新实例。  
  66.         /// <summary>  
  67.         /// 初始化 <see cref="En<%= GetClassName(SourceTable) %>List" /> 类的新实例。  
  68.         ///</summary>  
  69.         public En<%= GetClassName(SourceTable) %>List()  
  70.         {  
  71.             <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%> = new List<En<%= GetClassName(SourceTable) %>>();  
  72.         }  
  73.         #endregion  
  74.  
  75.         #region 获取或设置<%=EntityName%>集合。  
  76.         ///<summary>  
  77.         ///获取或设置<%=EntityName%>集合。  
  78.         ///</summary>  
  79.         ///<value><%=EntityName%>集合。</value>  
  80.         public List<En<%= GetClassName(SourceTable) %>> <%= GetClassName(SourceTable) %>s  
  81.         {  
  82.             get { return <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%>; }  
  83.             set { <%= GetCamelCaseName(GetClassName(SourceTable) + "s" )%> = value; }  
  84.         }  
  85.         #endregion  
  86.     }  
  87.  
  88. }  
  89. <script runat="template">  
  90.  
  91. // 获取私有字段名称。  
  92. public string GetCamelCaseName(string value)  
  93. {  
  94.     return "_" + value.Substring(0, 1).ToLower() + value.Substring(1);  
  95. }  
  96.  
  97. // 获取基本类型。  
  98. public string GetBaseType(string value)  
  99. {  
  100.     return value.Substring(0,1).ToUpper() + value.Substring(1);  
  101. }  
  102.  
  103. // 获取CS数据类型名称。  
  104. public string GetCSharpVariableType(ColumnSchema column)  
  105. {  
  106.     if (column.Name.EndsWith("TypeCode")) return column.Name;  
  107.     switch (column.DataType)  
  108.     {  
  109.         case DbType.AnsiString: return "string";  
  110.         case DbType.AnsiStringFixedLength: return "string";  
  111.         case DbType.Binary: return "byte[]";  
  112.         case DbType.Boolean: return "bool";  
  113.         case DbType.Byte: return "byte";  
  114.         case DbType.Currency: return "decimal";  
  115.         case DbType.Date: return "DateTime";  
  116.         case DbType.DateTime: return "DateTime";  
  117.         case DbType.Decimal: return "decimal";  
  118.         case DbType.Double: return "double";  
  119.         case DbType.Guid: return "Guid";  
  120.         case DbType.Int16: return "short";  
  121.         case DbType.Int32: return "int";  
  122.         case DbType.Int64: return "long";  
  123.         case DbType.Object: return "object";  
  124.         case DbType.SByte: return "sbyte";  
  125.         case DbType.Single: return "float";  
  126.         case DbType.String: return "string";  
  127.         case DbType.StringFixedLength: return "string";  
  128.         case DbType.Time: return "TimeSpan";  
  129.         case DbType.UInt16: return "ushort";  
  130.         case DbType.UInt32: return "uint";  
  131.         case DbType.UInt64: return "ulong";  
  132.         case DbType.VarNumeric: return "decimal";  
  133.         default:  
  134.         {  
  135.             return "__UNKNOWN__" + column.NativeType;  
  136.         }  
  137.     }  
  138. }  
  139.  
  140. // 获取表名称。  
  141. public string GetClassName(TableSchema table)  
  142. {  
  143.     if (table.Name.EndsWith("s"))  
  144.     {  
  145.         return table.Name.Substring(0, table.Name.Length - 1);  
  146.     }  
  147.     else 
  148.     {  
  149.         return table.Name;  
  150.     }  
  151. }  
  152. </script> 

本日志由 hooperzao 于 2010-05-29 23:26:13 发表到 敏捷开发 中,目前已经被浏览 128 次,评论 0 次;

//模板的基础知识

//任何模板都需要的第一句,用来指定模板编辑语言是什么,目标语言是什么:

  1. <%@ CodeTemplate Language="C#" TargetLanguage="T-SQL" Description="Generates a update stored procedure." %>  

//接下来写模板需要从外界引入的参数

  1. <%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Category="Context" Description="Database" %> 

//在模板里面用到了codesmith的函数和方法,需要引入对应的包,一般是

  1. <%@ Assembly Name="SchemaExplorer" %>  
  2. <%@ Import Namespace="SchemaExplorer" %> 

我理解assembly 是引入dll,import 是引入dll里面的命名空间,这些dll有的是codesmith自己带的,对于vs.net提供的dll,都可以引入使用。

//所有codesmith函数都在script标签里面定义,包括变量

  1. <script runat="template">  
  2. private string _outputDirectory = String.Empty;  
  3. </script> 

调用用<% %> 括起来,一般有一个主函数来执行整个模板的函数

  1. <%  
  2. this.Go();  
  3. %> 

将生成的变量插入到模板的任何需要动态生成的地方,直接用asp.net的写法就可以了,例如

  1. namespace <%=DALNameSpace%>.SqlClient 

//一般模板的函数和用法

  1. /// <summary>  
  2. /// 拷贝指定文件  
  3. /// </summary>  
  4. public void SafeCopyFile(string path, string destination)  
  5. {  
  6. FileInfo file1 = new FileInfo(path);  
  7. file1.CopyTo(destination, true);  
  8. }  
  9. /// <summary>  
  10. /// 创建指定目录  
  11. /// </summary>  
  12. public void SafeCreateDirectory(string path)  
  13. {  
  14. if (!Directory.Exists(path))  
  15. {  
  16. Directory.CreateDirectory(path);  
  17. }  
  18. }  
  19. /// <summary>  
  20. /// 根据指定模板生成指定文件  
  21. /// </summary>  
  22. public void RenderToFile(string templateName, string path, bool overwrite)  
  23. {  
  24. this._CurrentFileName = path;  
  25. this.GetTemplate(templateName).RenderToFile(path, overwrite);  
  26. this._counter++;  
  27. }  
  28. /// <summary>  
  29. /// 打开文件目录,[Editor]标签表示调用指定的编辑器;category表示参数所属目录;Descript表示对参数的描述;defaultvalue表示缺省值CodeTemplateProperty表示该参数是可选还是必须的,CodeTemplatePropertyOption.Optional是可选,CodeTemplatePropertyOption.Required是必须  
  30. /// </summary>  
  31. private string _outputDirectory = String.Empty;  
  32. [Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]   
  33. [CodeTemplateProperty(CodeTemplatePropertyOption.Optional)]  
  34. [Category("General")]  
  35. [Description("The directory to output the results to.")]  
  36. [DefaultValue("")]  
  37. public string OutputDirectory   
  38. {   
  39. get 
  40. {  
  41. if (_outputDirectory.Length == 0)  
  42. {  
  43. return @"c:\NetTiers\Output");  
  44. }  
  45. else 
  46. {  
  47. return _outputDirectory;  
  48. }  
  49. }  
  50. set 
  51. {  
  52. if (value.EndsWith("\\")) value = value.Substring(0, value.Length - 1);  
  53. _outputDirectory = value;  
  54. }   
  55. }  
  56. //获取当前打开模板所在路径  
  57. this.CodeTemplateInfo.DirectoryName  
  58. //对于模板,当前打开的模板可以用codeTemplateInfo访问,其他的子模板需要先根据文件名和路径载入,然后编辑模板,最后赋予参数,生成文件。  
  59. //设定模板路径  
  60. private string[] _templatesFileNames = new string[] {  
  61. "vsnet2003.project.cst",  
  62. "vsnet2005.project.cst",  
  63. "vsnet2003.solution.cst",  
  64. "vsnet2005.solution.cst",  
  65. "ASP.Net\\2.0\\Entty_aspx_resx.cst" 
  66. };  
  67. //设定编辑好的子模板保存的hashtable,在hashtable里面,key是文件名,所以全套模板不能有重复的文件名  
  68. // Compile and load all them in a collection  
  69. private System.Collections.Hashtable _CodeTemplates = new System.Collections.Hashtable();  
  70. //载入模板  
  71. // load all the templates and put them into an hashtable  
  72. public void LoadTemplates()  
  73. {   
  74. foreach(string _templatesFileName in _templatesFileNames)  
  75. {  
  76. string key = System.IO.Path.GetFileName(_templatesFileName);  
  77. if (_CodeTemplates.Contains(key))  
  78. {  
  79. continue;  
  80. }  
  81. _CodeTemplates.Add(key, this.CompileTemplate(this.CodeTemplateInfo.DirectoryName + _templatesFileName));  
  82. // Set the properties that all the commonsqlcode inherited templates should set  
  83. // TODO : use reflection to check that the templates inherits from commonsql  
  84. try 
  85. {  
  86. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("EntityFormat", EntityFormat);  
  87. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("CollectionFormat",   
  88.  
  89. CollectionFormat);  
  90. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("ProviderFormat", ProviderFormat);  
  91. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("InterfaceFormat", InterfaceFormat);  
  92. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("BaseClassFormat", BaseClassFormat);  
  93. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("EnumFormat", EnumFormat);  
  94. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("ManyToManyFormat", ManyToManyFormat);  
  95. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("AliasFilePath", AliasFilePath);  
  96. ((CodeSmith.Engine.CodeTemplate)_CodeTemplates[key]).SetProperty("StrippedTablePrefixes", StrippedTablePrefixes);  
  97. }  
  98. catch(Exception) {}  
  99. }  
  100. }  
  101. //载入的时候都需要编译模板  
  102. public CodeTemplate CompileTemplate(string templateName)  
  103. {  
  104. this._CurrentFileName = templateName;  
  105. CodeTemplateCompiler compiler = new CodeTemplateCompiler(templateName);  
  106. compiler.Compile();  
  107. if (compiler.Errors.Count == 0)  
  108. {  
  109. return compiler.CreateInstance();  
  110. }  
  111. else 
  112. {  
  113. for (int i = 0; i < compiler.Errors.Count; i++)  
  114. {  
  115. Response.WriteLine(compiler.Errors[i].ToString());  
  116. }  
  117. return null;  
  118. }  
  119. }  
  120. //获取模板  
  121. public CodeTemplate GetTemplate(string templateType)  
  122. {  
  123. return (CodeSmith.Engine.CodeTemplate)_CodeTemplates[templateType];  
  124. }  
  125. //给模板赋值  
  126. this.GetTemplate("EntityProviderBase.cst").SetProperty("SourceTable", SourceTable);  
  127. //数据库属性  
  128. <%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Optional="False" Category="DataSource" Description="Database that the stored procedures should be based on." %>  
  129. //遍历数据库里面的所有数据表  
  130. private TableSchemaCollection _sourceTables;  
  131. private ViewSchemaCollection _sourceViews;  
  132. for (int i=0; i < SourceDatabase.Tables.Count; i++)  
  133. {  
  134. _sourceTables.Add(SourceDatabase.Tables[i]);  
  135. }  
  136. //遍历数据库里面的所有视图  
  137. for (int i=0; i < SourceDatabase.Views.Count; i++)  
  138. {  
  139. _sourceViews.Add(SourceDatabase.Views[i]);  
  140. }  
  141. //获取表格名  
  142. SourceTables[i].Name  
  143. //遍历表的结构  
  144. for (int i=0; i< SourceTable.Columns.Count; i++) {  
  145. Response.Write("\""+ SourceTable.Columns[i].Name + "\""); }  
  146. //指定打开哪个或者哪几个表  
  147. [Category("DataSource")]  
  148. [Description("The tables to generate.")]  
  149. [CodeTemplateProperty(CodeTemplatePropertyOption.Optional)]  
  150. public TableSchemaCollection SourceTables  
  151. {  
  152. get 
  153. {  
  154. if (this._sourceTables != null && this._sourceTables.Count > 0 )  
  155. return this._sourceTables;  
  156. else 
  157. return null;  
  158. }  
  159. set 
  160. {  
  161. this._sourceTables = value;  
  162. }  
  163. }  
  164. //关于遍历文件夹和拷贝文件夹里面所有文件是我自己写的,在nettiers里面没有用例:  
  165. //拷贝目录  
  166. public void CopyDirectory(string path)  
  167. {  
  168. SafeCreateDirectory(OutputDirectory+path);  
  169. DirectoryInfo dir = new DirectoryInfo(this.CodeTemplateInfo.DirectoryName+path);  
  170. FileInfo[] fileList = dir.GetFiles();  
  171. foreach (FileInfo sourceFile in fileList)   
  172. {   
  173. sourceFile.CopyTo(OutputDirectory + path+"\\"+sourceFile.Name, true);  
  174. Response.WriteLine("Copy file: " + sourceFile.Name);  
  175. }  
  176. }  
  177.  
  178. //遍历文件夹:先打开目录,然后载入目录下的文件,这个操作完全是用c#代码来写的,更多功能可以参考msdn  
  179. DirectoryInfo dir = new DirectoryInfo(this.CodeTemplateInfo.DirectoryName+path);  
  180. FileInfo[] fileList = dir.GetFiles();  
  181. foreach (FileInfo sourceFile in fileList)   
  182. {   
  183. sourceFile.CopyTo(OutputDirectory + path+"\\"+sourceFile.Name, true);  
  184. Response.WriteLine("Copy file: " + sourceFile.Name);  
  185. }  

本日志由 hooperzao 于 2010-05-29 19:45:15 发表到 敏捷开发 中,目前已经被浏览 111 次,评论 0 次;

  1. using System;  
  2. using System.IO;  
  3. using System.Text;  
  4. using System.Security.Cryptography;  
  5. using System.Web;  
  6.  
  7. namespace Test.Com  
  8. {  
  9. /// <summary>  
  10.  /// DESEncryptor 的摘要说明。  
  11.  /// </summary>  
  12.  public class DESEncryptor  
  13.  {  
  14.   #region 私有成员  
  15.   /// <summary>  
  16.   /// 输入字符串  
  17.   /// </summary>  
  18.   private string inputString=null;  
  19.   /// <summary>  
  20.   /// 输出字符串  
  21.   /// </summary>  
  22.   private string outString=null;  
  23.   /// <summary>  
  24.   /// 输入文件路径  
  25.   /// </summary>  
  26.   private string inputFilePath=null;  
  27.   /// <summary>  
  28.   /// 输出文件路径  
  29.   /// </summary>  
  30.   private string outFilePath=null;  
  31.   /// <summary>  
  32.   /// 加密密钥  
  33.   /// </summary>  
  34.   private string encryptKey=null;  
  35.   /// <summary>  
  36.   /// 解密密钥  
  37.   /// </summary>  
  38.   private string decryptKey=null;  
  39.   /// <summary>  
  40.   /// 提示信息  
  41.   /// </summary>  
  42.   private string noteMessage=null;  
  43.   #endregion  
  44.   #region 公共属性  
  45.   /// <summary>  
  46.   /// 输入字符串  
  47.   /// </summary>  
  48.   public string InputString  
  49.   {  
  50.    get{return inputString;}  
  51.    set{inputString=value;}  
  52.   }  
  53.   /// <summary>  
  54.   /// 输出字符串  
  55.   /// </summary>  
  56.   public string OutString  
  57.   {  
  58.    get{return outString;}  
  59.    set{outString=value;}  
  60.   }  
  61.   /// <summary>  
  62.   /// 输入文件路径  
  63.   /// </summary>  
  64.   public string InputFilePath  
  65.   {  
  66.    get{return inputFilePath;}  
  67.    set{inputFilePath=value;}  
  68.   }  
  69.   /// <summary>  
  70.   /// 输出文件路径  
  71.   /// </summary>  
  72.   public string OutFilePath  
  73.   {  
  74.    get{return outFilePath;}  
  75.    set{outFilePath=value;}  
  76.   }  
  77.   /// <summary>  
  78.   /// 加密密钥  
  79.   /// </summary>  
  80.   public string EncryptKey  
  81.   {  
  82.    get{return encryptKey;}  
  83.    set{encryptKey=value;}  
  84.   }  
  85.   /// <summary>  
  86.   /// 解密密钥  
  87.   /// </summary>  
  88.   public string DecryptKey  
  89.   {  
  90.    get{return decryptKey;}  
  91.    set{decryptKey=value;}  
  92.   }  
  93.   /// <summary>  
  94.   /// 错误信息  
  95.   /// </summary>  
  96.   public string NoteMessage  
  97.   {  
  98.    get{return noteMessage;}  
  99.    set{noteMessage=value;}  
  100.   }  
  101.   #endregion  
  102.   #region 构造函数  
  103.   public DESEncryptor()  
  104.   {  
  105.    //  
  106.    // TODO: 在此处添加构造函数逻辑  
  107.    //  
  108.   }  
  109.   #endregion  
  110.   #region DES加密字符串  
  111.   /// <summary>  
  112.   /// 加密字符串  
  113.   /// 注意:密钥必须为8位  
  114.   /// </summary>  
  115.   /// <param name="strText">字符串</param>  
  116.   /// <param name="encryptKey">密钥</param>  
  117.   public  void  DesEncrypt()  
  118.   {  
  119.    byte[] byKey=null;     
  120.    byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};  
  121.    try 
  122.    {  
  123.     byKey = System.Text.Encoding.UTF8.GetBytes(this.encryptKey.Substring(0,8));  
  124.     DESCryptoServiceProvider des = new DESCryptoServiceProvider();  
  125.     byte[] inputByteArray = Encoding.UTF8.GetBytes(this.inputString);  
  126.     MemoryStream ms = new  MemoryStream();  
  127.     CryptoStream cs = new  CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write) ;  
  128.     cs.Write(inputByteArray, 0, inputByteArray.Length);  
  129.     cs.FlushFinalBlock();  
  130.     this.outString=Convert.ToBase64String(ms.ToArray());  
  131.    }  
  132.    catch(System.Exception error)  
  133.    {  
  134.     this.noteMessage=error.Message;  
  135.    }  
  136.   }  
  137.   #endregion  
  138.   #region DES解密字符串  
  139.   /// <summary>  
  140.   /// 解密字符串  
  141.   /// </summary>  
  142.   /// <param name="this.inputString">加了密的字符串</param>  
  143.   /// <param name="decryptKey">密钥</param>  
  144.   public void DesDecrypt()  
  145.   {  
  146.    byte[] byKey = null;   
  147.    byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};   
  148.    byte[] inputByteArray = new Byte[this.inputString.Length];  
  149.    try 
  150.    {  
  151.     byKey = System.Text.Encoding.UTF8.GetBytes(decryptKey.Substring(0,8));  
  152.     DESCryptoServiceProvider des = new DESCryptoServiceProvider();  
  153.     inputByteArray = Convert.FromBase64String(this.inputString);  
  154.     MemoryStream ms = new MemoryStream();  
  155.     CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);  
  156.     cs.Write(inputByteArray, 0, inputByteArray.Length);  
  157.     cs.FlushFinalBlock();  
  158.     System.Text.Encoding encoding = new System.Text.UTF8Encoding();  
  159.     this.outString=encoding.GetString(ms.ToArray());  
  160.    }  
  161.    catch(System.Exception error)  
  162.    {  
  163.     this.noteMessage=error.Message;  
  164.    }  
  165.   }  
  166.   #endregion  
  167.   #region DES加密文件  
  168.   /// <summary>  
  169.   /// DES加密文件  
  170.   /// </summary>  
  171.   /// <param name="this.inputFilePath">源文件路径</param>  
  172.   /// <param name="this.outFilePath">输出文件路径</param>  
  173.   /// <param name="encryptKey">密钥</param>  
  174.   public void FileDesEncrypt()  
  175.   {  
  176.    byte[] byKey=null;     
  177.    byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};  
  178.    try 
  179.    {  
  180.     byKey = System.Text.Encoding.UTF8.GetBytes(this.encryptKey.Substring(0,8));  
  181.     FileStream fin = new FileStream(this.inputFilePath, FileMode.Open, FileAccess.Read);  
  182.     FileStream fout = new FileStream(this.outFilePath, FileMode.OpenOrCreate, FileAccess.Write);  
  183.     fout.SetLength(0);  
  184.     //Create variables to help with read and write.  
  185.     byte[] bin  = new byte[100]; //This is intermediate storage for the encryption.  
  186.     long rdlen  = 0;              //This is the total number of bytes written.  
  187.     long totlen = fin.Length;    //This is the total length of the input file.  
  188.     int  len;                     //This is the number of bytes to be written at a time.  
  189.     DES des = new DESCryptoServiceProvider();            
  190.     CryptoStream encStream = new CryptoStream(fout, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);  
  191.                   
  192.    
  193.     //Read from the input file, then encrypt and write to the output file.  
  194.     while(rdlen < totlen)  
  195.     {  
  196.      len = fin.Read(bin, 0, 100);  
  197.      encStream.Write(bin, 0, len);  
  198.      rdlen = rdlen + len;   
  199.     }  
  200.    
  201.     encStream.Close();    
  202.     fout.Close();  
  203.     fin.Close();       
  204.       
  205.  
  206.    }  
  207.    catch(System.Exception error)  
  208.    {  
  209.     this.noteMessage=error.Message.ToString();  
  210.       
  211.    }  
  212.   }  
  213.   #endregion  
  214.   #region DES解密文件  
  215.   /// <summary>  
  216.   /// 解密文件  
  217.   /// </summary>  
  218.   /// <param name="this.inputFilePath">加密了的文件路径</param>  
  219.   /// <param name="this.outFilePath">输出文件路径</param>  
  220.   /// <param name="decryptKey">密钥</param>  
  221.   public void FileDesDecrypt()  
  222.   {  
  223.    byte[] byKey = null;   
  224.    byte[] IV= {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};      
  225.    try 
  226.    {  
  227.     byKey = System.Text.Encoding.UTF8.GetBytes(decryptKey.Substring(0,8));   
  228.     FileStream fin = new FileStream(this.inputFilePath, FileMode.Open, FileAccess.Read);  
  229.     FileStream fout = new FileStream(this.outFilePath, FileMode.OpenOrCreate, FileAccess.Write);  
  230.     fout.SetLength(0);  
  231.     //Create variables to help with read and write.  
  232.     byte[] bin  = new byte[100]; //This is intermediate storage for the encryption.  
  233.     long rdlen  = 0;              //This is the total number of bytes written.  
  234.     long totlen = fin.Length;    //This is the total length of the input file.  
  235.     int  len;                     //This is the number of bytes to be written at a time.  
  236.     DES des = new DESCryptoServiceProvider();            
  237.     CryptoStream encStream = new CryptoStream(fout, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);  
  238.                    
  239.    
  240.     //Read from the input file, then encrypt and write to the output file.  
  241.     while(rdlen < totlen)  
  242.     {  
  243.      len = fin.Read(bin, 0, 100);  
  244.      encStream.Write(bin, 0, len);  
  245.      rdlen = rdlen + len;       
  246.     }  
  247.    
  248.     encStream.Close();    
  249.     fout.Close();  
  250.     fin.Close();       
  251.    }  
  252.    catch(System.Exception error)  
  253.    {  
  254.     this.noteMessage=error.Message.ToString();  
  255.    }  
  256.   }  
  257.   #endregion  
  258.   #region MD5  
  259.   /// <summary>  
  260.   /// MD5 Encrypt  
  261.   /// </summary>  
  262.   /// <param name="strText">text</param>  
  263.   /// <returns>md5 Encrypt string</returns>  
  264.   public void MD5Encrypt()  
  265.   {  
  266.    MD5 md5 = new MD5CryptoServiceProvider();  
  267.    byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(this.inputString));     
  268.    this.outString=System.Text.Encoding.Default.GetString(result);  
  269.   }  
  270.   #endregion  
  271.    
  272.  }  
  273. }   

本文来自CSDN博客:http://blog.csdn.net/cooljazz/archive/2006/05/31/766660.aspx

本日志由 hooperzao 于 2010-05-28 20:58:18 发表到 C# 中,目前已经被浏览 98 次,评论 0 次;

 

  1. /**********************Created by Chen*****************  
  2.  
  3. *出处以及原创作者email:aishen944-sohu.com  
  4.  
  5. ***********************************************************/ 
  6.  
  7. using System;  
  8. using System.Drawing;  
  9. using System.Drawing.Drawing2D;  
  10. using System.Drawing.Imaging;  
  11. using System.IO;  
  12. namespace ImageDrawing  
  13. {  
  14.  /// <summary>  
  15.  /// 图片修改类,主要是用来保护图片版权的  
  16.  /// </summary>  
  17.  public class ImageModification  
  18.  {  
  19.   #region "member fields"  
  20.   private string modifyImagePath=null;  
  21.   private string drawedImagePath=null;  
  22.   private int rightSpace;  
  23.   private int bottoamSpace;  
  24.   private int lucencyPercent=70;  
  25.   private string outPath=null;  
  26.   #endregion  
  27.   public ImageModification()  
  28.   {  
  29.   }  
  30.   #region "propertys"  
  31.   /// <summary>  
  32.   /// 获取或设置要修改的图像路径  
  33.   /// </summary>  
  34.   public string ModifyImagePath  
  35.   {  
  36.    get{return this.modifyImagePath;}  
  37.    set{this.modifyImagePath=value;}  
  38.   }  
  39.   /// <summary>  
  40.   /// 获取或设置在画的图片路径(水印图片)  
  41.   /// </summary>  
  42.   public string DrawedImagePath  
  43.   {  
  44.    get{return this.drawedImagePath;}  
  45.    set{this.drawedImagePath=value;}  
  46.   }  
  47.   /// <summary>  
  48.   /// 获取或设置水印在修改图片中的右边距  
  49.   /// </summary>  
  50.   public int RightSpace  
  51.   {  
  52.    get{return this.rightSpace;}  
  53.    set{this.rightSpace=value;}  
  54.   }  
  55.   //获取或设置水印在修改图片中距底部的高度  
  56.   public int BottoamSpace  
  57.   {  
  58.    get{return this.bottoamSpace;}  
  59.    set{this.bottoamSpace=value;}  
  60.   }  
  61.   /// <summary>  
  62.   /// 获取或设置要绘制水印的透明度,注意是原来图片透明度的百分比  
  63.   /// </summary>  
  64.   public int LucencyPercent  
  65.   {  
  66.    get{return this.lucencyPercent;}  
  67.    set 
  68.    {  
  69.     if(value>=0&&value<=100)  
  70.      this.lucencyPercent=value;  
  71.    }  
  72.   }  
  73.   /// <summary>  
  74.   /// 获取或设置要输出图像的路径  
  75.   /// </summary>  
  76.   public string OutPath  
  77.   {  
  78.    get{return this.outPath;}  
  79.    set{this.outPath=value;}  
  80.   }  
  81.   #endregion  
  82.   #region "methods"  
  83.   /// <summary>  
  84.   /// 开始绘制水印  
  85.   /// </summary>  
  86.   public void DrawImage()  
  87.   {  
  88.    Image modifyImage=null;  
  89.    Image drawedImage=null;  
  90.    Graphics g=null;  
  91.    try 
  92.    {      
  93.     //建立图形对象  
  94.     modifyImage=Image.FromFile(this.ModifyImagePath);  
  95.     drawedImage=Image.FromFile(this.DrawedImagePath);  
  96.     g=Graphics.FromImage(modifyImage);  
  97.     //获取要绘制图形坐标  
  98.     int x=modifyImage.Width-this.rightSpace;  
  99.     int y=modifyImage.Height-this.BottoamSpace;  
  100.     //设置颜色矩阵  
  101.     float[][] matrixItems ={   
  102.              new float[] {1, 0, 0, 0, 0},  
  103.              new float[] {0, 1, 0, 0, 0},  
  104.              new float[] {0, 0, 1, 0, 0},  
  105.              new float[] {0, 0, 0, (float)this.LucencyPercent/100f, 0},   
  106.              new float[] {0, 0, 0, 0, 1}};   
  107.  
  108.     ColorMatrix colorMatrix = new ColorMatrix(matrixItems);  
  109.     ImageAttributes imgAttr=new ImageAttributes();  
  110.     imgAttr.SetColorMatrix(colorMatrix,ColorMatrixFlag.Default,ColorAdjustType.Bitmap);  
  111.     //绘制阴影图像  
  112.     g.DrawImage(  
  113.      drawedImage,  
  114.      new Rectangle(x,y,drawedImage.Width,drawedImage.Height),  
  115.      0,0,drawedImage.Width,drawedImage.Height,  
  116.      GraphicsUnit.Pixel,imgAttr);  
  117.     //保存文件  
  118.     string[] allowImageType={".jpg",".gif",".png",".bmp",".tiff",".wmf",".ico"};  
  119.     FileInfo file=new FileInfo(this.ModifyImagePath);  
  120.     ImageFormat imageType=ImageFormat.Gif;  
  121.     switch(file.Extension.ToLower())  
  122.     {  
  123.      case ".jpg":  
  124.       imageType=ImageFormat.Jpeg;  
  125.       break;  
  126.      case ".gif":  
  127.       imageType=ImageFormat.Gif;  
  128.       break;  
  129.      case ".png":  
  130.       imageType=ImageFormat.Png;  
  131.       break;  
  132.      case ".bmp":  
  133.       imageType=ImageFormat.Bmp;  
  134.       break;  
  135.      case ".tif":  
  136.       imageType=ImageFormat.Tiff;  
  137.       break;  
  138.      case ".wmf":  
  139.       imageType=ImageFormat.Wmf;  
  140.       break;  
  141.      case ".ico":  
  142.       imageType=ImageFormat.Icon;  
  143.       break;  
  144.      default:  
  145.       break;  
  146.     }  
  147.     MemoryStream ms=new MemoryStream();  
  148.     modifyImage.Save(ms,imageType);  
  149.     byte[] imgData=ms.ToArray();  
  150.     modifyImage.Dispose();  
  151.     drawedImage.Dispose();  
  152.     g.Dispose();  
  153.     FileStream fs=null;  
  154.     if(this.OutPath==null || this.OutPath=="")  
  155.     {  
  156.      File.Delete(this.ModifyImagePath);  
  157.      fs=new FileStream(this.ModifyImagePath,FileMode.Create,FileAccess.Write);  
  158.     }  
  159.     else 
  160.     {  
  161.      fs=new FileStream(this.OutPath,FileMode.Create,FileAccess.Write);  
  162.     }  
  163.     if(fs!=null)  
  164.     {  
  165.      fs.Write(imgData,0,imgData.Length);  
  166.      fs.Close();  
  167.     }  
  168.    }  
  169.    finally 
  170.    {  
  171.     try 
  172.     {  
  173.      drawedImage.Dispose();  
  174.      modifyImage.Dispose();  
  175.      g.Dispose();  
  176.     }  
  177.     catch{;}  
  178.    }  
  179.   }  
  180.   #endregion  
  181.  }  
  182. }  

本文来自CSDN博客:http://blog.csdn.net/sunkangta/archive/2005/05/23/378534.aspx

本日志由 hooperzao 于 2010-05-28 20:56:19 发表到 C# 中,目前已经被浏览 66 次,评论 0 次;

  1. using System;  
  2.  
  3. namespace Test.Com  
  4. {  
  5.  /// <summary>  
  6.  /// 功能:字符串处理函数集  
  7.  /// </summary>  
  8.  public class DealString  
  9.  {  
  10.   #region 私有成员  
  11.   /// <summary>  
  12.   /// 输入字符串  
  13.   /// </summary>  
  14.   private string inputString=null;  
  15.   /// <summary>  
  16.   /// 输出字符串  
  17.   /// </summary>  
  18.   private string outString=null;  
  19.   /// <summary>  
  20.   /// 提示信息  
  21.   /// </summary>  
  22.   private string noteMessage=null;  
  23.   #endregion  
  24.  
  25.   #region 公共属性  
  26.   /// <summary>  
  27.   /// 输入字符串  
  28.   /// </summary>  
  29.   public string InputString  
  30.   {  
  31.    get{return inputString;}  
  32.    set{inputString=value;}  
  33.   }  
  34.   /// <summary>  
  35.   /// 输出字符串  
  36.   /// </summary>  
  37.   public string OutString  
  38.   {  
  39.    get{return outString;}  
  40.    set{outString=value;}  
  41.   }  
  42.   /// <summary>  
  43.   /// 提示信息  
  44.   /// </summary>  
  45.   public string NoteMessage  
  46.   {  
  47.    get{return noteMessage;}  
  48.    set{noteMessage=value;}  
  49.   }  
  50.   #endregion  
  51.     
  52.   #region 构造函数  
  53.   public DealString()  
  54.   {  
  55.    //  
  56.    // TODO: 在此处添加构造函数逻辑  
  57.    //  
  58.   }  
  59.   #endregion  
  60.  
  61.   #region 公共方法  
  62.   public void ConvertToChineseNum()  
  63.   {  
  64.    string numList="零壹贰叁肆伍陆柒捌玖";  
  65.    string rmbList = "分角元拾佰仟万拾佰仟亿拾佰仟万";  
  66.    double number=0;  
  67.    string tempOutString=null;  
  68.  
  69.    try 
  70.    {  
  71.     number=double.Parse(this.inputString);  
  72.    }  
  73.    catch 
  74.    {  
  75.     this.noteMessage="传入参数非数字!";  
  76.     return;  
  77.    }  
  78.      
  79.    if(number>9999999999999.99)  
  80.     this.noteMessage="超出范围的人民币值";  
  81.  
  82.    //将小数转化为整数字符串  
  83.    string tempNumberString=Convert.ToInt64(number*100).ToString();  
  84.    int tempNmberLength=tempNumberString.Length;  
  85.    int i=0;  
  86.    while(i<tempNmberLength)  
  87.    {  
  88.     int oneNumber=Int32.Parse(tempNumberString.Substring(i,1));  
  89.     string oneNumberChar=numList.Substring(oneNumber,1);  
  90.     string oneNumberUnit=rmbList.Substring(tempNmberLength-i-1,1);  
  91.     if(oneNumberChar!="零")  
  92.      tempOutString+=oneNumberChar+oneNumberUnit;  
  93.     else 
  94.     {  
  95.      if(oneNumberUnit=="亿"||oneNumberUnit=="万"||oneNumberUnit=="元"||oneNumberUnit=="零")  
  96.      {  
  97.       while (tempOutString.EndsWith("零"))  
  98.       {  
  99.        tempOutString=tempOutString.Substring(0,tempOutString.Length-1);  
  100.       }  
  101.  
  102.      }  
  103.      if(oneNumberUnit=="亿"||(oneNumberUnit=="万"&&!tempOutString.EndsWith("亿"))||oneNumberUnit=="元")  
  104.      {  
  105.       tempOutString+=oneNumberUnit;  
  106.      }  
  107.      else 
  108.      {  
  109.       bool tempEnd=tempOutString.EndsWith("亿");  
  110.       bool zeroEnd=tempOutString.EndsWith("零");  
  111.       if(tempOutString.Length>1)  
  112.       {  
  113.        bool zeroStart=tempOutString.Substring(tempOutString.Length-2,2).StartsWith("零");  
  114.        if(!zeroEnd&&(zeroStart||!tempEnd))  
  115.         tempOutString+=oneNumberChar;  
  116.       }  
  117.       else 
  118.       {  
  119.        if(!zeroEnd&&!tempEnd)  
  120.         tempOutString+=oneNumberChar;  
  121.       }  
  122.      }  
  123.     }  
  124.     i+=1;  
  125.    }  
  126.  
  127.    while (tempOutString.EndsWith("零"))  
  128.    {  
  129.     tempOutString=tempOutString.Substring(0,tempOutString.Length-1);  
  130.    }  
  131.  
  132.    while(tempOutString.EndsWith("元"))  
  133.    {  
  134.     tempOutString=tempOutString+"整";  
  135.    }  
  136.  
  137.    this.outString=tempOutString;  
  138.  
  139.      
  140.   }  
  141.   #endregion  
  142.  }  

 本文来自CSDN博客:http://blog.csdn.net/rexsp/archive/2004/03/30/14170.aspx

本日志由 hooperzao 于 2010-05-28 20:55:15 发表到 C# 中,目前已经被浏览 105 次,评论 0 次;

191/2