예제 #1
0
        /// <summary>
        /// Writes out an updated field notes file
        /// </summary>
        private void UpdateFNFile()
        {
            string fnFile = m_Win.App.AppConfig.FieldNotesFile;

            FieldNotesHandler.ClearFieldNotes(fnFile);
            FieldNotesHandler.WriteToFile(m_Logs, fnFile);
        }
예제 #2
0
        /// <summary>
        /// Warns the user about unsaved changes when switching selected field note
        /// </summary>
        private void HandleUnsavedChanges()
        {
            MessageDialog dlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,
                                                  Catalog.GetString("You have unsaved changes that will be lost. Do you wish to save?\n"));

            if ((int)(ResponseType.Yes) == dlg.Run())
            {
                SaveLogChanges();
            }
            else
            {
                hasUnsaved = false;
                PopulateLogs(FieldNotesHandler.GetLogs(m_Win.App.AppConfig.FieldNotesFile, m_Win.App.OwnerIDs[0]));
            }
            dlg.Hide();
            dlg.Dispose();
            hasUnsaved = false;
        }
예제 #3
0
        protected virtual void OnDeleteAllClick(object sender, System.EventArgs e)
        {
            MessageDialog dlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo,
                                                  Catalog.GetString("Are you sure you want to remove all field notes?"));

            try
            {
                if ((int)ResponseType.Yes == dlg.Run())
                {
                    FieldNotesHandler.ClearFieldNotes(m_Win.App.AppConfig.FieldNotesFile);
                    m_Logs.Clear();
                    PopulateLogs(m_Logs);
                }
                dlg.Hide();
                dlg.Dispose();
            }
            catch (Exception e1)
            {
                dlg.Hide();
                OCMApp.ShowException(e1);
            }
        }
예제 #4
0
 /// <summary>
 /// Connect to the specified profile and download all field notes
 /// </summary>
 /// <param name="profile">
 /// The GPS Profile to use <see cref="GPSProfile"/>
 /// </param>
 /// <param name="latestScan">
 /// Logs older then this date will be ignored <see cref="DateTime"/>
 /// </param>
 /// <param name="ownerId">
 /// The owner ID to use for marking the logs in the OCM DB <see cref="String"/>
 /// </param>
 /// <returns>
 /// The new datetime of the latest scan <see cref="DateTime"/>
 /// </returns>
 public DateTime ProcessFieldNotes(GPSProfile profile, DateTime latestScan, String ownerId)
 {
     try
     {
         statusLabel.Markup = Catalog.GetString("<i>Receiving from device...</i>");
         OCMApp.UpdateGUIThread();
         List <CacheLog> logs       = FieldNotesHandler.GetLogs(profile.FieldNotesFile, ownerId);
         int             iCount     = 0;
         int             iProgCount = 0;
         int             iTotal     = logs.Count;
         statusLabel.Markup = Catalog.GetString("<i>Processing Field Notes...</i>");
         m_Win.App.CacheStore.StartUpdate();
         DateTime newLatest = DateTime.MinValue;
         foreach (CacheLog log in logs)
         {
             if (m_cancel)
             {
                 m_Win.App.CacheStore.CancelUpdate();
                 return(DateTime.MinValue);
             }
             double prog = (double)((double)iProgCount / (double)iTotal);
             loadProgress.Fraction = prog;
             loadProgress.Text     = prog.ToString("0%");
             iProgCount++;
             OCMApp.UpdateGUIThread();
             if (log.LogDate <= latestScan)
             {
                 System.Console.WriteLine("Skipping" + latestScan);
                 continue;
             }
             List <Geocache> cache = m_Win.App.CacheStore.GetCachesByName(new string[] { log.CacheCode });
             if (cache.Count > 0)
             {
                 UpdateCache(cache[0], log);
             }
             if (newLatest < log.LogDate)
             {
                 newLatest = log.LogDate;
             }
             iCount++;
         }
         if (!m_cancel)
         {
             UpdateFNFile(logs);
             m_Win.App.CacheStore.CompleteUpdate();
         }
         else
         {
             m_Win.App.CacheStore.CancelUpdate();
         }
         buttonCancel.Visible  = false;
         buttonClose.Visible   = true;
         buttonView.Visible    = true;
         loadProgress.Fraction = 1;
         statusLabel.Markup    = String.Format(Catalog.GetString("<i>Scanned {0} Field Notes, {1} new.</i>"), iProgCount, iCount);
         loadProgress.Text     = Catalog.GetString("Complete");
         return(newLatest);
     }
     catch (Exception e)
     {
         m_Win.App.CacheStore.CancelUpdate();
         this.Hide();
         OCMApp.ShowException(e);
         return(DateTime.MinValue);
     }
 }
예제 #5
0
        /// <summary>
        /// Writes out an updated field notes file
        /// </summary>
        private void UpdateFNFile(List <CacheLog> logs)
        {
            string fnFile = m_Win.App.AppConfig.FieldNotesFile;

            FieldNotesHandler.WriteToFile(logs, fnFile);
        }