Пример #1
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Remove.S7.S7Tag> ExecuteAsync(S7Tag request, CancellationToken cancellationToken = default)
        {
            var s7Tag = await _tagRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false); //.GetAllS7Tag().SingleOrDefault(g => g.Id == request.Id);

            _tagRepository.Delete(s7Tag);
            return(new KSociety.Com.App.Dto.Res.Remove.S7.S7Tag(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) > 0));
        }
Пример #2
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Copy.Common.TagGroup> ExecuteAsync(TagGroup request, CancellationToken cancellationToken = default)
        {
            var commonTagGroup = _mapper.Map <Domain.Entity.Common.TagGroup>(request);
            await _tagGroupRepository.AddAsync(commonTagGroup, cancellationToken).ConfigureAwait(false);

            return(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) == -1 ? new KSociety.Com.App.Dto.Res.Copy.Common.TagGroup(Guid.Empty) : new KSociety.Com.App.Dto.Res.Copy.Common.TagGroup(commonTagGroup.Id));
        }
Пример #3
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Add.S7.S7Tag> ExecuteAsync(S7Tag request, CancellationToken cancellationToken = default)
        {
            var s7Tag = _mapper.Map <Domain.Entity.S7.S7Tag>(request);
            await _tagRepository.AddAsync(s7Tag, cancellationToken).ConfigureAwait(false);

            return(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) == -1 ? new KSociety.Com.App.Dto.Res.Add.S7.S7Tag(Guid.Empty) : new KSociety.Com.App.Dto.Res.Add.S7.S7Tag(s7Tag.Id));
        }
Пример #4
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Copy.Common.Connection> ExecuteAsync(Connection request, CancellationToken cancellationToken = default)
        {
            var commonConnection = _mapper.Map <Domain.Entity.Common.Connection>(request);
            await _connectionRepository.AddAsync(commonConnection, cancellationToken).ConfigureAwait(false);

            return(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) == -1 ? new KSociety.Com.App.Dto.Res.Copy.Common.Connection(Guid.Empty) : new KSociety.Com.App.Dto.Res.Copy.Common.Connection(commonConnection.Id));
        }
Пример #5
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Update.Logix.LogixTag> ExecuteAsync(LogixTag request, CancellationToken cancellationToken = default)
        {
            var logixTag = _mapper.Map <Domain.Entity.Logix.LogixTag>(request);

            _tagRepository.Update(logixTag);
            return(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) == -1 ? new KSociety.Com.App.Dto.Res.Update.Logix.LogixTag(Guid.Empty) : new KSociety.Com.App.Dto.Res.Update.Logix.LogixTag(logixTag.Id));
        }
Пример #6
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Remove.Common.Connection> ExecuteAsync(Connection request, CancellationToken cancellationToken = default)
        {
            var commonConnection = await _connectionRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false); //.GetAllConnection().SingleOrDefault(g => g.Id == request.Id);

            _connectionRepository.Delete(commonConnection);

            return(new KSociety.Com.App.Dto.Res.Remove.Common.Connection(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) > 0));
        }
Пример #7
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Import.S7.S7Tag> ExecuteAsync(S7Tag request, CancellationToken cancellationToken = default)
        {
            var result = await _tagRepository.ImportCsvAsync(request.ByteArray, cancellationToken).ConfigureAwait(false);

            var output = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            return(output == -1 ? new KSociety.Com.App.Dto.Res.Import.S7.S7Tag(result) : new KSociety.Com.App.Dto.Res.Import.S7.S7Tag(false));
        }
Пример #8
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Remove.Common.TagGroup> ExecuteAsync(TagGroup request, CancellationToken cancellationToken = default)
        {
            var commonTagGroup = await _tagGroupRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false); //.GetAllTagGroup().SingleOrDefault(tag => tag.Id == request.Id);

            _tagGroupRepository.Delete(commonTagGroup);

            return(new KSociety.Com.App.Dto.Res.Remove.Common.TagGroup(await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false) > 0));
        }
        public async ValueTask <KSociety.Com.App.Dto.Res.Update.S7.S7Connection> ExecuteAsync(S7Connection request, CancellationToken cancellationToken = default)
        {
            var s7Connection = _mapper.Map <Domain.Entity.S7.S7Connection>(request);

            _connectionRepository.Update(s7Connection);
            var result = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            return(result == -1 ? new KSociety.Com.App.Dto.Res.Update.S7.S7Connection(Guid.Empty) : new KSociety.Com.App.Dto.Res.Update.S7.S7Connection(s7Connection.Id));
        }
Пример #10
0
        public async ValueTask <KSociety.Com.App.Dto.Res.ModifyField.Logix.LogixTag> ExecuteAsync(LogixTag request, CancellationToken cancellationToken = default)
        {
            var logixTag = await _tagRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false);  //.GetAllLogixTag().SingleOrDefault(g => g.Id == request.Id);

            logixTag?.ModifyField(request.FieldName, request.Value);
            var result = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            return(new KSociety.Com.App.Dto.Res.ModifyField.Logix.LogixTag(result > 0));
        }
Пример #11
0
        public async ValueTask <KSociety.Com.App.Dto.Res.ModifyField.Common.Connection> ExecuteAsync(Connection request, CancellationToken cancellationToken = default)
        {
            var commonConnection = await _connectionRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false); //.GetAllConnection().SingleOrDefault(g => g.Id == request.Id);

            commonConnection?.ModifyField(request.FieldName, request.Value);
            var result = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            return(new KSociety.Com.App.Dto.Res.ModifyField.Common.Connection(result > 0));
        }
Пример #12
0
        public async ValueTask <KSociety.Com.App.Dto.Res.ModifyField.Common.TagGroup> ExecuteAsync(TagGroup request, CancellationToken cancellationToken = default)
        {
            var commonTagGroup = await _tagGroupRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false); //.GetAllTagGroup().SingleOrDefault(tagGroup => tagGroup.Id == request.Id);

            commonTagGroup?.ModifyField(request.FieldName, request.Value);

            var result = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            return(new KSociety.Com.App.Dto.Res.ModifyField.Common.TagGroup(result > 0));
        }
Пример #13
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Add.S7.S7Connection> ExecuteAsync(S7Connection request, CancellationToken cancellationToken = default)
        {
            var s7Connection = _mapper.Map <Domain.Entity.S7.S7Connection>(request);
            var addResult    = await _connectionRepository.AddAsync(s7Connection, cancellationToken).ConfigureAwait(false);

            //_logger.LogTrace("S7ConnectionReqHdlr: " + GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + " Result: " + addResult.Entity.Id + " " + s7Connection.Id);
            var result = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            _logger.LogTrace("S7ConnectionReqHdlr: " + GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod()?.Name + " Result: " + result + " " + s7Connection.Id);
            return(result == -1 ? new KSociety.Com.App.Dto.Res.Add.S7.S7Connection(Guid.Empty) : new KSociety.Com.App.Dto.Res.Add.S7.S7Connection(s7Connection.Id));
        }
Пример #14
0
        public async ValueTask <KSociety.Com.App.Dto.Res.Import.S7.S7Connection> ExecuteAsync(S7Connection request, CancellationToken cancellationToken = default)
        {
            try
            {
                var result = await _connectionRepository.ImportCsvAsync(request.ByteArray, cancellationToken).ConfigureAwait(false);

                var output = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

                return(output == -1 ? new KSociety.Com.App.Dto.Res.Import.S7.S7Connection(result) : new KSociety.Com.App.Dto.Res.Import.S7.S7Connection(false));
            }
            catch (Exception ex)
            {
                _logger.LogError(GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod()?.Name + ": " + ex.Message + " - " + ex.StackTrace);
            }

            return(new KSociety.Com.App.Dto.Res.Import.S7.S7Connection(false));
        }
Пример #15
0
        public async ValueTask <KSociety.Com.App.Dto.Res.ModifyField.S7.S7Connection> ExecuteAsync(S7Connection request, CancellationToken cancellationToken = default)
        {
            var s7Connection = await _connectionRepository.FindAsync(cancellationToken, request.Id).ConfigureAwait(false); //.GetAllS7Connection().SingleOrDefault(g => g.Id == request.Id);

            try
            {
                s7Connection?.ModifyField(request.FieldName, request.Value);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message + " - " + ex.StackTrace);
            }

            var result = await _unitOfWork.CommitAsync(cancellationToken).ConfigureAwait(false);

            return(new KSociety.Com.App.Dto.Res.ModifyField.S7.S7Connection(result > 0));
        }