public void runRules_TwoReviewsOneRule() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "comments", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "positiveOne", Weight = 1 }, new KeyWeight() { Keyword = "negativeOne", Weight = -1 }, new KeyWeight() { Keyword = "positiveTwo", Weight = 2 } } } }; JsonAnalyzer <Review> analyzer = new JsonAnalyzer <Review>(rules); ReviewCollection mockCollection = new ReviewCollection() { dealerId = "12345", ratingURl = "test/ratings", name = "testDealer", reviewCount = 1, reviews = new List <Review>() { new Review() { id = "001", dateWritten = "01/19/2021", comments = "positiveOne positiveOne positiveOne positiveOne positiveTwo " + "positiveTwo negativeOne negativeOne negativeOne negativeOne negativeOne" }, new Review() { id = "002", dateWritten = "01/19/2021", comments = "positiveOne positiveOne positiveOne positiveOne positiveTwo " + "positiveTwo negativeOne negativeOne negativeOne negativeOne negativeOne" } } }; analyzer.runRules(JsonConvert.SerializeObject(mockCollection.reviews)); KeyValuePair <Review, int> review = analyzer.getTop(2)[0]; Assert.AreEqual(3, review.Value); review = analyzer.getTop(2)[1]; Assert.AreEqual(3, review.Value); }
public void runRules_ReviewWithNoProperty() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "testProperty", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "positiveOne", Weight = 1 }, new KeyWeight() { Keyword = "negativeOne", Weight = -1 }, new KeyWeight() { Keyword = "positiveTwo", Weight = 2 } } } }; JsonAnalyzer <testType> analyzer = new JsonAnalyzer <testType>(rules); List <testType> testList = new List <testType>() { new testType(), new testType() }; Assert.ThrowsException <Exception>(() => analyzer.runRules(JsonConvert.SerializeObject(testList))); }
/// <summary> /// 获取标签值 /// </summary> /// <param name="flags"></param> /// <returns></returns> public static BuiltInArchiveFlags GetBuiltInFlags(string flags) { JsonAnalyzer json = new JsonAnalyzer(flags); BuiltInArchiveFlags flag = BuiltInArchiveFlags.None; if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.AsPage]) == "1") { flag |= BuiltInArchiveFlags.AsPage; } if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSpecial]) == "1") { flag |= BuiltInArchiveFlags.IsSpecial; } if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSystem]) == "1") { flag |= BuiltInArchiveFlags.IsSystem; } if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.Visible]) == "1") { flag |= BuiltInArchiveFlags.Visible; } return(flag); }
//[AcceptVerbs("POST")] public string Verify(string domain,string key,string token) { //activatorFile.Append("YmIyNDAwMGI3YmEyZGMwZTgxZWI2OGQxYzk3MWU4NWI=", "{domain:'temp.ops.cc',start:'*',end='*'}"); try { if (activatorFile.Contains(key)) { JsonAnalyzer ja=new JsonAnalyzer(activatorFile[key]); string endDate = ja.GetValue("end"); //如果结束时间为不限 if (endDate == "*") return GethandleJson("ok"); //判断结束时间是否已过,未过则返回"ok"; DateTime _endDate; DateTime.TryParse(endDate, out _endDate); if (_endDate > DateTime.Now) return GethandleJson("ok"); } } catch { //如果控制端出现任何异常,则默认全部通过 return GethandleJson("ok"); } // // 不存在Key或者已过有效期 // 返回值 // go:返回数据但不调用Response.End() // end:返回数据调用Response.End() // 其他数据则默认通过且存入缓存 return GethandleJson("end"); }
private Task showError(ICompatibleHttpContext context, string message) { Hashtable hash = new Hashtable { ["error"] = 1, ["message"] = message }; return(context.Response.WriteAsync(JsonAnalyzer.ToJson(hash))); }
void RegisterRenamers(ConfuserContext context, NameService service) { bool wpf = false, caliburn = false, winforms = false, json = false; foreach (var module in context.Modules) { foreach (var asmRef in module.GetAssemblyRefs()) { if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" || asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") { wpf = true; } else if (asmRef.Name == "Caliburn.Micro") { caliburn = true; } else if (asmRef.Name == "System.Windows.Forms") { winforms = true; } else if (asmRef.Name == "Newtonsoft.Json") { json = true; } } } if (wpf) { var wpfAnalyzer = new WPFAnalyzer(); context.Logger.Debug("WPF found, enabling compatibility."); service.Renamers.Add(wpfAnalyzer); if (caliburn) { context.Logger.Debug("Caliburn.Micro found, enabling compatibility."); service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer)); } } if (winforms) { var winformsAnalyzer = new WinFormsAnalyzer(); context.Logger.Debug("WinForms found, enabling compatibility."); service.Renamers.Add(winformsAnalyzer); } if (json) { var jsonAnalyzer = new JsonAnalyzer(); context.Logger.Debug("Newtonsoft.Json found, enabling compatibility."); service.Renamers.Add(jsonAnalyzer); } }
public void outputWordCount_OneReviewOneRule() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "comments", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "positiveOne", Weight = 1 }, new KeyWeight() { Keyword = "negativeOne", Weight = -1 }, new KeyWeight() { Keyword = "positiveTwo", Weight = 2 } } } }; JsonAnalyzer <Review> analyzer = new JsonAnalyzer <Review>(rules); StringWriter debugLog = new StringWriter(); Console.SetOut(debugLog); Console.SetError(debugLog); ReviewCollection mockCollection = new ReviewCollection() { dealerId = "12345", ratingURl = "test/ratings", name = "testDealer", reviewCount = 1, reviews = new List <Review>() { new Review() { id = "001", dateWritten = "01/19/2021", comments = "positiveOne positiveOne positiveOne positiveOne positiveTwo " + "positiveTwo negativeOne negativeOne negativeOne negativeOne negativeOne" } } }; analyzer.outputWordCount(JsonConvert.SerializeObject(mockCollection.reviews)); string log = debugLog.ToString(); Assert.AreEqual(0, "negativeone 5\r\npositiveone 4\r\npositivetwo 2\r\n".CompareTo(log)); }
private void showError(string message) { Hashtable hash = new Hashtable(); hash["error"] = 1; hash["message"] = message; context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); context.Response.Write(JsonAnalyzer.ToJson(hash)); context.Response.End(); }
/// <summary> /// 获取标签的字典形式 /// </summary> /// <param name="flags"></param> /// <returns></returns> public static Dictionary <string, bool> GetFlagsDict(string flags) { IDictionary <string, string> dict = new JsonAnalyzer(flags).ConvertToDictionary(); Dictionary <string, bool> flagDict = new Dictionary <string, bool>(); foreach (KeyValuePair <string, string> pair in dict) { flagDict.Add(pair.Key, pair.Value == "1"); } return(flagDict); }
public void runRules_CustomObject() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "testProperty", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "positiveOne", Weight = 1 }, new KeyWeight() { Keyword = "negativeOne", Weight = -1 }, new KeyWeight() { Keyword = "positiveTwo", Weight = 2 } } } }; JsonAnalyzer <testType> analyzer = new JsonAnalyzer <testType>(rules); StringWriter debugLog = new StringWriter(); Console.SetOut(debugLog); Console.SetError(debugLog); List <testType> testList = new List <testType>() { new testType() { testProperty = "positiveTwo" }, new testType() { testProperty = "negativeOne negativeOne" } }; analyzer.runRules(JsonConvert.SerializeObject(testList)); KeyValuePair <testType, int> testType = analyzer.getTop(2)[0]; Assert.AreEqual(2, testType.Value); testType = analyzer.getTop(2)[1]; Assert.AreEqual(-2, testType.Value); }
private static int GetIntValue(string field) { int i = 0; string json = GetData(DateTime.Now); if (String.Compare(json, defaultJson, true) != 0) { JsonAnalyzer js = new JsonAnalyzer(json); int.TryParse(js.GetValue(field), out i); } return i; }
private static int GetIntValue(string field) { int i = 0; string json = GetData(DateTime.Now); if (String.Compare(json, defaultJson, true) != 0) { JsonAnalyzer js = new JsonAnalyzer(json); int.TryParse(js.GetValue(field), out i); } return(i); }
public void outputWordCount_CustomObject() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "testProperty", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "positiveOne", Weight = 1 }, new KeyWeight() { Keyword = "negativeOne", Weight = -1 }, new KeyWeight() { Keyword = "positiveTwo", Weight = 2 } } } }; JsonAnalyzer <testType> analyzer = new JsonAnalyzer <testType>(rules); StringWriter debugLog = new StringWriter(); Console.SetOut(debugLog); Console.SetError(debugLog); List <testType> testList = new List <testType>() { new testType() { testProperty = "positiveTwo" }, new testType() { testProperty = "negativeOne negativeOne" } }; analyzer.outputWordCount(JsonConvert.SerializeObject(testList)); string log = debugLog.ToString(); Assert.AreEqual(0, "negativeone 2\r\npositivetwo 1\r\n".CompareTo(log)); }
public void runRules_BadRule() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "aPropertyThatDoesNotExist", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "positiveOne", Weight = 1 }, new KeyWeight() { Keyword = "negativeOne", Weight = -1 }, new KeyWeight() { Keyword = "positiveTwo", Weight = 2 } } } }; JsonAnalyzer <testType> analyzer = new JsonAnalyzer <testType>(rules); List <testType> testList = new List <testType>() { new testType() { testProperty = "positiveTwo" }, new testType() { testProperty = "negativeOne negativeOne" } }; Assert.ThrowsException <Exception>(() => analyzer.runRules(JsonConvert.SerializeObject(testList))); }
//[AcceptVerbs("POST")] public string Verify(string domain, string key, string token) { //activatorFile.Append("YmIyNDAwMGI3YmEyZGMwZTgxZWI2OGQxYzk3MWU4NWI=", "{domain:'temp.j6.cc',start:'*',end='*'}"); try { if (activatorFile.Contains(key)) { JsonAnalyzer ja = new JsonAnalyzer(activatorFile[key]); string endDate = ja.GetValue("end"); //如果结束时间为不限 if (endDate == "*") { return(GethandleJson("ok")); } //判断结束时间是否已过,未过则返回"ok"; DateTime _endDate; DateTime.TryParse(endDate, out _endDate); if (_endDate > DateTime.Now) { return(GethandleJson("ok")); } } } catch { //如果控制端出现任何异常,则默认全部通过 return(GethandleJson("ok")); } // // 不存在Key或者已过有效期 // 返回值 // go:返回数据但不调用Response.End() // end:返回数据调用Response.End() // 其他数据则默认通过且存入缓存 return(GethandleJson("end")); }
void RegisterRenamers(ConfuserContext context, NameService service) { bool wpf = false, caliburn = false, winforms = false, json = false; foreach (ModuleDefMD module in context.Modules) { foreach (AssemblyRef asmRef in module.GetAssemblyRefs()) { switch (asmRef.Name) { case "WindowsBase": case "PresentationCore": case "PresentationFramework": case "System.Xaml": wpf = true; break; case "Caliburn.Micro": caliburn = true; break; case "System.Windows.Forms": winforms = true; break; case "Newtonsoft.Json": json = true; break; } } } if (wpf) { var wpfAnalyzer = new WPFAnalyzer(); //context.Logger.Debug("WPF found, enabling compatibility."); service.Renamers.Add(wpfAnalyzer); if (caliburn) { //context.Logger.Debug("Caliburn.Micro found, enabling compatibility."); service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer)); } } if (winforms) { var winformsAnalyzer = new WinFormsAnalyzer(); //context.Logger.Debug("WinForms found, enabling compatibility."); service.Renamers.Add(winformsAnalyzer); } if (json) { var jsonAnalyzer = new JsonAnalyzer(); //context.Logger.Debug("Newtonsoft.Json found, enabling compatibility."); service.Renamers.Add(jsonAnalyzer); } }
/// <summary> /// 处理上传 /// </summary> /// <param name="context"></param> /// <returns></returns> public Task UploadRequest(ICompatibleHttpContext context) { context.Response.ContentType("application/json; charset=utf-8"); var path = context.Request.GetPath(); //String aspxUrl = path.Substring(0, path.LastIndexOf("/") + 1); String saveUrl = $"{(this._appPath == "/" ? "" : this._appPath)}/{this._rootPath}"; //定义允许上传的文件扩展名 Hashtable extTable = new Hashtable(); extTable.Add("image", "gif,jpg,jpeg,png,bmp,webp"); extTable.Add("flash", "swf,flv"); extTable.Add("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb"); extTable.Add("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,7z"); //最大文件大小 int maxSize = 10240000; ICompatiblePostedFile imgFile = context.Request.File("imgFile"); if (imgFile == null) { return(this.showError(context, "请选择文件。")); } String dirPath = EnvUtil.GetBaseDirectory() + this._rootPath; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath).Create(); //return showError(context,"上传目录不存在。"); } String dirName = context.Request.Query("dir"); if (String.IsNullOrEmpty(dirName)) { dirName = "image"; } if (!extTable.ContainsKey(dirName)) { return(this.showError(context, "目录名不正确。")); } String fileName = imgFile.GetFileName(); String fileExt = Path.GetExtension(fileName).ToLower(); if (imgFile.GetLength() > maxSize) { return(this.showError(context, "上传文件大小超过限制。")); } if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(((String)extTable[dirName]).Split(','), fileExt.Substring(1).ToLower()) == -1) { return(this.showError(context, "上传文件扩展名是不允许的扩展名。\n只允许" + ((String)extTable[dirName]) + "格式。")); } //创建文件夹 dirPath += dirName + "/"; saveUrl += dirName + "/"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath).Create(); } String ymd = DateTime.Now.ToString("yyyyMM", DateTimeFormatInfo.InvariantInfo); dirPath += ymd + "/"; saveUrl += ymd + "/"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } String originName = UploadUtils.GetUploadFileName(imgFile); String newFileName = originName + fileExt; //String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt; // 自动将重复的名称命名 String targetPath = dirPath + newFileName; int i = 0; while (File.Exists(targetPath)) { i++; newFileName = $"{originName}_{i.ToString()}{fileExt}"; targetPath = dirPath + newFileName; } SaveFile(imgFile, targetPath); String fileUrl = saveUrl + newFileName; Hashtable hash = new Hashtable(); hash["error"] = 0; hash["url"] = fileUrl; return(context.Response.WriteAsync(JsonAnalyzer.ToJson(hash))); }
public static async void Minecraft_Start() { var Downloader = new Downloader(); bool check = await Downloader.check_pre_start(); if (!check) { return; } var json = new JsonAnalyzer(); string[] urlsforge = await Task.Factory.StartNew(async () => await json.jsonAnalyzer(false, true)).Result; string[] urlslibraries = await Task.Factory.StartNew(async () => await json.jsonAnalyzer(true, false)).Result; string launch = @"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx" + Properties.Settings.Default["RAM"] + "M -Xms" + Properties.Settings.Default["RAM"] + "M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M " + @"-Djava.library.path=" + Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\natives-win\ " + @"-cp "; if (config.forge == true) launch += Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\net\minecraftforge\forge\1.7.10-10.13.4.1492-1.7.10\forge-1.7.10-10.13.4.1492-1.7.10.jar;"; else launch += Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\versions\1.7.10\1.7.10.jar;"; foreach (string url in urlsforge) { if (url.Contains("platform")) continue; if (url.Contains("https://libraries.minecraft.net")) { string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("https://libraries.minecraft.net", ""); string FileName = Path.GetFileName(dir); dir = Path.GetDirectoryName(@dir); //MessageBox.Show(@dir); if (!Directory.Exists(@dir)) { Directory.CreateDirectory(@dir); } launch = launch + ("\"" + @dir + "\\" + FileName + "\"" + ";"); } if (url.Contains("http://files.minecraftforge.net/maven/")) { string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("http://files.minecraftforge.net/maven/", ""); //localpath = localpath.Replace("/","\\"); string FileName = Path.GetFileName(dir); //MessageBox.Show(FileName); dir = Path.GetDirectoryName(@dir); //MessageBox.Show(@dir); if (!Directory.Exists(@dir)) { Directory.CreateDirectory(@dir); } launch = launch + ("\"" + @dir + "\\" + FileName.Replace(".jar.pack.xz", ".jar") + "\"" + ";"); } } foreach (string url in urlslibraries) { if (url.Contains("platform")) continue; if (url.Contains("https://libraries.minecraft.net")) { string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("https://libraries.minecraft.net", ""); //localpath = localpath.Replace("/","\\"); string FileName = Path.GetFileName(dir); //MessageBox.Show(FileName); dir = Path.GetDirectoryName(@dir); //MessageBox.Show(@dir); if (!Directory.Exists(@dir)) { Directory.CreateDirectory(@dir); } launch = launch + ("\"" + @dir + "\\" + FileName + "\"" + ";"); } if (url.Contains("http://files.minecraftforge.net/maven/")) { string dir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\libraries\" + url.Replace("http://files.minecraftforge.net/maven/", ""); //localpath = localpath.Replace("/","\\"); string FileName = Path.GetFileName(dir); //MessageBox.Show(FileName); dir = Path.GetDirectoryName(@dir); //MessageBox.Show(@dir); if (!Directory.Exists(@dir)) { Directory.CreateDirectory(@dir); } launch = launch + ("\"" + @dir + "\\" + FileName.Replace(".jar.pack.xz", ".jar") + "\"" + ";"); } } if (config.forge == true) launch += Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\minecraft\versions\1.7.10\1.7.10.jar"; launch = launch + //" net.minecraft.client.main.Main " + " net.minecraft.launchwrapper.Launch " + "--username " + Form1.singleton.UsernameTextBox.Text + " " + //"--accessToken " + MojangLogin.getAccessToken() + " " + //"--username killpowa " + "--accessToken 0 " + "--version 1.7.10-Forge10.13.4.1448-1.7.10 " + "--gameDir \"minecraft\\instances\\" + Form1.singleton.ModpackList.SelectedItem.ToString() + "\" " + "--assetsDir minecraft\\assets\\ " + "--userProperties {} " + //"--uuid " + MojangLogin.getUUID() + " " + "--uuid 3b40f99969e64dbcabd01f87cddcb1fd " + "--tweakClass cpw.mods.fml.common.launcher.FMLTweaker"; //string launch = @"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M -Dos.version=10.0 -Djava.library.path=C:\Users\david\AppData\Roaming\.minecraft\versions\1.7.10-Forge10.13.4.1448-1.7.10\1.7.10-Forge10.13.4.1448-1.7.10-natives-260440781397829 -cp C:\Users\david\AppData\Roaming\.minecraft\libraries\net\minecraftforge\forge\1.7.10-10.13.4.1448-1.7.10\forge-1.7.10-10.13.4.1448-1.7.10.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\minecraft\launchwrapper\1.11\launchwrapper-1.11.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\ow2\asm\asm-all\5.0.3\asm-all-5.0.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\typesafe\akka\akka-actor_2.11\2.3.3\akka-actor_2.11-2.3.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\typesafe\config\1.2.1\config-1.2.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-actors-migration_2.11\1.1.0\scala-actors-migration_2.11-1.1.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-compiler\2.11.1\scala-compiler-2.11.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\plugins\scala-continuations-library_2.11\1.0.2\scala-continuations-library_2.11-1.0.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\plugins\scala-continuations-plugin_2.11.1\1.0.2\scala-continuations-plugin_2.11.1-1.0.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-library\2.11.1\scala-library-2.11.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-parser-combinators_2.11\1.0.1\scala-parser-combinators_2.11-1.0.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-reflect\2.11.1\scala-reflect-2.11.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-swing_2.11\1.0.1\scala-swing_2.11-1.0.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\scala-lang\scala-xml_2.11\1.0.2\scala-xml_2.11-1.0.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\lzma\lzma\0.0.1\lzma-0.0.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\17.0\guava-17.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\mojang\realms\1.3.5\realms-1.3.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\java3d\vecmath\1.3.1\vecmath-1.3.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\io\netty\netty-all\4.0.10.Final\netty-all-4.0.10.Final.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\15.0\guava-15.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\google\code\gson\gson\2.2.4\gson-2.2.4.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\com\mojang\authlib\1.5.21\authlib-1.5.21.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta9.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\log4j-core-2.0-beta9.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl\2.9.1\lwjgl-2.9.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.1\lwjgl_util-2.9.1.jar;C:\Users\david\AppData\Roaming\.minecraft\libraries\tv\twitch\twitch\5.16\twitch-5.16.jar;C:\Users\david\AppData\Roaming\.minecraft\versions\1.7.10\1.7.10.jar net.minecraft.launchwrapper.Launch --username killpowa --version 1.7.10-Forge10.13.4.1448-1.7.10 --gameDir C:\Users\david\AppData\Roaming\.minecraft --assetsDir C:\Users\david\AppData\Roaming\.minecraft\assets --assetIndex 1.7.10 --uuid 3b40f99969e64dbcabd01f87cddcb1fd --accessToken b856b175da4a46e8a85e34f385396157 --userProperties {} --userType legacy --tweakClass cpw.mods.fml.common.launcher.FMLTweaker"; /*try { //MessageBox.Show(launch); Process test = new Process(); test.StartInfo.UseShellExecute = false; test.StartInfo.RedirectStandardOutput = true; test.StartInfo.FileName = "java.exe"; test.StartInfo.Arguments = launch; test.Start(); Form1.singleton.richTextBox1.Text = launch; string output = test.StandardOutput.ReadToEnd(); MessageBox.Show(output); } catch(Exception e) { MessageBox.Show("Non e' stato possibile avviare il gioco. Controlla di avere installato JAVA!"); throw; }*/ Downloader downloader = new Downloader(); DebugMode.sendToConsole("Launching Minecraft with following settings: \n\r" + launch); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = downloader.GetJavaInstallationPath() + "//bin//java.exe"; startInfo.Arguments = launch; Process.Start(startInfo); }
/// <summary> /// 获取标签值 /// </summary> /// <param name="flags"></param> /// <param name="flagKey"></param> /// <returns></returns> public static bool GetFlag(string flags, string flagKey) { JsonAnalyzer json = new JsonAnalyzer(flags); return(json.GetValue(flagKey) == "1"); }
/// <summary> /// 校验激活状态 /// </summary> internal static void VerifyActivation() { if(DateTime.Now<new DateTime(2014,02,16)){ return; } // // 如果异步方式调用 // 或在本地调试则不校验 // if (Cms.Cache.Get(checkKey) != null || CheckIsHostOnLocalhost()) { return; } // // 异步从服务器读取激活状态 // /* new Thread(() => { lock (activeInfo) { CheckActiveState(); } }).Start();*/ CheckActiveState(); //=====分析获得的数据并返回到客户端=====// if (!String.IsNullOrEmpty(activeInfo)) { lock (activeInfo) { try { JsonAnalyzer js = new JsonAnalyzer(activeInfo); string result = js.GetValue("state"); if (result != "ok") { activiveIsNormal = false; //设置状态 string content = js.GetValue("content"); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.Write(content); //返回字符串 if (result == "end") { HttpRuntime.UnloadAppDomain(); HttpContext.Current.Response.End(); return; } else if (result == "go") { return; } } else { activiveIsNormal = true; //设置状态 //如果通过校验,则缓存1日激活状态 Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(7)); } } catch { //如果发生异常 //则创建缓存3天候过期来避免频繁向服务器发送校验请求 Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(3)); } } } }
/// <summary> /// 记录IP信息 /// </summary> /// <param name="ip"></param> public static void Record(string ip) { new Thread(() => { try { string key = String.Format("{0:yyyyMMdd}", DateTime.Now); string data; //流量数据 int todayIP = 0, todayPV = 0, totalIP = 0, totalPV = 0; string ips = String.Empty; //IP库 //获取累计的IP和PV,如果不存在,则创建字段 if (trafficFile.Contains("totalIP")) { int.TryParse(trafficFile["totalIP"], out totalIP); } else { trafficFile.Add("totalIP", "0"); } if (trafficFile.Contains("totalPV")) { int.TryParse(trafficFile["totalPV"], out totalPV); } else { trafficFile.Add("totalPV", "0"); } data = GetData(DateTime.Now); JsonAnalyzer js = new JsonAnalyzer(data); int.TryParse(js.GetValue("ip"), out todayIP); int.TryParse(js.GetValue("pv"), out todayPV); //检测是否是独立访客,如果是则增加IP并记录 if (trafficFile.Contains("ips")) { ips = trafficFile["ips"]; } else { trafficFile.Add("ips", ""); } if (ips.IndexOf(ip) == -1) { ips = String.Format("{0}{1}|", ips, ip); trafficFile["ips"] = ips; ++todayIP; ++totalIP; //更新今日IP数据并返回新的JSON js = new JsonAnalyzer(js.SetValue("ip", todayIP.ToString())); //保存总的IP数据 if (trafficFile.Contains("totalIP")) { trafficFile["totalIP"] = totalIP.ToString(); } else { trafficFile.Add("totalIP", totalIP.ToString()); } } ++todayPV; ++totalPV; //保存今日PV trafficFile[key] = js.SetValue("pv", todayPV.ToString()); //保存总的PV数据 trafficFile["totalPV"] = totalPV.ToString(); } catch (Exception ex) { // //Catch error // trafficFile.Flush(); } }).Start(); }
/// <summary> /// 获取标签的字典形式 /// </summary> /// <param name="flags"></param> /// <returns></returns> public static Dictionary<string, bool> GetFlagsDict(string flags) { IDictionary<string, string> dict = new JsonAnalyzer(flags).ConvertToDictionary(); Dictionary<string, bool> flagDict = new Dictionary<string, bool>(); foreach (KeyValuePair<string, string> pair in dict) { flagDict.Add(pair.Key, pair.Value == "1"); } return flagDict; }
/// <summary> /// 获取标签值 /// </summary> /// <param name="flags"></param> /// <param name="flagKey"></param> /// <returns></returns> public static bool GetFlag(string flags, string flagKey) { JsonAnalyzer json = new JsonAnalyzer(flags); return json.GetValue(flagKey) == "1"; }
public void getTop_ReturnSubset() { List <AnalyzerRule> rules = new List <AnalyzerRule>() { new AnalyzerRule() { Key = "comments", Rules = new List <KeyWeight>() { new KeyWeight() { Keyword = "amazing", Weight = 2 }, new KeyWeight() { Keyword = "helpful", Weight = 1 }, new KeyWeight() { Keyword = "bad", Weight = -1 } } } }; JsonAnalyzer <Review> analyzer = new JsonAnalyzer <Review>(rules); ReviewCollection mockCollection = new ReviewCollection() { dealerId = "12345", ratingURl = "test/ratings", name = "testDealer", reviewCount = 1, reviews = new List <Review>() { new Review() { id = "001", dateWritten = "01/19/2021", comments = "Helpful and amazing" }, new Review() { id = "002", dateWritten = "01/19/2021", comments = "Amazing and a little bad" }, new Review() { id = "003", dateWritten = "01/19/2021", comments = "Helpful and a little bad" }, new Review() { id = "003", dateWritten = "01/19/2021", comments = "Just bad" } } }; analyzer.runRules(JsonConvert.SerializeObject(mockCollection.reviews)); int numToReturn = 2; List <KeyValuePair <Review, int> > returned = analyzer.getTop(numToReturn); Assert.AreEqual(numToReturn, returned.Count); }
/// <summary> /// 校验激活状态 /// </summary> internal static void VerifyActivation() { if (DateTime.Now < new DateTime(2014, 02, 16)) { return; } // // 如果异步方式调用 // 或在本地调试则不校验 // if (Cms.Cache.Get(checkKey) != null || CheckIsHostOnLocalhost()) { return; } // // 异步从服务器读取激活状态 // /* * new Thread(() => * { * lock (activeInfo) * { * CheckActiveState(); * } * * }).Start();*/ CheckActiveState(); //=====分析获得的数据并返回到客户端=====// if (!String.IsNullOrEmpty(activeInfo)) { lock (activeInfo) { try { JsonAnalyzer js = new JsonAnalyzer(activeInfo); string result = js.GetValue("state"); if (result != "ok") { activiveIsNormal = false; //设置状态 string content = js.GetValue("content"); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.Write(content); //返回字符串 if (result == "end") { HttpRuntime.UnloadAppDomain(); HttpContext.Current.Response.End(); return; } else if (result == "go") { return; } } else { activiveIsNormal = true; //设置状态 //如果通过校验,则缓存1日激活状态 Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(7)); } } catch { //如果发生异常 //则创建缓存3天候过期来避免频繁向服务器发送校验请求 Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(3)); } } } }
public void ProcessRequest(HttpContext context) { String aspxUrl = context.Request.Path.Substring(0, context.Request.Path.LastIndexOf("/") + 1); string siteId = Logic.CurrentSite.SiteId.ToString(); //根目录路径,相对路径 String rootPath = String.Format("{0}s{1}/", CmsVariables.RESOURCE_PATH, siteId); //根目录URL,可以指定绝对路径,比如 http://www.yoursite.com/attached/ string appPath = Cms.Context.ApplicationPath; String rootUrl = String.Format("{0}/{1}s{2}/", appPath == "/"?"":appPath, CmsVariables.RESOURCE_PATH, siteId); //图片扩展名 String fileTypes = "gif,jpg,jpeg,png,bmp"; String currentPath = ""; String currentUrl = ""; String currentDirPath = ""; String moveupDirPath = ""; String dirPath = AppDomain.CurrentDomain.BaseDirectory + rootPath; String dirName = context.Request.QueryString["dir"]; if (!String.IsNullOrEmpty(dirName)) { if (Array.IndexOf("image,flash,media,file".Split(','), dirName) == -1) { context.Response.Write("Invalid Directory name."); context.Response.End(); } dirPath += dirName + "/"; rootUrl += dirName + "/"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath).Create(); } } //根据path参数,设置各路径和URL String path = context.Request.QueryString["path"]; path = String.IsNullOrEmpty(path) ? "" : path; if (path == "") { currentPath = dirPath; currentUrl = rootUrl; currentDirPath = ""; moveupDirPath = ""; } else { currentPath = dirPath + path; currentUrl = rootUrl + path; currentDirPath = path; moveupDirPath = Regex.Replace(currentDirPath, @"(.*?)[^\/]+\/$", "$1"); } //排序形式,name or size or type String order = context.Request.QueryString["order"]; order = String.IsNullOrEmpty(order) ? "" : order.ToLower(); //不允许使用..移动到上一级目录 if (Regex.IsMatch(path, @"\.\.")) { context.Response.Write("Access is not allowed."); context.Response.End(); } //最后一个字符不是/ if (path != "" && !path.EndsWith("/")) { context.Response.Write("Parameter is not valid."); context.Response.End(); } //目录不存在或不是目录 if (!Directory.Exists(currentPath)) { context.Response.Write("Directory does not exist."); context.Response.End(); } //遍历目录取得文件信息 string[] dirList = Directory.GetDirectories(currentPath); string[] fileList = Directory.GetFiles(currentPath); switch (order) { case "size": Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new SizeSorter()); break; case "type": Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new TypeSorter()); break; case "name": default: Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new NameSorter()); break; } Hashtable result = new Hashtable(); result["moveup_dir_path"] = moveupDirPath; result["current_dir_path"] = currentDirPath; result["current_url"] = currentUrl; result["total_count"] = dirList.Length + fileList.Length; List <Hashtable> dirFileList = new List <Hashtable>(); for (int i = 0; i < dirList.Length; i++) { DirectoryInfo dir = new DirectoryInfo(dirList[i]); Hashtable hash = new Hashtable(); hash["is_dir"] = true; hash["has_file"] = (dir.GetFileSystemInfos().Length > 0); hash["filesize"] = 0; hash["is_photo"] = false; hash["filetype"] = ""; hash["filename"] = dir.Name; hash["datetime"] = dir.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); dirFileList.Add(hash); } for (int i = 0; i < fileList.Length; i++) { FileInfo file = new FileInfo(fileList[i]); Hashtable hash = new Hashtable(); hash["is_dir"] = false; hash["has_file"] = false; hash["filesize"] = file.Length; hash["is_photo"] = (Array.IndexOf(fileTypes.Split(','), file.Extension.Substring(1).ToLower()) >= 0); hash["filetype"] = file.Extension.Substring(1); hash["filename"] = file.Name; hash["datetime"] = file.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"); dirFileList.Add(hash); } string files = String.Empty; int j = 0; foreach (Hashtable h in dirFileList) { files += JsonAnalyzer.ToJson(h); if (++j < dirFileList.Count) { files += ","; } } result["file_list"] = "[" + files + "]"; context.Response.AddHeader("Content-Type", "application/json; charset=UTF-8"); context.Response.Write(JsonAnalyzer.ToJson(result)); context.Response.End(); }
/// <summary> /// 获取标签值 /// </summary> /// <param name="flags"></param> /// <returns></returns> public static BuiltInArchiveFlags GetBuiltInFlags(string flags) { JsonAnalyzer json = new JsonAnalyzer(flags); BuiltInArchiveFlags flag = BuiltInArchiveFlags.None; if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.AsPage]) == "1") { flag |= BuiltInArchiveFlags.AsPage; } if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSpecial]) == "1") { flag |= BuiltInArchiveFlags.IsSpecial; } if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSystem]) == "1") { flag |= BuiltInArchiveFlags.IsSystem; } if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.Visible]) == "1") { flag |= BuiltInArchiveFlags.Visible; } return flag; }
public void ProcessRequest(HttpContext context) { String aspxUrl = context.Request.Path.Substring(0, context.Request.Path.LastIndexOf("/") + 1); string siteID = Logic.CurrentSite.SiteId.ToString(); //文件保存目录路径 String savePath = String.Format("/{0}s{1}/", CmsVariables.RESOURCE_PATH, siteID); //文件保存目录URL string appPath = Cms.Context.ApplicationPath; String saveUrl = String.Format("{0}/{1}s{2}/", appPath == "/"?"":appPath, CmsVariables.RESOURCE_PATH, siteID); //定义允许上传的文件扩展名 Hashtable extTable = new Hashtable(); extTable.Add("image", "gif,jpg,jpeg,png,bmp"); extTable.Add("flash", "swf,flv"); extTable.Add("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb"); extTable.Add("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2,7z"); //最大文件大小 int maxSize = 1000000; this.context = context; HttpPostedFile imgFile = context.Request.Files["imgFile"]; if (imgFile == null) { showError("请选择文件。"); } String dirPath = AppDomain.CurrentDomain.BaseDirectory + savePath; checkDir: bool isCreate = false; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath).Create(); if (!isCreate) { isCreate = true; goto checkDir; } showError("上传目录不存在。"); } String dirName = context.Request.QueryString["dir"]; if (String.IsNullOrEmpty(dirName)) { dirName = "image"; } if (!extTable.ContainsKey(dirName)) { showError("目录名不正确。"); } String fileName = imgFile.FileName; String fileExt = Path.GetExtension(fileName).ToLower(); if (imgFile.InputStream == null || imgFile.InputStream.Length > maxSize) { showError("上传文件大小超过限制。"); } if (String.IsNullOrEmpty(fileExt) || Array.IndexOf(((String)extTable[dirName]).Split(','), fileExt.Substring(1).ToLower()) == -1) { showError("上传文件扩展名是不允许的扩展名。\n只允许" + ((String)extTable[dirName]) + "格式。"); } //创建文件夹 dirPath += dirName + "/"; saveUrl += dirName + "/"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath).Create(); } String ymd = DateTime.Now.ToString("yyyyMM", DateTimeFormatInfo.InvariantInfo); dirPath += ymd + "/"; saveUrl += ymd + "/"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } String newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt; String filePath = dirPath + newFileName; imgFile.SaveAs(filePath); String fileUrl = saveUrl + newFileName; Hashtable hash = new Hashtable(); hash["error"] = 0; hash["url"] = fileUrl; context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8"); context.Response.Write(JsonAnalyzer.ToJson(hash)); context.Response.End(); }
/// <summary> /// 文件浏览 /// </summary> /// <param name="context"></param> /// <returns></returns> public Task FileManagerRequest(ICompatibleHttpContext context) { context.Response.ContentType("application/json; charset=utf-8"); //根目录路径,相对路径 //String rootPath = $"{CmsVariables.RESOURCE_PATH}{siteId}/"; //根目录URL,可以指定绝对路径,比如 http://www.yoursite.com/attached/ // string appPath = Cms.Context.ApplicationPath; String rootUrl = $"{(this._appPath == "/" ? "" : this._appPath)}/{this._rootPath}"; //图片扩展名 String fileTypes = "gif,jpg,jpeg,png,bmp"; String currentPath = ""; String currentUrl = ""; String currentDirPath = ""; String moveUpDirPath = ""; String dirPath = EnvUtil.GetBaseDirectory() + this._rootPath; String dirName = context.Request.Query("dir"); if (!String.IsNullOrEmpty(dirName)) { if (Array.IndexOf("image,flash,media,file".Split(','), dirName) == -1) { return(context.Response.WriteAsync("Invalid Directory name.")); } dirPath += dirName + "/"; rootUrl += dirName + "/"; if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath).Create(); } } //根据path参数,设置各路径和URL String path = context.Request.Query("path"); path = String.IsNullOrEmpty(path) ? "" : path; if (path == "") { currentPath = dirPath; currentUrl = rootUrl; currentDirPath = ""; moveUpDirPath = ""; } else { currentPath = dirPath + path; currentUrl = rootUrl + path; currentDirPath = path; moveUpDirPath = Regex.Replace(currentDirPath, @"(.*?)[^\/]+\/$", "$1"); } //排序形式,name or size or type String order = context.Request.Query("order"); order = String.IsNullOrEmpty(order) ? "" : order.ToLower(); //不允许使用..移动到上一级目录 if (Regex.IsMatch(path, @"\.\.")) { return(context.Response.WriteAsync("Access is not allowed.")); } //最后一个字符不是/ if (path != "" && !path.EndsWith("/")) { return(context.Response.WriteAsync("Parameter is not valid.")); } //目录不存在或不是目录 if (!Directory.Exists(currentPath)) { return(context.Response.WriteAsync("Directory does not exist.")); } //遍历目录取得文件信息 string[] dirList = Directory.GetDirectories(currentPath); string[] fileList = Directory.GetFiles(currentPath); switch (order) { case "size": Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new SizeSorter()); break; case "type": Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new TypeSorter()); break; case "name": default: Array.Sort(dirList, new NameSorter()); Array.Sort(fileList, new NameSorter()); break; } Hashtable result = new Hashtable(); result["moveup_dir_path"] = moveUpDirPath; result["current_dir_path"] = currentDirPath; result["current_url"] = currentUrl; result["total_count"] = dirList.Length + fileList.Length; List <Hashtable> dirFileList = new List <Hashtable>(); for (int i = 0; i < dirList.Length; i++) { DirectoryInfo dir = new DirectoryInfo(dirList[i]); Hashtable hash = new Hashtable { ["is_dir"] = true, ["has_file"] = (dir.GetFileSystemInfos().Length > 0), ["filesize"] = 0, ["is_photo"] = false, ["filetype"] = "", ["filename"] = dir.Name, ["datetime"] = dir.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") }; dirFileList.Add(hash); } for (int i = 0; i < fileList.Length; i++) { FileInfo file = new FileInfo(fileList[i]); if (file.Extension.Equals("")) { continue; } Hashtable hash = new Hashtable { ["is_dir"] = false, ["has_file"] = false, ["filesize"] = file.Length, ["is_photo"] = (Array.IndexOf(fileTypes.Split(','), file.Extension.Substring(1).ToLower()) >= 0), ["filetype"] = file.Extension.Substring(1), ["filename"] = file.Name, ["datetime"] = file.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") }; dirFileList.Add(hash); } string files = String.Empty; int j = 0; foreach (Hashtable h in dirFileList) { files += JsonAnalyzer.ToJson(h); if (++j < dirFileList.Count) { files += ","; } } result["file_list"] = "[" + files + "]"; context.Response.ContentType("application/json; charset=utf-8"); return(context.Response.WriteAsync(JsonAnalyzer.ToJson(result))); }
void RegisterRenamers(ConfuserContext context, NameService service) { bool wpf = false; bool caliburn = false; bool winforms = false; bool json = false; bool visualBasic = false; bool vsComposition = false; foreach (var module in context.Modules) { foreach (var asmRef in module.GetAssemblyRefs()) { if (asmRef.Name == "WindowsBase" || asmRef.Name == "PresentationCore" || asmRef.Name == "PresentationFramework" || asmRef.Name == "System.Xaml") { wpf = true; } else if (asmRef.Name == "Caliburn.Micro") { caliburn = true; } else if (asmRef.Name == "System.Windows.Forms") { winforms = true; } else if (asmRef.Name == "Newtonsoft.Json") { json = true; } else if (asmRef.Name == "Microsoft.VisualStudio.Composition") { vsComposition = true; } } var vbEmbeddedAttribute = module.FindNormal("Microsoft.VisualBasic.Embedded"); if (vbEmbeddedAttribute != null && vbEmbeddedAttribute.BaseType.FullName.Equals("System.Attribute")) { visualBasic = true; } } if (wpf) { var wpfAnalyzer = new WPFAnalyzer(); context.Logger.Debug("WPF found, enabling compatibility."); service.Renamers.Add(wpfAnalyzer); if (caliburn) { context.Logger.Debug("Caliburn.Micro found, enabling compatibility."); service.Renamers.Add(new CaliburnAnalyzer(wpfAnalyzer)); } } if (winforms) { var winformsAnalyzer = new WinFormsAnalyzer(); context.Logger.Debug("WinForms found, enabling compatibility."); service.Renamers.Add(winformsAnalyzer); } if (json) { var jsonAnalyzer = new JsonAnalyzer(); context.Logger.Debug("Newtonsoft.Json found, enabling compatibility."); service.Renamers.Add(jsonAnalyzer); } if (visualBasic) { var vbAnalyzer = new VisualBasicRuntimeAnalyzer(); context.Logger.Debug("Visual Basic Embedded Runtime found, enabling compatibility."); service.Renamers.Add(vbAnalyzer); } if (vsComposition) { var analyzer = new VsCompositionAnalyzer(); context.Logger.Debug("Visual Studio Composition found, enabling compatibility."); service.Renamers.Add(analyzer); } }
/// <summary> /// 记录IP信息 /// </summary> /// <param name="ip"></param> public static void Record(string ip) { new Thread(() => { try { string key = String.Format("{0:yyyyMMdd}", DateTime.Now); string data; //流量数据 int todayIP = 0, todayPV = 0, totalIP = 0, totalPV = 0; string ips = String.Empty; //IP库 //获取累计的IP和PV,如果不存在,则创建字段 if (trafficFile.Contains("totalIP")) { int.TryParse(trafficFile["totalIP"], out totalIP); } else { trafficFile.Append("totalIP", "0"); } if (trafficFile.Contains("totalPV")) { int.TryParse(trafficFile["totalPV"], out totalPV); } else { trafficFile.Append("totalPV", "0"); } data = GetData(DateTime.Now); JsonAnalyzer js = new JsonAnalyzer(data); int.TryParse(js.GetValue("ip"), out todayIP); int.TryParse(js.GetValue("pv"), out todayPV); //检测是否是独立访客,如果是则增加IP并记录 if (trafficFile.Contains("ips")) { ips = trafficFile["ips"]; } else { trafficFile.Append("ips", ""); } if (ips.IndexOf(ip) == -1) { ips = String.Format("{0}{1}|", ips, ip); trafficFile["ips"] = ips; ++todayIP; ++totalIP; //更新今日IP数据并返回新的JSON js = new JsonAnalyzer(js.SetValue("ip", todayIP.ToString())); //保存总的IP数据 if (trafficFile.Contains("totalIP")) { trafficFile["totalIP"] = totalIP.ToString(); } else { trafficFile.Append("totalIP", totalIP.ToString()); } } ++todayPV; ++totalPV; //保存今日PV trafficFile[key] = js.SetValue("pv", todayPV.ToString()); //保存总的PV数据 trafficFile["totalPV"] = totalPV.ToString(); } catch (Exception ex) { // //Catch error // trafficFile.Flush(); } }).Start(); }