private void PrepareDataSet()
        {
            TimeGraphUI = new BindableCollection <TimeGraphUIModel>();
            var serviceList = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId));

            foreach (var service in serviceList)
            {
                var item = new TimeGraphUIModel();
                var serviceTemplateId = service.ServiceTemplateId;
                item.TimeEventList       = new BindableCollection <ExtendedFullTimeEventModel>(FullTimeEventDataAccess.GetAllExtendedFullTimeEventsPerServiceTemplate(serviceTemplateId));
                item.ServiceName         = service.ServiceName;
                item.ServiceAbbreviation = service.ServiceAbbreviation;
                int actualTime = service.StartTime;
                foreach (var fullTimeEvent in item.TimeEventList)
                {
                    actualTime += fullTimeEvent.ArrivalTime;
                    DataPoint point = GetFirstDataPoint(fullTimeEvent, actualTime);
                    item.DataLine.Add(point);
                    if (fullTimeEvent.WaitTime > 0)
                    {
                        actualTime += fullTimeEvent.WaitTime;
                        DataPoint point2 = GetSecondDataPoint(actualTime, point.X);
                        item.DataLine.Add(point2);
                    }
                }
                TimeGraphUI.Add(item);
            }
        }
        private void SetPeriod()
        {
            var Services = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId));

            GraphCanvasSettings.StartTime = (Services.Min(x => x.StartTime) / 60) * 60;
            GraphCanvasSettings.EndTime   = (Services.Max(x => x.EndTime) / 60 + 1) * 60;
        }
Exemple #3
0
        private bool insertToDatabase(string filename)
        {
            ExcelSheet sheet = new ExcelSheet();

            sheet.open(filename);

            if (!sheet.isOpen())
            {
                return(false);
            }
            DataSet  dsCountry = CountriesDataAccess.getAsDataset();
            DataSet  dsRates   = sheet.getDataSet();
            DateTime startDate = getDateFromName(sheet.getName());
            DateTime endDate   = new DateTime(3015, 1, 1);//FIXME hardcoded end date
            DateTime capDate   = startDate.AddSeconds(-1);

            Hashtable hCountry = CreateIndexHashtable(dsCountry.Tables[0]);


            ServicesDataAccess.capEndDate(capDate);

            for (int i = 0; i < sheet.getTabCount(); i++)
            {
                int st = Environment.TickCount;
                insertSheet(dsRates, hCountry, i, startDate, endDate);
                Debug.WriteLine("insertSheet took:{0}ms", Environment.TickCount - st);
            }

            return(true);
        }
        public async Task Repeat()
        {
            ServiceId       = SelectedService.Id;
            ServiceTemplate = ServiceTemplateDataAccess.GetServiceTemplateById(SelectedService.ServiceTemplateId);
            ReviewServicesViewModel reviewVM = IoC.Get <ReviewServicesViewModel>();

            for (int i = 0; i < RepeatCount; i++)
            {
                var newService = new ServiceModel();
                newService.ServiceTemplateId = ServiceTemplate.Id;
                newService.ServiceName       = SelectedService.ServiceName;
                newService.StartTime         = SelectedService.StartTime + (i + 1) * TimeOffset;
                newService.EndTime           = SelectedService.EndTime + (i + 1) * TimeOffset;
                int    serviceNumber = NumberStart + i * NumberOffset;
                string offset        = serviceNumber.ToString($"D{Digits}");
                newService.ServiceAbbreviation = $"{ServiceTemplate.ServiceTemplateAbbreviation}{Separator}{offset}";
                reviewVM.CreatedServices.Add(newService);
            }

            reviewVM.CreatedServices = new BindableCollection <ServiceModel>(reviewVM.CreatedServices.OrderBy(x => x.StartTime));
            await _windowManager.ShowDialogAsync(reviewVM);

            if (reviewVM.IsSaved)
            {
                ServiceList = new BindableCollection <ServiceModel>(ServicesDataAccess
                                                                    .GetServicesPerRoute(RouteId).OrderBy(x => x.StartTime));
                NotifyOfPropertyChange(() => ServiceList);
            }
            NotifyOfPropertyChange(() => CanRepeat);
        }
 public void CopyAllServices()
 {
     foreach (var item in ServiceSourceList)
     {
         ConnectTtSiDataAccess.InsertConnection(item.Id, SelectedTimetable.Id);
     }
     ServiceDestinationList = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(SelectedTimetable.Id));
     NotifyOfPropertyChange(() => ServiceDestinationList);
     NotifyOfPropertyChange(() => CopyStatus);
 }
Exemple #6
0
        private void insertSheet(DataSet dsRates, Hashtable htCountry, int tabIndex, DateTime startDate, DateTime endDate)
        {
            int   destCountryID;
            float peekRate;
            float offPeekRate;
            int   sourceCountryID = 0;

            DataTable table = dsRates.Tables[tabIndex];

            string[] words = table.TableName.Split('_');
            if (words.Length < 2)
            {
                return;
            }

            string serviceName       = words[0];
            string sourceCountryName = words[1];
            int    peekStartTime     = getPeekStartTime(table.TableName);
            int    offPeekStartTime  = getOffPeekStartTime(table.TableName);

            try
            {
                sourceCountryID = Int16.Parse(htCountry[sourceCountryName].ToString());   //constant acces time
            }
            catch (Exception)
            {
                Debug.WriteLine("Error looking up for country {0}", sourceCountryName);
            }

            DataTable dt = initBatchTable();


            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataRow tmp    = table.Rows[i];
                DataRow newRow = dt.NewRow();
                destCountryID = Int16.Parse(tmp[0].ToString());
                peekRate      = float.Parse(tmp[1].ToString());
                offPeekRate   = float.Parse(tmp[2].ToString());

                newRow["Name"]                  = serviceName;
                newRow["PeekRate"]              = peekRate;
                newRow["OffPeekRate"]           = offPeekRate;
                newRow["RateEffectiveDate"]     = startDate;
                newRow["RateEndDate"]           = endDate;
                newRow["PeekRateStartTime"]     = peekStartTime;
                newRow["OffPeekRateStartTime"]  = offPeekStartTime;
                newRow["DestinationCountry_ID"] = destCountryID;
                newRow["SourceCountry_ID"]      = sourceCountryID;

                dt.Rows.Add(newRow);
                //ServicesDataAccess.insertService(serviceName, peekRate, offPeekRate, startDate, endDate, sourceCountryID, destCountryID);
            }
            ServicesDataAccess.insertServiceTable(dt);
        }
        public async Task OK()
        {
            foreach (var item in CreatedServices)
            {
                ServicesDataAccess.InsertService(item);
            }

            IsSaved = true;
            CreatedServices.Clear();
            await TryCloseAsync();
        }
Exemple #8
0
        public ServicesDataModel()
        {
            this.Services = new List <string>();
            this.Statuses = new List <string>();
            ServicesDataAccess sda = new ServicesDataAccess();

            foreach (var service in sda.Services)
            {
                this.Services.Add(service.Key);
                this.Statuses.Add(service.Value);
            }
        }
        protected override async void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);
            RouteModel rm = RouteDataAccess.GetRouteById(RouteId);

            RouteName           = rm.RouteName;
            ServiceTemplateList = new BindableCollection <ServiceTemplateModel>(ServiceTemplateDataAccess.GetServiceTemplatesPerRoute(RouteId));
            ServiceList         = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerRoute(RouteId).OrderBy(x => x.StartTime));
            NotifyOfPropertyChange(() => ServiceTemplateList);
            NotifyOfPropertyChange(() => ServiceList);
            NotifyOfPropertyChange(() => RouteName);
            NotifyOfPropertyChange(() => TimetableName);
        }
        public void SaveService()
        {
            ServiceModel newService = new ServiceModel();

            newService.ServiceName         = ServiceName;
            newService.ServiceAbbreviation = ServiceAbbreviation;
            newService.ServiceTemplateId   = ServiceTemplate.Id;
            newService.StartTime           = TimeConverters.TimeToMinutes(StartTimeText);
            newService.EndTime             = TimeConverters.TimeToMinutes(EndTimeText);
            if (ServiceId <= 0)
            {
                ServicesDataAccess.InsertService(newService);
            }
            else
            {
                newService.Id = ServiceId;
                ServicesDataAccess.UpdateService(newService);
            }
            ServiceList = new BindableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerRoute(RouteId).OrderBy(x => x.StartTime));
            ClearService();
            NotifyOfPropertyChange(() => ServiceList);
        }
        private void PrepareDataSet()
        {
            TimeGraphUI      = new ObservableCollection <TimeGraphUIModel>();
            ServiceClassList = ServiceClassDataAccess.GetAllServiceClasses();
            var serviceList = new ObservableCollection <ServiceModel>(ServicesDataAccess.GetServicesPerTimetable(TimetableId));

            foreach (var service in serviceList)
            {
                var item = new TimeGraphUIModel();
                var serviceTemplateId = service.ServiceTemplateId;
                var serviceTemplate   = ServiceTemplateDataAccess.GetServiceTemplateById(serviceTemplateId);
                item.TimeEventList       = new BindableCollection <ExtendedFullTimeEventModel>(FullTimeEventDataAccess.GetAllExtendedFullTimeEventsPerServiceTemplate(serviceTemplateId));
                item.ServiceName         = service.ServiceName;
                item.ServiceAbbreviation = service.ServiceAbbreviation;
                item.ServiceType         = serviceTemplate.ServiceType;
                item.StartTimeText       = service.StartTimeText;
                item.EndTimeText         = service.EndTimeText;
                int actualTime = service.StartTime;
                foreach (var fullTimeEvent in item.TimeEventList)
                {
                    actualTime += fullTimeEvent.ArrivalTime;
                    fullTimeEvent.ArrivalTimeText = TimeConverters.MinutesToString(actualTime);
                    DataPoint point = GetFirstDataPoint(fullTimeEvent, actualTime);
                    item.DataLine.Add(point);
                    if (fullTimeEvent.WaitTime > 0)
                    {
                        actualTime += fullTimeEvent.WaitTime;
                        DataPoint point2 = GetSecondDataPoint(actualTime, point.X);
                        item.DataLine.Add(point2);
                    }
                    fullTimeEvent.DepartureTimeText = TimeConverters.MinutesToString(actualTime);
                }
                TimeGraphUI.Add(item);
            }
            OnPropertyChanged("TimeGraphUI");
        }
 public void DeleteService()
 {
     ServicesDataAccess.DeleteService(SelectedService.Id);
     ServiceList.Remove(SelectedService);
     ServiceId = 0;
 }