// public class ArbitraryQuery : Predicate<GPSTrackInfo> // { // private bool m_blnExported; // private bool m_blnBeingExported; // // public ArbitraryQuery(bool blnExported , bool blnBeingExported) // { // _points=points; // } // // public bool Match(GPSTrackInfo trackInfo) // { // // return ((trackInfo.Exported == m_blnExported) && (trackInfo.Exporting==m_blnBeingExported)); // } // } //// //// Comparison<StockItem> stockCmp = new // // Comparison<StockItem>(delegate(StockItem s1, StockItem s2) // // { // // return s2.Title.CompareTo(s1.Title); // // }); // // // public class QuerySorter extends Comparison<GPSTrackInfo> // { // private bool m_blnExported; // private bool m_blnBeingExported; // // public int compare(GPSTrackInfo t1, GPSTrackInfo t2) // { // if (t1. < t2.getDateExec()) return -1; // if (t1.getDateExec() > t2.getDateExec()) return 1; // return 0; // } // } void BtnLogLocationWSClick(object sender, System.EventArgs e) { try { LogLocationService service = new LogLocationService(); service.Url = m_strLogMyPositionURL; PositionalLogEntryRequest request = new PositionalLogEntryRequest(); PositionalLogEntry[] logEntries = new PositionalLogEntry[10]; //TODO: need to know how many positions... Credentials credentials = new Credentials(); credentials.UserID = "u771666"; credentials.AccessToken = "[1212121]"; credentials.Password = "******"; request.Credentials = credentials; request.LogEntry = getLogEntries(); PositionalLogEntryResponse response = service.LogLocation(request); MessageBox.Show(response.ReturnCode, "PositionalLogEntryResponse"); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Message); LogError("An error occurred in -> getLogEntries()...", ex); } }
private PositionalLogEntry[] getLogEntries() { IObjectContainer dbTrack = Db4oFactory.OpenFile(m_strTrackingDBFileName); PositionalLogEntry[] logEntries = null; try{ // RT - there is no need to sort the results for the WS? // Comparison<GPSTrackInfo> trackCmp = new // Comparison<GPSTrackInfo>(delegate(GPSTrackInfo s1, GPSTrackInfo s2) // { // return s1.When.CompareTo(s2.When); // }); // // Native Query using Comparison // Predicate <GPSTrackInfo> trackPred = new Predicate <GPSTrackInfo>(delegate(GPSTrackInfo item) { return(true); //item.Exported == false; }); // // IList<GPSTrackInfo> results = dbTrack.Query<GPSTrackInfo>(trackPred, trackCmp); IList <GPSTrackInfo> results = dbTrack.Query <GPSTrackInfo>(trackPred); //iCount = results.Count; logEntries = new PositionalLogEntry[results.Count]; //TODO: need to know how many positions... int iCurrentPosition = 0; foreach (GPSTrackInfo item in results) { GPSTrackInfo trackInfo = item; ExportGPSInfo.Coordinate coordinate = new Coordinate(); coordinate.Latitude = trackInfo.Where.GetLatitude(CoordinateFormat.DecimalDegrees); coordinate.Longitude = trackInfo.Where.GetLongitude(CoordinateFormat.DecimalDegrees); coordinate.Format = CoordinateFormats.DecimalDegrees; PositionalLogEntry entry = new PositionalLogEntry(); entry.Position = coordinate; entry.Date = trackInfo.When; entry.Time = trackInfo.When; entry.TrackID = trackInfo.TrackId; logEntries[iCurrentPosition] = entry; // string strDate = trackInfo.When.ToString("dd-MMM-yy ") + trackInfo.When.ToString("T"); // string strOutput = "T "+ trackInfo.Where.GetLatitude(CoordinateFormat.DecimalDegrees) + // " " +trackInfo.Where.GetLongitude(CoordinateFormat.DecimalDegrees) + // " " +strDate; // m_swOutputFile.WriteLine(strOutput); //iCount++; //if(iCount < 514) //{ trackInfo.Exported = true; dbTrack.Set(trackInfo); //} iCurrentPosition++; } //m_swOutputFile.WriteLine(result.Count); } catch (Exception ex) { // MessageBox.Show(ex.Message, ex.Message); LogError("An error occurred in -> getLogEntries()...", ex); } finally { dbTrack.Close(); } //PositionalLogEntry[] logEntries = new PositionalLogEntry[10]; //TODO: need to know how many positions... return(logEntries); }
private PositionalLogEntry[] getLogEntries() { IObjectContainer dbTrack = Db4oFactory.OpenFile(m_strTrackingDBFileName); PositionalLogEntry[] logEntries = null; try{ // RT - there is no need to sort the results for the WS? // Comparison<GPSTrackInfo> trackCmp = new // Comparison<GPSTrackInfo>(delegate(GPSTrackInfo s1, GPSTrackInfo s2) // { // return s1.When.CompareTo(s2.When); // }); // // Native Query using Comparison // Predicate<GPSTrackInfo> trackPred = new Predicate<GPSTrackInfo>(delegate(GPSTrackInfo item) { return true; //item.Exported == false; }); // // IList<GPSTrackInfo> results = dbTrack.Query<GPSTrackInfo>(trackPred, trackCmp); IList<GPSTrackInfo> results = dbTrack.Query<GPSTrackInfo>(trackPred); //iCount = results.Count; logEntries = new PositionalLogEntry[results.Count]; //TODO: need to know how many positions... int iCurrentPosition = 0; foreach (GPSTrackInfo item in results) { GPSTrackInfo trackInfo = item; ExportGPSInfo.Coordinate coordinate = new Coordinate(); coordinate.Latitude = trackInfo.Where.GetLatitude(CoordinateFormat.DecimalDegrees); coordinate.Longitude = trackInfo.Where.GetLongitude(CoordinateFormat.DecimalDegrees); coordinate.Format = CoordinateFormats.DecimalDegrees; PositionalLogEntry entry = new PositionalLogEntry(); entry.Position = coordinate; entry.Date = trackInfo.When; entry.Time = trackInfo.When; entry.TrackID = trackInfo.TrackId; logEntries[iCurrentPosition] = entry; // string strDate = trackInfo.When.ToString("dd-MMM-yy ") + trackInfo.When.ToString("T"); // string strOutput = "T "+ trackInfo.Where.GetLatitude(CoordinateFormat.DecimalDegrees) + // " " +trackInfo.Where.GetLongitude(CoordinateFormat.DecimalDegrees) + // " " +strDate; // m_swOutputFile.WriteLine(strOutput); //iCount++; //if(iCount < 514) //{ trackInfo.Exported = true; dbTrack.Set(trackInfo); //} iCurrentPosition++; } //m_swOutputFile.WriteLine(result.Count); } catch (Exception ex) { // MessageBox.Show(ex.Message, ex.Message); LogError("An error occurred in -> getLogEntries()...", ex); } finally { dbTrack.Close(); } //PositionalLogEntry[] logEntries = new PositionalLogEntry[10]; //TODO: need to know how many positions... return logEntries; }
// public class ArbitraryQuery : Predicate<GPSTrackInfo> // { // private bool m_blnExported; // private bool m_blnBeingExported; // // public ArbitraryQuery(bool blnExported , bool blnBeingExported) // { // _points=points; // } // // public bool Match(GPSTrackInfo trackInfo) // { // // return ((trackInfo.Exported == m_blnExported) && (trackInfo.Exporting==m_blnBeingExported)); // } // } //// //// Comparison<StockItem> stockCmp = new // // Comparison<StockItem>(delegate(StockItem s1, StockItem s2) // // { // // return s2.Title.CompareTo(s1.Title); // // }); // // // public class QuerySorter extends Comparison<GPSTrackInfo> // { // private bool m_blnExported; // private bool m_blnBeingExported; // // public int compare(GPSTrackInfo t1, GPSTrackInfo t2) // { // if (t1. < t2.getDateExec()) return -1; // if (t1.getDateExec() > t2.getDateExec()) return 1; // return 0; // } // } void BtnLogLocationWSClick(object sender, System.EventArgs e) { try { LogLocationService service = new LogLocationService(); service.Url = m_strLogMyPositionURL; PositionalLogEntryRequest request = new PositionalLogEntryRequest(); PositionalLogEntry[] logEntries = new PositionalLogEntry[10]; //TODO: need to know how many positions... Credentials credentials = new Credentials(); credentials.UserID = "u771666"; credentials.AccessToken = "[1212121]"; credentials.Password = "******"; request.Credentials = credentials; request.LogEntry = getLogEntries(); PositionalLogEntryResponse response = service.LogLocation(request); MessageBox.Show(response.ReturnCode,"PositionalLogEntryResponse" ); } catch(Exception ex) { MessageBox.Show(ex.Message, ex.Message); LogError("An error occurred in -> getLogEntries()...", ex); } }