No Description
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.

Main.cs 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6. using UnityEngine.Networking;
  7. using UnityEngine.EventSystems;
  8. using System.Text.RegularExpressions;
  9. using System.Data.SqlClient;
  10. using System.Runtime.InteropServices;
  11. using System.Text;
  12. using TMPro;
  13. using System;
  14. using System.IO;
  15. using ZXing;
  16. using ZXing.QrCode;
  17. using System.Net;
  18. using System.Data;
  19. using SimpleJSON;
  20. using System.Linq;
  21. using System.ComponentModel;
  22. using System.Runtime.InteropServices;
  23. using System.Globalization;
  24. public class Main : MonoBehaviour
  25. {
  26. [SerializeField] TextMeshProUGUI 伺服器;
  27. public CanvasScaler canvasScaler;
  28. [SerializeField] GameObject 讀取面板;
  29. [SerializeField] TextMeshProUGUI 讀取;
  30. [SerializeField] GameObject 彈跳面板;
  31. [SerializeField] TextMeshProUGUI 彈跳文字;
  32. private string loadingText = "";
  33. private int dotCount = 0;
  34. private List<Button> bts = new List<Button>();
  35. void Start()
  36. {
  37. Screen.autorotateToPortrait = false;
  38. Screen.orientation = ScreenOrientation.LandscapeLeft;
  39. float rate = 1600.0f / 1000.0f;
  40. if (Main.Global.rate>rate)
  41. {
  42. canvasScaler.matchWidthOrHeight = 1f;
  43. }
  44. else
  45. {
  46. canvasScaler.matchWidthOrHeight = 0f;
  47. }
  48. if (Main.Global.預設伺服器路徑=="official")
  49. {
  50. 伺服器.text="official";
  51. }
  52. else
  53. {
  54. 伺服器.text="test";
  55. }
  56. Debug.Log(Main.Global.阿帕契路徑);
  57. if (Main.Global.阿帕契路徑==Main.Global.PHP清單[0][1].ToString().Trim('"') || Main.Global.阿帕契路徑==Main.Global.PHP清單[2][1].ToString().Trim('"'))
  58. {
  59. Main.Global.阿帕契路徑=Main.Global.PHP清單[2][1].ToString().Trim('"');
  60. }
  61. else
  62. {
  63. Main.Global.阿帕契路徑=Main.Global.PHP清單[3][1].ToString().Trim('"');
  64. }
  65. Debug.Log(Main.Global.阿帕契路徑);
  66. StartCoroutine(AnimateText());
  67. 讀取面板.SetActive(true);
  68. StartCoroutine(讀取CC());
  69. }
  70. IEnumerator AnimateText()
  71. {
  72. string qqq = 讀取.text.ToString();
  73. while (true)
  74. {
  75. yield return new WaitForSeconds(0.5f);
  76. if (dotCount < 3)
  77. {
  78. loadingText += ".";
  79. dotCount++;
  80. }
  81. else
  82. {
  83. loadingText = "";
  84. dotCount = 0;
  85. }
  86. 讀取.text = qqq+loadingText;
  87. }
  88. }
  89. IEnumerator 讀取CC()
  90. {
  91. string strcon = "讀取";
  92. string name = Main.Global.PA;
  93. string ps = Main.Global.PB;
  94. string se = Main.Global.預設伺服器路徑;
  95. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&密碼={2}&se={3}", strcon, name, ps, se);
  96. Debug.Log(strUrl);
  97. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  98. yield return request.SendWebRequest();
  99. if (request.result == UnityWebRequest.Result.ConnectionError)
  100. {
  101. //Debug.Log(request.error);
  102. }
  103. Debug.Log(request.downloadHandler.text);
  104. JSONNode json1 = JSON.Parse(request.downloadHandler.text);
  105. Debug.Log(json1);
  106. 讀取面板.SetActive(false);
  107. Main.Global.人員 = json1[0].ToString().Trim('"');
  108. Main.Global.級別 = json1[129].ToString().Trim('"');
  109. Main.Global.職稱 = json1[131].ToString().Trim('"');
  110. //if (json1[104].ToString()=="0")
  111. //{
  112. // Main.Global.可選擇車廠型式=false;
  113. //}
  114. //else
  115. //{
  116. // Main.Global.可選擇車廠型式=true;
  117. //}
  118. //if (json1[106].ToString()=="0")
  119. //{
  120. // Main.Global.開啟帳本=false;
  121. //}
  122. //else
  123. //{
  124. // Main.Global.開啟帳本=true;
  125. //}
  126. //if (json1[124].ToString()=="0")
  127. //{
  128. // 物料使用狀況.gameObject.SetActive(false);
  129. //}
  130. //else
  131. //{
  132. // bts.Add(物料使用狀況);
  133. //}
  134. //if (json1[125].ToString()=="0")
  135. //{
  136. // 庫存查詢.gameObject.SetActive(false);
  137. //}
  138. //else
  139. //{
  140. // bts.Add(庫存查詢);
  141. //}
  142. //if (json1[63].ToString()=="0")
  143. //{
  144. // 銷售報表.gameObject.SetActive(false);
  145. //}
  146. //else
  147. //{
  148. // bts.Add(銷售報表);
  149. //}
  150. //if (json1[126].ToString()=="0")
  151. //{
  152. // 車輛入廠紀錄.gameObject.SetActive(false);
  153. //}
  154. //else
  155. //{
  156. // bts.Add(車輛入廠紀錄);
  157. //}
  158. //if (json1[93].ToString()=="0")
  159. //{
  160. // 收支單一覽表.gameObject.SetActive(false);
  161. //}
  162. //else
  163. //{
  164. // bts.Add(收支單一覽表);
  165. //}
  166. //if (json1[92].ToString()=="0")
  167. //{
  168. // 收支單審核.gameObject.SetActive(false);
  169. //}
  170. //else
  171. //{
  172. // bts.Add(收支單審核);
  173. //}
  174. //for (int i = 0; i < bts.Count; i++)
  175. //{
  176. // // 設定按鈕的位置
  177. // float x = 150 + (i % 2) * 450; // 在每一行的水平位置
  178. // float y = -250 - (i / 2) * 475; // 在每一行的垂直位置
  179. // RectTransform rt = bts[i].GetComponent<RectTransform>();
  180. // rt.anchoredPosition = new Vector2(x, y);
  181. //}
  182. }
  183. public void 截圖()
  184. {
  185. string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
  186. ScreenCapture.CaptureScreenshot(fileName);
  187. }
  188. public void 配方()
  189. {
  190. change_Secen(2);
  191. }
  192. public void 拍照()
  193. {
  194. change_Secen(3);
  195. }
  196. public void 拍照1()
  197. {
  198. change_Secen(4);
  199. }
  200. public void 檢點()
  201. {
  202. change_Secen(5);
  203. }
  204. public void changen()
  205. {
  206. //Main.Global.判斷是否第一次=true;
  207. change_Secen(0);
  208. }
  209. public void change_Secen(int _screenNum)
  210. {
  211. //Main.Global.判斷是否第一次=true;
  212. SceneManager.LoadScene(_screenNum);
  213. }
  214. public static class Global
  215. {
  216. public static string 登入人IP, 年,日期 ,職稱,狀態,系統語言, 使用者名稱, 密碼, 進入, 離開, 資料庫版本號, 執行檔版本號,版本號比對,預設伺服器路徑,版本號,選擇組別,阿帕契路徑,阿帕契,CC判別,合約內容,合約編號,級別,ID,查詢日期,人員,連動客戶;
  217. public static bool 開啟帳本,判斷是否連線,可選擇車廠型式 ,啟動完畢,系統分區控制,登入位置,鏡頭啟動,有無清單 ,讀取完畢, 首次登入, 讀取年份, 快速登入, show1, show2, show3, show4, show5, show6, show7,展示帳號登入,qwe,印尼內網;
  218. public static int 部門編號,camfps;
  219. public static float rate, rate_;
  220. //public static TimeSpan 運行天數;
  221. public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
  222. //public static bool[] 電表異常BL = new bool[999];
  223. // public static Sprite[] Wnum;
  224. // public static Sprite[] Bnum;
  225. public static string[] 系統語言資料;
  226. // public static string[] CC判斷=new string[999];
  227. public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
  228. public static string[,] PHP = new string[5, 2];
  229. public static JSONArray PHP清單;
  230. }
  231. }