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 async Task <HttpResponseMessage> UploadPromotionPhoto() { if (ModelState.IsValid) { var provider = new MultipartMemoryStreamProvider(); Claims claims = new Claims().Values(); NameValueCollection parameters = HttpContext.Current.Request.Params; try { //LogManager.Info(string.Concat(" PromotionProspectAdd ismimemultipart: ", Request.Content.IsMimeMultipartContent())); if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; //LogManager.Info(string.Concat("PromotionProspectAdd ismimemultipart: ", HttpContext.Current.Request.Files.Count)); string pathStorage = string.Empty; foreach (var file in HttpContext.Current.Request.Files) { var f = provider.Contents[count]; string fileName; if (f.Headers.ContentDisposition == null || f.Headers.ContentDisposition.FileName == null) { fileName = parameters["FileName"].ToString() + ".jpeg"; } else { fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); } string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); pathStorage = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.FilePath = pathStorage; ft.OriginalName = fileName; try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria int fileId = _FileTemp.SaveFileTemp(ft); _listFileTemp.Add(fileId); PromotionPhotoInputDTO promotionPhoto = new PromotionPhotoInputDTO(); promotionPhoto.PromotionIntegrationCode = Guid.Parse(parameters["IntegrationCode"].ToString()); promotionPhoto.Active = true; promotionPhoto.FileId = fileId; promotionPhoto.IsDefault = (count == 1); promotionPhoto.PathImage = ft.FilePath; promotionPhoto.ShowOrder = (byte)count; promotionPhoto.UserSystemId = claims.userSystemId; var _clientPromotion = new HttpClient(); _clientPromotion.BaseAddress = new Uri(CustomConfiguration.WebApiPromotion); var resultTask = _clientPromotion.PostAsJsonAsync("api/Promotion/UploadPromotionPhoto", promotionPhoto).Result; if (!resultTask.IsSuccessStatusCode) { LogManager.Error("UploadPromotionPhoto Handler: Erro ao enviar web.api promotion: status: " + resultTask.StatusCode); } } return(Request.CreateResponse(HttpStatusCode.OK, pathStorage)); } catch (Exception ex) { LogManager.Error(string.Format("PromotionProspectAdd image Error:{0}", ex)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } } return(Request.CreateResponse(HttpStatusCode.OK, new { })); }
public async Task <HttpResponseMessage> EditPromotionPhoto() { PromotionPhotoInputDTO promotionPhoto = new PromotionPhotoInputDTO(); var provider = new MultipartMemoryStreamProvider(); Claims claims = new Claims().Values(); NameValueCollection parameters = HttpContext.Current.Request.Params; try { if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; foreach (var file in HttpContext.Current.Request.Files) { var f = provider.Contents[count]; string fileName; if (f.Headers.ContentDisposition == null || f.Headers.ContentDisposition.FileName == null) { fileName = parameters["FileName"].ToString() + ".jpeg"; } else { fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); } string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); ft.FilePath = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.OriginalName = fileName; try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria int fileId = _FileTemp.SaveFileTemp(ft); _listFileTemp.Add(fileId); promotionPhoto.PromotionIntegrationCode = Guid.Parse(parameters["IntegrationCode"].ToString()); promotionPhoto.Active = true; promotionPhoto.FileId = fileId; promotionPhoto.IsDefault = true; promotionPhoto.PathImage = ft.FilePath; promotionPhoto.ShowOrder = (byte)count; promotionPhoto.UserSystemId = claims.userSystemId; var _clientPromotion = new HttpClient(); _clientPromotion.BaseAddress = new Uri(CustomConfiguration.WebApiPromotion); var resultTask = _clientPromotion.PostAsJsonAsync("api/Promotion/EditPromotionPhoto", promotionPhoto).Result; if (!resultTask.IsSuccessStatusCode) { LogManager.Error("EditPromotionPhoto Handler: Erro ao enviar web.api promotion: status: " + resultTask.StatusCode); } } } catch (Exception ex) { LogManager.Error(string.Format("PromotionProspectAdd image Error:{0}", ex)); } return(Request.CreateResponse(HttpStatusCode.OK, new { promotionPhoto.PathImage })); } } catch (System.Exception ex) { LogManager.Error(string.Format("ValidateUser Error:{0} : {1}", ex, ex.StackTrace)); LogManager.Error(string.Format("ValidateUser Error Parametros recebidos: Alert = {0}, normalPrice = {1} , discountPercent = {2} ,ExpertiseId = {3} ,Title = {4} ,ShortDescription = {5} ,FullDescription = {6} ,StartDateUTC = {7} ,ValidUntilUTC = {8} ,RequiredTimeForActivation = {9},PromotionTypeId = {10} ,PromotionBillingModelId = {11} ,PromotionRecurrenceId = {12} ,PromotionPaymentTypeId = {13} ,CurrencyId = {14} ,ExpertisePromotionCostReferenceId = {15},NumberOfAvailableCoupons = {16} ,PersonIntegrationID = {17}", parameters["Alert"], parameters["NormalPrice"], parameters["DiscountePercentege"], parameters["ExpertiseId"], parameters["Title"], parameters["ShortDescription"], parameters["FullDescription"], parameters["StartDateUTC"], parameters["ValidUntilUTC"], parameters["RequiredTimeForActivation"], parameters["PromotionTypeId"], parameters["PromotionBillingModelId"], parameters["PromotionRecurrenceId"], parameters["PromotionPaymentTypeId"], parameters["CurrencyId"], parameters["ExpertisePromotionCostReferenceId"], parameters["NumberOfAvailableCoupons"], parameters["PersonIntegrationID"].Replace(",", ""))); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, new { })); }
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); } } }
public async Task <HttpResponseMessage> CompleteRegistrationExternalPerson() { //se tiver logo var provider = new MultipartMemoryStreamProvider(); NameValueCollection parameters = HttpContext.Current.Request.Params; if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; foreach (var file in HttpContext.Current.Request.Files) { var f = provider.Contents[count]; string fileName; if (f.Headers.ContentDisposition == null || f.Headers.ContentDisposition.FileName == null) { fileName = parameters["FileName"].ToString(); } else { fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); } string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); ft.FilePath = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.OriginalName = fileName; try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria try { _listFileTemp.Add(_FileTemp.SaveFileTemp(ft)); } catch (Exception ex) { LogManager.Error("Erro ao salvar Logo do Person"); } } } catch (Exception ex) { LogManager.Error(string.Format("CompleteRegistrationExternalPerson image Error:{0}", ex)); } } try { //var commandPersonCompleteRegistration = new UpdatePersonCompleteRegistrationCommand(); //commandPersonCompleteRegistration.IntegrationCode = Guid.NewGuid(); //commandPersonCompleteRegistration.PhoneNumber = parameters["PhoneNumber"].ToString(); //commandPersonCompleteRegistration.UserSystemId = long.Parse(parameters["UserId"].ToString()); //commandPersonCompleteRegistration.PersonIntegrationID = Guid.NewGuid(); //commandPersonCompleteRegistration.Document = parameters["Document"].ToString(); //this.bus.Send(commandPersonCompleteRegistration); //var UpdatePersonAddressCompleteRegistration = new UpdatePersonAddressCompleteRegistrationCommand(); //UpdatePersonAddressCompleteRegistration.PersonIntegrationId = commandPersonCompleteRegistration.PersonIntegrationID; //UpdatePersonAddressCompleteRegistration.StreetName = parameters["StreetName"].ToString(); //UpdatePersonAddressCompleteRegistration.Number = parameters["Number"].ToString(); //UpdatePersonAddressCompleteRegistration.State = parameters["State"].ToString(); //UpdatePersonAddressCompleteRegistration.Country = parameters["Country"].ToString(); //UpdatePersonAddressCompleteRegistration.City = parameters["City"].ToString(); //UpdatePersonAddressCompleteRegistration.PostCode = parameters["PostCode"].ToString(); //UpdatePersonAddressCompleteRegistration.ContactEMail = parameters["SecundaryEmail"].ToString(); //UpdatePersonAddressCompleteRegistration.ContactPhoneNumber = parameters["SmartPhoneNumber"].ToString(); //UpdatePersonAddressCompleteRegistration.CreatedBy = Convert.ToInt32(parameters["UserId"].ToString()); //UpdatePersonAddressCompleteRegistration.ServerInstanceId = Convert.ToInt16(1); //this.bus.Send(UpdatePersonAddressCompleteRegistration); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (System.Exception ex) { LogManager.Error(string.Format("CompleteRegistartionPerson: {0}", parameters)); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public async Task <HttpResponseMessage> PersonDocumentAdd() { try { var provider = new MultipartMemoryStreamProvider(); NameValueCollection parameters = HttpContext.Current.Request.Params; if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; foreach (var file in HttpContext.Current.Request.Files) { var f = provider.Contents[count]; string fileName; if (f.Headers.ContentDisposition == null || f.Headers.ContentDisposition.FileName == null) { fileName = parameters["FileName"].ToString(); } else { fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); } string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); ft.FilePath = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.OriginalName = fileName; try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria _listFileTemp.Add(_FileTemp.SaveFileTemp(ft)); } } catch (Exception ex) { LogManager.Error(string.Format("PersonDocumentAdd image Error:{0}", ex)); } } var personDocument = new AddPersonDocumentCommand() { DocumentTypeId = (short)GeneralEnumerators.EnumDocumentType.CNPJ, Number = parameters["CNPJ"].ToString(), Active = true, listFileTemp = _listFileTemp, PersonIntegrationId = Guid.Parse(parameters["PersonIntegrationID"]), UserSystemId = Convert.ToInt32(parameters["UserSystem"].ToString()) }; this.bus.Send(personDocument); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (System.Exception e) { LogManager.Error("Erro ao Add PersonDocumentAdd", e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public async Task <HttpResponseMessage> PersonProspectDesktopAdd() { //recebo as imagens se tiver try { var provider = new MultipartMemoryStreamProvider(); NameValueCollection parameters = HttpContext.Current.Request.Params; if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; foreach (var file in HttpContext.Current.Request.Files) { var f = provider.Contents[count]; string fileName; if (f.Headers.ContentDisposition == null || f.Headers.ContentDisposition.FileName == null) { fileName = parameters["FileName"].ToString(); } else { fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); } string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); ft.FilePath = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.OriginalName = fileName; try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria try { _listFileTemp.Add(_FileTemp.SaveFileTemp(ft)); } catch (Exception ex) { LogManager.Info("PersonProspectAdd sem Imagem"); throw; } } } catch (Exception ex) { LogManager.Error(string.Format("PersonProspectAdd image Error:{0}", ex)); } } if (!string.IsNullOrEmpty(parameters["CampaignId"].ToString())) { campaignID = Convert.ToInt64(parameters["CampaignId"].ToString()); } else { campaignID = null; } if (!string.IsNullOrEmpty(parameters["InviteId"].ToString())) { inviteId = long.Parse(parameters["InviteId"].ToString()); } else { inviteId = null; } var Person = new AddPersonCommand(); Person.IntegrationCode = Guid.NewGuid(); Person.Name = parameters["Name"]; Person.FantasyName = parameters["FantasyName"].ToString(); Person.PersonOriginTypeId = Convert.ToByte(parameters["PersonOriginTypeId"]); Person.CampaignId = campaignID; Person.CountryId = Convert.ToByte(parameters["CountryId"]); Person.LanguageId = Convert.ToByte(parameters["LanguageId"]); Person.PersonTypeId = Convert.ToByte(parameters["PersonTypeId"]); Person.PersonProfileId = Convert.ToByte(parameters["PersonProfileId"]); Person.PersonStatusId = Convert.ToByte(parameters["PersonStatusId"]); Person.CurrencyId = Convert.ToByte(parameters["CurrencyId"].ToString()); Person.CreationDateUTC = DateTime.UtcNow; Person.PhoneNumber = parameters["PhoneNumber"].ToString(); Person.InviteId = inviteId; Person.ServerInstanceId = Convert.ToInt16(1); Person.Active = true; Person.listFileTemp = _listFileTemp; Person.UserSystemId = long.Parse(parameters["UserSystem"].ToString()); Person.PersonIntegrationID = Guid.NewGuid(); Person.Number = parameters["CNPJ"].ToString();//cnpj this.bus.Send(Person); List <int> expertiseId = new List <int>() { Convert.ToInt32(parameters["ExpertiseId"].ToString()) }; var personExpertise = new AddPersonExpertiseCommand() { ExpertiseListId = expertiseId, InsertedDateUTC = DateTime.UtcNow, InsertedBy = Convert.ToInt32(parameters["UserSystem"].ToString()), CustomDescription = parameters["CustomDescription"].ToString(), ServerInstanceId = 1,//Convert.ToInt16(json.ServerInstanceId), //CustomPhotoFileId = string.IsNullOrEmpty(json.CustomPhotoFileId) ? null : json.CustomPhotoFileId, //CustomDescription = json.CustomDescription, ExhibitionOrder = 1, // Convert.ToByte(json.ExhibitionOrder), PersonIntegrationId = Person.PersonIntegrationID, Active = true //Convert.ToBoolean(json.Active) }; this.bus.Send(personExpertise); return(Request.CreateResponse(HttpStatusCode.OK, new { Person.PersonIntegrationID })); } catch (System.Exception ex) { LogManager.Error(string.Format("ValidateUser Error:{0}", ex)); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public async Task <HttpResponseMessage> PersonProspectAdd() { //recebo as imagens se tiver try { var provider = new MultipartMemoryStreamProvider(); NameValueCollection parameters = HttpContext.Current.Request.Params; if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; foreach (var file in HttpContext.Current.Request.Files) { var f = provider.Contents[count]; string fileName; if (f.Headers.ContentDisposition == null || f.Headers.ContentDisposition.FileName == null) { fileName = parameters["FileName"].ToString(); } else { fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); } string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); ft.FilePath = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.OriginalName = fileName; try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria try { _listFileTemp.Add(_FileTemp.SaveFileTemp(ft)); } catch (Exception ex) { LogManager.Info("PersonProspectAdd sem Imagem"); throw; } } } catch (Exception ex) { LogManager.Error(string.Format("PersonProspectAdd image Error:{0}", ex)); } } var Person = new AddPersonCommand() { IntegrationCode = Guid.NewGuid(), Name = parameters["Name"], FantasyName = parameters["FantasyName"].ToString(), //NameFromSecurityCheck = parameters["NameFromSecurityCheck"].ToString(), //SecuritySourceId = parameters["SecuritySourceId"], //IsSafe = parameters["IsSafe"], //FriendlyNameURL = parameters["FriendlyNameURL"].ToString(), PersonOriginTypeId = Convert.ToByte(parameters["PersonOriginTypeId"]), //PersonOriginDetails = parameters["PersonOriginDetails"].ToString(), CampaignId = long.Parse(parameters["CampaignId"].ToString()), CountryId = Convert.ToByte(parameters["CountryId"]), LanguageId = Convert.ToByte(parameters["LanguageId"]), PersonTypeId = Convert.ToByte(parameters["PersonTypeId"]), PersonProfileId = Convert.ToByte(parameters["PersonProfileId"]), PersonStatusId = Convert.ToByte(parameters["PersonStatusId"]), //PersonalWebSite = parameters["PersonalWebSite.ToString(), CurrencyId = Convert.ToByte(parameters["CurrencyId"].ToString()), CreationDateUTC = DateTime.UtcNow, //ActivationCode = parameters["ActivationCode.ToString(), //ActivationDateUTC = DateTime.Parse( parameters["ActivationDateUTC"].ToString()), PhoneNumber = parameters["PhoneNumber"].ToString(), //PersonFatherId = parameters["PersonFatherId, InviteId = long.Parse(parameters["InviteId"].ToString()), ServerInstanceId = Convert.ToInt16(1), Active = true, listFileTemp = _listFileTemp, UserSystemId = long.Parse(parameters["UserSystem"].ToString()), PersonIntegrationID = Guid.NewGuid() //,ImgListId = _listFileTemp }; this.bus.Send(Person); return(Request.CreateResponse(HttpStatusCode.OK, new { Person.PersonIntegrationID })); } catch (System.Exception ex) { LogManager.Error(string.Format("ValidateUser Error:{0}", ex)); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }
public async Task <HttpResponseMessage> PostFile(string jsonData) { JavaScriptSerializer serializer = new JavaScriptSerializer(); var json = serializer.Deserialize <dynamic>(jsonData); try { string Name = json["Name"]; string Description = json["Description"]; string ExpertiseFather = json["ExpertiseFather"]; int? expertiseFatherId = null; if (!string.IsNullOrEmpty(ExpertiseFather)) { expertiseFatherId = int.Parse(ExpertiseFather); } string ApprovalStatusId = json["ApprovalStatusId"]; string CreatedBy = json["CreatedBy"]; string ApprovedBy = json["ApprovedBy"]; //recebo as imagens se tiver var provider = new MultipartMemoryStreamProvider(); if (Request.Content.IsMimeMultipartContent()) { try { await Request.Content.ReadAsMultipartAsync(provider); fs = new List <FIleServer>(); int count = 0; foreach (var f in provider.Contents) { var fileName = f.Headers.ContentDisposition.FileName.ToString().Replace("\"", ""); string mimeType = new MimeType().GetMimeType(fileName); var stream = (HttpContext.Current.Request.Files[count]).InputStream; byte[] bytesInStream = new byte[stream.Length]; stream.Read(bytesInStream, 0, bytesInStream.Length); Domain.ReadModel.FileTemp ft = new Domain.ReadModel.FileTemp(); ft.FileIntegrationCode = Guid.NewGuid(); ft.FilePath = _storage.UploadFile(_containerName, ft.FileIntegrationCode.ToString(), mimeType, bytesInStream); ft.OriginalName = f.Headers.ContentDisposition.FileName.Replace("\"", ""); try { using (Image img = Image.FromStream(stream: stream, useEmbeddedColorManagement: false, validateImageData: false)) { ft.Width = img.PhysicalDimension.Width.ToString(); ft.Height = img.PhysicalDimension.Height.ToString(); } count++; } catch (Exception ex) { LogManager.Error("Erro ao recuperar dimensoes da imagen", ex); } //salvo na tablea temporaria _listFileTemp.Add(_FileTemp.SaveFileTemp(ft)); } } catch (Exception ex) { LogManager.Info("Expertise sem Imagem"); } } var user = this._UserDao.Get(new Domain.ReadModel.User { UserId = int.Parse(CreatedBy) }); var expertise = new AddExpertiseCommand() { Name = Name, DefaultDescription = Description, ApprovedDate = DateTime.UtcNow, CreatedDateUTC = DateTime.UtcNow, ExpertiseFatherId = expertiseFatherId, ApprovalStatusId = byte.Parse(ApprovalStatusId), CreatedBy = int.Parse(CreatedBy), ApprovedBy = int.Parse(ApprovedBy), Active = true, listFileTemp = _listFileTemp, PersonId = user.PersonId }; this.bus.Send(expertise); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { LogManager.Error("Erro ao cadastrar Expertise: ", ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex)); } }