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); }
//private string GetLogoTipo(int PersonId) //{ // //todo: implementar a logica que dado um personId de uma pessoa fisica faz a consulta de quem eh a empresa empregadora (personFatherId), o FileId e com base nisso, consulta no FileServer a URL do logotipo // return ""; //} public void Handle(UploadPhotoUserCommand command) { var repository = this.contextFactory(); var user = repository.Get(x => x.IntegrationCode == command.IntegrationCode); foreach (var item in command.ListFileTemp) { FIleServer fs = new FIleServer(); fs.FilePath = item.FilePath; fs.Width = item.Width; fs.Height = item.Height; fs.OriginalName = item.OriginalName; fs.FileIntegrationCode = item.FileIntegrationCode; //fs.FileTempId = item.FIl; fs.Description = "Photo Profile User"; fs.FileUtilizationId = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album); fs.FriendlyName = user.Name; fs.Alt = user.Name; fs.Name = user.Name; fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User; fs.PersonId = user.PersonId; fs.UploadedBy = Convert.ToInt32(command.CreatedBy); var ret = fs.SendFilePath(fs); if (ret > 0) { UserFile userFile = new UserFile(); userFile.UserId = user.UserId; userFile.FileId = ret; userFile.AssociatedDateUTC = DateTime.UtcNow; userFile.Active = true; //aggregateroot user.UserFile.Add(userFile); user.UrlImagemLogo = item.FilePath; repository.Save(user); } else { throw new Exception(); } } }
public void Handle(AddExpertiseCommand command) { var repository = this.contextFactory(); //command.CreatedBy = 0; var expertise = new Domain.Expertise(Guid.NewGuid(), command.ExpertiseId, command.Name, command.ExpertiseFatherId, command.CreatedBy, command.CreatedDateUTC, command.ApprovalStatusId, command.ApprovedBy, command.ApprovedDate, command.DefaultDescription, command.IsPriceDefinedEditorially, command.ApprovalStatus, command.Expertise1, command.Expertise2, command.User, command.User1, command.Active); repository.Save(expertise); 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; fileTempId = item; fs.FileTempId = fileTempId; fs.Description = "Usuário do Heeelp"; fs.FileUtilizationId = Convert.ToByte(GeneralEnumerators.EnumFileUtiliaztion.Album); fs.FriendlyName = command.Name; fs.Alt = command.Name; fs.Name = command.Name; fs.FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User; fs.PersonId = command.PersonId; fs.UploadedBy = command.CreatedBy; expertise.CompleteSuccessFile(fs); // repository.Save(expertise); } expertise.Complete(); repository.Save(expertise); }
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 CompleteSuccessFile(FIleServer fs) { this.AddEvent(new ExpertiseCreatedFIleEvent { SourceId = this.Id, ExpertiseId = this.ExpertiseId, FilePath = fs.FilePath, Width = fs.Width, Height = fs.Height, OriginalName = fs.OriginalName, FileTempId = fs.FileTempId, Description = "Usuário do Heeelp", FriendlyName = fs.FriendlyName, FileUtilizationId = fs.FileUtilizationId, Alt = fs.Alt, FileIntegrationCode = fs.FileIntegrationCode, Name = fs.Name, FileOriginTypeId = (int)GeneralEnumerators.EnumModules.Core_User, PersonId = fs.PersonId, UploadedBy = fs.UploadedBy }); }
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); } } }