public static IStream StreamFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId) { var commandInput = CommandInputFromStreamIdentifier(command, streamId); if (commandInput != null) { return(commandInput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map)); } var commandOutput = CommandOutputFromStreamIdentifier(command, streamId); if (commandOutput != null) { return(commandOutput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map)); } var filterchain = FilterchainFromStreamIdentifier(command, streamId); if (filterchain != null) { var filterchainOutput = filterchain.OutputList.First(si => si.Stream.Map == streamId.Map); return(filterchainOutput.Stream); } throw new StreamNotFoundException(); }
public static CommandStage Select(this CommandStage stage, StreamIdentifier streamId) { var streamIdList = new List <StreamIdentifier> { streamId }; return(stage.Select(streamIdList)); }
public IEnumerable <IEvent> GetByStreamId(StreamIdentifier streamId) { if (this.eventStreams.ContainsKey(streamId.Value)) { return(this.eventStreams[streamId.Value].ToEvents()); } throw new Exception("Stream not found"); }
public T GetById <T>(Guid id) where T : EventStream { var streamId = new StreamIdentifier(typeof(T).Name, id); var history = this.eventStore.GetByStreamId(streamId); T streamItem = processor.RebuildAggregate <T>(history); return(streamItem); }
public IEnumerable <IEvent> GetByStreamId(StreamIdentifier streamId) { if (store.ContainsKey(streamId.Value)) { return(store[streamId.Value].AsReadOnly()); } throw new EventStreamNotFoundException(streamId); }
public static CommandStage Select(this FFmpegCommand command, StreamIdentifier streamId) { var streamIdList = new List <StreamIdentifier>() { streamId }; return(command.Select(streamIdList)); }
public Task <IEnumerable <Event> > GetByStreamIdAsync(StreamIdentifier streamId) { if (_store.TryGetValue(streamId.Value, out var value)) { return(Task.FromResult(value)); } throw new EventStreamNotFoundException(streamId); }
public T GetById <T>(Guid id) where T : EventStream, new() { var eventStream = new T(); var streamId = new StreamIdentifier(eventStream.Name, id); var events = _eventStore.GetByStreamId(streamId); eventStream.Load(events); return(eventStream); }
public T GetById <T>(Guid id) where T : EventStream, new() { var streamItem = new T(); var streamId = new StreamIdentifier(streamItem.Name, id); var history = this.eventStore.GetByStreamId(streamId); streamItem.LoadFromHistory(history); return(streamItem); }
public async Task <T> GetById <T>(Guid id) where T : AggregateRoot, new() { var streamItem = new T(); var streamId = new StreamIdentifier(streamItem.GetType().Name, id); var history = await _eventStore.GetByStreamId(streamId); streamItem.LoadFromHistory(history); return(streamItem); }
public static int IndexOfFilterchain(FFmpegCommand command, StreamIdentifier streamId) { var matchingFilterchain = FilterchainFromStreamIdentifier(command, streamId); if (matchingFilterchain == null) { return(-1); } return(command.Filtergraph.IndexOf(matchingFilterchain)); }
public static int IndexOfResource(FFmpegCommand command, StreamIdentifier streamId) { var matchingResource = CommandInputFromStreamIdentifier(command, streamId); if (matchingResource == null) { return(-1); } return(command.Inputs.IndexOf(matchingResource)); }
public static int IndexOfOutput(FFmpegCommand command, StreamIdentifier streamId) { var matchingOutput = CommandOutputFromStreamIdentifier(command, streamId); if (matchingOutput == null) { return(-1); } return(command.Outputs.IndexOf(matchingOutput)); }
public async Task <T> GetByIdAsync <T>(Guid id) where T : EventStream, new() { var streamItem = new T(); var streamId = new StreamIdentifier(streamItem.Name, id); var history = await _eventStore.GetByStreamIdAsync(streamId); streamItem.LoadFromHistory(history); return(streamItem); }
static void UploadFileToDataBase() { //your default folder to save files StreamIdentifier.DefaultFolderPath = "J:\\Test\\"; //test file path to save in database string filePath = "D:\\SignalGo-Sample.rar"; //file id from your sql etc id int fileId = 456; //your file password to access get stream string password = "******"; using (StreamIdentifier streamIdentifier = new StreamIdentifier()) { var info = new System.IO.FileInfo(filePath); var checkSum = FileChecksumMaker.GetFileCheckSum(filePath); //save your information of file FileInfo fileInfo = new FileInfo() { Id = fileId, CreatedDateTime = DateTime.Now, FileChecksumInfo = checkSum, FileName = Path.GetFileName(filePath), DataType = "application/x-rar-compressed", FileSize = info.Length, LastUpdateDateTime = DateTime.Now, Password = password }; //start upload your file or stream var result = streamIdentifier.StartUpload(fileInfo, filePath, 0, info.Length, (position) => { Console.WriteLine($"Position Wrote : {position} From Length: {info.Length}"); }); Console.WriteLine("Upload Result: " + result); } var fileToDownload = StreamIdentifier.GetFileInfo(fileId, password); if (fileToDownload != null) { //get stream to read var stream = StreamIdentifier.GetFileStream(fileId, 0); Console.WriteLine("get file to download success!"); } else { Console.WriteLine("file not found or password is wrong!"); } }
protected void Given <TEventStream, TEvent>(Guid id, TEvent evt) where TEvent : IEvent where TEventStream : EventStream { var streamIdentifier = new StreamIdentifier(typeof(TEventStream).Name, id); var eventStoreStream = new EventStoreStream(streamIdentifier, new List <IEvent> { evt }); this.eventStore.Save(new List <EventStoreStream> { eventStoreStream }); this.eventStore.CommitInitialEvents(); }
public byte[] Serialize() { List <byte> ser = new List <byte>(); //Put in guid ser.AddRange(StreamIdentifier.ToByteArray()); //Put in Stream Package count ser.AddRange(BitConverter.GetBytes(StreamPackageCount)); //Put in my package number ser.AddRange(BitConverter.GetBytes(PackageNumber)); //Put in the content ser.AddRange(Content); return(ser.ToArray()); }
public async Task <IEnumerable <IEvent> > GetByStreamId(StreamIdentifier streamId) { if (streamId == null || string.IsNullOrWhiteSpace(streamId.Value)) { throw new InvalidOperationException("stream Id is required"); } var result = await _connection.ReadStreamEventsForwardAsync(streamId.Value, StreamPosition.Start, 1000, false); if (result != null && result.Status == SliceReadStatus.Success) { List <IEvent> res = GetEvents(result); return(res); } else { throw new InvalidOperationException(string.Format("There no events with Stream identifer : {0}", streamId.Value)); } }
private void Fill(FFmpegCommand command, CommandOutput commandOutput) { //find the command output map setting, if the command output has map settings //then they make up its dependecy tree. var allSettingMaps = commandOutput.Settings.OfType <Map>(); if (allSettingMaps.Any()) { var streamIdListFromMaps = allSettingMaps.Select(map => StreamIdentifier.Create(command.Owner.Id, command.Id, map.Stream)).ToList(); Fill(command, streamIdListFromMaps); return; } //if the command output does not contain map settings then the dependency tree //is made up of all the input streams. command.Objects.Inputs.ForEach(commandResource => DependecyTree.Add(MetadataInfoTreeSource.Create(commandResource))); }
public static Options Create(StreamIdentifier streamIdentifier, StreamRevision expectedStreamRevision, TimeSpan?timeoutAfter) => new()
public static CommandOutput CommandOutputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId) { if (streamId == null) { throw new ArgumentNullException("streamId"); } return(command.Objects.Outputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map))); }
public bool Equals(StreamIdentifier streamId) { return Map == streamId.Map && CommandId == streamId.CommandId && FactoryId == streamId.FactoryId; }
public IEnumerable <IEvent> GetByStreamId(StreamIdentifier streamId, params Type[] types) { // TODO fix throw new NotImplementedException(); }
public StreamIdentifier GetStreamIdentifier() { return(StreamIdentifier.Create(Owner.Owner.Owner.Id, Owner.Id, Stream.Map)); }
public static bool ReceiptBelongsToCommand(FFmpegCommand command, StreamIdentifier streamId) { return(command.Owner.Id == streamId.FactoryId && command.Id == streamId.CommandId); }
public static Filterchain FilterchainFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId) { if (streamId == null) { throw new ArgumentNullException("streamId"); } return(command.Objects.Filtergraph.FilterchainList.FirstOrDefault(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId)))); }
public static MetadataInfoTreeContainer GetMetadataInfo(FFmpegCommand command, StreamIdentifier streamId) { //first validate that the streamId does in fact belong to the command. if (!CommandHelper.ReceiptBelongsToCommand(command, streamId)) { throw new ArgumentException("The provided streamId is not part of the provided ffmpeg command.", "streamId"); } var resourceIndex = CommandHelper.IndexOfResource(command, streamId); if (resourceIndex > -1) { return(ResourceMetadataInfo(command, resourceIndex)); } var filterchainIndex = CommandHelper.IndexOfFilterchain(command, streamId); if (filterchainIndex > -1) { return(FilterchainMetadataInfo(command, filterchainIndex)); } var outputIndex = CommandHelper.IndexOfOutput(command, streamId); if (outputIndex > -1) { return(OutputMetadataInfo(command, outputIndex)); } return(null); }
public void SetVersionIdentifierMethod(StreamIdentifier Identifier) { this.Identifier = Identifier; }
public EventStreamNotFoundException(StreamIdentifier identifier) : base(string.Format("Stream Not Found Id: {0}", identifier.Value)) { }
public EventStoreStream(StreamIdentifier identifier, IEnumerable <IEvent> events) { this.Id = identifier.Value; this.Events = events.ToList(); }
public bool Equals(StreamIdentifier streamId) { return(Map == streamId.Map && CommandId == streamId.CommandId && FactoryId == streamId.FactoryId); }