public void clearAccount() { settingLib.CreateContainer("CampusNetwork").CreateSetting("campusNetworkAccountId", "").SaveSetting(); settingLib.CreateContainer("CampusNetwork").CreateSetting("campusNetworkAccountPasswd", "").SaveSetting(); settingLib.CreateContainer("CampusNetwork").CreateSetting("isCampusNetworkAccountSaved", false).SaveSetting(); DebugLib.DebugOutput("accountSettting cleared"); }
public CampusNetworkClass() { checkIsSettingSaved(); if (!isSettingSaved) { settingLib.CreateContainer("CampusNetwork").CreateSetting("isCampusNetworkAccountSaved", false); DebugLib.DebugOutput(isSettingSaved); } wlanType = checkWlanType(); }
private int checkWlanType() { string ssid = getDeviceWlanSsid(); int wlanType; DebugLib.DebugOutput(ssid); switch (ssid) { case "BUPT-1": wlanType = 1; break; case "BUPT-2": wlanType = 2; break; case "BUPT-3": wlanType = 3; break; case "BUPT-dot1x": wlanType = 4; break; case "BUPT-guest": wlanType = 5; break; case "BUPT-portal": wlanType = 6; break; default: wlanType = 0; break; } return(wlanType); }
public static void Main(string[] arg) { // *** Parse arguments. if (arg.Length == 0) { PrintUsage(); return; } bool optRunTests = false; bool optInteractiveMode = false; bool optVerbose = false; bool optPause = false; bool optDump = false; List <string> optFiles = new List <string>(); List <string> passThroughArgs = null; for (int iArg = 0; iArg < arg.Length; ++iArg) { string ar = arg[iArg]; if (ar[0] == '-' || ar[0] == '/') { if (ar[1] == 't') { optRunTests = true; } else if (ar[1] == 'i') { optInteractiveMode = true; } else if (ar[1] == 'v') { Console.WriteLine("verbose enabled."); optVerbose = true; } else if (ar[1] == 'p') { optPause = true; } else if (ar[1] == 'd') { optDump = true; } else if (ar[1] == 'a') { if (iArg == arg.Length - 1) { Console.WriteLine("Argument expected after -a option."); PrintUsage(); return; } else { passThroughArgs = passThroughArgs ?? new List <string>(); passThroughArgs.Add(arg[++iArg]); } } else { Console.WriteLine("Unrecognized option '" + ar[1] + "'."); PrintUsage(); return; } } else { optFiles.Add(ar); } } // *** Initialize engine. // Create engine. Engine engine = new Engine(); engine.LogError = (msg) => { ConsoleColor sav = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(msg); Console.ForegroundColor = sav; }; // Register optional libraries. DebugLib.Register(engine); FileLib.Register(engine); DateTimeLib.Register(engine); ConsoleLib.Register(engine); List <ParseErrorInst> errors = new List <ParseErrorInst>(); // Create pass-through args. if (null != passThroughArgs) { string initScript = "global List<string> CLIargs = new { "; foreach (string pta in passThroughArgs) { initScript += "Add(\"" + pta + "\"); "; } initScript += "};"; ScriptResult result = engine.RunScript(initScript, false); if (!result.success) { Console.WriteLine("INTERNAL ERROR creating passthrough arguments array."); return; } errors.Clear(); } // *** Do tasks. // Tests... if (optRunTests) { UnitTests.RunTests(engine, optVerbose); } // Files... foreach (string filename in optFiles) { string fileContents; try { fileContents = File.ReadAllText(filename); } catch (Exception e) { Console.WriteLine("Error attempting to open '" + filename + "': " + e.Message); break; } errors.Clear(); ScriptResult result = engine.RunScript(fileContents, optVerbose, filename); if (result.success) { Console.WriteLine("Returned: " + CoreLib.ValueToString(engine.defaultContext, result.value, true)); } else { // At time of writing, errors get printed (in red) when they are created, so don't need to do it again here. //Console.WriteLine(result); Console.WriteLine(" " + filename + " failed to compile or execute."); } } // Interactive mode... if (optInteractiveMode) { Console.WriteLine("Pebble Interpreter (C) 2021 Patrick Cyr"); Console.WriteLine("Interactive mode. Enter 'exit' to exit, 'help' for help:"); // Lines in interactive mode don't use their own scope. Instead, they // use one shared scope that is created here. engine.defaultContext.stack.PushTerminalScope("<interactive mode>", null); while (true) { Console.Write("> "); string line = Console.ReadLine(); line = line.Trim(); if (line.Equals("exit", StringComparison.OrdinalIgnoreCase)) { break; } if (line.Equals("help", StringComparison.OrdinalIgnoreCase)) { line = "Debug::DumpClass(\"Debug\");"; Console.WriteLine(line); } ScriptResult result = engine.RunInteractiveScript(line, optVerbose); if (result.success) { if (null == result.value) { Console.WriteLine("<null>"); } else { Console.WriteLine(CoreLib.ValueToString(engine.defaultContext, result.value, true)); } } } } // Dump memory... if (optDump) { Console.WriteLine(); Console.WriteLine(engine.defaultContext); } // Pause before exiting... if (optPause) { Console.WriteLine("Press any key to exit."); Console.ReadKey(); } }
private async Task <string> LoginAction(string loginUrl, string postData) { string response, ret; try { response = await webLib.HttpPost(loginUrl, postData, "gb2312"); string regStr; string regRet; //html [^(<title>))] regStr = @"(?<=<title>)(.*?)(?=</title>)"; regRet = RegLib.RegexMatch(regStr, ref response); if (regRet == "登录成功窗") { DebugLib.DebugOutput("登录成功"); ret = "登陆成功"; } else if (regRet == "信息返回窗") { //javascrpit Msg=\d*; regStr = @"(?<=Msg=)(\d*)(?=;)"; regRet = RegLib.RegexMatch(regStr, ref response); DebugLib.DebugOutput(regRet); int msgId = Int32.Parse(regRet); DebugLib.DebugOutput(msgId); string errInfo = ""; regStr = @"(?<=xip=')(.*)('?=;)"; regRet = RegLib.RegexMatch(regStr, ref response); string xipStr = regRet; DebugLib.DebugOutput(xipStr); switch (msgId) { case 0: errInfo = "账号或密码不对,请重新输入"; break; case 1: regStr = @"(?<=msga=)(.*)(?=;)"; regRet = RegLib.RegexMatch(regStr, ref response); string msgaStr = regRet; if (msgaStr != "") { switch (msgaStr) { case "error0": errInfo = "本IP不允许Web方式登录"; break; case "error1": errInfo = "本账号不允许Web方式登录"; break; case "error2": errInfo = "本账号不允许修改密码"; break; default: errInfo = msgaStr; break; } } break; case 2: DebugLib.DebugOutput(regRet); errInfo = "该账号正在IP为:" + xipStr + "的机器上使用,<br><br>请点击<a href='a11.htm'>继续</a>断开它的连接并重新输入用户名和密码登陆本机。"; break; case 3: errInfo = "本账号只能在指定地址使用" + xipStr; break; case 4: errInfo = "本账号费用超支或时长流量超过限制"; break; case 5: errInfo = "本账号暂停使用"; break; case 6: errInfo = "System buffer full"; break; case 7: errInfo = "余额啥的正常"; break; case 8: errInfo = "本账号正在使用,不能修改"; break; case 9: errInfo = "新密码与确认新密码不匹配,不能修改"; break; case 10: errInfo = "密码修改成功"; break; case 11: regStr = @"(?<=mac=')(.*)('?=;)"; regRet = RegLib.RegexMatch(regStr, ref response); string macStr = regRet; errInfo = "本账号只能在指定地址使用" + macStr; break; case 14: errInfo = "注销成功"; break; case 15: errInfo = "登录成功"; break; } DebugLib.DebugOutput(errInfo); ret = errInfo; } else { DebugLib.DebugOutput("登录失败"); ret = "登陆失败"; } } catch { ret = "网络错误,登陆失败"; } return(ret); }