暫無描述
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.

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