public void Excute(AsyncParameters parameters, string cmd) { try { if (string.IsNullOrEmpty(AuthenticationString)) { parameters.Client.Send(Encoding.UTF8.GetBytes("ok")); } else { string[] parms = cmd.Split('|'); if (parms != null && parms.Length > 1) { if (parms[1] == AuthenticationString) { parameters.Client.Send(Encoding.UTF8.GetBytes("ok")); } else { parameters.Client.Send(Encoding.UTF8.GetBytes("failed")); } } else { parameters.Client.Send(Encoding.UTF8.GetBytes("key")); } } } catch { } }
public void Excute(AsyncParameters parameters, string cmd) { try { ICommand icmd = CommandFactory.Creat(cmd); icmd.Excute(); } catch { } }
public void Excute(AsyncParameters parameters, string cmd) { foreach (Item i in Items) { if(i.Cmd==cmd) try { ICommand icmd = CommandFactory.Creat(i.ToCmd()); icmd.Excute(); } catch { } } }
public void Excute(AsyncParameters parameters, string cmd) { string[] cmdParms = cmd.Split('|'); if(cmdParms.Length<2) { return; } else { sb.Remove(0, sb.Length); if (cmdParms[1].ToLower() == "disk") { DriveInfo[] d = DriveInfo.GetDrives(); foreach(DriveInfo difo in d) { if (difo.DriveType == DriveType.Fixed) { sb.Append(difo.Name + ",Disk;"); } } } else { if(Directory.Exists(cmdParms[1])) { //文件夹路径 string[] dirs = Directory.GetDirectories(cmdParms[1]); foreach(string s in dirs) { sb.Append(s + ",Dir;"); } string[] files=Directory.GetFiles(cmdParms[1]); foreach(string fs in files) { FileInfo info = new FileInfo(fs); sb.Append(fs + ",File,"+(info.Length/1024).ToString()+";"); } } else { //什么都不是 } } byte[] data=Encoding.UTF8.GetBytes(sb.ToString()); parameters.Client.Send(data); } }
public void Excute(AsyncParameters parameters, string cmd) { string[] cmdParms = cmd.Split('|'); if (cmdParms.Length < 2) { return; } else { if (File.Exists(cmdParms[1])) { byte[] fileBuffer = new byte[1024]; FileStream fs = File.OpenRead(cmdParms[1]); while (fs.Position < fs.Length) { int len = fs.Read(fileBuffer, 0, fileBuffer.Length); parameters.Client.Send(fileBuffer, len, 0); } fs.Close(); parameters.Client.Close(); } } }
public void Excute(AsyncParameters parameters, string cmd) { try { string[] parms = cmd.Split('|'); if (parms != null && parms.Length > 1) { VideoParameters = new VideoParameters(); foreach (string p in parms) { string prm = p.ToLower(); if (prm == "followmouse") { ShowModel = ShowModels.FollowMouse; } else if (prm == "fullscreen") { ShowModel = ShowModels.FullScreen; } else if (prm[prm.Length - 1] == 'w') { VideoParameters.Width = int.Parse(prm.Substring(0, prm.Length - 1)); } else if (prm[prm.Length - 1] == 'h') { VideoParameters.Height = int.Parse(prm.Substring(0, prm.Length - 1)); } else if (prm[prm.Length - 1] == 'q') { VideoParameters.Quality = long.Parse(prm.Substring(0, prm.Length - 1)); } } } } catch { } VideoParameters v; if(VideoParameters==null||VideoParameters.Width==0||VideoParameters.Height==0) { v = defaultVideoParameters; } else { v = VideoParameters; } try { Screenshot ss = new Screenshot(); Image img = null; if (ShowModel == ShowModels.FollowMouse) { img = ss.GetRectangleScreenshot(v); } else { img = ss.GetFullScreenImage(v); } parameters.Data = ImageProcessing.CompressedImageQuality(img, v.Quality); img.Dispose(); //Console.WriteLine(parameters.Data.Length / 1024); parameters.Client.BeginSend(parameters.Data, 0, parameters.Data.Length, 0, new AsyncCallback(EndSend), parameters); } catch (Exception e) { Console.WriteLine(e.Message+e.Source+e.StackTrace); } }
public void Excute(AsyncParameters parameters, string cmd) { }
private void clientWorkThread(Socket client) { AsyncParameters asynParam = new AsyncParameters(serverSocket, client); client.BeginReceive(asynParam.Data, 0, asynParam.Data.Length, 0, new AsyncCallback(endReceive), asynParam); }
private void ResolveAndExcuteCMD(AsyncParameters asyncParam ,string cmd) { int index = cmd.IndexOf('|'); string mainCmd=""; if(index>0) { mainCmd= cmd.Substring(0, index); } else { mainCmd = cmd; } foreach (IExecutor ie in Executors) { if (ie.CommandText.Contains(mainCmd.ToLower())) { ie.Excute(asyncParam, cmd); } } }