public Tokenverification(string Token) { var payload = new JwtBuilder().Decode <IDictionary <string, object> >(Token); string secret = "MVgIUONObLgr8262769MBI8787rREbtF"; try { var json = new JwtBuilder().WithSecret(secret).MustVerifySignature().Decode(Token); Tokenstatus = "認證成功"; NewToken = new JwtBuilder().WithAlgorithm(new HMACSHA256Algorithm()).WithSecret(secret) .AddClaim("exp", DateTimeOffset.UtcNow.AddMinutes(10).ToUnixTimeSeconds()) .AddClaim("id", payload["id"]).Build(); } catch (TokenExpiredException) { List <IDbDataParameter> SetParameters = new List <IDbDataParameter>(); SetParameters.Add(new SqlParameter("@Logout", "登出")); SetParameters.Add(new SqlParameter("@LogoutId", payload["id"])); string SQLString = "UPDATE Users SET LoginStatus = @Logout WHERE id =@LogoutId"; OpenDB iOpneDB = new OpenDB(); if (iOpneDB.UPDATE(SQLString, SetParameters) > 0) { Tokenstatus = "認證過期"; NewToken = ""; } } //catch (SignatureVerificationException) //{ // Tokenstatus = "Token無效"; // NewToken = ""; //} }
void ReleaseDesignerOutlets() { if (OpenDB != null) { OpenDB.Dispose(); OpenDB = null; } if (CopyEmailadressen != null) { CopyEmailadressen.Dispose(); CopyEmailadressen = null; } if (Print != null) { Print.Dispose(); Print = null; } if (Search != null) { Search.Dispose(); Search = null; } if (Zoekveld != null) { Zoekveld.Dispose(); Zoekveld = null; } }
public DataTable getitem(string place) { OpenDB iOpneDB = new OpenDB(); List <IDbDataParameter> SetParameters = new List <IDbDataParameter>(); string SQLString = ""; SQLString = "SELECT * FROM item_withplace where item_place = @Itemplace"; SetParameters.Add(new SqlParameter("@Itemplace", place)); return(iOpneDB.SELECT(SQLString, SetParameters)); }
public frmMain() { InitializeComponent(); frmMain.Instance = this; this.Text = Const.ApplicationName; MessageProvider.Instance.SetProvider(this); InitializeTabs(); Helper.SetRegistryFeatureBrowserEmulation(); Helper.PrepareBrowser(frmMain.Instance?.Browser); Action <bool> UpdateLayout = null; UpdateLayout = (x) => { var browser = frmMain.Instance?.Browser; if (this.InvokeRequired) { this.Invoke(UpdateLayout); return; } if (Settings.VerticalMode.Value) { panelBrowser.Dock = DockStyle.Top; if (!Settings.BattleInfoLayout.Value) { browser.Left = panelBrowser.ClientSize.Width / 2 - browser.ClientSize.Width / 2; } else { browser.Left = 0; panelRemain.Padding = new Padding(browser.Width + 4, 0, 0, 0); contentBattle.Invalidate(); } } else { panelBrowser.Dock = DockStyle.Left; browser.Left = 0; panelRemain.Padding = new Padding(0, browser.Height + 4, 0, 0); } if (x) { if (Settings.BattleInfoLayout.Value) { if (CurrentTab == "Battle") { UpdateTab("General"); } if (contentBattle.Parent != null) { contentBattle.Parent.Controls.Remove(contentBattle); } panelRemain.Controls.Add(contentBattle); panelRemain.Visible = true; tabBattle.Visible = false; } else { panelRemain.Controls.Remove(contentBattle); tabBattle.Visible = true; } } }; panelBrowser.Resize += (s, e) => UpdateLayout(false); Translator.Initialize(); DataStorage.Instance.Initialize(); DataStorage.Instance.PropertyEvent(nameof(DataStorage.Initialized), () => { this.contentGeneral.SetHomeport(DataStorage.Instance.Homeport); this.contentFleets.SetHomeport(DataStorage.Instance.Homeport); }); Settings.VerticalMode.PropertyEvent(nameof(Settings.VerticalMode.Value), () => UpdateLayout(true), true); Settings.BattleInfoLayout.PropertyEvent(nameof(Settings.BattleInfoLayout.Value), () => UpdateLayout(true), true); { int x = this.Left, y = this.Top; int w = this.Width, h = this.Height; int state = (int)this.WindowState; if (Settings.Application_X.Value != int.MinValue) { x = Settings.Application_X.Value; } if (Settings.Application_Y.Value != int.MinValue) { y = Settings.Application_Y.Value; } if (Settings.Application_Width.Value != int.MinValue) { w = Settings.Application_Width.Value; } if (Settings.Application_Height.Value != int.MinValue) { h = Settings.Application_Height.Value; } if (Settings.Application_State.Value != int.MinValue) { state = Settings.Application_State.Value; } this.StartPosition = FormStartPosition.Manual; this.WindowState = (FormWindowState)state; this.Location = new Point(x, y); this.Size = new Size(w, h); } this.Move += (s, e) => { Settings.Application_State.Value = (int)this.WindowState; if (this.WindowState != FormWindowState.Maximized) { Settings.Application_X.Value = this.Left; Settings.Application_Y.Value = this.Top; } }; this.Resize += (s, e) => { Settings.Application_State.Value = (int)this.WindowState; if (this.WindowState != FormWindowState.Maximized) { Settings.Application_Width.Value = this.Width; Settings.Application_Height.Value = this.Height; } }; this.FormClosing += (s, e) => { if (DataStorage.Instance?.IsInSortie ?? false) { if (MessageBox.Show("정말로 종료하시겠습니까?", Const.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.No) { e.Cancel = true; } } }; this.FormClosed += (s, e) => Application.Exit(); VolumeMixer.SetApplicationMute( Process.GetCurrentProcess().Id, Settings.Application_Muted.Value ); Settings.AlwaysOnTop.PropertyEvent(nameof(Settings.AlwaysOnTop.Value), () => this.TopMost = Settings.AlwaysOnTop.Value, true); Proxy.Instance.Register(e => { if (!e.Request.PathAndQuery.StartsWith("/kcsapi/")) { return; } var x = e.TryParse(false); if (x == null || !x.IsSuccess) { MessageProvider.Instance.Submit( string.Format( "서버에서 {0} 오류를 전달했습니다.", x?.RawData.api_result ?? -1 ), Const.ApplicationName ); } }); this.Show(); logger = new Logger(); openDB = new OpenDB(); }
private Dictionary <string, object> ExecuteQuery(OpenDB dbInfo, DBQuery query) { System.Diagnostics.Debug.Assert(!_isExecutingQuery, "SQLitePluginModule: Only 1 query should be executing at a time."); _isExecutingQuery = true; try { if (query.SQL == null) { throw new RNSQLiteException("You must specify a sql query to execute"); } try { var previousRowsAffected = _sqliteAPI.TotalChanges(dbInfo.Handle); var statement = _sqliteAPI.Prepare2(dbInfo.Handle, query.SQL); if (query.Params != null) { var argIndex = 0; foreach (var arg in query.Params.Children()) { // sqlite bind uses 1-based indexing for the arguments BindStatement(statement, argIndex + 1, arg); argIndex++; } } var resultRows = new List <Dictionary <string, object> >(); long? insertId = null; var rowsAffected = 0; SQLiteError error = null; var keepGoing = true; while (keepGoing) { switch (_sqliteAPI.Step(statement)) { case SQLite.Net.Interop.Result.Row: resultRows.Add(ExtractRow(statement)); break; case SQLite.Net.Interop.Result.Done: var nowRowsAffected = _sqliteAPI.TotalChanges(dbInfo.Handle); rowsAffected = nowRowsAffected - previousRowsAffected; var nowInsertId = _sqliteAPI.LastInsertRowid(dbInfo.Handle); if (rowsAffected > 0 && nowInsertId != 0) { insertId = nowInsertId; } keepGoing = false; break; default: var webErrorCode = sqliteToWebSQLError(_sqliteAPI.ErrCode(dbInfo.Handle)); var message = _sqliteAPI.Errmsg16(dbInfo.Handle); error = new SQLiteError(webErrorCode, message); keepGoing = false; break; } } _sqliteAPI.Finalize(statement); if (error != null) { NotifyOnSQLiteException(error); throw new RNSQLiteException(error); } var resultSet = new Dictionary <string, object> { { "rows", resultRows }, { "rowsAffected", rowsAffected } }; if (insertId != null) { resultSet["insertId"] = insertId; } return(resultSet); } catch (SQLite.Net.SQLiteException ex) { var error = new SQLiteError(sqliteToWebSQLError(ex.Result), ex.Message); NotifyOnSQLiteException(error); throw new RNSQLiteException(error); } } finally { _isExecutingQuery = false; } }
public void open(OpenOptions options, ICallback success, ICallback error) { QueueWithCancellation(async() => { var dbFileName = options.Name; if (dbFileName == null) { error.Invoke("You must specify database name"); return; } if (_openDBs.ContainsKey(dbFileName)) { success.Invoke("Database opened"); return; } var assetFileOp = ResolveAssetFile(options.AssetFileName, dbFileName); var assetFile = assetFileOp == null ? null : await assetFileOp; // NoMutex means SQLite can be safely used by multiple threads provided that no // single database connection is used simultaneously in two or more threads. SQLite.Net.Interop.SQLiteOpenFlags sqlOpenFlags = SQLite.Net.Interop.SQLiteOpenFlags.NoMutex; string absoluteDbPath; if (options.ReadOnly && assetFileOp != null) { sqlOpenFlags |= SQLite.Net.Interop.SQLiteOpenFlags.ReadOnly; absoluteDbPath = assetFile.Path; } else { sqlOpenFlags |= SQLite.Net.Interop.SQLiteOpenFlags.ReadWrite | SQLite.Net.Interop.SQLiteOpenFlags.Create; absoluteDbPath = ResolveDbFilePath(dbFileName); // Option to create from resource (pre-populated) if db does not exist: if (assetFileOp != null) { try { await CopyDbAsync(assetFile, dbFileName); } catch (Exception) { // CopyDbAsync throws when the file already exists. } } } SQLite.Net.Interop.IDbHandle dbHandle; if (_sqliteAPI.Open(GetNullTerminatedUtf8(absoluteDbPath), out dbHandle, (int)sqlOpenFlags, IntPtr.Zero) == SQLite.Net.Interop.Result.OK) { _openDBs[dbFileName] = new OpenDB(dbHandle, absoluteDbPath); success.Invoke("Database opened"); } else { error.Invoke("Unable to open DB"); } }); }