posts - 101,  comments - 14,  trackbacks - 0
     摘要:   private void MQRecieve()   //MQ接收函数        {            try     &nbs...  阅读全文
posted @ 2010-02-08 09:04 天书 阅读(19) | 评论 (0)编辑 收藏

using System.Text.RegularExpressions;

 private bool isContainCh(string s)
        
{
            Regex r4 
= new Regex(@"^[\u4e00-\u9fa5]+$");
            
int len = s.Length;
            
for (int i = 0; i < len - 1; i++)
            
{
                
string str = s.Substring(i, 1);
                
if (r4.IsMatch(str))
                
{
                    
return true;
                    
                }

            }

            
return false;
        }
posted @ 2010-01-12 09:29 天书 阅读(11) | 评论 (0)编辑 收藏
首先:服务端要发四个字节过来,代表接下来他发了多少数据过来,然后每次客户端就读这个长度的数据即可。这样收发就同步了哈哈!
然后:客户端就按照这个长度来读服务端一次发过来的信息。


还要解决一个问题就是 socket接收信息由字节转换成整型:
 Byte[] RecNum = new byte[4];
                        int iRevNum = netstream.Read(RecNum, 0, RecNum.Length);//读取客户发送来的字节信息。
                        int i = BitConverter.ToInt32(RecNum, 0);
                        i = System.Net.IPAddress.NetworkToHostOrder(i);


接下来就按i这么大来读信息就能同步了。具体代码见下:(网元监控中使用)

private void Read()
        {
            try
            {
                Byte[] Recp = new byte[1024];
                if (ClientSocket == null)
                {
                    return;
                }
                NetworkStream netstream = new NetworkStream(ClientSocket);
                int iRevp = netstream.Read(Recp, 0, Recp.Length);//读取客户发送来的信息。
                string strRevp = System.Text.Encoding.GetEncoding("gb2312").GetString(Recp, 0, iRevp);
                if (strRevp.IndexOf("请输入指令") != -1)
                {
                    string sendMsg = "";
                    if (curPort.Equals("ALL"))
                    {
                        sendMsg = "track " + curNet.NeENName + "\r\n";
                    }
                    else
                    {
                        sendMsg = "track " + curNet.NeENName + "#" + curPort + "\r\n";
                    }
                    DispatchMessage(sendMsg);
                }
                while (true)
                {
                    try
                    {
                        Byte[] RecNum = new byte[4];
                        int iRevNum = netstream.Read(RecNum, 0, RecNum.Length);//读取客户发送来的字节信息。
                        int i = BitConverter.ToInt32(RecNum, 0);
                        i = System.Net.IPAddress.NetworkToHostOrder(i);

                        Byte[] Rec = new byte[i];
                        int iRev = netstream.Read(Rec, 0, Rec.Length);//读取客户发送来的信息。
                        string strRev = System.Text.Encoding.GetEncoding("gb2312").GetString(Rec, 0, iRev);

                        strRev = strRev.Replace("\0", "");
                        ProcessReceiveData(strRev);
                    }
                    catch (Exception ex)
                    {
                        ;
                    }
                    Thread.Sleep(1000);
                }

            }
            catch (Exception ex)
            {
                ;
            }
        }
posted @ 2010-01-07 11:34 天书 阅读(25) | 评论 (0)编辑 收藏

跨线程时 一定要用System.Timer,而不要用System.windows.Forms.Timer.

Timer 控件到点时,一定要先stop然后做其他工作,最后再messageBox.show() ;否则messageBox.show() 将线程阻塞在那块等待用户操作了,要是用户不在没有操作,则不能stop()

posted @ 2010-01-07 10:04 天书 阅读(15) | 评论 (0)编辑 收藏

1:网线或者网络的事,比如IP被占用,网线不好用。

查找方法: ping一下网关。

2:接收数据中有"\0",把后面数据截断了。

解决办法: string.replace("\0","")

posted @ 2010-01-07 10:03 天书 阅读(21) | 评论 (0)编辑 收藏
colorFont.myFont.fontStyle  :int 类型(存在数据库中读出来的)
FontStyle fs = (FontStyle)colorFont.myFont.fontStyle;
            Font ft = new Font(colorFont.myFont.fontName, colorFont.myFont.fontSize,fs);
int ifontStyle = (int)ft.fontStyle;
posted @ 2009-11-09 20:09 天书 阅读(17) | 评论 (0)编辑 收藏
1:添加—新建项目—其它项目类型—安装和部署—安装项目
2:在视图—文件系统中,按照源程序bin目录下的结构,构建文件夹及文件(文件夹中套n多文件夹的可以同时开着两个,拖进去,不用一层一层建太麻烦了)
3:属性-系统必备里-.NETFrameWork2.0打上对勾
4:视图—文件系统—用户桌面添加上快捷方式,右键添加,同时属性中的alwayscreate 设为true
5:这样打包好后系统就自动提炼DotNetFrameWork放入到CMTSetup\Debug下面的自动创建的文件夹dotnetfx下面了。
posted @ 2009-09-24 17:07 天书 阅读(64) | 评论 (0)编辑 收藏
1:把(tuxedo安装目录)D:\Program Files\tuxedo10.0_VS2005\bin 下面的DLL都考到应用程序所在目录,即CMT.exe  所在的同一目录,同时把D:\Program Files\tuxedo10.0_VS2005下面的locale和udataobj目录也考到应用程序所在目录。
2:  string nlsPath = Application.StartupPath + "\\locale\\C";
            string curPath = Application.StartupPath;
            Bea.Tuxedo.ATMI.Utils.tuxputenv("NLSPATH=" + nlsPath);
            Bea.Tuxedo.ATMI.Utils.tuxputenv("TUXDIR=" + curPath);
            Bea.Tuxedo.ATMI.Utils.tuxputenv("APPDIR=" + curPath);
            Bea.Tuxedo.ATMI.Utils.tuxputenv("WSNADDR=//10.5.0.3:9300");   (这个最好读配置文件因为它不是固定的)
posted @ 2009-09-24 14:38 天书 阅读(31) | 评论 (0)编辑 收藏
仅列出标题  下一页

<2010年2月>
31123456
78910111213
14151617181920
21222324252627
28123456
78910111213

常用链接

留言簿(1)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜

60天内阅读排行