protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2IR_SCR_1314 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { var returnValue = new FR_Guid(); var item = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_CountingRun(); if (Parameter.LOG_WRH_INJ_InventoryJob_CountingRunID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.LOG_WRH_INJ_InventoryJob_CountingRunID); if (result.Status != FR_Status.Success || item.LOG_WRH_INJ_InventoryJob_CountingRunID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } } if (Parameter.IsDeleted == true) { item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.LOG_WRH_INJ_InventoryJob_CountingRunID)); } //Creation specific parameters (Tenant, Account ... ) if (Parameter.LOG_WRH_INJ_InventoryJob_CountingRunID == Guid.Empty) { item.Tenant_RefID = securityTicket.TenantID; } item.InventoryJob_Process_RefID = Parameter.InventoryJob_Process_RefID; item.ExecutingBusinessParticipant_RefID = Parameter.ExecutingBusinessParticipant_RefID; item.SequenceNumber = Parameter.SequenceNumber; if (Parameter.IsCounting_Started != null) { item.IsCounting_Started = Parameter.IsCounting_Started.Value; } if (Parameter.IsCounting_Completed != null) { item.IsCounting_Completed = Parameter.IsCounting_Completed.Value; } if (Parameter.IsCountingListPrinted != null) { item.IsCountingListPrinted = Parameter.IsCountingListPrinted.Value; } if (Parameter.IsDifferenceFound != null) { item.IsDifferenceFound = Parameter.IsDifferenceFound.Value; } return(new FR_Guid(item.Save(Connection, Transaction), item.LOG_WRH_INJ_InventoryJob_CountingRunID)); }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5IN_SIP_1804 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var previouslyAddedProcessShelves = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process_Shelf[0]; var processID = Parameter.InventoryProcessID; if (processID != Guid.Empty) { #region Load previously added Process Shelves previouslyAddedProcessShelves = CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process_Shelf.Query.Search(Connection, Transaction, new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process_Shelf.Query { LOG_WRH_INJ_InventoryJob_Process_RefID = Parameter.InventoryProcessID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).ToArray(); #endregion } else { #region Create new Inventory Process int processesCount = CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process.Query.Search(Connection, Transaction, new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process.Query { LOG_WRH_INJ_InventoryJob_RefID = Parameter.InventoryJobID, Tenant_RefID = securityTicket.TenantID }).Count(); var process = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process { LOG_WRH_INJ_InventoryJob_ProcessID = Guid.NewGuid(), Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID, LOG_WRH_INJ_InventoryJob_RefID = Parameter.InventoryJobID, SequenceNumber = processesCount + 1, //BookedIntoStock_ByAccount_RefID = securityTicket.TenantID, //BookedIntoStock_Date = DateTime.Now, IsBookedIntoStock = false }; process.Save(Connection, Transaction); processID = process.LOG_WRH_INJ_InventoryJob_ProcessID; #endregion #region Create counting run with Sequence Number 1 CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_CountingRun countingRun = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_CountingRun(); countingRun.LOG_WRH_INJ_InventoryJob_CountingRunID = Guid.NewGuid(); countingRun.InventoryJob_Process_RefID = process.LOG_WRH_INJ_InventoryJob_ProcessID; countingRun.IsCounting_Completed = false; countingRun.IsCounting_Started = false; countingRun.IsCountingListPrinted = false; countingRun.IsDifferenceFound = false; countingRun.SequenceNumber = 1; countingRun.Tenant_RefID = securityTicket.TenantID; countingRun.Creation_Timestamp = DateTime.Now; countingRun.IsDeleted = false; countingRun.Save(Connection, Transaction); #endregion } #region Delete removed deselected // TODO: make cross between previosly added shelves and those one that are given through Parameter's array member var previouslyAddedShelvesIDs = previouslyAddedProcessShelves.Select(x => x.LOG_WRH_Shelf_RefID).ToArray(); var intersected = previouslyAddedShelvesIDs.Intersect(Parameter.CheckedShelves); var shelvesForDeletion = previouslyAddedShelvesIDs.Except(intersected); var newShelves = Parameter.CheckedShelves.Except(intersected); if (shelvesForDeletion.Count() != 0) { foreach (var shelfID in shelvesForDeletion) { var processShelf = previouslyAddedProcessShelves.Single(x => x.LOG_WRH_Shelf_RefID == shelfID); processShelf.IsDeleted = true; processShelf.Save(Connection, Transaction); } } #endregion #region Create new process-shelf entries foreach (var newShelfID in newShelves) { var processShelf = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process_Shelf { LOG_WRH_INJ_InventoryJob_Process_ShelfID = Guid.NewGuid(), Creation_Timestamp = DateTime.Now, Tenant_RefID = securityTicket.TenantID, LOG_WRH_INJ_InventoryJob_Process_RefID = processID, LOG_WRH_Shelf_RefID = newShelfID, }; processShelf.Save(Connection, Transaction); } #endregion returnValue.Result = processID; //CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_Process_ShelfContent return(returnValue); #endregion UserCode }
protected static FR_Bool Execute(DbConnection Connection, DbTransaction Transaction, P_L5IN_UCRD_1140 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); // Get current counting run var countingRun = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_CountingRun(); countingRun.Load(Connection, Transaction, Parameter.CountingRunID); // Check is current counting run valid if (countingRun == null || countingRun.IsDeleted || countingRun.LOG_WRH_INJ_InventoryJob_CountingRunID == Guid.Empty) { throw new Exception("Bad parameter CountingRunID."); } // Get counting result values for current counting run var parameterGetCountingResult = new CL5_APOLogistic_Inventory.Atomic.Retrieval.P_L5IN_GCRfCR_1654 { CountingRunID = Parameter.CountingRunID }; var countingResultAndTrackingInstanceValues = CL5_APOLogistic_Inventory.Atomic.Retrieval.cls_Get_CountingResults_for_CountingRun.Invoke(Connection, Transaction, parameterGetCountingResult, securityTicket).Result; #region Check Counting Results // Check values bool updateCountingRuns = false; foreach (var item in countingResultAndTrackingInstanceValues) { // Check Tracking Instance if (item.LOG_WRH_INJ_CountingResult_TrackingInstanceID != Guid.Empty) { if (item.TrackingInstance_CountedAmount != item.TrackingInstance_CurrentQuantity) { var trackingInstance = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_CountingResult_TrackingInstance(); trackingInstance.Load(Connection, Transaction, item.LOG_WRH_INJ_CountingResult_TrackingInstanceID); trackingInstance.IsDifferenceToExpectedQuantityFound = true; trackingInstance.Save(Connection, Transaction); updateCountingRuns = true; } } // Check Shelf counting result if (item.LOG_WRH_INJ_InventoryJob_CountingResultID != Guid.Empty) { if (item.Shelf_CountedAmount != item.Shelf_CurrentQuantity) { var countingResult = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventryJob_CountingResult(); countingResult.Load(Connection, Transaction, item.LOG_WRH_INJ_InventoryJob_CountingResultID); countingResult.IsDifferenceToExpectedQuantityFound = true; countingResult.Save(Connection, Transaction); updateCountingRuns = true; } } } #endregion #region Counting Run Manage if (updateCountingRuns) { // Create new counting run var nextCountingRun = new CL1_LOG_WRH_INJ.ORM_LOG_WRH_INJ_InventoryJob_CountingRun(); nextCountingRun.ExecutingBusinessParticipant_RefID = countingRun.ExecutingBusinessParticipant_RefID; nextCountingRun.InventoryJob_Process_RefID = countingRun.InventoryJob_Process_RefID; nextCountingRun.SequenceNumber = 2; nextCountingRun.Tenant_RefID = securityTicket.TenantID; nextCountingRun.Save(Connection, Transaction); countingRun.IsDifferenceFound = true; countingRun.Save(Connection, Transaction); } countingRun.IsCounting_Completed = true; countingRun.Save(Connection, Transaction); #endregion return(new FR_Bool { Result = true }); #endregion UserCode }