コード例 #1
0
ファイル: CacheLog.cs プロジェクト: michaeloed/mgmgeo
        /// <summary>
        /// Clone current object
        /// </summary>
        /// <returns>cloned object</returns>
        public CacheLog Clone()
        {
            CacheLog log = new CacheLog(_daddy);

            log._Date       = _Date;
            log._Encoded    = _Encoded;
            log._FinderId   = _FinderId;
            log._LogId      = _LogId;
            log._SortingKey = _SortingKey;
            log._Text       = _Text;
            log._Type       = _Type;
            log._User       = _User;

            return(log);
        }
コード例 #2
0
        private static Geocache FillGeocache(MainWindow daddy, String owner, String dbname, String code, SQLiteDataReader rdr, SQLiteConnection con)
        {
            var geo = new Geocache(daddy);

            geo._Code                   = code;
            geo._Url                    = "http://coord.info/" + geo._Code;
            geo._CacheId                = rdr["CacheID"] as String;
            geo._Name                   = rdr["Name"] as String;
            geo._Type                   = rdr["Type"] as String;
            geo._dLatitude              = (Double)(rdr["Latitude"]);
            geo._dLongitude             = (Double)(rdr["Longitude"]);
            geo._Latitude               = geo._dLatitude.ToString().Replace(",", ".");
            geo._Longitude              = geo._dLongitude.ToString().Replace(",", ".");
            geo._D                      = rdr["Difficulty"] as String;
            geo._T                      = rdr["Terrain"] as String;
            geo._Owner                  = rdr["Owner"] as String;
            geo._OwnerId                = rdr["OwnerId"] as String;
            geo._PlacedBy               = rdr["PlacedBy"] as String;
            geo._DateCreation           = rdr["DateCreation"] as String;
            geo._ShortDescription       = rdr["ShortDescription"] as String;
            geo._LongDescription        = rdr["LongDescription"] as String;
            geo._ShortDescriptionInHTML = geo._ShortDescription;
            geo._LongDescriptionInHTML  = geo._LongDescription;
            geo._ShortDescHTML          = ((bool)(rdr["ShortDescriptionAsHTML"]))?"True":"False";
            geo._LongDescHTML           = ((bool)(rdr["LongDescriptionAsHTML"]))?"True":"False";
            geo._Available              = ((bool)(rdr["Available"]))?"True":"False";
            geo._Archived               = ((bool)(rdr["Archived"]))?"True":"False";
            geo._Container              = rdr["Container"] as String;
            geo._Hint                   = rdr["Hint"] as String;
            geo._bFound                 = (bool)(rdr["Found"]);
            geo._listAttributesId       = new List <String>((rdr["AttributesIds"] as String).Split(';'));
            if (geo._listAttributesId.Count != 0)
            {
                geo._listAttributesId.RemoveAt(geo._listAttributesId.Count - 1);
            }
            geo._Attributes = new List <String>((rdr["AttributesStatus"] as String).Split(';'));
            if (geo._Attributes.Count != 0)
            {
                geo._Attributes.RemoveAt(geo._Attributes.Count - 1);
            }

            // LogIds
            String logsid = rdr["LogIds"] as String;

            if (logsid != "")
            {
                logsid = logsid.Substring(0, logsid.Length - 1);
            }

            if (logsid != "")
            {
                // Retrieve log from DB
                String sq = "SELECT * from Log where LogId in (" + logsid + ")";
                // retrieve values
                using (SQLiteCommand cmd3 = new SQLiteCommand(sq, con))
                {
                    using (SQLiteDataReader rdr3 = cmd3.ExecuteReader())
                    {
                        while (rdr3.Read())
                        {
                            CacheLog log = new CacheLog(daddy);
                            log._LogId    = rdr3["LogId"] as String;
                            log._Date     = rdr3["Date"] as String;
                            log._Type     = rdr3["Type"] as String;
                            log._User     = rdr3["Finder"] as String;
                            log._FinderId = rdr3["FinderId"] as String;
                            log._Text     = rdr3["Comment"] as String;
                            log._Encoded  = ((bool)(rdr3["CommentIsEncoded"]))?"True":"False";
                            geo._Logs.Insert(0, log);
                        }
                    }
                }
            }

            // WaypointsIds
            String wptsid = rdr["WaypointsIds"] as String;

            if (wptsid != "")
            {
                wptsid = wptsid.Substring(0, wptsid.Length - 1);
            }
            if (wptsid != "")
            {
                // Retrieve wpts from DB
                String[] ids = wptsid.Split(',');
                wptsid = "";
                foreach (String id in ids)
                {
                    wptsid += "'" + id + "',";
                }
                wptsid = wptsid.Substring(0, wptsid.Length - 1);
                String sq = "SELECT * from Waypoint where Code in (" + wptsid + ")";
                // retrieve values
                using (SQLiteCommand cmd3 = new SQLiteCommand(sq, con))
                {
                    using (SQLiteDataReader rdr3 = cmd3.ExecuteReader())
                    {
                        while (rdr3.Read())
                        {
                            Waypoint wpt   = new Waypoint();
                            String   wcode = rdr3["Code"] as String;
                            wpt._name       = wcode;
                            wpt._GCparent   = geo._Code;
                            wpt._eOrigin    = (Waypoint.WaypointOrigin)((int)(rdr3["Origin"]));
                            wpt._lat        = rdr3["Latitude"] as String;
                            wpt._lon        = rdr3["Longitude"] as String;
                            wpt._time       = rdr3["Date"] as String;
                            wpt._cmt        = rdr3["Comment"] as String;
                            wpt._desc       = rdr3["Description"] as String;
                            wpt._url        = rdr3["Url"] as String;
                            wpt._urlname    = rdr3["UrlName"] as String;
                            wpt._sym        = rdr3["Symbol"] as String;
                            wpt._type       = rdr3["Type"] as String;
                            wpt._DateExport = DateTime.Parse(rdr3["DateExport"] as String);


                            geo._waypoints.Add(wcode, wpt);
                        }
                    }
                }
            }

            // TBIds
            String tbsid = rdr["TBIds"] as String;

            if (tbsid != "")
            {
                tbsid = tbsid.Substring(0, tbsid.Length - 1);
            }
            if (tbsid != "")
            {
                // Retrieve tbs from DB
                String sq = "SELECT * from TravelBug where Id in (" + tbsid + ")";
                // retrieve values
                using (SQLiteCommand cmd3 = new SQLiteCommand(sq, con))
                {
                    using (SQLiteDataReader rdr3 = cmd3.ExecuteReader())
                    {
                        while (rdr3.Read())
                        {
                            geo._listTBId.Add(rdr3["Id"] as String);
                            geo._listTB.Add(rdr3["Ref"] as String, rdr3["Name"] as String);
                        }
                    }
                }
            }

            geo._Country    = rdr["Country"] as String;
            geo._State      = rdr["State"] as String;
            geo._DateExport = DateTime.Parse(rdr["DateExport"] as String);

            // Owned ?

            geo.UpdateDistanceToHome(daddy.HomeLat, daddy.HomeLon);

            // Update donnée privées
            geo.UpdatePrivateData(owner); // fait netre autre les coords

            // complete origin
            geo._origin.Add(dbname);

            return(geo);
        }