Esempio n. 1
0
        private RecordDeleteViewModel DeleteModel(string id, out GSMModem record)
        {
            RecordDeleteViewModel deleteModel = new RecordDeleteViewModel();

            record = null;
            deleteModel.ActionName     = "Delete";
            deleteModel.ControllerName = "Modem";
            deleteModel.Id             = id;
            deleteModel.Title          = "Delete Modem";
            if (id == null)
            {
                ModelState.AddModelError(string.Empty, "Invalid Action");
                return(deleteModel);
            }
            record = _context.GSMModem.SingleOrDefault(m => m.Id == id);
            if (record == null)
            {
                ModelState.AddModelError(string.Empty, "Record not found.");
            }
            else
            {
                deleteModel.RecordDetail.Add(new RecordDetail {
                    Label = "Modem Name", Value = record.GSMModem_Id
                });
                deleteModel.RecordDetail.Add(new RecordDetail {
                    Label = "Port", Value = record.PortName
                });
            }
            return(deleteModel);
        }
Esempio n. 2
0
        public void getModemDetails(GSMModem oGsmModem)
        {
            if (oGsmModem == null)
            {
                MessageBox.Show("Modem object is Null", dialogCaption, MessageBoxButtons.OK);
                this.Close();
            }

            if (!oGsmModem.IsConnected)
            {
                MessageBox.Show("Modem is not connected", dialogCaption, MessageBoxButtons.OK);
                this.Close();
            }

            try {
                txtRevision.Text = oGsmModem.Revision;
            }
            catch (Exception ex) {
                txtRevision.Text = "Not supported";
            }

            try {
                txtIMSI.Text = oGsmModem.IMSI;
            }
            catch (Exception ex) {
                txtIMSI.Text = "Not supported";
            }

            try {
                txtIMEI.Text = oGsmModem.IMEI;
            }
            catch (Exception ex) {
                txtIMEI.Text = "Not supported";
            }

            try {
                txtModel.Text = oGsmModem.PhoneModel;
            }
            catch (Exception ex) {
                txtModel.Text = "Not supported";
            }

            try {
                txtManufacturer.Text = oGsmModem.Manufacturer;
            }
            catch (Exception ex) {
                txtManufacturer.Text = "Not supported";
            }

            try {
                txtSMSC.Text = oGsmModem.SMSC;
            }
            catch (Exception ex) {
                txtSMSC.Text = "Not supported";
            }

            try {
                Rssi rssi = oGsmModem.GetRssi();
                txtSignal.Text = rssi.Current + " of " + rssi.Maximum;
            }
            catch (Exception ex) {
                txtSignal.Text = "Not supported";
            }

            try {
                Storage[] storages = oGsmModem.GetStorageSetting();
                int       i        = 0;
                txtSupportedStorage.Text = string.Empty;
                for (i = 0; i <= storages.Length - 1; i++)
                {
                    Storage storage = storages[i];
                    txtSupportedStorage.Text += storage.Name + "(" + storage.Used + "/" + storage.Total + "), ";
                }
            }
            catch (Exception ex) {
                txtSupportedStorage.Text = "Not supported";
            }
        }
    public bool SendMsg(string tmpPort, int tmpRate, string tmpUser, string tmpInfo)
    {
        GSMModem gm = new GSMModem();
        int      b  = 1;

        char[]   tmpChar = { ';' };
        string[] tmpStr  = tmpUser.Split(tmpChar);
        try
        {
            gm.ComPort  = tmpPort;
            gm.BaudRate = tmpRate;
            //gm.OnRecieved += new GSMModem.OnRecievedHandler(gm_OnRecieved);
            //UpdateHandle = new UpdataDelegate(UpdateLabel8);        //实例化委托

            if (gm.IsOpen == false)
            {
                gm.Open();
            }

            //管理员手机信息提取
            //char[] tmpChar = { ';' };
            //string[] tmpStr = tmpUser.Split(tmpChar);



            for (int i = 0; i < tmpStr.Length; i++)
            {
                try {
                    gm.Close();
                    Thread.Sleep(1000);
                    gm.Open();
                    Thread.Sleep(1000);
                    gm.SendMsg(tmpStr[i], tmpInfo);
                }
                catch
                {
                    try {
                        gm.Close();
                        Thread.Sleep(1000);
                        gm.Open();
                        Thread.Sleep(1000);
                        gm.SendMsg(tmpStr[i + 1], tmpInfo);
                    }
                    catch
                    {
                        try
                        {
                            gm.Close();
                            Thread.Sleep(1000);
                            gm.Open();
                            Thread.Sleep(1000);
                            gm.SendMsg(tmpStr[i + 2], tmpInfo);
                            b = b / i;
                        }
                        catch
                        {
                            try
                            {
                                gm.Close();
                                Thread.Sleep(1000);
                                gm.Open();
                                Thread.Sleep(1000);
                                gm.SendMsg(tmpStr[i + 3], tmpInfo);
                                b = b / i;
                            }
                            catch
                            {
                                try
                                {
                                    gm.Close();
                                    Thread.Sleep(1000);
                                    gm.Open();
                                    Thread.Sleep(1000);
                                    gm.SendMsg(tmpStr[i + 4], tmpInfo);
                                    b = b / i;
                                }
                                catch
                                {
                                    try
                                    {
                                        gm.Close();
                                        Thread.Sleep(1000);
                                        gm.Open();
                                        Thread.Sleep(1000);
                                        gm.SendMsg(tmpStr[i + 5], tmpInfo);
                                        b = b / i;
                                    }
                                    catch
                                    {
                                        try
                                        {
                                            gm.Close();
                                            Thread.Sleep(1000);
                                            gm.Open();
                                            Thread.Sleep(1000);
                                            gm.SendMsg(tmpStr[i + 6], tmpInfo);
                                            b = b / i;
                                        }
                                        catch
                                        {
                                            try
                                            {
                                                gm.Close();
                                                Thread.Sleep(2000);
                                                gm.Open();
                                                Thread.Sleep(2000);
                                                gm.SendMsg(tmpStr[i + 7], tmpInfo);
                                                b = b / i;
                                            }
                                            catch
                                            {
                                                gm.Close();
                                                Thread.Sleep(2000);
                                                gm.Open();
                                                Thread.Sleep(1000);
                                                gm.SendMsg(tmpStr[i + 8], tmpInfo);
                                                b = b / i;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (gm.IsOpen == true)
            {
                gm.Close();
            }
            return(true);
        }
        catch
        {
            if (gm.IsOpen == true)
            {
                gm.Close();
            }
            gm.Open();

            return(true);
        }
    }
Esempio n. 4
0
        public void getModemDetails(GSMModem oGsmModem) 
        {
            if (oGsmModem == null) 
            {
                MessageBox.Show("Modem object is Null", dialogCaption, MessageBoxButtons.OK);
                this.Close();
            }

            if (!oGsmModem.IsConnected)
            {
                MessageBox.Show("Modem is not connected", dialogCaption, MessageBoxButtons.OK);
                this.Close();
            }

             try {
                 txtRevision.Text = oGsmModem.Revision;
             }
             catch (Exception ex) {
                 txtRevision.Text = "Not supported";
             }
            
             try {
                 txtIMSI.Text = oGsmModem.IMSI;
             }
             catch (Exception ex) {
                 txtIMSI.Text = "Not supported";
             }
            
             try {
                 txtIMEI.Text = oGsmModem.IMEI;
             }
             catch (Exception ex) {
                 txtIMEI.Text = "Not supported";
             }
            
             try {
                 txtModel.Text = oGsmModem.PhoneModel;
             }
             catch (Exception ex) {
                 txtModel.Text = "Not supported";
             }
            
             try {
                 txtManufacturer.Text = oGsmModem.Manufacturer;
             }
             catch (Exception ex) {
                 txtManufacturer.Text = "Not supported";
             }
            
             try {
                 txtSMSC.Text = oGsmModem.SMSC;
             }
             catch (Exception ex) {
                 txtSMSC.Text = "Not supported";
             }
            
             try {
                 Rssi rssi = oGsmModem.GetRssi();
                 txtSignal.Text = rssi.Current + " of " + rssi.Maximum;
             }
             catch (Exception ex) {
                 txtSignal.Text = "Not supported";
             }
            
             try {
                 Storage[] storages = oGsmModem.GetStorageSetting();
                 int i = 0;
                 txtSupportedStorage.Text = string.Empty;
                 for (i = 0; i <= storages.Length - 1; i++) {
                     Storage storage = storages[i];
                     txtSupportedStorage.Text += storage.Name + "(" + storage.Used + "/" + storage.Total + "), ";
                 }
             }
             catch (Exception ex) {
                 txtSupportedStorage.Text = "Not supported";
             }
             
        }