protected override async Task OnInitializedAsync() { ShowResults = false; results = await Logs.GetAsync(HostnameFilter, Username); ShowResults = true; }
public FuelBurnRateRequest PostMileageTargetRequest() { //fuelBurnRateRequest = null; //CustomHeaders = new Dictionary<string, string>(); // if (string.IsNullOrEmpty(AccessToken)) GetToken(); try { string FuelBurnRequestString = GetFuelBurnRateRequest(); //CustomHeaders.Add(CustomerUid, CustomerUID); LogResult.Report(Log, "log_ForInfo", "Request string: " + FuelBurnRequestString); LogResult.Report(Log, "log_ForInfo", "Post to URL: " + AssetServiceConfig.FuelBurnRateAPI); ResponseString = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, AccessToken, HeaderSettings.JsonMediaType, FuelBurnRequestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); LogResult.Report(Log, "log_ForInfo", "Response Recieved: " + ResponseString); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While Getting Data From AlertsManager Service", e); throw new Exception(e + " Got Error While Getting Data From AlertsManager Service"); } try { fuelBurnRateResponse = JsonConvert.DeserializeObject <FuelBurnRateResponse>(ResponseString); LogResult.Report(Log, "log_ForInfo", "Deserialized the response"); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e); throw new Exception(e + " Got Error While DeSerializing JSON Object"); } return(fuelBurnRateRequest); }
public void GivenCustomerServiceIsReadyToVerify(string TestDescription) { //log the scenario info TestName = (ScenarioContext.Current.ScenarioInfo).Title + "_" + TestDescription; //TestName = TestDescription; LogResult.Report(Log, "log_ForInfo", "Execution started for Test Scenario" + TestName); }
public void AssociateAssetDevice() { Guid.TryParse(AssetUID, out AssetUidGuid); associateAssetDevice = new AssociateAssetDevice { DeviceUID = defaultValidDeviceServiceCreateModel.DeviceUID, AssetUID = AssetUidGuid, ReceivedUTC = DateTime.Now, ActionUTC = DateTime.Now }; var requestString = JsonConvert.SerializeObject(associateAssetDevice); try { GetToken(true); var response = RestClientUtil.DoHttpRequest(AssetServiceConfig.DeviceAssetAssociationEndpoint, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null); LogResult.Report(Log, "log_ForInfo", "Device Asset Association ends-Success "); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Exception Occured while associating asset to device" + "AssetUID-" + AssetUidGuid + "DeviceUID-" + defaultValidDeviceServiceCreateModel.DeviceUID); throw new Exception("Exception Occured while associating asset to device" + "AssetUID - " + AssetUidGuid + "DeviceUID - " + defaultValidDeviceServiceCreateModel.DeviceUID); } }
private void WaitForKafkaResponseAfterDissociate(bool isPositiveCase = true) { int i = 0; if (!isPositiveCase) { LogResult.Report(Log, "log_ForInfo", "Expecting No Response From Kafka"); } else { LogResult.Report(Log, "log_ForInfo", "Waiting " + KafkaServicesConfig.InitialWaitingTimeForReceivingResponseInSeconds + " seconds For Kafka Response"); } for (i = 0; i < KafkaServicesConfig.InitialWaitingTimeForReceivingResponseInSeconds; i++) { if (DissociateCustomerUserModel.CustomerUID != Guid.Empty) { if (dissociateCustomerUserResponse != null) { break; } } Thread.Sleep(1000); } if (i >= KafkaServicesConfig.InitialWaitingTimeForReceivingResponseInSeconds && isPositiveCase) { LogResult.Report(Log, "log_ForError", "Got Error While Waiting For Kafka Response"); throw new Exception("Got Error While Waiting For Kafka Response"); } }
public List <string> GetSQLResults(string queryString) { MySqlDataReader dataReader = null; List <string> dbResult = new List <string>(); using (MySqlConnection mySqlConnection = new MySqlConnection(MySqlConnectionString)) { try { //Open connection mySqlConnection.Open(); //Execute the SQL query MySqlCommand mySqlCommand = new MySqlCommand(queryString, mySqlConnection); //Read the results into a SqlDataReader and store in string variable for later reference dataReader = mySqlCommand.ExecuteReader(); while (dataReader != null && dataReader.Read()) { if (dataReader.HasRows) { for (int i = 0; i < dataReader.VisibleFieldCount; i++) { dbResult.Add(dataReader[i].ToString()); } } //dataReader.ToString(); } } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got error while executing db query", e); throw new InvalidDataException("Error Occurred while executing db query"); } }; return(dbResult); }
public void GivenFuelBurntRateIsReadyToVerify(string testDescription) { string testName = string.Empty; testName = (ScenarioContext.Current.ScenarioInfo).Title.ToString() + "_" + testDescription; LogResult.Report(Log, "log_ForInfo", "Execution started for Test Scenario " + testName); }
public void PostFuelBurntRate(bool isvalid = true) { var requestString = JsonConvert.SerializeObject(fuelRequest); try { LogResult.Report(Log, "log_ForInfo", "Create Fuel Burnt rate: Starts"); string accessToken = AssetServiceConfig.GetValidUserAccessToken(); string response; SetCustomerUIDHeader(AssetServiceConfig.CustomerUID); if (isvalid) { response = RestClientUtil.DoHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, accessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); } else { response = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.FuelBurnRateAPI, HeaderSettings.PutMethod, accessToken, HeaderSettings.JsonMediaType, requestString, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); } fuelResponse = JsonConvert.DeserializeObject <FuelBurntRateResponse>(response); LogResult.Report(Log, "log_ForInfo", "Create Fuel Burnt rate: Ends"); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Exception Occured while creating fuel burnt rate " + e); throw new Exception("Exception Occured while creating creating fuel burnt rate \n"); } }
public static void InitializeKafkaConsumer(IHandler handler) { CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); ConsumerSettings settings = null; settings = new ConsumerSettings() { GroupName = "AssetServiceAutomation", TopicName = AssetServiceConfig.AssetServiceTopic, KafkaUri = KafkaUri, AutoCommit = true, BatchRead = false, ReadAsync = true, ReadFromEnd = false, MaxQueueSize = 50000, MaxBatchSize = 2000 }; if (KafkaDriver.Equals(RPL)) { CommonConsumer = new RPLConsumer(); } else if (KafkaDriver.Equals(MISAKAI)) { CommonConsumer = new MisakaiConsumer(); } else { CommonConsumer = new JavaConsumer(); } LogResult.Report(Log, "log_ForInfo", "Kafka Consumer Initialized For " + "Topic: " + AssetServiceConfig.AssetServiceTopic); KafkaConsumer = Task.Factory.StartNew(() => CommonConsumer.StartConsuming(handler, settings, cancellationTokenSource.Token)); }
public static void ProduceMessage(string message, string key = "") { PayloadMessage payloadMessage = new PayloadMessage { Value = message, Key = key }; switch (KafkaDriver) { case JAVA: Console.WriteLine("In JavaPublisher"); LogResult.Report(Log, "log_ForInfo", "In JavaPublisher"); if (JavaPublisher != null) { JavaPublisher.Publish(payloadMessage); } else { Console.WriteLine("Javapublisher is null " + JavaPublisher); LogResult.Report(Log, "log_ForInfo", "Javapublisher is null" + JavaPublisher); } break; } }
public void GivenSAVSubscriptionServiceIsReadyToVerify(string testDescription) { TestDescription = testDescription; TestName = (ScenarioContext.Current.ScenarioInfo).Title + "_" + testDescription; //TestName = TestDescription; LogResult.Report(Log, "log_ForInfo", "Execution started for Test Scenario" + TestName); SubscriptionType.Add("Essentials"); }
public static void DisposePublisher() { if (KafkaDriver.Equals(RPL)) { //RPLPublisher.Dispose(); LogResult.Report(Log, "log_ForInfo", "Kafka Publisher Disposed"); } }
public static void DisposeConsumer() { if (KafkaDriver.Equals(RPL)) { CommonConsumer.Dispose(); LogResult.Report(Log, "log_ForInfo", "Kafka Consumer Disposed"); } }
public IEnumerable <Folding> Update(LogResult logResult) { var fold = _configurationManager.Load().Result.Fold; foreach (var entry in logResult.Entries) { if (entry.Lines <= 1) { continue; } var entryOffset = (int)entry.Offset; var logEntry = entry.LogEntry.ToString(); var indexOfFirstLf = logEntry.IndexOf('\n'); if (indexOfFirstLf == -1) { continue; } var startOffset = entryOffset + indexOfFirstLf; if (logEntry[indexOfFirstLf - 1] == '\r') { startOffset -= 1; } var endOffset = entryOffset + logEntry.Length; if (logEntry.EndsWith("\r\n")) { endOffset -= 2; } else if (logEntry.EndsWith("\n")) { endOffset -= 1; } if (startOffset >= endOffset) { continue; } var folding = new Folding { StartOffset = startOffset, EndOffset = endOffset, Name = "...", IsFolded = fold }; yield return(folding); } }
public ReturnT <LogResult> log(long logDateTim, int logId, int fromLineNum) { // log filename: yyyy-MM-dd/9999.log //todo:这里时间戳转换应该会问题 String logFileName = XxlJobFileAppender.makeLogFileName(TimeUtil.ToTime(logDateTim), logId); LogResult logResult = XxlJobFileAppender.readLog(logFileName, fromLineNum); return(new ReturnT <LogResult>(logResult)); }
public void GetDeviceTypeCustomerNull() { LogResult.Report(Log, "log_ForInfo", "GetDeviceTypeDetails: Starts for Customer" + CustomerUID); GetToken(false); CustomHeaders.Add(CustomerUid, ""); var ResponseJSON = RestClientUtil.DoInvalidHttpRequest(AssetServiceConfig.GetDeviceType, HeaderSettings.GetMethod, AccessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.BadRequest, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, CustomHeaders); deviceTypeResponse = JsonConvert.DeserializeObject <DeviceTypeResponse>(ResponseJSON); LogResult.Report(Log, "log_ForInfo", "GetDeviceTypeDetails: Ends for Customer" + CustomerUID); }
public static void WaitForDB() { int InitialWaitingTimeForReceivingResponseInSeconds = int.Parse(ConfigurationManager.AppSettings["InitialWaitingTimeForReceivingResponseInSeconds"]); LogResult.Report(Log, "log_ForInfo", "Waiting " + InitialWaitingTimeForReceivingResponseInSeconds + " seconds for DB"); for (int i = 1; i <= InitialWaitingTimeForReceivingResponseInSeconds; i++) { Thread.Sleep(1000); } }
public WriteToExcel(LogResult logResult) { var list = new List <LogResult> { logResult }; DataTable table = (DataTable)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(list), (typeof(DataTable))); // Open the document for editing. CreateNewExcelFile(table); }
public async void OnSearchCriteria() { ShowResults = false; results = await Logs.GetAsync(HostnameFilter, Username); if (results.value.Count() != 0) { ShowResults = true; } StateHasChanged(); }
public async Task Display(LogResult result) { _currentResult = result; await Application.Current.Dispatcher.Invoke(async() => { Document.Text = result.LogText; Document.UndoStack.ClearAll(); Foldings = await Task.Factory.StartNew(() => _foldingService.Update(result).ToList()); }); }
public List <LogResult> GetLogChanges() { if (ActionList.NotNull() && !ActionList.Any()) { return(new List <LogResult>()); } var _lstLogResult = new List <LogResult>(); var attorneyId = AttorneyUser.UserId; if (_faxChanged) { var _logResult = new LogResult(); _logResult.UserId = attorneyId; _logResult.Type = LogType.Audit; _logResult.FieldName = nameof(CurrentFaxNumber); _logResult.PreviousValue = CurrentFaxNumber?.Number; _logResult.NewValue = NewFaxNumber?.Number; _logResult.Result = true; _logResult.Message = "Fax Changed"; _lstLogResult.Add(_logResult); } if (_assistantChanged) { var _logResult = new LogResult(); _logResult.UserId = attorneyId; _logResult.Type = LogType.Audit; _logResult.FieldName = nameof(CurrentAssistant); _logResult.PreviousValue = CurrentAssistant?.UserId; _logResult.NewValue = NewAssistant?.UserId; _logResult.Result = true; _logResult.Message = "Assistant Changed"; _lstLogResult.Add(_logResult); } foreach (var action in ActionList) { if (action.Result.NotNull()) { var _logResult = new LogResult(); _logResult.UserId = attorneyId; _logResult.Type = LogType.ApiCall; _logResult.Result = action.Result.Result; _logResult.FieldName = "FaxSoultion"; _logResult.NewValue = $"AttId:{action.AssistantSnycObj.FaxAttorneyUserId} UsrId:{action.AssistantSnycObj.FaxUserId} FaxId:{action.AssistantSnycObj.FaxNumberId}"; _logResult.Message = $"Action:{action.ActionType.ToString()} Message:{action.Result.HttpCallLog} {action.Result.Message}"; _lstLogResult.Add(_logResult); } } return(_lstLogResult); }
public void ThenTheDeviceUpdatedDetailsMustBeStoredInMySqlDB() { try { Assert.IsTrue(deviceServiceSupport.ValidateDB("UpdateEvent"), "DB Verification failed"); LogResult.Report(Log, "log_ForInfo", "DB Validation Successful\n"); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While Validating DB", e); throw new Exception(e + "Got Error While Validating DB\n"); } }
public void GetAccountHierarchyByUserUID() { // AccountHierarchyByUserUIDResponseString try { LogResult.Report(Log, "log_ForInfo", "Performing Get Account Hierarchy By User UID"); AccountHierarchyByUserUIDResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.AccountHierarchyByUserUIDEndPoint, HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While Performing Get Account Hierarchy By User UID", e); throw new Exception(e + " Got Error While Performing Get Account Hierarchy By User UID"); } }
public void PostAssociateAssetCustomer() { try { string AssociateAssetCustomerRequest = GetAssociateAssetCustomerRequestString(); string AssociateAssetCustomer = "https://api-stg.trimble.com/t/trimble.com/vss-dev-customerservice/1.0/AssociateCustomerAsset"; var Responsestring = RestClientUtil.DoHttpRequest(AssociateAssetCustomer, HeaderSettings.PostMethod, AccessToken, HeaderSettings.JsonMediaType, AssociateAssetCustomerRequest, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType, null); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Exception Occured while associating asset to device" + "AssetUID-" + createAssetEvent.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID); throw new Exception("Exception Occured while associating asset to device" + "AssetUID-" + createAssetEvent.AssetUID + "Customer-" + associateAssetCustomer.CustomerUID); } }
public bool ValidateDB() { string query; bool dbResult = false; string DBResultCustomerUID; string DBResultStartDate; string DBResultEndDate; string DBResultSubscriptionSource; for (int i = 0; i < SAVSubscriptionDBValidation.Count(); i++) { MySqlDataReader dataReader = null; //List<string> dbResult = new List<string>(); query = string.Format(SAVSubscriptionSqlQueries.SAVSubscriptionByAssetUID, SAVSubscriptionDBValidation[i].AssetUID.Replace("-", ""), SAVSubscriptionDBValidation[i].SubscriptionUID.Replace("-", "")); using (MySqlConnection mySqlConnection = new MySqlConnection(SubscriptionServiceConfig.MySqlConnection)) { try { //Open connection mySqlConnection.Open(); //Execute the SQL query MySqlCommand mySqlCommand = new MySqlCommand(query, mySqlConnection); dataReader = mySqlCommand.ExecuteReader(); while (dataReader != null && dataReader.Read()) { if (dataReader.HasRows) { DBResultCustomerUID = dataReader[0].ToString(); DBResultStartDate = dataReader[1].ToString(); DBResultEndDate = dataReader[2].ToString(); DBResultSubscriptionSource = dataReader[3].ToString(); Assert.AreEqual(SAVSubscriptionDBValidation[i].CustomerUID.Replace("-", "").ToUpper(), DBResultCustomerUID, "Customer DB Validation Fail"); Assert.AreEqual(SAVSubscriptionDBValidation[i].StartDate, DBResultStartDate, "Start Date VAlidation Fail"); Assert.AreEqual(SAVSubscriptionDBValidation[i].EndDate, DBResultEndDate, "End Date Validation Fail"); Assert.AreEqual(SAVSubscriptionDBValidation[i].SubscriptionSource.ToString(), DBResultSubscriptionSource, "Subscription Source Validation Fail"); dbResult = true; } } } catch (Exception e) { LogResult.Report(SAVSubscriptionSteps.Log, "log_ForError", "Got error while executing db query", e); return(dbResult); } } } return(dbResult); }
public static LogResult[] Analysis(String path) { byte[] byteArray = System.Text.Encoding.Default.GetBytes(path); char * pArray = AnalysisLogFile(byteArray); int lines = getLen(); Console.WriteLine("C#, loglines:" + lines); logInfo[] getLog = new logInfo[1]; //生成可以在C#中使用的数据 LogResult[] myLogResult = new LogResult[lines]; for (int i = 0; i < lines; i++) { getLog[0] = (logInfo)Marshal.PtrToStructure((IntPtr)(pArray) + Marshal.SizeOf(typeof(logInfo)) * i, typeof(logInfo)); myLogResult[i] = new LogResult(); myLogResult[i].type = getLog[0].type; myLogResult[i].line = getLog[0].line; myLogResult[i].time_v = getLog[0].time_v; myLogResult[i].time = Convert.ToString(Marshal.PtrToStringAnsi((IntPtr)((byte *)getLog[0].time))); myLogResult[i].cmd = Convert.ToString(Marshal.PtrToStringAnsi((IntPtr)((byte *)getLog[0].cmd))); //去掉文件类型引起的回车符问题 if (myLogResult[i].cmd.Length > 2) { myLogResult[i].cmd = myLogResult[i].cmd.Replace("\r", "").Replace("\n", ""); } //Console.WriteLine("C#, line:" + getLog[0].line); //添加到扫描结果的数组中 if (getLog[0].type == 0x06) { //扫描结果数组初始话 scanResultList = new List <string>(); CDLL_scan_results result = (CDLL_scan_results)Marshal.PtrToStructure((IntPtr)(getLog[0].cmd), typeof(CDLL_scan_results)); while ((int)(result.Next) != 0 && (IntPtr)(result.result) != null) { String temp = Convert.ToString(Marshal.PtrToStringAnsi((IntPtr)((byte *)result.result))); scanResultList.Add(temp); result = (CDLL_scan_results)Marshal.PtrToStructure((IntPtr)(result.Next), typeof(CDLL_scan_results)); } myLogResult[i].scanResultList = scanResultList; } } return(myLogResult); }
public string PostValidReadRequestToService(string accessToken) { try { LogResult.Report(Log, "log_ForInfo", "Reading the list of available geofences for the user accesstoken the request with Valid Values: " + accessToken); string ResponseString = RestClientUtil.DoHttpRequest(CustomerServiceConfig.CustomerServiceEndpoint + "/accounthierarchy", HeaderSettings.GetMethod, accessToken, HeaderSettings.JsonMediaType, null, HttpStatusCode.OK, HeaderSettings.BearerType, HeaderSettings.JsonMediaType); return(ResponseString); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While Posting Data To Geofence Service", e); throw new Exception(e + " Got Error While Posting Data To Geofence Service"); } }
private void TestLogNonExisting() { string nonExisting = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Journal.ConfigureJournalSocket(nonExisting); // Journal is not available Assert.False(Journal.IsAvailable); using (var message = Journal.GetMessage()) { // This shouldn't throw. LogResult result = Journal.Log(LogFlags.Information, message); Assert.Equal(LogResult.NotAvailable, result); } }
public void VerifyInvalidResponse() { try { getAssetSettingsResponse = JsonConvert.DeserializeObject <GetAssetSettingsResponseModel>(ResponseJSON); var result = getAssetSettingsResponse.assetSettings.Find(x => x.assetUid == CreateAsset.AssetUID); Assert.AreEqual(null, result); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Exception Occured while deserializing getAssetSettingsResponse " + e); throw new Exception("Exception Occured while deserializing getAssetSettingsResponse \n"); } }
public void VerifyErrorResponse() { AssetDeviceErrorResponseModel response; try { response = JsonConvert.DeserializeObject <AssetDeviceErrorResponseModel>(ResponseString); } catch (Exception e) { LogResult.Report(Log, "log_ForError", "Got Error While DeSerializing JSON Object", e); throw new Exception("Got Error While DeSerializing JSON Object"); } Assert.AreEqual("Invalid input", response.Message); }
protected void Init() { System.DateTime thisDateTime = System.DateTime.Now; this.DateTime = thisDateTime.ToString("dd-MM-yyyy [hh:mm:ss:fff]"); this.LineNumber++; this.Result = LogResult.NOT; this.Description = ""; this.ShortMessage = ""; }
public static LogResult[] Analysis(String path) { byte[] byteArray = System.Text.Encoding.Default.GetBytes(path); char* pArray = AnalysisLogFile(byteArray); int lines = getLen(); Console.WriteLine("C#, loglines:" + lines); logInfo[] getLog = new logInfo[1]; //生成可以在C#中使用的数据 LogResult[] myLogResult = new LogResult[lines]; for (int i = 0; i < lines; i++) { getLog[0] = (logInfo)Marshal.PtrToStructure((IntPtr)(pArray) + Marshal.SizeOf(typeof(logInfo))*i, typeof(logInfo)); myLogResult[i] = new LogResult(); myLogResult[i].type = getLog[0].type; myLogResult[i].line = getLog[0].line; myLogResult[i].time_v = getLog[0].time_v; myLogResult[i].time = Convert.ToString(Marshal.PtrToStringAnsi((IntPtr)((byte*)getLog[0].time))); myLogResult[i].cmd = Convert.ToString(Marshal.PtrToStringAnsi((IntPtr)((byte*)getLog[0].cmd))); //去掉文件类型引起的回车符问题 if (myLogResult[i].cmd.Length > 2) myLogResult[i].cmd = myLogResult[i].cmd.Replace("\r", "").Replace("\n", ""); //Console.WriteLine("C#, line:" + getLog[0].line); //添加到扫描结果的数组中 if (getLog[0].type == 0x06) { //扫描结果数组初始话 scanResultList = new List<string>(); CDLL_scan_results result = (CDLL_scan_results)Marshal.PtrToStructure((IntPtr)(getLog[0].cmd), typeof(CDLL_scan_results)); while ((int)(result.Next) != 0 && (IntPtr)(result.result) != null) { String temp = Convert.ToString(Marshal.PtrToStringAnsi((IntPtr)((byte*)result.result))); scanResultList.Add(temp); result = (CDLL_scan_results)Marshal.PtrToStructure((IntPtr)(result.Next), typeof(CDLL_scan_results)); } myLogResult[i].scanResultList = scanResultList; } } return myLogResult; }
//将数据转换为扫描结果的struct public static ScanResults[] getScanResults(LogResult log) { ScanResults[] scanResultsArray = new ScanResults[log.scanResultList.Count]; for (int i = 0; i < scanResultsArray.Length; i++) { //先按照空格把数据分割开 String[] result = log.scanResultList[i].Split(' '); if (result.Length == 4) { scanResultsArray[i].BSSID = result[0].Substring(result[0].IndexOf('=')+1); scanResultsArray[i].SSID = result[1].Substring(result[1].IndexOf('=')+1); scanResultsArray[i].freq = Convert.ToInt32(result[2].Substring(result[2].IndexOf('=') + 1)); scanResultsArray[i].level = result[3].Substring(result[3].IndexOf('=')+1); } } return scanResultsArray; }