private static string ReadDevice(xssmsmms.SmsProtocolGsm objGsmProtocol) { String strInput = "", strDevice = ""; System.Int32 i, j; Console.WriteLine("选择设备: "); for (i = 1; i <= 8; i++) { Console.WriteLine(" " + i.ToString() + ": COM" + i.ToString()); } for (j = 0; j <= objGsmProtocol.GetDeviceCount() - 1; j++) { Console.WriteLine(" " + (i + j).ToString() + ": " + objGsmProtocol.GetDevice(j).ToString()); } while (strDevice == "") { Console.Write(" > "); strInput = Console.ReadLine(); if ((System.Int32.Parse(strInput) < i)) strDevice = "COM" + (System.Int32.Parse(strInput)).ToString(); else if (System.Int32.Parse(strInput) < i + j) strDevice = objGsmProtocol.GetDevice(System.Int32.Parse(strInput) - i); } Console.WriteLine(" 选择设备: " + strDevice + "\r\n"); return strDevice; }
private static string ReadDevice(xssmsmms.MmsProtocolMm1 objMm1Protocol) { String strInput = "", strDevice = ""; System.Int32 j; Console.WriteLine("选择设备(发送彩信不可以直接连COM口): "); for (j = 0; j < objMm1Protocol.GetDeviceCount(); j++) { Console.WriteLine(" " + j.ToString() + ": " + objMm1Protocol.GetDevice(j).ToString()); } while (strDevice == "") { Console.Write(" > "); strInput = Console.ReadLine(); if (System.Int32.Parse(strInput) < j) strDevice = objMm1Protocol.GetDevice(System.Int32.Parse(strInput)); } Console.WriteLine(" 选择设备: " + strDevice + "\r\n"); return strDevice; }