Exemplo n.º 1
0
        private void CacheSchedules()
        {
            TransitScheduleCacher.CacheSchedules(ref m_caching_complete, m_workspace_path,
                                                 ref m_total_row_count, SetTotalRowCount, ref m_one_percent,
                                                 ref m_caching_message, ref m_current_table_name, DisplayTableName,
                                                 UpdateTimeUI, ref m_calExceptions, ref m_calendars, ref m_trips, ref m_eids, ref m_linefeatures);

            if (m_caching_complete)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                //btnCancel.Text = "&Close";
                DisplayError();
                m_total_seconds_remaining = 0;
            }
        }
        private void CacheSchedules()
        {
            // Only cache if we haven't done so already, unless we specifically want it to cache every time.
            if (m_CacheOnEverySolve || !m_caches.ContainsKey(m_workspace_path_name))
            {
                // Instantiate new cache object, which we will fill
                Cache m_cache = new Cache();

                if (m_VerboseLogging)
                {
                    WriteToOutputFile(m_LogFile, "CacheSchedules because we don't already have a cache object for this network, or m_CacheOnEverySolve == true");
                }
                try
                {
                    // For Server and 64bit GP, we don't want to display a dialog.
                    //   Check for 64bit and act accordingly.
                    //   Eventually, when desktop is 64bit, this will need to be updated.
                    // you can check the IntPtr size to find out if you are 32 or 64bit
                    //  8 = 64bit, 4 = 32bit;
                    int bits = IntPtr.Size * 8;
                    if (bits != 64)
                    {
                        if (m_VerboseLogging)
                        {
                            WriteToOutputFile(m_LogFile, "32bit. Opening cache progress form");
                        }
                        frmProgress = new ProgressForm(m_workspace_path_name);
                        frmProgress.ShowDialog();

                        if (frmProgress.CachingComplete)
                        {
                            m_cache.m_trips         = frmProgress.Trips;
                            m_cache.m_eids          = frmProgress.eids;
                            m_cache.m_calendars     = frmProgress.Calendars;
                            m_cache.m_calExceptions = frmProgress.Cal_Exceptions;
                            if (m_VerboseLogging)
                            {
                                WriteToOutputFile(m_LogFile, "Cache complete. m_trips: " + m_cache.m_trips.Count + " m_calendars: " + m_cache.m_calendars.Count + " m_calExceptions: " + m_cache.m_calExceptions.Count + " m_eids: " + m_cache.m_eids.Count);
                            }
                        }
                        else
                        {
                            string error_message = "Unable to cache transit schedules." + Environment.NewLine + "Details: " + frmProgress.CachingMessage;
                            if (m_VerboseLogging)
                            {
                                WriteToOutputFile(m_LogFile, error_message);
                            }
                            throw new Exception(error_message);
                        }
                    }
                    else
                    {
                        if (m_VerboseLogging)
                        {
                            WriteToOutputFile(m_LogFile, "64bit. Opening cache progress form");
                        }
                        bool   caching_completed  = false;
                        string caching_message    = "";
                        int    total_row_count    = 0;
                        int    one_percent        = 1;
                        string current_table_name = "";
                        TransitScheduleCacher.CacheSchedules(ref caching_completed, m_workspace_path_name,
                                                             ref total_row_count, null, ref one_percent, ref caching_message,
                                                             ref current_table_name, null, null,
                                                             ref m_cache.m_calExceptions, ref m_cache.m_calendars, ref m_cache.m_trips, ref m_cache.m_eids, ref m_cache.m_linefeatures);

                        if (m_VerboseLogging)
                        {
                            WriteToOutputFile(m_LogFile, "Cache complete. m_trips: " + m_cache.m_trips.Count + " m_calendars: " + m_cache.m_calendars.Count + " m_calExceptions: " + m_cache.m_calExceptions.Count + " m_eids: " + m_cache.m_eids.Count);
                        }

                        if (!caching_completed)
                        {
                            string error_message = "Unable to cache transit schedules." + Environment.NewLine + "Details: " + caching_message;
                            if (m_VerboseLogging)
                            {
                                WriteToOutputFile(m_LogFile, error_message);
                            }
                            throw new Exception(error_message);
                        }
                    }

                    // Add the current cache to a dictionary of caches we can choose from at solve time.
                    if (m_caches.ContainsKey(m_workspace_path_name))
                    {
                        m_caches[m_workspace_path_name] = m_cache;
                    }
                    else
                    {
                        m_caches.Add(m_workspace_path_name, m_cache);
                    }
                }
                catch (Exception e)
                {
                    string error_message = "Transit schedule caching failure for " + DisplayName + ". Error message: " + e.Message;
                    if (m_VerboseLogging)
                    {
                        WriteToOutputFile(m_LogFile, error_message);
                    }
                    throw new Exception(error_message, e);
                }
            }
        }