void grdResourceManifestList_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            DataSet dsResourceManifest = facResourceManifest.GetResourceManifestList((DateTime)dteStartDate.SelectedDate, (DateTime)dteEndDate.SelectedDate);

            this.grdResourceManifestList.DataSource = dsResourceManifest;
        }
示例#2
0
        private void ConfigureDisplay()
        {
            this.ResourceManifestId     = Convert.ToInt32(this.Page.Request.QueryString["rmId"].ToString());
            this.lblManifestNumber.Text = this.ResourceManifestId.ToString();

            // If rmID (resource manifest id) is null then throw exception
            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);

            txtManifestName.Text         = this.SavedResourceManifest.Description;
            dteManifestDate.SelectedDate = this.SavedResourceManifest.ManifestDate;

            DataAccess.IOrganisationLocation dacOrgLoc = new DataAccess.Organisation();
            cboDepot.DataSource     = dacOrgLoc.GetAllDepots(Orchestrator.Globals.Configuration.IdentityId);
            cboDepot.DataValueField = "OrganisationLocationId";
            cboDepot.DataTextField  = "OrganisationLocationName";
            cboDepot.DataBind();
            cboDepot.Items.Insert(0, new ListItem("All", "0"));

            dteStartdate.SelectedDate = DateTime.Today;
            dteEndDate.SelectedDate   = DateTime.Today.AddDays(1);

            txtExtraRowCount.Value     = Orchestrator.Globals.Configuration.DefaultResourceManifestNoOfBlankLines;
            chkUsePlannedTimes.Checked = Orchestrator.Globals.Configuration.UsePlannedTimes;
            chkShowFullAddress.Checked = Orchestrator.Globals.Configuration.ResourceManifestShowFullAddress;

            if (this.SavedResourceManifest.ResourceManifestJobs.Count == 1)
            {
                chkExcludeFirstRow.Enabled = chkExcludeFirstRow.Checked = false;
            }
            else
            {
                chkExcludeFirstRow.Checked = Orchestrator.Globals.Configuration.ExcludeResourceManifestFirstLine;
            }
        }
        private void ConfigureDisplay()
        {
            this.ResourceManifestId     = Convert.ToInt32(this.Page.Request.QueryString["rmId"].ToString());
            this.lblManifestNumber.Text = this.ResourceManifestId.ToString();

            // If rmID (resource manifest id) is null then throw exception
            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);

            txtManifestName.Text         = this.SavedResourceManifest.Description;
            dteManifestDate.SelectedDate = this.SavedResourceManifest.ManifestDate;

            dteStartdate.SelectedDate = DateTime.Today;
            dteEndDate.SelectedDate   = DateTime.Today.AddDays(1);

            txtExtraRowCount.Value     = Orchestrator.Globals.Configuration.DefaultResourceManifestNoOfBlankLines;
            chkUsePlannedTimes.Checked = Orchestrator.Globals.Configuration.UsePlannedTimes;
            chkShowFullAddress.Checked = Orchestrator.Globals.Configuration.ResourceManifestShowFullAddress;

            if (this.SavedResourceManifest.ResourceManifestJobs.Count == 1)
            {
                chkExcludeFirstRow.Enabled = chkExcludeFirstRow.Checked = false;
            }
            else
            {
                chkExcludeFirstRow.Checked = Orchestrator.Globals.Configuration.ExcludeResourceManifestFirstLine;
            }
        }
示例#4
0
        private void GenerateAndShowManifest(int resourceManifestID, bool excludeFirstLine, int extraRows, bool usePlannedTimes, bool includeScript, bool showFullAddress, bool useInstructionOrder)
        {
            Facade.ResourceManifest   facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            Entities.ResourceManifest rm = new Orchestrator.Entities.ResourceManifest();
            rm = facResourceManifest.GetResourceManifest(resourceManifestID);

            // Retrieve the resource manifest
            NameValueCollection reportParams = new NameValueCollection();
            DataSet             manifests    = new DataSet();

            manifests.Tables.Add(ManifestGeneration.GetDriverManifest(rm.ResourceManifestId, rm.ResourceId, usePlannedTimes, excludeFirstLine, showFullAddress, useInstructionOrder));

            if (manifests.Tables[0].Rows.Count > 0)
            {
                // Add blank rows if applicable
                if (extraRows > 0)
                {
                    for (int i = 0; i < extraRows; i++)
                    {
                        DataRow newRow = manifests.Tables[0].NewRow();
                        manifests.Tables[0].Rows.Add(newRow);
                    }
                }

                //-------------------------------------------------------------------------------------
                //									Load Report Section
                //-------------------------------------------------------------------------------------
                reportParams.Add("ManifestName", rm.Description);
                reportParams.Add("ManifestID", rm.ResourceManifestId.ToString());
                reportParams.Add("UsePlannedTimes", usePlannedTimes.ToString());

                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.RunSheet;
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = manifests;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = "";
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                // Show the user control
                if (includeScript)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">location.href='/reports/reportviewer.aspx?wiz=true';</script>");
                }
            }
        }
示例#5
0
        void btnAddSelectedJob_Click(object sender, EventArgs e)
        {
            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();

            int highestJobOrder = 0;

            // Find the highest job order and simply add it to the end
            foreach (Entities.ResourceManifestJob rmj in this.SavedResourceManifest.ResourceManifestJobs)
            {
                if (rmj.JobOrder > highestJobOrder)
                {
                    highestJobOrder = rmj.JobOrder;
                }
            }

            foreach (GridItem row in grdResourceManifestAddJobs.Items)
            {
                if (row.ItemType == GridItemType.AlternatingItem || row.ItemType == GridItemType.Item)
                {
                    HtmlInputHidden hidJobId          = row.FindControl("hidJobId") as HtmlInputHidden;
                    HtmlInputHidden hidJobOrder       = row.FindControl("hidJobOrder") as HtmlInputHidden;
                    CheckBox        chkDriverManifest = row.FindControl("chkDriverManifest") as CheckBox;
                    if (chkDriverManifest.Checked)
                    {
                        int jobId = int.Parse(hidJobId.Value);

                        // Double check to make sure the rmj isn't already on the manifest.
                        Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.JobId == Convert.ToInt32(hidJobId.Value));
                        if (rmj != null)
                        {
                            // The rmj is already on the manifest, simply change its removed flag
                            if (rmj.Removed == true)
                            {
                                rmj.Removed = false;
                            }
                        }
                        else
                        {
                            //Get Instructions Resourced
                            Facade.Instruction facInstruction = new Facade.Instruction();
                            List <int>         instructionIDs = facInstruction.GetInstructionIDsForDriverResource(jobId, this.SavedResourceManifest.ResourceId, true);

                            foreach (int instructionID in instructionIDs)
                            {
                                // create a new rmj to add to the manifest
                                Entities.ResourceManifestJob newRmj = new Orchestrator.Entities.ResourceManifestJob();
                                newRmj.JobOrder           = ++highestJobOrder;
                                newRmj.ResourceManifestId = this.SavedResourceManifest.ResourceManifestId;
                                newRmj.JobId         = Convert.ToInt32(hidJobId.Value);
                                newRmj.InstructionId = instructionID;
                                this.SavedResourceManifest.ResourceManifestJobs.Add(newRmj);
                            }
                        }
                    }
                }
            }

            facResourceManifest.UpdateResourceManifest(this.SavedResourceManifest, this.Page.User.Identity.Name);
            this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);

            grdResourceManifestJobs.Rebind();

            // Clear the add jobs grid.
            grdResourceManifestAddJobs.DataSource = null;
            grdResourceManifestAddJobs.DataBind();
            pnlAddJobs.Visible          = false;
            pnlExistingManifest.Visible = true;
        }
示例#6
0
        protected void btnDisplayManifest_Click(object sender, EventArgs e)
        {
            // Save the new job order (if its been changed)
            if (hidManifestChanged.Value.ToLower() == "true")
            {
                Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();

                // Save the job order
                foreach (GridItem row in grdResourceManifestJobs.Items)
                {
                    if (row.ItemType == GridItemType.AlternatingItem || row.ItemType == GridItemType.Item)
                    {
                        HtmlInputHidden hidJobId    = row.FindControl("hidJobId") as HtmlInputHidden;
                        HtmlInputHidden hidJobOrder = row.FindControl("hidJobOrder") as HtmlInputHidden;
                        HtmlInputHidden hidResourceManifestJobId = row.FindControl("hidResourceManifestJobId") as HtmlInputHidden;
                        CheckBox        chkDriverManifest        = row.FindControl("chkDriverManifest") as CheckBox;

                        //Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.JobId == Convert.ToInt32(hidJobId.Value));
                        Entities.ResourceManifestJob rmj = this.SavedResourceManifest.ResourceManifestJobs.Find(o => o.ResourceManifestJobId == Convert.ToInt32(hidResourceManifestJobId.Value));
                        rmj.JobOrder = Convert.ToInt32(hidJobOrder.Value);

                        // Also identify whether the user has removed the job from the manifest.
                        rmj.Removed = !chkDriverManifest.Checked;
                    }
                }

                this.SavedResourceManifest.Description  = txtManifestName.Text;
                this.SavedResourceManifest.ManifestDate = dteManifestDate.SelectedDate.Value;

                facResourceManifest.UpdateResourceManifest(this.SavedResourceManifest, this.Page.User.Identity.Name);

                this.SavedResourceManifest = facResourceManifest.GetResourceManifest(this.ResourceManifestId);
            }

            grdResourceManifestJobs.Rebind();

            // Retrieve the resource manifest
            NameValueCollection reportParams = new NameValueCollection();
            DataSet             manifests    = new DataSet();

            manifests.Tables.Add(ManifestGeneration.GetDriverManifest(this.SavedResourceManifest.ResourceManifestId, this.SavedResourceManifest.ResourceId, chkUsePlannedTimes.Checked, chkExcludeFirstRow.Checked, chkShowFullAddress.Checked, true));

            if (manifests.Tables[0].Rows.Count > 0)
            {
                // Add blank rows if applicable
                int extraRows = int.Parse(txtExtraRowCount.Text);
                if (extraRows > 0)
                {
                    for (int i = 0; i < extraRows; i++)
                    {
                        DataRow newRow = manifests.Tables[0].NewRow();
                        manifests.Tables[0].Rows.Add(newRow);
                    }
                }

                //-------------------------------------------------------------------------------------
                //									Load Report Section
                //-------------------------------------------------------------------------------------
                reportParams.Add("ManifestName", this.txtManifestName.Text);
                reportParams.Add("ManifestID", this.lblManifestNumber.Text);
                reportParams.Add("UsePlannedTimes", chkUsePlannedTimes.Checked.ToString());

                Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable]       = eReportType.RunSheet;
                Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable]     = reportParams;
                Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable]  = manifests;
                Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable]   = "";
                Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table";

                // Show the user control
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script language=\"javascript\">window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');</script>");
            }
        }
示例#7
0
        void grdResourceManifestJobs_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DataSet   dsDrivers = new DataSet();
            DataTable dt        = new DataTable();

            dt.Columns.Add(new DataColumn("JobID", typeof(int)));
            dt.Columns.Add(new DataColumn("DriverType", typeof(string)));
            dt.Columns.Add(new DataColumn("DriverResourceID", typeof(int)));
            dt.Columns.Add(new DataColumn("DriverName", typeof(string)));
            dt.Columns.Add(new DataColumn("Instructions", typeof(string)));
            dt.Columns.Add(new DataColumn("EarliestDateTime", typeof(DateTime)));
            dt.Columns.Add(new DataColumn("OrderIDs", typeof(string)));
            dt.Columns.Add(new DataColumn("ResourceManifestId", typeof(int)));
            dt.Columns.Add(new DataColumn("Removed", typeof(bool)));
            dt.Columns.Add(new DataColumn("ActiveOnAnotherManifestId", typeof(string)));
            dt.Columns.Add(new DataColumn("ResourceManifestJobId", typeof(int)));
            dsDrivers.Tables.Add(dt);

            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            DataSet ds = facResourceManifest.GetResourceManifestJobInstructions(this.ResourceManifestId);

            int  currentJobID  = -1;
            int  currentDriver = -1;
            bool rowAdded      = true;

            string InstructionText  = string.Empty;
            string myOrderIds       = String.Empty;
            bool   hasDriverChanged = false;

            DataRow row = null;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string   orderIDs = String.Empty;
                DateTime plannedArrivalDateTime = chkUsePlannedTimes.Checked ? Convert.ToDateTime(dr["PlannedArrivalDateTime"]) : Convert.ToDateTime(dr["OrderDateTime"]);

                // Get the OrderIDs for the PIL Production.
                orderIDs = GetOrderIDs(dr);

                if (((int)dr["DriverResourceID"] != currentDriver))
                {
                    if (row != null)
                    {
                        if (InstructionText.Length > 0)
                        {
                            row["Instructions"] = InstructionText;
                            row["OrderIDs"]     = myOrderIds;
                        }
                        // Add the row to the table
                        dt.Rows.Add(row);
                        rowAdded = true;
                    }
                    currentDriver    = (int)dr["DriverResourceID"];
                    InstructionText  = String.Empty;
                    myOrderIds       = String.Empty;
                    hasDriverChanged = true;
                }
                if (dr["JobID"] != DBNull.Value && (((int)dr["JobID"] != currentJobID) || hasDriverChanged))
                {
                    if (row != null && rowAdded == false)
                    {
                        if (InstructionText.Length > 0)
                        {
                            row["Instructions"] = InstructionText;
                            row["OrderIDs"]     = myOrderIds;
                            // Add the row to the table
                            dt.Rows.Add(row);
                        }
                    }
                    hasDriverChanged = false;
                    currentJobID     = (int)dr["JobID"];
                    InstructionText  = String.Empty;
                    myOrderIds       = String.Empty;

                    // Add a New Row
                    row = dt.NewRow();
                    row["DriverType"]       = dr["DriverType"];
                    row["DriverName"]       = dr["FullName"];
                    row["JobID"]            = dr["JobID"];
                    row["EarliestDateTime"] = plannedArrivalDateTime;
                    row["DriverResourceID"] = dr["DriverResourceID"];
                    rowAdded = false;
                    // Add the First Instruction to the Text
                    InstructionText                  = GetInstructionText(dr);
                    myOrderIds                       = GetOrderIDs(dr);
                    row["Instructions"]              = InstructionText;
                    row["OrderIDs"]                  = myOrderIds;
                    row["ResourceManifestId"]        = dr["ResourceManifestId"];
                    row["Removed"]                   = dr["Removed"];
                    row["ActiveOnAnotherManifestId"] = dr["ActiveOnAnotherManifestId"];
                    row["ResourceManifestJobId"]     = dr["ResourceManifestJobId"];
                }
                else if (dr["JobID"] != DBNull.Value && (int)dr["JobID"] == currentJobID)
                {
                    if (plannedArrivalDateTime < ((DateTime)row["EarliestDateTime"]))
                    {
                        row["EarliestDateTime"] = plannedArrivalDateTime;
                    }
                    //Add the instruction
                    InstructionText    += "<br/>" + GetInstructionText(dr);
                    myOrderIds         += ("," + GetOrderIDs(dr));
                    row["Instructions"] = InstructionText;
                }
                else
                {
                    // Not assigned
                    if (row != null && rowAdded == false)
                    {
                        if (InstructionText.Length > 0)
                        {
                            row["Instructions"] = InstructionText;
                            row["OrderIDs"]     = myOrderIds;
                            // Add the row to the table
                            dt.Rows.Add(row);
                        }
                    }

                    // Add a New Row
                    row = dt.NewRow();
                    row["DriverType"]       = dr["DriverType"];
                    row["DriverName"]       = dr["FullName"];
                    row["DriverResourceID"] = dr["DriverResourceID"];
                    row["JobID"]            = dr["JobID"];
                    rowAdded                         = false;
                    InstructionText                  = String.Empty;
                    myOrderIds                       = String.Empty;
                    row["ResourceManifestId"]        = dr["ResourceManifestId"];
                    row["Removed"]                   = dr["Removed"];
                    row["ActiveOnAnotherManifestId"] = dr["ActiveOnAnotherManifestId"];
                    row["ResourceManifestJobId"]     = dr["ResourceManifestJobId"];
                }
            }
            if (rowAdded == false && row != null && row["DriverType"] != DBNull.Value)
            {
                dt.Rows.Add(row);
            }

            foreach (DataRow r in dt.Rows)
            {
                if (r["Removed"].ToString().ToLower() == "true")
                {
                    r["Instructions"] = REMOVED_JOB_INSTRUCTION_TEXT;
                }
            }

            this.grdResourceManifestJobs.DataSource = dsDrivers;
        }
示例#8
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());
        }
示例#9
0
        void btnDriverManifests_Click(object sender, EventArgs e)
        {
            Session[Orchestrator.Globals.Constants.SubbyManifestListFromDate] = dteStartdate.SelectedDate;
            Session[Orchestrator.Globals.Constants.SubbyManifestListToDate]   = dteEndDate.SelectedDate;
            Session[Orchestrator.Globals.Constants.SubbyManifestDate]         = dteManifestDate.SelectedDate;

            CheckBox    chkManifest    = null;
            HiddenField hidResourceIds = null;

            int runningJobOrder = 0;

            Entities.ResourceManifest resourceManifest = new Orchestrator.Entities.ResourceManifest();
            resourceManifest.ManifestDate         = dteManifestDate.SelectedDate.Value;
            resourceManifest.Description          = txtManifestName.Text;
            resourceManifest.ResourceManifestJobs = new List <Entities.ResourceManifestJob>();

            Facade.ResourceManifest facResourceManifest = new Orchestrator.Facade.ResourceManifest();
            Facade.Instruction      facInstruction      = new Orchestrator.Facade.Instruction();

            foreach (Telerik.Web.UI.GridDataItem gdi in grdManifests.Items)
            {
                chkManifest = gdi.FindControl("chkDriverManifest") as CheckBox;
                if (chkManifest != null && chkManifest.Checked)
                {
                    if (gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobID"] != DBNull.Value)
                    {
                        hidResourceIds = gdi.FindControl("hidResourceId") as HiddenField;

                        // Save ResourceManifestJob rows here
                        int subContractorID = Convert.ToInt32(hidResourceIds.Value);
                        int jobId           = Convert.ToInt32(gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobID"]);

                        if (resourceManifest.SubcontractorId == null || resourceManifest.SubcontractorId == 0)
                        {
                            resourceManifest.SubcontractorId = subContractorID;
                        }

                        //Get Instructions Resourced
                        List <int> instructionIDs = facInstruction.GetInstructionIDsForSubContractor(jobId, subContractorID, true);

                        foreach (int instructionID in instructionIDs)
                        {
                            // Create new resource manifest jobs rows
                            Entities.ResourceManifestJob rmj = new Orchestrator.Entities.ResourceManifestJob();
                            rmj.JobId         = jobId;
                            rmj.InstructionId = instructionID;
                            rmj.JobOrder      = ++runningJobOrder;

                            // Add the resource manifest job to the collection.
                            resourceManifest.ResourceManifestJobs.Add(rmj);
                        }
                    }
                }
            }

            // Create the new resource manifest.
            this.ResourceManifestId = facResourceManifest.CreateResourceManifest(resourceManifest, this.Page.User.Identity.Name);

            // Redirect to the drivers ResourceManifestJob edit page.
            Response.Redirect("SubbyResourceManifest.aspx?rmID=" + this.ResourceManifestId.ToString());
        }
示例#10
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);
        }
示例#11
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);
        }