//-------------------------------------------------------------------------- private void Initialise() { ((WizardMasterPage)this.Master).WizardTitle = "Document Wizard"; if (this.ScannedFormId > 0) { Orchestrator.Facade.Form facForm = new Orchestrator.Facade.Form(); Entities.Scan scannedform = facForm.GetForScannedFormId(this.ScannedFormId); tblPODReturn.Visible = false; this.AppendOrReplaceFieldSet.Style["display"] = ""; this.appendReplaceText.Style["display"] = ""; if (scannedform.ScannedFormPDF == Globals.Constants.NO_DOCUMENT_AVAILABLE) { this.AppendOrReplaceFieldSet.Style["display"] = "none"; this.appendReplaceText.Style["display"] = "none"; this.rblAppandOReplace.Style["display"] = "none"; } else { this.rblAppandOReplace.Style["display"] = ""; } this.appendReplaceText.InnerHtml = "A " + scannedform.FormTypeId.ToString() + " document already exists."; if (scannedform.IsUploaded) { this.appendReplaceText.InnerHtml += " [ <a target='_blank' href='" + scannedform.ScannedFormPDF + "' > View </a> ]"; } else { this.appendReplaceText.InnerHtml += " [ Not yet uploaded ]"; } } else { this.AppendOrReplaceFieldSet.Visible = false; this.appendReplaceText.Visible = false; this.rblAppandOReplace.Visible = false; } Facade.IUser facUser = new Facade.User(); Entities.User loggedOnUser = facUser.GetUserByUserName(this.Page.User.Identity.Name); if (!loggedOnUser.HasScannerLicense) { // Disable the scanning option this.rblOperation.Items[0].Selected = false; this.rblOperation.Items[0].Text = "You do not currently have a license to scan."; this.rblOperation.Items[0].Enabled = false; // select the upload option. this.rblOperation.Items[1].Selected = true; } }
protected void dgUnattachedDeHire_ItemDataBound(object sender, DataGridItemEventArgs e) { m_assignedPodCount = (int)ViewState["AssignedPODCount"]; if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Orchestrator.Facade.POD facPOD = new Orchestrator.Facade.POD(); Orchestrator.Facade.Form facForm = new Orchestrator.Facade.Form(); int orderID = int.Parse(e.Item.Cells[0].Text); int scannedFormId = -1; int dehireReceiptId = int.Parse(e.Item.Cells[1].Text); string receiptNumber = e.Item.Cells[2].Text; Entities.Scan dehireReceiptScan = null; if (int.TryParse(e.Item.Cells[3].Text, out scannedFormId) && scannedFormId > 0) { dehireReceiptScan = facForm.GetForScannedFormId(scannedFormId); } if (dehireReceiptScan == null) { string date = e.Item.Cells[5].Text; string truncatedDate = date.Substring(0, date.LastIndexOf(' ')); string urlEncodedDate = Server.UrlEncode(truncatedDate); ((CheckBox)e.Item.FindControl("chkUnassignPOD")).Visible = false; ((HyperLink)e.Item.FindControl("lnkPODScanning")).Text = "Scan Dehire Receipt"; ((HyperLink)e.Item.FindControl("lnkPODScanning")).NavigateUrl = @"javascript:OpenDehireWindow(" + JobId + "," + orderID + "," + dehireReceiptId + ",'" + receiptNumber + "');"; } else { if (dehireReceiptScan.ScannedFormId > 0) { ((HyperLink)e.Item.FindControl("lnkPODView")).Visible = true; ((HyperLink)e.Item.FindControl("lnkPODView")).Target = "_blank"; ((HyperLink)e.Item.FindControl("lnkPODView")).NavigateUrl = dehireReceiptScan.ScannedFormPDF.Trim(); } ((RdoBtnGrouper)e.Item.FindControl("rbgCollectionDrop")).Visible = false; ((HyperLink)e.Item.FindControl("lnkPODScanning")).Text = "Dehire Receipt Number " + receiptNumber; ((HyperLink)e.Item.FindControl("lnkPODScanning")).NavigateUrl = @"javascript:OpenDehireWindowForEdit(" + dehireReceiptScan.ScannedFormId.ToString() + "," + JobId + "," + orderID + "," + dehireReceiptId + ",'" + receiptNumber + "');"; m_assignedPodCount++; } } ViewState["AssignedPODCount"] = m_assignedPodCount; }
public bool DoesScannedFormRowExist(string fileName) { bool doesScanFormRowExist = false; Facade.Form facScanForm = new Orchestrator.Facade.Form(); Entities.Scan scan = facScanForm.GetForScannedFormForScannedFormPDF(fileName); if (scan.ScannedFormId > 0) { doesScanFormRowExist = true; } return(doesScanFormRowExist); }
protected void dgPODSearchResults_ItemCommand(object sender, DataGridCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Facade.IPOD facPOD = new Facade.POD(); Facade.IForm facForm = new Facade.Form(); Entities.POD podToView = facPOD.GetForPODId(int.Parse(e.Item.Cells[0].Text)); Entities.Scan scan = facForm.GetForScannedFormId(podToView.ScannedFormId); byte[] scannedFormImage; scannedFormImage = Convert.FromBase64String(scan.ScannedFormImage); Response.Clear(); Response.ContentType = "image/tiff"; Response.AddHeader("Content-Disposition", "attachment; filename=" + "PODTicketNo" + e.Item.Cells[1].Text + ".tif"); Response.OutputStream.Write(scannedFormImage, 0, scannedFormImage.Length); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { Facade.IForm facForm = new Facade.Form(); Entities.Scan scan = facForm.GetForScannedFormId(scannedFormId); for (int i = 0; i < scan.PageCount; i++) { TabStripTab tab = new TabStripTab(); string imgName = "_page" + ((int)(i + 1)).ToString() + ".jpg"; tab.Look.ImageUrl = imgName; tab.SelectedLook.ImageUrl = imgName; tab.ClientSideCommand = "selectPage(" + i.ToString() + ");"; ThumbnailsTabStrip.Tabs.Add(tab); } CurrentImage.Width = Unit.Percentage(100); CurrentImage.Height = Unit.Percentage(100); }
public string ScanHasBeenUploadedTo(string URL) { string methodStatus = String.Empty; Uri URI = new Uri(URL); string newFileName = URI.Segments[URI.Segments.Length - 1]; Facade.Form facScanForm = new Orchestrator.Facade.Form(); Entities.Scan scan = facScanForm.GetForScannedFormForScannedFormPDF(newFileName); if (scan == null) { throw new ApplicationException("ScanHasBeenUploadedTo - Scan not found for filename " + newFileName); } scan.IsUploaded = true; scan.ScannedFormPDF = URL; try { // update the IsUploaded flag on the scannedForm facScanForm.Update(scan, scan.CreateUserID); } catch (Exception ex) { throw new ApplicationException("ScanHasBeenUploadedTo - Update ScanForm failed", ex); } //If the scan is a POD email it if (scan.FormTypeId == eFormTypeId.POD) { //Email the POD to the client Facade.IPOD facPod = new Facade.POD(); //Make the call to send the email async as it will //have to download the attachment MethodCall <string, int> asyncSendClientPod = facPod.SendClientPod; asyncSendClientPod.BeginInvoke(scan.ScannedFormId, r => { try { asyncSendClientPod.EndInvoke(r); } catch (Exception ex) { WebUI.Global.UnhandledException(ex); } }, null); } return(methodStatus); }
protected void Page_Load(object sender, System.EventArgs e) { userFullName = ((Entities.CustomPrincipal)Page.User).UserName; if (!IsLocal && Request.QueryString["ScannedFormID"] != null) { txtFileName.Text = ""; Facade.IForm facForm = new Facade.Form(); scannedFormId = int.Parse(Request.QueryString["ScannedFormId"]); Entities.Scan scan = facForm.GetForScannedFormId(scannedFormId); txtFirstFormPageID.Text = Request.QueryString["PageNumber"]; txtTotalPages.Text = scan.PageCount.ToString(); } else { txtTotalPages.Text = Request.QueryString["TotalPages"]; txtFileName.Text = Request.QueryString["FileName"]; } }
private int SaveReportPdf(eReportType reportType, byte[] bytes, string userName) { var uploaderPath = Globals.Configuration.OrchestratorServerUploaderPdfsPath; if (string.IsNullOrEmpty(uploaderPath)) { throw new ApplicationException("Cannot email report: the OrchestratorServerUploaderPdfsPath setting has not been configured."); } if (!Directory.Exists(uploaderPath)) { Directory.CreateDirectory(uploaderPath); } var sendNowPath = Path.Combine(uploaderPath, "sendnow"); if (!Directory.Exists(sendNowPath)) { Directory.CreateDirectory(sendNowPath); } var fileName = string.Format("EmailedReport_{0}_{1}_{2:yyyyMMddHHmmss}.pdf", Enum.GetName(typeof(eReportType), reportType), userName, DateTime.Now); var fileNameAndPath = Globals.Configuration.ScanFormSendNow ? Path.Combine(sendNowPath, fileName) : Path.Combine(uploaderPath, fileName); File.WriteAllBytes(fileNameAndPath, bytes); var facForm = new Facade.Form(); var bookingForm = new Entities.Scan { ScannedDateTime = DateTime.Today, FormTypeId = eFormTypeId.EmailedReport, ScannedFormPDF = fileName, IsAppend = false, IsUploaded = false, }; var scannedFormID = facForm.Create(bookingForm, userName); return(scannedFormID); }
public Entities.Scan GetScannedForm(string FileName, out string PreviousScanURL) { Facade.Form facScanForm = new Orchestrator.Facade.Form(); Entities.Scan scan = facScanForm.GetForScannedFormForScannedFormPDF(FileName); PreviousScanURL = string.Empty; if (scan != null && scan.PreviousScannedFormId.HasValue) { Entities.Scan previousScan = facScanForm.GetForScannedFormId(scan.PreviousScannedFormId.Value); if (previousScan != null) { PreviousScanURL = previousScan.ScannedFormPDF; } } if (scan == null || scan.ScannedFormId < 1) { return(null); } else { return(scan); } }
//-------------------------------------------------------------------------- public string ScanHasBeenUploaded(string fileNameAndFTPDirectory) { //If the http post file upload is being used then the PODs must be on this server //so we can append etc. //Not sure why something sikmilar to this is done in scanreceive.aspx //TODO However this needs to be tested //This is no longer called - is it redundant? if (fileNameAndFTPDirectory.StartsWith("\\")) { fileNameAndFTPDirectory = fileNameAndFTPDirectory.Substring(1, fileNameAndFTPDirectory.Length - 1); } string methodStatus = String.Empty; string newFileName = Path.GetFileName(fileNameAndFTPDirectory); string newFileLocation = Path.Combine(Server.MapPath("~/PDFS"), fileNameAndFTPDirectory.Replace(newFileName, "")); string newFileLocationAndName = Path.Combine(newFileLocation, newFileName); Facade.Form facScanForm = new Orchestrator.Facade.Form(); if (this.AppendOrReplace.Contains("A")) { Entities.Scan scan = facScanForm.GetForScannedFormId(this.ScannedFormId); if (scan != null) { PdfDocument previousDocument; string existingFileNameAndPath = scan.ScannedFormPDF; if (File.Exists(existingFileNameAndPath)) { previousDocument = PdfReader.Open(existingFileNameAndPath, PdfDocumentOpenMode.Import); try { // should always exist if (!Directory.Exists(newFileLocation)) { Directory.CreateDirectory(newFileLocation); } } catch (Exception ex) { throw new ApplicationException("ScanHasBeenUploaded - Error Creating directory - " + newFileLocation, ex); } try { // read the exisiting but newly created pdf PdfDocument newPdfDoc = PdfReader.Open(newFileLocationAndName, PdfDocumentOpenMode.Import); PdfDocument finalDoc = new PdfDocument(); // Append the previous document to our new document foreach (PdfPage page in previousDocument.Pages) { finalDoc.AddPage(page); } // Append the new document to the previous document foreach (PdfPage page in newPdfDoc.Pages) { finalDoc.AddPage(page); } // attempt to save the new doc finalDoc.Save(newFileLocationAndName); methodStatus = "Appended " + newFileLocationAndName + " to " + existingFileNameAndPath; } catch (Exception ex) { throw new ApplicationException("ScanHasBeenUploaded - Error appending document - " + fileNameAndFTPDirectory, ex); } } else { throw new ApplicationException("ExistingScanForm file could not be found - Path - " + existingFileNameAndPath); } } else { throw new ApplicationException("ExistingScanForm entity could not be found."); } } else { methodStatus = "Append = false or no previousScanneDformId to append too."; } return(methodStatus); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // This property defaults to eFormTypeId.POD if it has not been supplied if (this.FormType == eFormTypeId.POD) { Facade.POD facPod = new Orchestrator.Facade.POD(); Entities.POD pod = null; if (this.OrderID > 0) { pod = facPod.GetForOrderID(OrderID); } if (this.CollectDropID > 0) { pod = facPod.GetPODForCollectDropID(CollectDropID); } if (pod != null) { lblDescription.Text = "There has already been a PDF uploaded for this order, if you upload another one this will overrwite the existing file."; txtTicketNo.Text = pod.TicketNo; dteSignatureDate.SelectedDate = pod.SignatureDate; } else { if (!String.IsNullOrEmpty(Request.QueryString["ticket"])) { txtTicketNo.Text = Request.QueryString["ticket"]; } if (!String.IsNullOrEmpty(Request.QueryString["sigDate"])) { dteSignatureDate.SelectedDate = DateTime.Parse(Request.QueryString["sigDate"]); } } } // This property defaults to eFormTypeId.POD if it has not been supplied else if (this.FormType == eFormTypeId.BookingForm) { Orchestrator.Facade.Form facBF = new Orchestrator.Facade.Form(); Facade.IOrder facOrder = new Orchestrator.Facade.Order(); Entities.Order order = null; Entities.Scan bookingForm = null; txtTicketNo.Visible = false; lblTicketRef.Visible = false; this.btnUpload.CausesValidation = false; dteSignatureDate.Visible = false; lblSignatureDate.Visible = false; if (this.OrderID > 0) { order = facOrder.GetForOrderID(OrderID); } if (order != null && order.BookingFormScannedFormId != null) { bookingForm = facBF.GetForScannedFormId((int)order.BookingFormScannedFormId); } if (bookingForm != null) { lblDescription.Text = "There has already been a booking form uploaded for this order, if you upload another one this will overwrite the existing file."; } else { lblDescription.Text = String.Empty; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //If the http post file upload is being used then the PODs must be on this server //so we can append etc. //TODO However this needs to be tested // get the existing file if neccessary if (Request.QueryString["AppendOrReplace"] != null && Request.QueryString["AppendOrReplace"].ToString().Contains("A")) { // get the ScannedForm record so that we can retrieve the existing document and append to it. BusinessLogicLayer.Form busForm = new Orchestrator.BusinessLogicLayer.Form(); Entities.Scan scanForm = busForm.GetForScannedFormId(int.Parse(Request.QueryString["ScannedFormId"].ToString())); if (scanForm != null) { _pdfDocument = PdfReader.Open(Path.Combine(Server.MapPath("~/PDFS"), scanForm.ScannedFormPDF), PdfDocumentOpenMode.Import); } } HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile postedFile = files[0]; BufferedStream bs = null; byte[] fileOutput = null; try { if (postedFile.InputStream != null) { bs = new BufferedStream(postedFile.InputStream); int length = Convert.ToInt32(bs.Length); fileOutput = new byte[length]; bs.Read(fileOutput, 0, length); } } finally { bs.Close(); bs.Dispose(); } if (fileOutput.Length > 0) { string basePath = Server.MapPath("~/PDFS"); if (!basePath.EndsWith("\\")) { basePath += "\\"; } bool writeError = false; string pathAndFileName = Path.Combine(basePath, postedFile.FileName); string path = pathAndFileName.Replace(Path.GetFileName(pathAndFileName), ""); MemoryStream ms = new MemoryStream(fileOutput); try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } catch (Exception ex) { throw ex; } if (!writeError) { try { // create new pdf MemoryStream previousFileStream = new MemoryStream(fileOutput); PdfDocument newPdfDoc = PdfReader.Open(previousFileStream, PdfDocumentOpenMode.Modify); // _pdf will be null unless we are appending to an existing doc if (_pdfDocument == null) { newPdfDoc.Save(pathAndFileName); } else { foreach (PdfPage page in newPdfDoc.Pages) { _pdfDocument.AddPage(page); } _pdfDocument.Save(pathAndFileName); } //File.WriteAllBytes(string.Format("{0}\\{1}", path, fileName), ms.ToArray()); } catch (Exception ex) { throw ex; } } ms.Close(); ms.Dispose(); } } }
public string ScanHasBeenUploaded(string fileNameAndFTPDirectory) { if (fileNameAndFTPDirectory.StartsWith("\\")) { fileNameAndFTPDirectory = fileNameAndFTPDirectory.Substring(1, fileNameAndFTPDirectory.Length - 1); } string pdfLocation = Server.MapPath("~/PDFS"); string methodStatus = String.Empty; string newFileName = Path.GetFileName(fileNameAndFTPDirectory); string newFileLocation = Path.Combine(pdfLocation, fileNameAndFTPDirectory.Replace(newFileName, "")); string newFileLocationAndName = Path.Combine(newFileLocation, newFileName); Facade.Form facScanForm = new Orchestrator.Facade.Form(); Entities.Scan scan = facScanForm.GetForScannedFormForScannedFormPDF(newFileName); if (scan.IsAppend && scan.PreviousScannedFormId != null) { Entities.Scan existingScan = null; // get the previous scannedForm Record existingScan = facScanForm.GetForScannedFormId((int)scan.PreviousScannedFormId); if (existingScan != null) { PdfDocument previousDocument; //string existingFileNameAndPath = Path.Combine(pdfLocation, existingScan.ScannedFormPDF); string existingFileNameAndPath = Server.MapPath(existingScan.ScannedFormPDF); if (File.Exists(existingFileNameAndPath)) { previousDocument = PdfReader.Open(existingFileNameAndPath, PdfDocumentOpenMode.Import); try { // should always exist if (!Directory.Exists(newFileLocation)) { Directory.CreateDirectory(newFileLocation); } } catch (Exception ex) { throw new ApplicationException("ScanHasBeenUploaded - Error Creating directory - " + newFileLocation, ex); } try { // read the exisiting but newly created pdf PdfDocument newPdfDoc = PdfReader.Open(newFileLocationAndName, PdfDocumentOpenMode.Import); PdfDocument finalDoc = new PdfDocument(); // Append the previous document to our new document foreach (PdfPage page in previousDocument.Pages) { finalDoc.AddPage(page); } // Append the new document to the previous document foreach (PdfPage page in newPdfDoc.Pages) { finalDoc.AddPage(page); } // attempt to save the new doc finalDoc.Save(newFileLocationAndName); methodStatus = "Appended " + newFileLocationAndName + " to " + existingFileNameAndPath; } catch (Exception ex) { throw new ApplicationException("ScanHasBeenUploaded - Error appending document - " + fileNameAndFTPDirectory, ex); } } else { throw new ApplicationException("ExistingScanForm file could not be found - Path - " + existingFileNameAndPath + " - New FileLocationAndName: " + newFileLocationAndName); } } else { throw new ApplicationException("ExistingScanForm entity could not be found."); } } else { methodStatus = "Append = false or no previousScanneDformId to append too." + Environment.NewLine; } scan.IsUploaded = true; //Use full URL instead //scan.ScannedFormPDF = fileNameAndFTPDirectory; string URL = this.Context.Request.Url.GetLeftPart(UriPartial.Authority) + "/PDFS/" + fileNameAndFTPDirectory.Replace('\\', '/'); scan.ScannedFormPDF = URL; try { // update the IsUploaded flag on the scannedForm facScanForm.Update(scan, scan.CreateUserID); Facade.IPOD facPod = new Facade.POD(); methodStatus += facPod.SendClientPod(scan.ScannedFormId); } catch (Exception ex) { throw new ApplicationException("ScanHasBeenUploaded - Update ScanForm failed (ScanForm ID:" + scan.ScannedFormId + ")", ex); } return(methodStatus); }
public List <Orchestrator.BulkScan.Types.ScanResult> GetScanUploadDefaultInformationAndExistingScans(string barcodes) { if (string.IsNullOrEmpty(barcodes)) { return(new List <ScanResult>()); } List <ScanResult> result = new List <ScanResult>(); Facade.Form facForm = new Orchestrator.Facade.Form(); Facade.ResourceManifest facRM = new Orchestrator.Facade.ResourceManifest(); Facade.IOrder facOrder = new Orchestrator.Facade.Order(); Entities.Scan scan = null; ScanResult sr = null; foreach (string barcode in barcodes.Split(":".ToCharArray())) { try { // The 3rd and 4th chars of the barcode indicate the form type switch (barcode.Substring(2, 2)) { case "02": // Resource Manifests string extractedResourceManifestId = barcode.Substring(4, 8); for (int i = 0; i < 8; i++) { if (extractedResourceManifestId.Length > 0 && extractedResourceManifestId.Substring(0, 1) == "0") { extractedResourceManifestId = extractedResourceManifestId.Substring(1); } else { break; } } int resourceManifestId = Convert.ToInt32(extractedResourceManifestId); Entities.ResourceManifest rm = facRM.GetResourceManifest(resourceManifestId); if (rm != null) { sr = new ScanResult(); sr.Barcode = barcode; sr.FormType = "02"; if (rm.ScannedFormId > 0) { scan = facForm.GetForScannedFormId(rm.ScannedFormId); if (scan != null) { sr.PDFPath = scan.ScannedFormPDF; sr.Replace = false; } } result.Add(sr); } break; //case "01": // Delivery Note // int orderId = Convert.ToInt32(barcode.Substring(3)); // Entities.Order order = facOrder.GetForOrderID(orderId); // if (order != null) // { // sr = new ScanResult(); // sr.Barcode = barcode; // sr.FormType = "01"; // if (order.DeliveryNoteScannedFormId.HasValue) // { // scan = facForm.GetForScannedFormId(order.DeliveryNoteScannedFormId.Value); // if (scan != null) // { // sr.PDFPath = scan.ScannedFormPDF; // sr.Replace = false; // } // } // result.Add(sr); // } // break; case "01": // PODS string extratedOrderId = barcode.Substring(4, 8); for (int i = 0; i < 8; i++) { if (extratedOrderId.Length > 0 && extratedOrderId.Substring(0, 1) == "0") { extratedOrderId = extratedOrderId.Substring(1); } else { break; } } int orderId2 = Convert.ToInt32(extratedOrderId); Entities.Order order2 = facOrder.GetForOrderID(orderId2); if (order2 != null) { Facade.POD facPod = new Orchestrator.Facade.POD(); Entities.POD pod = facPod.GetForOrderID(orderId2); BatchItemPodInfo podInfo = new BatchItemPodInfo(); sr = new ScanResult(); sr.Barcode = barcode; sr.FormType = "01"; if (pod != null) { scan = facForm.GetForScannedFormId(pod.ScannedFormId); if (scan != null) { sr.PDFPath = scan.ScannedFormPDF; sr.Replace = false; } } int collectDropId = facOrder.GetDeliveryCollectDropIDForPODScanner(orderId2); int JobId = facOrder.GetDeliveryJobIDForOrderID(orderId2); DataSet dsJobDetails = facPod.GetJobDetails(JobId); bool foundCollectDrop = false; foreach (DataRow row in dsJobDetails.Tables["CollectionDrop"].Rows) { if ((int)row["CollectDropId"] == collectDropId) { podInfo.TicketNumber = row["ClientsCustomerReference"].ToString(); podInfo.SignatureDate = (DateTime)row["CollectDropDateTime"]; foundCollectDrop = true; break; } } // If we don't find pod info, default it to something sensible. if (!foundCollectDrop) { podInfo.TicketNumber = ""; podInfo.SignatureDate = DateTime.Now; } sr.BatchItemInfo = SerializeBatchItemInfoToString(sr.FormType, podInfo); result.Add(sr); } break; default: break; } } catch (Exception ex) { ScanResult srError = new ScanResult(); srError.Barcode = barcode; srError.ErrorOccurred = true; srError.ErrorText = ex.Message; result.Add(srError); } } return(result); }
public bool PrepareForBulkScanUpload(List <ScanPreparation> scanPreps, string userId) { bool result = false; foreach (ScanPreparation sp in scanPreps) { if (sp.FormType == "02") // Resource Manifest { Entities.Scan manifest = null; // Resource Manifest if (Convert.ToInt32(sp.RecordId) > 0) { Facade.Form facForm = new Facade.Form(); manifest = new Entities.Scan(); // If this is not a replace (ie its an 'append'), then the previousScannedFormId value must be set. // The previousScannedFormId should also be set when a placeholder row (with NoDocumentScanned.pdf) is present. Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest(); Entities.ResourceManifest rm = facResourceManifest.GetResourceManifest(int.Parse(sp.RecordId)); if (rm.ScannedFormId > 0) { manifest.PreviousScannedFormId = rm.ScannedFormId; } manifest.ScannedDateTime = DateTime.Today; manifest.FormTypeId = eFormTypeId.Manifest; manifest.ScannedFormPDF = sp.PDFFileName; manifest.IsAppend = !sp.Replace; manifest.IsUploaded = false; int scanFormId = facForm.CreateNew(manifest, userId); if (scanFormId > 0) { manifest.ScannedFormId = scanFormId; // Update manifest record here facResourceManifest.UpdateResourceManifestScan(int.Parse(sp.RecordId), scanFormId, userId); } } result = true; } if (sp.FormType == "01") // POD { Facade.IOrder facOrder = new Facade.Order(); Facade.POD facPod = new Orchestrator.Facade.POD(); Entities.POD pod = null; int collectDropId = facOrder.GetDeliveryCollectDropIDForPODScanner(int.Parse(sp.RecordId)); int JobId = facOrder.GetDeliveryJobIDForOrderID(int.Parse(sp.RecordId)); pod = facPod.GetForOrderID(int.Parse(sp.RecordId)); if (pod == null) { pod = new Entities.POD(); } BatchItemPodInfo podInfo = (BatchItemPodInfo)DeserializeBatchItemInfoFromString(sp); if (podInfo != null) { pod.TicketNo = podInfo.TicketNumber; pod.SignatureDate = podInfo.SignatureDate; } else { pod.TicketNo = string.Empty; pod.SignatureDate = DateTime.Now; } //pod.PreviousScannedFormId pod.ScannedDateTime = DateTime.Today; pod.JobId = JobId; pod.CollectDropId = collectDropId; pod.OrganisationId = 0; if (pod.ScannedFormPDF != null && pod.ScannedFormPDF.ToLower().Contains(Globals.Constants.NO_DOCUMENT_AVAILABLE.ToLower())) { pod.IsAppend = false; } else { pod.IsAppend = !sp.Replace; } pod.ScannedFormPDF = sp.PDFFileName; if (pod.ScannedFormId > 0) { facPod.Update(pod, userId); // re get the pod entry as the scannedFormId will have changed. pod = facPod.GetForPODId(pod.PODId); } else { int podId = facPod.Create(pod, JobId, 0, collectDropId, userId); // get the newly created pod. pod = facPod.GetForPODId(podId); } result = true; } //if (sp.FormType == "01") // delivery notes //{ // Entities.Scan deliveryNote = null; // // delivery note // if (Convert.ToInt32(sp.RecordId) > 0) // { // Facade.IOrder facOrder = new Facade.Order(); // Facade.Form facForm = new Facade.Form(); // deliveryNote = new Entities.Scan(); // // If this is not a replace (ie its an 'append'), then the previousScannedFormId value must be set. // // The previousScannedFormId should also be set when a placeholder row (with NoDocumentScanned.pdf) is present. // Entities.Order order = facOrder.GetForOrderID(int.Parse(sp.RecordId)); // if (order.DeliveryNoteScannedFormId > 0) // deliveryNote.PreviousScannedFormId = order.DeliveryNoteScannedFormId; // deliveryNote.ScannedDateTime = DateTime.Today; // deliveryNote.FormTypeId = eFormTypeId.DeliveryNote; // deliveryNote.ScannedFormPDF = sp.PDFFileName; // deliveryNote.IsAppend = !sp.Replace; // deliveryNote.IsUploaded = false; // int scanFormId = facForm.CreateNew(deliveryNote, userId); // if (scanFormId > 0) // { // deliveryNote.ScannedFormId = scanFormId; // // Update manifest record here // facOrder.UpdateDeliveryNoteScannedFormId(int.Parse(sp.RecordId), scanFormId, userId); // } // } // result = true; //} } return(result); }