Пример #1
0
        public static List <TechnicianRequirement> TestGetTourOfTechnician(Ident ident, int mandatorId, ID technicianID, DateTime date, VueTOView.Common.Environment environment)
        {
            List <TechnicianRequirement> list   = new List <TechnicianRequirement>();
            List <TechnicianRequirement> tours  = new List <TechnicianRequirement>();
            WebToolExtendedServiceClient client = ClientProvider.ProvideTOClient(environment);
            Task <ServiceReference2.ResultListOfAppointmentuukIAVwv> task = client.GetTourOfTechnicianAsync(ident, mandatorId, technicianID, date, null);
            ResultListOfAppointmentuukIAVwv result = task.Result;

            if ((result != null) && string.IsNullOrEmpty(result.Error) && (result.DataList != null) && (result.DataList.Length > 0))
            {
                List <Appointment> appointments = result.DataList.Where(x => x.State != ActivationState.Deleted).ToList();
                foreach (Appointment appointment in appointments)
                {
                    List <TechnicianRequirement> appointmenttours = appointment.TechnicianRequirements.Where(y => y.TechnicianID.SourceId == technicianID.SourceId && y.State != ActivationState.Deleted).ToList();
                    foreach (TechnicianRequirement tour in appointmenttours)
                    {
                        tour.Appointment             = appointment;
                        tour.Appointment.GeoLocation = TestGetGeoLocation(client, ident, mandatorId, tour.Appointment.GeoLocationID);
                        if (tour.Appointment.GeoLocation != null)
                        {
                            tours.Add(tour);
                        }
                    }
                }

                list = tours.OrderBy(x => x.RealStart).ToList();
            }

            return(list);
        }
Пример #2
0
        public static List <TechnicianRequirement> GetToursOfTechnicianFromService(GetToursOfTechnicianRequest getToursOfTechnicianRequest)
        {
            if (getToursOfTechnicianRequest == null)
            {
                throw new ArgumentNullException(nameof(getToursOfTechnicianRequest));
            }

            List <TechnicianRequirement> list   = new List <TechnicianRequirement>();
            List <TechnicianRequirement> tours  = new List <TechnicianRequirement>();
            WebToolExtendedServiceClient client = ClientProvider.ProvideTOClient(getToursOfTechnicianRequest.Environment);
            Task <ServiceReference2.ResultListOfAppointmentuukIAVwv> task = client.GetTourOfTechnicianAsync(getToursOfTechnicianRequest.Ident, getToursOfTechnicianRequest.MandatorId, getToursOfTechnicianRequest.TechnicianID, getToursOfTechnicianRequest.Date, null);
            ResultListOfAppointmentuukIAVwv result = task.Result;

            if ((result != null) && string.IsNullOrEmpty(result.Error) && (result.DataList != null) && (result.DataList.Length > 0))
            {
                List <Appointment> appointments = result.DataList.Where(x => x.State != ActivationState.Deleted).ToList();
                foreach (Appointment appointment in appointments)
                {
                    List <TechnicianRequirement> appointmenttours = appointment.TechnicianRequirements.Where(y => y.TechnicianID.SourceId == getToursOfTechnicianRequest.TechnicianID.SourceId && y.State != ActivationState.Deleted).ToList();
                    foreach (TechnicianRequirement tour in appointmenttours)
                    {
                        tour.Appointment             = appointment;
                        tour.Appointment.GeoLocation = GetGeoLocation(client, getToursOfTechnicianRequest.Ident, getToursOfTechnicianRequest.MandatorId, tour.Appointment.GeoLocationID);
                        if (tour.Appointment.GeoLocation != null)
                        {
                            tours.Add(tour);
                        }
                    }
                }

                list = tours.OrderBy(x => x.RealStart).ToList();
            }

            return(list);
        }