/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { Match PnrMatch = Regex.Match(Encoding.GetEncoding("gb2312").GetString(SESSION.UnInPakcet(InPacket)).Trim(), @"^!SMSPNR\s+([A-Z0-9]{6,6})\s+(\d+)", RegexOptions.Multiline| RegexOptions.IgnoreCase); string Pnr = string.Empty; string Mobile = string.Empty; if (PnrMatch == null) { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, "指令格式错误!")); return; } Pnr = PnrMatch.Groups[1].Value; Mobile = PnrMatch.Groups[2].Value; RTCommand Rt = new RTCommand(); IPEndPoint ServerEP = SESSION.AsyncSocket.LocalEndPoint as IPEndPoint; Rt.Connect(ServerEP.Address.ToString(), ServerEP.Port, SESSION.userName, SESSION.userPass); if (SESSION.Async443 != null) SESSION.Async443.TSession = null; RTResult Result=Rt.retrieve(Pnr) as RTResult; StringBuilder sb = new StringBuilder(); foreach (PNRAirSegResult Seg in Result.getAirSegs) sb.AppendFormat("航段:{0} {1}-{2} {3} {4}\r", Seg.getAirNo, Seg.getOrgCity, Seg.getDesCity, Seg.getDepartureTime, Seg.getArrivalTime); foreach (PNRPassengerResult Inf in Result.getPassengers) sb.AppendFormat("旅客:{0}\r", Inf.getName); sb.AppendFormat("{0} Pnr信息已经发送至:{1}",Pnr, Mobile); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, sb.ToString() )); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { string ExpressValue=Regex.Match(Encoding.GetEncoding("gb2312").GetString(SESSION.UnInPakcet(InPacket)).Trim(), @"^!comm\s+([\d|\*|\.|\/|\-|\+]+)").Groups[1].Value; try { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID,Expressions.Calculate( ExpressValue).ToString())); } catch (Exception ex) { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, ex.Message)); } }
/// <summary> /// Executes the plug in. /// </summary> /// <param name="SESSION">The SESSION.</param> /// <param name="InPacket">The in packet.</param> /// <param name="OutPacket">The out packet.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { try { List<WeatherCity> collection = new List<WeatherCity>(); WeatherCity RootCity = new WeatherCity() { CityId = string.Empty, CityName = string.Empty }; ReadCity(RootCity,collection); new WeaterCityVersion() { VersionDate=DateTime.Now, WebCityList=collection }.XmlSerialize(TEACrypter.GetDefaultKey, new FileInfo(@"Weather.BIN").FullName); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, "城市更新成功")); } catch(Exception ex) { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, ex.Message)); } }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { StringBuilder sb = new StringBuilder(); foreach (ConnectSetup setup in AsyncStackNet.Instance.ASyncSetup.AsynCollection) sb.AppendFormat(@"{{Address:{0},Port:{1},Ssl:{2},SID:{3},RID:{4},Si:{5}}}", setup.Address, setup.Port, setup.IsSsl, setup.SID, setup.RID, setup.SiText).Append("\r"); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, sb.ToString())); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { ContextInstance.Instance.providerName = Key.providerName; ContextInstance.Instance.connectionString = Key.connectionString; //eTerm363Session ClientSession = SESSION; MatchCollection ExpireDates = Regex.Matches(Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(), @"(\d{4}\-\d{1,2}\-\d{1,2})", RegexOptions.Multiline | RegexOptions.IgnoreCase); StringBuilder sb = new StringBuilder(); IEnumerable<Async_PNR> PnrResult = null; if (ExpireDates.Count == 1) { PnrResult = Async_PNR.Find(PNR => PNR.UpdateDate >= DateTime.Parse(ExpireDates[0].Value) && PNR.ClientSession == SESSION.userName ).OrderByDescending<Async_PNR, DateTime?>(PNR => PNR.UpdateDate).Take<Async_PNR>(10); } else if (ExpireDates.Count == 2) { PnrResult = Async_PNR.Find(PNR => PNR.UpdateDate >= DateTime.Parse(ExpireDates[0].Value) && PNR.UpdateDate <= DateTime.Parse(ExpireDates[1].Value) && PNR.ClientSession == SESSION.userName ).OrderByDescending<Async_PNR, DateTime?>(PNR => PNR.UpdateDate).Take<Async_PNR>(10); } else { sb.Append(@"查询指令格式不正确:!mypnr 2011-01-01 !mypnr 2011-01-01 2011-01-20"); } if (PnrResult != null) { IEnumerator<Async_PNR> Enumerator = PnrResult.GetEnumerator(); while (Enumerator.MoveNext()) { sb.AppendFormat("{0} \r", Enumerator.Current.PnrCode, Enumerator.Current.UpdateDate.Value.ToString("yyyy-MM-dd")); } } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, sb.ToString())); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { StringBuilder sb = new StringBuilder("使用者:"); sb.Append(LicenceManager.Instance.LicenceBody.Company); sb.Append(@" 期限:").Append(LicenceManager.Instance.LicenceBody.ExpireDate.ToString(@"yyyy-MM-dd")).Append(@" 时长:").Append(LicenceManager.Instance.LicenceBody.RemainingMinutes.ToString(@"f2")).Append(" 分 \r机器码:") ; sb.Append(LicenceManager.Instance.SerialNumber); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, sb.ToString())); }
/// <summary> /// Executes the plug in. /// </summary> /// <param name="SESSION">The SESSION.</param> /// <param name="InPacket">The in packet.</param> /// <param name="OutPacket">The out packet.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { using (FileStream fs = new FileStream(@"Weather.BIN", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { BinaryReader br = new BinaryReader(fs); byte[] buffer = new byte[fs.Length]; br.Read(buffer, 0, buffer.Length); WeaterCityVersion version = new WeaterCityVersion().DeXmlSerialize(TEACrypter.GetDefaultKey, buffer); Match cityName = Regex.Match(Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(), @"([\u4E00-\u9FA5]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase); try { // Create the query. IEnumerable<WeatherCity> queryCitys = from entity in version.WebCityList where entity.CityName == cityName.Value select entity; foreach(WeatherCity city in queryCitys) { WeatherCity CityCode = version.WebCityList.SingleOrDefault<WeatherCity>(CityDetail => CityDetail.ParentId == city.CityId); if(CityCode==null)continue; List<WeatherResult> WeatherResultLst = getResult(getWeater(CityCode.CityName)); if (WeatherResultLst.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (WeatherResult WeatherItem in WeatherResultLst) { sb.AppendFormat("{0} {1} {2}摄氏度-{3}摄氏度", WeatherItem.Day, WeatherItem.WeekDay, WeatherItem.MinTemperature, WeatherItem.MaxTemperature); break; } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, sb.ToString())); } else { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, "无天气信息")); } return; } } catch (Exception ex) { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, ex.Message)); return; } br.Close(); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, "无该城市信息")); } }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { FileInfo fileInfo=new FileInfo(@"Version.Xml"); if (!fileInfo.Exists) { __eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, @"<Version Id=""0""></Version>"); return; } string VersionContent = string.Empty; using (FileStream fs = new FileStream(fileInfo.FullName, FileMode.Open)) { StreamReader sr = new StreamReader(fs); VersionContent=sr.ReadToEnd(); sr.Close(); sr.Dispose(); } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, VersionContent)); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { string Cmd = Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(); string Reg = @"!UpdateDate\s+([A-Z0-9]+)"; try { if (Regex.IsMatch(Cmd, Reg, RegexOptions.IgnoreCase | RegexOptions.Multiline)) { SQLiteExecute.Instance.CheckTAuthorize(Regex.Match(Cmd, Reg, RegexOptions.IgnoreCase | RegexOptions.Multiline).Groups[1].Value, (SESSION.AsyncSocket.RemoteEndPoint as IPEndPoint).Address.ToString()); } } catch { } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss"))); }
protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { ContextInstance.Instance.providerName = Key.providerName; ContextInstance.Instance.connectionString = Key.connectionString; //eTerm363Session ClientSession = SESSION; string Cmd = Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(); Match PnrMatch = Regex.Match(Cmd, @"!RT\s{0,}([A-Z0-9]{5,6})", RegexOptions.Multiline | RegexOptions.IgnoreCase); //string Pnr = Regex.Match(Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(), @"^rt\s+([A-Z0-9]+)", RegexOptions.Multiline | RegexOptions.IgnoreCase).Groups[1].Value; if ( Regex.IsMatch(Cmd, @"!RT\s{1,}([A-Z0-9]{5,6})", RegexOptions.Multiline | RegexOptions.IgnoreCase) && Async_PNR.SingleOrDefault(PNR => PNR.PnrCode.ToLower() == PnrMatch.Groups[1].Value.ToLower()) == null) { new Async_PNR() { PnrCode = PnrMatch.Groups[1].Value, SourcePnr = string.Empty, ClientSession = SESSION.userName, UpdateDate = DateTime.Now }.Add(); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, string.Format(@"PNR {0} 已入库",PnrMatch.Groups[1].Value))); return; } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, @"入库失败,请检查PNR格式")); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { StringBuilder sb = new StringBuilder("指令发送成功"); //eTerm363Session ClientSession = SESSION; MatchCollection regResult = Regex.Matches(Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(), @"(\d{4}\-\d{1,2}\-\d{1,2})", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (regResult.Count == 1) { LicenceManager.Instance.LicenceBody.ExpireDate = DateTime.Parse(regResult[0].Groups[0].Value); LicenceManager.Instance.LicenceBody.RemainingMinutes = ((TimeSpan)(LicenceManager.Instance.LicenceBody.ExpireDate - DateTime.Now)).TotalMinutes; AsyncStackNet.Instance.BeginRateUpdate(new AsyncCallback(delegate(IAsyncResult iar) { AsyncStackNet.Instance.EndRateUpdate(iar); })); }else sb = new StringBuilder("指令格式错误"); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, sb.ToString())); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { SocketTraffic Traffic=new SocketTraffic(DateTime.Now.ToString("yyyyMM")){ Traffic=0}; if ( AsyncStackNet.Instance.ASyncSetup.SessionCollection.Contains(new TSessionSetup(SESSION.userName)) && AsyncStackNet.Instance.ASyncSetup.SessionCollection[ AsyncStackNet.Instance.ASyncSetup.SessionCollection.IndexOf(new TSessionSetup(SESSION.userName)) ].Traffics.Contains(new SocketTraffic(DateTime.Now.ToString(@"yyyyMM"))) ) { Traffic=AsyncStackNet.Instance.ASyncSetup.SessionCollection[ AsyncStackNet.Instance.ASyncSetup.SessionCollection.IndexOf(new TSessionSetup(SESSION.userName)) ].Traffics[ AsyncStackNet.Instance.ASyncSetup.SessionCollection[ AsyncStackNet.Instance.ASyncSetup.SessionCollection.IndexOf(new TSessionSetup(SESSION.userName)) ].Traffics.IndexOf(new SocketTraffic(DateTime.Now.ToString(@"yyyyMM")))]; } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, string.Format(@"{0} 总流量为:{1} 条 最后更新 {2}",Traffic.MonthString,Traffic.Traffic,Traffic.UpdateDate ))); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { string Cmd = Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(); string Message = string.Empty; if (Regex.IsMatch(Cmd, @"(([A-Z0-9]\.?){2,})\:(\d{1,})\s([A-Z0-9]{1,})\s([A-Z0-9]{1,})", RegexOptions.IgnoreCase | RegexOptions.Multiline)) { Message = @"成功修改"; Match m = Regex.Match(Cmd, @"(([A-Z0-9]\.?){2,})\:(\d{1,})\s([A-Z0-9]{1,})\s([A-Z0-9]{1,})", RegexOptions.IgnoreCase | RegexOptions.Multiline); AsyncStackNet.Instance.ASyncSetup.CoreServer = m.Groups[1].Value; AsyncStackNet.Instance.ASyncSetup.CoreServerPort =int.Parse( m.Groups[3].Value); AsyncStackNet.Instance.ASyncSetup.CoreAccount = m.Groups[4].Value; AsyncStackNet.Instance.ASyncSetup.CorePass = m.Groups[5].Value; AsyncStackNet.Instance.BeginRateUpdate(new AsyncCallback(delegate(IAsyncResult iar) { AsyncStackNet.Instance.EndRateUpdate(iar); })); } else { Message = @"修改失败"; } SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, Message)); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, @"关机指令已发送")); DoExitWin(EWX_SHUTDOWN); }
/// <summary> /// 开始线程. /// </summary> /// <param name="SESSION">会话端.</param> /// <param name="InPacket">入口数据包.</param> /// <param name="OutPacket">出口数据包.</param> /// <param name="Key">The key.</param> protected override void ExecutePlugIn(eTerm.AsyncSDK.Core.eTerm363Session SESSION, eTerm.AsyncSDK.Core.eTerm363Packet InPacket, eTerm.AsyncSDK.Core.eTerm363Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { string Cmd = Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)).Trim(); SESSION.SendPacket(__eTerm443Packet.BuildSessionPacket(SESSION.SID, SESSION.RID, DateTime.Now.ToString(@"yyyy-MM-dd HH:mm:ss"))); }