public Course(string title, StreamValue stream, TypeValue type, DateTime startDate, DateTime endDate) { if (String.IsNullOrWhiteSpace(title)) { throw new ArgumentNullException("title", "Course's title cannot be null or empty!"); } Title = title; Stream = stream; Type = type; StartDate = startDate; EndDate = endDate; }
public static void CreateCell(this StreamValueDTO svd, ref StreamValue sv) { if (svd.CellValue.HasValue) { sv = new StreamValue(CellValue: svd.CellValue); } if (svd.DigitalValue.HasValue) { sv = new StreamValue(DigitalValue: svd.DigitalValue); } if (svd.NumericValue.HasValue) { sv = new StreamValue(NumericValue: svd.NumericValue); } if (svd.StringValue != null) { sv = new StreamValue(StringValue: svd.StringValue); } }
public static void CreateCell(this StreamValueDTO_Accessor svda, ref StreamValue sv) { if (svda.Contains_CellValue) { sv = new StreamValue(CellValue: svda.CellValue); } if (svda.Contains_DigitalValue) { sv = new StreamValue(DigitalValue: svda.DigitalValue); } if (svda.Contains_NumericValue) { sv = new StreamValue(NumericValue: svda.NumericValue); } if (svda.Contains_StringValue) { sv = new StreamValue(StringValue: svda.StringValue); } }
public override void InsertStreamValueHandler(StreamValueCollectionDTOReader request) { long streamCellId = request.StreamCellId; long streamSnapshotCellId; StreamType streamType; int indexHeight; //Stream using (var streamCell = Storage.UseTempanyStream(streamCellId, CellAccessOptions.ThrowExceptionOnCellNotFound)) { indexHeight = streamCell.IndexHeight; streamType = (StreamType)streamCell.ValueType; streamSnapshotCellId = streamCell.Snapshot; } //New values List <StreamValue> newValueCells = new List <StreamValue>(request.Values.Count); foreach (var valuesDto in request.Values) { StreamValue valueCell = new StreamValue(); //ugly struct hack, unnecessary construction valuesDto.CreateCell(ref valueCell); Storage.SaveStreamValue(valueCell); newValueCells.Add(valueCell); } List <long> newValueCellsIds = newValueCells.Select(sv => sv.CellID).ToList(); //New values collection StreamValueCollection newValues = new StreamValueCollection(newValueCellsIds); Storage.SaveStreamValueCollection(newValues); int newLevel = GetRandomLevel(indexHeight); //Existing snapshot List <long> existingPreviousPointers; long existingTimestamp; long existingValues; using (var streamSnapshotCell = Storage.UseTimestamp(streamSnapshotCellId, CellAccessOptions.ThrowExceptionOnCellNotFound)) { existingTimestamp = streamSnapshotCell.Ticks; existingValues = streamSnapshotCell.Values; existingPreviousPointers = streamSnapshotCell.Previous; } //For now, only support monotonic increasing timestamps if (request.Timestamp <= existingTimestamp) { throw new NotSupportedException("Specified timestamp is earlier than snapshot time. Stream timestamp must be monotonically increasing (CTP limitation)."); } //New timestamp to hold existing snapshot List <long> trimmedExistingPreviousPointers = existingPreviousPointers.Take(newLevel).ToList(); Timestamp shiftedExistingSnapshot = new Timestamp(existingTimestamp, existingValues, trimmedExistingPreviousPointers); Storage.SaveTimestamp(shiftedExistingSnapshot); //Update existing snapshot List <long> newPreviousPointers = Enumerable.Range(0, newLevel).Select(i => shiftedExistingSnapshot.CellID).Concat(existingPreviousPointers.Skip(newLevel)).ToList(); using (var streamSnapshotCell = Storage.UseTimestamp(streamSnapshotCellId, CellAccessOptions.ThrowExceptionOnCellNotFound)) { streamSnapshotCell.Ticks = request.Timestamp; streamSnapshotCell.Values = newValues.CellID; streamSnapshotCell.Previous = newPreviousPointers; } //update index height if increased if (newLevel > indexHeight) { using (var streamCell = Storage.UseTempanyStream(streamCellId, CellAccessOptions.ThrowExceptionOnCellNotFound)) { streamCell.IndexHeight = newLevel; } } }