Ejemplo n.º 1
0
        //--------------------------------------------------------------------------

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

            int scanFormId = -1;

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

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

                this.BookingForm.ScannedDateTime = DateTime.Today;
                this.BookingForm.FormTypeId      = eFormTypeId.BookingForm;
                this.BookingForm.ScannedFormPDF  = this.FileName;

                if (this.AppendOrReplace.Contains("A"))
                {
                    this.BookingForm.IsAppend = true;
                }
                else
                {
                    this.BookingForm.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.BookingForm.IsUploaded = true;
                }
                else
                {
                    this.BookingForm.IsUploaded = false;
                }

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

                if (scanFormId > 0)
                {
                    Orchestrator.Facade.IOrder facOrder = new Orchestrator.Facade.Order();
                    facOrder.UpdateBookingFormScannedFormId(this.OrderId, scanFormId, ((Entities.CustomPrincipal)Page.User).UserName);
                }
            }

            this.Close(this.ScannedFormId.ToString());
        }
Ejemplo n.º 2
0
 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();
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public string ScanHasBeenUploadedToWithId(string URL, int scannedFormId)
        {
            var methodStatus = String.Empty;

            var facScanForm = new Facade.Form();
            var scan        = facScanForm.GetForScannedFormId(scannedFormId);

            if (scan == null)
            {
                // If scan is null try and use the old method based on file name.
                ScanHasBeenUploadedTo(URL);
                return(methodStatus);
            }

            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);
        }
Ejemplo n.º 5
0
        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"];
            }
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        //--------------------------------------------------------------------------

        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());
        }
Ejemplo n.º 8
0
        void btnNext_Click(object sender, EventArgs e)
        {
            if (this.ScannedFormId > 0)
            {
                Facade.Form facForm = new Facade.Form();
                this.DehireReceipt = facForm.GetForScannedFormId(this.ScannedFormId);
            }

            int scanFormId = -1;

            // With job POD scanning
            if (this.OrderId > 0)
            {
                Facade.Form           facForm          = new Facade.Form();
                Facade.IDeHireReceipt facDehireReceipt = new Facade.CollectDrop();

                string userID = ((Entities.CustomPrincipal)Page.User).UserName;

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

                this.DehireReceipt.ScannedDateTime = DateTime.Today;
                this.DehireReceipt.FormTypeId      = eFormTypeId.DehireReceipt;
                this.DehireReceipt.ScannedFormPDF  = this.FileName;

                // N = No document available
                if (this.AppendOrReplace.Contains("N"))
                {
                    if (this.DehireReceipt.ScannedFormId == 0)
                    {
                        this.DehireReceipt.ScannedFormPDF = Orchestrator.Globals.Constants.NO_DOCUMENT_AVAILABLE;
                    }
                }
                else
                {
                    this.DehireReceipt.ScannedFormPDF = this.FileName;
                }

                if (this.AppendOrReplace.Contains("A"))
                {
                    this.DehireReceipt.IsAppend = true;
                }
                else
                {
                    this.DehireReceipt.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.DehireReceipt.IsUploaded = true;
                }
                else
                {
                    this.DehireReceipt.IsUploaded = false;
                }

                // Update the receipt number,
                facDehireReceipt.UpdateReceiptNumber(DehireReceiptId, txtDehireReceiptNumber.Text, userID);
                // Create the scanned form.
                scanFormId = facForm.Create(this.DehireReceipt, userID);

                if (scanFormId > 0)
                {
                    facDehireReceipt.UpdateScannedForm(DehireReceiptId, scanFormId, userID);
                }
            }

            this.Close(this.ScannedFormId.ToString());
        }
        //--------------------------------------------------------------------------

        private void Initialise()
        {
            Facade.Form facForm = new Facade.Form();

            if (this.ScannedFormId > 0)
            {
                this.ScannedForm = facForm.GetForScannedFormId(this.ScannedFormId);
            }
            else
            {
                this.ScannedForm = new Entities.Scan();
            }

            this.ScannedForm.ScannedDateTime = DateTime.Today;
            this.ScannedForm.FormTypeId      = (eFormTypeId)this.ScannedFormTypeId;
            this.ScannedForm.ScannedFormPDF  = this.FileName;

            if (this.AppendOrReplace.Contains("A"))
            {
                this.ScannedForm.IsAppend = true;
            }
            else
            {
                this.ScannedForm.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.ScannedForm.IsUploaded = true;
            }
            else
            {
                this.ScannedForm.IsUploaded = false;
            }

            //Creates a new scanned form and references the previous scanned form if necessary
            int scanFormId = facForm.Create(this.ScannedForm, ((Entities.CustomPrincipal)Page.User).UserName);

            if (scanFormId > 0)
            {
                EF.OrganisationDocument orgDoc = null;

                if (this.OrganisationDocumentId > 0)
                {
                    orgDoc = DataContext.OrganisationDocuments.First(od => od.OrganisationDocumentId == this.OrganisationDocumentId);
                }
                else
                {
                    orgDoc             = new EF.OrganisationDocument();
                    orgDoc.Description = DataContext.FormTypes.First(ft => ft.FormTypeId == this.ScannedFormTypeId).Description;
                    orgDoc.OrganisationReference.EntityKey = EF.DataContext.CreateKey("OrganisationSet", "IdentityId", this.OrganisationIdentityId);
                    this.DataContext.AddToOrganisationDocuments(orgDoc);
                }

                orgDoc.ScannedFormReference.EntityKey = EF.DataContext.CreateKey("ScannedForms", "ScannedFormID", scanFormId);
                this.DataContext.SaveChanges();
            }


            this.Close(this.ScannedFormId.ToString());
        }
Ejemplo n.º 10
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);
        }