예제 #1
0
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            Facade.Security          facSecurity  = new Facade.Security();
            Entities.User            busUser      = new Entities.User();
            Entities.CustomPrincipal loggedOnUser = (Entities.CustomPrincipal)Page.User;

            if (facSecurity.ValidatePassword(txtUsername.Text, txtNewPassword.Text))
            {
                if (facSecurity.UpdatePassword(txtUsername.Text, txtNewPassword.Text, loggedOnUser.UserName))
                {
                    pnlChangePassword.Visible             = false;
                    pnlChangePasswordConfirmation.Visible = true;
                    if (Request["returnURL"] != null)
                    {
                        Response.Redirect(Request.QueryString["returnURL"]);
                    }
                }
                else
                {
                    lblMessage.Text    = ("The password has not been updated. Please note old passwords cannot be used again for at least one year.");
                    lblMessage.Visible = true;
                }
            }
            else
            {
                rfvComplexPwd.IsValid = false;
                lblMessage.Visible    = false;
            }
        }
예제 #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            if (Request.QueryString["jobId"] != null)
            {
                int.TryParse(Request.QueryString["jobId"], out m_jobId);
            }

            user = (Entities.CustomPrincipal)Page.User;
            if (Request["wiz"] != null && Request["wiz"].ToString() == "true")
            {
                m_isWizard = true;
                pnlWizardHeading.Visible = true;
                pnl1.Visible             = false;
                ShowLeftMenu             = false;
                RadMenu1.Visible         = false;
            }

            if (Request.QueryString["wizard"] != null)
            {
                pnlDialogHeading.Visible = false;
            }

            LoadMenu();
        }
예제 #3
0
        /// <summary>
        /// Validate that the current user session has a valid forms authentication cookie containing an
        /// active Session ID and, if so, attach a CustomPrincipal for the user to the current HttpContext.
        /// </summary>
        internal static void ValidateSession()
        {
            var context    = HttpContext.Current;
            var authTicket = GetCurrentAuthenticationTicket();

            if (authTicket == null)
            {
                return;
            }

            var authenticationCookieData = ParseAuthenticationCookieData(authTicket.UserData);

            // If the cookie data does not exist in the required format then the session is not valid
            if (authenticationCookieData == null)
            {
                context.User = null;
                return;
            }

            if (context.Request.Url.AbsolutePath.Contains(".aspx"))
            {
                using (var uow = DIContainer.CreateUnitOfWork())
                {
                    var userRepo = DIContainer.CreateRepository <IUserRepository>(uow);
                    var user     = userRepo.FindByName(authenticationCookieData.Username, includeIdentity: true, includeUserRoles: true);
                    var isExcludedFromSessionValidation = user.IsProteoUser || user.IsInRole(eUserRole.ClientUser);

                    if (user.Individual.Identity.IdentityStatus == eIdentityStatus.Deleted)
                    {
                        LogOff();
                        context.Response.Redirect(context.Request.Url.AbsolutePath + "?HasLoggedOff=1&lockordeleted=2");
                        return;
                    }
                    if (user.LockedOutUntilDateTime > System.DateTime.Now)
                    {
                        LogOff();
                        context.Response.Redirect(context.Request.Url.AbsolutePath + "?HasLoggedOff=1&lockordeleted=1");
                        return;
                    }
                    // If the sessionID does not match any active session then it is not valid.
                    if (!isExcludedFromSessionValidation && !user.GetUserSessionIDs().Contains(authenticationCookieData.SessionID.ToString()))
                    {
                        LogOff();
                        context.Response.Redirect(context.Request.Url.AbsolutePath + "?HasLoggedOff=1&multiples=1");
                        return;
                    }
                }
            }

            var identity = new FormsIdentity(authTicket);

            var principal = new Entities.CustomPrincipal(
                identity,
                authenticationCookieData.IdentityID,
                authenticationCookieData.Roles,
                authenticationCookieData.FullName,
                authenticationCookieData.Username);

            context.User = principal;
        }
예제 #4
0
        void grdFilters_ItemCommand(object source, GridCommandEventArgs e)
        {
            int filterID = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["FilterId"].ToString());

            Entities.CustomPrincipal principal = (Entities.CustomPrincipal)Page.User;

            switch (e.CommandName.ToLower())
            {
            case "setdefault":
                using (Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic())
                    facTrafficSheetFilter.SetDefault(filterID, principal.IdentityId, principal.UserName);
                grdFilters.Rebind();
                break;

            case "switchactivity":
                GridDataItem gdi      = e.Item as GridDataItem;
                bool         isActive = (gdi["IsActive"] as TableCell).Text == "Yes" ? true : false;

                using (Facade.ITrafficSheetFilter facTrafficSheetFilter = new Facade.Traffic())
                    if (isActive)
                    {
                        facTrafficSheetFilter.Deactivate(filterID, principal.UserName);
                    }
                    else if (e.Item.Cells[5].Text.ToLower() == "no")
                    {
                        facTrafficSheetFilter.Activate(filterID, principal.UserName);
                    }
                grdFilters.Rebind();

                break;
            }
        }
예제 #5
0
        protected void cmdLock_Click(object sender, System.EventArgs e)
        {
            Entities.CustomPrincipal loggedOnUser = (Entities.CustomPrincipal)Page.User;
            Facade.UserAdmin         facUserAdmin = new Facade.UserAdmin();
            Facade.Security          facSecurity  = new Facade.Security();
            int IdentityId = Convert.ToInt32(Request.QueryString["identityId"]);

            if (cmdLock.Text == "Lock")
            {
                if (facUserAdmin.LockUser(IdentityId))
                {
                    cmdLock.Text = "Unlock";
                }
                else
                {
                    lblMessage.Text = "Failed to lock User.";
                }
            }
            else if (cmdLock.Text == "Unlock")
            {
                if (facUserAdmin.UnLockUser(IdentityId))
                {
                    cmdLock.Text = "Lock";
                }
                else
                {
                    lblMessage.Text = "Failed to unlock User.";
                }
            }
        }
예제 #6
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();
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //bool performAction = !(this.Request.QueryString["action"] == null);
            //if (performAction)
            //{
            //    string action = this.Request.QueryString["action"].ToString();
            //    switch (action)
            //    {
            //        case "dn": // delivery note
            //            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');", true);
            //            break;

            //        case "bf": // booking form
            //            Page.ClientScript.RegisterStartupScript(this.GetType(), "bookingform", "NewBookingForm();", true);
            //            break;

            //        case "pil": // pallet identification label
            //            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "window.open('" + Page.ResolveClientUrl("../reports/reportviewer.aspx?wiz=true") + "');", true);
            //            break;

            //        default:
            //            break;
            //    }
            //}

            Entities.CustomPrincipal cp = Page.User as Entities.CustomPrincipal;
            if (cp.IsInRole(((int)eUserRole.ClientUser).ToString()))
            {
                // Hide scan booking form button for client users, only allow upload.
                lblClientConfirmationMessage.Visible = true;
            }

            ShowOptions();
        }
예제 #8
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (Request["wiz"] != null && Request["wiz"].ToString() == "true")
     {
         m_isWizard          = true;
         __pnlFooter.Visible = false;
     }
     user         = (Entities.CustomPrincipal)Page.User;
     lblUser.Text = user.Name;
 }
예제 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user = (Entities.CustomPrincipal)Page.User;

            // Get the query string variables
            _jobId          = Convert.ToInt32(Request.QueryString["jobId"]);
            _lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

            // Default the arrival date and departure dates to match the dates of their
            // prior instructions respectively.
            GetJobAndInstructions();

            if (!Page.IsPostBack)
            {
                var busJob = new BusinessLogicLayer.Job();
                ucMultiDestination.ArrivalDateTime = _endInstruction.PlannedDepartureDateTime.Add(busJob.GetMinimumTravellingTime());
            }
        }
예제 #10
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();
            }
        }
        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();
            }
        }
예제 #12
0
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            bool success = false;

            Entities.CustomPrincipal loggedOnUser = (Entities.CustomPrincipal)Page.User;

            Facade.IUserAdmin facUserAdmin = new Facade.UserAdmin();
            Facade.ISecurity  facSecurity  = new Facade.Security();

            success = facUserAdmin.UpdateUserState((int)ViewState["identityId"], (int)eIdentityStatus.Deleted, loggedOnUser.Name);

            if (success)
            {
                this.ReturnValue = "CloseAndRefresh";
                this.Close();
            }
            else
            {
                lblMessage.Text = "Update User failed. Please try again.";
            }
        }
예제 #13
0
        private void GetClientId()
        {
            Entities.CustomPrincipal cp = Page.User as Entities.CustomPrincipal;

            if (cp.IsInRole(((int)eUserRole.ClientUser).ToString()))
            {
                Facade.IUser  facUser = new Facade.User();
                SqlDataReader reader  = facUser.GetRelatedIdentity(((Entities.CustomPrincipal)Page.User).UserName);
                reader.Read();

                if ((eRelationshipType)reader["RelationshipTypeId"] == eRelationshipType.IsClient)
                {
                    int RelatedIdentityID = int.Parse(reader["RelatedIdentityId"].ToString());
                    _clientIdentityId = RelatedIdentityID;
                }
                else
                {
                    throw new ApplicationException("User is not a client user.");
                }
            }
        }
예제 #14
0
        /// <summary>
        /// The users wishes to save the filter.
        /// </summary>
        void btnSaveFilter_Click(object sender, EventArgs e)
        {
            btnSaveFilter.DisableServerSideValidation();

            if (Page.IsValid)
            {
                Facade.ITrafficSheetFilter  facTrafficSheetFilter = new Facade.Traffic();
                Entities.CustomPrincipal    user   = (Entities.CustomPrincipal)Page.User;
                Entities.TrafficSheetFilter filter = null;
                bool isUpdate = false;
                if (dteStartDate.SelectedDate != null && dteEndDate.SelectedDate == null)
                {
                    dteEndDate.SelectedDate = ((DateTime)dteStartDate.SelectedDate).AddDays(1).Add(new TimeSpan(23, 59, 59));
                }

                if (cboFilters.SelectedValue != "0" && cboFilters.SelectedItem.Text == txtFilterName.Text)
                {
                    // We are going to update the old version of the filter.
                    isUpdate = true;
                    filter   = facTrafficSheetFilter.GetForTrafficSheetFilterId(Convert.ToInt32(cboFilters.SelectedValue));
                }
                else
                {
                    filter            = new Entities.TrafficSheetFilter(user.IdentityId);
                    filter.FilterName = txtFilterName.Text;
                }
                filter.FilterStartDate = (DateTime)dteStartDate.SelectedDate;
                filter.FilterEnddate   = (DateTime)dteEndDate.SelectedDate;

                // Configure the filter
                filter.ControlAreaId = Convert.ToInt32(cboControlArea.SelectedValue);
                filter.TrafficAreaIDs.Clear();

                foreach (ListItem item in cboTrafficAreas.Items)
                {
                    if (item.Selected)
                    {
                        filter.TrafficAreaIDs.Add(Convert.ToInt32(item.Value));
                    }
                }

                filter.FilterOutExcludedPoints = false;
                filter.TrafficSheetGrouping    = eTrafficSheetGrouping.None;
                filter.TrafficSheetSorting     = eTrafficSheetSorting.EarliestLeg;
                filter.JobStates.Clear();

                foreach (ListItem item in chkJobStates.Items)
                {
                    if (item.Selected)
                    {
                        filter.JobStates.Add(Enum.Parse(typeof(eJobState), item.Value.Replace(" ", "")));
                    }
                }

                filter.BusinessTypes.Clear();
                foreach (ListItem li in cblBusinessType.Items)
                {
                    if (li.Selected)
                    {
                        filter.BusinessTypes.Add((int)int.Parse(li.Value));
                    }
                }

                filter.DepotId = int.Parse(cboDepot.SelectedValue);

                filter.OnlyShowJobsWithDemurrage = chkOnlyShowJobsWithDemurrage.Checked;
                filter.OnlyShowJobsWithDemurrageAwaitingAcceptance = chkOnlyShowJobsWithDemurrageAwaitingAcceptance.Checked;
                filter.OnlyShowJobsWithPCVs = chkOnlyShowJobsWithPCVs.Checked;
                filter.OnlyShowMyJobs       = false;

                Facade.ITrafficArea facTrafficArea = new Facade.Traffic();

                if (isUpdate)
                {
                    ((Facade.ITrafficSheetFilter)facTrafficArea).Update(filter, user.UserName);
                }
                else
                {
                    filter.FilterId = ((Facade.ITrafficSheetFilter)facTrafficArea).Create(filter, user.UserName);
                }

                SetFilter();
                PopulateFilterList();
                cboFilters.ClearSelection();
                SelectItem(cboFilters.Items, filter.FilterId);

                this.ReturnValue = "refresh";
                this.Close();
            }
        }
예제 #15
0
        //-----------------------------------------------------------------------------------------------------------

        protected void btnUpdateOrders_Click(object sender, EventArgs e)
        {
            // Find out if we need to create a new instruction, if all the orders have been selected then we can
            // change the instructions point and all the orders delivery points without adding a new instruction.

            // if some orders are left on the existing instruction then we need to remove the selected orders from
            // the current instruction and create a new instruction based on the new delivery details.
            // Then add the selected orders to the newly created instruction.

            // Ensure that all points are created.

            if (this.cboNewDeliveryPoint.PointID < 1)
            {
                this.lblError.Text = "Please select a Point.";
            }
            else
            {
                this.lblError.Text = String.Empty;
                Facade.IOrder        facorder       = new Facade.Order();
                Facade.IInstruction  facInstruction = new Facade.Instruction();
                Entities.Instruction instruction    = null;

                List <int> orderIds      = new List <int>();
                int        instructionId = -1;
                int        runId         = -1;

                foreach (GridDataItem item in grdOrders.Items)
                {
                    if (instructionId == -1)
                    {
                        Label lblInstruction = (Label)item.FindControl("lblInstructionId");
                        int.TryParse(lblInstruction.Text, out instructionId);
                    }
                    if (runId == -1)
                    {
                        HyperLink hypRun = (HyperLink)item.FindControl("hypRun");
                        int.TryParse(hypRun.Text, out runId);
                    }

                    CheckBox chkOrderId = (CheckBox)item.FindControl("chkSelectOrder");
                    int      orderId;
                    int.TryParse(chkOrderId.Attributes["OrderID"].ToString(), out orderId);

                    if (chkOrderId.Checked)
                    {
                        orderIds.Add(int.Parse(chkOrderId.Attributes["OrderID"].ToString()));
                    }
                }

                instruction = facInstruction.GetInstruction(instructionId);

                if (instruction != null)
                {
                    Facade.IJob  facJob = new Facade.Job();
                    Entities.Job run    = facJob.GetJob(runId, true);

                    if (orderIds.Count == this.grdOrders.Items.Count)
                    {
                        ChangeExistingInstruction(instruction, run, orderIds);

                        List <Entities.Instruction> amendedInstructions = new List <Orchestrator.Entities.Instruction>();
                        amendedInstructions.Add(instruction);
                        // Commit the action.
                        Entities.FacadeResult    retVal = null;
                        Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;

                        retVal = facJob.AmendInstructions(run, amendedInstructions, eLegTimeAlterationMode.Enforce_Booked_Times, user.Name);
                    }
                    else
                    {
                        List <Entities.Instruction> amendedInstructions = new List <Orchestrator.Entities.Instruction>();

                        Facade.IOrder facOrder = new Facade.Order();
                        BusinessLogicLayer.ICollectDrop busCollectDrop = new BusinessLogicLayer.CollectDrop();

                        using (TransactionScope tran = new TransactionScope())
                        {
                            foreach (int ordId in orderIds)
                            {
                                Entities.Order currentOrder = facOrder.GetForOrderID(ordId);

                                Entities.CollectDrop collectDrop = instruction.CollectDrops.Find(i => i.OrderID == currentOrder.OrderID);
                                busCollectDrop.Delete(collectDrop, this.Page.User.Identity.Name);

                                this.AddNewDropInstruction(currentOrder, run, amendedInstructions);
                            }

                            // Commit the action.
                            Entities.FacadeResult    retVal = null;
                            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;

                            retVal = facJob.AmendInstructions(run, amendedInstructions, eLegTimeAlterationMode.Enforce_Booked_Times, user.Name);
                            if (retVal.Success)
                            {
                                tran.Complete();
                            }
                        }
                    }
                }

                this.grdOrders.DataSource = null;
                this.grdOrders.Rebind();
            }
        }
예제 #16
0
        void btnApply_Click(object sender, EventArgs e)
        {
            List <int> reject         = new List <int>();
            List <int> regenerate     = new List <int>();
            List <int> approve        = new List <int>();
            List <int> approveAndPost = new List <int>();

            // React to the user's options.
            foreach (GridDataItem row in gvPreInvoices.Items)
            {
                if (row.OwnerTableView.Name == PreInvoiceTableName && (row.ItemType == GridItemType.Item || row.ItemType == GridItemType.AlternatingItem))
                {
                    HtmlInputRadioButton rdoReject         = row.FindControl("rdoReject") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoRegenerate     = row.FindControl("rdoRegenerate") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApprove        = row.FindControl("rdoApprove") as HtmlInputRadioButton;
                    HtmlInputRadioButton rdoApproveAndPost = row.FindControl("rdoApproveAndPost") as HtmlInputRadioButton;
                    HtmlInputCheckBox    chkUseHeadedPaper = row.FindControl("chkUseHeadedPaper") as HtmlInputCheckBox;

                    if (rdoReject.Checked)
                    {
                        reject.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }
                    else if (rdoRegenerate.Checked)
                    {
                        regenerate.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }
                    else if (rdoApprove.Checked)
                    {
                        approve.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }
                    else if (rdoApproveAndPost.Checked)
                    {
                        approveAndPost.Add(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()));
                    }

                    if (rdoApprove.Checked || rdoApproveAndPost.Checked)
                    {
                        if (chkUseHeadedPaper.Checked)
                        {
                            SetUseHeadedPaperParameter(int.Parse((gvPreInvoices.MasterTableView.DataKeyValues[row.ItemIndex]["PreInvoiceID"]).ToString()), chkUseHeadedPaper.Checked);
                        }
                    }
                }
            }

            // Notify no-one.
            List <Contracts.DataContracts.NotificationParty> notificationParties = new List <Contracts.DataContracts.NotificationParty>();

            Entities.CustomPrincipal cp = (Entities.CustomPrincipal)Page.User;


            try
            {
                // Kick off the workflow (if there is anything to do).
                if (approveAndPost.Count + approve.Count + regenerate.Count + reject.Count > 0)
                {
                    GenerateInvoiceClient gic = new GenerateInvoiceClient("Orchestrator.InvoiceService");
                    gic.VerifyInvoices(approveAndPost.ToArray(), approve.ToArray(), regenerate.ToArray(), reject.ToArray(), notificationParties.ToArray(), cp.UserName);

                    Server.Transfer("reviewablegroups.aspx");
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException exc)
            {
                // Not possible to send message to workflow host - send email to support.
                Utilities.SendSupportEmailHelper("GenerateInvoiceClient.VerifyInvoices(int[], int[], int[], int[], Orchestrator.Entities.NotificationParty[], string)", exc);
                // Redirect user to an appropriate page.
                Server.Transfer("../../OfflineProcessInitiationFailed.aspx");
            }
        }
예제 #17
0
        private void TrunkLeg()
        {
            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;
            Entities.FacadeResult    result = null;

            int pointId = ucPoint.PointID;// int.Parse(cboPoint.SelectedValue);

            if (!IsUpdate)
            {
                #region Create New Trunk
                Entities.Instruction instruction = null;
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    instruction = facInstruction.GetInstruction(m_instructionId);
                }

                // We've trunked the leg.
                DateTime arriveAtTrunkPoint;
                DateTime leaveTrunkPoint;

                // Get the arrival time.
                //arriveAtTrunkPoint = timeStartDate.xDateTime;
                arriveAtTrunkPoint = new DateTime(rdiStartDate.SelectedDate.Value.Year, rdiStartDate.SelectedDate.Value.Month, rdiStartDate.SelectedDate.Value.Day, rdiStartTime.SelectedDate.Value.Hour, rdiStartTime.SelectedDate.Value.Minute, 0);

                // Get the departure time.
                //leaveTrunkPoint = timeEndDate.xDateTime;
                leaveTrunkPoint = new DateTime(rdiEndDate.SelectedDate.Value.Year, rdiEndDate.SelectedDate.Value.Month, rdiEndDate.SelectedDate.Value.Day, rdiEndTime.SelectedDate.Value.Hour, rdiEndTime.SelectedDate.Value.Minute, 0);

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

                // Create the new trunk instruction
                Entities.Instruction trunkInstruction = new Orchestrator.Entities.Instruction();
                trunkInstruction.InstructionTypeId        = (int)eInstructionType.Trunk;
                trunkInstruction.JobId                    = instruction.JobId;
                trunkInstruction.PointID                  = pointId;
                trunkInstruction.PlannedDepartureDateTime = leaveTrunkPoint;
                trunkInstruction.PlannedArrivalDateTime   = arriveAtTrunkPoint;
                trunkInstruction.Trailer                  = instruction.Trailer;

                // Set the booked datetime of the trunk to the trunks planned arrival time. This could produce a situation
                // where the booked times do not flow, however, the trunks booked time is irrelevant so if this happens, it shouldn't matter.
                // Failing to set a booked time for the trunk here would cause an error when attempting to save the instruction.
                trunkInstruction.BookedDateTime = arriveAtTrunkPoint;

                // Note: Always get the driver and the vehicle.
                trunkInstruction.Driver  = instruction.Driver;
                trunkInstruction.Vehicle = instruction.Vehicle;

                // Add the trunk to the job.
                using (Facade.IJob facJob = new Facade.Job())
                {
                    Entities.Job job = facJob.GetJob(instruction.JobId);
                    result = facJob.Trunk(trunkInstruction, instruction, job.IdentityId, user.UserName, job.LastUpdateDate, chkDriver.Checked, chkVehicle.Checked);
                }

                #endregion
            }
            else
            {
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    facInstruction.UpdatePointID(m_instructionId, pointId, user.UserName);
                    result = new Orchestrator.Entities.FacadeResult(true);
                }
            }

            if (result.Success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }
        }
예제 #18
0
        private static void EmailExceptionToSupport(Exception exception)
        {
            StringBuilder sb = new StringBuilder();
            XmlSerializer xmls;
            StringWriter  strWriter = null;
            HttpContext   ctx       = HttpContext.Current;

            sb.Append("An Orchestrator error has been encountered." + Environment.NewLine);
            sb.Append("Host Machine: " + Environment.MachineName + Environment.NewLine);
            sb.Append("Date: " + DateTime.Now.ToString("dd/MM/yy HH:mm:ss") + Environment.NewLine);
            sb.Append(Environment.NewLine);

            #region Details of Request

            sb.Append("Request Information" + Environment.NewLine);
            sb.Append("*******************" + Environment.NewLine);
            try
            {
                sb.Append("URL: " + ctx.Request.Url.AbsoluteUri + Environment.NewLine);
                sb.Append(string.Format("QueryString: {0} items, with {1} length", ctx.Request.QueryString.Keys.Count.ToString(), ctx.Request.QueryString.ToString().Length) + Environment.NewLine);
                sb.Append(Environment.NewLine);
                foreach (string key in ctx.Request.QueryString.AllKeys)
                {
                    sb.Append(string.Format("             {0}: {1}", key, ctx.Request.QueryString[key]) + Environment.NewLine + Environment.NewLine);
                }
                sb.Append(Environment.NewLine);
            }
            catch (Exception rexc)
            {
                sb.Append("Could not retrieve all request information: " + rexc.Message + Environment.NewLine);
            }

            #endregion

            #region Details of User

            sb.Append("User Information" + Environment.NewLine);
            sb.Append("****************" + Environment.NewLine);
            try
            {
                sb.Append("User: "******"Name: " + user.Name + Environment.NewLine);
                    sb.Append("Roles: " + user.UserRole + Environment.NewLine);
                }
                else
                {
                    sb.Append("unknown" + Environment.NewLine);
                }
                sb.Append("Is Authenticated: " + ctx.Request.IsAuthenticated + Environment.NewLine);
                sb.Append("User Host Name: " + ctx.Request.UserHostName + Environment.NewLine);
                sb.Append("User Host Address: " + ctx.Request.UserHostAddress + Environment.NewLine);
                sb.Append(Environment.NewLine);
            }
            catch (Exception uexc)
            {
                sb.Append("Could not retrieve all user information: " + uexc.Message + Environment.NewLine);
            }

            #endregion

            #region Details of Exception

            sb.Append("Exception Information" + Environment.NewLine);
            sb.Append("*********************" + Environment.NewLine);
            try
            {
                while (exception != null)
                {
                    sb.Append("Type: " + exception.GetType().Name + Environment.NewLine);
                    sb.Append("Message: " + exception.Message + Environment.NewLine);
                    sb.Append("Stack Trace: " + exception.StackTrace + Environment.NewLine);
                    sb.Append("Source: " + exception.Source + Environment.NewLine);
                    sb.Append("Serialised as: " + Environment.NewLine);

                    if (exception != null && exception.GetType().IsSerializable)
                    {
                        try
                        {
                            xmls      = new XmlSerializer(exception.GetType());
                            strWriter = new StringWriter();
                            xmls.Serialize(strWriter, exception);
                            sb.Append(strWriter.ToString() + Environment.NewLine);
                        }
                        catch (Exception serialisationException)
                        {
                            sb.Append("Failed to serialise (" + serialisationException.Message + ")" + Environment.NewLine);
                        }
                        finally
                        {
                            if (strWriter != null)
                            {
                                strWriter.Close();
                                strWriter = null;
                            }
                        }
                    }
                    else
                    {
                        sb.Append("Does not support serialisation." + Environment.NewLine);
                    }
                    sb.Append(Environment.NewLine);

                    exception = exception.InnerException;
                }
            }
            catch (Exception eexc)
            {
                sb.Append("Could not retrieve all exception information: " + eexc.Message + Environment.NewLine);
            }

            #endregion

            #region Details of Session

            sb.Append("Session Information" + Environment.NewLine);
            sb.Append("*******************" + Environment.NewLine);
            try
            {
                sb.Append(string.Format("Session: {0} items", ctx.Session.Keys.Count) + Environment.NewLine);
                sb.Append(Environment.NewLine);
                foreach (string key in ctx.Session.Keys)
                {
                    object sessionItem = ctx.Session[key];

                    sb.Append(string.Format("         Key: {0}", key) + Environment.NewLine);
                    sb.Append(string.Format("         Type: {0}", sessionItem != null ? sessionItem.GetType().Name : "null") + Environment.NewLine);
                    sb.Append(string.Format("         Value: {0}", sessionItem != null ? sessionItem.ToString() : "null") + Environment.NewLine);
                    sb.Append("         Serialised as: " + Environment.NewLine);

                    if (sessionItem != null && sessionItem.GetType().IsSerializable)
                    {
                        try
                        {
                            xmls      = new XmlSerializer(sessionItem.GetType());
                            strWriter = new StringWriter();
                            xmls.Serialize(strWriter, sessionItem);
                            sb.Append(strWriter.ToString() + Environment.NewLine);
                        }
                        catch (Exception serialisationException)
                        {
                            sb.Append("         Failed to serialise (" + serialisationException.Message + ")" + Environment.NewLine);
                        }
                        finally
                        {
                            if (strWriter != null)
                            {
                                strWriter.Close();
                                strWriter = null;
                            }
                        }
                    }
                    else
                    {
                        sb.Append("         Does not support serialisation." + Environment.NewLine);
                    }
                    sb.Append(Environment.NewLine);
                }
                sb.Append(Environment.NewLine);
            }
            catch (Exception sexc)
            {
                sb.Append("Could not retrieve all session information: " + sexc.Message + Environment.NewLine);
            }

            #endregion

            string errorText = sb.ToString();

            try
            {
                MailMessage mailMessage = new MailMessage();

                mailMessage.From = new MailAddress(Orchestrator.Globals.Configuration.MailFromAddress,
                                                   Orchestrator.Globals.Configuration.MailFromName);

                mailMessage.To.Add("*****@*****.**");

                mailMessage.Subject    = "Orchestrator Error - " + Environment.MachineName;
                mailMessage.Body       = sb.ToString();
                mailMessage.IsBodyHtml = false;

                SmtpClient smtp = new System.Net.Mail.SmtpClient();
                smtp.Host        = Globals.Configuration.MailServer;
                smtp.Credentials = new NetworkCredential(Globals.Configuration.MailUsername,
                                                         Globals.Configuration.MailPassword);

                smtp.Send(mailMessage);
                mailMessage.Dispose();
            }
            catch { }
        }
예제 #19
0
        private void addUser()
        {
            if (Page.IsValid)
            {
                Entities.CustomPrincipal loggedOnUser = (Entities.CustomPrincipal)Page.User;

                Facade.IUserAdmin facUserAdmin = new Facade.UserAdmin();
                Facade.ISecurity  facSecurity  = new Facade.Security();

                int  organisationId = 0;
                int  teamId         = 0;
                bool plannerRemoved = false;

                if (m_isClient == true)
                {
                    organisationId = Convert.ToInt32(cboClient.SelectedValue);
                }
                else
                {
                    teamId = Convert.ToInt32(cboTeam.SelectedItem.Value);
                }
                int retIdentityId;

                if (string.IsNullOrEmpty(txtSelectedRoles.Value))
                {
                    lblMessage.Text = "Edit user failed.  At least one role must be selected.";
                    return;
                }

                string[] sRoles = txtSelectedRoles.Value.Substring(1).Split(',');
                int[]    iRoles = new int[sRoles.Length];

                for (int count = 0; count <= sRoles.Length - 1; count++)
                {
                    iRoles[count] = Convert.ToInt32(sRoles[count]);
                }

                var validateRolesResult = facUserAdmin.ValidateUserRoles(txtUserName.Text, iRoles);

                if (!validateRolesResult.Success)
                {
                    if (validateRolesResult.Infringements.Select(i => i.Description).Contains("PlannerRemoved") && validateRolesResult.Infringements.Count == 1)
                    {
                        plannerRemoved = true;
                    }
                    else
                    {
                        lblMessage.Text = string.Join("<br />", validateRolesResult.Infringements.Select(i => i.Description));
                        return;
                    }
                }

                if (btnAdd.Text == "Add")
                {
                    // Validate password
                    if (facSecurity.ValidatePassword(txtUserName.Text, txtPassword.Text))
                    {
                        rfvComplex.IsValid = true;
                    }
                    else
                    {
                        rfvComplex.IsValid = false;
                        return;
                    }

                    if (!m_isClient)
                    {
                        retIdentityId = facUserAdmin.AddUser(txtUserName.Text, txtPassword.Text, txtForenames.Text, txtSurname.Text, iRoles, teamId, loggedOnUser.Name, txtEmail.Text, chkCanAccessFromAnywhere.Checked, chkScannedLicense.Checked);
                    }
                    else
                    {
                        retIdentityId = facUserAdmin.AddUserForClient(txtUserName.Text, txtPassword.Text, txtForenames.Text, txtSurname.Text, iRoles, organisationId, loggedOnUser.Name, txtEmail.Text, chkScannedLicense.Checked);
                    }

                    if (retIdentityId > 0)
                    {
                        if (chkEmailDetails.Checked && m_isClient && pnlEmailDetails.Visible)
                        {
                            EmailClient();
                        }
                        this.ReturnValue = "CloseAndRefresh";
                        this.Close();
                    }
                    else if (retIdentityId == -1)
                    {
                        lblMessage.Text = "The Username has already been added to the application.";
                    }
                    else
                    {
                        lblMessage.Text = "Add new User failed. Please try again.";
                    }
                }
                else if (btnAdd.Text == "Update")
                {
                    bool success = false;
                    if (!m_isClient)
                    {
                        success = facUserAdmin.UpdateUser((int)ViewState["identityId"], txtPassword.Text, txtForenames.Text, txtSurname.Text, Convert.ToInt32(cboUserStatus.SelectedValue), iRoles, teamId, loggedOnUser.Name, txtEmail.Text, chkCanAccessFromAnywhere.Checked, chkScannedLicense.Checked, plannerRemoved);
                    }
                    else
                    {
                        success = facUserAdmin.UpdateUserForClient((int)ViewState["identityId"], txtPassword.Text, txtForenames.Text, txtSurname.Text, Convert.ToInt32(cboUserStatus.SelectedValue), iRoles, organisationId, loggedOnUser.Name, txtEmail.Text, chkScannedLicense.Checked);
                    }

                    if (success)
                    {
                        this.ReturnValue = "CloseAndRefresh";
                        this.Close();
                    }
                    else
                    {
                        lblMessage.Text = "Update User failed. Please try again.";
                    }
                }
            }
        }
예제 #20
0
        //private void MessageBox(string msg)
        //{
        //    Label lbl = new Label();
        //    lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
        //    Page.Controls.Add(lbl);
        //}

        private void btnConfirmDropConversion_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var facPoint = new Facade.Point();

                // Get the point to trunk to.
                var trunkPoint = facPoint.GetPointForPointId(ucPoint.PointID);;

                // Configure the instructions.
                var dropInstruction = GetInstruction();
                Entities.Instruction trunkInstruction = new Entities.Instruction(eInstructionType.Trunk, dropInstruction.JobId, String.Empty);
                trunkInstruction.BookedDateTime            = dropInstruction.BookedDateTime;
                trunkInstruction.IsAnyTime                 = dropInstruction.IsAnyTime;
                trunkInstruction.PointID                   = trunkPoint.PointId;
                trunkInstruction.Point                     = trunkPoint;
                trunkInstruction.CollectDrops              = new Entities.CollectDropCollection();
                trunkInstruction.ClientsCustomerIdentityID = trunkPoint.IdentityId;

                // Process the collect drops.
                for (int collectDropIndex = 0; collectDropIndex < dropInstruction.CollectDrops.Count; collectDropIndex++)
                {
                    var cd = dropInstruction.CollectDrops[collectDropIndex];

                    // If the order can be moved from the drop to the trunk do so.
                    if (CanBeRemovedFromDrop(dropInstruction, cd.Order))
                    {
                        cd.CollectDropId = 0;
                        cd.InstructionID = trunkInstruction.InstructionID;
                        cd.OrderAction   = eOrderAction.Cross_Dock;
                        trunkInstruction.CollectDrops.Add(cd);
                        dropInstruction.CollectDrops.RemoveAt(collectDropIndex);
                        collectDropIndex--;
                    }
                }

                if (trunkInstruction.CollectDrops.Count > 0)
                {
                    // Alter the job.
                    Facade.IJob facJob       = new Facade.Job();
                    var         job          = facJob.GetJob(dropInstruction.JobId, true, true);
                    var         instructions = new List <Entities.Instruction>()
                    {
                        dropInstruction, trunkInstruction
                    };
                    Entities.CustomPrincipal user = Page.User as Entities.CustomPrincipal;
                    var result = facJob.AmendInstructions(job, instructions, eLegTimeAlterationMode.Minimal, user.UserName);

                    if (result.Success)
                    {
                        // Close this window and refresh the parent window.
                        this.ReturnValue = "refresh";
                        this.Close();
                    }
                }
                else
                {
                    // No action to take - close this window.
                    if (String.IsNullOrEmpty(errorMessage))
                    {
                        this.ReturnValue = "refresh";
                        this.Close();
                    }
                    else
                    {
                        //System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Please see the Message in the " +
                        //"Table for more information", "Error",
                        //    System.Windows.Forms.MessageBoxButtons.OK);
                        ClientScript.RegisterStartupScript(GetType(), "Error", "alert('Please see the message in the Table for more information');", true);
                    }
                }
            }
        }
예제 #21
0
        void btnConfirmTrunkConversion_Click(object sender, EventArgs e)
        {
            var dropInstructions = new Dictionary <int, Entities.Instruction>();
            var facPoint         = new Facade.Point();

            // Configure the instructions.
            var trunkInstruction = GetInstruction();

            // Process the collect drops.
            for (int collectDropIndex = 0; collectDropIndex < trunkInstruction.CollectDrops.Count; collectDropIndex++)
            {
                var cd = trunkInstruction.CollectDrops[collectDropIndex];

                // If the order can be moved from the drop to the trunk do so.
                if (CanBeRemovedFromTrunk(trunkInstruction, cd.Order))
                {
                    Entities.Instruction dropInstruction;
                    if (!dropInstructions.TryGetValue(cd.Order.DeliveryPointID, out dropInstruction))
                    {
                        var deliveryPoint = facPoint.GetPointForPointId(cd.Order.DeliveryPointID);
                        dropInstruction = new Entities.Instruction(eInstructionType.Drop, trunkInstruction.JobId, String.Empty);
                        dropInstruction.BookedDateTime            = trunkInstruction.BookedDateTime;
                        dropInstruction.IsAnyTime                 = trunkInstruction.IsAnyTime;
                        dropInstruction.PointID                   = deliveryPoint.PointId;
                        dropInstruction.Point                     = deliveryPoint;
                        dropInstruction.CollectDrops              = new Entities.CollectDropCollection();
                        dropInstruction.ClientsCustomerIdentityID = deliveryPoint.IdentityId;
                        dropInstructions.Add(cd.Order.DeliveryPointID, dropInstruction);
                    }

                    cd.CollectDropId = 0;
                    cd.InstructionID = dropInstruction.InstructionID;
                    cd.OrderAction   = eOrderAction.Cross_Dock;
                    dropInstruction.CollectDrops.Add(cd);
                    trunkInstruction.CollectDrops.RemoveAt(collectDropIndex);
                    collectDropIndex--;
                }
            }

            if (dropInstructions.Count > 0)
            {
                // Alter the job.
                Facade.IJob facJob       = new Facade.Job();
                var         job          = facJob.GetJob(trunkInstruction.JobId, true, true);
                var         instructions = new List <Entities.Instruction>()
                {
                    trunkInstruction
                };
                instructions.AddRange(dropInstructions.Values);
                Entities.CustomPrincipal user = Page.User as Entities.CustomPrincipal;
                var result = facJob.AmendInstructions(job, instructions, eLegTimeAlterationMode.Minimal, user.UserName);

                if (result.Success)
                {
                    // Close this window and refresh the parent window.
                    this.ReturnValue = "refresh";
                    this.Close();
                }
            }
            else
            {
                // No action to take - close this window.
                this.ReturnValue = "refresh";
                this.Close();
            }
        }