示例#1
0
文件: CaBiData.cs 项目: kylehill/cabi
    public static bool AddPullData(XContainer xc, List<Station> stationList)
    {
        try
        {
            string LastUpdate = xc.Element("stations").Attribute("lastUpdate").Value;
            CaBiDataContext dc = new CaBiDataContext();

            if ((from p in dc.Pulls where p.DateSignature == LastUpdate select p).Count<Pull>() == 0)
            {
                Pull p = new Pull();
                p.DateSignature = LastUpdate;
                p.PullDate = DateTime.Now;
                dc.Pulls.InsertOnSubmit(p);
                dc.SubmitChanges();

                int pullID = (from pid in dc.Pulls where pid.DateSignature == LastUpdate select pid.PullID).First<int>();

                foreach (Station s in stationList)
                {
                    if ((from ps in dc.PulledStations where ps.StationID == s.id select ps).Count<PulledStation>() == 0)
                    {
                        CaBiDataContext dcsub = new CaBiDataContext();
                        PulledStation ps = new PulledStation();
                        ps.StationID = s.id;
                        ps.StationName = s.name;
                        ps.Latitude = s.lat;
                        ps.Longitude = s.lng;
                        ps.Installed = s.installed;
                        ps.Locked = s.locked;
                        ps.Temporary = s.temporary;
                        dcsub.PulledStations.InsertOnSubmit(ps);
                        dcsub.SubmitChanges();
                    }

                    PullResult pr = new PullResult();
                    pr.PullID = pullID;
                    pr.StationID = s.id;
                    pr.Docked = s.bikeCount;
                    pr.Empty = s.dockCount;
                    pr.Installed = s.installed;
                    pr.Locked = s.locked;
                    pr.Temporary = s.temporary;
                    dc.PullResults.InsertOnSubmit(pr);
                }
                dc.SubmitChanges();
            }

            return true;
        }
        catch
        {
            return false;
        }
    }
示例#2
0
    public static bool AddPullData(XContainer xc, List <Station> stationList)
    {
        try
        {
            string          LastUpdate = xc.Element("stations").Attribute("lastUpdate").Value;
            CaBiDataContext dc         = new CaBiDataContext();

            if ((from p in dc.Pulls where p.DateSignature == LastUpdate select p).Count <Pull>() == 0)
            {
                Pull p = new Pull();
                p.DateSignature = LastUpdate;
                p.PullDate      = DateTime.Now;
                dc.Pulls.InsertOnSubmit(p);
                dc.SubmitChanges();

                int pullID = (from pid in dc.Pulls where pid.DateSignature == LastUpdate select pid.PullID).First <int>();

                foreach (Station s in stationList)
                {
                    if ((from ps in dc.PulledStations where ps.StationID == s.id select ps).Count <PulledStation>() == 0)
                    {
                        CaBiDataContext dcsub = new CaBiDataContext();
                        PulledStation   ps    = new PulledStation();
                        ps.StationID   = s.id;
                        ps.StationName = s.name;
                        ps.Latitude    = s.lat;
                        ps.Longitude   = s.lng;
                        ps.Installed   = s.installed;
                        ps.Locked      = s.locked;
                        ps.Temporary   = s.temporary;
                        dcsub.PulledStations.InsertOnSubmit(ps);
                        dcsub.SubmitChanges();
                    }

                    PullResult pr = new PullResult();
                    pr.PullID    = pullID;
                    pr.StationID = s.id;
                    pr.Docked    = s.bikeCount;
                    pr.Empty     = s.dockCount;
                    pr.Installed = s.installed;
                    pr.Locked    = s.locked;
                    pr.Temporary = s.temporary;
                    dc.PullResults.InsertOnSubmit(pr);
                }
                dc.SubmitChanges();
            }

            return(true);
        }
        catch
        {
            return(false);
        }
    }
示例#3
0
 partial void DeletePulledStation(PulledStation instance);
示例#4
0
 partial void UpdatePulledStation(PulledStation instance);
示例#5
0
 partial void InsertPulledStation(PulledStation instance);
示例#6
0
 partial void DeletePulledStation(PulledStation instance);
示例#7
0
 partial void UpdatePulledStation(PulledStation instance);
示例#8
0
 partial void InsertPulledStation(PulledStation instance);