Exemplo n.º 1
0
        private bool UpdatePoint()
        {
            Facade.IPoint facPoint = new Facade.Point();
            string        userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // Ensure the latest traffic area id is reflected in the update.
            point.Address.TrafficArea.TrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);

            Entities.FacadeResult retVal = facPoint.Update(point, userName);
            if (retVal.Success)
            {
                lblConfirmation.Text    = "The point has been updated.";
                lblConfirmation.Visible = true;

                point = facPoint.GetPointForPointId(point.PointId);
                cboTrafficArea.SelectedValue = point.Address.TrafficArea.TrafficAreaId.ToString();
            }
            else
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(retVal.Success);
        }
Exemplo n.º 2
0
        ///	<summary>
        /// Update Trailer
        ///	</summary>
        private bool UpdateTrailer()
        {
            Facade.ITrailer facResource = new Facade.Resource();
            string          userName    = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult result = facResource.Update(trailer, userName);

            if (result.Success)
            {
                if (Configuration.IsMwfCustomer && !string.IsNullOrEmpty(Configuration.BlueSphereCustomerId))
                {
                    try
                    {
                        MobileWorkerFlow.MWFServicesCommunication.Client.UpdateTrailerInBlueSphere(trailer, trailer.ResourceId.ToString());
                    }
                    catch (Exception ex)
                    {
                        // MM (2nd April 2012): Not ideal but solution for now, if fail to get through to bluesphere then show error to user
                        lblConfirmation.Text      = "There was an error updating the trailer: " + ex.Message;
                        lblConfirmation.Visible   = true;
                        lblConfirmation.ForeColor = Color.Red;
                        result = new Entities.FacadeResult(false);
                        return(false);
                    }
                }
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(result.Success);
        }
Exemplo n.º 3
0
        private void AddDestination(int jobId)
        {
            DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

            Facade.IJob facJob = new Facade.Job();

            // Define the trunk instruction.
            DateTime bookedDateTime = new DateTime(rdiArrivalDate.SelectedDate.Value.Year, rdiArrivalDate.SelectedDate.Value.Month, rdiArrivalDate.SelectedDate.Value.Day, rdiArrivalTime.SelectedDate.Value.Hour, rdiArrivalTime.SelectedDate.Value.Minute, 0);
            TimeSpan travellingTime = bookedDateTime.Subtract(CurrentJob.Instructions[CurrentJob.Instructions.Count - 1].PlannedDepartureDateTime);

            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;
            Entities.FacadeResult    result = facJob.AttachDestination(CurrentJob, ucPoint.PointID, chkDriver.Checked, chkVehicle.Checked, chkTrailer.Checked, travellingTime, true, user.IdentityId, user.UserName);

            if (result.Success)
            {
                Cache.Remove(jobEntityForJobId + JobId.ToString());
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infrigementDisplay.Infringements = result.Infringements;
                infrigementDisplay.DisplayInfringments();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a job to manage the collection and delivery of the orders.
        /// </summary>
        private void CreateJob()
        {
            string userName = ((Entities.CustomPrincipal)Page.User).UserName;

            // Ensure the orders are all of the correct business type.
            Facade.IOrderGroup facOrderGroup = new Facade.Order();
            var businessTypeID = facOrderGroup.DetermineBusinessType(OrderGroup.OrderGroupID, false, userName);

            Facade.IJob           facJob = new Facade.Job();
            Entities.FacadeResult res    = facJob.CreateJobForOrderGroup(businessTypeID, this.OrderGroup, userName);

            if (res.Success)
            {
                int jobID = res.ObjectId;

                string jobDetailsRelativeURL = string.Format("~/Job/Job.aspx?wiz=true&jobID={0}", jobID);
                string jobDetailsURL         = Page.ResolveClientUrl(jobDetailsRelativeURL);
                string jobDetailsJS          = string.Format("openResizableDialogWithScrollbars('{0}' + getCSID(), 1220, 930);", jobDetailsURL);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "viewJob", jobDetailsJS, true);
            }
            else
            {
                this.DisplayInfringments(res);
            }

            // Update the UI of the page.
            RebindPage();
        }
Exemplo n.º 5
0
        private bool UpdateInstruction()
        {
            Facade.IJob facJob = new Facade.Job();
            string      userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult result = null;

            if (m_instruction.InstructionID == 0)
            {
                int plannerId = ((Entities.CustomPrincipal)Page.User).IdentityId;
                result = facJob.AddInstruction(m_job, m_instruction, plannerId, userId);
            }
            else
            {
                // Update the instruction
                result = facJob.UpdateInstruction(m_job, m_instruction, userId);
            }

            if (result.Success)
            {
                if (!chkManualRateEntry.Checked)
                {
                    // Cause the rates to be recalculated for this job.
                    facJob.PriceJob(m_jobId, ((Entities.CustomPrincipal)Page.User).UserName);
                }

                m_job            = facJob.GetJob(m_jobId, true);
                m_job.Charge     = ((Facade.IJobCharge)facJob).GetForJobId(m_jobId);
                m_job.References = ((Facade.IJobReference)facJob).GetJobReferences(m_jobId);
            }

            return(result.Success);
        }
Exemplo n.º 6
0
        void lvDuplicateAddress_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            int pointId = Convert.ToInt32(e.CommandArgument);

            Facade.IPoint  facPoint = new Facade.Point();
            Entities.Point p        = facPoint.GetPointForPointId(pointId);
            if (p != null)
            {
                if (p.PointStateId == ePointState.Deleted)
                {
                    string userId = ((Orchestrator.Entities.CustomPrincipal)Page.User).UserName;
                    p.PointStateId = ePointState.Approved;
                    Entities.FacadeResult result = facPoint.Update(p, userId);
                }

                this.SelectedPoint     = p;
                cboPoint.Text          = p.Description;
                cboPoint.SelectedValue = p.IdentityId.ToString() + "," + p.PointId.ToString();

                pnlNewPoint.Visible = false;
                pnlPoint.Visible    = true;
                this.divDuplicateAddress.Visible = false;
                inpCreateNewPointSelected.Value  = string.Empty;
            }
        }
Exemplo n.º 7
0
        private void RemoveDestination(int jobId)
        {
            DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

            Facade.IJob facJob = new Facade.Job();

            if (CurrentJob.Instructions.Count > 0 && FoundInstruction == null)
            {
                FoundInstruction = CurrentJob.Instructions.Find(instruc => instruc.InstructionTypeId == (int)eInstructionType.Trunk && instruc.InstructionOrder == CurrentJob.Instructions.Count - 1 && (instruc.CollectDrops.Count == 0 || instruc.CollectDrops[0].OrderID == 0));
            }

            Entities.FacadeResult result = facJob.RemoveInstruction(CurrentJob, FoundInstruction.InstructionID, ((Entities.CustomPrincipal)Page.User).UserName);

            if (result.Success)
            {
                Cache.Remove(jobEntityForJobId + JobId.ToString());
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infrigementDisplay.Infringements = result.Infringements;
                infrigementDisplay.DisplayInfringments();
            }
        }
Exemplo n.º 8
0
        //-----------------------------------------------------------------------------------------------------------

        private void ChangeExistingInstruction(Entities.Instruction instruction, Entities.Job run, List <int> orderIds)
        {
            Facade.IInstruction facInstruction = new Facade.Instruction();
            // no need to create a new instruction.
            Entities.FacadeResult      retVal   = new Entities.FacadeResult();
            Orchestrator.Facade.IOrder facOrder = new Orchestrator.Facade.Order();
            Facade.Job facJob = new Facade.Job();
            Entities.CollectDropCollection collectDrops = new Orchestrator.Entities.CollectDropCollection();
            // Update the Order and the relevant instructions
            foreach (int ordId in orderIds)
            {
                DataSet dsOrders = facOrder.GetLegsForOrder(ordId);
                // Get the last job id from the dataset
                int jobId = -1;
                if (dsOrders.Tables[0].Rows.Count > 0)
                {
                    jobId = Convert.ToInt32(dsOrders.Tables[0].Rows[dsOrders.Tables[0].Rows.Count - 1]["JobID"].ToString());
                }

                Entities.Order currentOrder = facOrder.GetForOrderID(ordId);
                if (instruction.CollectDrops.GetForOrderID(currentOrder.OrderID) != null)
                {
                    facInstruction.UpdatePointID(instruction.InstructionID, this.cboNewDeliveryPoint.PointID, this.Page.User.Identity.Name);
                    instruction.PointID = this.cboNewDeliveryPoint.PointID;

                    this.UpdateOrder(currentOrder);

                    instruction.BookedDateTime           = currentOrder.DeliveryDateTime;
                    instruction.PlannedArrivalDateTime   = currentOrder.DeliveryDateTime;
                    instruction.PlannedDepartureDateTime = currentOrder.DeliveryDateTime;
                }
            }
        }
Exemplo n.º 9
0
        private bool UpdatePoint()
        {
            Facade.IPoint facPoint = new Facade.Point();
            string        userName = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult retVal = facPoint.Update(_point, userName);

            return(retVal.Success);
        }
        private void btnAssign_Click(object sender, EventArgs e)
        {
            ArrayList arrJobId = null;
            string    jobIdCSV = string.Empty;
            string    userName = ((Entities.CustomPrincipal)Page.User).UserName;

            btnAssign.DisableServerSideValidation();

            arrJobId = GetJobsSelected();

            if (arrJobId.Count == 0)
            {
                foreach (object item in arrJobId)
                {
                    if (jobIdCSV != String.Empty)
                    {
                        jobIdCSV += ",";
                    }

                    jobIdCSV += (item);
                }

                lblAssignUpdate.Text      = "No jobs have be selected to assign invoice number, please select jobs to assign.";
                lblAssignUpdate.ForeColor = Color.Red;
                return;
            }
            else
            {
                // Add the invoice number to the selected jobs ids.
                Facade.IJobSubContractor facSub = new Facade.Job();

                Entities.FacadeResult result = facSub.AssignInvoiceNumber(txtInvoiceNumber.Text, hidSelectedJobs.Value, userName); //brInvoice.ValidateSubContractors(jobIdCSV);

                if (result.Success)
                {
                    lblAssignUpdate.Text      = "The jobs have been assigned the customers invoice number";
                    lblAssignUpdate.ForeColor = Color.Blue;
                    txtInvoiceNumber.Text     = string.Empty;

                    LoadGrid();
                }
                else
                {
                    // Display errors
                    infringementDisplay.Infringements = result.Infringements;
                    infringementDisplay.DisplayInfringments();

                    lblAssignUpdate.Text      = "The jobs have been failed to assign the customers invoice number";
                    lblAssignUpdate.ForeColor = Color.Red;
                }
            }
        }
Exemplo n.º 11
0
        void btnConfirm_Click(object sender, EventArgs e)
        {
            int newControlAreaId = Convert.ToInt32(cboControlArea.SelectedValue);
            int newTrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue);

            bool success = true;

            if (newControlAreaId != m_instruction.ControlAreaId || newTrafficAreaId != m_instruction.TrafficAreaId)
            {
                // Update the control area and traffic area for the leg, and it's following legs if the checkbox is checked.
                // If the checkbox is checked, the resources on the leg are moved onto the receiving planner's resource list.
                Facade.IJob facJob = new Facade.Job();

                // The end instruction of the leg should always be passed when calling SetControlArea. This is different from
                // m_instruction, which is the start instruction of the leg. The Start instruction of the leg detertmines the
                // traffic area responsible for planning the leg.
                int instructionOrder = m_instruction.InstructionOrder + 1;

                if (m_instruction.InstructionOrder == 0)
                {
                    // The instruction is the 1st on the job
                    // Edge case: ensure it is not the only one (ie. collection only job)
                    // If it is then we shouldn't increment the instruction order when calling SetControlArea.
                    Facade.IInstruction            facInstruction = new Facade.Instruction();
                    Entities.InstructionCollection instructions   = facInstruction.GetForJobId(m_instruction.JobId);

                    if (instructions.Count == 1)
                    {
                        instructionOrder--;
                    }
                }

                Entities.FacadeResult result = facJob.SetControlArea(m_instruction.JobId, newControlAreaId, newTrafficAreaId, instructionOrder, chkApplyToAllFollowingInstructions.Checked, m_lastUpdateDate, ((Entities.CustomPrincipal)Page.User).UserName);
                success = result.Success;

                if (!success)
                {
                    // Display the infringements.
                    idErrors.Infringements = result.Infringements;
                    idErrors.DisplayInfringments();
                    idErrors.Visible = true;
                    trErrors.Visible = true;
                }
            }

            if (success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
        }
Exemplo n.º 12
0
        private bool AddPoint()
        {
            if (_point != null)
            {
                Facade.IPoint facPoint = new Facade.Point();
                string        userName = ((Entities.CustomPrincipal)Page.User).UserName;

                Entities.FacadeResult retVal = facPoint.Create(_point, userName);

                return(retVal.Success);
            }

            return(false);
        }
        /// <summary>
        /// Updates the location
        /// </summary>
        /// <returns>true if the update succeeded, false otherwise</returns>
        private bool UpdateLocation()
        {
            Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult result = facOrganisationLocation.Update(m_location, _individual, userId);
            if (!result.Success)
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            m_location = facOrganisationLocation.GetLocationForOrganisationLocationId(m_location.OrganisationLocationId);
            cboTrafficArea.SelectedValue = m_location.Point.Address.TrafficArea.TrafficAreaId.ToString();

            return(result.Success);
        }
Exemplo n.º 14
0
        private void RemoveTrunkInstruction()
        {
            Entities.CustomPrincipal user = (Entities.CustomPrincipal)Page.User;

            Facade.IJob           facJob = new Facade.Job();
            Entities.FacadeResult result = facJob.RemoveInstruction(m_jobId, m_instructionID, user.UserName);

            if (result.Success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infrigementDisplay.Infringements = result.Infringements;
                infrigementDisplay.DisplayInfringments();
            }
        }
Exemplo n.º 15
0
        protected void btnConfirm_Click1(object sender, EventArgs e)
        {
            Facade.IJob           facJob = new Facade.Job();
            Entities.FacadeResult result = null;

            result = facJob.MultiTrunk(_jobId, ucMultiTrunk.SelectedMultiTrunk, _endInstruction, ucMultiTrunk.ArrivalDateTime, _job.IdentityId, user.UserName, _lastUpdateDate, ucMultiTrunk.UseDriver, ucMultiTrunk.UseVehicle);

            if (result.Success == false)
            {
                // Display infringements
                infrigementDisplay.Infringements = result.Infringements;
                infrigementDisplay.DisplayInfringments();
                return;
            }

            this.ReturnValue = "refresh";
            this.Close();
        }
Exemplo n.º 16
0
        protected void btnConfirm_Click1(object sender, EventArgs e)
        {
            Facade.IJob           facJob = new Facade.Job();
            Entities.FacadeResult result = null;

            result = facJob.AttachMultipleDestinations(_jobId, ucMultiDestination.SelectedMultiTrunk, _endInstruction, ucMultiDestination.ArrivalDateTime, _lastUpdateDate, ucMultiDestination.UseDriver, ucMultiDestination.UseVehicle, user.IdentityId, user.UserName);

            if (result.Success)
            {
                Cache.Remove(jobEntityForJobId + this._jobId.ToString());
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infrigementDisplay.Infringements = result.Infringements;
                infrigementDisplay.DisplayInfringments();
            }
        }
Exemplo n.º 17
0
        private bool AddOrganisation()
        {
            int  identityId = 0;
            bool success    = false;

            Entities.FacadeResult retVal = new Entities.FacadeResult(0);

            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            retVal = facOrganisation.Create(m_organisation, userId);

            if (!retVal.Success)
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
                infringementDisplay.Visible = true;

                lblConfirmation.Text      = "There was an error adding the clients customer, please try again.";
                lblConfirmation.Visible   = true;
                lblConfirmation.ForeColor = Color.Red;
                success = false;
            }
            else
            {
                identityId = retVal.ObjectId;
                success    = true;
            }

            Repositories.DTOs.GeofenceNotificationSettings settings = new Repositories.DTOs.GeofenceNotificationSettings();
            settings.IdentityId = m_organisation.IdentityId;
            settings.Enabled    = chkBoxEnableNotification.Checked;
            if (chkBoxEnableNotification.Checked)
            {
                settings.NotificationType = Convert.ToInt32(cbNotificationType.SelectedValue);
                settings.NotifyWhen       = Convert.ToInt32(cbNotifyWhen.SelectedValue);
                settings.Recipient        = txtContactDetail.Text;
            }
            facOrganisation.AddOrUpdate(settings, userId);

            return(success);
        }
        /// <summary>
        /// Creates the location
        /// </summary>
        /// <returns>true if the create succeeded, false otherwise</returns>
        private bool CreateLocation()
        {
            Facade.IOrganisationLocation facOrganisationLocation = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult result = facOrganisationLocation.Create(m_location, _individual, userId);

            if (result.Success)
            {
                m_locationId = result.ObjectId;
                m_location.OrganisationLocationId = m_locationId;
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(result.Success);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Creates a new point based on the separate parts of the point passed as arguements.
        /// </summary>
        /// <param name="organisationId">The identity id of the organisation this point is registered to.</param>
        /// <param name="organisationName">The name of the organisation this point is registered to.</param>
        /// <param name="closestTownId">The id of the town id that is closest to this point.</param>
        /// <param name="description">The description that should be given to this point.</param>
        /// <param name="addressLine1">The first line of the address.</param>
        /// <param name="addressLine2">The second line of the address.</param>
        /// <param name="addressLine3">The third line of the address.</param>
        /// <param name="postTown">The town.</param>
        /// <param name="county">The county the point is within.</param>
        /// <param name="postCode">The post code.</param>
        /// <param name="longitude">The longitude attached to this point.</param>
        /// <param name="latitude">The latitude attached to this point.</param>
        /// <param name="trafficAreaId">The traffic area for this point.</param>
        /// <param name="userId">The id of the user creating this point.</param>
        /// <returns>The id of the new point created, or 0 if there were infringments encountered.</returns>
        private int CreateNewPoint(int organisationId, string organisationName, int closestTownId, string description, string addressLine1, string addressLine2, string addressLine3, string postTown, string county, string postCode, decimal longitude, decimal latitude, int trafficAreaId, string userId)
        {
            Entities.FacadeResult retVal = null;

            Entities.Point point = new Entities.Point();
            point.Address = new Entities.Address();
            point.Address.AddressLine1 = addressLine1;
            point.Address.AddressLine2 = addressLine2;
            point.Address.AddressLine3 = addressLine3;
            point.Address.PostTown     = postTown;
            point.Address.County       = county;
            point.Address.PostCode     = postCode;
            point.Address.Longitude    = longitude;
            point.Address.Latitude     = latitude;
            point.Address.TrafficArea  = new Entities.TrafficArea();
            point.Address.TrafficArea.TrafficAreaId = trafficAreaId;
            point.Address.AddressType = eAddressType.Point;

            point.Description      = description;
            point.IdentityId       = organisationId;
            point.Latitude         = latitude;
            point.Longitude        = longitude;
            point.OrganisationName = organisationName;
            Facade.IPostTown facPostTown = new Facade.Point();
            point.PostTown = facPostTown.GetPostTownForTownId(closestTownId);

            Facade.IPoint facPoint = new Facade.Point();
            retVal = facPoint.Create(point, userId);

            if (retVal.Success)
            {
                return(retVal.ObjectId);
            }
            else
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();

                return(0);
            }
        }
        void btnUpdate_Click(object sender, EventArgs e)
        {
            Entities.FacadeResult    result          = null;
            Entities.CustomPrincipal user            = (Entities.CustomPrincipal)Page.User;
            Facade.IPalletReturn     facPalletReturn = new Facade.Pallet();

            result = facPalletReturn.UpdatePalletHandlingInstructions(m_job, UpdatedPalletDeliveries, PalletDeliveries, user.IdentityId, user.UserName);

            if (result != null && result.Success)
            {
                this.ReturnValue        = bool.TrueString;
                PalletDeliveries        = null;
                UpdatedPalletDeliveries = null;
                this.Close();
            }
            else
            {
                idErrors.Infringements = result.Infringements;
                idErrors.DisplayInfringments();
            }
        }
Exemplo n.º 21
0
        private bool UpdateOrganisation()
        {
            Facade.IOrganisation facOrganisaton = new Facade.Organisation();
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            if (m_organisation.IdentityStatus == eIdentityStatus.Active && m_originalStatus == eIdentityStatus.Unapproved)
            {
                // Approve all the Points for this Client Customer too.
                Facade.IPoint facPoint = new Facade.Point();
                bool          success  = facPoint.ApproveAllPointsForOganisation(m_organisation.IdentityId);
            }


            Entities.FacadeResult retVal = facOrganisaton.Update(m_organisation, userId);

            if (!retVal.Success)
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
                infringementDisplay.Visible = true;
            }

            if (Globals.Configuration.ClientCustomerDeliveryNotificationEnabled)
            {
                Repositories.DTOs.GeofenceNotificationSettings settings = new Repositories.DTOs.GeofenceNotificationSettings();
                settings.IdentityId = m_organisation.IdentityId;
                settings.Enabled    = chkBoxEnableNotification.Checked;

                if (chkBoxEnableNotification.Checked)
                {
                    settings.NotificationType = Convert.ToInt32(cbNotificationType.SelectedValue);
                    settings.NotifyWhen       = Convert.ToInt32(cbNotifyWhen.SelectedValue);
                    settings.Recipient        = txtContactDetail.Text;
                }

                facOrganisaton.AddOrUpdate(settings, userId);
            }

            return(retVal.Success);
        }
Exemplo n.º 22
0
        private void LinkJobs()
        {
            bool linkDriver  = chkLinkDriver.Checked;
            bool linkVehicle = chkLinkVehicle.Checked;
            bool linkTrailer = chkLinkTrailer.Checked;

            List <int> legIds = new List <int>();

            foreach (RepeaterItem repItem in repLegs.Items)
            {
                if (repItem.ItemType == ListItemType.Item || repItem.ItemType == ListItemType.AlternatingItem)
                {
                    CheckBox chkThisLeg = (CheckBox)repItem.FindControl("chkThisLeg");

                    if (chkThisLeg.Checked)
                    {
                        HtmlInputHidden hidInstructionId = (HtmlInputHidden)repItem.FindControl("hidInstructionId");
                        legIds.Add(int.Parse(hidInstructionId.Value));
                    }
                }
            }

            DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

            Facade.IJob           facJob = new Facade.Job();
            Entities.FacadeResult result = facJob.LinkJobs(m_sourceInstructionId, m_jobId, legIds, linkDriver, linkVehicle, linkTrailer, lastUpdateDate, ((Entities.CustomPrincipal)Page.User).UserName);

            if (result.Success)
            {
                mwhelper.CloseForm     = true;
                mwhelper.CausePostBack = true;
                mwhelper.OutputData    = "<linkJobs />";
            }
            else
            {
                infrigementDisplay.Infringements = result.Infringements;
                infrigementDisplay.DisplayInfringments();
                infrigementDisplay.Visible = true;
            }
        }
Exemplo n.º 23
0
        public Orchestrator.WebUI.Services.Point UpdatePoint(Orchestrator.WebUI.Services.Point p, string userId)
        {
            Orchestrator.WebUI.Services.Point returnPoint   = null;
            Orchestrator.Facade.IPoint        facPoint      = new Orchestrator.Facade.Point();
            Orchestrator.Entities.Point       selectedPoint = facPoint.GetPointForPointId(p.PointID);
            selectedPoint.Description                = p.Description;
            selectedPoint.Latitude                   = (decimal)p.Latitide;
            selectedPoint.Longitude                  = (decimal)p.Longitude;
            selectedPoint.PostTown.TownId            = p.ClosestTownID;
            selectedPoint.PostTown.TownName          = p.ClosestTown;
            selectedPoint.PointNotes                 = p.PointNotes;
            selectedPoint.PointCode                  = p.PointCode;
            selectedPoint.PhoneNumber                = p.PhoneNumber;
            selectedPoint.Address.AddressLine1       = p.AddressLine1;
            selectedPoint.Address.AddressLine2       = p.AddressLine2;
            selectedPoint.Address.AddressLine3       = p.AddressLine3;
            selectedPoint.Address.PostTown           = p.PostTown;
            selectedPoint.Address.County             = p.County;
            selectedPoint.Address.PostCode           = p.PostCode;
            selectedPoint.Address.CountryId          = p.CountryID;
            selectedPoint.Address.CountryDescription = p.CountryDescription;

            Entities.FacadeResult facResult = facPoint.Update(selectedPoint, userId);

            if (facResult.Success)
            {
                returnPoint = this.GetPointForWebService(selectedPoint.PointId);
            }
            else
            {
                foreach (BusinessRuleInfringement i in facResult.Infringements)
                {
                    p.ErrorMeesage += String.Format("{0} : {1}{2}", i.Key, i.Description, Environment.NewLine);
                }

                returnPoint = p;
            }

            return(returnPoint);
        }
Exemplo n.º 24
0
        protected void btnApproveOrganisation_Click(object sender, EventArgs e)
        {
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            int organisationID = Convert.ToInt32(Request.QueryString["OrganisationID"].ToString());

            this.Organisation = facOrganisation.GetForIdentityId(organisationID);
            this.Organisation.IdentityStatus = eIdentityStatus.Active;

            Entities.FacadeResult result = null;
            result = facOrganisation.Update(this.Organisation, this.Page.User.Identity.Name);

            if (result.Success)
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApprovePoint", "window.opener.__doPostBack('','Refresh');window.close();", true);
            }
            else
            {
                idErrors.Infringements = result.Infringements;
                idErrors.DisplayInfringments();
                idErrors.Visible = true;
            }
        }
Exemplo n.º 25
0
        private bool AddPoint()
        {
            Facade.IPoint facPoint = new Facade.Point();
            string        userName = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.FacadeResult retVal = facPoint.Create(point, userName);

            if (retVal.Success)
            {
                lblConfirmation.Text    = "The point was added.";
                lblConfirmation.Visible = true;

                ViewState["pointId"] = retVal.ObjectId;

                point = facPoint.GetPointForPointId(retVal.ObjectId);

                ViewState["point"] = point;

                cboClient.Enabled = false;

                PopulateTrafficAreaControl();

                cboTrafficArea.Visible = true;
                lblTrafficArea.Visible = true;
                cboTrafficArea.Items.FindByValue(point.Address.TrafficArea.TrafficAreaId.ToString()).Selected = true;

                btnAdd.Text = "Update";
                m_isUpdate  = true;

                PopulateTrafficAreaControl();
            }
            else
            {
                infringementDisplay.Infringements = retVal.Infringements;
                infringementDisplay.DisplayInfringments();
            }

            return(retVal.Success);
        }
Exemplo n.º 26
0
        protected void btnApprovePoint_Click(object sender, EventArgs e)
        {
            int orderId = Convert.ToInt32(Request.QueryString["OrderId"].ToString());
            int pointId = Convert.ToInt32(Request.QueryString["PointId"].ToString());

            Facade.Point   facPoint = new Orchestrator.Facade.Point();
            Entities.Point point    = facPoint.GetPointForPointId(pointId);

            Facade.IOrganisation  facOrg = new Facade.Organisation();
            Entities.Organisation org    = facOrg.GetForName(point.OrganisationName);

            Entities.FacadeResult res = null;

            using (TransactionScope ts = new TransactionScope())
            {
                if (org.IdentityStatus == eIdentityStatus.Unapproved)
                {
                    // Set the identityStatus to approved
                    org.IdentityStatus = eIdentityStatus.Active;
                    facOrg.Update(org, this.Page.User.Identity.Name);
                }

                point.PointStateId = ePointState.Approved;
                res = facPoint.Update(point, this.Page.User.Identity.Name);

                ts.Complete();
            }

            if (res.Success)
            {
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ApprovePoint", "window.opener.__doPostBack('','Refresh');window.close();", true);
            }
            else
            {
                idErrors.Infringements = res.Infringements;
                idErrors.DisplayInfringments();
                idErrors.Visible = true;
            }
        }
Exemplo n.º 27
0
        private void StoreActual()
        {
            Entities.FacadeResult result = null;
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            Entities.InstructionActual ia = null;
            Facade.IJob facJob            = new Facade.Job();
            string      errMessage        = "<div style=\"background-color:white; color:red; border:solid 1pt black; padding:5px;\"> One or nore of the Call Ins that you wanted to create could not be done as there are either earlier debriefs to be processed first or they are on the same job as others that are for Customers that have been marked as to require the capture of Debrief information : <br/>{0}</div>";
            string      jobLink           = "<a href=\"job.aspx?jobId={0}&csid=xx\" target=\"_blank\">{0}</a>";
            string      jobLinks          = string.Empty;
            string      jobIds            = string.Empty;

            int i = 0;

            foreach (Telerik.Web.UI.GridDataItem gdi in grdCallIns.SelectedItems)
            {
                if (i > 100)
                {
                    break;
                }
                m_instructionId = (int)gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["InstructionId"];
                m_jobID         = (int)gdi.OwnerTableView.DataKeyValues[gdi.ItemIndex]["JobId"];
                m_job           = facJob.GetJob(m_jobID, true);
                ia     = PopulateInstructionActual();
                result = CreateInstructionActual(ia, userId);
                if (result.Success == false)
                {
                    jobIds += string.Format(jobLink, m_jobID.ToString()) + "<br/>";
                }
                i++;
            }

            if (jobIds.Length > 0)
            {
                litError.Text    = string.Format(errMessage, jobIds);
                litError.Visible = true;
            }
        }
Exemplo n.º 28
0
        void btnConfirm_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Facade.IJob facJob = new Facade.Job();
                Entities.InstructionCollection instructionCollection = PopulateInstructions();

                DateTime lastUpdateDate      = DateTime.Parse(Request.QueryString["LastUpdateDate"]);
                Entities.FacadeResult result = facJob.UpdatePlannedTimes(this.JobID, instructionCollection, lastUpdateDate, ((Entities.CustomPrincipal)Page.User).Name);

                if (result.Success)
                {
                    // Successful update return and refresh the grid.
                    this.ReturnValue = "refresh";
                    this.Close();
                }
                else
                {
                    // Display infringements to user.
                    infrigementDisplay.Infringements = result.Infringements;
                    infrigementDisplay.DisplayInfringments();
                }
            }
        }
        protected bool GenerateBatch()
        {
            bool success = true;

            NameValueCollection clients = new NameValueCollection();
            NameValueCollection batchNo = new NameValueCollection();

            foreach (DataListItem item in dlJob.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    string batchId    = ((TextBox)item.FindControl("txtBatchNo")).Text;
                    string jobId      = ((LinkButton)item.FindControl("lnkJobId")).Text;
                    string identityId = ((HtmlInputHidden)item.FindControl("hidIdentityId")).Value;

                    if (batchId != String.Empty)
                    {
                        HtmlImage imgError   = (HtmlImage)item.FindControl("imgError");
                        TextBox   txtBatchNo = (TextBox)item.FindControl("txtBatchNo");

                        // Check whether this is a new batch and if
                        // so make sure the job added is from the same client
                        if (m_batches.Get(batchId) == null)
                        {
                            m_batches.Add(batchId, jobId);
                            clients.Add(batchId, identityId);
                            batchNo.Add(batchId, batchId);
                            imgError.Visible     = false;
                            txtBatchNo.BackColor = Color.White;
                            txtBatchNo.ToolTip   = string.Empty;
                        }
                        else
                        {
                            if (identityId == clients.Get(batchId))
                            {
                                m_batches.Set(batchId, m_batches.Get(batchId) + "," + jobId);
                                imgError.Visible     = false;
                                txtBatchNo.BackColor = Color.White;
                                txtBatchNo.ToolTip   = string.Empty;
                            }
                            else
                            {
                                txtBatchNo.BackColor = Color.Red;
                                txtBatchNo.ToolTip   = imgError.Alt;
                                imgError.Visible     = true;
                                success = false;
                            }
                        }
                    }
                }
            }

            if (!success)
            {
                return(success);
            }

            // Record batches that have been successful
            Facade.IInvoiceBatches facInv = new Facade.Invoice();
            bool   marker = false;
            string userId = ((Entities.CustomPrincipal)Page.User).UserName;

            for (int i = 0; i < m_batches.Count; i++)
            {
                int    batchId = Convert.ToInt32(batchNo[i].ToString());
                string jobIds  = m_batches[i].ToString();

                // Check whether these are OLD or NEW invoice batches either create or update
                bool exists = facInv.CheckBatchExists(batchId);

                if (exists)
                {
                    facInv.Update(batchId, jobIds, userId); // UPDATE If it has a Batch Id
                    marker = true;
                }
                else
                {
                    Entities.FacadeResult result = facInv.Create(batchId, jobIds, userId); // CREATE If it hasn't an Id

                    if (result.Success)
                    {
                        marker = true;
                    }
                    else
                    {
                        infringementDisplay.Infringements = result.Infringements;
                        infringementDisplay.DisplayInfringments();

                        marker = false;
                    }
                }
            }

            return(marker);
        }
Exemplo n.º 30
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (cboPoint.SelectedValue == String.Empty)
                {
                    int ownerID = 0;

                    if (cboOwner.SelectedValue == string.Empty)
                    {
                        // Create a new client customer for the point owner (this can be upgraded to client in the future).
                        Entities.Organisation organisation = new Entities.Organisation();
                        organisation.OrganisationName = cboOwner.Text;
                        organisation.OrganisationType = eOrganisationType.ClientCustomer;
                        Facade.IOrganisation  facOrganisation = new Facade.Organisation();
                        Entities.FacadeResult result          = facOrganisation.Create(organisation, ((Entities.CustomPrincipal)Page.User).UserName);
                        if (result.Success)
                        {
                            ownerID = result.ObjectId;
                        }
                        else
                        {
                            // Organisation has already been created by someone else between validation and this call (unlikely)
                            ownerID = facOrganisation.GetForName(cboOwner.Text).IdentityId;
                        }
                    }
                    else
                    {
                        ownerID = int.Parse(cboOwner.SelectedValue);
                    }

                    // Set the point type, organisation, town, and name for the new point
                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Drop:
                        Session[wizard.C_POINT_TYPE] = ePointType.Deliver;
                        Session[wizard.C_POINT_FOR]  = m_instruction.ClientsCustomerIdentityID;
                        break;

                    case eInstructionType.Load:
                        Session[wizard.C_POINT_TYPE] = ePointType.Collect;
                        Session[wizard.C_POINT_FOR]  = ownerID;
                        break;
                    }

                    Session[wizard.C_INSTRUCTION_INDEX] = m_instructionIndex;
                    Session[wizard.C_POINT_NAME]        = cboPoint.Text;
                    Session[wizard.C_TOWN_ID]           = Convert.ToInt32(cboTown.SelectedValue);

                    // The point name must be unique for this client
                    bool          foundPointName = false;
                    Facade.IPoint facPoint       = new Facade.Point();
                    DataSet       pointNames     = facPoint.GetAllForOrganisation((int)Session[wizard.C_POINT_FOR], ePointType.Any, cboPoint.Text);
                    foreach (DataRow row in pointNames.Tables[0].Rows)
                    {
                        if (((string)row["Description"]) == cboPoint.Text)
                        {
                            foundPointName = true;
                        }
                    }

                    if (foundPointName)
                    {
                        pnlCreateNewPoint.Visible = true;
                    }
                    else
                    {
                        // Allow the user to create the new point
                        GoToStep("CNP");
                    }
                }
                else
                {
                    int pointId = Convert.ToInt32(cboPoint.SelectedValue);

                    if (m_isUpdate)
                    {
                        if (m_instruction.InstructionID == 0)
                        {
                            // Adding a new instruction

                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Altering an existing instruction
                            // Cause the first collectdrop to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }
                        }
                    }
                    else
                    {
                        if (m_isAmendment)
                        {
                            if (pointId != m_instruction.PointID)
                            {
                                Facade.IPoint  facPoint      = new Facade.Point();
                                Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                                m_instruction.Point   = selectedPoint;
                                m_instruction.PointID = selectedPoint.PointId;
                            }

                            // Cause the first point to be displayed.
                            if (m_instruction.CollectDrops.Count > 0)
                            {
                                Session[wizard.C_COLLECT_DROP]       = m_instruction.CollectDrops[0];
                                Session[wizard.C_COLLECT_DROP_INDEX] = 0;
                            }

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                        else
                        {
                            Facade.IPoint  facPoint      = new Facade.Point();
                            Entities.Point selectedPoint = facPoint.GetPointForPointId(pointId);

                            // Add the collect drop point information
                            m_instruction.Point         = selectedPoint;
                            m_instruction.PointID       = selectedPoint.PointId;
                            m_instruction.InstructionID = m_instruction.InstructionID;

                            Session[wizard.C_INSTRUCTION] = m_instruction;
                        }
                    }

                    GoToStep("PD");
                }
            }
        }