Beispiel #1
0
        public List <OutputEntity> Calculate(List <InputEntity> inputList)
        {
            List <OutputEntity> list = new List <OutputEntity>();

            foreach (var ip in inputList)
            {
                OutputEntity op = new OutputEntity(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), ip.Date, ip.TimeParams, ip.Operation, null);
                switch (ip.Operation)
                {
                case DateOperation.ADD:
                    op.Result = AddToDate(ip);
                    break;

                case DateOperation.SUBTRACT:
                    op.Result = SubtractFromDate(ip);
                    break;

                case DateOperation.DAY_OF_WEEK:
                    op.Result = DayOfTheWeek(ip);
                    break;

                case DateOperation.WEEK_OF_YEAR:
                    op.Result = WeekOfTheYear(ip);
                    break;

                default:
                    op.Result = "Error : No/Invalid operation specified.";
                    break;
                }
                list.Add(op);
            }

            return(list);
        }
Beispiel #2
0
 public OutputEntityEditorWindow(IntentEditorWindow parent)
 {
     InitializeComponent();
     ParentWindow = parent;
     Data         = new OutputEntity();
     Data.GUID    = EditorUtils.ByteArrayToHexString(EditorUtils.GenerateNextGUID());
 }
        public virtual Task <bool> UpsertOutputsAsync(
            IEnumerable <ITxOutput> outputs,
            string currency,
            string address)
        {
            lock (_sync)
            {
                foreach (var output in outputs)
                {
                    var id     = $"{output.TxId}:{output.Index}";
                    var entity = new OutputEntity
                    {
                        Output   = output, // todo: copy?
                        Currency = currency,
                        Address  = address
                    };

                    _outputs[id] = entity;

                    var data = Convert.ToBase64String(BsonSerializer.Serialize(_bsonMapper.ToDocument(output)));
                    SaveDataCallback?.Invoke(AvailableDataType.Output, $"{id}/{currency}/{address}", data);
                }

                return(Task.FromResult(true));
            }
        }
Beispiel #4
0
        public OutputEntity Update(EmployeeEntity EmployeeEntity, Guid OutputId, OutputEntity OutputEntity)
        {
            OutputEntity.Id = OutputId;
            Output Output = new Output(OutputEntity);

            UnitOfWork.OutputRepository.AddOrUpdate(Output);
            UnitOfWork.Complete();
            return(Get(EmployeeEntity, Output.Id));
        }
Beispiel #5
0
        public OutputEntity Create(EmployeeEntity EmployeeEntity, OutputEntity OutputEntity)
        {
            if (OutputEntity == null)
            {
                throw new NotFoundException();
            }
            Output Output = new Output(OutputEntity);

            UnitOfWork.OutputRepository.AddOrUpdate(Output);
            UnitOfWork.Complete();
            return(Get(EmployeeEntity, Output.Id));
        }
        public virtual Task <bool> UpsertOutputsAsync(
            IEnumerable <ITxOutput> outputs,
            string currency,
            string address)
        {
            lock (_sync)
            {
                foreach (var output in outputs)
                {
                    var id = $"{output.TxId}:{output.Index}";

                    _outputs[id] = new OutputEntity
                    {
                        Output   = output, // todo: copy?
                        Currency = currency,
                        Address  = address
                    };
                }

                return(Task.FromResult(true));
            }
        }
Beispiel #7
0
 public OutputEntity Update(Guid OutputId, [FromBody] OutputEntity OutputEntity)
 {
     return(OutputService.Update(EmployeeEntity, OutputId, OutputEntity));
 }
Beispiel #8
0
 public OutputEntity Create([FromBody] OutputEntity OutputEntity)
 {
     return(OutputService.Create(EmployeeEntity, OutputEntity));
 }
Beispiel #9
0
 public Output(OutputEntity OutputEntity) : base(OutputEntity)
 {
 }
Beispiel #10
0
 public OutputEntityEditorWindow(IntentEditorWindow parent, OutputEntity existingData)
 {
     InitializeComponent();
     ParentWindow = parent;
     Data         = existingData;
 }
 public void AddRecord(OutputEntity record)
 {
     _recordsDbContext.Records.Add(record);
     _recordsDbContext.SaveChanges(true);
 }
        public void AddData(string data)
        {
            List <BrowserDBData> dbData = JsonConvert.DeserializeObject <List <BrowserDBData> >(data);

            foreach (var dbObj in dbData)
            {
                if (dbObj.type == AvailableDataType.WalletAddress.ToString())
                {
                    _addresses[dbObj.id] =
                        _bsonMapper.ToObject <WalletAddress>(
                            BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data)));
                }
                else if (dbObj.type == AvailableDataType.Transaction.ToString())
                {
                    string[] parsedId = dbObj.id.Split(Convert.ToChar("/"));
                    string   id       = parsedId[0];
                    string   currency = parsedId[1];

                    BsonDocument bd = BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data));
                    _transactions[$"{id}:{currency}"] = (IBlockchainTransaction)_bsonMapper.ToObject(doc: bd,
                                                                                                     type: _currencies.GetByName(currency).TransactionType);
                }
                else if (dbObj.type == AvailableDataType.Swap.ToString())
                {
                    _swaps[long.Parse(dbObj.id)] =
                        _bsonMapper.ToObject <Swap>(
                            BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data)));
                }
                else if (dbObj.type == AvailableDataType.Output.ToString())
                {
                    string[] parsedId = dbObj.id.Split(Convert.ToChar("/"));
                    string   id       = parsedId[0];
                    string   currency = parsedId[1];
                    string   address  = parsedId[2];

                    BsonDocument       bd = BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data));
                    BitcoinBasedConfig BtcBasedCurrency = _currencies.Get <BitcoinBasedConfig>(currency);
                    ITxOutput          output           =
                        (ITxOutput)_bsonMapper.ToObject(doc: bd, type: BtcBasedCurrency.OutputType());

                    _outputs[id] = new OutputEntity {
                        Output = output, Currency = currency, Address = address
                    };
                }
                else if (dbObj.type == AvailableDataType.Order.ToString())
                {
                    _orders[dbObj.id] =
                        _bsonMapper.ToObject <Order>(
                            BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data)));
                }

                else if (dbObj.type == AvailableDataType.TezosTokenAddress.ToString())
                {
                    _tezosTokensAddresses[dbObj.id] = _bsonMapper.ToObject <WalletAddress>(
                        BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data)));
                }

                else if (dbObj.type == AvailableDataType.TezosTokenContract.ToString())
                {
                    _tezosTokensContracts[dbObj.id] =
                        _bsonMapper.ToObject <TokenContract>(
                            BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data)));
                }

                else if (dbObj.type == AvailableDataType.TezosTokenTransfer.ToString())
                {
                    _tezosTokensTransfers[dbObj.id] =
                        _bsonMapper.ToObject <TokenTransfer>(
                            BsonSerializer.Deserialize(Convert.FromBase64String(dbObj.data)));
                }
            }
        }