public SystemParameterList GetGroupFamilyMedicAntecedent(ref OperationResult pobjOperationResult, int pintParentParameterId) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); var query = (from A in dbContext.systemparameter where A.i_ParameterId == pintParentParameterId && A.i_GroupId == 149 select new SystemParameterList { v_Value1 = A.v_Value1 }).FirstOrDefault(); SystemParameterList objData = query; pobjOperationResult.Success = 1; return(objData); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = ex.Message; return(null); } }
public RequestSorterTests() { this.users = new[] { new ApplicationUser { Id = Guid.NewGuid().ToString(), CommuteDistance = 2 }, new ApplicationUser { Id = Guid.NewGuid().ToString(), CommuteDistance = 4 }, new ApplicationUser { Id = Guid.NewGuid().ToString(), CommuteDistance = 6 }, new ApplicationUser { Id = Guid.NewGuid().ToString(), CommuteDistance = 8 }, new ApplicationUser { Id = Guid.NewGuid().ToString(), CommuteDistance = 10 } }; this.requests = new List <Request>(); this.allocations = new List <Allocation>(); this.reservations = new List <Reservation>(); this.systemParameter = new SystemParameterList { NearbyDistance = 4 }; }
private void grdDataHabitaciones_AfterSelectChange(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e) { if (grdDataHabitaciones.Selected.Rows.Count == 0) { return; } OperationResult objOperationResult = new OperationResult(); SystemParameterList habHospit = new SystemParameterList(); if (_mode == "NewASEGU") { #region Conexion SAM ConexionSigesoft conectasam = new ConexionSigesoft(); conectasam.opensigesoft(); #endregion var cadena1 = "select r_HospitalBedPrice from protocol where v_ProtocolId ='" + _v_ProtocoloId + "'"; SqlCommand comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft); SqlDataReader lector = comando.ExecuteReader(); string hab = "0.00"; while (lector.Read()) { hab = lector.GetValue(0).ToString(); } lector.Close(); txtPrecio.Text = double.Parse(hab).ToString("N2"); txtPrecio.Enabled = false; } else { int HabitacionId = int.Parse(grdDataHabitaciones.Selected.Rows[0].Cells["i_HabitacionId"].Value.ToString()); habHospit = _hospitalizacionBL.GetHabitaciónH(ref objOperationResult, HabitacionId); txtPrecio.Text = double.Parse(habHospit.v_Value2).ToString("N2"); } }
public SystemParameterList GetParentNameSystemParameter(ref OperationResult pobjOperationResult, string pstrValue, int pintGroupId) { //mon.IsActive = true; try { SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel(); var query = (from A in dbContext.systemparameter where A.v_Value1 == pstrValue && A.i_GroupId == pintGroupId select new SystemParameterList { i_ParentParameterId = A.i_ParentParameterId.Value, }).FirstOrDefault(); var query2 = (from A in dbContext.systemparameter where A.i_ParameterId == query.i_ParentParameterId && A.i_GroupId == pintGroupId select new SystemParameterList { v_Value1 = A.v_Value1, }).FirstOrDefault(); SystemParameterList objData = query2; pobjOperationResult.Success = 1; return(objData); } catch (Exception ex) { pobjOperationResult.Success = 0; pobjOperationResult.ExceptionMessage = ex.Message; return(null); } }
private void cboHabitación_SelectedIndexChanged(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); SystemParameterList habHospit = new SystemParameterList(); if (cboHabitación.SelectedValue == null) { return; } if (cboHabitación.SelectedValue.ToString() == "-1") { txtPrecio.Text = "."; return; } if (_mode == "NewASEGU") { #region Conexion SAM ConexionSigesoft conectasam = new ConexionSigesoft(); conectasam.opensigesoft(); #endregion var cadena1 = "select r_HospitalBedPrice from protocol where v_ProtocolId ='" + _v_ProtocoloId + "'"; SqlCommand comando = new SqlCommand(cadena1, connection: conectasam.conectarsigesoft); SqlDataReader lector = comando.ExecuteReader(); string hab = ""; while (lector.Read()) { hab = lector.GetValue(0).ToString(); } lector.Close(); txtPrecio.Text = hab; txtPrecio.Enabled = false; } else { habHospit = _hospitalizacionBL.GetHabitaciónH(ref objOperationResult, int.Parse(cboHabitación.SelectedValue.ToString())); txtPrecio.Text = habHospit.v_Value2; } }
public IReadOnlyList <Request> Sort( LocalDate date, IReadOnlyList <Request> requests, IReadOnlyList <Allocation> existingAllocations, IReadOnlyList <Reservation> reservations, SystemParameterList systemParameterList) { var requestsToSort = requests .Where(r => r.Date == date && IsNotAlreadyAllocated(r, existingAllocations)) .ToArray(); var exisingAllocationsRatios = requestsToSort.ToDictionary( r => r, r => CalculateExistingAllocationRatio(r, requests, existingAllocations, reservations)); RandomiseMissingAllocationRatios(exisingAllocationsRatios); return(requestsToSort .OrderBy(r => HasReservation(r, reservations)) .ThenBy(r => LivesFarAway(r, systemParameterList)) .ThenBy(r => exisingAllocationsRatios[r]) .ToArray()); }
private static int LivesFarAway(Request request, SystemParameterList systemParameterList) => request.ApplicationUser.CommuteDistance == null || request.ApplicationUser.CommuteDistance > systemParameterList.NearbyDistance ? 0 : 1;
private void btnMoveEPP_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); SystemParameterBL objSystemParameterBL = new SystemParameterBL(); SystemParameterList objSystemParameterList = new SystemParameterList(); TypeOfEEPList objTypeOfEEP = new TypeOfEEPList(); if (treeViewEPP.SelectedNode == null) { return; } //Si la lista temporal es null se la setea con una lista vacia if (_TempTypeOfEEPList == null) { _TempTypeOfEEPList = new List <TypeOfEEPList>(); } int ParameterId = int.Parse(treeViewEPP.SelectedNode.Name.ToString()); History.frmOtroEPP frmOtroEpp = new History.frmOtroEPP(); string OtroEpp = ""; if (ParameterId == 16) { frmOtroEpp.ShowDialog(); OtroEpp = frmOtroEpp.EppName; objSystemParameterList = objSystemParameterBL.GetParentNameSystemParameter(ref objOperationResult, frmOtroEpp.ParameterId); } else { objSystemParameterList = objSystemParameterBL.GetParentNameSystemParameter(ref objOperationResult, ParameterId); } History.frmEppPercentage frm = new History.frmEppPercentage(objSystemParameterList.v_Value1, 0); frm.ShowDialog(); if (frm.DialogResult == System.Windows.Forms.DialogResult.OK) { if (objSystemParameterList != null) { TypeOfEEPList findResult = new TypeOfEEPList(); //Busco en la lista temporal si ya se agrego el item seleccionado if (ParameterId == 16) { findResult = _TempTypeOfEEPList.Find(p => p.i_TypeofEEPId == frmOtroEpp.ParameterId); } else { findResult = _TempTypeOfEEPList.Find(p => p.i_TypeofEEPId == ParameterId); } if (findResult == null) { objTypeOfEEP.v_TypeofEEPId = Guid.NewGuid().ToString(); if (ParameterId == 16) { objTypeOfEEP.i_TypeofEEPId = frmOtroEpp.ParameterId; objTypeOfEEP.v_TypeofEEPName = OtroEpp; } else { objTypeOfEEP.i_TypeofEEPId = ParameterId; objTypeOfEEP.v_TypeofEEPName = objSystemParameterList.v_Value1; } objTypeOfEEP.r_Percentage = frm._Porcentage; objTypeOfEEP.i_RecordStatus = (int)RecordStatus.Agregado; objTypeOfEEP.i_RecordType = (int)RecordType.Temporal; _TempTypeOfEEPList.Add(objTypeOfEEP); } else { if (findResult.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { if (findResult.i_RecordType == (int)RecordType.NoTemporal)// El registro Tiene in ID de BD { findResult.i_TypeofEEPId = ParameterId; findResult.v_TypeofEEPName = objSystemParameterList.v_Value1; findResult.r_Percentage = frm._Porcentage; findResult.i_RecordStatus = (int)RecordStatus.Grabado; } else if (findResult.i_RecordType == (int)RecordType.Temporal) // El registro tiene un ID temporal [GUID] { findResult.i_TypeofEEPId = ParameterId; findResult.v_TypeofEEPName = objSystemParameterList.v_Value1; findResult.r_Percentage = frm._Porcentage; findResult.i_RecordStatus = (int)RecordStatus.Agregado; } } else { MessageBox.Show("Por favor seleccione otro item. ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } var dataList = _TempTypeOfEEPList.FindAll(p => p.i_RecordStatus != (int)RecordStatus.EliminadoLogico); // Cargar grilla grdDataEPP.DataSource = new TypeOfEEPList(); grdDataEPP.DataSource = dataList; grdDataEPP.Refresh(); } } }
private void btnMoveDanger_Click(object sender, EventArgs e) { OperationResult objOperationResult = new OperationResult(); SystemParameterBL objSystemParameterBL = new SystemParameterBL(); SystemParameterList objSystemParameterList = new SystemParameterList(); WorkstationDangersList objWorkstationDangers = new WorkstationDangersList(); if (treeViewDangers.SelectedNode == null) { return; } //Si la lista temporal es null se la setea con una lista vacia if (_TempWorkstationDangersList == null) { _TempWorkstationDangersList = new List <WorkstationDangersList>(); } int ParameterId = int.Parse(treeViewDangers.SelectedNode.Name.ToString()); History.frmOtroPeligro frmOtroPeligro = new History.frmOtroPeligro(); string OtroDangrer = ""; if (ParameterId == 35) { frmOtroPeligro.ShowDialog(); OtroDangrer = frmOtroPeligro.DangerName; objSystemParameterList = objSystemParameterBL.GetParentNameSystemParameter(ref objOperationResult, frmOtroPeligro.ParameterId, 145); } else { objSystemParameterList = objSystemParameterBL.GetParentNameSystemParameter(ref objOperationResult, ParameterId, 145); } History.frmRuidoPopup frm = new History.frmRuidoPopup(); if (objSystemParameterList != null) { WorkstationDangersList findResult = new WorkstationDangersList(); //Busco en la lista temporal si ya se agrego el item seleccionado if (ParameterId == 35) { findResult = _TempWorkstationDangersList.Find(p => p.i_DangerId == frmOtroPeligro.ParameterId); } else { findResult = _TempWorkstationDangersList.Find(p => p.i_DangerId == ParameterId); } if (findResult == null) { // Levantar popup para registrar datos propios de ruido if (ParameterId == (int)PeligrosEnElPuesto.Ruido) { frm.ShowDialog(); if (frm.DialogResult == DialogResult.Cancel) { return; } objWorkstationDangers.v_TimeOfExposureToNoise = frm.FuenteRuido; objWorkstationDangers.i_NoiseLevel = frm.NivelRuidoId; objWorkstationDangers.i_NoiseSource = frm.TiempoExposicionRuidoId; } objWorkstationDangers.v_WorkstationDangersId = Guid.NewGuid().ToString(); objWorkstationDangers.v_ParentName = objSystemParameterList.v_Value1; if (ParameterId == 35) { objWorkstationDangers.v_DangerName = OtroDangrer; objWorkstationDangers.i_DangerId = frmOtroPeligro.ParameterId; } else { objWorkstationDangers.i_DangerId = ParameterId; objWorkstationDangers.v_DangerName = treeViewDangers.SelectedNode.Text.ToString(); } objWorkstationDangers.i_RecordStatus = (int)RecordStatus.Agregado; objWorkstationDangers.i_RecordType = (int)RecordType.Temporal; _TempWorkstationDangersList.Add(objWorkstationDangers); } else { // Levantar popup para registrar datos propios de ruido if (ParameterId == (int)PeligrosEnElPuesto.Ruido) { if (findResult.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { frm.ShowDialog(); if (frm.DialogResult == DialogResult.Cancel) { return; } } else { MessageBox.Show("Por favor seleccione otro item. ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (findResult.i_RecordStatus == (int)RecordStatus.EliminadoLogico) { if (findResult.i_RecordType == (int)RecordType.NoTemporal)// El registro Tiene in ID de BD { findResult.i_DangerId = ParameterId; findResult.v_DangerName = objSystemParameterList.v_Value1; findResult.v_DangerName = treeViewDangers.SelectedNode.Text.ToString(); findResult.v_TimeOfExposureToNoise = frm.FuenteRuido; findResult.i_NoiseLevel = frm.NivelRuidoId; findResult.i_NoiseSource = frm.TiempoExposicionRuidoId; findResult.i_RecordStatus = (int)RecordStatus.Grabado; } else if (findResult.i_RecordType == (int)RecordType.Temporal) // El registro tiene un ID temporal [GUID] { findResult.i_DangerId = ParameterId; findResult.v_DangerName = objSystemParameterList.v_Value1; findResult.v_DangerName = treeViewDangers.SelectedNode.Text.ToString(); findResult.v_TimeOfExposureToNoise = frm.FuenteRuido; findResult.i_NoiseLevel = frm.NivelRuidoId; findResult.i_NoiseSource = frm.TiempoExposicionRuidoId; findResult.i_RecordStatus = (int)RecordStatus.Agregado; } } else { MessageBox.Show("Por favor seleccione otro item. ya existe", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } var dataList = _TempWorkstationDangersList.FindAll(p => p.i_RecordStatus != (int)RecordStatus.EliminadoLogico); //var peopleInOrder = people.OrderBy(person => person.LastName); // Cargar grilla grdDataDangers.DataSource = new WorkstationDangersList(); grdDataDangers.DataSource = dataList; grdDataDangers.Refresh(); } }
public void UpdateSystemParameterList(SystemParameterList updated) => throw new NotImplementedException();
public void Test_Get() { // Arrange var firstDate = 6.November(2018); var lastDate = 7.November(2018); var activeDates = new[] { firstDate, lastDate }; var principal = new ClaimsPrincipal(); var loggedInUser = new ApplicationUser { FirstName = "Colm", LastName = "Wilkinson" }; var otherUser = new ApplicationUser { FirstName = "Philip", LastName = "Quast" }; var applicationUsers = new[] { loggedInUser, otherUser }; var systemParameterList = new SystemParameterList { ReservableSpaces = 3 }; // Set up mock date calculator var mockDateCalculator = new Mock <IDateCalculator>(MockBehavior.Strict); mockDateCalculator .Setup(d => d.GetActiveDates()) .Returns(activeDates); // Set up reservation repository var mockReservationRepository = new Mock <IReservationRepository>(MockBehavior.Strict); mockReservationRepository .Setup(r => r.GetReservations(firstDate, lastDate)) .Returns( new[] { new Reservation { ApplicationUser = loggedInUser, Date = firstDate, Order = 0 }, new Reservation { ApplicationUser = otherUser, Date = firstDate, Order = 1 }, new Reservation { ApplicationUser = otherUser, Date = lastDate, Order = 0 } }); // Set up system parameter list repository var mockSystemParameterListRepository = new Mock <ISystemParameterListRepository>(MockBehavior.Strict); mockSystemParameterListRepository .Setup(p => p.GetSystemParameterList()) .Returns(systemParameterList); // Set up user manager var mockUserManager = TestHelpers.CreateMockUserManager(principal, loggedInUser); mockUserManager .SetupGet(u => u.Users) .Returns(applicationUsers.AsQueryable()); // Act var model = new EditReservationsModel( mockDateCalculator.Object, mockSystemParameterListRepository.Object, mockReservationRepository.Object, mockUserManager.Object) { PageContext = { HttpContext = new DefaultHttpContext { User = principal } } }; model.OnGet(); // Assert Assert.NotNull(model.Calendar); Assert.Single(model.Calendar.Weeks); Assert.Equal(5.November(2018), model.Calendar.Weeks[0].Days[0].Date); Assert.Equal(activeDates, model.Calendar.ActiveDates()); var expectedSelectedUserIds = new Dictionary <LocalDate, IReadOnlyList <string> > { { firstDate, new[] { loggedInUser.Id, otherUser.Id, null } }, { lastDate, new[] { otherUser.Id, null, null } } }; foreach (var activeDate in activeDates) { Assert.NotNull(model.Calendar.Data(activeDate).SpaceReservations); Assert.Equal(systemParameterList.ReservableSpaces, model.Calendar.Data(activeDate).SpaceReservations.Count); for (var order = 0; order < model.Calendar.Data(activeDate).SpaceReservations.Count; order++) { var spaceReservation = model.Calendar.Data(activeDate).SpaceReservations[order]; var expectedDisplayValues = new[] { $"Space {order + 1}", otherUser.FullName, loggedInUser.FullName }; var expectedKeys = new[] { $"{activeDate.ForRoundTrip()}|{order}|", $"{activeDate.ForRoundTrip()}|{order}|{otherUser.Id}", $"{activeDate.ForRoundTrip()}|{order}|{loggedInUser.Id}" }; Assert.Equal(expectedDisplayValues, spaceReservation.Options.Select(d => d.DisplayValue)); Assert.Equal(expectedKeys, spaceReservation.Options.Select(d => d.Key)); var expectedSelectedUserId = expectedSelectedUserIds[activeDate][order]; foreach (var displayReservation in spaceReservation.Options) { var expectedIsSelected = expectedSelectedUserId != null && displayReservation.Key.EndsWith(expectedSelectedUserId); Assert.Equal(expectedIsSelected, displayReservation.IsSelected); } } } }
public static void Test_Create(TestData testData) { var allocationDate = 26.February(2018); var otherUsers = new[] { new ApplicationUser { Id = Guid.NewGuid().ToString() }, new ApplicationUser { Id = Guid.NewGuid().ToString() } }; var otherDateRequests = new[] { new Request { Date = 25.February(2018), ApplicationUser = otherUsers[0] }, new Request { Date = 27.February(2018), ApplicationUser = otherUsers[1] } }; var otherDateReservations = new[] { new Reservation { Date = 25.February(2018), ApplicationUser = otherUsers[0] }, new Reservation { Date = 27.February(2018), ApplicationUser = otherUsers[1] } }; var otherDateAllocations = new[] { new Allocation { Date = 25.February(2018), ApplicationUser = otherUsers[0] }, new Allocation { Date = 27.February(2018), ApplicationUser = otherUsers[1] } }; // Arrange var users = Enumerable .Range(0, testData.TotalUsers) .Select(x => new ApplicationUser { Id = Guid.NewGuid().ToString() }) .ToArray(); var newRequests = Enumerable .Range(0, testData.TotalNewRequests) .Select(x => new Request { ApplicationUser = users[x], Date = allocationDate }) .ToArray(); var alreadyAllocatedRequests = Enumerable .Range(testData.TotalNewRequests, testData.TotalAlreadyAllocatedRequests) .Select(x => new Request { ApplicationUser = users[x], Date = allocationDate }) .ToArray(); var existingAllocations = Enumerable .Range(testData.TotalNewRequests, testData.TotalAlreadyAllocatedRequests) .Select(x => new Allocation { ApplicationUser = users[x], Date = allocationDate }) .Concat(otherDateAllocations) .ToArray(); var allRequests = newRequests .Concat(alreadyAllocatedRequests) .Concat(otherDateRequests) .ToArray(); var reservations = testData.UsersWithReservations .Select(i => new Reservation { ApplicationUser = users[i], Date = allocationDate }) .Concat(otherDateReservations) .ToArray(); var systemParameter = new SystemParameterList { ReservableSpaces = testData.ReservableSpaces, TotalSpaces = testData.TotalSpaces }; var mockSorter = new Mock <IRequestSorter>(MockBehavior.Strict); var sortedRequests = testData.SortOrder.Select(o => newRequests[o]).ToArray(); mockSorter .Setup(s => s.Sort(allocationDate, allRequests, existingAllocations, reservations, systemParameter)) .Returns(sortedRequests); var expectedAllocatedRequests = sortedRequests .Take(testData.TotalExpectedAllocations) .ToArray(); // Act var singleDayAllocationCreator = new SingleDayAllocationCreator(mockSorter.Object); var result = singleDayAllocationCreator.Create( allocationDate, allRequests, reservations, existingAllocations, systemParameter, testData.ShortLeadTime); // Assert Assert.Equal(expectedAllocatedRequests.Length, result.Count); foreach (var expectedAllocatedRequest in expectedAllocatedRequests) { Assert.NotNull(result.SingleOrDefault(a => a.ApplicationUser == expectedAllocatedRequest.ApplicationUser && a.Date == expectedAllocatedRequest.Date)); } }
public static void Test_Create() { // Arrange var shortLeadTimeAllocationDates = new[] { 27.February(2018), 28.February(2018) }; var longLeadTimeAllocationDates = new[] { 1.March(2018), 2.March(2018) }; var mockDateCalculator = new Mock <IDateCalculator>(MockBehavior.Strict); mockDateCalculator .Setup(d => d.GetShortLeadTimeAllocationDates()) .Returns(shortLeadTimeAllocationDates); mockDateCalculator .Setup(d => d.GetLongLeadTimeAllocationDates()) .Returns(longLeadTimeAllocationDates); var firstDate = 29.December(2017); // 60 days before first short lead time allocation date var lastDate = 2.March(2018); var requests = new[] { new Request { Date = 27.February(2018) }, new Request { Date = 27.February(2018) }, new Request { Date = 3.January(2018) }, new Request { Date = 1.March(2018) } }; var mockRequestRepository = new Mock <IRequestRepository>(MockBehavior.Strict); mockRequestRepository .Setup(r => r.GetRequests(firstDate, lastDate)) .Returns(requests); var reservations = new[] { new Reservation { Date = 27.February(2018) }, new Reservation { Date = 27.February(2018) }, new Reservation { Date = 22.February(2018) }, new Reservation { Date = 13.January(2018) } }; var mockReservationRepository = new Mock <IReservationRepository>(MockBehavior.Strict); mockReservationRepository .Setup(r => r.GetReservations(firstDate, lastDate)) .Returns(reservations); var originalExistingAllocations = new[] { new Allocation { Date = 27.February(2018) }, new Allocation { Date = 27.February(2018) }, new Allocation { Date = 31.December(2017) } }; var mockAllocationRepository = new Mock <IAllocationRepository>(MockBehavior.Strict); mockAllocationRepository .Setup(a => a.GetAllocations(firstDate, lastDate)) .Returns(originalExistingAllocations); var systemParameterList = new SystemParameterList(); var mockSystemParameterListRepository = new Mock <ISystemParameterListRepository>(MockBehavior.Strict); mockSystemParameterListRepository.Setup(s => s.GetSystemParameterList()).Returns(systemParameterList); var newAllocations = shortLeadTimeAllocationDates .Concat(longLeadTimeAllocationDates) .SelectMany(d => new[] { new Allocation { Date = d }, new Allocation { Date = d } }) .ToArray(); var mockSingleDayAllocationCreator = new Mock <ISingleDayAllocationCreator>(MockBehavior.Strict); foreach (var date in shortLeadTimeAllocationDates.Concat(longLeadTimeAllocationDates)) { mockSingleDayAllocationCreator .Setup(c => c.Create( date, requests, reservations, It.Is(ExpectedExistingAllocations(originalExistingAllocations, newAllocations, date)), systemParameterList, shortLeadTimeAllocationDates.Contains(date))) .Returns(newAllocations.Where(a => a.Date == date).ToArray()); } mockAllocationRepository .Setup(a => a.AddAllocations(It.IsAny <IReadOnlyList <Allocation> >())); // Act var result = new AllocationCreator( mockRequestRepository.Object, mockReservationRepository.Object, mockAllocationRepository.Object, mockSystemParameterListRepository.Object, mockDateCalculator.Object, mockSingleDayAllocationCreator.Object).Create(); // Assert Assert.Equal(newAllocations, result); mockAllocationRepository.Verify(r => r.AddAllocations(newAllocations), Times.Once); }