コード例 #1
0
        private void LoadStatuses()
        {
            var statuses = Enum.GetValues(typeof(MWFStatusEnum)).Cast <MWFStatusEnum>()
                           .Where(s => (((int)s == (int)MWFStatusEnum.Complete) || ((int)s == (int)MWFStatusEnum.OnSite) || ((int)s == (int)MWFStatusEnum.Drive) || ((int)s == (int)MWFStatusEnum.Unknown)))
                           .Select(s => new
            {
                Text  = MWF_Instruction.GetStatusDescription(s),
                Value = (int)s
            }).Distinct();

            this.StatusCheckboxList.DataSource = statuses;
            this.StatusCheckboxList.DataBind();
        }
コード例 #2
0
        private object GetInstructionsGridData()
        {
            Facade.IPoint   facPoint              = new Facade.Point();
            Facade.Resource facDriver             = new Facade.Resource();
            var             signatureImageBaseUri = Utilities.GetSignatureImageBaseUri();

            using (var uow = DIContainer.CreateUnitOfWork())
            {
                var repo         = DIContainer.CreateRepository <IMWF_InstructionRepository>(uow);
                var instructions = repo.GetAll();

                // Apply filters
                if (!string.IsNullOrEmpty(DriverPicker.SelectedValue))
                {
                    int selectedDriverID = int.Parse(DriverPicker.SelectedValue);
                    instructions = instructions.Where(i => i.Driver.ResourceID == selectedDriverID);
                }
                if (!string.IsNullOrEmpty(VehiclePicker.SelectedValue))
                {
                    string selectedVehicleReg = VehiclePicker.SelectedValue;
                    instructions = instructions.Where(i => i.VehicleReg == selectedVehicleReg);
                }

                var statusIDs = Utilities.ExtractCheckBoxListValues(StatusCheckboxList);
                if (statusIDs.Count > 0)
                {
                    instructions = instructions.Where(e => statusIDs.Contains((int)e.Status));
                }

                // Comm status filter
                var communicationStatusIDs = Utilities.ExtractCheckBoxListValues(CommunicationStatusCheckBoxList);
                if (communicationStatusIDs.Count > 0)
                {
                    instructions = instructions.Where(e => communicationStatusIDs.Contains((int)e.CommunicationStatus));
                }

                if (ArrivalFrom.SelectedDate != null && ArrivalTo.SelectedDate != null)
                {
                    instructions = instructions.Where(i => i.ArriveDateTime >= ArrivalFrom.SelectedDate.Value &&
                                                      i.ArriveDateTime <= ArrivalTo.SelectedDate.Value);
                }

                if (ArrivalFrom.SelectedDate != null && ArrivalTo.SelectedDate == null)
                {
                    instructions = instructions.Where(i => i.ArriveDateTime >= ArrivalFrom.SelectedDate.Value);
                }

                if (!string.IsNullOrEmpty(txtSearchField.Text))
                {
                    var searchTextAsStr = txtSearchField.Text.Trim();
                    var searchTextAsInt = Utilities.ParseNullable <int>(txtSearchField.Text);

                    if (searchTextAsInt.HasValue)
                    {
                        instructions = instructions.Where(i => i.Job.Title.Contains(txtSearchField.Text.Trim()) || i.Job.ID == searchTextAsInt.Value);
                    }
                    else
                    {
                        instructions = instructions.Where(i => i.Job.Title.Contains(searchTextAsStr) || i.OrderInstructions.FirstOrDefault().Order.ItemTitle.Contains(searchTextAsStr));
                    }
                }

                var queryData = instructions.Select(i => new
                {
                    i.ID,
                    JobID             = i.Job.ID,
                    InstructionTypeID = i.InstructionType,
                    CustomerReference = i.Job.Title,
                    CustomerOrder     = (i.OrderInstructions.Any()) ? i.OrderInstructions.FirstOrDefault().Order.ItemTitle : "",
                    PointDescription  = i.Point.Description,
                    DriverIndividual  = i.Driver == null ? null : i.Driver.Individual,
                    Vehicle           = i.VehicleReg == null ? string.Empty : i.VehicleReg,
                    i.ArriveDateTime,
                    i.DepartDateTime,
                    i.CommunicateDateTime,
                    i.LastUpdateDateTime,
                    CommunicationStatusID = i.CommunicationStatus,
                    StatusID       = i.Status,
                    SignedBy       = i.InstructionSignatures.FirstOrDefault().SignedBy,
                    SignedComment  = i.InstructionSignatures.FirstOrDefault().Comment,
                    SignatureImage = i.InstructionSignatures.FirstOrDefault().ImageName,
                    SignedDateTime = i.CompleteDateTime,
                    CQuantity      = i.InstructionType == MWFInstructionTypeEnum.Collect ?
                                     i.OrderInstructions.Sum(f => f.Order.ConfirmedCollectQuantity) :
                                     i.OrderInstructions.Sum(f => f.Order.ConfirmedDeliverQuantity),
                    RunStatus          = i.Job.Status,
                    SignatureLatitude  = i.InstructionSignatures.FirstOrDefault().Latitude,
                    SignatureLongitude = i.InstructionSignatures.FirstOrDefault().Longitude,
                    OrderID            = (i.OrderInstructions.Any()) ? (int?)i.OrderInstructions.FirstOrDefault().Order.ID : (int?)null,
                    OrderComplete      = i.CompleteDateTime.HasValue,
                    i.DriveDateTime,
                    i.CompleteDateTime
                }).OrderByDescending(i => i.ArriveDateTime).ToList();

                var gridData = queryData.Select(qd => new
                {
                    qd.ID,
                    qd.JobID,
                    InstructionType = MWF_Instruction.GetInstructionTypeDescription(qd.InstructionTypeID),
                    qd.CustomerReference,
                    qd.CustomerOrder,
                    Location    = qd.PointDescription,
                    ArrivalTime = qd.ArriveDateTime,
                    Status      = MWF_Instruction.GetStatusDescription(qd.StatusID),
                    qd.RunStatus,
                    qd.StatusID,
                    qd.CommunicationStatusID,
                    Driver                = qd.DriverIndividual == null ? string.Empty : Entities.Utilities.MergeStrings(" ", qd.DriverIndividual.FirstNames, qd.DriverIndividual.LastName),
                    VehicleReg            = qd.Vehicle,
                    CommunicationStatus   = MWF_Instruction.GetCommunicationStatusDescription((int)qd.CommunicationStatusID),
                    CommunicationDateTime = qd.CommunicateDateTime,
                    SignedBy              = qd.SignedBy,
                    SignedComment         = qd.SignedComment,
#if DEBUG
                    SignatureImage = String.IsNullOrEmpty(qd.SignatureImage) ? "" : "http://demo.orchestrator.co.uk/signatures/" + qd.SignatureImage,
#else
                    SignatureImage = String.IsNullOrEmpty(qd.SignatureImage) ? "" : new Uri(signatureImageBaseUri, qd.SignatureImage).AbsoluteUri,
#endif
                    SignedDateTime    = qd.SignedDateTime.HasValue ? qd.SignedDateTime.Value.ToLongDateString() + " " + qd.SignedDateTime.Value.ToLongTimeString() : "",
                    ConfirmedQuantity = qd.CQuantity,
                    qd.SignatureLatitude,
                    qd.SignatureLongitude,
                    qd.OrderID,
                    qd.OrderComplete,
                    qd.DriveDateTime,
                    qd.CompleteDateTime
                });

                return(gridData.ToList());
            }
        }