编程笔记

******************2009-2019 coding 笔记**********************

----------------------------------------------------------------------------------------------

SELECT id, code, Name, Lasttrade, Chg, ChgPct, OpenPrice, YClose, High, Low, Volume, Amount, Time
FROM HisInfo

SELECT id, code, Name, Lasttrade, Chg, ChgPct, OpenPrice, YClose, High, Low, Volume, Amount, Time
FROM HisInfo_All
where time between '2010-05-11' and '2010-05-13'
----------------------------------------------------------------------------------------------
香港交易所从2011年3月7日更改了港股交易时间
最新的港股交易时间更改为:9:30:00-12:00:00 13:30:00-16:00:00
港股交易时间10:00--12.30 下午14.30--16.00
港交所从2012年3月6日更改了港股交易时间
港交:9:30:00-12:00:00 下午13:00:00-16:00:00
国内:9:30:00-11:30:00 下午13:00:00-15:00:00
期货:9:15:00-11:30:00 下午13:30:00-15:15:00
期货合约大小写:郑州和中金所是大写,上期和大连是小写
----------------------------------------------------------------------------------------------
取得系统运行初始目录
AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
----------------------------------------------------------------------------------------------
1.端口使用情况
netstat -n
netstat -an //显示全部
netstat -a命令将显示所有连接,而netstat -r显示路由表和活动连接。netstat -e命令将显示 Ethernet 统计信息,而netstat -s显示每个协议的统计信息

2.跟踪路由 tracert [-d] [-h maximum_hops] [-j computer-list] [-w timeout] target_name
tracert 192.168.1.1 //显示上网路由及IP对应的机器名
tracert www.gtadata.com.cn
----------------------------------------------------------------------------------------------
连接串
Data Source=192.168.187.122;Initial Catalog=HK_AlgoTrading;User ID=sa;Password=gta@2009;Connect Timeout=30

SQL Server 2005 可用性
在高可用技术、额外的备份和恢复功能,以及复制增强上的投资使企业能够构建和部署高可用的应用系统。
SQL Server 2005在高可用上的创新有:数据镜像,故障转移集群,数据库快照和增强的联机操作,
这有助于最小化宕机时间和确保企业的关键系统可用。
http://www.diybl.com/course/7_databases/sql/sql2005/20071226/95375.html
----------------------------------------------------------------------------------------------
sql2ksp4补丁
http://www.rztong.com.cn/download/sql2ksp4.rar
当SQL Server 2000安装后局域网能ping通但telnet端口失败时,要打sp4补丁。
----------------------------------------------------------------------------------------------
处理应用事件
Application.DoEvents();
----------------------------------------------------------------------------------------------
.Net常用工具组件
BackgroundWorker - 后台作业类
private BackgroundWorker _logWorker = new BackgroundWorker();
_logWorker = new BackgroundWorker();
_logWorker.DoWork += new DoWorkEventHandler(_logWorker_DoWork);
_logWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_logWorker_RunWorkerCompleted);

让它工作:
if (!this._logWorker.IsBusy)
this._logWorker.RunWorkerAsync();
----------------------------------------------------------------------------------------------
this[]的写法
public MLArray this[ int m, int n ]
{
set{ _cells[ GetIndex(m,n) ] = value; }
get{ return (MLArray)_cells[ GetIndex(m,n) ]; }
}
----------------------------------------------------------------------------------------------
事件定义过程
1、定义委托
public delegate void OrderResponseHandler( DataOrderBase orderbase );
2、定义委托变量(可选)
protected OrderResponseHandler _orderNoBackEvent = null;
3、定义事件属性
public event OrderResponseHandler orderNoBackEvent
{
add
{_orderNoBackEvent += value;}
remove
{_orderNoBackEvent -= value;}
}

不定义委托变量时
m_ClientSocket.OnConnect += new ObjectHandler(SocketOnConnect);

事件写法
public delegate void EventHandler(Object sender, EventArgs e);
public event EventHandler NoDataEventHandler;
----------------------------------------------------------------------------------------------
函数接口,->需在派生类中实现
public abstract DataAccount Login(DataAccountBase cDataAccount);
----------------------------------------------------------------------------------------------
多线程中异步更新UI界面
OnShow = ShowText;
void test_OnTime(string str)
{
BeginInvoke(OnShow, new object[] { str });
}
public delegate void ShowStr(string str);
protected ShowStr OnShow = null;

private void ShowText(string str)
{
this.Text = str;
}
2===========================================
OnShow = ShowText;
void test_OnTime(string str)
{
BeginInvoke(OnShow, new object[] { str });
}
private Action<string> OnShow;
private void ShowText(string str)
{
this.Text = str;
}
----------------------------------------------------------------------------------------------
多线程加委托的方法解决界面卡死
delegate void labDelegate(string str);
private void SetLableText(string str)
{
if (label1.InvokeRequired)
{
Invoke(new labDelegate(SetLableText), new string[] { str });
}
else
{
label1.Text = str;
}
}

//use SetLableText("数据加载完成!");
----------------------------------------------------------------------------------------------
异步调用
this.BeginInvoke(new MethodInvoker(delegate()
{
button1.Enabled = true;
}));

----------------------------------------------------------------------------------------------
事件
public event Action<Dictionary<string, string>> OnNewOrderSingle;

public delegate void RecvMessageEventHandler(object sender, string msg);
public event RecvMessageEventHandler OnRecvMessage;
----------------------------------------------------------------------------------------------

泛型委托
1.Action是没有返回值的委托
2.Func<> 是有返回值的委托,其它定义及使用和Action一样
3.
private Func<string, string> ph;
----------------------------------------------------------------------------------------------
异步执行
//定义
Action<DataOrderExt> ProcFunc;
ProcFunc = ProcItem;
void ProcItem(DataOrderExt obj) {...}
ProcFunc.BeginInvoke(obj, new AsyncCallback(ProcessEnd), null); //异步调用
----------------------------------------------------------------------------------------------
取某目录的所有文件数
public int GetFileLists(string srcPath)
{
try
{
string[] fileList = System.IO.Directory.GetFileSystemEntries(srcPath);
foreach (string file in fileList)
{
if (System.IO.Directory.Exists(file))
GetFileNum(file);
else
fileNum++;
}
}
catch
{
}
return fileNum;
}
----------------------------------------------------------------------------------------------
应用程序必须运行完所有的前台线程才可以
退出;而对于后台线程,应用程序则可以不考虑其是否已经运行完毕而直接退出,所有的
后台线程在应用程序退出时都会自动结束。
一个线程是前台线程还是后台线程可由它的IsBackground属性来决定。默认为前台线程

----------------------------------------------------------------------------------------------
#region == MD5加密 ==

using System.Security.Cryptography;

/// <summary>
/// 加密
/// </summary>
/// <param name="source">待加密的字符串</param>
/// <returns>返回32字符组成的字符串</returns>
public static string MD5Encrypt(string source)
{
string strReturn = "";
try
{
byte[] btEncrypt = (new UnicodeEncoding()).GetBytes(source);
MD5 mMd5 = new MD5CryptoServiceProvider();
strReturn = BytesToHexString(mMd5.ComputeHash(btEncrypt));
}
catch (Exception ex)
{
LogHelper.WriteException(ex.Message, "BOManager.BLL.LocalTrader.MD5Encrypt");
}
return strReturn;
}
/// <summary>
/// 字节转换为十六进制字符串 如:255 ->"FF", 14->"0E"
/// </summary>
/// <param name="btSource"></param>
/// <returns></returns>
private static string BytesToHexString(byte[] btSource)
{
if (null == btSource || 0 == btSource.Length)
return string.Empty;
StringBuilder sbDes = new StringBuilder();
foreach (byte bBt in btSource)
{
sbDes.Append(bBt.ToString("x2"));
}
return sbDes.ToString().ToUpper();
}
#endregion
----------------------------------------------------------------------------------------------
该方法已过期
[Obsolete("该方法已过期", true)]
public static void SetCodeListData(byte[] codeDatas, DateTime lastUpdateTime)
{...}
----------------------------------------------------------------------------------------------
SQL 2005 快照生成
create database db_mirror_snapshot on (name=DB_Mirror_data,Filename='d:\luo\db_mirror_snapshot.ss')
as snapshot of db_mirror;
go

-- 恢复数据库快照
RESTORE DATABASE db_mirror FROM DATABASE_SNAPSHOT = db_mirror_snapshot
GO

drop database db_mirror_snapshot
go
----------------------------------------------------------------------------------------------
显示数据库组成
RESTORE FILELISTONLY FROM disk='D:\虚拟交易所后台V2.0\VTS_ManagementCenter.bak'
----------------------------------------------------------------------------------------------
select @@version; --查看SQL2005版本

SELECT * FROM sys.database_mirroring_endpoints --查看端点情况

SELECT * FROM sys.database_mirroring_endpoints
SELECT * FROM sys.database_mirroring WHERE database_id =
(SELECT database_id FROM sys.databases WHERE name = 'db_mirror')
go
----------------------------------------------------------------------------------------------
镜像备变主切换?
use master
go
alter database test set partner force_service_allow_data_loss
go

----------------------------------------------------------------------------------------------
网络负载平衡群集(NLB) 2010-02-01
->就是一个虚拟IP对应多台服务器,要是win2003系统,安装有网络负载平衡群集管理,然后用管理员登录,
最好是一样的名称和密码。
->加入负载均衡方法:
在Win2003中本地连接选中属性里的负载均衡,设置属性为VIP(虚拟IP),并且在TCP/IP里进入“高级”,在IP里加入虚拟
的IP。注:加入多台时,优先级从1~32,不要重复,不然无法成功聚合
2011.3.8补充:
1.VIP要跟实体IP在同一网段,不然不能成功!(今天试了班天不行最后在网上找到说要同一网段)
2.客户端也要在同一网段,不然也ping不到(通过在核心交换机/路由器上做虚地址与MAC地址的绑定解决,但没试过)
在三层交换机上添加静态arp记录 192.168.1.11 02:BF:CA:78:90:0B 这个是相同的MAC地址。
是加了MAC地址才可以,MAC是集群属性里跟IP设置对应的网络地址。
3.注:此次测试的主机都是固定IP,不是动态生成的还不知有无影响,不过不在域中也是可行的
4.单网卡用多播,双网卡用单播,多播才能保持原IP通讯
----------------------------------------------------------------------------------------------
安装 卸载.net服务
installutil F:\Projects\roeWinSrv\roeWinSrv\bin\Debug\roe.exe
installutil /uninstall F:\Projects\roeWinSrv\roeWinSrv\bin\Debug\roe.exe
----------------------------------------------------------------------------------------------
遍历字典
Dictionary<string, string> pushData;
foreach (KeyValuePair<string, string> tag in pushData)

----------------------------------------------------------------------------------------------
可由多个线程同时访问的字典
ConcurrentDictionary<string, object> m_CacheManager
----------------------------------------------------------------------------------------------
SQL连接串
DATABASE=quickfix;DRIVER={SQL Server};SERVER=(local)
Data Source=local; database=HK_AlgoTrading;User ID=sa;Password=sa;Asynchronous Processing=True;Connect Timeout=30
server=192.168.187.35;uid=root;password=luo;database=ArbitrageSysROE;pooling=true
Data Source=192.168.187.35; database=ArbitrageSysROE;User ID=sa;Password=sa;Asynchronous Processing=True;Connect Timeout=30
----------------------------------------------------------------------------------------------
删除表记录方式:
truncate table dbo.tam_dtl 重置主键同时清所有记录
delete From dbo.tam_dtl 只是删记录

----------------------------------------------------------------------------------------------
多线程
Thread thread = new Thread(new ThreadStart(saveMgr.DoSave));
thread.IsBackground = true;
thread.Priority = ThreadPriority.Highest;
thread.Start();
----------------------------------------------------------------------------------------------
将一个表的数据复制到另一个表
insert into tam_HK_MasterOrder_dtl_bak select * from tam_HK_MasterOrder_dtl
SET @errorSun=@errorSun +@@ERROR
----------------------------------------------------------------------------------------------
1、显示自定义的代码内容
2、显示1~5档的双向内容
3、统计1~5档及累计信息,分析走势

----------------------------------------------------------------------------------------------
保留2位小数
this.lblExecRate.Text = m_NewQty == 0.0F ? "0.00" : (m_OrderQty / m_NewQty).ToString("P02");
----------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------
回调函数 - AsyncCallback 的实现,主函数做完后接着执行回调

public delegate string ProcessHandler(string s);
ProcessHandler ph = ActionSwitch;

protected string ActionSwitch(string s)
{
str1 = s;
return s + ":"; //返回值在回调中EndInvoke能获取到
}
protected void ProcessEnd(IAsyncResult ar)
{
string s = ph.EndInvoke(ar); //得到主调的返回值
str2 = s + ar.AsyncState.ToString();//获取主调传过来的预设值
}
private void btnCall_Click(object sender, EventArgs e)
{
ph.BeginInvoke(textBox1.Text, new AsyncCallback(ProcessEnd), textBox2.Text); //主线程已完成了,ActionSwitch和ProcessEnd是另外线程去执行
// 传给主函数参数 回调函数 传给回调函数的参数
}

*****回调*****
1. 业务连接对象队列数据
public class MessageData: EventArgs {}
2 数据处理委托
public delegate void OrderServiceProcessHandler( MessageData e );
3. 调用
1).MessageData md;
2).
OrderServiceProcessHandler soeh = new OrderServiceProcessHandler(this.ActionSwitch);
soeh.BeginInvoke(md, new AsyncCallback(this.SendOrderCallBack), md);
3).
protected void ActionSwitch(MessageData md){}
4).
protected void SendOrderCallBack(IAsyncResult ar)
{
ThreadPool.QueueUserWorkItem(this.SendOrderCallBackProcess, ar);
}
5).
protected void SendOrderCallBackProcess(object state)
{
IAsyncResult ar = (IAsyncResult)state;
MessageData md = (MessageData)ar.AsyncState;
}
4. 使用
public event OrderServiceProcessHandler DoOrderEvent = null;
DoOrderEvent += new OrderServiceProcessHandler(_doOrderManager_DoOrderEvent);
void _doOrderManager_DoOrderEvent(MessageData e)
----------------------------------------------------------------------------------------------
读:TextBox1.Text=File.ReadAllText("d:/b.txt",Encoding.Default);
写:File.WriteAllText("d:/a.txt", TextBox1.Text, Encoding.Default);
追加:File.AppendAllText("d:/a.txt", TextBox1.Text, Encoding.Default);
----------------------------------------------------------------------------------------------
ini文件读写、删除

WritePrivateProfileString(_Section, _Key, _Value, _IniPath);

public static string IniReadValue(string _Section, string _Key, string _IniPath)
{
StringBuilder _temp = new StringBuilder(255);
int i = GetPrivateProfileString(_Section, _Key, "", _temp, 255, _IniPath);
return _temp.ToString();
}
删除
WritePrivateProfileString(_Section, _Key, null, _IniPath);
清空全部
WritePrivateProfileString(_Section, null, null, _IniPath);
----------------------------------------------------------------------------------------------
//注册未知异常处理事件
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnHandledException);
----------------------------------------------------------------------------------------------
线程池异步操作
foreach(var action in actions)
{
var a = action; //for循环中,还没执行,action就被改变了
ThreadPool.QueueUserWorkItem(state =>a(), null);
}
----------------------------------------------------------------------------------------------
反射生成类
string className = ConfigurationManager.AppSettings["QuotationService"];
factory = (IQuotationProviderFactory)Assembly.Load(className).CreateInstance(className+".GTARealTimeQuotationProviderFactory");
----------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------
C++ 异常不抛出的处理
try
{
}
catch(...) //三个点,表示所有异常的处理,
{}
----------------------------------------------------------------------------------------------
时间加减计算方法
TimeSpan sumTime = Convert.ToDateTime(endTime).Subtract(Convert.ToDateTime(startTime)) ;//得到时间差。
Double simTime = sumTime.TotalMinutes / 60; //得到你要的数字型结果。
----------------------------------------------------------------------------------------------
服务器技术:
2010.10.28
服务器用了队列,但数据几千几千的加,服务器没时间处理Client的请求,所以要入列与请求出列处理
要做成分开的。250846/355429 这是实时的一个数字,显示已累积很大,但Client却没什么事做


----------------------------------------------------------------------------------------------
将信息写入文件
System.IO.StreamWriter sw = new System.IO.StreamWriter(@"log/fixmsg.txt", true);
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm 下单 - ") + message.ToString());
sw.Close();
----------------------------------------------------------------------------------------------
读取xml文件
<fix major="4" minor="2"> //根
<fields> //组
<field number="1" name="Account" type="STRING"/> //成员
<field number="6" name="AvgPx" type="PRICE"/>
<field number="150" name="ExecType" type="CHAR">
<value enum="0" description="NEW"/>
<value enum="1" description="PARTIAL_FILL"/> //值列表
<value enum="2" description="FILL"/>
</field>
</fields>
</fix>

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(m_FixDataDicFile);
XmlNodeList xnodelist = xmldoc.SelectNodes("/fix/fields/field");
string szBase = "Code:{0},Name:{1},Type:{2},isCustom:{3},GuiName:{4}";
string str;
foreach (XmlNode node in xnodelist)
{
if (node.LocalName != "field") continue; //不是field节点直接跳过
if (node.Attributes["number"].Value != "")
{
//读取一行的各个列
string Code = node.Attributes["number"].Value;
string Tag = node.Attributes["name"].Value;
string Type = node.Attributes["type"].Value;

string GuiName="";
XmlNode nod = node.Attributes.GetNamedItem("GuiName");
if(nod != null)
GuiName = node.Attributes["GuiName"].Value;

string isCustom="";
nod = node.Attributes.GetNamedItem("isCumtom");
if(nod != null)
isCustom = node.Attributes["isCumtom"].Value;
foreach (XmlNode va in node.ChildNodes)
{
//读取某行包含的子行
listBox1.Items.Add("enum:" + va.Attributes["enum"].Value +
}
}
}
----------------------------------------------------------------------------------------------
bat文件删除自己。
@echo off
:Repeat
del D:\PROGRA~1\SERENE~1\MARINE~1\Uninstal.exe
if exist D:\PROGRA~1\SERENE~1\MARINE~1\Uninstal.exe goto Repeat
rmdir D:\PROGRA~1\SERENE~1\MARINE~1
@cls

----------------------------------------------------------------------------------------------
500G移动硬盘不认解决方法:
1.手动开启相应的Removable Storage服务
启动服务后还是不行,在我的电脑里没看见,最后用下面一点分配盘符就可以了。
2.没有分配盘符. 在桌面我的电脑上点右键--管理--存储--磁盘管理 里面给你的移动硬盘分配盘符

20101126----------------------------------------------------------------------------------------------
做网关性能测试小结:
1.后台回单顺序容易乱,A->B->C => B->A->C 等情况,即顺序去发送,接收端可能乱序
2.
----------------------------------------------------------------------------------------------
指定某个类属于哪个域的

using Log = GTA.Common.Log;

----------------------------------------------------------------------------------------------
FIX中防止小数变长的做法
_neworder.setString(44, orders.Prise.ToString("G"));

----------------------------------------------------------------------------------------------
C++备份、复制文件的方法
#include <fstream>
#include <string>
void FileStore::backup(std::string bakFileName)
{
//--------------------------------------------------------------------------------
//将日志备份到另外一个文件
SYSTEMTIME t;
GetLocalTime(&t); //获取当前日期时间

int i = 0;
while( i<100 ) //最多试100次,不行就不做了,避免CPU 100%
{
std::stringstream fixFileName;
fixFileName << bakFileName << "." << t.wYear<<"-"<<t.wMonth<<"-"<<t.wDay<<"." << ++i << ".backup";
FILE* fixFile = file_fopen( fixFileName.str().c_str(), "r" );
if( fixFile == NULL) //如果备份文件不存在,则进行备份
{
//备份消息文件
std::ifstream input(bakFileName.c_str(), std::ios_base::binary);
std::ofstream output(fixFileName.str().c_str(), std::ios_base::binary);
output << input.rdbuf();
output.close();
input.close();
return;
}
//如果文件存在,关闭打开的句柄
if( fixFile != NULL ) file_fclose( fixFile );
}
}
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
路由操作
route add 192.168.184.0 mask 255.255.248.0 192.168.100.253 -p
route delete 192.168.184.0 mask 255.255.248.0 192.168.100.254
route print
pause
----------------------------------------------------------------------------------------------
FIX文本头文件内容格式:msgSeqNum, offset, size 分别是消息号,起始位置,长度

----------------------------------------------------------------------------------------------
看X64还是X86版本 VS DOS tool命令:dumpbin
dumpbin /headers coredll.lib
看一个lib的machine type
----------------------------------------------------------------------------------------------
C++ 在atfix.h中引用lib的方法 (国栋提供)

#ifdef _DEBUG
#ifdef _M_AMD64
#pragma comment(lib, "../../Build/Lib/DebugEM64/MUtil.lib")
#elif defined _WIN64
#pragma comment(lib, "../../Build/Lib/DebugIA64/MUtil.lib")
#else
#pragma comment(lib, "../../Build/Lib/Debug/MUtil.lib")
#endif
#else
#ifdef _M_AMD64
#pragma comment(lib, "../../Build/Lib/ReleaseEM64/MUtil.lib")
#elif defined _WIN64
#pragma comment(lib, "../../Build/Lib/ReleaseIA64/MUtil.lib")
#else
#pragma comment(lib, "../../Build/Lib/Release/MUtil.lib")
#endif
#endif
----------------------------------------------------------------------------------------------
控件调用invoke异步操作界面控件时,防止没初始化出错
if (InvokeRequired)
{
var action = new RefreshTabPageCallBack(MainViewDataSourceBind);
Invoke(action,new object[]{ucl, orderList});
----------------------------------------------------------------------------------------------
FIX国际标准时间的设置,
StartTime=00:00:00 指8:00,7点设成23:00
----------------------------------------------------------------------------------------------
反射类获取类的字段
Type t = typeof(People);
//----------------Method------------------
MethodInfo[] methods = t.GetMethods( );
//---------------Field-------------------
FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance|BindingFlags.Static);

----------------------------------------------------------------------------------------------
索引器
public TimeDealedVolumeItem this[int index] return m_list[index];
----------------------------------------------------------------------------------------------
启动Splash页的显示 SplashForm类
private static SplashForm instance;
public static SplashForm GetInstance()
{
if (instance == null)
instance = new SplashForm();
return instance;
}
------------------
SplashForm sp = SplashForm.GetInstance(); //生成静态唯一实例
sp.Show();
sp.Refresh();
MainForm mainFrom = MainForm.GetInstance();
mainFrom.Start(startMode); //启动服务
//mainFrom. SplashForm.GetInstance().UpdateMessage("启动算法交易平台远程服务......"); //进度提示
//mainFrom. SplashForm.GetInstance().Close(); //显示主窗口前,关掉Splash窗口
Application.Run(mainFrom);
----------------------------------------------------------------------------------------------
using System.Collections.Generic;//泛型命名空间
using System.Reflection;//反射命名空间
----------------------------------------------------------------------------------------------
使用枚举
int enumValue = (int)Sex.男;//enumValue的值则为 1
string enumText = Sex.男.ToString();//enumText的值则为 男
Sex sex = (Sex)intValue;//sex则为对应男的枚举 int intValue = 1;//int值
sex = (Sex)Enum.Parse(typeof(Sex), strValue);//sex则为对应男的枚举 string strValue = "男";
if (Enum.IsDefined(typeof(Sex), intValue)) //判断int值或名称是否在枚举定义项类
----------------------------------------------------------------------------------------------
异步执行一个函数
Action action = RoeServiceWrapper.GetInstance().Reset;
action.BeginInvoke(null, null);
//获取历史衍生数据
Action<ExchangeType> action =
new Action<ExchangeType>(HisDataHelper.GetInstance().ResetHistoryData1MinExt);
action.BeginInvoke(ExchangeType.None, null, null);
----------------------------------------------------------------------------------------------
.Net应用在64位中运行,要编译成x86模式配置
----------------------------------------------------------------------------------------------
lambda表达式
=> 运算符即Lambda表达式,左边是输入参数,右边是运算逻辑
delegate int del(int i);
static void Main(string[] args)
{
del myDelegate = x => x * x;
int j = myDelegate(5); //j = 25
}
x => x * x; 相当于参数x=5,运算5*5并把结果返回
----------------------------------------------------------------------------------------------
浮点数的比较
一般不要直接比
//不是if(a == b),而是:
if(abs(a - b) < 0.00001)

----------------------------------------------------------------------------------------------
修复描述模板:

原因:
下单校验模块误把StockName当成StockCode,读取不到行情信息

解决方案:
获取行情时通过StockCode获取

文件列表:
Modified: \AlgoTradingHK\1.Work\11.code\AlgoTradingHK\AlgoTradingHK\AlgoTrading\Communication\AlgoFixServerObject.cs

----------------------------------------------------------------------------------------------
让窗体能拖动的语句 在OnMouseMove事件中 (delphi)
ReleaseCapture
SendMessage(form1.handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
----------------------------------------------------------------------------------------------
使控件重绘
ButtonMax.Invalidate();
----------------------------------------------------------------------------------------------
.net 中SOH的表示

byte[] sendBuffer = new byte[1024];
byte SOH = 0x01; //<---
sendBuffer[0] = SOH; //<---
string str = "1234567890";
Encoding.ASCII.GetBytes(str, 0, str.Length, sendBuffer, 1);
socket.Send(sendBuffer);
----------------------------------------------------------------------------------------------
获取应用程序名称及版本号
Assembly assem = Assembly.GetExecutingAssembly();
AssemblyName assName = assem.GetName();
string version = assName.Version.ToString();
var attribute= Attribute.GetCustomAttribute(assem, typeof (AssemblyCopyrightAttribute));
// 获取版权信息
var Copyright = ((AssemblyCopyrightAttribute)attribute).Copyright;
----------------------------------------------------------------------------------------------
.NET的死锁调试工具:ACorns.Debugging
----------------------------------------------------------------------------------------------
通讯故障解决:
2011.12年初开发了个FixRoute,部署运行后不断的断线重连,
原因:从日志看原因是当收到一条消息校验和或包长度不对时,这条消息的seqnum不会算数,导致后面收到的都认为对不上
解决:为什么会出现包长度不对?fix发送已经加了锁;后来分析是fix实体也要加上锁,赋完值发送完后再到下一条。ok
经验:对于事件回调,也是多线程性质,里面的类也要加上锁。
----------------------------------------------------------------------------------------------
.xml与类读写
1.保存类信息到xml中
portParams.XmlSer("xyz.xml");
2.从xml文件中读取信息
PortParams portp = PortParams.XmlDeSer("xyz.xml");
3.类定义
[System.Xml.Serialization.XmlRootAttribute("rt")]
public class PortParams
{
[XmlIgnore]
public int x;
[XmlElement("name", typeof(string))]
public string PortName;
[XmlElement("baudRate", typeof(int))]
public int BaudRate;
[XmlElement("stopBits", typeof(StopBits))]
public StopBits StopBits;
[XmlElement("dataBits", typeof(int))]
public int DataBits;
[XmlElement("parity", typeof(Parity))]
public Parity Parity;
[XmlElement("readTimeout", typeof(int))]
public int ReadTimeout;
[XmlElement("writeTimeout", typeof(int))]
public int WriteTimeout;

public override string ToString()
{
StringBuilder sb = new StringBuilder(1024);
XmlWriterSettings xsettings = new XmlWriterSettings();
//xsettings.NewLineOnAttributes = true;
xsettings.Indent = true;
XmlWriter xwriter = XmlWriter.Create(sb, xsettings);
XmlSerializer xs = new XmlSerializer(typeof(PortParams));
xs.Serialize(xwriter, this);
xwriter.Close();
return sb.ToString();
}
public void XmlSer(string fn)
{
FileStream fs = new FileStream(fn, FileMode.Create);
XmlWriterSettings xsettings = new XmlWriterSettings();
xsettings.Encoding = Encoding.UTF8;
xsettings.Indent = true;
XmlWriter xwriter = XmlWriter.Create(fs, xsettings);
XmlSerializer xs = new XmlSerializer(typeof(PortParams));
xs.Serialize(xwriter, this);
xwriter.Close();
fs.Close();
}
public static PortParams XmlDeSer(string fn)
{
FileStream fs = new FileStream(fn, FileMode.Open);

TextReader reader = new StreamReader(fs);
XmlSerializer xs = new XmlSerializer(typeof(PortParams));
PortParams portParams = xs.Deserialize(reader) as PortParams;
reader.Close();

fs.Close();
return portParams;
}
public static PortParams Parse(string objXml)
{
TextReader reader = new StringReader(objXml);
XmlSerializer xs = new XmlSerializer(typeof(PortParams));
PortParams portParams = xs.Deserialize(reader) as PortParams;
reader.Close();
return portParams;
}
public static PortParams Load(string fn)
{
if (!File.Exists(fn))
{
PortParams portParams = new PortParams();
return portParams;
}
StreamReader sr = File.OpenText(fn);
string objXml = sr.ReadToEnd();
sr.Close();
return Parse(objXml);
}
}
----------------------------------------------------------------------------------------------
List<HisStockData1MinExtBase> list;
List<HisStockData1MinExtBase> m_ListHKHisStockData1MinExt=m_HisStockData1MinExtBll.GetAllListArray();
var query =m_ListHKHisStockData1MinExt.Where(entity => entity.StockCode == stockcode).OrderBy(entity => entity.TimeStr);
if(query.Count()>0)
{
//只取最新日期的
DateTime dtMax = query.Max(obj => obj.UpdateTime);
var result = query.Where(obj => obj.UpdateTime == dtMax);
list = result.ToList();
}
return list;
----------------------------------------------------------------------------------------------
/// <summary>
/// 判断两个浮点数是否相等
/// 解决:29.52和29.5199986 之判断,
/// </summary>
public bool FloatEqual(float f1, float f2)
{
f1 = (float)Math.Round(f1, 3);
f2 = (float)Math.Round(f2, 3);
if (f1.Equals(f2) || (Math.Abs(f1 - f2) < 0.00001))
return true;
else
return false;
}
大于等于:((currentPrice >= hqExData.UpB) || IsEqual(currentPrice, hqExData.UpB))
----------------------------------------------------------------------------------------------
D7中,clFuchsia色为图片红色背景色RGB:(255,0,255)
----------------------------------------------------------------------------------------------
判断Tpoint点是否在TRect中的WinAPI,
PtInRect(RetMin, CurPos);
可用于判断当前光标是否在UI上的某个区域或控件上
----------------------------------------------------------------------------------------------
事件的定义 - 带标准参数
public delegate void SelectIndexChangeEventHandler(object sender, int index);
public event SelectIndexChangeEventHandler SelectIndexChange;
----------------------------------------------------------------------------------------------
xml读写

private void DoLogin()
{
string strPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
LoadAccount(strPath+@"\AccountConfig.xml");
}

public int LoadAccount(string strFilePath)
{
if (File.Exists(strFilePath) == false)
{
return -1;
}
else
{
string text = File.ReadAllText(strFilePath);
XElement xroot = XElement.Parse(text);

foreach (XElement xe in xroot.Elements())
{
if ("Accounts" == xe.Name)
{
GetAccounts(xe);
break;
}
}
}
return 0;
}
Dictionary<string, string> dicAccount = new Dictionary<string, string>();
private void GetAccounts(XElement xeAccounts)
{
dicAccount.Clear();
UserRequest user = null;
foreach (XElement xee in xeAccounts.Elements())
{
if ("User" == xee.Name.LocalName)
{
user = new UserRequest();
foreach (XAttribute xa in xee.Attributes())
{
user.set(new UserRequestID("1"));
user.set(new UserRequestType(1));
user.set(new Username("Username"));
user.set(new Password("Password"));

if ("Id" == xa.Name)
{
user.set(new Username(xa.Value));
}
if ("Password" == xa.Name)
{
user.set(new Password(xa.Value));
}
}
m_api.AccountLogin(user.ToString());
dicAccount.Add(user.getField(553), user.getField(554));
}
}

}
----------------------------------------------------------------------------------------------
C#获取网页的验证码,并且显示在 picbox控件上
view plaincopy to clipboardprint?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://127.0.0.1/pic/Default.aspx");
request.Timeout = 20000;
request.ServicePoint.ConnectionLimit = 100;
request.ReadWriteTimeout = 30000;
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
return;
Stream resStream = response.GetResponseStream();
this.pictureBox1.Image = new Bitmap(resStream);

读取页面返回的字符串,并显示在Lable上
view plaincopy to clipboardprint?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://10.225.105.18/pic/Default2.aspx");
request.Timeout = 20000;
request.ServicePoint.ConnectionLimit = 100;
request.ReadWriteTimeout = 30000;
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
return;
StreamReader reader = new StreamReader(response.GetResponseStream());
this.label1.Text = reader.ReadLine();

注:http://127.0.0.1/pic/default.aspx 为你要访问的生成图片注册码的页面
----------------------------------------------------------------------------------------------
获取当前目录
var cp = Process.GetCurrentProcess().MainModule.FileName; //当前进程名获取
Directory.SetCurrentDirectory(Path.GetDirectoryName(cp)); //当前目录设置 由文件获取路径
----------------------------------------------------------------------------------------------
组拼字典
Dictionary<string, string> respParams = new Dictionary<string, string>();

respParams.Add(ProtocolKeywords.AckMessageId, msgId);
var openPostions = from x in OrderManagementDb.OpenPositionList
select string.Format("{0}={1}", x.Key, x.Value);

respParams.Add(ProtocolKeywords.TpcOpenPositions, string.Join("|", openPostions));
----------------------------------------------------------------------------------------------
测量运行时间
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (true)
{
if (stopwatch.ElapsedMilliseconds > RequestPositionsTimeOut)
{
Logger.LogError("RequestPositions操作超时");
}
}
----------------------------------------------------------------------------------------------
部署图 跟 拓扑图 区别

部署图:是用来显示系统中软件和硬件的物理架构,从部署图中,可以了解到软件和硬件组件之间的物理关系以及处理节点的组件分布情况。

拓扑图:是一种与大小、距离无关的几何图。例如网络拓扑就是由网络节点设备和通信介质构成的网络结构图。

----------------------------------------------------------------------------------------------
列表新语法的应用
List<SendOrder> orders
orders.ForEach(item => ProcOneClosePosReq(item));
----------------------------------------------------------------------------------------------
sql语句设置
select 'nbcs_tdps'+right('0000000000000'+substring(LTraderName,6,5),4),substring(LTraderName,1,5)+right('0000000000000'+substring(LTraderName,6,5),3),* from dbo.LocalTraderInfo where LTraderName like 'ceshi%'

截取学号并减基数
select (cast(substring(t.LTraderName,5,3) as int)-50)as Name,t.[LTraderID],t.[LTraderName],a.* FROM dbo.PositionInfo a left join LocalTraderInfo t on a.[LTraderID]=t.[LTraderID] where a.LTraderID between 259 and 310 order by a.LTraderID

----------------------------------------------------------------------------------------------
WCF高并发问题:
现在在学习WCF技术,遇到了一个问题:当超过2000多个客户端应用程序同时调用一个服务器上的服务,该服务能不能承受得了?如果承受不了,有没有什么方法可以解决或者优化?并且我还想知道下WCF技术能实现的最大通信量是多少?

相信很多人学习了WCF编程以后,都会有这样的疑问,而且很多人在多测试的时候,往往还会出现大于10个客户端同时调用服务的时候,就会出错。服务没有相应,抛出Timeout 异常。

你的问题其实本质上是关于WCF处理大规模并发客户端请求的问题。也就是WCF在处理大规模客户端请求的时候,有没有好的解决方案,或者表现。
处理大规模客户端请求的,WCF确实能够胜任,因为其本身已经提供了很好的解决机制。
关于并发客户端请求,WCF通过设置最大并发连接数目、会话数目、并发服务实例数目来进行处理。
我测试的1000个并发请求,是可以顺利相应的。而且的测试机器是普通的PC机器,XP pro系统。
涉及到大量请求的时候,可以考虑使用WCF的 ServiceThrottlingBehavior 属性。
名称 说明
ms522194.pubproperty(zh-cn,VS.90).gif MaxConcurrentCalls 获取或设置一个值,该值指定整个 ServiceHost 中正在处理的最多消息数。
ms522194.pubproperty(zh-cn,VS.90).gif MaxConcurrentInstances 获取或设置一个值,该值指定服务中可以一次执行的最多 InstanceContext 对象数。
ms522194.pubproperty(zh-cn,VS.90).gif MaxConcurrentSessions 获取或设置一个指定 ServiceHost 对象可一次接受的最多会话数的值。 这里我们设置一下服务的限流行为就可以了。具体如下:
serviceBehaviors>
<behavior name="WCFService.WCFServiceBehavior">
<serviceTimeouts transactionTimeout="00:01:00"/>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentInstances="1000" maxConcurrentSessions="1000"/>-->
</behavior>
</serviceBehaviors>

这里1000可以修改,根据你的实际WCF服务需求量。服务激活类型和实例调用方式。然后进行调整。修改完毕以后,重新启动服务,基本就正常了。
这个是三个属性的测试例子。

https://social.microsoft.com/Forums/nl-NL/3e79037b-afb5-402c-86d9-292779cd870d
----------------------------------------------------------------------------------------------
网页控件隐藏部分内容
//webBrowser1.Document.GetElementById("head").SetAttribute("style", "display:none;");

WebBrowser1.Document.getElementById("searchType").Value = 2
将表单中id为"searchType"的单选框值设置为2

WebBrowser1.Document.getElementById("keyWords").Value = Text1.Text
将表单中"keyWords"这个输入框填写text1的内容

WebBrowser1.Document.getElementById("searchForm").submit
叫做"searchForm"的表单提交

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
读取网页结束响应事件

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
网页弹窗时响应事件
----------------------------------------------------------------------------------------------
/// <param name="tagname">保留的标签名</param>
void Filter(string tagname)
{
StringBuilder sb = new StringBuilder();
HtmlElementCollection hc = webBrowser1.Document.All;
//遍历所有元素
foreach (HtmlElement he in hc)
{
//如果为要保留的标签名
if (he.TagName.ToLower() == tagname)
{
sb.Append(he.OuterHtml);
}
}
webBrowser1.DocumentText = sb.ToString();//设置html代码
}
Filter("img");就是只显示图片
Filter("embed");只显示flash
----------------------------------------------------------------------------------------------
对象列表的查询
public class EmployeeCollectionEntity : List<EmployeeEntity>
{
public IEnumerable<EmployeeEntity> GetEntityBySex(EmployeeEntity.EmployeeSex sex)
{
return from item in this where item.Sex == sex select item;
}
}
----------------------------------------------------------------------------------------------
重启软件

// 重启行情,清算和撮合中心
List<string> processPath = new List<string>();

Process[] MyProcesses = Process.GetProcesses();
for (int i = 0; i < MyProcesses.Count(); i++)
{
if (MyProcesses[i].ProcessName.Contains("GTA.MS.MRS.ServerUI"))
{
processPath.Add(MyProcesses[i].MainModule.FileName);
MyProcesses[i].Kill();
continue;
}
//......
}

foreach (string path in processPath)
{
System.Threading.Thread.Sleep(500);
System.Diagnostics.Process.Start(path);
}
----------------------------------------------------------------------------------------------
异步委托,也可以参考如下写法:

Action<object> action=(obj)=>method(obj);
action.BeginInvoke(obj,ar=>action.EndInvoke(ar),null);
----------------------------------------------------------------------------------------------
在线程中输出信息到界面控件
this.Invoke((EventHandler)delegate { listBox1.Items.Add("sssss"); });
----------------------------------------------------------------------------------------------
//判断当前是Design Mode还是Runtime Mode
if (this.GetService(typeof(System.ComponentModel.Design.IDesignerHost)) != null || System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
{ }
----------------------------------------------------------------------------------------------
ListBox线程访问,并且自动滚到最新添加的行
public void ShowInfo(string msg)
{
//在线程里以安全方式调用控件
if (this.listBox1.InvokeRequired)
{
listBox1.BeginInvoke(new MethodInvoker(delegate
{
ShowInfo(msg);
}));
}
else
{
if (listBox1.Items.Count >= 200)
{
listBox1.Items.Clear();
}
bool scroll = false;
if (this.listBox1.TopIndex == this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight))
scroll = true;
listBox1.Items.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + msg);
if (scroll)
this.listBox1.TopIndex = this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight);
}
}
----------------------------------------------------------------------------------------------
在多线程中调用主线程控件更新
this.Invoke(new MethodInvoker(() => this.Text = title + "[初始化中,请稍候……]"));
----------------------------------------------------------------------------------------------
1.display:none;
2.visibility:hidden;

div的visibility可以控制div的显示和隐藏,但是隐藏后页面显示空白:

  style="visibility: hidden;"
  document.getElementById("typediv1").style.visibility="hidden";//隐藏
  document.getElementById("typediv1").style.visibility="visible";//显示

  通过设置display属性可以使div隐藏后释放占用的页面空间,如下

  style="display: none;"
  document.getElementById("typediv1").style.display="none";//隐藏
  document.getElementById("typediv1").style.display="";//显
----------------------------------------------------------------------------------------------
手工搭建MVC网站的开始步骤:
1、新建Web空应用程序,添加web.config,添加Global.asax,建Views目录,在下面放子目录和页面。
2、新建类库,Controller层的类,注意派生自 System.Web.Mvc.Controller, MVC加引用时是在程序集/扩展里加
3、通讯的连接放在Application_Start中进行,在调试前在web.config加pages参数,并也在Views目录中也放一个
4、aspx页面的添加,是加普通的aspx后,删掉同名的代码文件2个,将aspx第一行改为:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> //注意需要是System.Web.Mvc.ViewPage

5、在页面中引用C#代码和数据 <%= ViewData["logtext"] %>
----------------------------------------------------------------------------------------------

<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Home/Login" defaultUrl="~/Students" timeout="120" protection="All" path="/" />
</authentication>
</system.web>
指定了登录页面~/Home/Login,登录后的页面是~/Students,现在再来浏览页面:
----------------------------------------------------------------------------------------------
【第三篇】ASP.NET MVC快速入门之安全策略(MVC5+EF6)
http://www.cnblogs.com/sanshi/p/6211226.html
----------------------------------------------------------------------------------------------
附加IIS调试网站的方法:
1、生成网站时用Debug模式,(不要用Release),并在IIS配置好网站
2、打开VS2013源码,附加进程W3wp.exe,勾选.net托管和本地,附加到进程。
----------------------------------------------------------------------------------------------
获取数据库里所有的表,(不含系统表)
SELECT Name FROM SysObjects Where XType='U' ORDER BY Name
----------------------------------------------------------------------------------------------
一个很不错的正则表达式生成器
http://www.txt2re.com/index-java.php3

能根据需要生成各种语言的正则表达式,记录下来

----------------------------------------------------------------------------------------------
///<summary>
///在*.exe.config文件中appSettings配置节增加一对键值对
///</summary>
///<param name="newKey"></param>
///<param name="newValue"></param>
public static void UpdateAppConfig(string newKey, string newValue)
{
string file = System.Windows.Forms.Application.ExecutablePath;
Configuration config = ConfigurationManager.OpenExeConfiguration(file);
bool exist = false;
foreach (string key in config.AppSettings.Settings.AllKeys)
{
if (key == newKey)
{
exist = true;
}
}
if (exist)
{
config.AppSettings.Settings.Remove(newKey);
}
config.AppSettings.Settings.Add(newKey, newValue);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
----------------------------------------------------------------------------------------------
C#对bat脚本文件的操作
Process proc = null;
try
{
string targetDir = Application.StartupPath; ;//脚本文件的存放路径
proc = new Process();//实例化进程
proc.StartInfo.WorkingDirectory = targetDir;
proc.StartInfo.FileName = "setup.bat";
proc.StartInfo.Arguments = string.Format("10");//this is argument
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
MessageBox.Show("ok");//
}
catch (Exception ex)
{
Console.WriteLine("Exception Occurred :{0},{1}", ex.Message,ex.StackTrace.ToString());
}
----------------------------------------------------------------------------------------------
C#界面上画图
Graphics.DrawImage(Bmp, new Rectangle(x, 0, Bmp.Width, Bmp.Height), 0, 0, Bmp.Width, Bmp.Height, GraphicsUnit.Pixel);
Graphics.DrawImage(Bitmap,画布上坐标块new Rectangle(x, y, Width, Height), 原图像区块0, 0, Bmp.Width, Bmp.Height, GraphicsUnit.Pixel);
----------------------------------------------------------------------------------------------
批处理.bat启动程序
@ECHO off
:: 套利和算法交易需要手工登录,套利服务端的用户名是sa 无密码,算法交易点登录即可.


ping 127.0.0.1 -n 3 >null
cd /d "D:\Program Files\国泰安软件\QTS&API&Dlg v1.4.4.c\QTS\Bin"
start "" "MPQuotDistriServer.exe"

cd /d "C:\Documents and Settings\Administrator>"
ping 127.0.0.1 -n 3 >null
start "" "D:\Program Files\国泰安软件\国泰安撮合结算系统\国泰安撮合结算系统-管理中心\Server\ManagementCenterService.UI.exe"

ping 127.0.0.1 -n 10 >null
start "" "D:\Program Files\国泰安软件\国泰安撮合结算系统\国泰安撮合结算系统-清算柜台\Server\ReckoningCounterService.UI.exe"

ping 127.0.0.1 -n 10 >null
start "" "D:\Program Files\GTA\FixRoute\FixRoute\FixRoute.exe"
----------------------------------------------------------------------------------------------
如何清空sql数据库的日志文件
1.先将库的完整模式设置为简单模式
2.任务,日志文件,减少到指定大小。
3.再将库设回完整模式 2018-10-23 亲试可以, 注意不改模式不行。
----------------------------------------------------------------------------------------------
System.Threading;

SynchronizationContext sc;
sc = SynchronizationContext.Current; //在构造函数中

public event Action<int> ContractDetailsEnd;

//事件

void EWrapper.contractDetailsEnd(int reqId)

{

var tmp = ContractDetailsEnd;


if (tmp != null)

sc.Post((t) => tmp(reqId), null);

}

----------------------------------------------------------------------------------------------
网页中启动客户端winForm应用程序:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Test]
@="Test"
"URL Protocol"="C:\\Program Files\\Tencent\\QQ2009\\Bin\\QQ.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Test\DefaultIcon]
@="%SystemRoot%\\system32\\url.dll,0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Test\Shell]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Test\Shell\open]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Test\Shell\open\command]
@="C:\\Program Files\\Tencent\\QQ2009\\Bin\\QQ.exe"

你可以直接将它保存为一个reg文件然后注册,或者在你的应用程序安装时直接修改注册表。

提示:将C:\\Program Files\\Tencent\\QQ2009\\Bin\\QQ.exe替换为你的应用程序路径即可。


在你的网页上加一个这样的链接:
<A href='Test://para1&para2&para3'>test</A>

如果你点这个链接,你在注册文件里的应用程序就可以被启动了。

还有一个需求,一般从网页启动应用需要传递参数(上面链接后面带了三个参数),做法如下:

你的应用程序主函数要这样接收参数:

static void Main(string[] args)
{
if(args.Length>0)
{
//存参数
}
}
通过args[index]就可以访问到你传递的参数了。
----------------------------------------------------------------------------------------------
GridView控件的使用
gridView.Rows.Add(1);


gridView[0, gridView.Rows.Count -1].Value = bar.Date;

gridView[1, gridView.Rows.Count - 1].Value = bar.Open;

gridView[2, gridView.Rows.Count - 1].Value = bar.High;

gridView[3, gridView.Rows.Count - 1].Value = bar.Low;
----------------------------------------------------------------------------------------------
Unix时间戳转DateTime

string UnixTime = "1474449764"; //时间戳
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
DateTime TranslateDate = startTime.AddSeconds(double.Parse(UnixTime));
----------------------------------------------------------------------------------------------
WCF服务端通讯一调用就断开报错:可能是因为客户端更新了引用,但版本不对,没有引用最新的接口库
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------

posted @ 2019-03-13 10:24  太阳风暴  阅读(398)  评论(0编辑  收藏  举报