diff --git a/Services/Workers/FileService.cs b/Services/Workers/FileService.cs index d48f3b7..dbb6a78 100644 --- a/Services/Workers/FileService.cs +++ b/Services/Workers/FileService.cs @@ -3,6 +3,7 @@ using ExpressBase.Common.Data; using ExpressBase.Common.EbServiceStack.ReqNRes; using ExpressBase.Common.Enums; +using ExpressBase.Common.LocationNSolution; using ExpressBase.Common.ServerEvents_Artifacts; using ExpressBase.Common.ServiceClients; using ExpressBase.Common.Structures; @@ -26,6 +27,16 @@ public FileServiceInternal(IMessageProducer _mqp, IMessageQueueClient _mqc, IEbS ReqType = this.GetType().ToString() }; } + public bool IsNewFileServer(string solutionId) + { + if (solutionId != string.Empty) + { + Eb_Solution _solution = this.GetSolutionObject(solutionId); + return _solution?.SolutionSettings?.EnableNewFileServer ?? false; + } + else + return false; + } public EbMqResponse Post(UploadFileRequest request) { @@ -35,25 +46,16 @@ public EbMqResponse Post(UploadFileRequest request) { EbConnectionFactory _ebConnectionFactory = new EbConnectionFactory(request.SolnId, this.Redis); - string filestore_sid = _ebConnectionFactory.FilesDB.UploadFile( - request.FileRefId.ToString(), - request.Byte, - request.FileCategory, - request.InfraConID - ); + string filestore_sid = _ebConnectionFactory.FilesDB.UploadFile(request.FileRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID, StaticFileConstants.GetFilePath(request), IsNewFileServer(request.SolnId)); string sql = _ebConnectionFactory.DataDB.EB_MQ_UPLOADFILE; DbParameter[] parameters = { _ebConnectionFactory.DataDB.GetNewParameter("filestoresid",EbDbTypes.String, filestore_sid), - _ebConnectionFactory.DataDB.GetNewParameter("refid",EbDbTypes.Int32, request.FileRefId), - _ebConnectionFactory.DataDB.GetNewParameter("length",EbDbTypes.Int64, request.Byte.Length), - _ebConnectionFactory.DataDB.GetNewParameter("filedb_con_id", EbDbTypes.Int32, _ebConnectionFactory.FilesDB.UsedConId), - _ebConnectionFactory.DataDB.GetNewParameter("is_image",EbDbTypes.Boolean, false) }; @@ -143,7 +145,7 @@ public EbMqResponse Post(UploadImageRequest request) try { Log.Info("FilesDB Collection Count: " + this.EbConnectionFactory.FilesDB.Count); - filestore_sid = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID); + filestore_sid = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID, StaticFileConstants.GetFilePath(request),IsNewFileServer(request.SolnId)); } catch (Exception e) { @@ -218,7 +220,7 @@ public EbMqResponse Post(UploadImageRequest request) if (thumbnailBytes.Length > 0) { - filestore_sid = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), thumbnailBytes, request.FileCategory, request.InfraConID); + filestore_sid = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), thumbnailBytes, request.FileCategory, request.InfraConID, StaticFileConstants.GetFilePath(request), IsNewFileServer(request.SolnId)); DbParameter[] parametersImageSmall = { this.EbConnectionFactory.DataDB.GetNewParameter("refid", EbDbTypes.Int32, request.ImageRefId), @@ -270,7 +272,7 @@ public EbMqResponse Post(UploadDpRequest request) { this.EbConnectionFactory = new EbConnectionFactory(request.SolnId, this.Redis); - string filestore_sid = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID); + string filestore_sid = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID, StaticFileConstants.GetFilePath(request), IsNewFileServer(request.SolnId)); DbParameter[] parameters = { @@ -314,7 +316,7 @@ public EbMqResponse Post(UploadDpRequest request) request.ImgManpSerConId = this.EbConnectionFactory.ImageManipulate[0].InfraConId; byte[] smallByte = responseContent.ReadAsByteArrayAsync().Result; - string fStoreIdSmall = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), smallByte, request.FileCategory, request.InfraConID); + string fStoreIdSmall = this.EbConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), smallByte, request.FileCategory, request.InfraConID, StaticFileConstants.GetFilePath(request), IsNewFileServer(request.SolnId)); DbParameter[] smallImgParams = { @@ -387,7 +389,7 @@ public EbMqResponse Post(UploadLogoRequest request) // } //} - string filestore_sid = this.InfraConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID); + string filestore_sid = this.InfraConnectionFactory.FilesDB.UploadFile(request.ImageRefId.ToString(), request.Byte, request.FileCategory, request.InfraConID, StaticFileConstants.GetFilePath(request), IsNewFileServer(request.SolnId)); string sql = @"INSERT INTO eb_files_ref_variations (eb_files_ref_id, filestore_sid, length, imagequality_id, is_image, img_manp_ser_con_id, filedb_con_id) diff --git a/Services/Workers/PdfMQService.cs b/Services/Workers/PdfMQService.cs index a8e5c1b..0938052 100644 --- a/Services/Workers/PdfMQService.cs +++ b/Services/Workers/PdfMQService.cs @@ -27,7 +27,7 @@ namespace ExpressBase.MessageQueue.Services.Workers [Restrict(InternalOnly = true)] public class PdfMQService : EbMqBaseService { - public PdfMQService(IEbConnectionFactory _dbf, IEbStaticFileClient _sfc, IMessageProducer _mqp, IMessageQueueClient _mqc, IServiceClient _ssclient, IEbServerEventClient _sec, PooledRedisClientManager pooledRedisManager) : base(_dbf, _sfc, _mqp, _mqc, _ssclient, _sec, pooledRedisManager) { } + public PdfMQService(IEbConnectionFactory _dbf, IEbStaticFileClient _sfc, IMessageProducer _mqp, IMessageQueueClient _mqc, IServiceClient _ssclient, IEbServerEventClient _sec, PooledRedisClientManager pooledRedisManager, EbStaticFileClient2 _sfc2) : base(_dbf, _sfc, _mqp, _mqc, _ssclient, _sec, pooledRedisManager, _sfc2) { } public MemoryStream Ms1 = null; @@ -71,6 +71,7 @@ public ReportRenderResponse Post(ReportRenderMultipleMQRequest request) reportObject.ObjectsDB = this.EbConnectionFactory.ObjectsDB; reportObject.Redis = this.Redis; reportObject.FileClient = this.FileClient; + reportObject.FileClient2 = this.FileClient2; reportObject.Solution = GetSolutionObject(request.SolnId); reportObject.ReadingUser = GetUserObject(request.ReadingUserAuthId); reportObject.RenderingUser = GetUserObject(request.RenderingUserAuthId); diff --git a/Startup.cs b/Startup.cs index 0805051..01a46d2 100644 --- a/Startup.cs +++ b/Startup.cs @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; +using System.Net.Http; using System.Reflection; //using Quartz; //using ServiceStack.Quartz; @@ -128,6 +129,7 @@ public override void Configure(Container container) container.Register(c => new EbConnectionFactory(c)).ReusedWithin(ReuseScope.Request); container.Register(c => new EbStaticFileClient()).ReusedWithin(ReuseScope.Request); + container.Register(c => new EbStaticFileClient2(new HttpClient())); RabbitMqMessageFactory rabitFactory = new RabbitMqMessageFactory(); rabitFactory.ConnectionFactory.UserName = Environment.GetEnvironmentVariable(EnvironmentConstants.EB_RABBIT_USER);