static void Main(string[] args) { String y = YingRSA.EncryptString("Ying is Ying", "-----BEGIN RSA PRIVATE KEY-----\nMIIJKAIBAAKCAgEAwg1953V0NHFuE+vClZPpmFerk/xmF5ZvnctBQG9wbchhHHHP\nAiReBpeAmlLXF3nO8NEWyO9fXcUObv4/n8xi+QGE0DWwP6h+e/26A68bJsYBbYcx\nCEBAM7AxKEXyu++EVt3z5VltvDwT9j5V1RzEeymeyobeJuOpygYMqTu90H4SwVID\nJ5Pojjqq0XHrD76X5A0wkoyacXQ0stjNrOtUUAOKs4um7+7vLSCrN0ZrnXyBfMxC\nphyRxcnjLC+NMud68pyx2AiyaVwvPMTfPXt/oT5VmLDNqzwCaL+uaQFsGmwcwUU3\nz5DmOp0hNKPop5YedGlD9H4ntNpjk15L7p/g9m9UELN63k95VpFCRxt6LaoQ3yd+\ncrbdpoydtlM2JII7f/fBnhvbMzlVmR4qBcDsocxVjTd/iNwseGVK9SnN82fFSmKI\nDScJw8jkmh6St5VTNACxcw+oNQfppfP1YSTmIbQlMyGLCaUNwKkHorCoS/paRa9f\nYi3cuO3PhIdeaOqcSlQHXlle+3dh46rL84LUMUcmQv8BO6X9AU5nXrxbOTXn9ezz\nEbMJW+BQ6+Ureyp/KtJwQQFTZa/Rx/vdNgIJMnCPUod0GT042lA0gICirgy1oPFG\nwjZpIMmumprJSwUApIjebvtq5jqwEaX9gdZUPQsuIGAvhszLY073Ix8W+akCAwEA\nAQKCAgAy0/HchIlRizx3/1LSdxHCk4QfmQbsury1qh2HUSkzuD6ngq/kMb5nH5vR\n0E0Cmyc3MK01KG3kU886B2KG6rQp4Nn253ko02t98rGccWs9NrP9CmIvdRTb9RSL\nJfc0fsI9NpnBwzDZEytvXliBH63fTMGI7taVfSBmCDucwEcxqzQiaubkoPtS9c70\nWVBmqVeDpmjImgeCHBwJlHwbBPDqnGLiMHwjcIQ5X8s5CTr63zfThnUWqXkNQ5o7\nYqErajJsBdsXaP/CVSESW8bVhdmiVH97JSRZ67f90+dNHdBB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ZfAEUNlV5HBTUAIt0vuAjIWiMgu4SAYIs=\n-----END RSA PRIVATE KEY-----\n"); Console.WriteLine(y); y = YingRSA.DecryptString(y, "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwg1953V0NHFuE+vClZPp\nmFerk/xmF5ZvnctBQG9wbchhHHHPAiReBpeAmlLXF3nO8NEWyO9fXcUObv4/n8xi\n+QGE0DWwP6h+e/26A68bJsYBbYcxCEBAM7AxKEXyu++EVt3z5VltvDwT9j5V1RzE\neymeyobeJuOpygYMqTu90H4SwVIDJ5Pojjqq0XHrD76X5A0wkoyacXQ0stjNrOtU\nUAOKs4um7+7vLSCrN0ZrnXyBfMxCphyRxcnjLC+NMud68pyx2AiyaVwvPMTfPXt/\noT5VmLDNqzwCaL+uaQFsGmwcwUU3z5DmOp0hNKPop5YedGlD9H4ntNpjk15L7p/g\n9m9UELN63k95VpFCRxt6LaoQ3yd+crbdpoydtlM2JII7f/fBnhvbMzlVmR4qBcDs\nocxVjTd/iNwseGVK9SnN82fFSmKIDScJw8jkmh6St5VTNACxcw+oNQfppfP1YSTm\nIbQlMyGLCaUNwKkHorCoS/paRa9fYi3cuO3PhIdeaOqcSlQHXlle+3dh46rL84LU\nMUcmQv8BO6X9AU5nXrxbOTXn9ezzEbMJW+BQ6+Ureyp/KtJwQQFTZa/Rx/vdNgIJ\nMnCPUod0GT042lA0gICirgy1oPFGwjZpIMmumprJSwUApIjebvtq5jqwEaX9gdZU\nPQsuIGAvhszLY073Ix8W+akCAwEAAQ==\n-----END PUBLIC KEY-----\n"); Console.WriteLine(y); Console.ReadKey(); }
public static void Ying() { yrouter.yget("/yingyggdrasil/", (yrequest) => new YingResponse(".json", JsonMapper.ToJson(new iYing { meta = new iYingMeta { serverName = "Ying Sakura City", implementationName = "Ying Yggdrasil Server", implementationVersion = "6.0.4.0" }, skinDomains = new List <String> { "zyy.com:6040", "iying.top:6040" }, signaturePublickey = "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwg1953V0NHFuE+vClZPp\nmFerk/xmF5ZvnctBQG9wbchhHHHPAiReBpeAmlLXF3nO8NEWyO9fXcUObv4/n8xi\n+QGE0DWwP6h+e/26A68bJsYBbYcxCEBAM7AxKEXyu++EVt3z5VltvDwT9j5V1RzE\neymeyobeJuOpygYMqTu90H4SwVIDJ5Pojjqq0XHrD76X5A0wkoyacXQ0stjNrOtU\nUAOKs4um7+7vLSCrN0ZrnXyBfMxCphyRxcnjLC+NMud68pyx2AiyaVwvPMTfPXt/\noT5VmLDNqzwCaL+uaQFsGmwcwUU3z5DmOp0hNKPop5YedGlD9H4ntNpjk15L7p/g\n9m9UELN63k95VpFCRxt6LaoQ3yd+crbdpoydtlM2JII7f/fBnhvbMzlVmR4qBcDs\nocxVjTd/iNwseGVK9SnN82fFSmKIDScJw8jkmh6St5VTNACxcw+oNQfppfP1YSTm\nIbQlMyGLCaUNwKkHorCoS/paRa9fYi3cuO3PhIdeaOqcSlQHXlle+3dh46rL84LU\nMUcmQv8BO6X9AU5nXrxbOTXn9ezzEbMJW+BQ6+Ureyp/KtJwQQFTZa/Rx/vdNgIJ\nMnCPUod0GT042lA0gICirgy1oPFGwjZpIMmumprJSwUApIjebvtq5jqwEaX9gdZU\nPQsuIGAvhszLY073Ix8W+akCAwEAAQ==\n-----END PUBLIC KEY-----\n" } ))).ypost("/yingyggdrasil/authserver/authenticate", (yrequest) => { YingAuthenticateRequest yauthinfo = JsonConvert.DeserializeObject <YingAuthenticateRequest>(new StreamReader(yrequest.InputStream).ReadToEnd()); YingAuthenticateResult yresult = YingAuthenticate.yauthenticate(yauthinfo.username, yauthinfo.password); if (!yresult.ysuccess) { throw YingException.Ying(yresult.ytype); } String yaccessToken = Guid.NewGuid().ToString("N"); if (yauthinfo.clientToken == null) { yauthinfo.clientToken = Guid.NewGuid().ToString("N"); } getYDataBaseManager().getYConnection().Insert(new zyy_yggdrasil_tokens { yemail = yauthinfo.username, yclientToken = yauthinfo.clientToken, yaccessToken = yaccessToken, ytime = getYTimeStamp().TotalMilliseconds }); String[] yprofiles = JsonConvert.DeserializeObject <String[]>(yresult.yuser.yprofiles); String yprofileId = yprofiles.FirstOrDefault(); zyy_yggdrasil_profile yprofile = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_profile>() where y.yyid == yprofileId select y).FirstOrDefault(); zyy_yggdrasil_texture ytexture = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_texture>() where y.ytextureid == yprofile.ytextureid select y).FirstOrDefault(); YingProfile yyy = new YingProfile { id = yprofile.yyid, name = yprofile.yname, properties = new List <YingPropertie> { new YingPropertie { name = "textures", value = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingTexture { timestamp = ytexture.ytimestamp, profileId = yprofile.yyid, profileName = yprofile.yname, textures = new Dictionary <String, YingTextureInfo> { { "SKIN", new YingTextureInfo() { url = ytexture.yskin, metadata = new Dictionary <String, String> { { "model", ytexture.yskinmetadata } } } } } }))), signature = null } } }; return(new YingResponse(".json", JsonConvert.SerializeObject(new iYingAuthenticate { accessToken = yaccessToken, clientToken = yauthinfo.clientToken, availableProfiles = new List <YingProfile> { yyy }, selectedProfile = yyy, user = new YingUser { id = yresult.yuser.yopenid, properties = new List <YingPropertie> { new YingPropertie { name = "preferredLanguage", value = "zh_CN" } } } }))); }).ypost("/yingyggdrasil/authserver/refresh", (yrequest) => { YingRefresh yinfo = JsonMapper.ToObject <YingRefresh>(new StreamReader(yrequest.InputStream).ReadToEnd()); YingAuthenticateResult yresult = YingAuthenticate.yrefresh(yinfo.accessToken, yinfo.clientToken); if (yresult.ysuccess) { throw new YingHttpException((int)HttpStatusCode.NoContent, $"Ying {HttpStatusCode.NoContent.GetDescription()}"); } else { String[] yprofiles = JsonConvert.DeserializeObject <String[]>(yresult.yuser.yprofiles); String yprofileId = yprofiles.FirstOrDefault(); zyy_yggdrasil_profile yprofile = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_profile>() where y.yyid == yprofileId select y).FirstOrDefault(); zyy_yggdrasil_texture ytexture = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_texture>() where y.ytextureid == yprofile.ytextureid select y).FirstOrDefault(); return(new YingResponse(".json", JsonConvert.SerializeObject(new YingRefreshResponse { accessToken = yresult.ytoken.yaccessToken, clientToken = yresult.ytoken.yclientToken, selectedProfile = new YingProfile { id = yprofile.yyid, name = yprofile.yname, properties = new List <YingPropertie> { new YingPropertie { name = "textures", value = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingTexture { timestamp = ytexture.ytimestamp, profileId = yprofile.yyid, profileName = yprofile.yname, textures = new Dictionary <String, YingTextureInfo> { { "SKIN", new YingTextureInfo() { url = ytexture.yskin, metadata = new Dictionary <String, String> { { "model", ytexture.yskinmetadata } } } } } }))), signature = null } } }, user = new YingUser { id = yresult.yuser.yopenid, properties = new List <YingPropertie> { new YingPropertie { name = "preferredLanguage", value = "zh_CN" } } } }))); } }).ypost("/yingyggdrasil/authserver/validate", (yrequest) => { YingValidate yinfo = JsonMapper.ToObject <YingValidate>(new StreamReader(yrequest.InputStream).ReadToEnd()); YingAuthenticateResult yresult = YingAuthenticate.yvalidate(yinfo.accessToken, yinfo.clientToken); if (yresult.ysuccess) { throw new YingHttpException((int)HttpStatusCode.NoContent, $"Ying {HttpStatusCode.NoContent.GetDescription()}"); } throw YingException.Ying(YingExceptionTypes.YingInvalidToken); /* * HttpListenerRequest yrequest = y.Request; * HttpListenerResponse yresponse = y.Response; * YingValidate yinfo = JsonMapper.ToObject<YingValidate>(new StreamReader(yrequest.InputStream).ReadToEnd()); * if(yinfo.clientToken == null) * { * if (getYDataBaseManager().getYConnection().Find<zyy_yggdrasil_tokens>(1).yaccessToken == yinfo.accessToken) ; * * } * * YingRouter.YResponseBuilder(y.Response, new YingResponseInfo * { * YStatusCode = HttpStatusCode.Forbidden, * YStatusDescription = "Ying Forbidden", * * YContentType = YingMimeMapping.YGetMimeType(".json"), * YContentEncoding = Encoding.UTF8 * }); * * yresponse.WriteContent(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingError * { * error = "Ying Error", * errorMessage = "Ying Invaild Token", * cause = "Ying Test Error" * }))); */ }).ypost("/yingyggdrasil/authserver/signout", (yrequest) => { YingSignout yinfo = JsonMapper.ToObject <YingSignout>(new StreamReader(yrequest.InputStream).ReadToEnd()); if (YingAuthenticate.ysignout(yinfo.username, yinfo.password)) { throw new YingHttpException((int)HttpStatusCode.NoContent, $"Ying {HttpStatusCode.NoContent.GetDescription()}"); } else { throw YingException.Ying(YingExceptionTypes.YingInvalidUsernameOrPassword); } }).ypost("/yingyggdrasil/authserver/invalidate", (yrequest) => { YingValidate yinfo = JsonMapper.ToObject <YingValidate>(new StreamReader(yrequest.InputStream).ReadToEnd()); YingAuthenticate.yinvalidate(yinfo.accessToken, yinfo.clientToken); throw new YingHttpException((int)HttpStatusCode.NoContent, $"Ying {HttpStatusCode.NoContent.GetDescription()}"); }).ypost("/yingyggdrasil/sessionserver/session/minecraft/join", (yrequest) => { YingJoin yyjoin = JsonMapper.ToObject <YingJoin>(new StreamReader(yrequest.InputStream).ReadToEnd()); yyjoin.yip = yrequest.UserHostAddress; yyjoin.ytime = getYTimeStamp(); yjoin.Add(yyjoin.serverId, yyjoin); throw new YingHttpException((int)HttpStatusCode.NoContent, $"Ying {HttpStatusCode.NoContent.GetDescription()}"); }).yget("/yingyggdrasil/sessionserver/session/minecraft/hasJoined*", (yrequest) => { NameValueCollection yquery = yrequest.QueryString; String yusername = yquery.Get("username"); String yserverId = yquery.Get("serverId"); String yip = yquery.Get("ip"); if (yjoin.ContainsKey(yserverId)) { String yselectedProfile = yjoin[yserverId].selectedProfile; zyy_yggdrasil_profile yprofile = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_profile>() where y.yyid == yselectedProfile select y).FirstOrDefault(); zyy_yggdrasil_texture ytexture = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_texture>() where y.ytextureid == yprofile.ytextureid select y).FirstOrDefault(); String yvalue = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingTexture { timestamp = ytexture.ytimestamp, profileId = yprofile.yyid, profileName = yprofile.yname, textures = new Dictionary <String, YingTextureInfo> { { "SKIN", new YingTextureInfo() { url = ytexture.yskin, metadata = new Dictionary <String, String> { { "model", ytexture.yskinmetadata } } } } } }))); return(new YingResponse(".json", JsonConvert.SerializeObject(new YingProfile { id = yprofile.yyid, name = yprofile.yname, properties = new List <YingPropertie> { new YingPropertie { name = "textures", value = yvalue, signature = YingRSA.EncryptString(yvalue, "-----BEGIN RSA PRIVATE KEY-----\nMIIJKAIBAAKCAgEAwg1953V0NHFuE+vClZPpmFerk/xmF5ZvnctBQG9wbchhHHHP\nAiReBpeAmlLXF3nO8NEWyO9fXcUObv4/n8xi+QGE0DWwP6h+e/26A68bJsYBbYcx\nCEBAM7AxKEXyu++EVt3z5VltvDwT9j5V1RzEeymeyobeJuOpygYMqTu90H4SwVID\nJ5Pojjqq0XHrD76X5A0wkoyacXQ0stjNrOtUUAOKs4um7+7vLSCrN0ZrnXyBfMxC\nphyRxcnjLC+NMud68pyx2AiyaVwvPMTfPXt/oT5VmLDNqzwCaL+uaQFsGmwcwUU3\nz5DmOp0hNKPop5YedGlD9H4ntNpjk15L7p/g9m9UELN63k95VpFCRxt6LaoQ3yd+\ncrbdpoydtlM2JII7f/fBnhvbMzlVmR4qBcDsocxVjTd/iNwseGVK9SnN82fFSmKI\nDScJw8jkmh6St5VTNACxcw+oNQfppfP1YSTmIbQlMyGLCaUNwKkHorCoS/paRa9f\nYi3cuO3PhIdeaOqcSlQHXlle+3dh46rL84LUMUcmQv8BO6X9AU5nXrxbOTXn9ezz\nEbMJW+BQ6+Ureyp/KtJwQQFTZa/Rx/vdNgIJMnCPUod0GT042lA0gICirgy1oPFG\nwjZpIMmumpr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ZnsEQjPNlFZWgLXqbXCxwG9U2cCggEBAMkrEOR88IJ2Bni3gC6MK7vT1Ax5\nFku7BwbTT5WyA2S/NcMqR4EIdFpfmAOI+2Dlaj2z/S1cEF2OM/FTnrNDDDXNLJau\n9pePwk20b3RFN+Nuz+gp4/Iew1sACaPPsrX4Fqa/dEywv7bElTM24EBLfBbMGegG\noMGcpcIY7lueNZq8PkAyWU/VR5CRMK6vrDrKFhHZ1eCi8VqfPx/t6TS7BkiGsTeQ\nRivmzdVryxDcqyswtM8g+oup5ITXCHDd45Vfc5hFfHgPHhVJuvkUGbfr7gN1hPiu\nz/v8CviBekMq0hT1VpDXEkS4CSZfAEUNlV5HBTUAIt0vuAjIWiMgu4SAYIs=\n-----END RSA PRIVATE KEY-----\n") } } }))); } else { throw new YingHttpException((int)HttpStatusCode.NoContent, $"Ying {HttpStatusCode.NoContent.GetDescription()}"); } }, true).yget("/yingyggdrasil/sessionserver/session/minecraft/profile/([a-zA-Z0-9]+)", (yrequest) => { String yuuid = yrequest.RawUrl.Replace("/yingyggdrasil/sessionserver/session/minecraft/profile/", ""); zyy_yggdrasil_profile yprofile = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_profile>() where y.yyid == yuuid select y).FirstOrDefault(); zyy_yggdrasil_texture ytexture = (from y in getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_texture>() where y.ytextureid == yprofile.ytextureid select y).FirstOrDefault(); return(new YingResponse(".json", JsonConvert.SerializeObject(new YingProfile { id = yprofile.yyid, name = yprofile.yname, properties = new List <YingPropertie> { new YingPropertie { name = "textures", value = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingTexture { timestamp = ytexture.ytimestamp, profileId = yprofile.yyid, profileName = yprofile.yname, textures = new Dictionary <String, YingTextureInfo> { { "SKIN", new YingTextureInfo() { url = ytexture.yskin, metadata = new Dictionary <String, String> { { "model", ytexture.yskinmetadata } } } } } }))), signature = null } } }))); }, true).yget("/yingyggdrasil/ytextures/([a-zA-Z0-9]+)", (yrequest) => { String yuuid = yrequest.RawUrl.Replace("/yingyggdrasil/ytextures/", ""); Byte[] ytexture = null; try { ytexture = File.ReadAllBytes(Path.Combine(getYFiles().getYTextures().FullName, $"{yuuid}.png")); } catch (Exception yexception) { throw new YingHttpException(404, "Ying Textures Not Found"); } return(new YingResponse(".png", ytexture)); }, true); /*yrouter.ypost("/yingyggdrasil/authserver/refresh", (yrequest, yresponse) => * { * * YingRefresh yinfo = JsonMapper.ToObject<YingRefresh>(new StreamReader(yrequest.InputStream).ReadToEnd()); * * * YingResult yresult = YingAuthenticate.yrefresh(yinfo.accessToken, yinfo.clientToken); * if (yresult.ysuccess) * { * * String yaccessToken = Guid.NewGuid().ToString("N"); * * getYDataBaseManager().getYConnection().Insert(new zyy_yggdrasil_tokens * { * yusername = yresult.ytoken.yusername, * * yclientToken = yresult.ytoken.yclientToken, * yaccessToken = yaccessToken, * * ytime = getYTimeStamp() * }); * * YingRouter.YResponseBuilder(yresponse, new YingResponseInfo * { * YStatusCode = HttpStatusCode.NoContent, * YStatusDescription = $"Ying {HttpStatusCode.NoContent.GetDescription()}", * * YContentType = YingMimeMapping.YGetMimeType(".json"), * YContentEncoding = Encoding.UTF8 * }); * * * yresponse.WriteContent(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingRefreshResponse * { * accessToken = yaccessToken, * clientToken = yresult.ytoken.yclientToken, * * selectedProfile = yyy, * * user = new YingUser * { * id = Guid.NewGuid().ToString("N"), * properties = new List<YingPropertie> * { * new YingPropertie { * name = "preferredLanguage", * value = "zh_CN" * } * } * } * }))); * * * * } * * * * * }); * * yrouter.ypost("/yingyggdrasil/authserver/validate", (yrequest, yresponse) => * { * YingValidate yinfo = JsonMapper.ToObject<YingValidate>(new StreamReader(yrequest.InputStream).ReadToEnd()); * * YingResult yresult = YingAuthenticate.yvalidate(yinfo.accessToken, yinfo.clientToken); * if (yresult.ysuccess) * { * YingRouter.YResponseBuilder(yresponse, new YingResponseInfo * { * YStatusCode = HttpStatusCode.NoContent, * YStatusDescription = $"Ying {HttpStatusCode.NoContent.GetDescription()}", * * YContentType = YingMimeMapping.YGetMimeType(".json"), * YContentEncoding = Encoding.UTF8 * }); * } * * /* * HttpListenerRequest yrequest = y.Request; * HttpListenerResponse yresponse = y.Response; * YingValidate yinfo = JsonMapper.ToObject<YingValidate>(new StreamReader(yrequest.InputStream).ReadToEnd()); * if(yinfo.clientToken == null) * { * if (getYDataBaseManager().getYConnection().Find<zyy_yggdrasil_tokens>(1).yaccessToken == yinfo.accessToken) ; * * } * * YingRouter.YResponseBuilder(y.Response, new YingResponseInfo * { * YStatusCode = HttpStatusCode.Forbidden, * YStatusDescription = "Ying Forbidden", * * YContentType = YingMimeMapping.YGetMimeType(".json"), * YContentEncoding = Encoding.UTF8 * }); * * yresponse.WriteContent(Encoding.UTF8.GetBytes(JsonMapper.ToJson(new YingError * { * error = "Ying Error", * errorMessage = "Ying Invaild Token", * cause = "Ying Test Error" * }))); *//* * * * }); * * yrouter.ypost("/yingyggdrasil/authserver/invalidate", (yrequest, yresponse) => { }); * yrouter.ypost("/yingyggdrasil/authserver/signout", (yrequest, yresponse) => { }); * * yrouter.ypost("/yingyggdrasil/sessionserver/session/minecraft/join", (yrequest, yresponse) => { }); * yrouter.yget("/yingyggdrasil/sessionserver/session/minecraft/hasJoined?username={username}&serverId={serverId}&ip={ip}", (yrequest, yresponse) => { }); * yrouter.yget("/yingyggdrasil/sessionserver/session/minecraft/profile/{uuid}?unsigned={unsigned}", (yrequest, yresponse) => { }); * * yrouter.ypost("/yingyggdrasil/api/profiles/minecraft", (yrequest, yresponse) => { });*/ //Guid.NewGuid().ToString("N"); ytimer.Tick += (ysender, yevent) => { //if(getYDataBaseManager().getYConnection().) TableQuery <zyy_yggdrasil_tokens> yquery = getYDataBaseManager().getYConnection().Table <zyy_yggdrasil_tokens>(); yquery.ToList().ForEach((y) => { if (y.ytime < getYTimeStamp().TotalMilliseconds - new TimeSpan(14, 6, 0, 4).TotalMilliseconds) { getYDataBaseManager().getYConnection().Delete <zyy_yggdrasil_tokens>(y.yid); } }); }; ytimer.Start(); }