Exemple #1
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();
     }
 }
        protected void btnAddToJob_Click(object sender, System.EventArgs e)
        {
            int collectDropId = 0;
            int PODId         = 0;

            Entities.POD podToAssign = null;

            // Find the Collect Drop ID for the selected collect drop portion
            foreach (DataGridItem cdsItem in dgCollectionDropSummary.Items)
            {
                DataGrid dgCollectionDrop = (DataGrid)cdsItem.FindControl("dgCollectionDrop");
                foreach (DataGridItem cdItem in dgCollectionDrop.Items)
                {
                    RdoBtnGrouper rbgCollectionDrop = (RdoBtnGrouper)cdItem.FindControl("rbgCollectionDrop");
                    if (rbgCollectionDrop.Checked)
                    {
                        collectDropId = int.Parse(cdItem.Cells[0].Text);
                    }
                }
            }

            // Find the POD ID of the selected POD
            foreach (DataGridItem PODItem in dgUnassignedPODs.Items)
            {
                RdoBtnGrouper rbgPODId = (RdoBtnGrouper)PODItem.FindControl("rbgPODId");
                if (rbgPODId.Checked)
                {
                    PODId       = int.Parse(PODItem.Cells[0].Text);
                    podToAssign = new Entities.POD(PODId, PODItem.Cells[1].Text, DateTime.Parse(PODItem.Cells[2].Text), m_jobId, collectDropId);
                }
            }

            if (podToAssign != null && collectDropId > 0 && PODId > 0)
            {
                Facade.IPOD facPOD = new Facade.POD();
                facPOD.AssignToJob(podToAssign, ((Entities.CustomPrincipal)Page.User).UserName);
            }
            else
            {
                lblAddToJobError.Text    = "Select POD and drop to which to assign.";
                lblAddToJobError.Visible = true;
            }
            PopulatePODs();
        }
        protected void dgCollectionDrop_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();
                int          collectDropId     = int.Parse(e.Item.Cells[0].Text);
                DataSet      dsPOD             = facPOD.GetForCollectDropID(collectDropId);
                Entities.POD itemPOD           = new Entities.POD();
                string       ticketNo          = null;
                if (dsPOD.Tables[0].Rows.Count > 0)
                {
                    itemPOD  = facPOD.GetForPODId(Convert.ToInt32(dsPOD.Tables[0].Rows[0]["PODId"]));
                    ticketNo = (string)dsPOD.Tables[0].Rows[0]["TicketNo"];
                }
                if (ticketNo == null)
                {
                    ((CheckBox)e.Item.FindControl("chkUnassignPOD")).Visible      = false;
                    ((HyperLink)e.Item.FindControl("lnkPODScanning")).Text        = "Scan POD";
                    ((HyperLink)e.Item.FindControl("lnkPODScanning")).NavigateUrl = @"javascript:OpenPODWindow(" + JobId + "," + collectDropId + ");";
                }
                else
                {
                    if (itemPOD != null && itemPOD.ScannedFormId > 0)
                    {
                        ((HyperLink)e.Item.FindControl("lnkPODView")).Visible     = true;
                        ((HyperLink)e.Item.FindControl("lnkPODView")).Target      = "_blank";
                        ((HyperLink)e.Item.FindControl("lnkPODView")).NavigateUrl = itemPOD.ScannedFormPDF.Trim();
                    }
                    ((RdoBtnGrouper)e.Item.FindControl("rbgCollectionDrop")).Visible = false;
                    ((HyperLink)e.Item.FindControl("lnkPODScanning")).Text           = "Ticket number " + ticketNo;
                    ((HyperLink)e.Item.FindControl("lnkPODScanning")).NavigateUrl    = @"javascript:OpenPODWindowForEdit(" + ((int)dsPOD.Tables[0].Rows[0]["ScannedFormID"]).ToString() + "," + JobId + ");";

                    m_assignedPodCount++;
                }
            }

            ViewState["AssignedPODCount"] = m_assignedPodCount;
        }
        protected void dgUnassignedPODs_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Facade.IPOD facPOD = new Facade.POD();

                Entities.POD itemPOD = facPOD.GetForPODId(int.Parse(e.Item.Cells[0].Text));

                string podId = e.Item.Cells[0].Text;

                HyperLink lnkViewPOD = (HyperLink)e.Item.FindControl("lnkViewPOD");
                if (itemPOD.ScannedFormId > 0)
                {
                    lnkViewPOD.Target      = "_blank";
                    lnkViewPOD.NavigateUrl = itemPOD.ScannedFormPDF;
                }
                else
                {
                    lnkViewPOD.Visible = false;
                }
            }
        }
Exemple #5
0
        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;
                    }
                }
            }
        }
Exemple #6
0
        private void CreatePOD(string fileName)
        {
            //if (fileName.StartsWith("\\"))
            //    fileName = fileName.Substring(1);

            Entities.POD pod    = null;
            Facade.POD   facPOD = new Orchestrator.Facade.POD();

            //Determine the Delivery job and collect drop for this order.
            if (this.OrderID > 0)
            {
                pod = facPOD.GetForOrderID(OrderID);
            }
            if (this.CollectDropID > 0)
            {
                pod = facPOD.GetPODForCollectDropID(this.CollectDropID);
            }

            // Is there already a POD for this collect drop?

            if (pod == null)
            {
                pod = new Orchestrator.Entities.POD();

                // get the details we need for the pod record.

                Facade.Order             facOrder       = new Orchestrator.Facade.Order();
                Facade.ICollectDrop      facCollectDrop = new Orchestrator.Facade.CollectDrop();
                Dictionary <string, int> orderDetails   = null;
                if (this.OrderID > 0)
                {
                    orderDetails = facOrder.GetDeliveryDetails(this.OrderID);
                }
                else
                {
                    orderDetails = facCollectDrop.GetDeliveryDetails(this.CollectDropID);
                }

                // Do we default to now (upload date) or do we look at the create date of the s

                pod.CollectDropId  = orderDetails["CollectDropID"];
                pod.JobId          = orderDetails["JobID"];
                pod.OrganisationId = orderDetails["CustomerIdentityID"];
                pod.FormTypeId     = eFormTypeId.POD;
            }

            pod.ScannedDateTime = DateTime.Now;
            pod.SignatureDate   = (DateTime)dteSignatureDate.SelectedDate;
            pod.TicketNo        = txtTicketNo.Text;
            pod.ScannedFormPDF  = fileName;
            try
            {
                if (pod.PODId > 0)
                {
                    facPOD.Update(pod, Page.User.Identity.Name);
                }
                else
                {
                    facPOD.Create(pod, pod.JobId, pod.OrganisationId, pod.CollectDropId, Page.User.Identity.Name);
                }

                this.ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", "<script type=\"text/javascript\">opener.location.href=opener.location.href; window.close();</script>");
            }
            catch (Exception ex)
            {
                lblError.Text    = ex.Message;
                lblError.Visible = true;
            }
        }
Exemple #7
0
        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);
        }
Exemple #8
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);
        }