123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- using UnityEngine.EventSystems;
- using System.Text.RegularExpressions;
- using System.Data.SqlClient;
- using System.Runtime.InteropServices;
- using System.Text;
- using TMPro;
- using System;
- using System.IO;
- using ZXing;
- using ZXing.QrCode;
- using System.Net;
- using System.Data;
- using SimpleJSON;
- using System.Linq;
- using System.ComponentModel;
- using System.Runtime.InteropServices;
- using System.Globalization;
-
-
- public class Main : MonoBehaviour
- {
- [SerializeField] TMP_Dropdown 連動下拉;
- public CanvasScaler canvasScaler;
-
- [SerializeField] Button 物料使用狀況;
- [SerializeField] Button 庫存查詢;
- [SerializeField] Button 銷售報表;
- [SerializeField] Button 車輛入廠紀錄;
- [SerializeField] Button 收支單一覽表;
- [SerializeField] Button 收支單審核;
- [SerializeField] Button 庫存盤損;
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
-
- private string loadingText = "";
- private int dotCount = 0;
-
- private List<Button> bts = new List<Button>();
-
- void Start()
- {
- Screen.autorotateToPortrait = false;
- Screen.orientation = ScreenOrientation.Portrait;
- float rate = 1000.0f / 1600.0f;
- if (canvasScaler == null)
- {
- canvasScaler = GetComponent<CanvasScaler>();
- }
- if (Main.Global.rate>rate)
- {
- canvasScaler.matchWidthOrHeight = 1f;
- }
- else
- {
- canvasScaler.matchWidthOrHeight = 0f;
- }
-
- StartCoroutine(AnimateText());
- 讀取面板.SetActive(true);
- StartCoroutine(讀取CC());
-
- }
-
- IEnumerator AnimateText()
- {
- string qqq = 讀取.text.ToString();
- while (true)
- {
- yield return new WaitForSeconds(0.5f);
-
- if (dotCount < 3)
- {
- loadingText += ".";
- dotCount++;
- }
- else
- {
- loadingText = "";
- dotCount = 0;
- }
- 讀取.text = qqq+loadingText;
- }
- }
- IEnumerator 讀取CC()
- {
- string strcon = "讀取";
- string name = Main.Global.PA;
- string ps = Main.Global.PB;
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&密碼={2}&se={3}", strcon, name, ps, se);
- Debug.Log(strUrl);
-
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- }
- JSONNode json1 = JSON.Parse(request.downloadHandler.text);
- Debug.Log(json1);
- 讀取面板.SetActive(false);
- Main.Global.人員 = json1[0].ToString().Trim('"');
- Main.Global.級別 = json1[129].ToString().Trim('"');
- Main.Global.職稱 = json1[131].ToString().Trim('"');
-
- if (json1[104].ToString()=="0")
- {
- Main.Global.可選擇車廠型式=false;
- }
- else
- {
- Main.Global.可選擇車廠型式=true;
- }
- if (json1[106].ToString()=="0")
- {
- Main.Global.開啟帳本=false;
- }
- else
- {
- Main.Global.開啟帳本=true;
- }
-
- if (json1[124].ToString()=="0")
- {
- 物料使用狀況.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(物料使用狀況);
- }
- if (json1[125].ToString()=="0")
- {
- 庫存查詢.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(庫存查詢);
- }
- if (json1[63].ToString()=="0")
- {
- 銷售報表.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(銷售報表);
- }
- if (json1[126].ToString()=="0")
- {
- 車輛入廠紀錄.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(車輛入廠紀錄);
- }
- if (json1[93].ToString()=="0")
- {
- 收支單一覽表.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(收支單一覽表);
- }
- if (json1[92].ToString()=="0")
- {
- 收支單審核.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(收支單審核);
- }
- if (json1[85].ToString()=="0")
- {
- 庫存盤損.gameObject.SetActive(false);
- }
- else
- {
- bts.Add(庫存盤損);
- }
- for (int i = 0; i < bts.Count; i++)
- {
- // 設定按鈕的位置
- float x = 200 + (i % 2) * 400; // 在每一行的水平位置
- float y = -250 - (i / 2) * 300; // 在每一行的垂直位置
- RectTransform rt = bts[i].GetComponent<RectTransform>();
- rt.anchoredPosition = new Vector2(x, y);
- }
-
- if (Main.Global.連動.Count > 1 && Main.Global.人員 != "測試人員")
- {
- 連動下拉.gameObject.SetActive(true);
- 連動下拉.options.Clear();
- List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
- string qa = "";
- for (int i = 0; i < Main.Global.連動.Count; i++)
- {
- if (Main.Global.連動[i][1].ToString().Trim('"') == Main.Global.預設伺服器路徑)
- {
- qa = Main.Global.連動[i][0].ToString().Trim('"');
- }
- string str = Main.Global.連動[i][0].ToString().Trim('"');
- options.Add(new TMP_Dropdown.OptionData(str));
- }
- 連動下拉.AddOptions(options);
- int index1 = 連動下拉.options.FindIndex(option => option.text == qa);
- 連動下拉.value = index1;
- 連動下拉.onValueChanged.AddListener(delegate
- {
- for (int i = 0; i<Main.Global.連動.Count; i++)
- {
- if (Main.Global.連動[i][0].ToString().Trim('"') == 連動下拉.options[連動下拉.value].text)
- {
- Main.Global.預設伺服器路徑 = Main.Global.連動[i][1].ToString().Trim('"');
- }
- }
- Debug.Log(Main.Global.預設伺服器路徑);
- });
- }
- else
- {
- 連動下拉.gameObject.SetActive(false);
- }
- 讀取面板.SetActive(false);
-
- }
- public void 開啟鎖定面板()
- {
- 彈跳面板.SetActive(true);
-
- }
- public void 關閉鎖定面板()
- {
- 彈跳面板.SetActive(false);
-
- }
- public void 程式鎖定()
- {
- StartCoroutine(鎖定系統());
- }
- IEnumerator 鎖定系統()
- {
- string strcon = "鎖定系統";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- Debug.Log(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- yield break;
- }
- yield return new WaitForSeconds(2f);
- Application.Quit();
- }
- public void 營銷報表()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(2);
- }
- public void 庫存()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(3);
- }
- public void 審核()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(6);
- }
- public void 物料使用()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(4);
- }
- public void 車輛紀錄()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(5);
- }
- public void 一覽表()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(7);
- }
- public void 盤營盤損()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(8);
- }
- public void changen()
- {
- //Main.Global.判斷是否第一次=true;
- change_Secen(0);
- }
- public void change_Secen(int _screenNum)
- {
- //Main.Global.判斷是否第一次=true;
- SceneManager.LoadScene(_screenNum);
- }
- public static class Global
- {
- public static string 登入人IP, 年,日期, 職稱,狀態,系統語言, 使用者名稱, 密碼, 進入, 離開, 資料庫版本號, 執行檔版本號,版本號比對,預設伺服器路徑,版本號,選擇組別,阿帕契路徑,阿帕契,CC判別,合約內容,合約編號,級別,ID,查詢日期,人員,連動客戶;
- public static bool 開啟帳本,判斷是否連線,可選擇車廠型式 ,啟動完畢,系統分區控制,登入位置,鏡頭啟動,有無清單 ,讀取完畢, 首次登入, 讀取年份, 快速登入, show1, show2, show3, show4, show5, show6, show7,展示帳號登入,qwe,印尼內網;
- public static int 部門編號,camfps;
- public static float rate, rate_, screenWidth, screenHeight;
- //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[5, 3];
- public static JSONNode 連動;
- }
- public void 截圖()
- {
- string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
- ScreenCapture.CaptureScreenshot(fileName);
- }
- }
|