Ejemplo n.º 1
0
        private static bool CommunicateInstructionsForSubContractor(int jobID, int subContractorId, string userId)
        {
            if (!Globals.Configuration.SubContractorCommunicationsRequired)
            {
                return(false);
            }

            Entities.DriverCommunication communication = new Entities.DriverCommunication();
            communication.Comments = "Communicated via Deliveries ScreSubcontractorCommunicationsRequireden";
            communication.DriverCommunicationStatus = eDriverCommunicationStatus.Accepted;
            string mobileNumber = "unknown";

            communication.DriverCommunicationType = eDriverCommunicationType.Manifest;
            communication.NumberUsed = mobileNumber;

            Facade.IInstruction facInstruction = new Facade.Instruction();
            List <int>          instructionIds = facInstruction.GetInstructionIDsForSubContractor(jobID, subContractorId, false);

            Facade.IJobSubContractor facJob = new Facade.Job();
            foreach (int instructionId in instructionIds)
            {
                communication.DriverCommunicationId = facJob.CreateCommunication(jobID, subContractorId, communication, userId);
            }

            return(true);
        }
        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 (Telerik.Web.UI.GridItem row in grdResourceManifestAddJobs.Items)
            {
                if (row.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem || row.ItemType == Telerik.Web.UI.GridItemType.Item)
                {
                    HtmlInputHidden hidJobId          = row.FindControl("hidJobId") as HtmlInputHidden;
                    HtmlInputHidden hidJobOrder       = row.FindControl("hidJobOrder") as HtmlInputHidden;
                    CheckBox        chkDriverManifest = row.FindControl("chkDriverManifest") as CheckBox;

                    int jobId = int.Parse(hidJobId.Value);

                    if (chkDriverManifest.Checked)
                    {
                        // 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.GetInstructionIDsForSubContractor(jobId, this.SavedResourceManifest.SubcontractorId.Value, 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;
        }