コード例 #1
0
        public Timetable(Settings settings, Idms idms)
        {
            this.settings = settings;
            this.idms     = idms;

            var(ok, folder) = settings.GetFolder("Timetable");
            if (ok)
            {
                var ttfNonZips = Directory.GetFiles(folder, "ttisf*").ToList();

                // remove non-rjis files that match the wildcard pattern but do not match a more precise regex:
                ttfNonZips.KeepRegex(@"ttisf\d{3}\.[a-z]{3}$");

                if (ttfNonZips.Count == 0)
                {
                    var rjisZips = Directory.GetFiles(folder, "ttf*.zip").ToList();
                }
                else
                {
                    var serialNumber = GetTimetableFilenameSerialNumber(ttfNonZips.OrderBy(x => GetTimetableFilenameSerialNumber(x)).Last());
                    var rjisLookup   = ttfNonZips.ToLookup(x => Path.GetExtension(x).Substring(1), StringComparer.OrdinalIgnoreCase);
                    var tooMany      = rjisLookup.Where(x => x.Count() > 1);
                    if (tooMany.Count() > 0)
                    {
                        throw new Exception("More than one timetable set in the timetable folder.");
                    }
                    timetableFilenameDict = rjisLookup.ToDictionary(x => x.Key, x => x.First());
                }

                var tasklist = new List <Action> {
                    ProcessMcaFile
                };
                var tlist = tasklist.Select(t => Task.Run(t));

                var  start = DateTime.Now;
                Task all   = Task.WhenAll(tlist).ContinueWith((task) =>
                {
                    if (task.IsCanceled)
                    {
                        System.Diagnostics.Debug.WriteLine("Cancelled");
                    }
                    else if (task.IsFaulted)
                    {
                        var ex = task.Exception;
                        System.Diagnostics.Debug.WriteLine($"Fault: exception is {ex.Message}");
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Task OK");
                        //Application.Current.Dispatcher.Invoke(() => LinesRead = linesRead);
                        // Ready = true;
                        var end    = DateTime.Now;
                        var result = (end - start).TotalSeconds;

                        System.Diagnostics.Debug.WriteLine($"total seconds {result}");
                    }
                });
            }
        }
コード例 #2
0
 public MainModel(Settings settings, RJIS rjis, Idms idms, Timetable timetable, RouteingGuide routeingGuide)
 {
     Settings      = settings;
     Rjis          = rjis;
     Idms          = idms;
     Timetable     = timetable;
     RouteingGuide = routeingGuide;
 }