public void Handle(AddPersonDocumentCommand command) { var repository = this.contextFactory(); var person = _PersonDao.GetByPersonIntegrationId(command.PersonIntegrationId); var personDocument = new Domain.PersonDocument(command.PersonDocumentId, person.PersonId, command.DocumentTypeId, command.Number, command.Complement, command.DateIssued, command.DateValidUntil, DateTime.UtcNow, command.FileId, command.Active, command.UserSystemId); if (command.listFileTemp != null) { foreach (var item in command.listFileTemp) { FIleServer fs = new FIleServer(); Domain.ReadModel.FileTemp fileTmp = new Domain.ReadModel.FileTemp(); fileTmp = _FileTemp.Get(item); fs.FilePath = fileTmp.FilePath; fs.Width = fileTmp.Width; fs.Height = fileTmp.Height; fs.OriginalName = fileTmp.OriginalName; fs.FileIntegrationCode = fileTmp.FileIntegrationCode; fs.FileTempId = item; fs.Description = "Usuário do Heeelp"; fs.FileUtilizationId = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album); fs.FriendlyName = person.Name; fs.Alt = person.Name; fs.Name = person.Name; fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User; fs.PersonId = command.PersonId; fs.UploadedBy = command.UserSystemId; var ret = fs.SendFilePath(fs); if (ret > 0) { _FileTemp.Delete(fs.FileTempId); personDocument.FileId = ret; } else { throw new Exception(); } } } repository.Save(personDocument); }
public void Handle(PersonDocumentFileAddedEvent @event) { FIleServer fs = new FIleServer(); fs.FilePath = @event.FilePath; fs.Width = @event.Width; fs.Height = @event.Height; fs.OriginalName = @event.OriginalName; fs.FileTempId = @event.FileTempId; fs.Description = @event.Description; fs.FriendlyName = @event.FriendlyName; fs.Alt = @event.Alt; fs.Name = @event.Name; fs.FileOriginTypeId = @event.FileOriginTypeId; fs.PersonId = @event.PersonId; fs.FileUtilizationId = @event.FileUtilizationId; fs.UploadedBy = @event.UploadedBy; var ret = fs.SendFilePath(fs); if (ret > 0) { _FileTemp.Delete(fs.FileTempId); var personFileCommand = new UpdatePersonDocument() { PersonDocumentId = @event.PersonDocumentId, PersonId = @event.PersonId, DocumentTypeId = @event.DocumentTypeId, InsertedDateUTC = @event.InsertedDateUTC, FileId = ret, Active = @event.Active, UserSystemId = Convert.ToInt32(@event.UploadedBy) }; this.bus.Send(personFileCommand); } else { throw new Exception(); } }
public void Handle(PersonProspectFileAddEvent @event) { FIleServer fs = new FIleServer(); fs.FilePath = @event.FilePath; fs.Width = @event.Width; fs.Height = @event.Height; fs.OriginalName = @event.OriginalName; fs.FileTempId = @event.FileTempId; fs.Description = @event.Description; fs.FriendlyName = @event.FriendlyName; fs.Alt = @event.Alt; fs.Name = @event.Name; fs.FileOriginTypeId = @event.FileOriginTypeId; fs.PersonId = @event.PersonId; fs.FileUtilizationId = @event.FileUtilizationId; fs.UploadedBy = @event.UploadedBy; var ret = fs.SendFilePath(fs); if (ret > 0) { _FileTemp.Delete(fs.FileTempId); var personFileCommand = new AddPersonFileCommand() { PersonId = @event.PersonId, AssociatedDateUTC = DateTime.UtcNow, FileId = ret, Active = true, AssocietedBy = Convert.ToInt32(@event.UploadedBy) }; this.bus.Send(personFileCommand); } else { throw new Exception(); } }
public void Handle(ExpertiseCreatedFIleEvent @event) { FIleServer fs = new FIleServer(); fs.FilePath = @event.FilePath; fs.Width = @event.Width; fs.Height = @event.Height; fs.OriginalName = @event.OriginalName; fs.FileTempId = @event.FileTempId; fs.Description = @event.Description; fs.FriendlyName = @event.FriendlyName; fs.Alt = @event.Alt; fs.Name = @event.Name; fs.FileOriginTypeId = @event.FileOriginTypeId; fs.PersonId = @event.PersonId; fs.FileUtilizationId = @event.FileUtilizationId; fs.UploadedBy = @event.UploadedBy; var ret = fs.SendFilePath(fs); if (ret > 0) { _FileTemp.Delete(fs.FileTempId); var expertisePhoto = new AddExpertisePhotoCommand() { ExpertiseId = @event.ExpertiseId, ExpertisePhotoId = 1, FileId = ret, IsDefault = true }; this.bus.Send(expertisePhoto); } else { throw new Exception(); } }
public void Handle(UserCreatedFIleEvent @event) { FIleServer fs = new FIleServer(); fs.FilePath = @event.FilePath; fs.Width = @event.Width; fs.Height = @event.Height; fs.OriginalName = @event.OriginalName; fs.FileTempId = @event.FileTempId; fs.Description = @event.Description; fs.FriendlyName = @event.FriendlyName; fs.Alt = @event.Alt; fs.Name = @event.Name; fs.FileOriginTypeId = @event.FileOriginTypeId; fs.PersonId = @event.PersonId; fs.FileUtilizationId = @event.FileUtilizationId; fs.UploadedBy = @event.UploadedBy; var ret = fs.SendFilePath(fs); if (ret > 0) { _FileTemp.Delete(fs.FileTempId); var userFileCommand = new AddUserFileCommand() { FileId = ret, AssociatedDateUTC = DateTime.UtcNow, Active = true, UserId = @event.UserId }; this.bus.Send(userFileCommand); } else { throw new Exception(); } }
public void Handle(AddPromotionProspectCommand command) { var person = _PersonDao.GetByPersonIntegrationId(command.PersonIntegrationID); command.PersonId = person.PersonId; List <long> listImgIds = new List <long>(); if (command.listFileTemp != null) { foreach (var item in command.listFileTemp) { FIleServer fs = new FIleServer(); Domain.ReadModel.FileTemp fileTmp = new Domain.ReadModel.FileTemp(); fileTmp = _FileTemp.Get(item); fs.FilePath = fileTmp.FilePath; fs.Width = fileTmp.Width; fs.Height = fileTmp.Height; fs.OriginalName = fileTmp.OriginalName.Replace(".jpg.jpeg", ".jpg"); fs.FileIntegrationCode = fileTmp.FileIntegrationCode; fs.FileTempId = item; fs.Description = "Usuário do Heeelp"; fs.FileUtilizationId = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album); fs.FriendlyName = fileTmp.OriginalName; fs.Alt = fileTmp.OriginalName; fs.Name = fileTmp.OriginalName; fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User; fs.PersonId = command.PersonId; fs.UploadedBy = Convert.ToInt32(command.UserSystemId); var ret = fs.SendFilePath(fs); if (ret > 0) { listImgIds.Add(ret); _FileTemp.Delete(fs.FileTempId); } else { throw new Exception(); } } } command.FilesIdList = listImgIds; string url = string.Empty; switch ((GeneralEnumerators.enumPromotionType)command.PromotionTypeId) { case GeneralEnumerators.enumPromotionType.Discount: url = "api/Promotion/AddDiscountPromotion"; break; case GeneralEnumerators.enumPromotionType.Award: url = "api/Promotion/AddAwardPromotion"; break; case GeneralEnumerators.enumPromotionType.Gift: url = "api/Promotion/AddGiftPromotion"; break; } var _clientPromotion = new HttpClient(); _clientPromotion.BaseAddress = new Uri(CustomConfiguration.WebApiPromotion); var resultTask = _clientPromotion.PostAsJsonAsync(url, command).Result; if (!resultTask.IsSuccessStatusCode) { LogManager.Error(url + " Handler: Erro ao enviar web.api promotion: status: " + resultTask.StatusCode); } else { resultTask = _clientPromotion.PostAsJsonAsync("api/Promotion/UploadPromotionPhoto", command).Result; if (!resultTask.IsSuccessStatusCode) { LogManager.Error("UploadPromotionPhoto Handler: Erro ao enviar web.api promotion: status: " + resultTask.StatusCode); } } }