//--------------------------------------------------------------------------

        private void Initialise()
        {
            if (this.ScannedFormId > 0)
            {
                Facade.Form facForm = new Facade.Form();
                this.Manifest = facForm.GetForScannedFormId(this.ScannedFormId);
            }

            int scanFormId = -1;

            // With job POD scanning
            if (this.ManifestId > 0)
            {
                Facade.Form facForm = new Facade.Form();

                if (this.Manifest == null)
                {
                    this.Manifest = new Entities.Scan();
                }

                this.Manifest.ScannedDateTime = DateTime.Today;
                this.Manifest.FormTypeId      = eFormTypeId.Manifest;

                if (String.IsNullOrEmpty(this.FileName))
                {
                    this.Manifest.ScannedFormPDF = Orchestrator.Globals.Constants.NO_DOCUMENT_AVAILABLE;
                }
                else
                {
                    this.Manifest.ScannedFormPDF = this.FileName;
                }

                if (this.AppendOrReplace.Contains("A"))
                {
                    this.Manifest.IsAppend = true;
                }
                else
                {
                    this.Manifest.IsAppend = false;
                }

                // if this is not set then we don't know where to save the file locally so it must have been uploaded immediately.
                if (this.AppendOrReplace.Contains("U") || String.IsNullOrEmpty(Globals.Configuration.ScannedDocumentPath))
                {
                    this.Manifest.IsUploaded = true;
                }
                else
                {
                    this.Manifest.IsUploaded = false;
                }

                scanFormId = facForm.Create(this.Manifest, ((Entities.CustomPrincipal)Page.User).UserName);

                if (scanFormId > 0)
                {
                    this.Manifest.ScannedFormId = scanFormId;

                    // Update manifest record here
                    Orchestrator.Facade.ResourceManifest facResourceManifest =
                        new Orchestrator.Facade.ResourceManifest();

                    facResourceManifest.UpdateResourceManifestScan(this.ManifestId, scanFormId, ((Entities.CustomPrincipal)Page.User).UserName);
                }
            }

            this.Close(this.ScannedFormId.ToString());
        }
Beispiel #2
0
        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);
        }