protected virtual bool MatchIndexNames([NotNull] IIndex source, [NotNull] IIndex target) { Check.NotNull(source, "source"); Check.NotNull(target, "target"); return(ExtensionProvider.Extensions(source).Name == ExtensionProvider.Extensions(target).Name); }
public void Initialize(Stream stream, AudioInfo audioInfo, MetadataDictionary metadata, SettingsDictionary settings) { Contract.Ensures(_encoder != null); // Load the external gain filter: ExportFactory <ISampleFilter> sampleFilterFactory = ExtensionProvider.GetFactories <ISampleFilter>("Name", "ReplayGain").SingleOrDefault(); if (sampleFilterFactory == null) { throw new ExtensionInitializationException(Resources.SampleEncoderReplayGainFilterError); } _replayGainFilterLifetime = sampleFilterFactory.CreateExport(); _replayGainFilterLifetime.Value.Initialize(metadata, settings); // Call the external ID3 encoder: ExportFactory <IMetadataEncoder> metadataEncoderFactory = ExtensionProvider.GetFactories <IMetadataEncoder>("Extension", EncoderInfo.FileExtension).Single(); if (metadataEncoderFactory == null) { throw new ExtensionInitializationException(string.Format(CultureInfo.CurrentCulture, Resources.SampleEncoderMetadataEncoderError, EncoderInfo.FileExtension)); } using (ExportLifetimeContext <IMetadataEncoder> metadataEncoderLifetime = metadataEncoderFactory.CreateExport()) metadataEncoderLifetime.Value.WriteMetadata(stream, metadata, settings); _encoder = InitializeEncoder(audioInfo, stream); ConfigureEncoder(settings, _encoder); if (_encoder.InitializeParams() != 0) { throw new IOException(Resources.SampleEncoderFailedToInitialize); } }
public async Task <ActionResult <object> > Get() { var correlationId = HttpContext.TraceIdentifier; // информация для логирования var preLog = correlationId + " | " + ClassName + "Controller." + ExtensionProvider.GetCallerMethodName(); // логируем начало выполнения метода Logging.Trace(preLog + " START"); // выполнение метода try { // логируем запрос Logging.Request(preLog + "(Запрос метода.)"); // получаем данные из базы данных var data = await DataProvider.GetAsync(Asd_E_Type.Department, correlationId); // логируем ответ Logging.Response(preLog + "(Ответ метода.)" + JsonConvert.SerializeObject(data, Formatting.Indented).ToTabString()); // возвращаем ответ var code = data == null ? Asd_E_ResponseCode.GetError : Asd_E_ResponseCode.Success; return(new Asd_Response(code, null, data, correlationId)); } catch (Exception ex) { // логируем исключение Logging.Exception(preLog + "(" + ex.Message + ")" + ex.StackTrace.ToTabString()); // возвращаем ответ return(new Asd_Response(Asd_E_ResponseCode.GetException, ex.Message, null, correlationId)); } finally { // логируем окончание выполнения метода Logging.Trace(preLog + " END"); } }
protected virtual bool MatchTableSchemas([NotNull] IEntityType source, [NotNull] IEntityType target) { Check.NotNull(source, "source"); Check.NotNull(target, "target"); return(ExtensionProvider.Extensions(source).Schema == ExtensionProvider.Extensions(target).Schema); }
protected virtual bool MatchColumnNames([NotNull] IProperty source, [NotNull] IProperty target) { Check.NotNull(source, "source"); Check.NotNull(target, "target"); return(ExtensionProvider.Extensions(source).Column == ExtensionProvider.Extensions(target).Column); }
public void Initialize(Stream stream, AudioInfo audioInfo, MetadataDictionary metadata, SettingsDictionary settings) { _encoder = new NativeVorbisEncoder(); _output = stream; // Load the external gain filter: ExportFactory <ISampleFilter> sampleFilterFactory = ExtensionProvider.GetFactories <ISampleFilter>("Name", "ReplayGain").SingleOrDefault(); if (sampleFilterFactory == null) { throw new ExtensionInitializationException(Resources.SampleEncoderReplayGainFilterError); } _replayGainFilterLifetime = sampleFilterFactory.CreateExport(); _replayGainFilterLifetime.Value.Initialize(metadata, settings); _oggStream = IntializeOggStream(settings); _buffer = new byte[4096]; if (!string.IsNullOrEmpty(settings["BitRate"])) { ConfigureEncoderForBitRate(settings, audioInfo, _encoder); } else { ConfigureEncoderForQuality(settings, audioInfo, _encoder); } WriteHeader(metadata, stream); }
/// <summary> /// presents the SaveDialog and returns the selected Filename (or null) /// </summary> /// <param name="multi"></param> /// <returns></returns> string SetupSaveDialog(string name, bool multi) { name = name.Replace(" ", "").Replace(":", "_").Replace(@"\", "_"); if (!multi) { System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog(); sfd.FileName = name; sfd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.AllFiles } ); sfd.Title = SimPe.Localization.GetString(this.ToString()); if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(sfd.FileName); } } else { System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { return(fbd.SelectedPath); } } return(null); }
public void Initialize(Stream stream, AudioInfo info, AudioMetadata metadata, SettingDictionary settings) { _stream = stream; InitializeReplayGainFilter(info, metadata, settings); // Call the external ID3 encoder, if available var metadataEncoderFactory = ExtensionProvider.GetFactories <IAudioMetadataEncoder>("Extension", FileExtension).FirstOrDefault(); if (metadataEncoderFactory != null) { using (var export = metadataEncoderFactory.CreateExport()) using (var tempStream = new MemoryStream()) { // Buffer the tag in memory export.Value.WriteMetadata(tempStream, metadata, settings); // Pre-allocate the whole stream (estimate worst case of 320kbps, plus the tag) stream.SetLength(0xA000 * (long)info.PlayLength.TotalSeconds + tempStream.Length); // Flush the tag to the output stream tempStream.WriteTo(stream); } } _encoder = new(stream); _encoder.SetChannels(info.Channels); _encoder.SetSampleRate(info.SampleRate); if (info.FrameCount > 0) { _encoder.SetSampleCount((uint)info.FrameCount); } if (settings.TryGetValue("BitRate", out int bitRate)) { // Use ABR, unless ForceCBR is set to true if (settings.TryGetValue("ForceCBR", out bool forceCbr) && forceCbr) { _encoder.SetBitRate(bitRate); } else { _encoder.SetVbrMeanBitRate(bitRate); _encoder.SetVbrMode(VbrMode.Abr); } } else { // Use VBR quality 3 if nothing else is specified _encoder.SetVbrQuality( settings.TryGetValue("VBRQuality", out int vbrQuality) ? vbrQuality : 3); _encoder.SetVbrMode(VbrMode.Mtrh); } _encoder.InitializeParameters(); }
public static async Task <bool> DeleteAsync(Asd_E_Type type, Guid id, string correlationId) { // информация для логирования var preLog = correlationId + " | " + ClassName + "." + type + "." + ExtensionProvider.GetCallerMethodName(); // логируем начало выполнения метода Logging.Trace(preLog + " START"); // выполнение метода try { // логируем запрос Logging.Request(preLog + "(Запрос метода. Исходные данные: Id = " + id + ")"); // создаем объект ответа bool response; // удаляем данные из базы данных await using (var context = new LocalDatabaseContext()) { switch (type) { case Asd_E_Type.Employee: var employee = await context.Employees.FindAsync(id); context.Employees.Remove(employee); response = await context.SaveChangesAsync() > 0; break; case Asd_E_Type.Department: var department = await context.Departments.FindAsync(id); context.Departments.Remove(department); response = await context.SaveChangesAsync() > 0; break; default: response = false; break; } } // логируем ответ Logging.Response(preLog + "(Ответ метода: " + response + ")"); // возвращаем ответ return(response); } catch (Exception ex) { // логируем исключение Logging.Exception(preLog + "(" + ex.Message + ")" + ex.StackTrace.ToTabString()); // возвращаем ответ return(false); } finally { // логируем окончание выполнения метода Logging.Trace(preLog + " END"); } }
public override bool Run() { Scheduler.MainThread = new TestScheduler(); ExtensionProvider .RegisterBehaviour("terrain_draw", typeof(TestModelBehaviour)); return(true); }
protected override void ProcessRecord() { foreach (ExportFactory <ISampleEncoder> encoderFactory in string.IsNullOrEmpty(Name) ? ExtensionProvider.GetFactories <ISampleEncoder>() : ExtensionProvider.GetFactories <ISampleEncoder>("Name", Name)) { using (ExportLifetimeContext <ISampleEncoder> encoderLifetime = encoderFactory.CreateExport()) WriteObject(encoderLifetime.Value.EncoderInfo); } }
protected override void ProcessRecord() { foreach (ExportFactory <IMetadataEncoder> factory in string.IsNullOrEmpty(Extension) ? ExtensionProvider.GetFactories <IMetadataEncoder>() : ExtensionProvider.GetFactories <IMetadataEncoder>("Extension", Extension)) { using (ExportLifetimeContext <IMetadataEncoder> encoderLifetime = factory.CreateExport()) WriteObject(encoderLifetime.Value.EncoderInfo); } }
protected virtual string ColumnType(IProperty property) { var extensions = ExtensionProvider.Extensions(property); return (TypeMapper.GetTypeMapping( extensions.ColumnType, extensions.Column, property.PropertyType, property.IsKey() || property.IsForeignKey(), property.IsConcurrencyToken) .StoreTypeName); }
public virtual AddDefaultConstraintOperation AddDefaultConstraintOperation([NotNull] IProperty target) { Check.NotNull(target, "target"); var extensions = ExtensionProvider.Extensions(target); return (new AddDefaultConstraintOperation( NameBuilder.SchemaQualifiedTableName(target.EntityType), NameBuilder.ColumnName(target), extensions.DefaultValue, extensions.DefaultExpression)); }
void InitializeReplayGainFilter(AudioInfo info, AudioMetadata metadata, SettingDictionary settings) { var filterFactory = ExtensionProvider.GetFactories <IAudioFilter>("Name", "ReplayGain").FirstOrDefault(); if (filterFactory == null) { return; } _replayGainExport = filterFactory.CreateExport(); _replayGainExport.Value.Initialize(info, metadata, settings); }
public static void Local() { // информация для логирования var preLog = Guid.Empty + " | " + ClassName + "." + ExtensionProvider.GetCallerMethodName(); try { using var context = new LocalDatabaseContext(); // мигрируем базу данных context.Database.Migrate(); } catch (Exception ex) { // логируем исключение Logging.Exception(preLog + "(" + ex.Message + ")" + ex.StackTrace.ToTabString()); } }
void InitializeReplayGainFilter( [NotNull] AudioInfo info, [NotNull] AudioMetadata metadata, [NotNull] SettingDictionary settings) { var filterFactory = ExtensionProvider.GetFactories <IAudioFilter>("Name", "ReplayGain").FirstOrDefault(); if (filterFactory == null) { return; } _replayGainExport = filterFactory.CreateExport(); // ReSharper disable once PossibleNullReferenceException _replayGainExport.Value.Initialize(info, metadata, settings); }
protected static SimPe.Packages.GeneratableFile ReColorXObject(CloneSettings.BaseResourceType br, SimPe.Packages.GeneratableFile pkg, Interfaces.Files.IPackedFileDescriptor pfd, uint localgroup, ObjectWorkshopSettings settings) { settings.KeepOriginalMesh = true; SimPe.Packages.GeneratableFile package = pkg; // we need packages in the Gmaes and the Download Folder if (((!System.IO.File.Exists(ScenegraphHelper.GMND_PACKAGE)) || (!System.IO.File.Exists(ScenegraphHelper.MMAT_PACKAGE))) && (settings is OWCloneSettings)) { if (Message.Show(Localization.Manager.GetString("OW_Warning"), "Warning", MessageBoxButtons.YesNo) == DialogResult.No) { return(package); } } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.Package, SimPe.ExtensionType.AllFiles } ); if (sfd.ShowDialog() != DialogResult.OK) { return(package); } //create a Cloned Object to get all needed Files for the Process WaitingScreen.Wait(); try { WaitingScreen.UpdateMessage("Collecting needed Files"); if ((package == null) && (pfd != null)) { package = RecolorClone(br, package, pfd, localgroup, settings, false); } } finally { WaitingScreen.Stop(); } package.FileName = sfd.FileName; package.Save(); return(package); }
public virtual Column Column([NotNull] IProperty property) { Check.NotNull(property, "property"); var extensions = ExtensionProvider.Extensions(property); return (new Column(NameBuilder.ColumnName(property), property.PropertyType) { DataType = extensions.ColumnType, IsNullable = property.IsNullable, DefaultValue = extensions.DefaultValue, DefaultSql = extensions.DefaultExpression, IsComputed = property.IsStoreComputed, IsTimestamp = property.IsConcurrencyToken && property.PropertyType == typeof(byte[]), MaxLength = property.MaxLength > 0 ? property.MaxLength : (int?)null }); }
public void Finish() { _audioFile !.Dispose(); _audioFile = null; _stream !.Position = 0; // Call the external MP4 encoder for writing iTunes-compatible atoms var metadataEncoderFactory = ExtensionProvider.GetFactories <IAudioMetadataEncoder>("Extension", FileExtension).FirstOrDefault(); if (metadataEncoderFactory == null) { return; } using (var export = metadataEncoderFactory.CreateExport()) export.Value.WriteMetadata(_stream, _metadata !, _settings !); }
protected virtual bool EquivalentColumns([NotNull] IProperty source, [NotNull] IProperty target) { Check.NotNull(source, "source"); Check.NotNull(target, "target"); var sourceExtensions = ExtensionProvider.Extensions(source); var targetExtensions = ExtensionProvider.Extensions(target); return (source.PropertyType == target.PropertyType && ColumnType(source) == ColumnType(target) && sourceExtensions.DefaultValue == targetExtensions.DefaultValue && sourceExtensions.DefaultExpression == targetExtensions.DefaultExpression && source.IsNullable == target.IsNullable && source.GenerateValueOnAdd == target.GenerateValueOnAdd && source.IsStoreComputed == target.IsStoreComputed && source.IsConcurrencyToken == target.IsConcurrencyToken && source.MaxLength == target.MaxLength); }
private static IServiceCollection AddExtensions(this IServiceCollection services, IOptionsProvider optionsProvider) { var configuration = optionsProvider.Get <NtradaOptions>(); var extensionProvider = new ExtensionProvider(configuration); services.AddSingleton <IExtensionProvider>(extensionProvider); foreach (var extension in extensionProvider.GetAll()) { if (extension.Options.Enabled == false) { continue; } extension.Extension.Add(services, optionsProvider); } return(services); }
public static async Task <bool> FindAsync(Asd_E_Type type, Guid id, string correlationId) { // информация для логирования var preLog = correlationId + " | " + ClassName + "." + type + "." + ExtensionProvider.GetCallerMethodName(); // логируем начало выполнения метода Logging.Trace(preLog + " START"); // выполнение метода try { // логируем запрос Logging.Request(preLog + "(Запрос метода. Исходные данные: Id = " + id + ")"); // создаем объект ответа bool response; // получаем данные из базы данных await using (var context = new LocalDatabaseContext()) { response = type switch { Asd_E_Type.Employee => await context.Employees.FindAsync(id) != null, Asd_E_Type.Department => await context.Departments.FindAsync(id) != null, _ => false }; } // логируем ответ Logging.Response(preLog + "(Ответ метода: " + response + ")"); // возвращаем ответ return(response); } catch (Exception ex) { // логируем исключение Logging.Exception(preLog + "(" + ex.Message + ")" + ex.StackTrace.ToTabString()); // возвращаем ответ return(false); } finally { // логируем окончание выполнения метода Logging.Trace(preLog + " END"); } }
public void Finish() { // ReSharper disable once PossibleNullReferenceException _audioFile.Dispose(); _audioFile = null; // ReSharper disable once PossibleNullReferenceException _stream.Position = 0; // Call the external MP4 encoder for writing iTunes-compatible atoms var metadataEncoderFactory = ExtensionProvider.GetFactories <IAudioMetadataEncoder>("Extension", FileExtension).FirstOrDefault(); if (metadataEncoderFactory == null) { return; } using (var export = metadataEncoderFactory.CreateExport()) // ReSharper disable twice AssignNullToNotNullAttribute export.Value.WriteMetadata(_stream, _metadata, _settings); }
public static async Task <bool> PutAsync <T>(Asd_E_Type type, Guid id, T request, string correlationId) { // информация для логирования var preLog = correlationId + " | " + ClassName + "." + type + "." + ExtensionProvider.GetCallerMethodName(); // логируем начало выполнения метода Logging.Trace(preLog + " START"); // выполнение метода try { // логируем запрос Logging.Request(preLog + "(Запрос метода. Исходные данные: Id = " + id + ")" + JsonConvert.SerializeObject(request, Formatting.Indented).ToTabString()); // создаем объект ответа bool response; // обновляем данные в базе данных await using (var context = new LocalDatabaseContext()) { context.Entry(request).State = EntityState.Modified; response = await context.SaveChangesAsync() > 0; } // логируем ответ Logging.Response(preLog + "(Ответ метода: " + response + ")"); // возвращаем ответ return(response); } catch (Exception ex) { // логируем исключение Logging.Exception(preLog + "(" + ex.Message + ")" + ex.StackTrace.ToTabString()); // возвращаем ответ return(false); } finally { // логируем окончание выполнения метода Logging.Trace(preLog + " END"); } }
public void GivenCustomExtensionShouldBeRegisteredAfterDefaultExtension() { var defaultPath = "default"; var customPath = "custom"; var options = new ExtensionOptions(); options.DefaultExtensions.Add(defaultPath); options.ExtensionPaths.Add(customPath); var loader = new Mock <IExtensionLoader>(); using (var defaultInstance = new ExtensionInstance(defaultPath, Mock.Of <IFileProvider>(), defaultPath, MockConfiguration(), NullLogger <ExtensionInstance> .Instance)) { using (var customInstance = new ExtensionInstance(customPath, Mock.Of <IFileProvider>(), customPath, MockConfiguration(), NullLogger <ExtensionInstance> .Instance)) { loader.Setup(l => l.LoadExtension(It.Is <string>(s => s.EndsWith(defaultPath)))).Returns(defaultInstance); loader.Setup(l => l.LoadExtension(It.Is <string>(s => s.EndsWith(customPath)))).Returns(customInstance); using (var subject = new ExtensionProvider(new[] { loader.Object }, MockConfigurationLoader(), new ExtensionInstanceFactory(NullLogger <ExtensionInstance> .Instance), Mock.Of <IExtensionLocator>(), Options.Create(options), NullLogger <ExtensionProvider> .Instance)) { Assert.Equal((subject as IExtensionProvider).Instances.First().Location, defaultPath); } } } }
/// <summary> /// Load a list of FIleDescriptors from the disc /// </summary> /// <param name="add">true if you want to add them lateron</param> /// <returns></returns> protected SimPe.Collections.PackedFileDescriptors LoadDescriptors(bool add) { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); if (!add) { ofd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.ExtractedFileDescriptor, SimPe.ExtensionType.AllFiles } ); } else { ofd.Filter = ExtensionProvider.BuildFilterString( new SimPe.ExtensionType[] { SimPe.ExtensionType.ExtractedFileDescriptor, SimPe.ExtensionType.ExtrackedPackageDescriptor, SimPe.ExtensionType.ExtractedFile, SimPe.ExtensionType.Package, SimPe.ExtensionType.DisabledPackage, SimPe.ExtensionType.AllFiles } ); } ofd.Title = SimPe.Localization.GetString(this.ToString()); ofd.Multiselect = add; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SimPe.Collections.PackedFileDescriptors pfds = LoadedPackage.LoadDescriptorsFromDisk(ofd.FileNames); return(pfds); } return(new SimPe.Collections.PackedFileDescriptors()); }
public void Submit(SampleCollection samples) { Contract.Ensures(_buffer != null); if (_buffer == null) { _buffer = new int[samples.SampleCount * samples.Channels]; } if (!samples.IsLast) { var index = 0; for (var sample = 0; sample < samples.SampleCount; sample++) { for (var channel = 0; channel < samples.Channels; channel++) { _buffer[index++] = (int)Math.Round(samples[channel][sample] * _multiplier); } } GCHandle handle = GCHandle.Alloc(_buffer, GCHandleType.Pinned); try { var bufferList = new AudioBufferList { NumberBuffers = 1, Buffers = new AudioBuffer[1] }; bufferList.Buffers[0].NumberChannels = (uint)samples.Channels; bufferList.Buffers[0].DataByteSize = (uint)(index * Marshal.SizeOf <int>()); bufferList.Buffers[0].Data = handle.AddrOfPinnedObject(); ExtendedAudioFileStatus status = _audioFile.Write(bufferList, (uint)samples.SampleCount); if (status != ExtendedAudioFileStatus.Ok) { throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.SampleEncoderWriteError, status)); } } finally { handle.Free(); } } else { _audioFile.Dispose(); // Call an external MP4 encoder for writing iTunes-compatible atoms: _stream.Position = 0; ExportFactory <IMetadataEncoder> metadataEncoderFactory = ExtensionProvider.GetFactories <IMetadataEncoder>("Extension", EncoderInfo.FileExtension) .SingleOrDefault(); if (metadataEncoderFactory == null) { throw new ExtensionInitializationException(string.Format(CultureInfo.CurrentCulture, Resources.SampleEncoderMetadataEncoderError, EncoderInfo.FileExtension)); } using (ExportLifetimeContext <IMetadataEncoder> metadataEncoderLifetime = metadataEncoderFactory.CreateExport()) metadataEncoderLifetime.Value.WriteMetadata(_stream, _metadata, _settings); } }
/// <inheritdoc /> public void Load(string fileName) { _networkstream = ExtensionProvider.IsNetworkStream(fileName); Log.Info("Loading file: {0}", fileName); if (_decodeChannel != 0 || _mixerChannel != 0) { Stop(); } try { Bass.StreamFree(_decodeChannel); } catch (Exception ex) { Debug.WriteLine(ex); } if (string.IsNullOrEmpty(fileName)) { Log.Error("Filename was null or empty. Aborted load"); return; } var sourceflags = BassFlags.Decode | BassFlags.Loop | BassFlags.Float | BassFlags.Prescan; var mixerflags = BassFlags.MixerDownMix | BassFlags.MixerPositionEx | BassFlags.AutoFree; if (_networkstream) { int r; lock (Lock) { // make sure only 1 thread at a time can do the following // increment the request counter for this request r = ++_req; } var netFlags = BassFlags.StreamDownloadBlocks | sourceflags; Bass.NetProxy = ""; //os default proxy _decodeChannel = Bass.CreateStream(fileName, 0, netFlags, _streamDloadProc, new IntPtr(r)); lock (Lock) { if (r != _req) { if (_decodeChannel != 0) { Bass.StreamFree(_decodeChannel); } return; } } _netadress = fileName; } else { if (ExtensionProvider.IsCdStream(fileName)) { var cd = new CDTrackInfo(fileName); _decodeChannel = BassCd.CreateStream(cd.Drive, cd.Track, sourceflags); Log.Info("Geting track metadata..."); UpdateCDTags(cd.Drive, cd.Track); } else { _decodeChannel = Bass.CreateStream(fileName, 0, 0, sourceflags); Log.Info("Geting track metadata..."); UpdateFileTags(fileName); } } if (_decodeChannel == 0) { Log.Error("Decode chanel creation failed: {0}", Bass.LastError); return; } var channelInfo = Bass.ChannelGetInfo(_decodeChannel); _mixerChannel = BassMix.CreateMixerStream(channelInfo.Frequency, channelInfo.Channels, mixerflags); if (_mixerChannel == 0) { Log.Error("Mixer chanel creation failed: {0}", Bass.LastError); return; } if (!BassMix.MixerAddChannel(_mixerChannel, _decodeChannel, BassFlags.MixerDownMix)) { Log.Error("Failed to route decoded stream to mixer: {0}", Bass.LastError); return; } if (!_networkstream) { Log.Info("Getting track length..."); var len = Bass.ChannelGetLength(_decodeChannel, PositionFlags.Bytes); _length = Bass.ChannelBytes2Seconds(_decodeChannel, len); NotifyChanged(nameof(Length)); Log.Info("Getting Chapters..."); Chapters.Clear(); Chapters.AddRange(ChapterFactory.GetChapters(fileName, _length)); } Volume = _LastVolume; Bass.ChannelSetAttribute(_mixerChannel, ChannelAttribute.Volume, Volume); Log.Info("Loaded file {0}", fileName); }
public static async Task <object> GetAsync(Asd_E_Type type, string correlationId) { // информация для логирования var preLog = correlationId + " | " + ClassName + "." + type + "." + ExtensionProvider.GetCallerMethodName(); // логируем начало выполнения метода Logging.Trace(preLog + " START"); // выполнение метода try { // логируем запрос Logging.Request(preLog + "(Запрос метода.)"); // создаем объект ответа IEnumerable <object> response; // получаем данные из базы данных await using (var context = new LocalDatabaseContext()) { response = type switch { Asd_E_Type.Employee => await context.Employees .Select(i => new { i.Id, i.Name, Department = new { i.Department.Id, i.Department.Name } }).ToListAsync(), Asd_E_Type.Department => await context.Departments .Include(i => i.Employees) .Select(i => new { i.Id, i.Name, i.Employees.Count, Avg = i.Employees.Sum(j => j.Salary) / i.Employees.Count, Employees = i.Employees .Select(j => new { j.Id, j.Name, j.Salary }) }).ToListAsync(), _ => null }; } // логируем ответ Logging.Response(preLog + "(Ответ метода.)" + JsonConvert.SerializeObject(response, Formatting.Indented).ToTabString()); // возвращаем ответ return(response); } catch (Exception ex) { // логируем исключение Logging.Exception(preLog + "(" + ex.Message + ")" + ex.StackTrace.ToTabString()); // возвращаем ответ return(null); } finally { // логируем окончание выполнения метода Logging.Trace(preLog + " END"); } }