Przeglądaj źródła

add Wifi IMEI upload

Robert 2 lat temu
rodzic
commit
abcc1fa66e

+ 2 - 1
AwInitilizer/Initilizer.csproj

@@ -15,6 +15,7 @@
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <Deterministic>true</Deterministic>
     <TargetFrameworkProfile />
+    <IsWebBootstrapper>false</IsWebBootstrapper>
     <PublishUrl>publish\</PublishUrl>
     <Install>true</Install>
     <InstallFrom>Disk</InstallFrom>
@@ -27,7 +28,6 @@
     <MapFileExtensions>true</MapFileExtensions>
     <ApplicationRevision>0</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
-    <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
@@ -99,6 +99,7 @@
     <Compile Include="Procedure\FirmwareCheckVersionProcedure.cs" />
     <Compile Include="Procedure\FirmwareUploadProcedure.cs" />
     <Compile Include="Procedure\VersionLogProcedure.cs" />
+    <Compile Include="Procedure\WifImeiRecordProcedure.cs" />
     <Compile Include="Procedure\WifRssiCheckProcedure.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Resx\AppResources.Designer.cs">

+ 1 - 0
AwInitilizer/MainWindow.xaml.cs

@@ -623,6 +623,7 @@ namespace AwInitilizer
             procedures.Add(new Procedure.BasicInfoUpdate.BasicInfoUpdateProcedure());
             procedures.Add(new Procedure.FourGenModuleCheck.FourGenModuleCheckProcedure());
             procedures.Add(new Procedure.WifRssiCheck.WifRssiCheckProcedure());
+            procedures.Add(new Procedure.WifImeiRecord.WifImeiRecordProcedure());
             procedures.Add(new Procedure.FirmwareBundleUpload.FirmwareFtpUploadProcedure());
             procedures.Add(new Procedure.FirmwareCheckVersion.FirmwareCheckVersionProcedure());
             procedures.Add(new Procedure.ButtonStatusCheck.ButtonStatusCheckPorcedure());

+ 123 - 0
AwInitilizer/Procedure/WifImeiRecordProcedure.cs

@@ -0,0 +1,123 @@
+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.WifImeiRecord
+{
+    public enum ErrorType
+    {
+        None,
+        WifiImeiNotFound,
+    }
+
+    public enum LogEvent
+    {
+        WifiImei
+    }
+
+    public class WifImeiRecordProcedure : ProcedureBase
+    {
+        private readonly static Dictionary<LogEvent, string> ReportDict = new Dictionary<LogEvent, string>()
+        {
+            { LogEvent.WifiImei, "WifiRssi" }
+        };
+        
+        private readonly static Dictionary<LogEvent, string> LogDict = new Dictionary<LogEvent, string>()
+        {
+            { LogEvent.WifiImei, "Get Wifi IMEI : {0}" }
+        };
+
+        public WifImeiRecordProcedure() : base()
+        {
+            Name = "WiFi IMEI record";
+            Content = "read and upload WIFI IMEI";
+
+            LogWriter = new ProcedureLog.LogWriter<WifImeiRecordProcedure, LogEvent>(this)
+            {
+                ReportPair = ReportDict,
+                LogPair = LogDict
+            };
+        }
+
+        public ErrorType Error { get; set; } = ErrorType.None;
+        private ProcedureLog.LogWriter<WifImeiRecordProcedure, LogEvent> LogWriter;
+
+        internal override async Task<bool> Run()
+        {
+            if (!UpdateData.SystemID.ModelName.Network.Description.Contains("WiFi"))
+            {
+                LogWriter.Log("Wifi not supported, skip procedure");
+
+                return true;
+            }
+
+            var imei = await GetWifiImei();
+            LogWriter.Report(LogEvent.WifiImei, imei);
+            return string.IsNullOrEmpty(imei);
+        }
+
+        internal async Task<string> GetWifiImei()
+        {
+            try
+            {
+                using (WebClientTimeout webClient = new WebClientTimeout())
+                {
+                    NameValueCollection parameters = new NameValueCollection();
+                    parameters.Add("opt", "3");
+                    webClient.QueryString = parameters;
+
+                    using (Stream stream = await webClient.OpenReadTaskAsync($"https://{ServerIpAddress}/get_query_action.php"))
+                    // 使用 StreamReader 讀取 stream 內的字元
+                    using (StreamReader reader = new StreamReader(stream))
+                    {
+                        // 將 StreamReader 所讀到的字元轉為 string
+                        string request = reader.ReadToEnd();
+                        LogWriter.Log($"GetResponse:{request}", isDebugLog: true);
+
+                        Regex rx = new Regex("(TelcomModemImei)\\\": \"([0-9]*)\"");
+                        var matches = rx.Matches(request);
+
+                        if (matches.Count != 0)
+                        {
+                            var match = matches[0];
+                            if (match.Groups.Count != 3)
+                            {
+                                Error = ErrorType.WifiImeiNotFound;
+                                return "";
+                            }
+                            else
+                            {
+                                if (match.Groups[2].Value is string imei)
+                                {
+                                    return imei;
+                                }
+                                Error = ErrorType.WifiImeiNotFound;
+                                return "";
+                            }
+                        }
+                        else
+                        {
+                            Error = ErrorType.WifiImeiNotFound;
+                            return "";
+                        }
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                Error = ErrorType.WifiImeiNotFound;
+
+                LogWriter.Log("Get Wifi IMEI Failed");
+                LogWriter.Log(e.Message, isDebugLog: true);
+
+                return "";
+            }
+        }
+    }
+}

+ 4 - 4
AwInitilizer/Properties/AssemblyInfo.cs

@@ -31,7 +31,7 @@ using System.Runtime.InteropServices;
 //
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.6.4.0")]
-[assembly: AssemblyVersion("1.6.4.0")]
-[assembly: AssemblyFileVersion("1.6.4.0")]
-[assembly: AssemblyInformationalVersion("78ae110")]
+// [assembly: AssemblyVersion("1.7.0.0")]
+[assembly: AssemblyVersion("1.7.0.0")]
+[assembly: AssemblyFileVersion("1.7.0.0")]
+[assembly: AssemblyInformationalVersion("1bdf159")]

+ 1 - 1
GitVersion.yml

@@ -1,6 +1,6 @@
 assembly-versioning-scheme: MajorMinorPatch
 assembly-informational-format: '{ShortSha}'
-next-version: 1.6.4
+next-version: 1.7.0
 branches: {}
 ignore:
   sha: []

+ 3 - 3
Initilizer/AssemblyInfo.cs

@@ -9,7 +9,7 @@
                                               // app, or any theme specific resource dictionaries)
 )]
 
-[assembly: AssemblyVersion("1.6.4.0")]
-[assembly: AssemblyFileVersion("1.6.4.0")]
-[assembly: AssemblyInformationalVersion("78ae110")]
+[assembly: AssemblyVersion("1.7.0.0")]
+[assembly: AssemblyFileVersion("1.7.0.0")]
+[assembly: AssemblyInformationalVersion("1bdf159")]
 

+ 4 - 4
MesAdaptor/Properties/AssemblyInfo.cs

@@ -31,7 +31,7 @@ using System.Runtime.InteropServices;
 //
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.6.4.0")]
-[assembly: AssemblyVersion("1.6.4.0")]
-[assembly: AssemblyFileVersion("1.6.4.0")]
-[assembly: AssemblyInformationalVersion("78ae110")]
+// [assembly: AssemblyVersion("1.7.0.0")]
+[assembly: AssemblyVersion("1.7.0.0")]
+[assembly: AssemblyFileVersion("1.7.0.0")]
+[assembly: AssemblyInformationalVersion("1bdf159")]