فهرست منبع

Read db files

Axel Nordh 3 سال پیش
والد
کامیت
f276ef230d

+ 11 - 0
Assets/Scripts/Database/Question.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: cd9cb0684d7789345a9a493840d14e16
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 88 - 0
Logs/AssetImportWorker0.log

@@ -319,3 +319,91 @@ Received Import Request.
   path: Assets/Scripts/Database/DatabaseController.cs
   artifactKey: Guid(a4b49e87c1008ec41be36a542eecfcf8) Importer(815301076,1909f56bfc062723c751e8b465ee728b)
 Start importing Assets/Scripts/Database/DatabaseController.cs using Guid(a4b49e87c1008ec41be36a542eecfcf8) Importer(815301076,1909f56bfc062723c751e8b465ee728b)  -> (artifact id: 'd60380cde25de6bb5c3c3558a55a8008') in 0.005227 seconds 
+========================================================================
+Received Prepare
+Registering precompiled user dll's ...
+Registered in 0.012740 seconds.
+Begin MonoManager ReloadAssembly
+Symbol file LoadedFromMemory doesn't match image F:\Unity\Projects\NarKampenTake2\Library\PackageCache\com.unity.visualscripting@1.7.8\Editor\VisualScripting.Core\Dependencies\DotNetZip\Unity.VisualScripting.IonicZip.dll
+Symbol file LoadedFromMemory doesn't match image F:\Unity\Projects\NarKampenTake2\Library\PackageCache\com.unity.visualscripting@1.7.8\Editor\VisualScripting.Core\Dependencies\YamlDotNet\Unity.VisualScripting.YamlDotNet.dll
+Native extension for WindowsStandalone target not found
+Native extension for iOS target not found
+Native extension for Android target not found
+Refreshing native plugins compatible for Editor in 0.70 ms, found 6 plugins.
+Preloading 0 native plugins for Editor in 0.00 ms.
+Unable to write to 'ProjectSettings\GvhProjectSettings.xml' (System.IO.IOException: Sharing violation on path F:\Unity\Projects\NarKampenTake2\ProjectSettings\GvhProjectSettings.xml
+  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <9aad1b3a47484d63ba2b3985692d80e9>:0 
+  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) [0x00000] in <9aad1b3a47484d63ba2b3985692d80e9>:0 
+  at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean useAsync) [0x00000] in <9aad1b3a47484d63ba2b3985692d80e9>:0 
+  at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int,bool)
+  at System.Xml.XmlWriterSettings.CreateWriter (System.String outputFileName) [0x00051] in <dd0557022e4e4150b548e69900b259c8>:0 
+  at System.Xml.XmlWriter.Create (System.String outputFileName, System.Xml.XmlWriterSettings settings) [0x0000a] in <dd0557022e4e4150b548e69900b259c8>:0 
+  at Google.ProjectSettings.Save () [0x0006d] in /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:821 , Project settings were not saved!
+UnityEngine.StackTraceUtility:ExtractStackTrace ()
+UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
+UnityEngine.Logger:Log (UnityEngine.LogType,object)
+UnityEngine.Debug:LogError (object)
+Google.Logger:Log (string,Google.LogLevel) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs:136)
+Google.ProjectSettings:Save () (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:844)
+Google.ProjectSettings:SetBool (string,bool,Google.SettingsLocation) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:485)
+Google.ProjectSettings:SetBool (string,bool) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:497)
+Google.IOSResolver:set_VerboseLoggingEnabled (bool) (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:1040)
+Google.IOSResolver:.cctor () (at /Users/drsanta/dev/tmp/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:726)
+System.Runtime.CompilerServices.RuntimeHelpers:RunClassConstructor (System.RuntimeTypeHandle)
+UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[])
+
+(Filename: /Users/drsanta/dev/tmp/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs Line: 844)
+
+Mono: successfully reloaded assembly
+- Completed reload, in  1.263 seconds
+Domain Reload Profiling:
+	ReloadAssembly (1264ms)
+		BeginReloadAssembly (163ms)
+			ExecutionOrderSort (0ms)
+			DisableScriptedObjects (12ms)
+			BackupInstance (0ms)
+			ReleaseScriptingObjects (0ms)
+			CreateAndSetChildDomain (46ms)
+		EndReloadAssembly (987ms)
+			LoadAssemblies (113ms)
+			RebuildTransferFunctionScriptingTraits (0ms)
+			SetupTypeCache (315ms)
+			ReleaseScriptCaches (1ms)
+			RebuildScriptCaches (48ms)
+			SetupLoadedEditorAssemblies (467ms)
+				LogAssemblyErrors (0ms)
+				InitializePlatformSupportModulesInManaged (27ms)
+				SetLoadedEditorAssemblies (0ms)
+				RefreshPlugins (1ms)
+				BeforeProcessingInitializeOnLoad (87ms)
+				ProcessInitializeOnLoadAttributes (283ms)
+				ProcessInitializeOnLoadMethodAttributes (65ms)
+				AfterProcessingInitializeOnLoad (3ms)
+				EditorAssembliesLoaded (0ms)
+			ExecutionOrderSort2 (0ms)
+			AwakeInstancesAfterBackupRestoration (15ms)
+Platform modules already initialized, skipping
+Refreshing native plugins compatible for Editor in 2.92 ms, found 6 plugins.
+Preloading 0 native plugins for Editor in 0.00 ms.
+Unloading 4085 Unused Serialized files (Serialized files now loaded: 0)
+Unloading 48 unused Assets / (26.0 KB). Loaded Objects now: 4553.
+Memory consumption went from 151.8 MB to 151.8 MB.
+Total: 2.992500 ms (FindLiveObjects: 0.246900 ms CreateObjectMapping: 0.171200 ms MarkObjects: 2.537500 ms  DeleteObjects: 0.036300 ms)
+
+AssetImportParameters requested are different than current active one (requested -> active):
+  custom:video-decoder-ogg-theora: a1e56fd34408186e4bbccfd4996cb3dc -> 
+  custom:container-muxer-webm: aa71ff27fc2769a1b78a27578f13a17b -> 
+  custom:container-demuxer-webm: 4f35f7cbe854078d1ac9338744f61a02 -> 
+  custom:video-encoder-webm-vp8: eb34c28f22e8b96e1ab97ce403110664 -> 
+  custom:video-codec-MediaFoundation-h265: 746d11721c4dcdbdad8f713fa42b33f4 -> 
+  custom:audio-encoder-webm-vorbis: bf7c407c2cedff20999df2af8eb42d56 -> 
+  custom:framework-win-MediaFoundation: 216162199b28c13a410421893ffa2e32 -> 
+  custom:container-demuxer-ogg: 62fdf1f143b41e24485cea50d1cbac27 -> 
+  custom:video-decoder-webm-vp8: 9c59270c3fd7afecdb556c50c9e8de78 -> 
+  custom:audio-decoder-ogg-vorbis: bf7c407c2cedff20999df2af8eb42d56 -> 
+========================================================================
+Received Import Request.
+  Time since last request: 43069.217007 seconds.
+  path: Assets/Scripts/Database/DatabaseController.cs
+  artifactKey: Guid(a4b49e87c1008ec41be36a542eecfcf8) Importer(815301076,1909f56bfc062723c751e8b465ee728b)
+Start importing Assets/Scripts/Database/DatabaseController.cs using Guid(a4b49e87c1008ec41be36a542eecfcf8) Importer(815301076,1909f56bfc062723c751e8b465ee728b)  -> (artifact id: '761144ddbe3cfa1ab45b8cbd313c1f6f') in 0.006955 seconds 

+ 59 - 0
Logs/AssetImportWorker1.log

@@ -300,6 +300,65 @@ Unloading 48 unused Assets / (26.1 KB). Loaded Objects now: 4549.
 Memory consumption went from 151.8 MB to 151.8 MB.
 Total: 2.524900 ms (FindLiveObjects: 0.230200 ms CreateObjectMapping: 0.178700 ms MarkObjects: 2.086300 ms  DeleteObjects: 0.029100 ms)
 
+AssetImportParameters requested are different than current active one (requested -> active):
+  custom:video-decoder-ogg-theora: a1e56fd34408186e4bbccfd4996cb3dc -> 
+  custom:container-muxer-webm: aa71ff27fc2769a1b78a27578f13a17b -> 
+  custom:container-demuxer-webm: 4f35f7cbe854078d1ac9338744f61a02 -> 
+  custom:video-encoder-webm-vp8: eb34c28f22e8b96e1ab97ce403110664 -> 
+  custom:video-codec-MediaFoundation-h265: 746d11721c4dcdbdad8f713fa42b33f4 -> 
+  custom:audio-encoder-webm-vorbis: bf7c407c2cedff20999df2af8eb42d56 -> 
+  custom:framework-win-MediaFoundation: 216162199b28c13a410421893ffa2e32 -> 
+  custom:container-demuxer-ogg: 62fdf1f143b41e24485cea50d1cbac27 -> 
+  custom:video-decoder-webm-vp8: 9c59270c3fd7afecdb556c50c9e8de78 -> 
+  custom:audio-decoder-ogg-vorbis: bf7c407c2cedff20999df2af8eb42d56 -> 
+========================================================================
+Received Prepare
+Registering precompiled user dll's ...
+Registered in 0.014436 seconds.
+Begin MonoManager ReloadAssembly
+Symbol file LoadedFromMemory doesn't match image F:\Unity\Projects\NarKampenTake2\Library\PackageCache\com.unity.visualscripting@1.7.8\Editor\VisualScripting.Core\Dependencies\DotNetZip\Unity.VisualScripting.IonicZip.dll
+Symbol file LoadedFromMemory doesn't match image F:\Unity\Projects\NarKampenTake2\Library\PackageCache\com.unity.visualscripting@1.7.8\Editor\VisualScripting.Core\Dependencies\YamlDotNet\Unity.VisualScripting.YamlDotNet.dll
+Native extension for WindowsStandalone target not found
+Native extension for iOS target not found
+Native extension for Android target not found
+Refreshing native plugins compatible for Editor in 0.69 ms, found 6 plugins.
+Preloading 0 native plugins for Editor in 0.00 ms.
+Mono: successfully reloaded assembly
+- Completed reload, in  1.291 seconds
+Domain Reload Profiling:
+	ReloadAssembly (1292ms)
+		BeginReloadAssembly (161ms)
+			ExecutionOrderSort (0ms)
+			DisableScriptedObjects (10ms)
+			BackupInstance (0ms)
+			ReleaseScriptingObjects (0ms)
+			CreateAndSetChildDomain (47ms)
+		EndReloadAssembly (1025ms)
+			LoadAssemblies (115ms)
+			RebuildTransferFunctionScriptingTraits (0ms)
+			SetupTypeCache (327ms)
+			ReleaseScriptCaches (1ms)
+			RebuildScriptCaches (45ms)
+			SetupLoadedEditorAssemblies (490ms)
+				LogAssemblyErrors (0ms)
+				InitializePlatformSupportModulesInManaged (27ms)
+				SetLoadedEditorAssemblies (0ms)
+				RefreshPlugins (1ms)
+				BeforeProcessingInitializeOnLoad (91ms)
+				ProcessInitializeOnLoadAttributes (316ms)
+				ProcessInitializeOnLoadMethodAttributes (50ms)
+				AfterProcessingInitializeOnLoad (3ms)
+				EditorAssembliesLoaded (0ms)
+			ExecutionOrderSort2 (0ms)
+			AwakeInstancesAfterBackupRestoration (15ms)
+Platform modules already initialized, skipping
+Refreshing native plugins compatible for Editor in 2.89 ms, found 6 plugins.
+Preloading 0 native plugins for Editor in 0.00 ms.
+Unloading 4085 Unused Serialized files (Serialized files now loaded: 0)
+Unloading 48 unused Assets / (26.0 KB). Loaded Objects now: 4553.
+Memory consumption went from 151.8 MB to 151.8 MB.
+Total: 2.798100 ms (FindLiveObjects: 0.285800 ms CreateObjectMapping: 0.178500 ms MarkObjects: 2.300500 ms  DeleteObjects: 0.032300 ms)
+
 AssetImportParameters requested are different than current active one (requested -> active):
   custom:video-decoder-ogg-theora: a1e56fd34408186e4bbccfd4996cb3dc -> 
   custom:container-muxer-webm: aa71ff27fc2769a1b78a27578f13a17b -> 

+ 0 - 83
ServerFiles/OLDnarKampen/dbFiles/ReadQuestionsFromFile.php

@@ -1,83 +0,0 @@
-<?php 
-
-	$hostname = 'localhost';
-	$username = 'narKampen';
-	$pass = 'IfRLzj2HJBXA9eei';
-	$database = 'narKampen';
-	
-	$conn = new mysqli($hostname, $username, $pass, $database);
-	if (!$conn) {
-		die("Connection Failed. ". mysqli_connect_error());
-	}
-	mysqli_set_charset($conn,'utf8');
-	
-// Check if file is CSV
-// get Filename, remove ending, this is the category name
-// get file contents 
-
-if (file_exists($argv[1])) {
-	$file = fopen($argv[1], "r");
-	$fileinfo = pathinfo($argv[1]);
-	
-	$categoryName = str_replace("_"," ", $fileinfo['filename']);
-	
-	while (($data = fgetcsv($file, 1000, ",")) !== false) {
-		$answer = intval($data[0]);
-		$question = $data[1];
-	 
-		if ($answer == null || $question == null || $answer == "" || $question == "") {
-			echo "Failed to get answer and/or question from " . print_r($data,true) .  "\r\n";
-			die();
-		}
-	 
-		$sql = "SELECT id FROM questions WHERE question = '$question'";
-		$result = $conn->query($sql);
-		if ($result === FALSE) {
-			echo "Insert new question $question \r\n";
-		} else {
-			$questionId = $result->fetch_object()->id;
-		}
-$result->free_result();
-		
-		if($questionId == null) {
-			$sql = "INSERT INTO questions (answer, question) 
-				VALUES ($answer, '$question') 
-				ON DUPLICATE KEY UPDATE 
-				answer = $answer,
-				id = LAST_INSERT_ID(id)";
-			$conn->query($sql);
-			$questionId = $conn->insert_id;	 
-		}
-		
-		if ($questionId == 0) {
-		
-			echo "Nothing insered or updated by sql: \r\n";
-			echo $sql;
-			die(); // Should not happen!
-		}
-		
-		$sql = "SELECT id FROM category WHERE name = '$categoryName'";
-		$result = $conn->query($sql);
-		if ($result === FALSE) {
-			echo "Failed to get category, add New with name $categoryName";
-		} else {
-			$categoryId = $result->fetch_object()->id;
-		}
-$result->free_result();
-		
-		if ($categoryId == null) {
-			$sql = "INSERT INTO category (name, r,g,b,a) VALUES ($categoryName, 255,255,255,255)";
-			$conn->query($sql);
-			$categoryId = $conn->insert_id;
-		}
-		
-		$sql = "INSERT INTO questionToCategory (questionId, categoryId) VALUES ($questionId, $categoryId)";
-		$conn->query($sql);
-		
-		echo "inserted question $question into category $categoryName \r\n";
- }
- 
- fclose($file);
-} else {
-	echo "Run with file as first argument";
-}

+ 1 - 1
ServerFiles/Questions.php

@@ -17,7 +17,7 @@ try {
     echo '<h1>An error har occured. </h1><pre>', $e->getMessage(), '</pre>';
 }
 
-$sth = $dbh->query('SELECT * FROM questions LIMIT 5');
+$sth = $dbh->query('SELECT * FROM Questions LIMIT 5');
 $sth->setFetchMode(PDO::FETCH_ASSOC);
 
 $result = $sth->fetchAll();

+ 89 - 0
ServerFiles/ReadQuestionsFromFile.php

@@ -0,0 +1,89 @@
+<?php
+
+$hostname = 'localhost';
+$username = 'narKampen';
+$pass = '9Bq.6[AcTc2ADwN-';
+$database = 'narKampen';
+
+$conn = new mysqli($hostname, $username, $pass, $database);
+if (!$conn) {
+    die('Connection Failed. ' . mysqli_connect_error());
+}
+mysqli_set_charset($conn, 'utf8');
+
+// Check if file is CSV
+// get Filename, remove ending, this is the category name
+// get file contents
+
+if (file_exists($argv[1])) {
+    $file = fopen($argv[1], 'r');
+    $fileinfo = pathinfo($argv[1]);
+
+    $categoryName = str_replace('_', ' ', $fileinfo['filename']);
+
+    while (($data = fgetcsv($file, 1000, ',')) !== false) {
+        $answer = intval($data[0]);
+        $question = $data[1];
+
+        if (
+            $answer == null ||
+            $question == null ||
+            $answer == '' ||
+            $question == ''
+        ) {
+            echo 'Failed to get answer and/or question from ' .
+                print_r($data, true) .
+                "\r\n";
+            die();
+        }
+
+        $sql = "SELECT id FROM questions WHERE question = '$question'";
+        $result = $conn->query($sql);
+        if ($result === false) {
+            echo "Insert new question $question \r\n";
+        } else {
+            $questionId = $result->fetch_object()->id;
+        }
+        $result->free_result();
+
+        if ($questionId == null) {
+            $sql = "INSERT INTO questions (answer, question)
+				VALUES ($answer, '$question')
+				ON DUPLICATE KEY UPDATE
+				answer = $answer,
+				id = LAST_INSERT_ID(id)";
+            $conn->query($sql);
+            $questionId = $conn->insert_id;
+        }
+
+        if ($questionId == 0) {
+            echo "Nothing insered or updated by sql: \r\n";
+            echo $sql;
+            die(); // Should not happen!
+        }
+
+        $sql = "SELECT id FROM category WHERE name = '$categoryName'";
+        $result = $conn->query($sql);
+        if ($result === false) {
+            echo "Failed to get category, add New with name $categoryName";
+        } else {
+            $categoryId = $result->fetch_object()->id;
+        }
+        $result->free_result();
+
+        if ($categoryId == null) {
+            $sql = "INSERT INTO category (name, r,g,b,a) VALUES ($categoryName, 255,255,255,255)";
+            $conn->query($sql);
+            $categoryId = $conn->insert_id;
+        }
+
+        $sql = "INSERT INTO questionToCategory (questionId, categoryId) VALUES ($questionId, $categoryId)";
+        $conn->query($sql);
+
+        echo "inserted question $question into category $categoryName \r\n";
+    }
+
+    fclose($file);
+} else {
+    echo 'Run with file as first argument';
+}