Пример #1
0
        private void EmailSetting_Load(object sender, EventArgs e)
        {
            CenterToScreen();
            switch (mGlobal.language)
            {
            case "Spanish":
                cul = CultureInfo.CreateSpecificCulture("es-ES");
                break;

            case "Korean":
                cul = CultureInfo.CreateSpecificCulture("ko-KR");
                break;

            case "Japanese":
                cul = CultureInfo.CreateSpecificCulture("ja-JP");
                break;

            default:
                cul = CultureInfo.CreateSpecificCulture("en-US");
                break;
            }


            emailDevice = Device35.DelInstance();
            emailDevice = Device35.Instance;
            byte[] buf    = new byte[600];
            string emails = "";

            string[] email;

            //emailDevice.USBOpen(host);
            for (int i = 0; i < 10; i++)
            {
                emailDevice.USBOpen(host);
                byte[] data = new byte[64];
                if (!emailDevice.readEmailSetting(ref data, i + 1))
                {
                    MessageBox.Show(res_man.GetString("Read Email Setting fail", cul));
                    emailDevice.Close();
                    return;
                }
                else
                {
                    for (int j = 0; j < 60; j++)
                    {
                        buf[60 * i + j] = data[j + 2];
                    }
                }
                emailDevice.Close();
            }

            //emailDevice.Close();
            int count = 0;

            for (int i = 0; i < buf.Length; i++)
            {
                if (buf[i] != 255 && buf[i] != 0)
                {
                    count += 1;
                }
            }

            emails = mGlobal.ArrayToStr(ref buf, 0, count);
            email  = emails.Split(';');
            //textBox1.Text = email[0];
            richTextBox1.Clear();
            for (int i = 0; i < email.Length; i++)
            {
                richTextBox1.Text += email[i] + Environment.NewLine;
            }

            if (richTextBox1.Text != "")
            {
                richTextBox1.Text = richTextBox1.Text.Substring(0, richTextBox1.Text.Length - 1);
            }


            //Read SMS
            byte[] SMSlist = new byte[200];
            for (int i = 0; i < 5; i++)
            {
                emailDevice.USBOpen(host);
                byte[] data = new byte[44];
                if (!emailDevice.readSMSSetting(ref data, i + 1))
                {
                    MessageBox.Show("Read SMS Setting fail");
                    emailDevice.Close();
                    return;
                }
                else
                {
                    for (int j = 0; j < 40; j++)
                    {
                        SMSlist[40 * i + j] = data[j + 2]; //bo report + byte length
                    }
                }
                emailDevice.Close();
            }
            rtxtSMS.Clear();

            byte[] singleSMS = new byte[20];
            for (int i = 0; i < 10; i++)
            {
                Array.Copy(SMSlist, i * 20, singleSMS, 0, 20);
                string singleText = Encoding.ASCII.GetString(singleSMS).Replace('\0', ' ').Trim();
                if (singleText.Length > 0)
                {
                    rtxtSMS.Text += singleText + Environment.NewLine;
                }
            }

            string FileName = "";

            FileName = mGlobal.app_patch(FileName);

            FileName += "\\dataEmail.txt";

            if (System.IO.File.Exists(FileName))
            {
                btnRead.Enabled = true;
            }
            else
            {
                btnRead.Enabled = false;
            }
        }