123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using TMPro;
- using System.Data.SqlClient;
- using System;
-
-
-
-
- public class Main : MonoBehaviour
- {
-
- // Start is called before the first frame update
- void Start()
- {
-
-
- }
-
- public static class Global
- {
- public static string 預設伺服器路徑,阿帕契路徑,阿帕契,ID,人員;
- public static bool 國外,鏡頭啟動;
- public static int camfps;
- public static float rate, rate_;
- //public static TimeSpan 運行天數;
- public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
- //public static bool[] 電表異常BL = new bool[999];
- // public static Sprite[] Wnum;
- // public static Sprite[] Bnum;
- public static string[] 系統語言資料;
- // public static string[] CC判斷=new string[999];
- public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
- public static string[,] PHP = new string[99, 2];
- }
-
- public static void 讀取sql()
- {
- string connectionString = "Data Source=mssql-147629-0.cloudclusters.net,12711;Initial Catalog=GCM-IP-DATE01;User ID=GCMIP01;Password=Df85deS52w";
-
- using (SqlConnection connection = new SqlConnection(connectionString))
- {
- try
- {
- connection.Open();
-
- string query = "SELECT 類別,位址 FROM PHP連線 Where 名稱=N'HXQR'";
- using (SqlCommand command = new SqlCommand(query, connection))
- {
- using (SqlDataReader reader = command.ExecuteReader())
- {
- int row = 0;
- while (reader.Read()) // 假設只取前兩筆資料
- {
- // 取得類別和位址資料
- Main.Global.PHP[row, 0] = reader["類別"].ToString();
- Main.Global.PHP[row, 1] = reader["位址"].ToString();
-
- row++;
- }
- Main.Global.國外 = true;
- }
-
- }
- }
- catch (Exception ex)
- {
- Debug.LogError("Error connecting to the database: " + ex.Message);
- Main.Global.國外 = false;
- }
- finally
- {
- connection.Close();
- }
- }
- }
- public static string GetAddressByCategory(string category)
- {
- for (int i = 0; i < Main.Global.PHP.GetLength(0); i++)
- {
- if (Main.Global.PHP[i, 0] == category)
- {
- return Main.Global.PHP[i, 1];
- }
- }
- return ""; // 或者返回一個默認值
- }
- }
|