Exemple #1
0
		public DocumentInfo GetDocumentInfo(Guid documentStorageId)
		{
			using (DVSContext dc = new DVSContext())
			{
				return dc.DocumentInfos.SingleOrDefault(d => d.DocumentStorageId == documentStorageId);
			}
		}
Exemple #2
0
		public void Delete(Guid documentStorageId)
		{
			_documentStorage.DeleteDocument(documentStorageId);
			using (DVSContext dc = new DVSContext())
			{
				var tDocument = dc.DocumentInfos.SingleOrDefault(d => d.DocumentStorageId == documentStorageId);
				if (tDocument != null)
				{
					dc.DocumentInfos.Remove(tDocument);
					dc.SaveChanges();
				}
			}
		}
Exemple #3
0
		static void Main(string[] args)
		{
			DbConfigManager.SetParameters(args);
			//	Generate IMigrationMetadata.Target 
			using (var db = new DVSContext())
			{
				var st = ModelHelper.GenerateModel(db);
			}

			try
			{
				Stopwatch sw = new Stopwatch();
				sw.Start();
				Console.WriteLine("Start DVS.Database project.");

				foreach (var usedContext in DbConfigManager.UsedContexts)
				{
					DbContext dataContext;
					if (usedContext.Key == "DVSContext")
						dataContext = new DVSContext();
					else if (usedContext.Key == "TaskQueueContext")
						dataContext = new TaskQueueContext();
					else if (usedContext.Key == "LoggerContext")
						dataContext = new LoggerContext();
					else
						throw new NotSupportedException(usedContext.Key);

					if (!DbConfigManager.IsGenerateScriptOnly)
					{
						DatabaseHelper.CreatedDatabase(dataContext, usedContext.Value);

						dataContext.Database.CompatibleWithModel(true);
					}
					else
					{
						string sqlUpdate = DatabaseHelper.GenetateSqlUpdate(dataContext, usedContext.Value);
						string sqlRollback = DatabaseHelper.GenetateSqlRollback(dataContext, usedContext.Value);

						File.WriteAllText(usedContext.Key + "Update_" + usedContext.Key + ".sql", sqlUpdate + Environment.NewLine + "GO");
						//		File.WriteAllText(usedContext.Key + "Rollback_" + usedContext.Key + ".sql", sqlRollback + Environment.NewLine + "GO");
					}
				}

				sw.Stop();
				Console.WriteLine(String.Format("End at {0} s", sw.ElapsedMilliseconds / 1000));
			}
			catch (Exception ex)
			{
				Console.WriteLine(String.Format("Error [{0}], [{1}]", ex.Message, ex.ToString()));
			}
		}
		private void CreateTestDataForAscGovLicense()
		{
			using (DVSContext context = new DVSContext())
			{
				var licenses = new AscGovLicense[] { 
							new AscGovLicense(){ LicenseNumber = "1", AppraiserStateId = "NY", LicenseStateId="NY", ExpirationDate = DateTime.Now, IsStatusInactive = true, City="22"},
							new AscGovLicense(){ LicenseNumber = "1", LicenseStateId="FL", ExpirationDate = DateTime.Now.AddYears(1), IsStatusInactive = false },
							new AscGovLicense(){ LicenseNumber ="2", LicenseStateId="NY", ExpirationDate = expiredDate, IsStatusInactive = false},
							new AscGovLicense(){ LicenseNumber="3", LicenseStateId="NY", ExpirationDate= DateTime.Now.AddYears(1), IsStatusInactive = false }};

				foreach (var license in licenses)
					context.AscGovLicenses.Add(license);

				context.SaveChanges();
			}
		}
Exemple #5
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;
		}
Exemple #6
0
		public void EndTrackChanges(DbChangeTracker context)
		{
			AddModifiedEntities(_addedEntities, EntityState.Added);

			if (_changeSet.ChangeEntities.Count != 0)
			{
				string userEmail = HttpContext.Current == null || HttpContext.Current.User == null || String.IsNullOrEmpty(HttpContext.Current.User.Identity.Name) ? null : HttpContext.Current.User.Identity.Name;
				_changeSet.IpAddress = NetworkUtil.GetIP4Address();

				using (var db = new DVSContext())
				{
					var users = db.Users.Where(e => e.Email == userEmail).AsEnumerable();
					_changeSet.UserId = users.Count() > 0 ? (int?)users.Select(e => e.Id).SingleOrDefault() : null;
					db.ChangeSets.Add(_changeSet);
					db.SaveChangesInternal();
				}
			}
		}
Exemple #7
0
		public static Order CreateTestOrder(LoanType loanType = LoanType.Conventional, bool supplementalREOAddendum = false)
		{
			using (var db = new DVSContext())
			{
				Order order = new Order()
				{
					GeneralInfo = new OrderGeneralInfo()
					{
						PropertyAddress = new Address() { ZIP = "12345", State = "NY" },
					},

					AppraisalInfo = new OrderAppraisalInfo()
					{
						PropertyTypeId = 1, //Single Family Residence - Attached
						OccupancyTypeId = 1,
						AppraisalTypeId = 1,
						Rush = true,
						AppraisalForm = 1,
						LoanType = loanType,
						SupplementalREOAddendum = supplementalREOAddendum
					},

					FeeInfo = new OrderFeeInfo()
					{
						AppraisalFee = 100
					},

					DueDate = DateTime.Now.AddDays(1),
					Latitude = 42.8140,
					Longitude = -73.94,
					OrderPublicId = Guid.NewGuid().ToString().Replace("-", String.Empty).Substring(0, 20),
					CreationDate = DateTime.Now,

					OrderStatus = OrderStatus.PendingAssignment,
					CreatedByClientUserId = 1
				};
				db.Orders.Add(order);
				db.SaveChanges();


				return order;
			}
		}
		public void TaskSchedulerManager_Task_AssignmentAppraisersForOrder_Duplicates()
		{
			var testOrder = OrderServiceTest.CreateTestOrder();
			var duplicateOrder = OrderServiceTest.CreateTestOrder();

			using (var db = new DVSContext())
			{
				db.Orders.Attach(testOrder);
				db.Orders.Attach(duplicateOrder);

				testOrder.AppraisalInfo.DuplicateOrderId = duplicateOrder.Id;
				duplicateOrder.AcceptedAppraiserUserId = TestConstants.TestAppraiserUser;

				var appraiserUser = db.AppraiserUsers.Find(TestConstants.TestAppraiserUser);
				appraiserUser.ServiceArea = new AppraiserServiceArea();
				appraiserUser.ServiceArea.Longitude = 1;
				appraiserUser.ServiceArea.Latitude = 1;
				appraiserUser.ServiceArea.ServiceAreaRadiusId = 1;

				db.SaveChanges();
			}

			var taskParams = new List<TaskParam>();
			taskParams.Add(new TaskParam(TaskParamsKey.OrderId, testOrder.Id.ToString()));
			int taskId = TestTaskLifeCycleInternal(TaskTypeEnum.AssignmentAppraisersForOrder, taskParams);

			using (var dc = new TaskQueueContext())
			{
				var duplicateOrderTask = dc.Tasks.Single(e => e.ParentTaskId == taskId);
				duplicateOrderTask.Should().NotBeNull();
				duplicateOrderTask.MinStartDate.Should().HaveValue();
			}
		}
Exemple #9
0
		protected void ClearDVSContext()
		{
			using (var dc = new DVSContext())
			{
				//foreach (var item in dc.ClientUsers) dc.ClientUsers.Remove(item);
				//foreach (var item in dc.Licenses) dc.Licenses.Remove(item);
				//foreach (var item in dc.AppraiserUsers) dc.AppraiserUsers.Remove(item);
				//foreach (var item in dc.AppraisalCompanyDetails) dc.AppraisalCompanyDetails.Remove(item);
				//foreach (var item in dc.AppraisalCompanyContacts) dc.AppraisalCompanyContacts.Remove(item);
				//foreach (var item in dc.ClientCompanies) dc.ClientCompanies.Remove(item);

				//foreach (var item in dc.ClientCompanies) dc.ClientCompanies.Remove(item);
				//foreach (var item in dc.DvsUsers) dc.DvsUsers.Remove(item);
				//foreach (var item in dc.Users) dc.Users.Remove(item);
				//foreach (var item in dc.Addresses) dc.Addresses.Remove(item);


				//foreach (var item in dc.AppraiserFees) dc.AppraiserFees.Remove(item);
				//foreach (var item in dc.AppraiserOrders) dc.AppraiserOrders.Remove(item);
				//foreach (var item in dc.DocumentInfos) dc.DocumentInfos.Remove(item);
				//foreach (var item in dc.HUDAppraiserContactInfos) dc.HUDAppraiserContactInfos.Remove(item);
				//foreach (var item in dc.HUDAppraiserLicenses) dc.HUDAppraiserLicenses.Remove(item);
				//foreach (var item in dc.LenderCompanies) dc.LenderCompanies.Remove(item);
				//foreach (var item in dc.LenderUserDetails) dc.LenderUserDetails.Remove(item);
				//foreach (var item in dc.Notifications) dc.Notifications.Remove(item);
				//foreach (var item in dc.Orders) dc.Orders.Remove(item);
				//foreach (var item in dc.WidgetsConfigs) dc.WidgetsConfigs.Remove(item);
                dc.Database.ExecuteSqlCommand(@"
				declare @tblName nvarchar(100),
                @sql nvarchar(100),
                @i int,@err int
                declare tbl cursor for
                select name,
                (select COUNT(*) from sys.objects where parent_object_id=ob.object_id and schema_id=1) c
                from sys.objects ob where [type]='U' and schema_id=1 and name<>'Roles'
                order by c desc
                set @err=1
                while @err=1 
                begin
                  set @err=0
                  OPEN tbl
                  FETCH next FROM tbl
                  INTO @tblName,@i
                  WHILE @@FETCH_STATUS = 0 
                  BEGIN
                    set @sql='delete from '+ @tblName
                    begin try
                       exec (@sql)
                    end try 
                    begin catch
                       set @err=1
                    end catch
                    FETCH NEXT FROM tbl
                    INTO @tblName,@i
                  END 
                  CLOSE tbl
                end  
                DEALLOCATE tbl");

                /*
                dc.Database.ExecuteSqlCommand(@"
				delete from ClientUsers
				delete from Licenses
				delete from AppraiserUsers
				delete from AppraisalCompanyDetails
				delete from AppraisalCompanyContacts

				delete from AppraiserContacts
				delete from AppraiserServiceAreas

				delete from ClientCompanyBranches
				delete from ClientCompanies
				delete from ClientCompanyProfiles

				delete from DvsUsers
				delete from Phones
				delete from Users
				delete from Addresses");
                */
				dc.SaveChanges();
			}
		}
Exemple #10
0
		public void OrderServiceTest_AssignmentOrdersDuplicates()
		{
			var testOrder = CreateTestOrder();
			var duplicateOrder = CreateTestOrder();

			using (var db = new DVSContext())
			{
				db.Orders.Attach(testOrder);
				db.Orders.Attach(duplicateOrder);

				testOrder.AppraisalInfo.DuplicateOrderId = duplicateOrder.Id;
				duplicateOrder.AcceptedAppraiserUserId = TestConstants.TestAppraiserUser;

				db.SaveChanges();
			}

			var nextDateTime = _orderAssignmentService.AssignmentAppraisersForOrder(testOrder.Id, 0, DateTime.Now);
			nextDateTime.Should().HaveValue();

			_appraiserOrderDeliveryService.Received(1).SendOrderInvitations(
				Arg.Is<Order>(e => e.Id == testOrder.Id), Arg.Is<AppraiserUser[]>(e => e.Length == 1 && e[0].Id == TestConstants.TestAppraiserUser));
		}
Exemple #11
0
		private void AddAppraiserUser(int currentScore, double feeAmount, bool addFHASurchargeFee = false, bool addSupplementalREOAddendumFee = false)
		{
			using (var db = new DVSContext())
			{
				AppraiserUser appraiserUser = new AppraiserUser()
				{
					Status = AppraiserUserStatus.Active,
					ServiceArea = new AppraiserServiceArea()
					{
						Latitude = 42.8141F, // Distance ~ 7 mil
						Longitude = -73.94F,
						ServiceAreaRadiusId = 3 // 10 mil
					},
					User = new User()
					{
						LastName = "LastName",
						FirstName = "FirtsName",
						Email = Guid.NewGuid().ToString().Replace("-", String.Empty) + "@mail.com",
						Salt = "123",
						Roles = new Role[]
	          {
	            db.Roles.Find(1) // Appraiser
	          }
					},
					Licenses = new License[]
	        {
	          new License() { Status = LicenseStatus.Active, ExpirationDate = DateTime.Now.AddYears(1), State = "NY", LicenseNumber = "1", LicenseTypeId = 2, FHARoster = true }
	        },
					QC = new AppraiserQC()
					{
						ScoreHistory = new AppraiserScoreHistoryEntry[]
	          {
	            new AppraiserScoreHistoryEntry(){ ScoreValue = 50, ChangeDate = DateTime.Now.AddDays(-10), ChangeReasonId = 1},
	            new AppraiserScoreHistoryEntry(){ ScoreValue = currentScore, ChangeDate = DateTime.Now.AddDays(-5), ChangeReasonId = 1},
	          }
					},
					Fees = new Collection<AppraiserFee>()
					{
						new AppraiserFee { Amount = feeAmount, ProductId = 1  },
					}
				};

				if (addFHASurchargeFee)
				{
					appraiserUser.Fees.Add(new AppraiserFee { Amount = 200, ProductId = 36 });
				}
				if (addSupplementalREOAddendumFee)
				{
					appraiserUser.Fees.Add(new AppraiserFee { Amount = 200, ProductId = 37 });
				}

				db.AppraiserUsers.Add(appraiserUser);

				db.SaveChanges();
			}
		}