Esempio n. 1
0
        public static SRV_RegisterData GetSrvRegisterData(string sernum, string hdd_serial)
        {
            if (sernum.Trim().Length < 12)
            {
                return(null);
            }

            //SRV_RegisterData srv_regdata = new SRV_RegisterData();
            //srv_regdata._conn_success = false;
            //srv_regdata._failed_reason = SRV_RegisterData.FAILED_REASON.NONE;

            SRV_RegisterData srv_regdata = null;

            try
            {
                string json_data = "{\"sernum\":\"" + sernum.Trim() + "\",";
                json_data += "\"hdd_serial\":\"" + hdd_serial.Trim() + "\"}";
                string result = WebComm.PostData("http://www.esg.co.th/XML-Exporter/get_registered_data.php", json_data);
                srv_regdata = JsonConvert.DeserializeObject <SRV_RegisterData>(result);
            }
            catch (Exception)
            {
                return(null);
            }

            return(srv_regdata);
        }
Esempio n. 2
0
        public static SRV_RegisterData GetSrvRegisterData(LOC_RegisterData local_regdata)
        {
            if (local_regdata == null)
            {
                return(null);
            }

            SRV_RegisterData srv_regdata = new SRV_RegisterData();

            srv_regdata._conn_success  = false;
            srv_regdata._failed_reason = SRV_RegisterData.FAILED_REASON.NONE;

            try
            {
                string json_data = "{\"token_key\":\"" + local_regdata.token_key + "\"}";
                string result    = WebComm.PostData("http://www.esg.co.th/XML-Exporter/get_registered_data.php", json_data);
                srv_regdata = JsonConvert.DeserializeObject <SRV_RegisterData>(result);
            }
            catch (Exception)
            {
                return(null);
            }

            return(srv_regdata);
        }
Esempio n. 3
0
        public static bool CheckLicense()
        {
            if (!Licensing.IsServerConnected())
            {
                MessageBox.Show("กรุณาตรวจสอบการเชื่อมต่ออินเทอร์เน็ต");
                return(false);
            }

            SRV_RegisterData srv_regdata = Licensing.GetSrvRegisterData(Licensing.GetLocalRegData());

            if (srv_regdata == null)
            {
                return(false);
            }
            else
            {
                if (Licensing.IsLAN())
                {
                    //MessageBox.Show("Licensing.GetSErverCompName() : " + Licensing.GetServerCompName() + "\nsrv_regdata.comp_name : " + srv_regdata.comp_name);

                    if (Licensing.GetServerCompName() == srv_regdata.comp_name && srv_regdata.reg_type == "LAN")
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    string drive_letter = AppDomain.CurrentDomain.BaseDirectory.Substring(0, 1).ToUpper();
                    if (Licensing.GetHDDSerialNumber(drive_letter) == srv_regdata.machine_code && srv_regdata.reg_type == "LOCAL")
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
        }
Esempio n. 4
0
 private void GetSrvRegData()
 {
     this.srv_regdata = Licensing.GetSrvRegisterData(RegisterDialog.ReadSernum(), Licensing.GetHDDSerialNumber(Licensing.GetSystemDriveLetter()));
 }
Esempio n. 5
0
        private void btnReloadStatus_Click(object sender, EventArgs e)
        {
            LoadingScreen ls = new LoadingScreen();

            ls.ShowCenterParent(this);

            SRV_RegisterData srv_regdata  = null;
            bool             is_connected = false;

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                if (!Licensing.IsServerConnected())
                {
                    is_connected = false;
                }
                else
                {
                    is_connected = true;
                }

                //if ((Licensing.IsLAN() && Licensing.IsServer()) || !Licensing.IsLAN())
                //{
                //srv_regdata = Licensing.GetSrvRegisterData(Licensing.GetLocalRegData());
                srv_regdata = Licensing.GetSrvRegisterData(RegisterDialog.ReadSernum(), Licensing.GetHDDSerialNumber(Licensing.GetSystemDriveLetter()));
                //}
                //System.Threading.Thread.Sleep(500);
            };
            worker.RunWorkerCompleted += delegate
            {
                ls.Close();

                if (!is_connected)
                {
                    MessageBox.Show("ไม่สามารถติดต่อกับเซิร์ฟเวอร์ได้, กรุณาตรวจสอบการเชื่อมต่ออินเทอร์เน็ต", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                if (srv_regdata == null)
                {
                    this.register_status = Licensing.STATUS.NOT_REGISTER;
                }
                else
                {
                    if (srv_regdata.status_code == ((int)Licensing.STATUS.NOT_REGISTER).ToString())
                    {
                        this.register_status = Licensing.STATUS.NOT_REGISTER;
                    }

                    if (srv_regdata.status_code == ((int)Licensing.STATUS.WAIT_FOR_VERIFY).ToString())
                    {
                        this.register_status = Licensing.STATUS.WAIT_FOR_VERIFY;
                    }

                    if (srv_regdata.status_code == ((int)Licensing.STATUS.REGISTERED).ToString())
                    {
                        this.register_status = Licensing.STATUS.REGISTERED;
                    }
                }
                this.RepaintStatusPanel();
                this.SetControlState();
            };
            worker.RunWorkerAsync();
        }
Esempio n. 6
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            LoadingScreen ls = new LoadingScreen();

            ls.ShowCenterParent(this);

            SRV_RegisterData srv_regdata = new SRV_RegisterData();

            srv_regdata._conn_success  = false;
            srv_regdata._failed_reason = SRV_RegisterData.FAILED_REASON.NONE;

            LOC_RegisterData loc_regdata = new LOC_RegisterData();

            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate
            {
                DriveInformation drive = Licensing.GetDriveInfo();

                //loc_regdata.token_key = Licensing.CalcMD5(drive.hddSerialNumber);
                //loc_regdata.machine_code = drive.hddSerialNumber;
                loc_regdata.token_key     = Licensing.CalcMD5(Licensing.GetHDDSerialNumber(Licensing.GetSystemDriveLetter()));
                loc_regdata.machine_code  = Licensing.GetHDDSerialNumber(Licensing.GetSystemDriveLetter());
                loc_regdata.comp_name     = Licensing.GetServerCompName();
                loc_regdata.reg_type      = (Licensing.IsLAN() ? "LAN" : "LOCAL");
                loc_regdata.sernum        = this.sernum;
                loc_regdata.contact       = this.contact;
                loc_regdata.telnum        = this.telnum;
                loc_regdata.email         = this.email;
                loc_regdata.remark        = this.remark;
                loc_regdata.slip_filename = Path.GetFileName(this.slip_file_path);
                loc_regdata.tax_filename  = Path.GetFileName(this.tax_file_path);

                NameValueCollection nvc = new NameValueCollection();
                nvc.Add("token_key", loc_regdata.token_key);
                nvc.Add("machine_code", loc_regdata.machine_code);
                nvc.Add("comp_name", loc_regdata.comp_name);
                nvc.Add("reg_type", loc_regdata.reg_type);
                nvc.Add("sernum", loc_regdata.sernum);
                nvc.Add("contact", loc_regdata.contact);
                nvc.Add("telnum", loc_regdata.telnum);
                nvc.Add("email", loc_regdata.email);
                nvc.Add("remark", loc_regdata.remark);
                nvc.Add("slip_filename", loc_regdata.slip_filename);

                try
                {
                    string       upload_tax_result = WebComm.UploadMultipart("http://www.esg.co.th/XML-Exporter/upload_tax_file.php", this.tax_file_path, "file1", "image/jpg", nvc);
                    ServerResult sr = JsonConvert.DeserializeObject <ServerResult>(upload_tax_result);
                    nvc.Add("tax_filename", sr.message);

                    string web_result = WebComm.UploadMultipart("http://www.esg.co.th/XML-Exporter/upload_register.php", this.slip_file_path, "file1", "image/jpg", nvc);
                    //WebResult web_result = WebComm.UploadMultipart("http://www.weetee.com:3636/XML-Exporter/upload.php", this.file_path, "file1", "image/jpg", nvc);
                    srv_regdata = JsonConvert.DeserializeObject <SRV_RegisterData>(web_result);
                    //loc_regdata.status_code = srv_regdata.status_code;
                    //loc_regdata.status = srv_regdata.status;
                    loc_regdata.reg_date     = DateTime.Parse(srv_regdata.reg_date, CultureInfo.GetCultureInfo("en-US").DateTimeFormat);
                    loc_regdata.reg_time     = srv_regdata.reg_time;
                    loc_regdata.reg_unixtime = srv_regdata.reg_unixtime;
                }
                catch (Exception ex)
                {
                    srv_regdata._conn_success = false;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                ls.Close();

                if (srv_regdata._conn_success)
                {
                    if ((int)srv_regdata._failed_reason == (int)SRV_RegisterData.FAILED_REASON.NONE)
                    {
                        //if (Licensing.WriteTokenKey(loc_regdata.token_key, loc_regdata.machine_code, loc_regdata.comp_name, loc_regdata.reg_type, loc_regdata.sernum, loc_regdata.contact, loc_regdata.telnum, loc_regdata.email, loc_regdata.remark, loc_regdata.slip_filename, loc_regdata.status_code, loc_regdata.status, loc_regdata.reg_date.ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US")), loc_regdata.reg_time, loc_regdata.reg_unixtime))
                        if (Licensing.WriteTokenKey(loc_regdata.token_key, loc_regdata.machine_code, loc_regdata.comp_name, loc_regdata.reg_type, loc_regdata.sernum, loc_regdata.contact, loc_regdata.telnum, loc_regdata.email, loc_regdata.remark, loc_regdata.slip_filename, loc_regdata.reg_date.ToString("yyyy-MM-dd", CultureInfo.GetCultureInfo("en-US")), loc_regdata.reg_time, loc_regdata.reg_unixtime))
                        {
                            MessageBox.Show("ส่งข้อมูลการลงทะเบียนโปรแกรมเรียบร้อย, เมื่อข้อมูลดังกล่าวได้รับการตรวจสอบจากทางบริษัทฯ แล้ว ท่านจะสามารถใช้งานความสามารถทั้งหมดของโปรแกรมได้ในทันที\n(โดยปกติใช้เวลาไม่เกิน 1 วันทำการ)");
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                        return;
                    }

                    if ((int)srv_regdata._failed_reason == (int)SRV_RegisterData.FAILED_REASON.DUPLICATE_SN)
                    {
                        MessageBox.Show(srv_regdata._failed_reason.ToReasonString());
                        return;
                    }
                }

                if (!srv_regdata._conn_success && srv_regdata._failed_reason == SRV_RegisterData.FAILED_REASON.NONE)
                {
                    MessageBox.Show("ไม่สามารถส่งข้อมูลการลงทะเบียนได้, กรุณาตรวจสอบการเชื่อมต่ออินเทอร์เน็ต", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            };
            worker.RunWorkerAsync();
        }