public static async Task SearchByKeywordMfrRequestAsync(ApplicationContext context, Proxy proxy, ApiRegInfo apiRegInfo, string keyword, Manufacturer manufacturer, int records, int startingRecord) { using (var searchAPI = new SearchAPI()) { var header = new MouserHeader(); header.AccountInfo = new AccountInfo(); header.AccountInfo.PartnerID = apiRegInfo.PartnerId; searchAPI.MouserHeaderValue = header; WebProxy wp = new WebProxy(proxy.IPAddress, true); if (proxy.UserName != "") { ICredentials credentials = new NetworkCredential(proxy.UserName, proxy.Password); wp.Credentials = credentials; } searchAPI.Proxy = wp; ResultParts resultParts = searchAPI.SearchByKeywordAndManufacturer(keyword, manufacturer.MouserID, records, startingRecord, String.Empty, String.Empty); EFManufacturer eFManufacturer = new EFManufacturer(context); manufacturer.StartingRecord = startingRecord; manufacturer.NumberOfResult = resultParts.NumberOfResult; await eFManufacturer.AddOrUpdateAsync(manufacturer, manufacturer.Id); foreach (var resultPart in resultParts.Parts.ToList()) { await SaveGoodAsync(context, resultPart, manufacturer); } } }
/// <summary> /// Processes the raw result from the merchant one web result /// Example: response=1&responsetext=SUCCESS&authcode=123456&transactionid=5158550654&avsresponse=N&cvvresponse=N&orderid=&type=sale&response_code=100 /// </summary> /// <param name="result"></param> public MerchantOnePaymentResult(string result) { RawResult = $"&{result.TrimEnd(';')}"; ResultParts = RawResult.Split("&").ToList().Where(v => v != string.Empty).ToList(); // 1, 2, 3 are the only valid responses according to the documentation Response = GetValue(ResultParts.FirstOrDefault(v => v.Contains("response=1") || v.Contains("response=2") || v.Contains("response=3"))); ResponseText = GetValue(ResultParts.FirstOrDefault(v => v.Contains("responsetext="))); AuthorizationCode = GetValue(ResultParts.FirstOrDefault(v => v.Contains("authcode="))); TransactionId = GetValue(ResultParts.FirstOrDefault(v => v.Contains("transactionid="))); AvsResponse = GetValue(ResultParts.FirstOrDefault(v => v.Contains("avsresponse="))); CvvResponse = GetValue(ResultParts.FirstOrDefault(v => v.Contains("cvvresponse="))); OrderId = GetValue(ResultParts.FirstOrDefault(v => v.Contains("orderid="))); Type = GetValue(ResultParts.FirstOrDefault(v => v.Contains("type="))); ResponseCode = GetValue(ResultParts.FirstOrDefault(v => v.Contains("response_code="))); }
/// <summary> /// Singleton patern : Constructor used to save all the data in a file. /// </summary> private ResultsViewModel() { Results = new ObservableCollection <ResultParts>(); RpVoice = new ResultParts("Results of the part \"Voice\""); RpAgitation = new ResultParts("Results of the Agitation part"); RpArmsMotion = new ResultParts("Results of the Arms Motion part"); RpFace = new ResultParts("Results of the part \"Face\""); ValueCheckBoxChoice = new bool[20]; for (int i = 0; i < 20; i++) { ValueCheckBoxChoice[i] = true; } Chart.Colors = new List <Color> { (Color)Application.Current.Resources["ColorGraph1"], (Color)Application.Current.Resources["ColorGraph2"], (Color)Application.Current.Resources["ColorGraph3"], (Color)Application.Current.Resources["ColorGraph4"], (Color)Application.Current.Resources["ColorGraph5"] }; }