using AwInitilizer.Assist; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace AwInitilizer.Procedure.TelcomModemImeiRecord { public enum ErrorType { None, TelcomModemImeiNotFound, } public enum LogEvent { TelcomModemImei } public class TelcomModemImeiRecordProcedure : ProcedureBase { private readonly static Dictionary ReportDict = new Dictionary() { { LogEvent.TelcomModemImei, "TelcomModemImei" } }; private readonly static Dictionary LogDict = new Dictionary() { { LogEvent.TelcomModemImei, "Get TelcomModem IMEI : {0}" } }; public TelcomModemImeiRecordProcedure() : base() { Name = "TelcomModem IMEI record"; Content = "read and upload TelcomModem IMEI"; LogWriter = new ProcedureLog.LogWriter(this) { ReportPair = ReportDict, LogPair = LogDict }; } public ErrorType Error { get; set; } = ErrorType.None; private ProcedureLog.LogWriter LogWriter; internal override async Task Run() { //if (!UpdateData.SystemID.ModelName.Network.Description.Contains("4G")) if (UpdateData.SystemID.ModelName.GetTelecomCnt() == 0) { LogWriter.Log("TelcomModem not supported, skip procedure"); return true; } var imei = await GetTelcomModemImei(); LogWriter.Report(LogEvent.TelcomModemImei, imei); return !string.IsNullOrEmpty(imei); } internal async Task GetTelcomModemImei() { try { var result = await EvApi.GetTelcomModemImei(); LogWriter.Log($"GetResponse:{result.Response}", isDebugLog: true); if (string.IsNullOrEmpty(result.Result)) { Error = ErrorType.TelcomModemImeiNotFound; } return result.Result; } catch (Exception e) { Error = ErrorType.TelcomModemImeiNotFound; LogWriter.Log("Get TelcomModem IMEI Failed"); LogWriter.Log(e.Message, isDebugLog: true); return ""; } } } }