/// <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.Net.eTerm443Async SESSION, eTerm.AsyncSDK.Net.eTerm443Packet InPacket, eTerm.AsyncSDK.Net.eTerm443Packet OutPacket, eTerm.AsyncSDK.AsyncLicenceKey Key) { ContextInstance.Instance.providerName = Key.providerName; ContextInstance.Instance.connectionString = Key.connectionString; string ClientSession=SESSION.TSession.userName; string eTermSession=SESSION.userName; new Async_Log() { ASynCommand = Encoding.GetEncoding("gb2312").GetString(SESSION.UnInPakcet(OutPacket)), ASyncResult = Encoding.GetEncoding("gb2312").GetString(SESSION.UnOutPakcet(InPacket)), ClientSession=ClientSession, eTermSession = eTermSession, LogDate=DateTime.Now }.Add(); }
/// <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"))); }
/// <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) { 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> /// 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, "无该城市信息")); } }
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) { 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"))); }