static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ApplicationInstance.MessageDlg = new ApplicationMessageDlg(); ApplicationInstance application = new ApplicationInstance(); application.ApplicationType = ApplicationType.Server; application.ConfigSectionName = "SharpNodeSettingsServer"; try { // load the application configuration. application.LoadApplicationConfiguration(false).Wait(); // check the application certificate. bool certOk = application.CheckApplicationInstanceCertificate(false, 0).Result; if (!certOk) { throw new Exception("Application instance certificate invalid!"); } // start the server. application.Start(new SharpNodeSettingsServer()).Wait(); // run the application interactively. ServerForm serverForm = new ServerForm(application); serverForm.StartPosition = FormStartPosition.CenterScreen; Application.Run(serverForm); } catch (Exception e) { ExceptionDlg.Show(application.ApplicationName, e); } }
private void Button2_Click(object sender, EventArgs e) { var view = new ServerForm(); var controller = new ServerFormController(view); view.Show(); }
public MyImageProcessor() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); sv = new ServerForm(); Application.Run(sv); }
private string CombinationalLogicCode(string AreaCode, string number) { string builder = ""; number = GetNuberToString(number); // 63301080000000314010401 string level = "6"; string ResourceType = "0314"; string ResourceTypeNumber = "01"; // 子类型 string Subtype = "04"; string logicCode = level + AreaCode + ResourceType + ResourceTypeNumber + Subtype + number; if (logicCode.Length != 23 && LogicalData.LogicalCode.Length == 23) { logicCode = LogicalData.LogicalCode; } logicCode = GetLogicalCodel(logicCode); if (logicCode.Length == 23) { if (!UpdateLogicalCode(LogicalData.srvID, logicCode)) { ServerForm.SetManager("更改逻辑编码失败", System.Drawing.Color.Red); } return(logicCode); } return(null); }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GlobalUtil.SetAuthorizedUser(ConfigurationManager.AppSettings["AuthorizedUser"], ConfigurationManager.AppSettings["AuthorizedPassword"]); GlobalUtil.SetMaxLengthOfUserID(byte.Parse(ConfigurationManager.AppSettings["MaxLengthOfUserID"])); OMCSConfiguration config = new OMCSConfiguration( int.Parse(ConfigurationManager.AppSettings["CameraFramerate"]), int.Parse(ConfigurationManager.AppSettings["DesktopFramerate"]) ); //用于验证登录用户的帐密 DefaultUserVerifier userVerifier = new DefaultUserVerifier(); Program.MultimediaServer = MultimediaServerFactory.CreateMultimediaServer(int.Parse(ConfigurationManager.AppSettings["Port"]), userVerifier, config, bool.Parse(ConfigurationManager.AppSettings["SecurityLogEnabled"])); ServerForm form = new ServerForm(Program.MultimediaServer); Application.Run(form); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GlobalUtil.SetAuthorizedUser(ConfigurationManager.AppSettings["AuthorizedUser"], ConfigurationManager.AppSettings["AuthorizedPassword"]); GlobalUtil.SetMaxLengthOfUserID(byte.Parse(ConfigurationManager.AppSettings["MaxLengthOfUserID"])); OMCSConfiguration config = new OMCSConfiguration(); //用于验证登录用户的帐密 DefaultUserVerifier userVerifier = new DefaultUserVerifier(); Program.MultimediaServer = MultimediaServerFactory.CreateMultimediaServer(int.Parse(ConfigurationManager.AppSettings["Port"]), userVerifier, config, bool.Parse(ConfigurationManager.AppSettings["SecurityLogEnabled"])); ServerForm form = new ServerForm(Program.MultimediaServer); Application.Run(form); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
void ShowServerManager(bool force = false) { if (serverForm == null) { serverForm = new ServerForm(); serverForm.Closing += (sender, e) => { serverForm.Hide(); e.Cancel = true; if (!IsClosing) { if (Db == null) { Init(); } } }; } if (force) { serverForm.ShowDialog(); } else { serverForm.Show(); serverForm.Activate(); } }
public bool Crear_Conexion(string ip, int puerto, ServerForm form) { try { IPAddress.TryParse(ip, out _ip_address); _puerto = puerto; _form = form; _mensajeManager = new MensajeManager(); _servidor = new TcpListener(_ip_address, _puerto); _servidor.Start(); _form.Imprimir_Log("Conexión abierta."); _juego = new Juego(); _servidor.BeginAcceptTcpClient(AceptandoCliente, _servidor); _form.Imprimir_Log("Esperando clientes..."); return(true); } catch (Exception e) { MessageBox.Show("Error: " + e.ToString()); return(false); } }
public Connection(TcpClient tcpClient, ServerForm form) { this.tcpClient = tcpClient; this.form = form; this.thread = new Thread(doConnection); this.stream = tcpClient.GetStream(); }
private bool UpdateState() { bool flag = false; XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); string MediaSql = ""; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; List <Device> lDev = new List <Device>(); try { lDev = GetEBRDTStateFromDataBase("Full"); frdStateName = "10" + SingletonInfo.GetInstance().CurrentResourcecode + BBSHelper.GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(SingletonInfo.GetInstance().SendTarAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } catch (Exception ex) { throw new Exception("终端状态变更:" + ex.Message); } return(flag); }
public void AdapterPost(string BrdStateDesc, string BrdStateCode) { XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); rHeart.SourceAreaCode = ServerForm.strSourceAreaCode; rHeart.SourceType = ServerForm.strSourceType; rHeart.SourceName = ServerForm.strSourceName; rHeart.SourceID = ServerForm.strSourceID; rHeart.sHBRONO = ServerForm.strHBRONO; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; try { Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.AdapterStateRequestResponse(frdStateName, BrdStateDesc, BrdStateCode); CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; SendTar.SendTarOrder.sendHelper.AddPostQueue(ServerForm.sZJPostUrlAddress, sHeartBeatTarName); } catch (Exception ex) { } }
private void multiplayerButton_Click(object sender, EventArgs e) { this.Hide(); ServerForm sf = new ServerForm(); sf.Closed += (s, args) => this.Close(); sf.Show(); }
/// <summary> /// 组合逻辑码 /// </summary> public string GetLogicalAndAddDataBase() { string logicalCode = GetGBCode(); int number = GetGBCodeCount(LogicalData.srvAreaID, null); if (number > 99) { ServerForm.SetManager("资源已满,查看是否要进行变更", System.Drawing.Color.Red); } return(CombinationalLogicCode(logicalCode, number.ToString())); }
public static void Initialize(ServerForm _f) { backgroundLogThread = new Thread(LogWorker); backgroundLogThread.IsBackground = true; // close app -> close this thread backgroundLogThread.Start(); f = _f; LogStruct Loggingstruct = new LogStruct(); Loggingstruct.Text = "[Logger initialized]"; Loggingstruct.Type = LogType.Trace; LogQueue.Enqueue(Loggingstruct); Loggingstruct.Text = " PacketLogger initialized"; Loggingstruct.Type = LogType.Trace; LogPacketQueue.Enqueue(Loggingstruct); }
public string AddPostQueue(string address, string FileName) { if (!string.IsNullOrEmpty(address) && !string.IsNullOrEmpty(FileName)) { PostModel postInfo = new PostModel(); postInfo.Address = address; postInfo.FileName = FileName; Queueinterface <PostModel> .SendQueue.Enqueue(postInfo); ServerForm.SetManager("队列添加成功:" + postInfo.FileName, Color.Green); return("1"); } else { ServerForm.SetManager("队列添加失败:" + FileName, Color.Red); return("2"); } }
/// <summary> /// Constructor which accepts Client TCP object /// </summary> /// <param name="tcpClient"></param> public ServerService(ServerForm parent, TcpClient tcpClient) { this.owner = parent; tcpServers = new TcpServers(this.owner); // Get Stream Object connectedClient = tcpClient; clientStream = tcpClient.GetStream(); // Create the state object. StateObject state = new StateObject(); state.workSocket = connectedClient.Client; //Call Asynchronous Receive Function connectedClient.Client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(OnReceive), state); //connectedClient.Client.BeginDisconnect(true, new AsyncCallback(DisconnectCallback), state); }
static void Main() { try { // Application.en Control.CheckForIllegalCrossThreadCalls = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ServerForm serform = new ServerForm(); ClientForm clientform = new ClientForm(); serform.Show(); clientform.Show(); Application.Run(new Form1()); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } }
public SnapperWindow(int x, int y, int width, int height) : base("Pixel Share", 10, 10, 640, 480) { // Show a form so we can capture the desired group IP and port number ServerForm groupForm = new ServerForm(); //IPAddress randomAddress = NewTOAPIA.Net.Utility.GetRandomMulticastAddress(); //groupForm.groupAddressField.Text = randomAddress.ToString(); groupForm.ShowDialog(); // Get the address and port from the form fUseGray = groupForm.checkBox1.Checked; string groupIP = groupForm.groupAddressField.Text; int groupPort = int.Parse(groupForm.groupPortField.Text); IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort); // Set our title to the address specified so the user // can easily identify their session. Title = "SnapNShare - " + ipep.ToString(); fSnapper = new ScreenSnapper(); fClientOrigin = new POINT(); int pwidth = ClientRectangle.Width; int pheight = ClientRectangle.Height; fScreenImage = new GDIDIBSection(width, height, BitCount.Bits24); fGrayImage = new PixelArray<Lumb>(width, height,fScreenImage.Orientation, new Lumb()); BackgroundColor = RGBColor.White; this.Opacity = 0.5; // Add the channel for graphics commands CommChannel graphicsChannel = new CommChannel(ipep, true, false); fCommandDispatcher = new GraphPortChunkEncoder(graphicsChannel); // Start the thread that will take snapshots of the screen fGlobalTimer = new PrecisionTimer(); fFrameRate = 2; // Frames per second fSnapperRunning = true; snapperThread = new Thread(RunSnaps); snapperThread.Start(); }
private async void Start(object sender, EventArgs e) { server = new ServerForm(); enemy = new EnemyForm(server); client = new ClientForm(server); client.Show(); server.Show(); StartModel.Enabled = false; await client.Initialize(); Maximize.Show(); Minimize.Show(); StartModel.Hide(); enemy.Show(); }
private void PostSend(PostModel postModel) { try { string result = HttpSendFile.UploadFilesByPost(postModel.Address, postModel.FileName); if (result != "0") { ServerForm.SetManager("发送成功:" + postModel.FileName, Color.Green); } else { ServerForm.SetManager("发送失败" + postModel.FileName, Color.Red); } } catch (Exception ex) { ServerForm.SetManager("发送失败" + postModel.FileName + "失败原因:" + ex.Message, Color.Red); Log.Instance.LogWrite("发送队列异常:" + ex.ToString()); } }
private void btnServer_Click(object sender, EventArgs e) { var message = string.Empty; // Start Application as Server Host = new WcfHost.WcfHost(); ServerForm serverForm = new ServerForm(); serverForm.Init(WcfHost.WcfHost.ServerVM); serverForm.Disposed += ServerForm_Disposed; if (Host.Start(out message)) { this.Hide(); serverForm.Show(); } else { MessageBox.Show(message); } }
protected override void Initialize() { serverForm = new ServerForm(); serverForm.Show(); serverForm.startServerBtn.Click += delegate(object o, EventArgs e) { server = new GameServer(); server.StartServer(); }; serverForm.connectClientBtn.Click += delegate(object o, EventArgs e) { client = new GameClient(); client.ConnectToServer(serverForm.IP, int.Parse(serverForm.Port), serverForm.ClientName); }; camera = new Camera2DControlled(); camera.Zoom = 1f; base.Initialize(); }
public static void Main(String[] arguments) { try { Arguments = arguments; NativeMethods.BeginTimePeriod(1); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += OnThreadException; AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; AppDomain.CurrentDomain.ProcessExit += (s, e) => NativeMethods.EndTimePeriod(1); Application.Run(ServerForm = new ServerForm()); } finally { Application.Exit(); } }
/// <summary> /// 播放 /// </summary> /// <returns></returns> public bool AudioPlay(int type, string ParamValue, string TsCmd_ID, string TsCmd_ValueID, string EBMInfoID) { try { ServerForm.SetManager("EBM开始时间: " + AudioModel.PlayingTime + "===>EBM结束时间: " + AudioModel.PlayEndTime, Color.Green); ServerForm.SetManager("播放开始时间: " + AudioModel.PlayingTime + "===>播放结束时间: " + AudioModel.PlayEndTime, Color.Green); ServerForm.SetManager("等待播放" + AudioModel.PlayingContent, Color.Green); EBD ebd = GetEBD(AudioModel.XmlFilaPath); string AreaString = CombinationArea(); #region 未播放 if (DateTime.Compare(AudioModel.PlayingTime, DateTime.Now) > 0) { AudioPlayState = AudioMessage.AudioPlayState.NotPlay; lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.NotBroadcast; } string strSql = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "1", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSql); Task.Factory.StartNew(() => { PlayStateInterface.NotPlay(TsCmd_ID, AudioModel.XmlFilaPath, "1"); ServerForm.SetManager("反馈未播放状态", Color.Green); }); } #endregion 未播放代码 //播放中 #region 播放中 while (true) { DateTime current = DateTime.Now; Thread.Sleep(1000); if (DateTime.Compare(current, AudioModel.PlayingTime) > 0)//当前时间大于播放开始时间 { ServerForm.SetManager("播放开始:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Color.Green); lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.Playback; } AudioPlayState = AudioMessage.AudioPlayState.Playing; // MqSendOrder sendOrder = new MqSendOrder(); bool result = SendMQ.MqSendOrder.sendOrder.SendMq(ebd, type, ParamValue, TsCmd_ID, TsCmd_ValueID); string strSql = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "2", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSql); Task.Factory.StartNew(() => { PlayStateInterface.Playing(TsCmd_ID, AudioModel.XmlFilaPath, "2", "播发中"); ServerForm.SetManager("反馈播发中状态", Color.Green); }); ServerForm.SetManager("播放中的反馈已发送", Color.Green); break; } } #endregion 播放中代码 //播放完成 #region 播放完 ServerForm.SetManager("进入等待播放完成流程", Color.Green); while (true) { Thread.Sleep(1000); // ServerForm.SetManager("未到结束时间在播放过程中:"+tmp.ToString(), Color.Green); if (DateTime.Compare(DateTime.Now, AudioModel.PlayEndTime) < 0)//结束时间大于当前时间 { string MediaSql = "select TsCmd_ID,TsCmd_ExCute from TsCmdStore where TsCmd_ID='" + TsCmd_ID + "'"; // MediaSql = "select top(1)TsCmd_ID,TsCmd_XmlFile from TsCmdStore where TsCmd_ValueID = '" + ebd.EBMStateRequest.EBM.EBMID + "' order by TsCmd_Date desc"; DataTable dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia != null && dtMedia.Rows.Count > 0) { if (dtMedia.Rows[0]["TsCmd_ExCute"].ToString().Contains("播放完毕")) { string strSql = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "3", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSql); ServerForm.SetManager("播放结束", Color.Green); lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.PlayOut; } AudioPlayState = AudioMessage.AudioPlayState.PlayingOver; Task.Factory.StartNew(() => { PlayStateInterface.PlayOver(TsCmd_ID, AudioModel.XmlFilaPath, "3", "开机/运行中"); ServerForm.SetManager("反馈播放完成状态", Color.Green); }); if (SingletonInfo.GetInstance().DicTsCmd_ID.ContainsKey(AreaString)) { SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); } if (SingletonInfo.GetInstance().DicPlayingThread.ContainsKey(AudioModel.AeraCodeReal)) { SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); // MessageBox.Show("文件播放完了->删除" + AudioModel.AeraCodeReal + "的字典值"); } break; } } } else { lock (ServerForm.PlayBackObject) { ServerForm.PlayBack = ServerForm.PlaybackStateType.PlayOut; } ServerForm.SetManager("播放结束", Color.Green); Task.Factory.StartNew(() => { PlayStateInterface.PlayOver(TsCmd_ID, AudioModel.XmlFilaPath, "3", "开机/运行中"); ServerForm.SetManager("反馈播放完成状态", Color.Green); }); string strSqlupdateEBMInfo = string.Format("update EBMInfo set EBMState = '{0}' where id='{1}'", "3", EBMInfoID); mainForm.dba.UpdateDbBySQL(strSqlupdateEBMInfo); //没播放完 但是文件时间到了 string strSql = ""; if (type == 1) { strSql = string.Format("update PLAYRECORD set PR_REC_STATUS = '{0}' where PR_SourceID='{1}'", "删除", TsCmd_ID); mainForm.dba.UpdateDbBySQL(strSql); string strSqlTsCmdStore = string.Format("update TsCmdStore set TsCmd_ExCute = '{0}' where TsCmd_ID='{1}'", "播放完毕", TsCmd_ID); mainForm.dba.UpdateDbBySQL(strSqlTsCmdStore); } else if (type == 2) { strSql = string.Format("update PLAYRECORD set PR_REC_STATUS = '{0}' ", "删除"); mainForm.dba.UpdateDbBySQL(strSql); } if (SingletonInfo.GetInstance().DicTsCmd_ID.ContainsKey(AreaString)) { SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); } if (SingletonInfo.GetInstance().DicPlayingThread.ContainsKey(AudioModel.AeraCodeReal)) { SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); // MessageBox.Show("播放时间到了->删除"+ AudioModel.AeraCodeReal+"的字典值"); } break; } } #endregion 播放完代码 GC.Collect(); return(true); } catch (Exception ex) { AudioPlayState = AudioMessage.AudioPlayState.error; // MessageBox.Show(ex.Message + ex.StackTrace); } return(false); }
private bool UpdateState(string TimingTerminalState) { bool flag = false; XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); rHeart.SourceAreaCode = ServerForm.strSourceAreaCode; rHeart.SourceType = ServerForm.strSourceType; rHeart.SourceName = ServerForm.strSourceName; rHeart.SourceID = ServerForm.strSourceID; rHeart.sHBRONO = ServerForm.strHBRONO; string MediaSql = ""; string strSRV_ID = ""; string strSRV_CODE = ""; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; List <Device> lDev = new List <Device>(); try { // MediaSql = "select SRV.SRV_ID,SRV.SRV_CODE,SRV_GOOGLE, SRV_PHYSICAL_CODE,srv_detail FROM SRV left join Srvtype on SRV.DeviceTypeId= Srvtype .srv_id where Srvtype.srv_id=1"; MediaSql = "select SRV.SRV_ID,SRV.SRV_CODE,SRV_GOOGLE, SRV_PHYSICAL_CODE,srv_detail,SRV_LOGICAL_CODE_GB,SRV_MFT_DATE,updateDate,SRV_RMT_STATUS FROM SRV left join Srvtype on SRV.DeviceTypeId= Srvtype .srv_id where Srvtype.srv_id=1"; DataTable dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia != null && dtMedia.Rows.Count > 0) { if (dtMedia.Rows.Count > 100) { int mod = dtMedia.Rows.Count / 100 + 1; for (int i = 0; i < mod; i++) { for (int idtM = 0; idtM < dtMedia.Rows.Count; idtM++) { Device DV = new Device(); DV.SRV_ID = dtMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); DV.DeviceID = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE_GB"].ToString();//修改于20180819 把资源码换成23位 DV.DeviceName = dtMedia.Rows[idtM][4].ToString(); DV.Latitude = dtMedia.Rows[idtM][2].ToString().Split(',')[0]; DV.Longitude = dtMedia.Rows[idtM][2].ToString().Split(',')[1]; DV.Srv_Mft_Date = dtMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtMedia.Rows[idtM]["updateDate"].ToString(); DV.DeviceState = TimingTerminalState; lDev.Add(DV); } Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(ServerForm.sZJPostUrlAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } } else { for (int idtM = 0; idtM < dtMedia.Rows.Count; idtM++) { Device DV = new Device(); DV.SRV_ID = dtMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); DV.DeviceID = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE_GB"].ToString(); DV.DeviceName = dtMedia.Rows[idtM][4].ToString(); DV.Latitude = dtMedia.Rows[idtM][2].ToString().Split(',')[0]; DV.Longitude = dtMedia.Rows[idtM][2].ToString().Split(',')[1]; DV.Srv_Mft_Date = dtMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtMedia.Rows[idtM]["updateDate"].ToString(); DV.DeviceState = TimingTerminalState; lDev.Add(DV); } frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(ServerForm.sZJPostUrlAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } } else { Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceStateResponse(lDev, frdStateName); TarXml.AudioResponseXml.CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; string result = SendTar.SendTarOrder.sendHelper.AddPostQueue(ServerForm.sZJPostUrlAddress, sHeartBeatTarName); if (result == "1") { flag = true; } } } catch (Exception ex) { throw new Exception("终端状态变更:" + ex.Message); } return(flag); }
private void mstripServerConnect_Click(object sender, EventArgs e) { ServerForm srv = new ServerForm(); srv.ShowDialog(); }
static void offline() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IServerConnectionManager serverManager = OfflineServerManager.getInstance(); ServerForm serverForm = new ServerForm(); serverManager.View = serverForm; serverManager.FeedbackWriter = serverForm; MainMenuForm mainForm1 = new MainMenuForm(), mainForm2 = new MainMenuForm(); IClientConnectionManager clientManager1 = new OfflineClientManager() { remoteProxy = serverManager, FeedbackWriter = mainForm1 }, clientManager2 = new OfflineClientManager() { remoteProxy = serverManager, FeedbackWriter = mainForm2 }; ConnectToServerForm connectForm1 = new ConnectToServerForm(), connectForm2 = new ConnectToServerForm(); MainMenuController mainController1 = new MainMenuController(clientManager1, mainForm1, connectForm1) { MyMatchFormController = new GraphicMatchController() }, mainController2 = new MainMenuController(clientManager2, mainForm2, connectForm2) { MyMatchFormController = new GraphicMatchController() }; DialogResult d = MessageBox.Show("Autorun?", "Autorun", MessageBoxButtons.YesNo); if (d == DialogResult.Yes) { mainController1.isAutorun = true; mainController2.isAutorun = true; mainController1.autorunName = "Player 1"; mainController2.autorunName = "Player 2"; } mainController1.start(); mainController2.start(); /* * IClientConnectionManager manager = new WCFClientManager(); * MainMenuForm mainForm = new MainMenuForm(); * mainForm.Text = arg ?? "Form"; * ConnectToServerForm connectForm = new ConnectToServerForm(); * manager.FeedbackWriter = mainForm; * MainMenuController controller = new MainMenuController(manager, * mainForm, connectForm); * controller.MyMatchFormController = new GraphicMatchController(); * controller.PlayerName = arg; * controller.start(); * //controller.setCurrentForm("Dispute"); */ Application.Run((MainMenuForm)mainController1.MyView); }
public static void processCmd(ServerForm mainForm, BinaryReader reader, ENUMS.MESSAGETYPE messageType) { try { Console.WriteLine(messageType); switch (messageType) { case ENUMS.MESSAGETYPE.EXIT: mainForm.stopClient();//disconnect socket break; case ENUMS.MESSAGETYPE.CODE: int mesLen = big2Small(reader.ReadInt32()); byte[] msg = reader.ReadBytes(mesLen); if (Encoding.UTF8.GetString(msg) != "小鸡炖蘑菇") { mainForm.stopClient(); } break; case ENUMS.MESSAGETYPE.FUN_LOCK: LockWorkStation();//lock PC break; case ENUMS.MESSAGETYPE.FUN_LOGOUT: DoExitWin(EWX_LOGOFF);//logout break; case ENUMS.MESSAGETYPE.FUN_MANAGER://open the task manager ProcessStartInfo ps = new ProcessStartInfo(); ps.FileName = @"C:\WINDOWS\system32\taskmgr.exe"; Process.Start(ps); break; case ENUMS.MESSAGETYPE.FUN_RESTART: DoExitWin(EWX_REBOOT); break; case ENUMS.MESSAGETYPE.FUN_SHOW_DESKTOP: Type shellType = Type.GetTypeFromProgID("Shell.Application"); object shellObject = System.Activator.CreateInstance(shellType); shellType.InvokeMember("ToggleDesktop", System.Reflection.BindingFlags.InvokeMethod, null, shellObject, null); break; case ENUMS.MESSAGETYPE.FUN_SHUTDOWN: DoExitWin(EWX_SHUTDOWN | EWX_FORCE); break; case ENUMS.MESSAGETYPE.FUN_SHUTDOWN_CANCEL: cancelShutdown(); break; case ENUMS.MESSAGETYPE.FUN_SHUTDOWN_TIME: int timeSpan = big2Small(reader.ReadInt32());//delay shutdown, int data, shutDownTime(timeSpan); break; case ENUMS.MESSAGETYPE.FUN_SLEEP: Application.SetSuspendState(PowerState.Hibernate, true, true); break; case ENUMS.MESSAGETYPE.HOST_NANME: int len = big2Small(reader.ReadInt32()); byte[] message = reader.ReadBytes(len); String msg2 = Encoding.UTF8.GetString(message); mainForm.setMessageHost(msg2); break; case ENUMS.MESSAGETYPE.KEY_DOWN: ENUMS.SPECIALKEYS key = (ENUMS.SPECIALKEYS)reader.ReadByte(); processKeys(key, DOWN); break; case ENUMS.MESSAGETYPE.KEY_UP: ENUMS.SPECIALKEYS key2 = (ENUMS.SPECIALKEYS)reader.ReadByte(); processKeys(key2, UP); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_CLICK: mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_DOUBLE_CLICK: //双击左键 mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Thread.Sleep(100); mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_DOWN: mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_UP: mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_MOVE: int xdis = big2Small(reader.ReadInt32()); int ydis = big2Small(reader.ReadInt32()); mouse_event(MOUSEEVENTF_MOVE, xdis, ydis, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_CLICK: mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); Thread.Sleep(100); mouse_event( MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_DOUBLE_CLICK: //双击右键 mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); Thread.Sleep(100); mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_DOWN: mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_UP: mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_WHEEL: int wheel = big2Small(reader.ReadInt32()); mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheel, 0); break; case ENUMS.MESSAGETYPE.MOUSE_SET: int xPoint = big2Small(reader.ReadInt32()); int yPoint = big2Small(reader.ReadInt32()); //mouse_event(MOUSEEVENTF_ABSOLUTE, xPoint, yPoint, 0, 0); SetCursorPos(xPoint, yPoint); break; case ENUMS.MESSAGETYPE.START_PIC: mainForm.startSendPicFlags(); break; case ENUMS.MESSAGETYPE.STOP_PIC: mainForm.stopSendPicFlags(); break; case ENUMS.MESSAGETYPE.TEXT: int textLen = big2Small(reader.ReadInt32()); byte[] textByte = reader.ReadBytes(textLen); SendKeys.SendWait(Encoding.UTF8.GetString(textByte)); break; case ENUMS.MESSAGETYPE.BOARDKEY_DOWN: byte keyDown = reader.ReadByte(); keybd_event(keyDown, MapVirtualKey(keyDown, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); break; case ENUMS.MESSAGETYPE.BOARDKEY_UP: byte keyUp = reader.ReadByte(); keybd_event(keyUp, MapVirtualKey(keyUp, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception("client is closed"); } }
public void TimingTerminalInfo(int type, string MediaSql) { DateTime INow = DateTime.Now; XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); rHeart.SourceAreaCode = ServerForm.strSourceAreaCode; rHeart.SourceType = ServerForm.strSourceType; rHeart.SourceName = ServerForm.strSourceName; rHeart.SourceID = ServerForm.strSourceID; rHeart.sHBRONO = ServerForm.strHBRONO; string strSRV_ID = ""; string strSRV_CODE = ""; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; DataTable dtMedia = null; DataTable dtSrvMedia = null; List <Device> lDev = new List <Device>(); try { dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia.Rows.Count > 0) { // MediaSql = "select top(99) SRV_ID,SRV_CODE,SRV_GOOGLE from SRV"; if (dtMedia != null && dtMedia.Rows.Count > 0) { for (int idtM = 0; idtM < dtMedia.Rows.Count; idtM++) { int srvId = Convert.ToInt32(dtMedia.Rows[idtM]["SRV_ID"].ToString()); string TerminalState = dtMedia.Rows[idtM]["SRV_RMT_STATUS"].ToString(); Device DV = new Device(); DV.SRV_ID = dtMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); DV.DeviceID = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE"].ToString(); DV.DeviceName = dtMedia.Rows[idtM][4].ToString(); DV.Latitude = dtMedia.Rows[idtM][2].ToString().Split(',')[0]; if (DV.Latitude.Split('.')[1].Length > 6) { DV.Latitude = DV.Latitude.Split('.')[0] + "." + DV.Latitude.Split('.')[1].Substring(0, 6); } DV.Longitude = dtMedia.Rows[idtM][2].ToString().Split(',')[1]; if (DV.Longitude.Split('.')[1].Length > 6) { DV.Longitude = DV.Latitude.Split('.')[0] + "." + DV.Longitude.Split('.')[1].Substring(0, 6); } DV.Srv_Mft_Date = dtMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtMedia.Rows[idtM]["srv_updateDate"].ToString(); /// Terminal_SRV_MFT_DATE,terminal_updateDate DV.Old_Srv_Mft_Date = dtMedia.Rows[idtM]["Terminal_SRV_MFT_DATE"].ToString(); DV.Old_UpdateDate = dtMedia.Rows[idtM]["terminal_updateDate"].ToString(); if (!(DV.Srv_Mft_Date.IndexOf(DV.Old_Srv_Mft_Date) > -1)) { rHeart.UpdateTerminalMaintenance(DV); lDev.Add(DV); } else if (!string.IsNullOrEmpty(DV.UpdateDate) && !string.IsNullOrEmpty(DV.Old_UpdateDate)) { if (!(DV.UpdateDate.IndexOf(DV.Old_UpdateDate) > -1)) { rHeart.UpdateTerminalMaintenance(DV); lDev.Add(DV); } } else { continue; } } //string TrLL = dtMedia.Rows[idtM][2].ToString(); //Device DV = new Device(); //if (idtM < 10) //{ // DV.DeviceID = "0" + idtM; //} //else { DV.DeviceID = idtM.ToString(); } //strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); //DV.DeviceID = strSRV_ID; //DV.DeviceName = strSRV_ID; //if (TrLL != "") //{ // string[] str = TrLL.Split(','); // if (str.Length >= 2) // { // DV.Longitude = str[1]; // DV.Latitude = str[0]; // } // else // { // DV.Longitude = "118.33"; // DV.Latitude = "33.95"; // } //} //else //{ // DV.Longitude = "118.33"; // DV.Latitude = "33.95"; //} } } if (lDev.Count > 0) { Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceInfoResponse(lDev, frdStateName); CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; send.address = ServerForm.sZJPostUrlAddress; send.fileNamePath = sHeartBeatTarName; SendTar.SendTarOrder.sendHelper.AddPostQueue(ServerForm.sZJPostUrlAddress, sHeartBeatTarName); } } catch { } Console.WriteLine((INow - DateTime.Now)); }
private void btnServer_Click(object sender, EventArgs e) { ServerForm serverForm = new ServerForm(); serverForm.Show(); }
public virtual AudioModel PlayReady(int type, string MQIns, string EBMInfoID) { try { if (MoreTime()) { //已经过了播放时间 不处理 PlayStateInterface.Untreated(AudioModel.XmlFilaPath, "0"); } else { bool res = false; string MQInstruction = MQIns; string AreaString = CombinationArea(); ///获取TsCmd_ValueID string TsCmd_ValueID = ""; //if (type == 2)//好坑 现场又坑我一把 20181219 //{ // TsCmd_ValueID = GetTmcValue(AreaString); //} //else //{ // TsCmd_ValueID = AreaString;//注意此处的TsCmd_ValueID为12位的区域码 20181212与刘工一起核查 //} TsCmd_ValueID = GetTmcValue(AreaString); if (!string.IsNullOrEmpty(TsCmd_ValueID)) { string result = InsertTsCmdStore(TsCmd_ValueID, AreaString, MQInstruction, AudioModel.PlayingTime.ToString(), AudioModel.PlayEndTime.ToString()); if (SingletonInfo.GetInstance().DicTsCmd_ID.ContainsKey(AreaString)) { SingletonInfo.GetInstance().DicTsCmd_ID.Remove(AreaString); } SingletonInfo.GetInstance().DicTsCmd_ID.Add(AreaString, result); if (!string.IsNullOrEmpty(result)) { Thread thread; string uuid = Guid.NewGuid().ToString("N"); thread = new Thread(delegate() { AudioPlay(type, MQInstruction, result, TsCmd_ValueID, EBMInfoID); } ); SingletonInfo.GetInstance().DicPlayingThread[AudioModel.AeraCodeReal].Add(thread); thread.IsBackground = true; thread.Start(); while (true) { Thread.Sleep(200); if (thread.ThreadState == ThreadState.Stopped) { thread.Abort(); GC.Collect(); if (SingletonInfo.GetInstance().DicPlayingThread.ContainsKey(AudioModel.AeraCodeReal)) { SingletonInfo.GetInstance().DicPlayingThread.Remove(AudioModel.AeraCodeReal); ServerForm.SetManager("播放过程线程stopped,DicPlayingThread中的字典被清理", Color.Green); } break; } } } } } } catch (Exception ex) { // MessageBox.Show("DicPlayingThread.count:"+SingletonInfo.GetInstance().DicPlayingThread.Count.ToString() + ","+ ex.Message+ex.StackTrace);// 测试注释 // return AudioModel; } return(null); }
public static void processCmd(ServerForm mainForm, BinaryReader reader, ENUMS.MESSAGETYPE messageType) { try { Console.WriteLine(messageType); switch (messageType) { case ENUMS.MESSAGETYPE.EXIT: mainForm.stopClient(); //disconnect socket break; case ENUMS.MESSAGETYPE.CODE: int mesLen = big2Small(reader.ReadInt32()); byte[] msg = reader.ReadBytes(mesLen); if (Encoding.UTF8.GetString(msg) != "小鸡炖蘑菇") { mainForm.stopClient(); } break; case ENUMS.MESSAGETYPE.FUN_LOCK: LockWorkStation(); //lock PC break; case ENUMS.MESSAGETYPE.FUN_LOGOUT: DoExitWin(EWX_LOGOFF); //logout break; case ENUMS.MESSAGETYPE.FUN_MANAGER: //open the task manager ProcessStartInfo ps = new ProcessStartInfo(); ps.FileName = @"C:\WINDOWS\system32\taskmgr.exe"; Process.Start(ps); break; case ENUMS.MESSAGETYPE.FUN_RESTART: DoExitWin(EWX_REBOOT); break; case ENUMS.MESSAGETYPE.FUN_SHOW_DESKTOP: Type shellType = Type.GetTypeFromProgID("Shell.Application"); object shellObject = System.Activator.CreateInstance(shellType); shellType.InvokeMember("ToggleDesktop", System.Reflection.BindingFlags.InvokeMethod, null, shellObject, null); break; case ENUMS.MESSAGETYPE.FUN_SHUTDOWN: DoExitWin(EWX_SHUTDOWN | EWX_FORCE); break; case ENUMS.MESSAGETYPE.FUN_SHUTDOWN_CANCEL: cancelShutdown(); break; case ENUMS.MESSAGETYPE.FUN_SHUTDOWN_TIME: int timeSpan = big2Small(reader.ReadInt32()); //delay shutdown, int data, shutDownTime(timeSpan); break; case ENUMS.MESSAGETYPE.FUN_SLEEP: Application.SetSuspendState(PowerState.Hibernate, true, true); break; case ENUMS.MESSAGETYPE.HOST_NANME: int len = big2Small(reader.ReadInt32()); byte[] message = reader.ReadBytes(len); String msg2 = Encoding.UTF8.GetString(message); mainForm.setMessageHost(msg2); break; case ENUMS.MESSAGETYPE.KEY_DOWN: ENUMS.SPECIALKEYS key = (ENUMS.SPECIALKEYS)reader.ReadByte(); processKeys(key, DOWN); break; case ENUMS.MESSAGETYPE.KEY_UP: ENUMS.SPECIALKEYS key2 = (ENUMS.SPECIALKEYS)reader.ReadByte(); processKeys(key2, UP); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_CLICK: mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_DOUBLE_CLICK: //双击左键 mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); Thread.Sleep(100); mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_DOWN: mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_LEFT_UP: mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_MOVE: int xdis = big2Small(reader.ReadInt32()); int ydis = big2Small(reader.ReadInt32()); mouse_event(MOUSEEVENTF_MOVE, xdis, ydis, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_CLICK: mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); Thread.Sleep(100); mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_DOUBLE_CLICK: //双击右键 mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); Thread.Sleep(100); mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_DOWN: mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_RIGHT_UP: mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case ENUMS.MESSAGETYPE.MOUSE_WHEEL: int wheel = big2Small(reader.ReadInt32()); mouse_event(MOUSEEVENTF_WHEEL, 0, 0, wheel, 0); break; case ENUMS.MESSAGETYPE.MOUSE_SET: int xPoint = big2Small(reader.ReadInt32()); int yPoint = big2Small(reader.ReadInt32()); //mouse_event(MOUSEEVENTF_ABSOLUTE, xPoint, yPoint, 0, 0); SetCursorPos(xPoint, yPoint); break; case ENUMS.MESSAGETYPE.START_PIC: mainForm.startSendPicFlags(); break; case ENUMS.MESSAGETYPE.STOP_PIC: mainForm.stopSendPicFlags(); break; case ENUMS.MESSAGETYPE.TEXT: int textLen = big2Small(reader.ReadInt32()); byte[] textByte = reader.ReadBytes(textLen); SendKeys.SendWait(Encoding.UTF8.GetString(textByte)); break; case ENUMS.MESSAGETYPE.BOARDKEY_DOWN: byte keyDown = reader.ReadByte(); keybd_event(keyDown, MapVirtualKey(keyDown, 0), KEYEVENTF_EXTENDEDKEY | 0, 0); break; case ENUMS.MESSAGETYPE.BOARDKEY_UP: byte keyUp = reader.ReadByte(); keybd_event(keyUp, MapVirtualKey(keyUp, 0), KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception("client is closed"); } }
/// <summary> /// Read line from GUI /// </summary> /// <returns></returns> /// <exception cref="InvalidOperationException"> /// Called if cannot readline from GUI</exception> protected static string ReadLine() { // Wait to readline return(ServerForm.ReadLine()); }
public TcpServers(ServerForm ParentForm) { this.ParentForm = ParentForm; }
public void TimingTerminalInfo(int type) { DateTime INow = DateTime.Now; XmlDocument xmlHeartDoc = new XmlDocument(); responseXML rHeart = new responseXML(); rHeart.SourceAreaCode = ServerForm.strSourceAreaCode; rHeart.SourceType = ServerForm.strSourceType; rHeart.SourceName = ServerForm.strSourceName; rHeart.SourceID = ServerForm.strSourceID; rHeart.sHBRONO = ServerForm.strHBRONO; string MediaSql = ""; string strSRV_ID = ""; string strSRV_CODE = ""; ServerForm.DeleteFolder(ServerForm.sHeartSourceFilePath);//删除原有XML发送文件的文件夹下的XML string frdStateName = ""; DataTable dtMedia = null; DataTable dtSrvMedia = null; List <Device> lDev = new List <Device>(); try { MediaSql = "select SRV_ID, SRV_CODE, SRV_GOOGLE, SRV_PHYSICAL_CODE, srv_detail, SRV_LOGICAL_CODE, SRV_RMT_STATUS, SRV_MFT_DATE, srv_updateDate,Terminal_SRV_MFT_DATE,terminal_updateDate from terminalMaintenanceView where deviceTypeId = '" + type + "' "; dtMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); if (dtMedia.Rows.Count == 0) { MediaSql = "select SRV.SRV_ID,SRV.SRV_CODE,SRV_GOOGLE, SRV_PHYSICAL_CODE,srv_detail,SRV_LOGICAL_CODE,SRV_MFT_DATE,updateDate,SRV_RMT_STATUS FROM SRV left join Srvtype on SRV.DeviceTypeId= Srvtype .srv_id where Srvtype.srv_id= " + type; dtSrvMedia = mainForm.dba.getQueryInfoBySQL(MediaSql); for (int idtM = 0; idtM < dtSrvMedia.Rows.Count; idtM++) { int srvId = Convert.ToInt32(dtSrvMedia.Rows[idtM]["SRV_ID"].ToString()); string TerminalState = dtSrvMedia.Rows[0]["SRV_RMT_STATUS"].ToString(); Device DV = new Device(); DV.SRV_ID = dtSrvMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtSrvMedia.Rows[idtM][1].ToString(); #region 自动添加逻辑编码 2018-01-10 string SRV_LOGICAL_CODE = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE"].ToString(); string areaId = dtMedia.Rows[idtM]["areaId"].ToString(); string SRV_LOGICAL_CODE_GB = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE_GB"].ToString(); int number = GetGBCodeCount(areaId, SRV_LOGICAL_CODE_GB); LogicalData logicaldata = new LogicalData(); logicaldata.srvID = dtMedia.Rows[idtM]["SRV_ID"].ToString(); logicaldata.srvAreaID = areaId; logicaldata.LogicalCode = SRV_LOGICAL_CODE; LogicalCoding.LogicalHelper logical = new LogicalCoding.LogicalHelper(logicaldata); if (number > 1) { SRV_LOGICAL_CODE_GB = logical.GetLogicalCodel(SRV_LOGICAL_CODE_GB); logical.UpdateLogicalCode(logicaldata.srvID, SRV_LOGICAL_CODE_GB); } if (string.IsNullOrEmpty(SRV_LOGICAL_CODE_GB) || SRV_LOGICAL_CODE_GB.Length != 23) { SRV_LOGICAL_CODE_GB = logical.GetLogicalAndAddDataBase(); if (string.IsNullOrEmpty(SRV_LOGICAL_CODE_GB)) { HttpServerFrom.SetManager("区域码有误请认真核对区域码", Color.Red); continue; } } if (!string.IsNullOrEmpty(SRV_LOGICAL_CODE_GB)) { if (!(SRV_LOGICAL_CODE_GB.Length == 23 && logical.GetCombAreaCode(SRV_LOGICAL_CODE_GB, areaId))) { SRV_LOGICAL_CODE_GB = logical.GetLogicalAndAddDataBase(); } } DV.DeviceID = SRV_LOGICAL_CODE_GB; #endregion DV.DeviceName = dtSrvMedia.Rows[idtM][4].ToString(); DV.Latitude = dtSrvMedia.Rows[idtM][2].ToString().Split(',')[0].Substring(0, 6); DV.Longitude = dtSrvMedia.Rows[idtM][2].ToString().Split(',')[1].Substring(0, 6);; DV.Srv_Mft_Date = dtSrvMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtSrvMedia.Rows[idtM]["updateDate"].ToString(); if (string.IsNullOrEmpty(DV.UpdateDate)) { DV.UpdateDate = "null"; } rHeart.AddTerminalMaintenance(DV); lDev.Add(DV); } } else { // MediaSql = "select top(99) SRV_ID,SRV_CODE,SRV_GOOGLE from SRV"; if (dtMedia != null && dtMedia.Rows.Count > 0) { for (int idtM = 0; idtM < dtMedia.Rows.Count; idtM++) { int srvId = Convert.ToInt32(dtMedia.Rows[idtM]["SRV_ID"].ToString()); string TerminalState = dtMedia.Rows[idtM]["SRV_RMT_STATUS"].ToString(); Device DV = new Device(); DV.SRV_ID = dtMedia.Rows[idtM][0].ToString(); strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); #region 自动添加逻辑编码 2018-01-10 string SRV_LOGICAL_CODE = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE"].ToString(); string areaId = dtMedia.Rows[idtM]["areaId"].ToString(); string SRV_LOGICAL_CODE_GB = dtMedia.Rows[idtM]["SRV_LOGICAL_CODE_GB"].ToString(); int number = GetGBCodeCount(areaId, SRV_LOGICAL_CODE_GB); LogicalData logicaldata = new LogicalData(); logicaldata.srvID = dtMedia.Rows[idtM]["SRV_ID"].ToString(); logicaldata.srvAreaID = areaId; logicaldata.LogicalCode = SRV_LOGICAL_CODE; LogicalCoding.LogicalHelper logical = new LogicalCoding.LogicalHelper(logicaldata); if (number > 1) { SRV_LOGICAL_CODE_GB = logical.GetLogicalCodel(SRV_LOGICAL_CODE_GB); logical.UpdateLogicalCode(logicaldata.srvID, SRV_LOGICAL_CODE_GB); } if (string.IsNullOrEmpty(SRV_LOGICAL_CODE_GB) || SRV_LOGICAL_CODE_GB.Length != 23) { SRV_LOGICAL_CODE_GB = logical.GetLogicalAndAddDataBase(); if (string.IsNullOrEmpty(SRV_LOGICAL_CODE_GB)) { HttpServerFrom.SetManager("区域码有误请认真核对区域码", Color.Red); continue; } } if (!string.IsNullOrEmpty(SRV_LOGICAL_CODE_GB)) { if (!(SRV_LOGICAL_CODE_GB.Length == 23 && logical.GetCombAreaCode(SRV_LOGICAL_CODE_GB, areaId))) { SRV_LOGICAL_CODE_GB = logical.GetLogicalAndAddDataBase(); } } DV.DeviceID = SRV_LOGICAL_CODE_GB; #endregion DV.DeviceName = dtMedia.Rows[idtM][4].ToString(); DV.Latitude = dtMedia.Rows[idtM][2].ToString().Split(',')[0]; if (DV.Latitude.Split('.')[1].Length > 6) { DV.Latitude = DV.Latitude.Split('.')[0] + "." + DV.Latitude.Split('.')[1].Substring(0, 6); } DV.Longitude = dtMedia.Rows[idtM][2].ToString().Split(',')[1]; if (DV.Longitude.Split('.')[1].Length > 6) { DV.Longitude = DV.Latitude.Split('.')[0] + "." + DV.Longitude.Split('.')[1].Substring(0, 6); } DV.Srv_Mft_Date = dtMedia.Rows[idtM]["SRV_MFT_DATE"].ToString(); DV.UpdateDate = dtMedia.Rows[idtM]["srv_updateDate"].ToString(); /// Terminal_SRV_MFT_DATE,terminal_updateDate DV.Old_Srv_Mft_Date = dtMedia.Rows[idtM]["Terminal_SRV_MFT_DATE"].ToString(); DV.Old_UpdateDate = dtMedia.Rows[idtM]["terminal_updateDate"].ToString(); if (!(DV.Srv_Mft_Date.IndexOf(DV.Old_Srv_Mft_Date) > -1)) { rHeart.UpdateTerminalMaintenance(DV); lDev.Add(DV); } else if (!string.IsNullOrEmpty(DV.UpdateDate) && !string.IsNullOrEmpty(DV.Old_UpdateDate)) { if (!(DV.UpdateDate.IndexOf(DV.Old_UpdateDate) > -1)) { rHeart.UpdateTerminalMaintenance(DV); lDev.Add(DV); } } else { continue; } } //string TrLL = dtMedia.Rows[idtM][2].ToString(); //Device DV = new Device(); //if (idtM < 10) //{ // DV.DeviceID = "0" + idtM; //} //else { DV.DeviceID = idtM.ToString(); } //strSRV_CODE = dtMedia.Rows[idtM][1].ToString(); //DV.DeviceID = strSRV_ID; //DV.DeviceName = strSRV_ID; //if (TrLL != "") //{ // string[] str = TrLL.Split(','); // if (str.Length >= 2) // { // DV.Longitude = str[1]; // DV.Latitude = str[0]; // } // else // { // DV.Longitude = "118.33"; // DV.Latitude = "33.95"; // } //} //else //{ // DV.Longitude = "118.33"; // DV.Latitude = "33.95"; //} } } if (lDev.Count > 0) { Random rdState = new Random(); frdStateName = "10" + rHeart.sHBRONO + GetSequenceCodes(); string xmlEBMStateFileName = "\\EBDB_" + frdStateName + ".xml"; xmlHeartDoc = rHeart.DeviceInfoResponse(lDev, frdStateName); CreateXML(xmlHeartDoc, ServerForm.sHeartSourceFilePath + xmlEBMStateFileName); ServerForm.mainFrm.GenerateSignatureFile(ServerForm.sHeartSourceFilePath, frdStateName); ServerForm.tar.CreatTar(ServerForm.sHeartSourceFilePath, ServerForm.sSendTarPath, frdStateName);//使用新TAR string sHeartBeatTarName = ServerForm.sSendTarPath + "\\" + "EBDT_" + frdStateName + ".tar"; send.address = ServerForm.sZJPostUrlAddress; send.fileNamePath = sHeartBeatTarName; SendTar.SendTarOrder.sendHelper.AddPostQueue(ServerForm.sZJPostUrlAddress, sHeartBeatTarName); } } catch { } Console.WriteLine((INow - DateTime.Now)); }