Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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 System.Text.RegularExpressions;
  8. using System.Data.SqlClient;
  9. using TMPro;
  10. using System;
  11. using System.IO;
  12. using ZXing;
  13. using ZXing.QrCode;
  14. using System.Net;
  15. using SimpleJSON;
  16. using System.ComponentModel;
  17. public class Main : MonoBehaviour
  18. {
  19. [SerializeField] GameObject 讀取面板;
  20. [SerializeField] TextMeshProUGUI 讀取;
  21. [SerializeField] GameObject 選單;
  22. [SerializeField] TextMeshProUGUI 伺服器;
  23. [SerializeField] Button 電子簽章_cb;
  24. [SerializeField] Button 個人照號管理_cb;
  25. [SerializeField] Button 點名_cb;
  26. [SerializeField] Button 庫存表_cb;
  27. [SerializeField] Button 生產排程表_cb;
  28. [SerializeField] Button 生產日報表_cb;
  29. [SerializeField] Button 出貨排程表_cb;
  30. [SerializeField] Button 出貨日報表_cb;
  31. [SerializeField] Button 庫存盤點_cb;
  32. [SerializeField] Button 庫存審查_cb;
  33. private List<Button> bts = new List<Button>();
  34. private string str;
  35. public CanvasScaler canvasScaler;
  36. public float idleTime = 300f; // 5分鐘的閒置時間
  37. private float timeSinceLastInteraction = 0f;
  38. private int buttonPressCount = 0;
  39. private float lastButtonPressTime = 0.0f;
  40. public float maxButtonPressInterval = 0.2f;
  41. public int requiredButtonPressCount = 5;
  42. private float timer = 0f;
  43. private float interval = 60f;
  44. private ScreenOrientation currentOrientation;
  45. float scale = 0;
  46. float xbar = 0;
  47. float ybar = 0;
  48. RectTransform panelRectTransform;
  49. float screenWidth;
  50. float screenHeight;
  51. private string loadingText = "";
  52. private int dotCount = 0;
  53. // Start is called before the first frame update
  54. void Start()
  55. {
  56. Screen.autorotateToPortrait = true;
  57. Screen.orientation = ScreenOrientation.AutoRotation;
  58. if (Screen.orientation == ScreenOrientation.LandscapeLeft)
  59. {
  60. float rate = 900.0f / 1900.0f;
  61. if (Main.Global.rate<rate)
  62. {
  63. canvasScaler.matchWidthOrHeight = 1f;
  64. }
  65. else
  66. {
  67. canvasScaler.matchWidthOrHeight = 0f;
  68. }
  69. }
  70. if (Screen.orientation == ScreenOrientation.Portrait)
  71. {
  72. float rate = 900.0f / 1900.0f;
  73. if (Main.Global.rate>rate)
  74. {
  75. canvasScaler.matchWidthOrHeight = 1f;
  76. }
  77. else
  78. {
  79. canvasScaler.matchWidthOrHeight = 0f;
  80. }
  81. }
  82. if (Main.Global.預設伺服器路徑=="official")
  83. {
  84. 伺服器.text="official";
  85. }
  86. else
  87. {
  88. 伺服器.text="test";
  89. }
  90. if (Main.Global.阿帕契路徑==Main.Global.PHP[0, 1] || Main.Global.阿帕契路徑==Main.Global.PHP[2, 1])
  91. {
  92. Main.Global.阿帕契路徑=Main.Global.PHP[2, 1];
  93. }
  94. else
  95. {
  96. Main.Global.阿帕契路徑=Main.Global.PHP[3, 1];
  97. }
  98. currentOrientation = Screen.orientation;
  99. //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/ow_main.php?";
  100. StartCoroutine(AnimateText());
  101. 讀取面板.SetActive(true);
  102. //Main.Global.預設伺服器路徑="official";
  103. //Main.Global.系統語言="繁體中文";
  104. //Main.Global.PA="b70340";
  105. //Main.Global.PB="0911274990";
  106. StartCoroutine(讀取CC());
  107. }
  108. void Update()
  109. {
  110. if (Screen.orientation != currentOrientation)
  111. {
  112. if (Screen.orientation == ScreenOrientation.LandscapeLeft)
  113. {
  114. change_Secen(12);
  115. }
  116. if (Screen.orientation == ScreenOrientation.Portrait)
  117. {
  118. change_Secen(1);
  119. }
  120. }
  121. }
  122. IEnumerator AnimateText()
  123. {
  124. string qqq = 讀取.text.ToString();
  125. while (true)
  126. {
  127. yield return new WaitForSeconds(0.5f);
  128. if (dotCount < 3)
  129. {
  130. loadingText += ".";
  131. dotCount++;
  132. }
  133. else
  134. {
  135. loadingText = "";
  136. dotCount = 0;
  137. }
  138. 讀取.text = qqq+loadingText;
  139. }
  140. }
  141. public void OnButtonPress()
  142. {
  143. if (Time.time - lastButtonPressTime > maxButtonPressInterval)
  144. {
  145. buttonPressCount = 0;
  146. }
  147. else
  148. {
  149. buttonPressCount++;
  150. }
  151. lastButtonPressTime = Time.time;
  152. if (buttonPressCount >= requiredButtonPressCount)
  153. {
  154. // 觸發你想要的事件
  155. buttonPressCount = 0;
  156. 選單.SetActive(true);
  157. }
  158. }
  159. IEnumerator 讀取CC()
  160. {
  161. string strcon = "讀取";
  162. string name = Main.Global.PA;
  163. string ps = Main.Global.PB;
  164. string se = Main.Global.預設伺服器路徑;
  165. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&密碼={2}&se={3}", strcon, name, ps, se);
  166. Debug.Log(strUrl);
  167. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  168. yield return request.SendWebRequest();
  169. if (request.result == UnityWebRequest.Result.ConnectionError)
  170. {
  171. //Debug.Log(request.error);
  172. }
  173. JSONNode json1 = JSON.Parse(request.downloadHandler.text);
  174. Debug.Log(json1);
  175. 讀取面板.SetActive(false);
  176. Main.Global.人員 = json1[0].ToString().Trim('"');
  177. Main.Global.級別 = json1[129].ToString().Trim('"');
  178. Main.Global.部門 = json1[130].ToString().Trim('"');
  179. Main.Global.職稱 = json1[131].ToString().Trim('"');
  180. Debug.Log(Main.Global.人員);
  181. 電子簽章_cb.gameObject.SetActive(false);
  182. //bts.Add(電子簽章_cb);
  183. bts.Add(個人照號管理_cb);
  184. bts.Add(庫存表_cb);
  185. if (json1[52].ToString()=="0")
  186. {
  187. 點名_cb.gameObject.SetActive(false);
  188. }
  189. else
  190. {
  191. bts.Add(點名_cb);
  192. }
  193. if (json1[53].ToString()=="0")
  194. {
  195. 生產排程表_cb.gameObject.SetActive(false);
  196. }
  197. else
  198. {
  199. bts.Add(生產排程表_cb);
  200. }
  201. if (json1[106].ToString()=="0")
  202. {
  203. 生產日報表_cb.gameObject.SetActive(false);
  204. }
  205. else
  206. {
  207. bts.Add(生產日報表_cb);
  208. }
  209. if (json1[109].ToString()=="0")
  210. {
  211. 出貨排程表_cb.gameObject.SetActive(false);
  212. }
  213. else
  214. {
  215. bts.Add(出貨排程表_cb);
  216. }
  217. if (json1[114].ToString()=="0")
  218. {
  219. 出貨日報表_cb.gameObject.SetActive(false);
  220. }
  221. else
  222. {
  223. bts.Add(出貨日報表_cb);
  224. }
  225. if (json1[85].ToString()=="0")
  226. {
  227. 庫存盤點_cb.gameObject.SetActive(false);
  228. }
  229. else
  230. {
  231. bts.Add(庫存盤點_cb);
  232. }
  233. if (json1[86].ToString()=="0")
  234. {
  235. 庫存審查_cb.gameObject.SetActive(false);
  236. }
  237. else
  238. {
  239. bts.Add(庫存審查_cb);
  240. }
  241. if (Screen.orientation == ScreenOrientation.LandscapeLeft)
  242. {
  243. for (int i = 0; i < bts.Count; i++)
  244. {
  245. float x, y;
  246. if (i % 2 == 0) // 偶數索引
  247. {
  248. x = 50f + (i / 2) * 250f;
  249. y = -50f;
  250. }
  251. else // 奇數索引
  252. {
  253. x = 50f + ((i - 1) / 2) * 250f;
  254. y = -400f;
  255. }
  256. RectTransform rt = bts[i].GetComponent<RectTransform>();
  257. rt.anchoredPosition = new Vector2(x, y);
  258. }
  259. }
  260. if (Screen.orientation == ScreenOrientation.Portrait)
  261. {
  262. for (int i = 0; i < bts.Count; i++)
  263. {
  264. // 設定按鈕的位置
  265. float x = 60 + (i % 4) * 210; // 在每一行的水平位置
  266. float y = -100 - (i / 4) * 300; // 在每一行的垂直位置
  267. RectTransform rt = bts[i].GetComponent<RectTransform>();
  268. rt.anchoredPosition = new Vector2(x, y);
  269. }
  270. }
  271. 讀取面板.SetActive(false);
  272. }
  273. public static class Global
  274. {
  275. public static string 登入人IP, 部門,年,日期, 職稱, 系統語言 ,使用者名稱, 密碼, 進入, 離開, 資料庫版本號, 執行檔版本號,版本號比對,預設伺服器路徑,版本號,選擇組別,阿帕契路徑,阿帕契,CC判別,合約內容,合約編號,級別,ID,查詢日期,人員,連動客戶;
  276. public static bool 判斷是否連線, 螢幕方向,啟動完畢,系統分區控制,登入位置,鏡頭啟動,有無清單 ,讀取完畢, 首次登入, 讀取年份, 快速登入, show1, show2, show3, show4, show5, show6, show7,展示帳號登入,qwe,印尼內網;
  277. public static int 部門編號,camfps;
  278. public static float rate, rate_;
  279. //public static TimeSpan 運行天數;
  280. public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
  281. //public static bool[] 電表異常BL = new bool[999];
  282. // public static Sprite[] Wnum;
  283. // public static Sprite[] Bnum;
  284. public static string[] 系統語言資料;
  285. // public static string[] CC判斷=new string[999];
  286. public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
  287. public static string[,] PHP = new string[5,2];
  288. }
  289. public void 回登入()
  290. {
  291. change_Secen(0);
  292. }
  293. public void 電簽()
  294. {
  295. change_Secen(2);
  296. }
  297. public void 個人帳號管理()
  298. {
  299. change_Secen(3);
  300. }
  301. public void 點名()
  302. {
  303. change_Secen(4);
  304. }
  305. public void 庫存()
  306. {
  307. change_Secen(5);
  308. }
  309. public void 生產排程()
  310. {
  311. change_Secen(6);
  312. }
  313. public void 出貨排程()
  314. {
  315. change_Secen(7);
  316. }
  317. public void 生產日報()
  318. {
  319. change_Secen(8);
  320. }
  321. public void 出貨日報()
  322. {
  323. change_Secen(9);
  324. }
  325. public void 盤點()
  326. {
  327. change_Secen(10);
  328. }
  329. public void 審查()
  330. {
  331. change_Secen(11);
  332. }
  333. public void 選單關閉()
  334. {
  335. 選單.SetActive(false);
  336. }
  337. public void 正式()
  338. {
  339. Main.Global.預設伺服器路徑="official";
  340. 伺服器.text="official";
  341. //StartCoroutine(測驗());
  342. }
  343. public void 測試()
  344. {
  345. Main.Global.預設伺服器路徑="test";
  346. 伺服器.text="test";
  347. //StartCoroutine(測驗());
  348. }
  349. public void change_Secen(int _screenNum)
  350. {
  351. SceneManager.LoadScene(_screenNum);
  352. }
  353. public void 截圖()
  354. {
  355. string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
  356. ScreenCapture.CaptureScreenshot(fileName);
  357. }
  358. }