Exemplo n.º 1
0
		private void StoreAvmResponse(int orderId, int currentUserId, string avmResponseString)
		{
			var documentBytes = Encoding.Unicode.GetBytes(avmResponseString);
			var documentInfo = new DocumentInfo();
			documentInfo.DateAdded = DateTime.Now;
			documentInfo.Size = documentBytes.Length;
			documentInfo.AddedByUserId = currentUserId;
			documentInfo.Name = DVS.Logic.Constants.Avm.AvmResponseDocumentType + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + "-id-" + orderId;
			documentInfo.DocumentType = DVS.Logic.Constants.Avm.AvmResponseDocumentType;
			var documentGuid = _documentService.StoreDocument(documentInfo, documentBytes);

            var responseXMLDocument = new XmlDocument();
            responseXMLDocument.LoadXml(avmResponseString);
            var pdfReportLinkNode = responseXMLDocument.SelectSingleNode("//pdf/pdfLink");
            if (pdfReportLinkNode != null)
            {
                using (WebClient webClient = new WebClient())
                {
                    var pdfReport = webClient.DownloadData(pdfReportLinkNode.InnerText);
                    var pdfDocumentInfo = new DocumentInfo();
                    pdfDocumentInfo.DateAdded = DateTime.Now;
                    pdfDocumentInfo.Size = pdfReport.Length;
                    pdfDocumentInfo.AddedByUserId = currentUserId;
                    pdfDocumentInfo.Name = ".pdf" + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + "-id-" + orderId;
                    pdfDocumentInfo.DocumentType = ".pdf";
                    var pdfDocumentGuid = _documentService.StoreDocument(pdfDocumentInfo, pdfReport);
                    UpdateAvmResponse(orderId, documentGuid, pdfDocumentGuid);
                }
            }
            else
            {
                UpdateAvmResponse(orderId, documentGuid, null);
            }
            _commitProvider.Commit();
		}
Exemplo n.º 2
0
		public Guid StoreDocument(DocumentInfo documentInfo, byte[] document)
		{
			using (StorageServiceClient client = new StorageServiceClient())
			{
				return client.StoreDocument(documentInfo, document);
			}
		}
Exemplo n.º 3
0
		public void FileUploadController_Download_should_return_file_stream()
		{
			var documentInfo = new DocumentInfo() { Name = "test.pdf" };
			var documentStream = new MemoryStream();
			DocumentService.IsDocumentExist(Arg.Any<Guid>()).Returns(true);
			DocumentService.GetDocumentInfo(Arg.Any<Guid>()).Returns(documentInfo);
			DocumentService.GetDocumentStream(Arg.Any<Guid>()).Returns(documentStream);
			AppraiserAccessManager.CanDownloadUserDocuments(Arg.Any<string>()).Returns(true);
			Target.Download(Guid.Empty);
			Target.HttpContext.Response.ContentType.Should().Be("application/octet-stream");
		}
Exemplo n.º 4
0
		public Guid StoreDocument(DocumentInfo documentInfo, byte[] document)
		{
			using (DVSContext dc = new DVSContext())
			{
				documentInfo.DocumentStorageId = documentInfo.DocumentStorageId == Guid.Empty ? Guid.NewGuid() : documentInfo.DocumentStorageId;
				documentInfo.Name = documentInfo.Name ?? String.Empty;
				documentInfo.AddedByUserId = documentInfo.AddedByUserId;
				documentInfo.DateAdded = documentInfo.DateAdded == default(DateTime) ? DateTime.Now : documentInfo.DateAdded;

				dc.DocumentInfos.Add(documentInfo);
				dc.SaveChanges();
			}

			_documentStorage.StoreDocument(document, documentInfo.DocumentStorageId);

			return documentInfo.DocumentStorageId;
		}
Exemplo n.º 5
0
		public void GenerateAndSaveLOE(Order order, int currentUserId)
		{
			if (order.OrderStatus == OrderStatus.CreationProcess || order.OrderStatus == OrderStatus.Draft)
			{
				throw new SecurityException(string.Format("Unable to generate LOE. Wrong status. (order id:{0})", order.Id));
			}
			var document = _reportManager.GetLOEReport(order.Id, ReportFormat.PDF);
			var documentInfo = new DocumentInfo()
			{
				AddedByUserId = currentUserId,
				DateAdded = DateTime.Now,
				DocumentType = "application/pdf",
				Name = "Order#" + order.OrderPublicId + "_LOE.pdf",
				Size = document.Length
			};
			var documentStorageId = _documentService.StoreDocument(documentInfo, document);
			order.LOEDocument = documentStorageId;
		}
Exemplo n.º 6
0
		public void GenerateAndSaveLOE_should_throw_generate_document()
		{
			var userId = 1;
			var order = new Order
			{
				Id = 1,
				OrderStatus = OrderStatus.OrderAccepted,
				OrderPublicId = "1234567890"
			};
			var documentGuid = Guid.NewGuid();
			var document = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
			_reportManager.GetLOEReport(order.Id, ReportFormat.PDF).Returns(document);
			var documentInfo = new DocumentInfo()
			{
				AddedByUserId = userId,
				DateAdded = DateTime.Now,
				DocumentType = "application/pdf",
				Name = "Order#" + order.OrderPublicId + "_LOE.pdf",
				Size = document.Length
			};
			_documentService.StoreDocument(documentInfo, document).Returns(documentGuid);
			_target.GenerateAndSaveLOE(order, userId);
		}
Exemplo n.º 7
0
		private Order CreateTestOrderInternal(int appraiserUserId)
		{
			var isTestOrderAdded = _orderRepository.Get(o => o.IsTestOrder == true && o.AcceptedAppraiserUserId == appraiserUserId).Count() > 0;
			if (!isTestOrderAdded)
			{
				var order = new Order();
				var orderData = _referenceManagement.GetTestOrderData();

				#region Populate Fields
				order.AcceptedAppraiserUserId = appraiserUserId;
				order.IsTestOrder = true;
				order.LastCompletedStep = 5;
				order.AppraisalInfo = new OrderAppraisalInfo
				{
					AppraisalForm = int.Parse(orderData[OrderField.AppraisalForm]),
					AppraisalTypeId = int.Parse(orderData[OrderField.AppraisalTypeId]),
					LoanTypeId = int.Parse(orderData[OrderField.LoanTypeId]),
					OccupancyTypeId = int.Parse(orderData[OrderField.OccupancyTypeId]),
					PropertyTypeId = int.Parse(orderData[OrderField.PropertyTypeId]),
					Rush = false,
					SecondDuplicateAppraisal = false,
					SupplementalREOAddendum = false
				};
				order.AppraiserOrderDeliveryType = (int)AppraiserOrderDeliveryType.Email;
				order.ClientCompanyId = int.Parse(orderData[OrderField.ClientCompanyId]);
				order.ClientCompanyBrancheId = int.Parse(orderData[OrderField.ClientCompanyBrancheId]);
				order.CreatedByClientUserId = int.Parse(orderData[OrderField.CreatedByClientUserId]);
				order.CreationDate = DateTime.Now;
				order.DueDate = _businessDaysCalc.GetNextBusinessDay(DateTime.Now, 5);
				order.FeeInfo = new OrderFeeInfo
				{
					IsPlatformUtilizationFeeVisible = true,
					AppraisalFee = 100,
					RushFee = 100,
					SecondAppraisalFee = 100,
					PlatformUtilizationFee = 100,
					SupplementalREOAddendumFee = 100
				};
				order.GeneralInfo = new OrderGeneralInfo
				{
					BorrowerFirstName = orderData[OrderField.BorrowerFirstName],
					BorrowerLastName = orderData[OrderField.BorrowerLastName],
					LoanNumber = orderData[OrderField.LoanNumber],
					PropertyAddress = new Address { City = orderData[OrderField.PropertyCity], County = orderData[OrderField.PropertyCounty], State = orderData[OrderField.PropertyState], Street = orderData[OrderField.PropertyStreet], ZIP = orderData[OrderField.PropertyZip] }
				};
				order.LoanAndContactInfo = new OrderLoanAndContactInfo
				{
					PurchasePrice = double.Parse(orderData[OrderField.PurchasePrice]),
					GFEAmount = double.Parse(orderData[OrderField.GFEAmount]),
					GFEDate = DateTime.Now,
					LoanPurposeTypeId = int.Parse(orderData[OrderField.LoanPurposeTypeId]),
					Contacts = new List<OrderContact> { new OrderContact { ContactRoleId = int.Parse(orderData[OrderField.ContactRoleId]), Name = orderData[OrderField.ContactName], Phone = orderData[OrderField.ContactPhone] } }
				};
				order.GeocodingCounty = orderData[OrderField.PropertyCounty];
				order.Latitude = 1;
				order.Longitude = 1;
				order.OrderPublicId = orderData[OrderField.OrderPublicId];
				order.OrderStatus = OrderStatus.OrderAccepted;

				var appraiserOrder = new AppraiserOrder
				{
					AppraiserId = order.AcceptedAppraiserUserId.Value,
					CreatedDate = order.CreationDate,
					Distance = 1,
					IsDeclined = false,
					Order = order
				};


				if (_configurationHelper.Environment != DvsEnvironment.Local)
				{
					var fileName = orderData[OrderField.PurchaseContractFileName];
					var purchaseContract = _documentService.GetStaticContent(fileName);
					var documentInfo = new DocumentInfo();
					documentInfo.Name = fileName;
					documentInfo.DateAdded = DateTime.Now;
					documentInfo.AddedByUserId = _securityContext.CurrentUser.Id;
					documentInfo.Size = purchaseContract.Length;

					var documentStorageId = _documentService.StoreDocument(documentInfo, purchaseContract);
					order.LoanAndContactInfo.PurchaseContractFileGuid = documentStorageId;
					_orderDocumentsRepository.Add(new OrderDocumentInfo() { DocumentTypeId = (int)DocumentType.PurchaseContract, FileId = documentStorageId, UserType = DocumentUserType.Lender, OrderId = order.Id });
				}
				#endregion

				_appraiserOrderRepository.Add(appraiserOrder);
				return order;
			}
			else
			{
				return null;
			}
		}
Exemplo n.º 8
0
		public Guid GenerateNachaFile(List<NachaFileAppraiserEntry> listOfAppraiserBilling, DateTime effectiveDate, DateTime throughDate, out bool isSuccess)
		{
			try
			{
				lock (Locker)
				{
					var firstUTN = _nachaFileGenerationManager.GetFirstUniqueTraceNumber();
					int added = 0;
					for (int i = 0; i < listOfAppraiserBilling.Count; i++)
					{
						listOfAppraiserBilling[i].UniqueTraceNumber = i + firstUTN + added;
						if (i + firstUTN >= 9999999)
						{
							firstUTN = 1;
							added = -i;
						}
					}
					var lastUTN = firstUTN + listOfAppraiserBilling.Count - 1 + added;

					var fileIdModifier = _nachaFileGenerationManager.GetFileIdModifier();
					var batchNumber = _nachaFileGenerationManager.GetBatchNumber();
					var creationDate = DateTime.Now;
					var fileName = string.Format("dvs_ach_{0:yyyyMMdd_HH-mm-ss-tt}.ach", creationDate);
					var nachaFile =
						new NachaFile(
							new NachaFileInfo
								{
									FileIdModifier = fileIdModifier,
									BatchNumber = batchNumber,
									CreationDate = creationDate,
									EffectiveEntryDate = effectiveDate,
									CompanyDescriptiveDate = throughDate
								}, listOfAppraiserBilling).RenderNachaFile();

					var documentInfo = new DocumentInfo()
					{
						AddedByUserId = _securityContext.CurrentUser.Id,
						DateAdded = creationDate,
						DocumentType = "nacha file",
						Name = fileName,
						Size = nachaFile.Length
					};

					var documentStorageId = _documentService.StoreDocument(documentInfo, Encoding.Default.GetBytes(nachaFile));
					var newNachaFile = new Model.Entities.NachaFile
					{
						BatchNumber = batchNumber,
						UniqueTraceNumber = lastUTN,
						CreationDate = creationDate,
						FileIdModifier = fileIdModifier,
						FileId = documentStorageId,
						FileName = fileName,
						DvsUser = _usersManagement.GetDvsUserByUserId(_securityContext.CurrentUser.Id)
					};

					_nachaFilesRepository.Add(newNachaFile);
					isSuccess = true;

					return documentStorageId;
				}
			}
			catch (Exception)
			{
				isSuccess = false;
				throw;
			}
		}
Exemplo n.º 9
0
		private void UploadFileInternal(List<ViewDataUploadFilesResult> statuses, HttpPostedFileBase file)
		{
			//IE fix
			var fileName = file.FileName;
			if (file.FileName.Contains(@"\"))
			{
				fileName = file.FileName.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries).Last();
			}

			using (var inputStream = file.InputStream)
			{
				byte[] buffer;
				using (BinaryReader br = new BinaryReader(inputStream))
				{
					buffer = br.ReadBytes((int)inputStream.Length);
				}

				var documentInfo = new DocumentInfo();
				documentInfo.Name = fileName;
				documentInfo.DocumentType = file.ContentType;
				documentInfo.Size = buffer.Length;
				documentInfo.DateAdded = DateTime.Now;
				documentInfo.AddedByUserId = SecurityContext.CurrentUser.Id;

				var documentStorageId = _documentService.StoreDocument(documentInfo, buffer);

				statuses.Add(new ViewDataUploadFilesResult()
				{
					id = documentStorageId,
					name = fileName,
					size = buffer.Length,
					type = file.ContentType,
					uploaded = DateTime.Now.ToString("MM/dd/yyyy hh:mm tt")
				});
			}
		}
Exemplo n.º 10
0
		private Guid GenerateOrderReport(ProcessCreditCardViewModel viewModel, string transactionId, string orderPublicNumber)
		{
			string creditCardName = _referenceManager.GetReference(ReferenceType.CreditCardTypes, false)[viewModel.CreditCardType.Value];

			var pdfDocument = _reportManager.GetPropertyAppraisalReceiptReport(
				viewModel.OrderId,
				viewModel.FirstName,
				viewModel.LastName,
				creditCardName,
				transactionId,
				viewModel.BillingAddress.Street,
				viewModel.BillingAddress.ZIP,
				GetStateAbbreviation(viewModel.BillingAddress.State),
				viewModel.BillingAddress.City, ReportFormat.PDF);

			var encryptedDocument = _cryptographicProvider.Encrypt(pdfDocument);

			var documentInfo = new DocumentInfo()
			{
				AddedByUserId = _securityContext.CurrentUser.Id,
				DateAdded = DateTime.Now,
				DocumentType = ".pdf",
				Name = "Order#" + orderPublicNumber + "_Receipt",
				Size = encryptedDocument.Value.Length,
				IsEncrypted = true
			};

			var documentStorageId = _documentService.StoreDocument(documentInfo, encryptedDocument.Value);

			return documentStorageId;
		}
Exemplo n.º 11
0
		private Guid StoreAvmRequest(int orderId, int currentUserId, string avmRequestString)
		{
			var documentBytes = Encoding.Unicode.GetBytes(avmRequestString);
			var documentInfo = new DocumentInfo();
			documentInfo.DateAdded = DateTime.Now;
			documentInfo.Size = documentBytes.Length;
			documentInfo.AddedByUserId = currentUserId;
			documentInfo.Name = DVS.Logic.Constants.Avm.AvmRequestDocumentType + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Year + "-id-" + orderId;
			documentInfo.DocumentType = DVS.Logic.Constants.Avm.AvmRequestDocumentType;
			var documentStorageId = _documentService.StoreDocument(documentInfo, documentBytes);
			UpdateAvmRequest(orderId, documentStorageId);
			_commitProvider.Commit();

			return documentStorageId;
		}
Exemplo n.º 12
0
		private bool ProcessSingleFile(int orderId, string fileExt, string fileName, int documentType)
		{
			var fullName = string.Format(_hotSpotDataFolder, fileExt, fileName);

			if (!System.IO.File.Exists(fullName))
			{
				throw new ApplicationException(string.Format("ACI processing files. File {0} does not exist", fullName));
			}

			var fileBytes = System.IO.File.ReadAllBytes(fullName);

			var documentInfo = new DocumentInfo();
			documentInfo.DateAdded = DateTime.Now;
			documentInfo.Size = fileBytes.Length;
			documentInfo.AddedByUserId = SecurityContext.CurrentUser.Id;
			documentInfo.Name = fileName;
			documentInfo.DocumentType = fileExt;
			
			var documentGuid = _documentService.StoreDocument(documentInfo, fileBytes);
            _orderDocumentsService.AddOrderDocument(orderId, documentGuid, documentType, null);
			
			System.IO.File.Delete(fullName);

			return true;
		}