• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 124,  comments - 29,  trackbacks - 0

            //注意在工程上添加系統引用System.Drawing 否則System點不出Drawing來。

            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Text;
            using System.Windows.Forms;
            using DevComponents.DotNetBar;

            namespace TaskBarFloatWnd
            {
                public partial class Form1 : Office2007Form
                {
                    public Form1()
                    {
                        InitializeComponent();
                       
                    }

                  

                    private void button1_Click(object sender, EventArgs e)
                    {

                        TaskBarWnd taskWnd = new TaskBarWnd();
                        System.Drawing.Rectangle r = System.Windows.Forms.Screen.GetWorkingArea(taskWnd);
                        taskWnd.Location = new System.Drawing.Point(r.Right - taskWnd.Width, r.Bottom - taskWnd.Height);
                        taskWnd.Show();
                    }
                }
            }



            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Text;
            using System.Windows.Forms;
            using DevComponents.DotNetBar;

            namespace TaskBarFloatWnd
            {
                
            public partial class TaskBarWnd : Office2007Form
                
            {
                    
            public TaskBarWnd()
                    
            {
                        InitializeComponent();
                        actform 
            = GetActiveWindow();
                    }

                    
            private bool isFristShow = true;//標識是否是首次加載
                    [System.Runtime.InteropServices.DllImport("user32.dll")]
                    
            public static extern IntPtr GetActiveWindow();//獲得當前活動窗體
                    [System.Runtime.InteropServices.DllImport("user32.dll")]
                    
            public static extern IntPtr SetActiveWindow(IntPtr hwnd);//設置活動窗體

                    
            private IntPtr actform = IntPtr.Zero;//保存自己得到焦點前擁有活動窗體的柄
                    private void TaskBarWnd_Load(object sender, EventArgs e)
                    
            {
                        textBox1.Text 
            = DateTime.Now + "——";
                        textBox1.Text 
            = textBox1.Text + "目前正對網元1進行做單操作,10分鐘內請大家避讓";

                    }

                    
            protected override void OnActivated(EventArgs e)
                    
            {
                        
            base.OnActivated(e);
                        
            if (isFristShow == true)
                        
            {
                            SetActiveWindow(actform);
                            isFristShow 
            = false;
                        }

                    }


                   

                    
            private void TaskBarWnd_FormClosing(object sender, FormClosingEventArgs e)
                    
            {
                        
                    }

                }

            }
            posted @ 2010-02-26 16:14 天書 閱讀(2876) | 評論 (1)編輯 收藏

             

            using System;
            using System.Collections.Generic;
            using System.Text;
            using System.Threading;
            using System.Net.Sockets;
            using System.Net;

            namespace SocketConnTimeOut
            {
                
            class TimeOutSocket
                
            {
                    
            private static bool IsConnectionSuccessful = false;
                    
            private static Exception socketexception;
                    
            private static ManualResetEvent TimeoutObject = new ManualResetEvent(false);

                    
            public static TcpClient Connect(IPEndPoint remoteEndPoint, int timeoutMSec)
                    
            {
                        TimeoutObject.Reset();
                        socketexception 
            = null;

                        
            string serverip = Convert.ToString(remoteEndPoint.Address);
                        
            int serverport = remoteEndPoint.Port;
                        TcpClient tcpclient 
            = new TcpClient();

                        tcpclient.BeginConnect(serverip, serverport, 
            new AsyncCallback(CallBackMethod), tcpclient);

                        
            if (TimeoutObject.WaitOne(timeoutMSec, false))
                        
            {
                            
            if (IsConnectionSuccessful)
                            
            {

                                
            return tcpclient;
                            }

                            
            else
                            
            {
                                
            throw socketexception;
                            }

                        }

                        
            else
                        
            {
                            tcpclient.Close();
                            
            throw new TimeoutException("TimeOut Exception");
                        }

                    }

                    
            private static void CallBackMethod(IAsyncResult asyncresult)
                    
            {
                        
            try
                        
            {
                            IsConnectionSuccessful 
            = false;
                            TcpClient tcpclient 
            = asyncresult.AsyncState as TcpClient;

                            
            if (tcpclient.Client != null)
                            
            {
                                tcpclient.EndConnect(asyncresult);
                                IsConnectionSuccessful 
            = true;
                            }

                        }

                        
            catch (Exception ex)
                        
            {
                            IsConnectionSuccessful 
            = false;
                            socketexception 
            = ex;
                        }

                        
            finally
                        
            {
                            TimeoutObject.Set();
                        }

                    }


                }

            }



            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Text;
            using System.Net.Sockets;
            using System.Net;
            using System.Threading;
            using System.IO;

            using System.Windows.Forms;

            namespace SocketConnTimeOut
            {
                public partial class Form1 : Form
                {
                    public Form1()
                    {
                        InitializeComponent();
                    }

                    private void label2_Click(object sender, EventArgs e)
                    {

                    }
                    string strIP = "";
                    int strPort = 8000;
                    int timeout = 1000;
                    private void btnConn_Click(object sender, EventArgs e)
                    {
                        try
                        {
                            strIP = txtIP.Text;
                            strPort = Convert.ToInt32(txtPort.Text);

                            IPAddress localAddr = IPAddress.Parse(strIP);
                            IPEndPoint remoteEndPoint = new IPEndPoint(localAddr, strPort);
                            TcpClient NetworkClient = TimeOutSocket.Connect(remoteEndPoint, timeout);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("連接失敗");
                        }
                    }
                }
            }

            posted @ 2010-02-25 14:57 天書 閱讀(5707) | 評論 (1)編輯 收藏

            using System;
            using System.Collections.Generic;
            using System.ComponentModel;
            using System.Data;
            using System.Drawing;
            using System.Text;
            using System.Windows.Forms;
            using System.Net;
            using System.Net.NetworkInformation;

            namespace PingIpAddress
            {
                public partial class Form1 : Form
                {
                    public Form1()
                    {
                        InitializeComponent();
                    }
                  
                    private void Form1_Load(object sender, EventArgs e)
                    {
                       
                       
                    }
                    private Ping pingSender = new Ping();
                    private string strIP = "";
                    private void button1_Click(object sender, EventArgs e)
                    {
                        strIP = txtIP.Text;
                        PingOptions pingOption = new PingOptions();
                        pingOption.DontFragment = true;

                        string data = "sendData:goodgoodgoodgoodgoodgood";
                        byte[] buffer = Encoding.ASCII.GetBytes(data);
                        int timeout = 120;
                        PingReply reply = pingSender.Send(strIP, timeout, buffer);
                        if (reply.Status == IPStatus.Success)
                        {
                            MessageBox.Show("能ping通 ");
                        }
                        else
                        {
                            MessageBox.Show("ping不通");
                        }
                    }
                }
            }

            using System;
            using System.Collections.Generic;
            using System.Windows.Forms;
            using System.Net;
            using System.Net.Sockets;
            using System.Threading;
            using System.Text;
            using OSSDOM.CMT.ConfigData;
            using System.Net;
            using System.Net.NetworkInformation;

            namespace OSSDOM.CMT.CommonUse
            {
                
            public class PingServer
                
            {
                    
                    
            private IPEndPoint EPServer = null;
                    
            public PingServer()
                    
            {
                        
            try
                        
            {
                            EPServer 
            = new IPEndPoint(IPAddress.Parse(MakeOptionDatas.MakeOptionDataInstance.proxy.strProxyIP), int.Parse(MakeOptionDatas.MakeOptionDataInstance.proxy.strProxyPort));
                        }

                        
            catch (Exception ex)
                        
            {
                            MessageBox.Show(ex.Message 
            + " " + ex.StackTrace);
                        }

                    }

                    
            //連接
                    private Ping pingSender = new Ping(); 
                    
            public bool ServerConnected()
                    
            {
                        
            try
                        
            {
                            PingOptions pingOption 
            = new PingOptions();
                            pingOption.DontFragment 
            = true;

                            
            string data = "sendData";
                            
            byte[] buffer = Encoding.ASCII.GetBytes(data);
                            
            int timeout = 120;
                            PingReply reply 
            = pingSender.Send(EPServer.Address, timeout, buffer);
                            
            if (reply.Status == IPStatus.Success)
                            
            {
                                
            //MessageBox.Show("能ping通 ");
                                return true;
                            }

                            
            else
                            
            {
                                
            //MessageBox.Show("ping不通");
                                return false;
                            }

                            
                            
                        }

                        
            catch
                        
            {
                            
            return false;
                        }

                    }

                    
            //斷開
                    public void Disconnect()
                    
            {
                        
                    }

                }

            }

            posted @ 2010-02-25 14:47 天書 閱讀(2130) | 評論 (0)編輯 收藏
                 摘要:   private void MQRecieve()   //MQ接收函數        {            try     &nbs...  閱讀全文
            posted @ 2010-02-08 09:04 天書 閱讀(575) | 評論 (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 天書 閱讀(460) | 評論 (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 天書 閱讀(954) | 評論 (0)編輯 收藏

            跨線程時 一定要用System.Timer,而不要用System.windows.Forms.Timer.

            Timer 控件到點時,一定要先stop然后做其他工作,最后再messageBox.show() ;否則messageBox.show() 將線程阻塞在那塊等待用戶操作了,要是用戶不在沒有操作,則不能stop()

            posted @ 2010-01-07 10:04 天書 閱讀(600) | 評論 (0)編輯 收藏

            1:網線或者網絡的事,比如IP被占用,網線不好用。

            查找方法: ping一下網關。

            2:接收數據中有"\0",把后面數據截斷了。

            解決辦法: string.replace("\0","")

            posted @ 2010-01-07 10:03 天書 閱讀(1252) | 評論 (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 天書 閱讀(287) | 評論 (0)編輯 收藏
            1:添加—新建項目—其它項目類型—安裝和部署—安裝項目
            2:在視圖—文件系統中,按照源程序bin目錄下的結構,構建文件夾及文件(文件夾中套n多文件夾的可以同時開著兩個,拖進去,不用一層一層建太麻煩了)
            3:屬性-系統必備里-.NETFrameWork2.0打上對勾
            4:視圖—文件系統—用戶桌面添加上快捷方式,右鍵添加,同時屬性中的alwayscreate 設為true
            5:這樣打包好后系統就自動提煉DotNetFrameWork放入到CMTSetup\Debug下面的自動創建的文件夾dotnetfx下面了。
            posted @ 2009-09-24 17:07 天書 閱讀(818) | 評論 (0)編輯 收藏
            僅列出標題
            共13頁: 1 2 3 4 5 6 7 8 9 Last 

            <2008年9月>
            31123456
            78910111213
            14151617181920
            21222324252627
            2829301234
            567891011

            常用鏈接

            留言簿(5)

            隨筆檔案

            文章分類

            文章檔案

            好友的Bolg

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            狠狠精品久久久无码中文字幕 | 久久AV高清无码| 久久久午夜精品| 一级做a爰片久久毛片免费陪| 久久精品国产一区二区三区| 精品久久一区二区| 99久久中文字幕| 97久久精品国产精品青草| WWW婷婷AV久久久影片| 成人综合伊人五月婷久久| 99久久99久久| 欧美久久综合性欧美| 久久久久久国产精品无码下载 | 国产综合久久久久久鬼色| 99久久er这里只有精品18| 久久免费线看线看| 国产精久久一区二区三区| 看全色黄大色大片免费久久久| 精品国产日韩久久亚洲| 久久久无码一区二区三区| 欧美久久综合性欧美| 亚洲国产精品无码久久青草| 久久91精品国产91久| 久久青青草原精品国产| 亚洲欧美日韩精品久久| 亚洲成av人片不卡无码久久| 欧美精品久久久久久久自慰| 亚洲国产精品久久久久网站 | 99久久精品日本一区二区免费 | 亚洲精品WWW久久久久久| 少妇人妻88久久中文字幕| 91精品国产91久久久久久青草| 香蕉久久夜色精品国产尤物| 久久久91精品国产一区二区三区| 欧美亚洲日本久久精品| AV色综合久久天堂AV色综合在| 久久精品国产亚洲7777| 久久精品国产久精国产思思| 久久久久亚洲精品无码网址| 国内精品人妻无码久久久影院| 中文国产成人精品久久亚洲精品AⅤ无码精品 |