private void btnHome_Click(object sender, EventArgs e) { etaxOneth etaxForm = new etaxOneth(); this.Close(); etaxForm.Show(); }
public void sendtochat_UAT(string urluat, etaxOneth from) { JObject oKeepResponeExecute = new JObject(); try { var client1 = new RestClient("https://uatchat-public.one.th:8034/api/v1/push_message"); var request1 = new RestRequest(Method.POST); request1.AddHeader("cache-control", "no-cache"); request1.AddHeader("Authorization", "Bearer A114be672146a57b690973a5b600f446187e8f9b094e84ae5a955780e477ae54a5cd8f63d965a462a822a7cad1b970374"); request1.AddHeader("Content-Type", "application/json"); //request1.AddParameter("undefined", "{\n \"to\": \"" + uidchatprod + "\",\n \"bot_id\": \"B0df132b88f9a526691a0576bfdb24196\",\n \"type\": \"template\",\n \"elements\": [\n {\n \"image\": \"http://clustem.eu/wp-content/uploads/icona-download-pdf.png\",\n \"title\": \"PDF File\",\n \"detail\": \"ตรวจสอบเอกสาร PDF\",\n \"choice\": [\n {\n \"label\": \"ตรวจสอบ\",\n \"type\": \"file\",\n \"file\": \"" + urlpor + "\",\n \"payload\": {\n \"keyword\": \"savefile\",\n \"msgtxt\": \"pdffile\"\n }\n }\n ]\n }\n ]\n}", ParameterType.RequestBody); request1.AddParameter("undefined", "{\n \"to\": \"" + from.txt_uid + "\",\n \"bot_id\": \"B0df132b88f9a526691a0576bfdb24196\",\n\"type\":\"template\",\n\"elements\": [\n {\n\"image\": \"http://clustem.eu/wp-content/uploads/icona-download-pdf.png\",\n \"title\": \"PDF File\",\n\"detail\": \"ชื่อเอกสาร : " + from.txt_namefile + " Tracking : " + from.txt_trackingid + "\",\n \"choice\": [\n {\n \"label\": \"ดาวน์โหลด\",\n \"type\": \"file\",\n \"file\": \"" + urluat + "\",\n \"payload\": {\n \"keyword\": \"savefile\",\n \"msgtxt\": \"pdffile\",\n \"namefile\": \"" + from.txt_namefile + "\",\n \"tracking_id\":\"" + from.txt_trackingid + "\"\n }\n }\n ]\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response1 = client1.Execute(request1); oKeepResponeExecute = JObject.Parse(response1.Content); Console.WriteLine(oKeepResponeExecute); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void GENTRACKING(etaxOneth from) { JObject oKeepResponeExecute = new JObject(); try { var client = new RestClient("https://etaxgateway.one.th:8550/api/v1/tracking"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("undefined", "{\n\t\"auth\":\"oeb2019\",\n\t\"username\":\"" + from.txtUserCode.Text + "\",\n\t\"file_name\":\"" + from.txt_namefile + "\",\n\t\"email\":\"" + from.txt_email + "\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); oKeepResponeExecute = JObject.Parse(response.Content); Console.WriteLine(oKeepResponeExecute); from.txt_trackingid = oKeepResponeExecute["tracking_id"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { oKeepResponeExecute = null; GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void production(etaxOneth from) { JObject oKeepResponeExecute = new JObject(); try { var client = new RestClient("https://etaxgateway.one.th:8550/api/v1/getuser_id"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/json"); request.AddParameter("application/json", "{\n\t\"username\":\"" + from.txtUserCode.Text + "\",\n\t\"type\":\"PROD\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); oKeepResponeExecute = JObject.Parse(response.Content); if (oKeepResponeExecute["message"].ToString() == "success") { idpord = (oKeepResponeExecute["text"]["id"]).ToString(); uidchatprod1 = this.checktofrdprod(idpord); from.txt_uid = uidchatprod1; from.txt_email = oKeepResponeExecute["text"]["thai_email"].ToString(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void sendtochat(string urlpor, etaxOneth from) { JObject oKeepResponeExecute = new JObject(); try { var client1 = new RestClient("https://chat-public.one.th:8034/api/v1/push_message"); var request1 = new RestRequest(Method.POST); request1.AddHeader("cache-control", "no-cache"); request1.AddHeader("Authorization", "Bearer A16185216830056b1946f138905230c3c633dbeec596d4e8d962971c40269af89a5b101b00a02411db4d741312cee67d5"); request1.AddHeader("Content-Type", "application/json"); //request1.AddParameter("undefined", "{\n \"to\": \"" + uidchatprod + "\",\n \"bot_id\": \"B0df132b88f9a526691a0576bfdb24196\",\n \"type\": \"template\",\n \"elements\": [\n {\n \"image\": \"http://clustem.eu/wp-content/uploads/icona-download-pdf.png\",\n \"title\": \"PDF File\",\n \"detail\": \"ตรวจสอบเอกสาร PDF\",\n \"choice\": [\n {\n \"label\": \"ตรวจสอบ\",\n \"type\": \"file\",\n \"file\": \"" + urlpor + "\",\n \"payload\": {\n \"keyword\": \"savefile\",\n \"msgtxt\": \"pdffile\"\n }\n }\n ]\n }\n ]\n}", ParameterType.RequestBody); request1.AddParameter("undefined", "{\n \"to\": \"" + from.txt_uid + "\",\n \"bot_id\": \"B0df132b88f9a526691a0576bfdb24196\",\n\"type\":\"template\",\n\"elements\": [\n {\n\"image\": \"http://clustem.eu/wp-content/uploads/icona-download-pdf.png\",\n \"title\": \"PDF File\",\n\"detail\": \"ชื่อเอกสาร " + from.txt_namefile + "Tracking " + from.txt_trackingid + "\",\n \"choice\": [\n {\n \"label\": \"ดาวน์โหลด\",\n \"type\": \"file\",\n \"file\": \"" + urluat + "\",\n \"payload\": {\n \"keyword\": \"savefile\",\n \"msgtxt\": \"pdffile\",\n \"namefile\": \"" + from.txt_namefile + "\",\n \"tracking_id\":\"" + from.txt_trackingid + "\"\n }\n }\n ]\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response1 = client1.Execute(request1); oKeepResponeExecute = JObject.Parse(response1.Content); Console.WriteLine(oKeepResponeExecute); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void EndSocketAuto(string type, etaxOneth form) { JObject oKeepResponeExecute = new JObject(); try { if (type == "Cancel") { socket.Emit("endtimeauto", form.inputnameFile.Text + "-" + idcom); socket.On("msg", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); //idcom = oKeepResponeExecute["data"].ToString(); }); } else if (type == "CloseAndCancel") { socket.Emit("endtimeauto", form.inputnameFile.Text + "-" + idcom); socket.On("msg", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); //idcom = oKeepResponeExecute["data"].ToString(); }); socket.Emit("exitprogram", form.inputnameFile.Text + "-" + idcom); socket.Disconnect(); } else if (type == "Close") { idcom = form.numberstringgen; socket.Emit("exitprogram", form.inputnameFile.Text + "-" + idcom); } else if (type == "CloseApplication") { socket.Emit("endprocressAll"); } } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); oKeepResponeExecute = null; oKeepResponeExecute.Remove(); } }
public void start_prog_t() { string email = this.email; string taxseller = this.taxseller; string branch = this.branch; string path = this.path; string input = this.input; string timeuser = this.timeuser; string typesoft = this.typesoft; string idcom; etaxOneth form = this.form; JObject oKeepResponeExecute = new JObject(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; string type_console = "start_program"; idcom = form.numberstringgen; Console.WriteLine(form.inputnameFile.Text + "-" + idcom); try { //pingeng = PingHost("devinet-etax.one.th"); if (pingeng) { string str = "{\n\t\"mailuser\":\"" + email + "\",\n\t\"tax_id\":\"" + taxseller + "\",\n\t\"branch_id\":\"" + branch + "\",\n\t\"setpath\":\"" + path + "\",\n\t\"inputpath\":\"" + input + "\",\n\t\"ipaddres\":\"" + GetLocalIPAddress() + "\",\n" + "\t\"namehost\":\"" + Environment.MachineName + "\",\n\t\"typesoft\":\"" + typesoft + "\",\n\t\"timeuser\":\"" + timeuser + "\",\n\t\"versionpro\":\"" + version + "\",\n\t\"idcomputer\":\"" + form.inputnameFile.Text + "-" + idcom + "\",\n\t\"type_console\":\"" + type_console + "\"\n}"; JObject json = JObject.Parse(str); Console.WriteLine(json + " ==== start"); var client = new RestClient(iphost + "/api/v1/forprogram"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddParameter("undefined", str, ParameterType.RequestBody); IRestResponse response = client.Execute(request); oKeepResponeExecute = JObject.Parse(response.Content.ToString()); Console.WriteLine(oKeepResponeExecute); } } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } }
public void nextSocket(etaxOneth form) { JObject oKeepResponeExecute = new JObject(); try { if (form.label18.Text.Length > 0) { socket.Emit("update", form.label18.Text); } socket.On("update", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); //sid = oKeepResponeExecute["data"].ToString(); }); socket.On("msgupdate", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); textcheckupdate = oKeepResponeExecute["msg"].ToString(); textversion = oKeepResponeExecute["version"].ToString(); if (textcheckupdate == "ok") { form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; form.button5.Visible = false; } else { form.label25.Text = "กรุณาอัพเดทโปรแกรม"; form.button5.Visible = true; } }); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); oKeepResponeExecute = null; oKeepResponeExecute.Remove(); } }
public void mainrestfulgetid(etaxOneth from) { try { if (from.lbUrl.Text == "Production") { this.production(from); } else if (from.lbUrl.Text == "ทดสอบระบบ") { this.uatpoc(from); } } catch (NullReferenceException a) { } }
private void button2_Click(object sender, EventArgs e) { try { etaxOneth etax = new etaxOneth(); etax.Show(); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } }
public string uploadfile_uat(string namefile, etaxOneth from) { JObject oKeepResponeExecute = new JObject(); try { var client = new RestClient("https://uatchat-public.one.th:8034/api/v1/upload_file_for_bot"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer A114be672146a57b690973a5b600f446187e8f9b094e84ae5a955780e477ae54a5cd8f63d965a462a822a7cad1b970374"); request.AddParameter("bot_id", "B0df132b88f9a526691a0576bfdb24196"); request.AddFile("file[]", namefile); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IRestResponse response = client.Execute(request); oKeepResponeExecute = JObject.Parse(response.Content); stopWatch.Stop(); urluat = ("https://uatchat-public.one.th:8034/get_botfile/bucket-botfile/B0df132b88f9a526691a0576bfdb24196/" + oKeepResponeExecute["data"][0]["message"]); from.txt_namefile = oKeepResponeExecute["data"][0]["file_name"].ToString(); if (oKeepResponeExecute["status"].ToString() == "success") { Console.WriteLine(oKeepResponeExecute["status"].ToString()); this.GENTRACKING(from); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } return(urluat); }
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { try { etaxOneth etax = new etaxOneth(); etax.Show(); notifyIcon1.Visible = true; } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } }
public string uploadfile_prod(string namefile, etaxOneth from) { JObject oKeepResponeExecute = new JObject(); try { var client = new RestClient("https://chat-public.one.th:8034/api/v1/upload_file_for_bot"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer A16185216830056b1946f138905230c3c633dbeec596d4e8d962971c40269af89a5b101b00a02411db4d741312cee67d5"); request.AddParameter("bot_id", "B0df132b88f9a526691a0576bfdb24196"); request.AddFile("file[]", namefile); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IRestResponse response = client.Execute(request); oKeepResponeExecute = JObject.Parse(response.Content); stopWatch.Stop(); urlprod = ("https://chat-public.one.th:8034/get_botfile/bucket-botfile/B0df132b88f9a526691a0576bfdb24196/" + oKeepResponeExecute["data"][0]["message"]); from.txt_namefile = oKeepResponeExecute["data"][0]["file_name"].ToString(); if (oKeepResponeExecute["status"].ToString() == "success") { Console.WriteLine(oKeepResponeExecute["status"].ToString()); this.GENTRACKING(from); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } return(urlprod); }
public void setstartUp() { if (!Directory.Exists(strPathConfig)) { try { Directory.CreateDirectory(strPathConfig); Microsoft.Win32.RegistryKey key; key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); string app_path = System.Reflection.Assembly.GetEntryAssembly().Location; string app_name = System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name; if (!key.GetValueNames().Contains(app_name)) { key.SetValue(app_name, app_path); key.Close(); } else { key.DeleteValue(app_name); key.SetValue(app_name, app_path); key.Close(); } Microsoft.Win32.RegistryKey rkey; rkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\ETAX\\Run"); if (rkey == null) { rkey.SetValue("PathConfigETAX", strPathConfig); } else { rkey.SetValue("PathConfigETAX", strPathConfig); } myTestKey = (string)rkey.GetValue("PathConfigETAX"); this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; int fileCount = Directory.GetFiles(myTestKey, "*.cfg", SearchOption.AllDirectories).Length; if (fileCount == 0) { etax = new etaxOneth(); etax.Show(); notifyIcon1.ShowBalloonTip(100, "แจ้งเตือน", "โปรแกรมพร้อมทำงาน..", ToolTipIcon.Info); } else { string[] textfile = Directory.GetFiles(myTestKey, "*.cfg").Select(Path.GetFileName).ToArray(); for (int i = 0; i < fileCount; i++) { StreamReader sr = new StreamReader(myTestKey + "\\" + textfile[i]); String line = sr.ReadToEnd(); byte[] data = Convert.FromBase64String(line); using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) { byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash)); using (TripleDESCryptoServiceProvider tripleDes = new TripleDESCryptoServiceProvider() { Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 }) { ICryptoTransform transform = tripleDes.CreateDecryptor(); byte[] results = transform.TransformFinalBlock(data, 0, data.Length); line = UTF8Encoding.UTF8.GetString(results); } } etax = new etaxOneth(); int len = line.ToString().Split(',').Length; bool checkst = bool.Parse(line.ToString().Split(',')[15]); if (checkst == true) { etax.linkpath = (myTestKey + "\\" + textfile[i]).ToString(); etax.nameFile = textfile[i].ToString(); etax.textinfile = line.ToString(); etax.Show(); sr.Close(); notifyIcon1.ShowBalloonTip(100, "แจ้งเตือน", "โปรแกรมเริ่มการทำงาน..", ToolTipIcon.Info); } else { sr.Close(); } } etax.Show(); } int countform = Application.OpenForms.OfType <etaxOneth>().Count(); rkey.Close(); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.SuppressFinalize(this); } } else { try { Microsoft.Win32.RegistryKey key; key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); string app_path = System.Reflection.Assembly.GetEntryAssembly().Location; string app_name = System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name; if (!key.GetValueNames().Contains(app_name)) { key.SetValue(app_name, app_path); key.Close(); } else { key.DeleteValue(app_name); key.SetValue(app_name, app_path); key.Close(); } Microsoft.Win32.RegistryKey rkey; rkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\ETAX\\Run"); if (rkey == null) { rkey.SetValue("PathConfigETAX", strPathConfig); } else { rkey.SetValue("PathConfigETAX", strPathConfig); } myTestKey = (string)rkey.GetValue("PathConfigETAX"); this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; int fileCount = Directory.GetFiles(myTestKey, "*.cfg", SearchOption.AllDirectories).Length; if (fileCount == 0) { etax = new etaxOneth(); try { etax.Show(); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); GC.Collect(); } GC.SuppressFinalize(this); } notifyIcon1.ShowBalloonTip(100, "แจ้งเตือน", "โปรแกรมพร้อมทำงาน..", ToolTipIcon.Info); } else { string[] textfile = Directory.GetFiles(myTestKey, "*.cfg").Select(Path.GetFileName).ToArray(); ManageProgram Manage = new ManageProgram(); bool Openprogram = true; Process[] process = Manage.Callprocess("ETAX-One Electronic Billing"); if (Manage.CheckProcess(process)) { DialogResult dialogResult = MessageBox.Show("โปรแกรมกำลังทำงานอยู่ในส่วนของ Background Process คุณต้องการเปิดเป็น Foreground Process หรือไม่ (อาจมีผลกระทบต่อการทำงาน โปรดตวรจสอบว่าระบบไม่ได้กำลังสร้างเอกสารอยู่)", "คำเตือน", MessageBoxButtons.YesNo); //MessageBox.Show("โปรแกรมกำลังทำงานอยู่ในส่วนของ Background Process คุณต้องการเปิดเป็น Foreground Process หรือไม่ (อาจมีผลกระทบต่อการทำงาน)"); if (dialogResult == DialogResult.Yes) { Manage.KillProcess(process); Openprogram = true; } else if (dialogResult == DialogResult.No) { Openprogram = false; Application.Exit(); } } else { Openprogram = true; } if (Openprogram) { for (int i = 0; i < fileCount; i++) { StreamReader sr = new StreamReader(myTestKey + "\\" + textfile[i]); String line = sr.ReadToEnd(); byte[] data = Convert.FromBase64String(line); using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) { byte[] keys = md5.ComputeHash(UTF8Encoding.UTF8.GetBytes(hash)); using (TripleDESCryptoServiceProvider tripleDes = new TripleDESCryptoServiceProvider() { Key = keys, Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 }) { ICryptoTransform transform = tripleDes.CreateDecryptor(); byte[] results = transform.TransformFinalBlock(data, 0, data.Length); line = UTF8Encoding.UTF8.GetString(results); } } etax = new etaxOneth(); int len = line.ToString().Split(',').Length; bool checkst = bool.Parse(line.ToString().Split(',')[15]); if (checkst == true) { etax.linkpath = (myTestKey + "\\" + textfile[i]).ToString(); etax.nameFile = textfile[i].ToString(); etax.textinfile = line.ToString(); etax.Show(); sr.Close(); notifyIcon1.ShowBalloonTip(100, "แจ้งเตือน", "โปรแกรมเริ่มการทำงาน..", ToolTipIcon.Info); } else { sr.Close(); } } etax.Show(); } } int countform = Application.OpenForms.OfType <etaxOneth>().Count(); etax.countform = countform; rkey.Close(); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.SuppressFinalize(this); } } }
public void coun_export() { etaxOneth form = this.form; JObject oKeepResponeExecute = new JObject(); JObject oKeepResponeExecute_ver = new JObject(); string type_console = "next_api"; try { //pingeng = PingHost("devinet-etax.one.th"); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; Console.WriteLine(pingeng); string str = form.label18.Text; string _sid = form.label20.Text; JObject json = JObject.Parse(str); JObject json_sid = JObject.Parse(_sid); Console.WriteLine(json); if (pingeng && json["mailuser"].ToString().Length > 0) { var client = new RestClient(iphost + "/api/v1/forprogram"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json"); json["type_console"] = type_console; json["sid"] = json_sid["sid"]; Console.WriteLine(json.ToString()); //string str = "{\n \"mailuser\": \"" + email + "\",\n \"tax_id\": \"" + taxseller + "\",\n \"branch_id\": \"" + branch + "\",\n \"setpath\": \"" + path + "\",\n \"room\": \"" + path + "\",\n \"inputpath\": \"" + input + "\",\n \"ipaddres\": \"" + GetLocalIPAddress() + "\",\n " + // "\"namehost\": \"" + Environment.MachineName + "\",\n \"typesoft\": \"" + typesoft + "\",\n \"timeuser\": " + timeuser + ",\n \"versionpro\": \"" + version + "\",\n \"idcomputer\": \"" + form.inputnameFile.Text + "-" + idcom + "\",\n \"type_console\": \"" + type_console + "\"\n}"; //JObject json = JObject.Parse(str); request.AddParameter("undefined", json.ToString(), ParameterType.RequestBody); IRestResponse response = client.Execute(request); oKeepResponeExecute = JObject.Parse(response.Content.ToString()); Console.WriteLine(oKeepResponeExecute); if (oKeepResponeExecute["version"].ToString() == version) { form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; form.button5.Visible = false; } else { form.label25.Text = "กรุณาอัพเดทโปรแกรม"; form.button5.Visible = true; } } else { this.form.label25.Text = "ไม่สามารถเชื่อมต่อ\nกับระบบแจ้งเตือนได้\nเนื่องจากไม่พบ Email"; } } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } }
public void connect_thisSocket(etaxOneth form) { socket.Connect(); }
public void connectSocket(etaxOneth form) { JObject oKeepResponeExecute = new JObject(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); if (form.label25.Text.ToString() == "กรุณาอัพเดทโปรแกรม") { try { string version = fvi.FileVersion; socket.Connect(); form.label25.Text = "กำลังตรวจสอบ เวอร์ชั่น"; form.button5.Visible = false; //Console.WriteLine(socket.Connect()); socket.On(Socket.EVENT_CONNECT, () => { Console.WriteLine("Connect"); }); socket.Emit("checkversioncurrent", version); socket.On("version", (data) => { Console.WriteLine(data); oKeepResponeExecute = JObject.Parse(data.ToString()); textcheckupdate = oKeepResponeExecute["type"].ToString(); textversion = oKeepResponeExecute["dataversion"].ToString(); if (textcheckupdate == "OK-Con") { form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; form.button5.Visible = false; } else { form.label25.Text = "กรุณาอัพเดทโปรแกรม"; form.button5.Visible = true; } }); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } } else if (form.label25.Text.ToString() == "ปิดระบบแจ้งเตือน") { try { string status_socket = this.API_checkversion(); } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } } //else if (form.metroToggle1.Checked == true) //{ // string version = fvi.FileVersion; // Console.WriteLine(version); // form.label25.Text = "กำลังตรวจสอบ เวอร์ชั่น"; // form.button5.Visible = false; // //Console.WriteLine(socket.Connect()); // socket.Emit("checkversioncurrent", version); // socket.On("version", (data) => // { // oKeepResponeExecute = JObject.Parse(data.ToString()); // Console.WriteLine(oKeepResponeExecute); // textcheckupdate = oKeepResponeExecute["type"].ToString(); // textversion = oKeepResponeExecute["dataversion"].ToString(); // if (textcheckupdate == "OK-Con") // { // form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; // form.button5.Visible = false; // } // else // { // form.label25.Text = "กรุณาอัพเดทโปรแกรม"; // form.button5.Visible = true; // } // }); //} }
public void strat_export() { string email = this.email; string taxseller = this.taxseller; string branch = this.branch; string path = this.path; string input = this.input; string timeuser = this.timeuser; string typesoft = this.typesoft; etaxOneth form = this.form; JObject oKeepResponeExecute = new JObject(); JObject oKeepResponeExecute_ver = new JObject(); string idcom; string type_console = "starttimeauto_program"; try { //pingeng = PingHost("devinet-etax.one.th"); idcom = form.numberstringgen; FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; Console.WriteLine(pingeng); if (pingeng && form.emailtxt.Text.Length > 0) { var client = new RestClient(iphost + "/api/v1/forprogram"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("Content-Type", "application/json"); string str = "{\n \"mailuser\": \"" + email + "\",\n \"tax_id\": \"" + taxseller + "\",\n \"branch_id\": \"" + branch + "\",\n \"setpath\": \"" + path + "\",\n \"room\": \"" + path + "\",\n \"inputpath\": \"" + input + "\",\n \"ipaddres\": \"" + GetLocalIPAddress() + "\",\n " + "\"namehost\": \"" + Environment.MachineName + "\",\n \"typesoft\": \"" + typesoft + "\",\n \"timeuser\": " + timeuser + ",\n \"versionpro\": \"" + version + "\",\n \"idcomputer\": \"" + form.inputnameFile.Text + "-" + idcom + "\",\n \"type_console\": \"" + type_console + "\"\n}"; Console.WriteLine(str + " =========="); JObject json = JObject.Parse(str); request.AddParameter("undefined", str, ParameterType.RequestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content.ToString()); oKeepResponeExecute = JObject.Parse(response.Content.ToString()); form.label20.Text = oKeepResponeExecute.ToString(); //n_text_apimail.jsontext = oKeepResponeExecute; //n_text_apimail.jsontext_about = json; if (form.label18.Text.Length == 0) { form.label18.Text = json.ToString(); } form.label25.Text = "กำลังตรวจสอบ เวอร์ชั่น"; var client_ver = new RestClient(iphost + "/api/v1/nxt_version"); var request_ver = new RestRequest(Method.POST); request_ver.AddHeader("cache-control", "no-cache"); request_ver.AddHeader("Content-Type", "application/json"); request_ver.AddParameter("undefined", "{\n \"this_version\": \"" + version + "\"\n}", ParameterType.RequestBody); IRestResponse response_ver = client_ver.Execute(request_ver); oKeepResponeExecute_ver = JObject.Parse(response_ver.Content.ToString()); Console.WriteLine(oKeepResponeExecute_ver); textcheckupdate = oKeepResponeExecute_ver["msg"].ToString(); textversion = oKeepResponeExecute_ver["version"].ToString(); if (textcheckupdate == "ok") { form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; form.button5.Visible = false; } else { form.label25.Text = "กรุณาอัพเดทโปรแกรม"; form.button5.Visible = true; } } else { this.form.label25.Text = "ไม่สามารถเชื่อมต่อ\nกับระบบแจ้งเตือนได้\nเนื่องจากไม่พบ Email"; } } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); } }
public void startSocketAuto2(string email, string taxseller, string branch, string path, string statusprogram, etaxOneth form, string input, string timeuser, string typesoft) { JObject oKeepResponeExecute = new JObject(); try { idcom = form.numberstringgen; FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; string str = "{ 'mailuser': '******','tax_id':'" + taxseller + "','branch_id':'" + branch + "','setpath':'" + path + "','room':'" + path + "','inputpath' : '" + input + "','ipaddres' : '" + GetLocalIPAddress() + "','namehost' : '" + Environment.MachineName + "','timeuser': '******','typesoft': '" + typesoft + "','versionpro':'" + version + "','idcomputer':'" + form.inputnameFile.Text + "-" + idcom + "' }"; string strroom = "{ 'room': '" + form.inputnameFile.Text + "-" + idcom + "'}"; if (statusprogram == "1") { JObject json = JObject.Parse(str); if (form.label18.Text.Length == 0) { form.label18.Text = json.ToString(); } socket.Emit("starttimeauto", json); socket.On("msg", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); //sid = oKeepResponeExecute["data"].ToString(); }); socket.On("msgupdate", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); textcheckupdate = oKeepResponeExecute["msg"].ToString(); textversion = oKeepResponeExecute["version"].ToString(); if (textcheckupdate == "ok") { form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; form.button5.Visible = false; } else { form.label25.Text = "กรุณาอัพเดทโปรแกรม"; form.button5.Visible = true; } }); } else if (statusprogram == "2") { JObject json = JObject.Parse(str); JObject jsonroon = JObject.Parse(strroom); if (form.label18.Text.Length == 0) { form.label18.Text = json.ToString(); } socket.Emit("enterroom", jsonroon); socket.Emit("starttimemmauto", json); socket.On("msg", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); //idcom = oKeepResponeExecute["data"].ToString(); }); socket.On("msgupdate", (data) => { oKeepResponeExecute = JObject.Parse(data.ToString()); textcheckupdate = oKeepResponeExecute["msg"].ToString(); textversion = oKeepResponeExecute["version"].ToString(); if (textcheckupdate == "ok") { form.label25.Text = "โปรแกรมเป็นเวอร์ชั่นล่าสุด\n" + "เวอร์ชั่น : " + textversion; form.button5.Visible = false; } else { form.label25.Text = "กรุณาอัพเดทโปรแกรม"; form.button5.Visible = true; } }); } } catch (Exception ea) { Console.WriteLine(ea); } finally { for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i); Console.WriteLine(count); GC.Collect(); } GC.WaitForPendingFinalizers(); GC.SuppressFinalize(this); oKeepResponeExecute = null; oKeepResponeExecute.Remove(); } }