示例#1
0
        public async Task <bool> HandleMessageAsync(string messageType, string message, IDictionary <string, object> userproperties)
        {
            try
            {
                var id          = Encoding.UTF8.GetString((byte[])userproperties["Id"]);
                var ordertype   = Encoding.UTF8.GetString((byte[])userproperties["OrderType"]);
                var sendingdate = Encoding.UTF8.GetString((byte[])userproperties["SendingDate"]);

                List <ValueDTO> values = new List <ValueDTO>();
                values.Add(new ValueDTO()
                {
                    Key = "Id", Value = id
                });
                values.Add(new ValueDTO()
                {
                    Key = "OrderType", Value = ordertype
                });
                values.Add(new ValueDTO()
                {
                    Key = "SendingDate", Value = sendingdate
                });


                var valresponse = await _service.Validate("CardCompos", ".json", message);

                var streamid = Guid.NewGuid();
                var filename = string.Format("{0}_{1}.json", id, messageType);
                if (await _service.AddToStorage(streamid, message, filename, "json", valresponse.Valid))
                {
                    Guid headerid = Guid.NewGuid();
                    var  xx       = await _service.AddHeader(headerid, "CardCompos");

                    var yy = await _service.AddFileExtension(headerid, streamid, filename, valresponse.Valid, string.Join("\n", valresponse.Messages), values);

                    DeliveryCompleted e = await _service.CreateFowardingCommand(headerid);

                    await _messagePublisher.PublishMessageAsync(messageType, e, "DataService", null);

                    //await _messagePublisher.PublishMessageAsync(messageType, e, "", null);
                    await _messagePublisher.PublishMessageAsync(messageType, e, "notification", null);
                }


                //scaler aanroepen

                //status terugkoppelen.
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        private async Task ProcessFile(SingleFile file)
        {
            Guid streamid = Guid.NewGuid();

            if (await _service.AddToStorage(streamid, file.FileName, file.GetFileType(), file.Valid, file.SubFolder))
            {
                if (await _service.AddHeader(file.DeliveryId, file.Flow, file.ParentId))
                {
                    if (await _service.AddFileExtension(file.DeliveryId, streamid, Path.GetFileName(file.FileName), file.Valid, string.Join("\n", file.Messages), null))
                    {
                        foreach (var sf in file.SingleFiles)
                        {
                            await ProcessFile(sf);
                        }
                        file.Saved = true;
                    }
                }
            }
        }