public ReportDto[] GetReports(string groupIdStr) { IUniqueIdentifier groupUid = groupIdStr.AsUniqueIdentifierGuid(); if (groupUid == null) { throw new ApiException( "Invalid unique identifier."); } return(_reportManager.GetReports(groupUid.AsGuid().Value) .Select(view => new ReportDto { UID = view.UID.ToString(), Name = view.Name, CallFromMenu = view.CallFromMenu, CallFromObject = view.CallFromObject, Group = new ReportGroupDto() { UID = view.GroupUid.ToString(), GroupName = view.DisplayGroup }, PreviewOnGeneration = view.PreviewOnGeneration, IconId = view.Icon == null ? null : (int?)view.Icon.Id }).ToArray()); }
public KafkaMessageProducer(KafkaServerConfiguration configuration, IUniqueIdentifier uniqueIdentifier) { this.configuration = configuration; this.uniqueIdentifier = uniqueIdentifier; producer = new ProducerBuilder <Null, IdentifiedMessage>(new ProducerConfig { BootstrapServers = configuration.ServerUrl }).SetValueSerializer(new CustomJsonSerializer <IdentifiedMessage>()).Build(); }
public bool Equals(IUniqueIdentifier identifier) { if (identifier is HashWrapper wrapper) { return(wrapper.Hash == this.Hash && wrapper.Instance == this.Instance); } return(false); }
public async Task Write(string key, IUniqueIdentifier obj) { var appFolder = await ApplicationFolder(); var storageFile = await appFolder.CreateFileAsync(key, CreationCollisionOption.OpenIfExists); var serialized = await Task.Run(() => JsonConvert.SerializeObject(obj, Converter)); await storageFile.WriteAllTextAsync(serialized); }
private static T Emit(T d, IDataContext context, IUniqueIdentifier <ObjectId> forObject) { if (d is IHasContext) { (d as IHasContext).Context = context; } if (d is IEmit) { (d as IEmit).Emit(context, forObject); } return(d); }
public KafkaMessageConsumer(KafkaServerConfiguration configuration, IUniqueIdentifier uniqueIdentifier) { this.configuration = configuration; this.uniqueIdentifier = uniqueIdentifier; consumer = new ConsumerBuilder <Ignore, IdentifiedMessage>(new ConsumerConfig { BootstrapServers = configuration.ServerUrl, GroupId = $"group-{Guid.NewGuid()}", AutoOffsetReset = AutoOffsetReset.Earliest, }).SetValueDeserializer(new CustomJsonDeserializer <IdentifiedMessage>()).Build(); consumer.Subscribe(configuration.TopicName); }
public static void Add(this ICollection <ObjectId> list, IUniqueIdentifier <ObjectId> document, bool ignoreNull = true) { if (document == null) { if (ignoreNull) { return; } else { throw new ArgumentException("Cannot add the ID of a null object to the list."); } } list.Add(document.Id); }
public ComparisonResults Compare(IUniquelyIdentifiable identifiable) { bool selfNull = this.Self == null; bool otherNull = identifiable == null; if (selfNull && otherNull) { return(ComparisonResults.Invalidating); } else if (selfNull ^ otherNull) { return(ComparisonResults.Invalidating); } else { IUniqueIdentifier otherIdentifier = identifiable.GetIdentifier(); HashWrapper selfIdentifier = this.hashWrapper.Value; if (otherIdentifier is HashWrapper wrapper) { bool hashMatch = wrapper.Hash == selfIdentifier.Hash; bool instanceMatch = wrapper.Instance == selfIdentifier.Instance; if (hashMatch && instanceMatch) { return(ComparisonResults.Match); } else if (hashMatch) { return(ComparisonResults.DifferentButEquivalent); } else if (instanceMatch) { return(ComparisonResults.Different | ComparisonResults.Invalidating); } else { return(ComparisonResults.Different); } } else { // Since the other instance wasn't a wrapper, it's (probably) not a match. Also, since we have no // idea what the type we contain is, assume we need to invalidate the cache. return(ComparisonResults.Different | ComparisonResults.Invalidating); } } }
public T GetOrCreate(IDataContext context, IUniqueIdentifier <ObjectId> forObject = null) { var id = forObject?.Id ?? "prime:associated-single-doc".GetObjectIdHashCode(); return(_cache.GetOrAdd(id, (k) => { var d = context.As <T>().FirstOrDefault(x => x.Id == k); if (d != null) { return Emit(d, context, forObject); } d = new T { Id = k }; (d as IOnNewInstance)?.AfterCreation(context, forObject); Emit(d, context, forObject); d.Save(context); return d; })); }
public string GetAccessId(string reportId) { IUniqueIdentifier reportUid = reportId.AsUniqueIdentifierGuid(); if (reportUid == null) { throw new ApiException( "Invalid unique identifier."); } ExpressReport.ExpressReport expressReport = null; try { expressReport = _reportManager.GetExpressReport(reportUid); } catch (ArgumentNullException) { throw new ApiException( "Report not found", HttpStatusCode.NotFound); } return(_fileAccessService.GetAccessId(reportId)); }
public IUserLed GetUserLed(IUniqueIdentifier identifier) { return(_boards.Where(neuronBoard => neuronBoard != null).Select(neuronBoard => neuronBoard.GetUserLed(identifier)).FirstOrDefault(item => item != null)); }
public IDigitalInput GetDigitalInput(IUniqueIdentifier identifier) { IDigitalInput item; return(DigitalInputDictionary.TryGetValue(identifier, out item) ? item : null); }
public void AfterCreation(IDataContext context, IUniqueIdentifier <ObjectId> parentObject) { }
public void AfterCreation(IDataContext context, IUniqueIdentifier <ObjectId> parentObject) { Bookmarks.Defaults(); }
public IDigitalOutput GetRelayOutput(IUniqueIdentifier identifier) { IDigitalOutput item; return(RelayOutputsDictionary.TryGetValue(identifier, out item) ? item : null); }
public bool Equals(IUniqueIdentifier identifier) { return(identifier != null && identifier is UniquePath other && other.Inner.Equals(this)); }
public Registrar(IUniqueIdentifier <string, ICitizen> identitySearch, ISearchFactory factory) { _identitySearch = identitySearch; _factory = factory; _citizens = new List <ICitizen>(); }
public IUserLed GetUserLed(IUniqueIdentifier identifier) { IUserLed item; return(UserLedsDictionary.TryGetValue(identifier, out item) ? item : null); }
public void AfterCreation(IDataContext context, IUniqueIdentifier <ObjectId> provider) { KeepFresh(context, provider as IAssetPairsProvider, true); }
public IAnalogOutput GetAnalogOutput(IUniqueIdentifier identifier) { IAnalogOutput item; return(AnalogOutputsDictionary.TryGetValue(identifier, out item) ? item : null); }
public static async Task Write(IUniqueIdentifier obj) { // Write object to storage var accessor = new StorageAccess(); await accessor.Write(obj.Id, obj); }
public IAnalogOutput GetAnalogOutput(IUniqueIdentifier identifier) { return(_boards.Where(neuronBoard => neuronBoard != null).Select(neuronBoard => neuronBoard.GetAnalogOutput(identifier)).FirstOrDefault(item => item != null)); }
public IOneWireConnector GetOneWireConnector(IUniqueIdentifier identifier) { IOneWireConnector item; return(OneWireConnectorsDictionary.TryGetValue(identifier, out item) ? item : null); }
public IModbusConnector GetModbusConnector(IUniqueIdentifier identifier) { IModbusConnector item; return(ModbusConnectorsDictionary.TryGetValue(identifier, out item) ? item : null); }
public IModbusConnector GetModbusConnector(IUniqueIdentifier identifier) { return(_boards.Where(neuronBoard => neuronBoard != null).Select(neuronBoard => neuronBoard.GetModbusConnector(identifier)).FirstOrDefault(item => item != null)); }
private XtraReport GetXtraReport(string reportId, string parameters = null, string entityId = null, string accessId = null) { if (accessId != null) { string accessedReportId = _fileAccessService.GetAccessObject(reportId, accessId); if (accessedReportId.IsNullOrEmpty()) { throw new ApiException( "Report not found", HttpStatusCode.NotFound); } } // идентификатор отчета доступен -> ищем сам отчет IUniqueIdentifier reportUid = reportId.AsUniqueIdentifierGuid(); if (reportUid == null) { throw new ApiException( "Invalid unique identifier."); } var xtraReport = new XtraReport(); ExpressReport.ExpressReport expressReport = null; try { expressReport = _reportManager.GetExpressReport(reportUid); } catch (ArgumentNullException) { throw new ApiException( "Report not found", HttpStatusCode.NotFound); } IEntity entity = null; if (!entityId.IsNullOrEmpty()) { entity = _entityManager.GetEntity(entityId.AsUniqueIdentifierGuid()); } // Получаем параметры: var expressParameters = GetParameters(expressReport, parameters, entity); // Определяем имя документа var documentName = _reportManager.GetReportFileName(expressReport); // Получаем имя файла по умолчанию, удалив недопустимые символы: var invalidFileNameChars = new HashSet <char>(Path.GetInvalidFileNameChars()); var defaultFileName = new string(documentName.Where(c => !invalidFileNameChars.Contains(c)).ToArray()); try { xtraReport = _dxReportCreator.CreateReport(expressReport, expressParameters, false); xtraReport.PrintingSystem.ExportOptions.PrintPreview.DefaultFileName = defaultFileName; return(xtraReport); } catch (OutOfMemoryException) { } return(xtraReport); }