prettyprint
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Prettify</title>
<link href="prettify.min.css" rel="stylesheet">
<script src="prettify.min.js"></script>
<style>
pre.prettyprint
{
border: 2px dashed #;
background: #ddd;
}
</style>
<script>
window.onload = function ()
{
// Load Prettify
prettyPrint();
}
</script>
</head>
<body>
<pre class="prettyprint lang-java">
// 异步方式
// 结果以事件回调方式返回
Command command = new Command("/system/bin/ping",
"-c", "", "-s", "",
"www.baidu.com");
Command.command(command, new Command.CommandListener() {
@Override
public void onCompleted(String str) {
Log.i(TAG, "onCompleted:\n" + str);
}
@Override
public void onCancel() {
Log.i(TAG, "onCancel");
}
@Override
public void onError() {
Log.i(TAG, "onError");
}
});
</pre>
<pre class="prettyprint lang-C#">
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text; namespace Justin.FrameWork.Helper
{
/// <summary>
/// Sql访问数据库帮助类
/// </summary>
public abstract class SqlHelper
{ /// <summary>
/// 如"data source=.;initial catalog=PrivilegeDB;integrated security=True;multipleactiveresultsets=True;"
/// </summary>
public static string ConnStr = "";
public static int CommandTimeout = ; private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection connection = new SqlConnection(connectionString))
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
}
public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandTimeout = ;
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
} public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
try
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
return rdr;
} catch
{
connection.Close();
throw;
}
}
public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection connection = new SqlConnection(connectionString))
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
object val = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return val;
} }
public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
object val = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return val;
} public static DataTable ExecuteDataTable(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{ SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
SqlDataAdapter MyAdapter = new SqlDataAdapter();
MyAdapter.SelectCommand = cmd;
DataSet ds = new DataSet();
MyAdapter.Fill(ds);
cmd.Parameters.Clear();
DataTable table = ds.Tables[];
ds.Dispose();
return table;
}
public static DataTable ExecuteDataTable(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand(); try
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
SqlDataAdapter MyAdapter = new SqlDataAdapter();
MyAdapter.SelectCommand = cmd;
DataSet ds = new DataSet();
MyAdapter.Fill(ds);
cmd.Parameters.Clear();
DataTable table = ds.Tables[];
ds.Dispose();
connection.Close();
return table;
}
catch
{
connection.Close();
throw;
}
}
} public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters)
{
parmCache[cacheKey] = commandParameters;
}
public static SqlParameter[] GetCachedParameters(string cacheKey)
{ SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey];
if (cachedParms == null)
return null;
SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length];
for (int i = , j = cachedParms.Length; i < j; i++)
clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone();
return clonedParms;
}
private static void PrepareCommand(SqlCommand cmd, SqlConnection connection, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms)
{
if (connection.State != ConnectionState.Open)
connection.Open();
cmd.Connection = connection;
cmd.CommandText = cmdText;
cmd.CommandTimeout = CommandTimeout;
if (trans != null)
cmd.Transaction = trans;
cmd.CommandType = cmdType;
if (cmdParms != null)
{
foreach (SqlParameter parm in cmdParms)
cmd.Parameters.Add(parm); } } public static SqlConnection GetConnection(string connectionString)
{
return new SqlConnection(connectionString);
}
}
} </pre>
</body>
</html>
prettyprint的更多相关文章
- JsonFormatter PrettyPrint
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- How can I pretty-print JSON in python?
python -m json.tool my_json.json 转自: http://stackoverflow.com/questions/352098/how-can-i-pretty-prin ...
- 使用dom4j工具:设置输出格式compactFormat和PrettyPrint(六)
package dom4j_write; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStre ...
- kindeditor4整合SyntaxHighlighter,让代码亮起来
这一篇我将介绍如何让kindeditor4.x整合SyntaxHighlighter代码高亮,因为SyntaxHighlighter的应用非常广泛,所以将kindeditor默认的prettify替换 ...
- 让kindeditor显示高亮代码
kindeditor4.x代码高亮功能默认使用的是prettify插件,prettify是Google提供的一款源代码语法高亮着色器,它提供一种简单的形式来着色HTML页面上的程序代码,实现方式如下: ...
- 快速搭建springmvc+spring data jpa工程
一.前言 这里简单讲述一下如何快速使用springmvc和spring data jpa搭建后台开发工程,并提供了一个简单的demo作为参考. 二.创建maven工程 http://www.cnblo ...
- 创建maven项目(cmd 命令)
2016五月 22 原 创建maven项目(cmd 命令) 分类:maven (994) (0) 1.普通方式创建 1)进入cmd窗口执行 mvn archetype:generate 2) 光标停止 ...
- springmvc环境搭建以及常见问题解决
1.新建maven工程 a) 打开eclipse,file->new->project->Maven->Maven Project b) 下一步 c) 选择创建的工程为 ...
- Webpack从入门到上线
webpack是目前一个很热门的前端打包工具,官网说得很清楚,webpack的出现就是要把requirejs干掉.同时它还提供了十分便利的本地开发的环境.网上并不容易找到一个讲解得比较详细完整的教程, ...
随机推荐
- Spark1.0源码编译
编译方式一:mavenexport MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"m ...
- 解决PHP生成校验码时“图像因其本身有错无法显示”的错误
今天使用http://crazymud.iteye.com/blog/452293给出的代码进行PHP生成校验码功能的实现,发现firefox一直提示“图像.......因其本身有错无法显示”的问题, ...
- 初探接口测试框架--python系列7
点击标题下「蓝色微信名」可快速关注 坚持的是分享,搬运的是知识,图的是大家的进步,没有收费的培训,没有虚度的吹水,喜欢就关注.转发(免费帮助更多伙伴)等来交流,想了解的知识请留言,给你带来更多价值,是 ...
- 3.5 The Lexical-Analyzer Generator Lex
3.5 The Lexical-Analyzer Generator Lex In this section, we introduce a tool called Lex, or in a more ...
- windows2008 设置会话超时时间
[ 组策略 ]开始-->运行-->gpedit.msc 计算机配置->管理模板->Windows组件->终端服务->会话
- Could not find action or result
[WARN ] 2013-11-21 14:08:16 :Could not find action or resultThere is no Action mapped for namespace ...
- Accessing the Deep Web: A Survey
http://www.inf.ufsc.br/~ronaldo/deepWeb/querying/Chang-dwsurvey-cacm07.pdf
- javascript设计模式-组合模式
组合模式所要解决的问题: 可以使用简单的对象组合成复杂的对象,而这个复杂对象有可以组合成更大的对象.可以把简单这些对象定义成类,然后定义一些容器类来存储这些简单对象. 客户端代码必须区别对象简单对象和 ...
- MULTIBYTETOWIDECHAR的与WIDECHARTOMULTIBYTE的参数详解及相互转换
第一个就是宽字符到多字节字符转换函数,函数原型如下: int WideCharToMultiByte( UINT CodePage, DWORD dwFlags, LPCWSTR lpWideChar ...
- 监控系统 - check_mk_agent
系统级监控 cpu (system, user) memory (cache, buffer, use)(MB) load (cpu core) diskspace (used, inode)(GB) ...