private void btn_Search_Click(object sender, RoutedEventArgs e) { var CustomerFiltered = from product in DB.SelectAllProducts() let ProductName = product.Name where ProductName.StartsWith(TextBox_Search.Text.ToLower()) || ProductName.StartsWith(TextBox_Search.Text.ToUpper()) || ProductName.Contains(TextBox_Search.Text) select product; ListBox_Products.ItemsSource = CustomerFiltered; }
public SqlServerSupportDates(IReadOnlyList <string> csvData) { ProductName = csvData[0]; // All of the date parsing below are forced to use US English culture // due to the CSV file from Microsoft's support site coming back // in that format regardless of the locale where the program runs LifeCycleStartDate = DateTime.TryParse(csvData[1], new CultureInfo("en-us"), DateTimeStyles.None, out var lifeCycleStartDate) ? lifeCycleStartDate : (DateTime?)null; MainstreamSupportEndDate = DateTime.TryParse(csvData[2], new CultureInfo("en-us"), DateTimeStyles.None, out var mainStreamSupportEndDate) ? mainStreamSupportEndDate : (DateTime?)null; ExtendedSupportEndDate = DateTime.TryParse(csvData[3], new CultureInfo("en-us"), DateTimeStyles.None, out var extendedSupportEndDate) ? extendedSupportEndDate : (DateTime?)null; ServicePackSupportEndDate = DateTime.TryParse(csvData[4], new CultureInfo("en-us"), DateTimeStyles.None, out var servicePackSupportEndDate) ? servicePackSupportEndDate : (DateTime?)null; for (var i = 5; i < csvData.Count; i++) { Notes += csvData[i]; } if (MainstreamSupportEndDate != null || ServicePackSupportEndDate != null) { return; } if (!ProductName.Contains("2017") && !ProductName.Contains("2016") && !ProductName.Contains("2014") && !ProductName.Contains("2012") && !ProductName.Contains("2008 R2")) { return; } Console.WriteLine($"NULL Dates in input string (culture={CultureInfo.CurrentCulture}): "); Console.WriteLine(string.Join(",", csvData)); throw new ArgumentException("NULL date values detected, exiting."); }
protected override void PlayAndRecord(string WavFileName, Channel Channel) { bool IsEqual = false; ProductName = string.Empty; List <Guid> AudioDeviceList = null; SetupApi = new SetupApi(); di.Clear(); switch (Channel) { case Channel.Left: case Channel.Right: case Channel.AudioJack: AudioDeviceList = MachineAudioDeviceList; break; case Channel.HeadSet: AudioDeviceList = ExternalAudioDeviceList; break; case Channel.Fan: AudioDeviceList = FanRecordDeviceList; break; } for (int n = -1; n < WaveOut.DeviceCount; n++) { var caps = WaveOut.GetCapabilities(n); Console.WriteLine("Play device {0}: {1}", n, caps.ProductName); Console.WriteLine(caps.ManufacturerGuid); Trace.WriteLine(caps.ManufacturerGuid); foreach (var v in AudioDeviceList) { if (caps.ManufacturerGuid.Equals(v)) { DeviceNumber = n; ProductName = caps.ProductName; SetupApi.GetLocationInformation(DeviceNumber, ProductName); Console.WriteLine("Find"); } } } switch (Channel) { case Channel.Left: case Channel.Right: if (string.IsNullOrEmpty(ProductName)) { throw new Exception("Machine audio device not found"); } break; case Channel.HeadSet: IsEqual = ExternalAudioDeviceList.Except(FanRecordDeviceList).Count() == 0; if (IsEqual) { if (SetupApi.di.Count() < 2 || ProductName.Contains(UsbAudioDeviceName)) { throw new Exception("External audio device not found"); } } else { if (string.IsNullOrEmpty(ProductName) || ProductName.Contains(UsbAudioDeviceName)) { throw new Exception("External audio device not found"); } } DeviceNumber = SetupApi.di.OrderBy(e => e.Value).FirstOrDefault().Key; //ProductName = SetupApi.di.OrderBy(e => e.Value).FirstOrDefault().Value; break; case Channel.AudioJack: if (string.IsNullOrEmpty(ProductName)) { throw new Exception("Audio Jack device not found"); } break; case Channel.Fan: IsEqual = ExternalAudioDeviceList.Except(FanRecordDeviceList).Count() == 0; if (IsEqual) { if (SetupApi.di.Count() < 2 || ProductName.Contains(UsbAudioDeviceName)) { throw new Exception("Fan record device not found"); } } else { if (string.IsNullOrEmpty(ProductName) || ProductName.Contains(UsbAudioDeviceName)) { throw new Exception("Fan record device not found"); } } DeviceNumber = SetupApi.di.OrderBy(e => e.Value).LastOrDefault().Key; //ProductName = SetupApi.di.OrderBy(e => e.Value).LastOrDefault().Value; break; } using (var inputReader = new WaveFileReader(WavFileName)) using (var outputDevice = new WaveOutEvent()) { outputDevice.DeviceNumber = DeviceNumber; Console.WriteLine("Play device: ###### {0} ######", WaveOut.GetCapabilities(DeviceNumber).ProductName); foreach (var item in SetupApi.di.OrderBy(e => e.Value)) { Console.WriteLine(item.Key + " " + item.Value); } outputDevice.Init(inputReader); outputDevice.PlaybackStopped += (sender, e) => { if (WavSource != null) { WavSource.StopRecording(); } Console.WriteLine("Play Stopped"); }; outputDevice.Play(); switch (Channel) { case Channel.Left: Record(Channel.Left).Wait(); break; case Channel.Right: Record(Channel.Right).Wait(); break; case Channel.AudioJack: Record(Channel.AudioJack).Wait(); break; case Channel.HeadSet: Record(Channel.HeadSet).Wait(); break; case Channel.Fan: Record(Channel.Fan).Wait(); break; } while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(500); } } }
protected override Task <string> Record(Channel Channel) { var tcs = new TaskCompletionSource <string>(); WavSource = new WaveInEvent(); bool IsEqual = false; ProductName = string.Empty; List <Guid> AudioDeviceList = null; switch (Channel) { case Channel.Left: case Channel.Right: AudioDeviceList = ExternalAudioDeviceList; break; case Channel.AudioJack: AudioDeviceList = MachineAudioDeviceList; break; case Channel.HeadSet: AudioDeviceList = DigitalMicDeviceList; break; case Channel.Fan: AudioDeviceList = FanRecordDeviceList; break; } SetupApi.di.Clear(); for (int n = -1; n < WaveInEvent.DeviceCount; n++) { var caps = WaveInEvent.GetCapabilities(n); Console.WriteLine("Record device {0}: {1}", n, caps.ProductName); Console.WriteLine(caps.ManufacturerGuid); Trace.WriteLine(caps.ManufacturerGuid); foreach (var v in AudioDeviceList) { if (caps.ManufacturerGuid.Equals(v)) { DeviceNumber = n; ProductName = caps.ProductName; if (!di.ContainsKey(DeviceNumber)) { di.Add(DeviceNumber, ProductName); } SetupApi.GetLocationInformation(DeviceNumber, ProductName); Console.WriteLine("Find"); } } } switch (Channel) { case Channel.Left: case Channel.Right: IsEqual = ExternalAudioDeviceList.Except(FanRecordDeviceList).Count() == 0; if (IsEqual) { if (SetupApi.di.Count() < 2 || ProductName.Contains(UsbAudioDeviceName)) { throw new Exception("External audio device not found"); } } else { if (string.IsNullOrEmpty(ProductName) || ProductName.Contains(UsbAudioDeviceName)) { throw new Exception("External audio device not found"); } } DeviceNumber = SetupApi.di.OrderBy(e => e.Value).FirstOrDefault().Key; //ProductName = SetupApi.di.OrderBy(e => e.Value).FirstOrDefault().Value; break; case Channel.HeadSet: if (string.IsNullOrEmpty(ProductName)) { throw new Exception("Digital Mic device not found"); } break; case Channel.AudioJack: ProductName = string.Empty; Regex regex = new Regex(RealtekMicrophone); foreach (var v in di) { if (regex.IsMatch(v.Value)) { DeviceNumber = v.Key; ProductName = v.Value; } } if (string.IsNullOrEmpty(ProductName)) { throw new Exception("Audio Jack device not found"); } break; case Channel.Fan: IsEqual = ExternalAudioDeviceList.Except(FanRecordDeviceList).Count() == 0; if (IsEqual) { if (SetupApi.di.Count() < 2) { throw new Exception("Fan record device not found"); } } else { if (string.IsNullOrEmpty(ProductName)) { throw new Exception("Fan record device not found"); } } DeviceNumber = SetupApi.di.OrderBy(e => e.Value).LastOrDefault().Key; //ProductName = SetupApi.di.OrderBy(e => e.Value).LastOrDefault().Value; break; } WavSource.DeviceNumber = DeviceNumber; Console.WriteLine("Record device ###### {0} ######", WaveInEvent.GetCapabilities(DeviceNumber).ProductName); foreach (var item in SetupApi.di.OrderBy(e => e.Value)) { Console.WriteLine(item.Key + " " + item.Value); } WavSource.WaveFormat = new WaveFormat(44100, 1); WavSource.DataAvailable += (sender, e) => { if (WavSourceFile != null) { WavSourceFile.Write(e.Buffer, 0, e.BytesRecorded); WavSourceFile.Flush(); } }; WavSource.RecordingStopped += (sender, e) => { if (WavSource != null) { WavSource.Dispose(); WavSource = null; } if (WavSourceFile != null) { WavSourceFile.Dispose(); WavSourceFile = null; } Thread.Sleep(200); tcs.SetResult("Done"); Console.WriteLine("Record Stopped"); }; switch (Channel) { case Channel.Left: WavSourceFile = new WaveFileWriter(LeftRecordFileName, WavSource.WaveFormat); break; case Channel.Right: WavSourceFile = new WaveFileWriter(RightRecordFileName, WavSource.WaveFormat); break; case Channel.HeadSet: WavSourceFile = new WaveFileWriter(InternalRecordFileName, WavSource.WaveFormat); break; case Channel.AudioJack: WavSourceFile = new WaveFileWriter(AudioJackRecordFileName, WavSource.WaveFormat); break; case Channel.Fan: WavSourceFile = new WaveFileWriter(FanRecordFileName, WavSource.WaveFormat); break; } WavSource.StartRecording(); return(tcs.Task); }
public override bool CheckIfNormal() { return(ProductName != null && (ProductName.Contains("WithFin") && Height > 60) || ((ProductName.Contains("NoFin") && Height > 0))); }