Nessuna descrizione
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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] TMP_Dropdown 連動下拉;
  27. public CanvasScaler canvasScaler;
  28. [SerializeField] Button 物料使用狀況;
  29. [SerializeField] Button 庫存查詢;
  30. [SerializeField] Button 銷售報表;
  31. [SerializeField] Button 車輛入廠紀錄;
  32. [SerializeField] Button 收支單一覽表;
  33. [SerializeField] Button 收支單審核;
  34. [SerializeField] Button 庫存盤損;
  35. [SerializeField] GameObject 讀取面板;
  36. [SerializeField] TextMeshProUGUI 讀取;
  37. [SerializeField] GameObject 彈跳面板;
  38. [SerializeField] TextMeshProUGUI 彈跳文字;
  39. private string loadingText = "";
  40. private int dotCount = 0;
  41. private List<Button> bts = new List<Button>();
  42. void Start()
  43. {
  44. Screen.autorotateToPortrait = false;
  45. Screen.orientation = ScreenOrientation.Portrait;
  46. float rate = 1000.0f / 1600.0f;
  47. if (canvasScaler == null)
  48. {
  49. canvasScaler = GetComponent<CanvasScaler>();
  50. }
  51. if (Main.Global.rate>rate)
  52. {
  53. canvasScaler.matchWidthOrHeight = 1f;
  54. }
  55. else
  56. {
  57. canvasScaler.matchWidthOrHeight = 0f;
  58. }
  59. StartCoroutine(AnimateText());
  60. 讀取面板.SetActive(true);
  61. StartCoroutine(讀取CC());
  62. }
  63. IEnumerator AnimateText()
  64. {
  65. string qqq = 讀取.text.ToString();
  66. while (true)
  67. {
  68. yield return new WaitForSeconds(0.5f);
  69. if (dotCount < 3)
  70. {
  71. loadingText += ".";
  72. dotCount++;
  73. }
  74. else
  75. {
  76. loadingText = "";
  77. dotCount = 0;
  78. }
  79. 讀取.text = qqq+loadingText;
  80. }
  81. }
  82. IEnumerator 讀取CC()
  83. {
  84. string strcon = "讀取";
  85. string name = Main.Global.PA;
  86. string ps = Main.Global.PB;
  87. string se = Main.Global.預設伺服器路徑;
  88. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&密碼={2}&se={3}", strcon, name, ps, se);
  89. Debug.Log(strUrl);
  90. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  91. yield return request.SendWebRequest();
  92. if (request.result == UnityWebRequest.Result.ConnectionError)
  93. {
  94. //Debug.Log(request.error);
  95. }
  96. JSONNode json1 = JSON.Parse(request.downloadHandler.text);
  97. Debug.Log(json1);
  98. 讀取面板.SetActive(false);
  99. Main.Global.人員 = json1[0].ToString().Trim('"');
  100. Main.Global.級別 = json1[129].ToString().Trim('"');
  101. Main.Global.職稱 = json1[131].ToString().Trim('"');
  102. if (json1[104].ToString()=="0")
  103. {
  104. Main.Global.可選擇車廠型式=false;
  105. }
  106. else
  107. {
  108. Main.Global.可選擇車廠型式=true;
  109. }
  110. if (json1[106].ToString()=="0")
  111. {
  112. Main.Global.開啟帳本=false;
  113. }
  114. else
  115. {
  116. Main.Global.開啟帳本=true;
  117. }
  118. if (json1[124].ToString()=="0")
  119. {
  120. 物料使用狀況.gameObject.SetActive(false);
  121. }
  122. else
  123. {
  124. bts.Add(物料使用狀況);
  125. }
  126. if (json1[125].ToString()=="0")
  127. {
  128. 庫存查詢.gameObject.SetActive(false);
  129. }
  130. else
  131. {
  132. bts.Add(庫存查詢);
  133. }
  134. if (json1[63].ToString()=="0")
  135. {
  136. 銷售報表.gameObject.SetActive(false);
  137. }
  138. else
  139. {
  140. bts.Add(銷售報表);
  141. }
  142. if (json1[126].ToString()=="0")
  143. {
  144. 車輛入廠紀錄.gameObject.SetActive(false);
  145. }
  146. else
  147. {
  148. bts.Add(車輛入廠紀錄);
  149. }
  150. if (json1[93].ToString()=="0")
  151. {
  152. 收支單一覽表.gameObject.SetActive(false);
  153. }
  154. else
  155. {
  156. bts.Add(收支單一覽表);
  157. }
  158. if (json1[92].ToString()=="0")
  159. {
  160. 收支單審核.gameObject.SetActive(false);
  161. }
  162. else
  163. {
  164. bts.Add(收支單審核);
  165. }
  166. if (json1[85].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 = 200 + (i % 2) * 400; // 在每一行的水平位置
  178. float y = -250 - (i / 2) * 300; // 在每一行的垂直位置
  179. RectTransform rt = bts[i].GetComponent<RectTransform>();
  180. rt.anchoredPosition = new Vector2(x, y);
  181. }
  182. if (Main.Global.連動.Count > 1 && Main.Global.人員 != "測試人員")
  183. {
  184. 連動下拉.gameObject.SetActive(true);
  185. 連動下拉.options.Clear();
  186. List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
  187. string qa = "";
  188. for (int i = 0; i < Main.Global.連動.Count; i++)
  189. {
  190. if (Main.Global.連動[i][1].ToString().Trim('"') == Main.Global.預設伺服器路徑)
  191. {
  192. qa = Main.Global.連動[i][0].ToString().Trim('"');
  193. }
  194. string str = Main.Global.連動[i][0].ToString().Trim('"');
  195. options.Add(new TMP_Dropdown.OptionData(str));
  196. }
  197. 連動下拉.AddOptions(options);
  198. int index1 = 連動下拉.options.FindIndex(option => option.text == qa);
  199. 連動下拉.value = index1;
  200. 連動下拉.onValueChanged.AddListener(delegate
  201. {
  202. for (int i = 0; i<Main.Global.連動.Count; i++)
  203. {
  204. if (Main.Global.連動[i][0].ToString().Trim('"') == 連動下拉.options[連動下拉.value].text)
  205. {
  206. Main.Global.預設伺服器路徑 = Main.Global.連動[i][1].ToString().Trim('"');
  207. }
  208. }
  209. Debug.Log(Main.Global.預設伺服器路徑);
  210. });
  211. }
  212. else
  213. {
  214. 連動下拉.gameObject.SetActive(false);
  215. }
  216. 讀取面板.SetActive(false);
  217. }
  218. public void 開啟鎖定面板()
  219. {
  220. 彈跳面板.SetActive(true);
  221. }
  222. public void 關閉鎖定面板()
  223. {
  224. 彈跳面板.SetActive(false);
  225. }
  226. public void 程式鎖定()
  227. {
  228. StartCoroutine(鎖定系統());
  229. }
  230. IEnumerator 鎖定系統()
  231. {
  232. string strcon = "鎖定系統";
  233. string se = Main.Global.預設伺服器路徑;
  234. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  235. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  236. Debug.Log(strUrl);
  237. yield return request.SendWebRequest();
  238. if (request.result == UnityWebRequest.Result.ConnectionError)
  239. {
  240. yield break;
  241. }
  242. yield return new WaitForSeconds(2f);
  243. Application.Quit();
  244. }
  245. public void 營銷報表()
  246. {
  247. //Main.Global.判斷是否第一次=true;
  248. change_Secen(2);
  249. }
  250. public void 庫存()
  251. {
  252. //Main.Global.判斷是否第一次=true;
  253. change_Secen(3);
  254. }
  255. public void 審核()
  256. {
  257. //Main.Global.判斷是否第一次=true;
  258. change_Secen(6);
  259. }
  260. public void 物料使用()
  261. {
  262. //Main.Global.判斷是否第一次=true;
  263. change_Secen(4);
  264. }
  265. public void 車輛紀錄()
  266. {
  267. //Main.Global.判斷是否第一次=true;
  268. change_Secen(5);
  269. }
  270. public void 一覽表()
  271. {
  272. //Main.Global.判斷是否第一次=true;
  273. change_Secen(7);
  274. }
  275. public void 盤營盤損()
  276. {
  277. //Main.Global.判斷是否第一次=true;
  278. change_Secen(8);
  279. }
  280. public void changen()
  281. {
  282. //Main.Global.判斷是否第一次=true;
  283. change_Secen(0);
  284. }
  285. public void change_Secen(int _screenNum)
  286. {
  287. //Main.Global.判斷是否第一次=true;
  288. SceneManager.LoadScene(_screenNum);
  289. }
  290. public static class Global
  291. {
  292. public static string 登入人IP, 年,日期, 職稱,狀態,系統語言, 使用者名稱, 密碼, 進入, 離開, 資料庫版本號, 執行檔版本號,版本號比對,預設伺服器路徑,版本號,選擇組別,阿帕契路徑,阿帕契,CC判別,合約內容,合約編號,級別,ID,查詢日期,人員,連動客戶;
  293. public static bool 開啟帳本,判斷是否連線,可選擇車廠型式 ,啟動完畢,系統分區控制,登入位置,鏡頭啟動,有無清單 ,讀取完畢, 首次登入, 讀取年份, 快速登入, show1, show2, show3, show4, show5, show6, show7,展示帳號登入,qwe,印尼內網;
  294. public static int 部門編號,camfps;
  295. public static float rate, rate_, screenWidth, screenHeight;
  296. //public static TimeSpan 運行天數;
  297. public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
  298. //public static bool[] 電表異常BL = new bool[999];
  299. // public static Sprite[] Wnum;
  300. // public static Sprite[] Bnum;
  301. public static string[] 系統語言資料;
  302. // public static string[] CC判斷=new string[999];
  303. public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
  304. public static string[,] PHP = new string[5, 3];
  305. public static JSONNode 連動;
  306. }
  307. public void 截圖()
  308. {
  309. string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
  310. ScreenCapture.CaptureScreenshot(fileName);
  311. }
  312. }