1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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<LogEvent, string> ReportDict = new Dictionary<LogEvent, string>()
- {
- { LogEvent.TelcomModemImei, "TelcomModemImei" }
- };
-
- private readonly static Dictionary<LogEvent, string> LogDict = new Dictionary<LogEvent, string>()
- {
- { LogEvent.TelcomModemImei, "Get TelcomModem IMEI : {0}" }
- };
- public TelcomModemImeiRecordProcedure() : base()
- {
- Name = "TelcomModem IMEI record";
- Content = "read and upload TelcomModem IMEI";
- LogWriter = new ProcedureLog.LogWriter<TelcomModemImeiRecordProcedure, LogEvent>(this)
- {
- ReportPair = ReportDict,
- LogPair = LogDict
- };
- }
- public ErrorType Error { get; set; } = ErrorType.None;
- private ProcedureLog.LogWriter<TelcomModemImeiRecordProcedure, LogEvent> LogWriter;
- internal override async Task<bool> 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<string> 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 "";
- }
- }
- }
- }
|