123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- using System;
- using System.Data;
- using System.IO;
- using System.Net;
- using System.Text;
- using System.Windows.Forms;
- using SPCwebServiceDll.spcwebapi;
- namespace SPCwebServiceDll
- {
- public class ws
- {
- public class Resp
- {
- public DataSet ds { get; set; }
- public string msg { get; set; }
- }
- private static string configFile = Application.StartupPath + "\\SPCWebServiceAvary.ini";
- private static int timeout = 10000;
- public static string readCfgUrl()
- {
- if (!File.Exists(configFile))
- {
- File.Create(configFile);
- return "NG: 設定檔[" + configFile + "]遺失!";
- }
- StreamReader streamReader = new StreamReader(configFile, Encoding.Default);
- string text = streamReader.ReadLine();
- if (text.Length == 0)
- {
- return "NG: 設定檔[" + configFile + "]未設定內容!";
- }
- streamReader.Dispose();
- streamReader.Close();
- return text;
- }
- public static Resp getctrlitem(string ctrlitem)
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- Resp resp = new Resp();
- try
- {
- resp.ds = service.getctrlitem(ctrlitem);
- resp.msg = "OK";
- return resp;
- }
- catch (WebException ex)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- return resp;
- }
- catch (Exception ex2)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex2.Message.ToString();
- return resp;
- }
- }
- public static Resp getspclevel()
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- Resp resp = new Resp();
- try
- {
- resp.ds = service.getspclevel();
- resp.msg = "OK";
- return resp;
- }
- catch (WebException ex)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- return resp;
- }
- catch (Exception ex2)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex2.Message.ToString();
- return resp;
- }
- }
- public static Resp getspcfile_jsz(string filename)
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- Resp resp = new Resp();
- try
- {
- resp.ds = service.getspcfile_jsz(filename);
- resp.msg = "OK";
- return resp;
- }
- catch (WebException ex)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- return resp;
- }
- catch (Exception ex2)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex2.Message.ToString();
- return resp;
- }
- }
- public static Resp getspcdefcode_jsz(string uperid)
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- Resp resp = new Resp();
- try
- {
- resp.ds = service.getspcdefcode_jsz(uperid);
- resp.msg = "OK";
- return resp;
- }
- catch (WebException ex)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- return resp;
- }
- catch (Exception ex2)
- {
- resp.ds = null;
- resp.msg = "NG:" + ex2.Message.ToString();
- return resp;
- }
- }
- public static string spcapi(string pwd, string groupname, string filename, string ctrlitem, string measdate, string measdata, string sp, string level1, string level2, string level3, string level4, string level5, string level6, string level7, string level8, string level9, string level10, string level11, string level12, string level13, string level14, string level15, string level16, string level17, string level18, string level19, string level20)
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- string empty = string.Empty;
- try
- {
- return service.spcapi(pwd, groupname, filename, ctrlitem, measdate, measdata, sp, level1, level2, level3, level4, level5, level6, level7, level8, level9, level10, level11, level12, level13, level14, level15, level16, level17, level18, level19, level20);
- }
- catch (WebException ex)
- {
- return "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- }
- catch (Exception ex2)
- {
- return "NG:" + ex2.Message.ToString();
- }
- }
- public static string spcapi_jsz(string pwd, string groupname, string filename, string lot_no, string lot_quantity, string inspect_qty, string defect_num, string measdate, string defect_code, string defect_name, string defect_qty, string level1, string level2, string level3, string level4, string level5, string level6, string level7, string level8, string level9, string level10, string level11, string level12, string level13, string level14, string level15, string level16, string level17, string level18, string level19, string level20)
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- string empty = string.Empty;
- try
- {
- return service.spcapi_jsz(pwd, groupname, filename, lot_no, lot_quantity, inspect_qty, defect_num, measdate, defect_code, defect_name, defect_qty, level1, level2, level3, level4, level5, level6, level7, level8, level9, level10, level11, level12, level13, level14, level15, level16, level17, level18, level19, level20);
- }
- catch (WebException ex)
- {
- return "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- }
- catch (Exception ex2)
- {
- return "NG:" + ex2.Message.ToString();
- }
- }
- public static string spcapi_shortrun(string pwd, string groupname, string filename, string ctrlitem, string partno, string sc, string usl, string lsl)
- {
- Service1 service = new Service1();
- service.Url = readCfgUrl();
- service.Timeout = timeout;
- string empty = string.Empty;
- try
- {
- return service.spcapi_shortrun(pwd, groupname, filename, ctrlitem, partno, sc, usl, lsl);
- }
- catch (WebException ex)
- {
- return "NG:" + ex.Message.ToString() + "," + Convert.ToString(service.Timeout / 1000) + "秒沒回應";
- }
- catch (Exception ex2)
- {
- return "NG:" + ex2.Message.ToString();
- }
- }
- }
- }
|