Beispiel #1
0
        static void FileBackup(object arg)
        {
            TcpClientHelper client = (TcpClientHelper)arg;

            //获取需备份的文件
            //DataTable dt = this._oFileWatch.GetBackupFiles();
            List <FileInfo> files = new List <FileInfo>();

            files.Add(new FileInfo()
            {
                Name = "log.txt", FullPath = @"C:\log.txt"
            });
            files.Add(new FileInfo()
            {
                Name = "dotNetFx40_Full_x86_x64.rar", FullPath = @"C:\dotNetFx40_Full_x86_x64.rar"
            });

            foreach (var file in files)
            {
                client.SendMessage("FileBak");
                //Thread.Sleep(10000);

                if (client.ReadMessage().ToLower() == "filebakok")
                {
                    client.SendMessage(file.Name);
                    client.SendFile(file.FullPath);
                    client.SendMessage(client.CalcFileHash(file.FullPath));

                    if (client.ReadMessage().ToLower() == "ok")
                    {
                        Console.WriteLine("备份文件【" + file.FullPath + "】成功");
                    }
                    else
                    {
                        Console.WriteLine("备份文件【" + file.FullPath + "】失败。");
                    }
                }
            }
        }
Beispiel #2
0
        public int SendMessage(string Msg)
        {
            TcpClientHelper client = new TcpClientHelper(ILL.GetConfig.CallServIp, ILL.GetConfig.CallServPort);

            try
            {
                client.Start();
                client.SendMessage(Msg);
                return(1);
            }
            catch
            {
                return(-1);
                //MessageBox.Show("排队叫号系统出现如下错误:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }