Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using TMPro;
  6. using System.Data.SqlClient;
  7. using System;
  8. public class Main : MonoBehaviour
  9. {
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. }
  14. public static class Global
  15. {
  16. public static string 預設伺服器路徑,阿帕契路徑,阿帕契,ID,人員;
  17. public static bool 國外,鏡頭啟動;
  18. public static int camfps;
  19. public static float rate, rate_;
  20. //public static TimeSpan 運行天數;
  21. public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
  22. //public static bool[] 電表異常BL = new bool[999];
  23. // public static Sprite[] Wnum;
  24. // public static Sprite[] Bnum;
  25. public static string[] 系統語言資料;
  26. // public static string[] CC判斷=new string[999];
  27. public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
  28. public static string[,] PHP = new string[99, 2];
  29. }
  30. public static void 讀取sql()
  31. {
  32. string connectionString = "Data Source=mssql-147629-0.cloudclusters.net,12711;Initial Catalog=GCM-IP-DATE01;User ID=GCMIP01;Password=Df85deS52w";
  33. using (SqlConnection connection = new SqlConnection(connectionString))
  34. {
  35. try
  36. {
  37. connection.Open();
  38. string query = "SELECT 類別,位址 FROM PHP連線 Where 名稱=N'HXQR'";
  39. using (SqlCommand command = new SqlCommand(query, connection))
  40. {
  41. using (SqlDataReader reader = command.ExecuteReader())
  42. {
  43. int row = 0;
  44. while (reader.Read()) // 假設只取前兩筆資料
  45. {
  46. // 取得類別和位址資料
  47. Main.Global.PHP[row, 0] = reader["類別"].ToString();
  48. Main.Global.PHP[row, 1] = reader["位址"].ToString();
  49. row++;
  50. }
  51. Main.Global.國外 = true;
  52. }
  53. }
  54. }
  55. catch (Exception ex)
  56. {
  57. Debug.LogError("Error connecting to the database: " + ex.Message);
  58. Main.Global.國外 = false;
  59. }
  60. finally
  61. {
  62. connection.Close();
  63. }
  64. }
  65. }
  66. public static string GetAddressByCategory(string category)
  67. {
  68. for (int i = 0; i < Main.Global.PHP.GetLength(0); i++)
  69. {
  70. if (Main.Global.PHP[i, 0] == category)
  71. {
  72. return Main.Global.PHP[i, 1];
  73. }
  74. }
  75. return ""; // 或者返回一個默認值
  76. }
  77. }