public void TestFakeStoredProc() { Reset(); UploadTestFile(); var adminService = new Mock <IAdminService>(); UploadQueueVMDC uploadRecord = GetUploadRecord(); adminService.Setup(x => x.CreateUploadQueue(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <UploadQueueDC>())).Returns(uploadRecord); adminService.Setup(x => x.GetUploadQueue(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>())).Returns(uploadRecord); QueueManager qMgr = new QueueManager(adminService.Object); var mockHandler = new Mock <IExceptionHandler>(); BatchUploadService svc = new BatchUploadService(new DocumentUploadService(), qMgr, mockHandler.Object, new DataStoreFactory()); BatchDetails batchDetails = new BatchDetails(dbConnectionString, replacementFileName, tempTableName, appId, "NoSuchProc", user); String guid = svc.QueueBatch(batchDetails); Assert.IsTrue(svc.CheckStatus(new Guid(guid), user) == UploadStatus.Running); Thread.Sleep(1 * 1000); // Give the thread a chance to run // Ensure one error logged adminService.Verify(x => x.CreateUploadErrorLog(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <UploadErrorLogDC>()), Times.Once()); // Ensure queue emptied Assert.AreEqual(0, svc.GetQueueSize()); // Ensure test file deleted CheckTestFileDeleted(); }
// public List <BatchHistoryListView> GetBatchDetails(out BatchDetails Details) { List <BatchHistoryListView> BatchHistoryList = new List <BatchHistoryListView>(); try { foreach (var item in _collectionView.AsEnumerable()) { iCount = _collectionView.Count; CalculateTotalSum(item); BatchHistoryList.Add(GetIndividualCollectionDetails(item)); _details.WeekEndDate = item.WeekEndDate; } if (_details.VTPSum != 0) { _details.dPayoutSum = (((Convert.ToDecimal(_details.VTPSum) - _details.WinLossSum)) / Convert.ToDecimal(_details.VTPSum)) * 100; } else { _details.dPayoutSum = 0; } //_details.dPayoutSum = _details.PayoutSum / iCount; _details.dHoldSum = _details.dPayoutSum / iCount; if (_details.VTPSum == 0) { _details.PayoutSum = 0; _details.HoldSum = 100; } } catch (Exception ex) { LogError(ex); } Details = _details; return(BatchHistoryList.ToList()); }
public void TestNoTempFile() { try { var adminService = new Mock <IAdminService>(); UploadQueueVMDC uploadRecord = new UploadQueueVMDC(); uploadRecord.UploadQueueItem = new UploadQueueDC(); uploadRecord.UploadQueueItem.Status = "C"; adminService.Setup(x => x.GetUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Returns(uploadRecord); adminService.Setup(x => x.CreateUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <UploadQueueDC>())).Returns(uploadRecord); var mockHandler = new Mock <IExceptionHandler>(); var mockBatchUploadFactory = new Mock <IDataStoreFactory>(); BatchUploadService svc = new BatchUploadService(new DocumentUploadService(), new QueueManager(adminService.Object), mockHandler.Object, mockBatchUploadFactory.Object); BatchDetails batchDetails = new BatchDetails(dbConnectionString, "NoSuchFile", tempTableName, appId, null, user); String guid = svc.QueueBatch(batchDetails); // Ensure one error logged mockHandler.Verify(x => x.ShieldException(It.IsAny <UploadConfigurationException>()), Times.Once()); // Ensure queue emptied Assert.AreEqual(0, svc.GetQueueSize()); } catch (Exception e) { String sr = e.Message; Assert.Fail(e.Message); } }
void AddRecords(string BatchNo) { try { BatchDetails newBatch = null; newBatch = (from u in m_originalBatchList where (u.BatchNo.Equals(BatchNo, StringComparison.CurrentCultureIgnoreCase)) select u).FirstOrDefault(); if (newBatch != null) { if (IsRequestedQtyGreaterThanTotalQty(m_RequestedQty)) { MessageBox.Show(Common.GetMessage("INF0062"), Common.GetMessage("10001"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { newBatch.RequestedQty = Convert.ToInt32(m_RequestedQty); m_BatchList.Add(newBatch); } } BindGrid(); } catch (Exception ex) { throw ex; } }
private void cmbMfgBatch_SelectedIndexChanged(object sender, EventArgs e) { try { if (m_originalBatchList != null) { if (m_originalBatchList.Count > 0) { string BatchNo = cmbMfgBatch.SelectedValue.ToString(); BatchDetails batchdetail = null; batchdetail = (from u in m_originalBatchList where (u.BatchNo.Equals(BatchNo, StringComparison.CurrentCultureIgnoreCase)) select u).FirstOrDefault(); if (batchdetail != null) { lblDisplayExpDate.Text = batchdetail.ExpDate; lblDisplayMfgDate.Text = batchdetail.MfgDate; lblDisplayMRP.Text = batchdetail.MRP; } } } } catch (Exception) { throw; } }
public String QueueBatch(BatchDetails batchDetails) { try { // Make sure no other processing running on this file name CheckUniqueRun(batchDetails); // Check that the temp file exists CheckFileExists(batchDetails); // Save new details row in database, generate GUID into batch details Guid processId = PersistQueue(batchDetails); // Add completion callback to batchUploader BackgroundWorker batchUploader = new BackgroundWorker(); batchUploader.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); batchUploaders.Add(batchDetails.ProcessId, new BatchUploader(batchUploader, batchDetails, dataStoreFactory.CreateDataStore(), documentUploadService)); // NB this starts the background thread return(processId.ToString()); } catch (Exception e) { exceptionHandler.ShieldException(e); return(null); } }
private BatchDetails GetBatchDetails(Guid processId, String user) { BatchDetails item = queueManager.GetBatchDetails(processId, user); if (item == null) { exceptionHandler.ShieldException(new ArgumentOutOfRangeException(String.Format("Batch with ID {0} does not exist", processId))); } return(item); }
public void TestQueueOfThreadsWithFailure() { Reset(); var adminService = new Mock <IAdminService>();//new AdminService.AdminServiceClient(); adminService.Setup(x => x.GetUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Callback(QueueUploadRecord); adminService.Setup(x => x.CreateUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <UploadQueueDC>())).Callback(AddToList); adminService.Setup(x => x.CreateUploadErrorLog(user, user, It.IsAny <String>(), "", It.IsAny <UploadErrorLogDC>())).Callback(SetErrorMessage); BatchUploadService svc = GetService(adminService); // Start a number of batch threads Guid[] guids = new Guid[5]; try { for (i = 0; i < 5; i++) { String tempFileName = "C:\\Temp\\Test" + i + "File.xls"; UploadTestFile(tempFileName); // Mock the admin service per call UploadQueueVMDC record = GetUploadRecord(); adminService.Setup(x => x.CreateUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <UploadQueueDC>())).Returns(record); adminService.Setup(x => x.GetUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Returns(record); BatchDetails batchDetails = new BatchDetails(dbConnectionString, tempFileName, tempTableName, appId, null, user); batchDetails.PostProcessing = Break; guids[i] = new Guid(svc.QueueBatch(batchDetails)); Assert.IsTrue(svc.CheckStatus(guids[i], user) == UploadStatus.Running); } } catch (Exception e) { throw e; } Thread.Sleep(5 * 1000); // Allow a bit of time for threads to all finish Assert.AreEqual(errors.Count, 5, "Wrong number of errors stored in queue"); for (int count = 0; count < 5; count++) { // OK all the errors are the same but we are at least checking that there are 5 adminService.Setup(x => x.GetUploadErrorLog(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Returns(errors[count]); Assert.AreEqual(svc.GetErrorMessage(guids[count], user), "Test Error Message"); CheckTestFileDeleted("C:\\Temp\\Test" + count + "File.xls"); } // Ensure all threads removed from queue Assert.AreEqual(svc.GetQueueSize(), 0); }
private void CheckFileExists(BatchDetails batchDetails) { if (!documentUploadService.FileExists(batchDetails.FileName)) { if (batchDetails.ProcessId != null) { // Get rid of this record queueManager.UpdateQueue(batchDetails.ProcessId, UploadStatus.Failed, batchDetails.CurrentUser); queueManager.AddErrorMessage(batchDetails.ProcessId, String.Format("Batch {0} cannot run. File {0} has been deleted", batchDetails.ProcessId, batchDetails.FileName), batchDetails.CurrentUser); } throw new UploadConfigurationException(String.Format("File {0} for batch {1} does not exist", batchDetails.FileName, batchDetails.ProcessId)); } }
public void TestQueueOfThreads() { Reset(); working = true; var adminService = new Mock <IAdminService>();//new AdminService.AdminServiceClient(); adminService.Setup(x => x.GetUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Callback(QueueUploadRecord); adminService.Setup(x => x.CreateUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <UploadQueueDC>())).Callback(AddToList); adminService.Setup(x => x.CreateUploadErrorLog(user, user, It.IsAny <String>(), "", It.IsAny <UploadErrorLogDC>())).Callback(SetErrorMessage); BatchUploadService svc = GetService(adminService); // Start a number of batch threads, add new DoWork method to each that will wait until we set a local variable to TRUE Guid[] guids = new Guid[5]; try { for (i = 0; i < 5; i++) { String tempFileName = "C:\\Temp\\Test" + i + "File.xls"; UploadTestFile(tempFileName); // Mock the admin service per call UploadQueueVMDC record = GetUploadRecord(); adminService.Setup(x => x.CreateUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <UploadQueueDC>())).Returns(record); adminService.Setup(x => x.GetUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Returns(record); BatchDetails batchDetails = new BatchDetails(dbConnectionString, tempFileName, tempTableName, appId, null, user); batchDetails.PostProcessing = WaitForStopWorking; guids[i] = new Guid(svc.QueueBatch(batchDetails)); Assert.IsTrue(svc.CheckStatus(guids[i], user) == UploadStatus.Running); } } catch (Exception e) { throw e; } finally { working = false; } Thread.Sleep(6 * 1000); // Allow time for all waiting threads to wake up and find out that they can stop working for (int count = 0; count < 5; count++) { CheckTestFileDeleted("C:\\Temp\\Test" + count + "File.xls"); } // Ensure all threads removed from queue Assert.AreEqual(svc.GetQueueSize(), 0); }
public ActionResult Index() { var lst = _db.tblMasterAcademicDetails.Select(m => m.BatchNo).Distinct(); List <BatchDetails> str = new List <BatchDetails>(); foreach (int item in lst) { BatchDetails bt = new BatchDetails(); bt.BatchNo = item; str.Add(bt); } ViewBag.BatchList = str; return(View()); }
private void CheckUniqueRun(BatchDetails batchDetails) { lock (batchUploadLock) { foreach (BatchUploader runner in batchUploaders.Values) { // Case where we can't start another if (runner.BatchDetails.FileName.Equals(batchDetails.FileName)) { throw new UploadConfigurationException(String.Format("A request for batch {0} is already queued", batchDetails.FileName)); } } } }
public void TestBatchUpload() { try { Reset(); UploadTestFile(); var adminService = new Mock <IAdminService>(); UploadQueueVMDC uploadRecord = new UploadQueueVMDC(); uploadRecord.UploadQueueItem = new UploadQueueDC(); uploadRecord.UploadQueueItem.Status = "C"; adminService.Setup(x => x.GetUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <String>())).Returns(uploadRecord); adminService.Setup(x => x.CreateUploadQueue(user, user, It.IsAny <String>(), "", It.IsAny <UploadQueueDC>())).Returns(uploadRecord); BatchUploadService svc = GetService(adminService); BatchDetails batchDetails = new BatchDetails(dbConnectionString, replacementFileName, tempTableName, appId, null, user); working = true; batchDetails.PostProcessing = WaitForStopWorking; String guid; try { guid = svc.QueueBatch(batchDetails); } catch (Exception e) { throw e; } finally { working = false; } // Wait for waiters to wake up Thread.Sleep(5 * 1000); Assert.IsTrue(svc.CheckStatus(new Guid(guid), user) == UploadStatus.Processed, "File upload did not complete"); Assert.AreEqual(errors.Count, 0); // Ensure temporary file has been deleted and queue emptied CheckTestFileDeleted(); Assert.AreEqual(0, svc.GetQueueSize()); } catch (Exception e) { String sr = e.Message; Assert.Fail(e.Message); } }
public async Task <IActionResult> UpdateBatchDetails([FromBody] BatchDetails objbatchDetails) { try { objbatchDetails.ModifiedBy = "Admin"; objbatchDetails.ModifiedDate = DateTime.Now; db.Entry(objbatchDetails).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); return(Ok(objbatchDetails)); } catch (Exception ex) { return(BadRequest()); } }
public Guid Queue(BatchDetails batchDetails) { UploadQueueDC dc = new UploadQueueDC(); dc.ApplicationCode = batchDetails.AppId; dc.ConnectionString = batchDetails.DatabaseConnectionString; dc.TempTableName = batchDetails.TableName; dc.StoredProcedure = batchDetails.StoredProcedure; dc.UploadFileName = batchDetails.FileName; dc.Status = "R"; UploadQueueVMDC result = uploadQueueManager.CreateUploadQueue(batchDetails.CurrentUser, batchDetails.CurrentUser, appID, "", dc); batchDetails.ProcessId = result.UploadQueueItem.Code; return(result.UploadQueueItem.Code); }
public List <BatchDetails> GetBatchDetails() { Dictionary <string, MySqlParameter> Parameter = new Dictionary <string, MySqlParameter>(); DataTable dt = _GenClassnew.ExecuteQuery("SP_GetBatchDetails", Parameter); List <BatchDetails> BatchDetails = new List <BatchDetails>(); foreach (DataRow row in dt.Rows) { BatchDetails BD = new BatchDetails(); BD.ID = row.Field <int>("ID"); BD.BatchName = row.Field <string>("BatchName"); BD.BatchName = row.Field <string>("BatchName") + " (" + row.Field <string>("Timings") + ")"; BD.Timings = row.Field <string>("Timings"); BatchDetails.Add(BD); } return(BatchDetails); }
public BatchDetails GetBatchDetails(Guid batchDetailsId, String user) { UploadQueueVMDC uploadRecord = uploadQueueManager.GetUploadQueue(user, user, appID, "", batchDetailsId.ToString()); if (uploadRecord != null) { // TODO use AutoMapper and VMDC object here?? What does a BatchDetails give me? BatchDetails batchDetails = new BatchDetails(uploadRecord.UploadQueueItem.ConnectionString, uploadRecord.UploadQueueItem.UploadFileName, uploadRecord.UploadQueueItem.TempTableName, batchDetailsId, uploadRecord.UploadQueueItem.StoredProcedure, user); return(batchDetails); } return(null); }
private EnterpriseEventCacheDataRequest GetInvalidCacheRequestData() { BatchDetails linkBatchDetails = new BatchDetails() { Href = @"http://tempuri.org.uk/batch/7b4cdb10-ddfd-4ed6-b2be-d1543d8b7272" }; BatchStatus linkBatchStatus = new BatchStatus() { Href = @"http://tempuri.org.uk/batch/7b4cdb10-ddfd-4ed6-b2be-d1543d8b7272/status" }; Get linkGet = new Get() { Href = @"http://tempuri.org.uk/batch/7b4cdb10-ddfd-4ed6-b2be-d1543d8b7272/files/exchangeset123.zip", }; CacheLinks links = new CacheLinks() { BatchDetails = linkBatchDetails, BatchStatus = linkBatchStatus, Get = linkGet }; return(new EnterpriseEventCacheDataRequest { Links = links, BusinessUnit = "ABC", Attributes = new List <Attribute> { new Attribute { Key = "Agency", Value = "DE" }, new Attribute { Key = "CellName", Value = "DE416050" }, new Attribute { Key = "EditionNumber", Value = "2" }, new Attribute { Key = "UpdateNumber", Value = "0" }, new Attribute { Key = "ProductCode", Value = "DEF" } }, BatchId = "d6cd4d37-4d89-470d-9a33-82b3d7f54b6e", BatchPublishedDate = DateTime.UtcNow }); }
public async Task <IActionResult> CreateBatchDetails([FromBody] BatchDetails objbatchDetails) { try { //bannerMaster.EnquiryID = 0; objbatchDetails.CreatedBy = "Admin"; objbatchDetails.CreatedDate = DateTime.Now; objbatchDetails.ModifiedBy = "Admin"; objbatchDetails.ModifiedDate = DateTime.Now; objbatchDetails.Active = true; db.batchDetails.Add(objbatchDetails); db.SaveChanges(); return(Ok(objbatchDetails)); } catch (Exception ex) { return(BadRequest()); } }
/// <summary> /// Creates a BatchUploader and starts the background worker thread using the given batch details /// </summary> /// <param name="worker">Background thread to start</param> /// <param name="batchDetails">Database and file details required to do work</param> public BatchUploader(BackgroundWorker worker_, BatchDetails batchDetails_, IDataStore dataStore_, IDocumentUploadService documentUploadService_) { batchUploader = worker_; BatchDetails = batchDetails_; dataStore = dataStore_; documentUploadService = documentUploadService_; batchUploader.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); batchUploader.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); batchUploader.DoWork += new DoWorkEventHandler(DoWork); batchUploader.WorkerReportsProgress = true; batchUploader.WorkerSupportsCancellation = true; Percentage = 0; batchUploader.RunWorkerAsync(); }
public MVCModels.BatchDetails GetBatchForDoctors(string DoctorCode, string DoctorRegion, string Region_Code, string TpDate) { MVCModels.BatchDetails lst = new BatchDetails(); try { using (IDbConnection connection = IDbOpenConnection()) { var p = new DynamicParameters(); p.Add("@DoctorCode", DoctorCode); p.Add("@DoctorRegion", DoctorRegion); p.Add("@Region_Code", Region_Code); p.Add("@TpDate", TpDate); var mullist = connection.QueryMultiple("Sp_hd_TP_BatchDoctorDetails", p, commandType: CommandType.StoredProcedure); lst.current = mullist.Read <MVCModels.BatchInfo>().ToList(); lst.previous = mullist.Read <MVCModels.BatchInfo>().ToList(); lst.future = mullist.Read <MVCModels.BatchInfo>().ToList(); } } catch (Exception ex) { throw ex; } return(lst); }
public List <Transport.BatchHistoryListView> GetBatchDetails(out BatchDetails details) { return(_batchHistoryBreakdown.GetBatchDetails(out details)); }
public List <ViewStockIn> ViewStockIn() { List <Stock> StockInList = new List <Stock>(); List <ViewStockIn> viewStockIns = new List <ViewStockIn>(); using (var connection = new SqlConnection(sqlConnectionString)) { connection.Open(); StockInList = connection.Query <Stock>("Select * from StockMaster").OrderBy(t => t.AddedOn).ToList(); foreach (var item in StockInList) { ViewStockIn viewStockInDetails = new ViewStockIn(); string[] BatchId = item.BatchIdFromMobile.Split(','); List <Batch> batch = new List <Batch>(); foreach (var batchIds in BatchId) { viewStockInDetails.Batch = new List <BatchDetails>(); var currentBatchDetails = connection.Query <BatchDetails>("Select * from BatchMaster where BID = @value", new { value = batchIds }).FirstOrDefault(); BatchDetails tempBatchDetails = new BatchDetails(); tempBatchDetails.BID = currentBatchDetails.BID; tempBatchDetails.BatchName = currentBatchDetails.BatchName; tempBatchDetails.Esl = currentBatchDetails.Esl; tempBatchDetails.Quantity = currentBatchDetails.Quantity; tempBatchDetails.WarehouseID = currentBatchDetails.WarehouseID; tempBatchDetails.AvailableQuantity = currentBatchDetails.AvailableQuantity; tempBatchDetails.SampleSentQty = currentBatchDetails.SampleSentQty; tempBatchDetails.MFGDate = currentBatchDetails.MFGDate; tempBatchDetails.EXPDate = currentBatchDetails.EXPDate; tempBatchDetails.Esl = currentBatchDetails.Esl; viewStockInDetails.Batch.Add(tempBatchDetails); } var currentProduct = connection.Query <ProductListNew>("Select * from ProductMaster_New where Id = @value", new { value = item.ProductId }).FirstOrDefault(); viewStockInDetails.ProductName = currentProduct.VarietyName; var currentCategory = connection.Query <CategoryType>("Select * from CategoryType where ID = @value", new { value = currentProduct.CatTypeId }).FirstOrDefault(); viewStockInDetails.CategoryName = currentCategory.Type; viewStockInDetails.LotBatchId = item.BatchIdFromMobile; viewStockInDetails.ProductId = item.ProductId; viewStockInDetails.Description = item.Remarks; viewStockInDetails.DateOfReceipt = item.RecievedOn; viewStockInDetails.CRVNo = item.CRVNo; viewStockInDetails.Quantity = item.Quantity; viewStockInDetails.AccountingUnit = currentProduct.Unit; viewStockInDetails.OrignalManufacture = item.OriginalManf; viewStockInDetails.packaging = item.PackingMaterial; viewStockInDetails.supplier = item.SupplierNo; viewStockInDetails.weight = item.Weight; viewStockInDetails.Remarks = item.Remarks; if (item.IsCP == true) { viewStockInDetails.CPLPNumber = "CP-" + item.Remarks; } if (item.IsLP == true) { viewStockInDetails.CPLPNumber = "LP-" + item.Remarks; } if (item.IsLT == true) { viewStockInDetails.CPLPNumber = "LT-" + item.Remarks; } if (item.IsIDT == true) { viewStockInDetails.IDTICTNumber = "IDT-" + item.Remarks; } if (item.IsICT == true) { viewStockInDetails.IDTICTNumber = "ICT-" + item.Remarks; } viewStockIns.Add(viewStockInDetails); } connection.Close(); } return(viewStockIns); }
private Guid PersistQueue(BatchDetails batchDetails) { return(queueManager.Queue(batchDetails)); }
public List <ViewStockOut> ViewStockOut() { List <ViewStockOut> StockOutList = new List <ViewStockOut>(); List <ViewStockOut> StockOutItem = new List <ViewStockOut>(); using (var connection = new SqlConnection(sqlConnectionString)) { connection.Open(); StockOutList = connection.Query <ViewStockOut>("Select * from StockOutMaster").ToList(); foreach (var item in StockOutList) { ViewStockOut viewStockOutDetails = new ViewStockOut(); BatchDetails batchDetails = new BatchDetails(); int BID = item.BatchId; // List<Batch> batch = new List<Batch>(); var currentBatchDetails = connection.Query <BatchDetails>("Select * from BatchMaster where BID = @BID", new { BID = BID }).FirstOrDefault(); BatchDetails tempBatchDetails = new BatchDetails(); viewStockOutDetails.Batch = new List <BatchDetails>(); tempBatchDetails.BID = currentBatchDetails.BID; tempBatchDetails.BatchName = currentBatchDetails.BatchName; tempBatchDetails.Esl = currentBatchDetails.Esl; tempBatchDetails.Quantity = currentBatchDetails.Quantity; tempBatchDetails.WarehouseID = currentBatchDetails.WarehouseID; tempBatchDetails.AvailableQuantity = currentBatchDetails.AvailableQuantity; tempBatchDetails.SampleSentQty = currentBatchDetails.SampleSentQty; tempBatchDetails.MFGDate = currentBatchDetails.MFGDate; tempBatchDetails.EXPDate = currentBatchDetails.EXPDate; tempBatchDetails.Esl = currentBatchDetails.Esl; viewStockOutDetails.Batch.Add(tempBatchDetails); var currentProduct = connection.Query <ProductListNew>("Select * from ProductMaster_New where Id = @value", new { value = item.ProductId }).FirstOrDefault(); viewStockOutDetails.ProductName = currentProduct.VarietyName; var currentCategory = connection.Query <CategoryType>("Select * from CategoryType where ID = @value", new { value = currentProduct.CatTypeId }).FirstOrDefault(); viewStockOutDetails.CategoryName = currentCategory.Type; // viewStockOutDetails.BatchId = item.BatchId; viewStockOutDetails.BatchName = currentBatchDetails.BatchName; viewStockOutDetails.ProductId = item.ProductId; viewStockOutDetails.Remarks = item.Remarks; viewStockOutDetails.Quantity = item.Quantity; viewStockOutDetails.DateofDispatch = item.DateofDispatch; viewStockOutDetails.StockType = item.StockType; viewStockOutDetails.VoucherNumber = item.VoucherNumber; viewStockOutDetails.AccountingUnit = currentProduct.Unit; if (item.IsAWS == true) { viewStockOutDetails.IDTReferenceNumber = "AWS-" + item.Remarks; } if (item.IsICT == true) { viewStockOutDetails.IDTReferenceNumber = "ICT-" + item.Remarks; } if (item.IsIDT == true) { viewStockOutDetails.IDTReferenceNumber = "IDT-" + item.Remarks; } StockOutItem.Add(viewStockOutDetails); } connection.Close(); } return(StockOutItem); }
public List <AvailableStock> AvailableStock() { List <Stock> StockInList = new List <Stock>(); List <AvailableStock> viewStockIns = new List <AvailableStock>(); using (var connection = new SqlConnection(sqlConnectionString)) { connection.Open(); StockInList = connection.Query <Stock>("Select * from StockMaster").ToList(); List <int> productIds = new List <int>(); foreach (var item in StockInList) { AvailableStock viewStockInDetails = new AvailableStock(); string[] BatchId = item.BatchIdFromMobile.Split(','); if (!productIds.Contains(item.ProductId)) { productIds.Add(item.ProductId); var currentProduct = connection.Query <ProductListNew>("Select * from ProductMaster_New where Id = @value", new { value = item.ProductId }).FirstOrDefault(); viewStockInDetails.ProductName = currentProduct.VarietyName; viewStockInDetails.unit = currentProduct.Unit; var currentCategory = connection.Query <CategoryType>("Select * from CategoryType where ID = @value", new { value = currentProduct.CatTypeId }).FirstOrDefault(); viewStockInDetails.CategoryName = currentCategory.Type; viewStockInDetails.LotBatchId = item.BatchIdFromMobile; viewStockInDetails.ProductId = item.ProductId; viewStockInDetails.Description = item.Remarks; viewStockInDetails.DateOfReceipt = item.RecievedOn; int availableQUantity = 0; string sheds = ""; foreach (var batchIds in BatchId) { viewStockInDetails.Batch = new List <BatchDetails>(); var currentBatchDetails = connection.Query <BatchDetails>("Select * from BatchMaster where BID = @value", new { value = batchIds }).FirstOrDefault(); BatchDetails tempBatchDetails = new BatchDetails(); tempBatchDetails.BID = currentBatchDetails.BID; tempBatchDetails.BatchName = currentBatchDetails.BatchName; tempBatchDetails.Esl = currentBatchDetails.Esl; tempBatchDetails.AvailableQuantity = currentBatchDetails.AvailableQuantity; availableQUantity = currentBatchDetails.AvailableQuantity + availableQUantity; tempBatchDetails.WarehouseID = currentBatchDetails.WarehouseID; tempBatchDetails.EXPDate = currentBatchDetails.EXPDate; tempBatchDetails.WarehouseNo = currentBatchDetails.WarehouseNo; sheds = sheds + tempBatchDetails.WarehouseNo + ","; viewStockInDetails.Batch.Add(tempBatchDetails); } viewStockInDetails.TotalAvailableQuantity = availableQUantity; viewStockInDetails.Sheds = sheds; viewStockIns.Add(viewStockInDetails); } else { foreach (var batchIds in BatchId) { viewStockInDetails.Batch = new List <BatchDetails>(); var currentBatchDetails = connection.Query <BatchDetails>("Select * from BatchMaster where BID = @value", new { value = batchIds }).FirstOrDefault(); Warehouse warehouse = connection.Query <Warehouse>("Select * from tblWarehouse where ID = @ID", new { ID = currentBatchDetails.WarehouseID }).FirstOrDefault(); BatchDetails tempBatchDetails = new BatchDetails(); int availableQUantity = 0; string sheds = ""; tempBatchDetails.BID = currentBatchDetails.BID; tempBatchDetails.BatchName = currentBatchDetails.BatchName; tempBatchDetails.Esl = currentBatchDetails.Esl; tempBatchDetails.AvailableQuantity = currentBatchDetails.AvailableQuantity; tempBatchDetails.WarehouseID = currentBatchDetails.WarehouseID; tempBatchDetails.EXPDate = currentBatchDetails.EXPDate; tempBatchDetails.WarehouseNo = warehouse.WareHouseNo; tempBatchDetails.Esl = currentBatchDetails.Esl; tempBatchDetails.MFGDate = currentBatchDetails.MFGDate; tempBatchDetails.WeightUnit = currentBatchDetails.WeightUnit; var result = viewStockIns.Find(x => x.ProductId == item.ProductId); if (!result.Sheds.TrimEnd(',').Contains(tempBatchDetails.WarehouseNo)) { sheds = sheds + tempBatchDetails.WarehouseNo + ","; } availableQUantity = currentBatchDetails.AvailableQuantity + availableQUantity; // viewStockInDetails.Batch.Add(tempBatchDetails); result.TotalAvailableQuantity = result.TotalAvailableQuantity + availableQUantity; result.Sheds = result.Sheds + sheds.TrimEnd(','); result.Batch.Add(tempBatchDetails); } } //viewStockIns.Add(viewStockInDetails); } connection.Close(); } return(viewStockIns); }
public async Task CreateBatch(CreateBatchInput input) { var batchDetails = BatchDetails.Create(AbpSession.GetTenantId(), input.BatchNumber, input.BatchDate, input.SampleType, input.Capacity); await _healthPackageManager.CreateBatchAsync(batchDetails); }