示例#1
0
        private LineInfo[] getLineList(double Longitude, double Latitude, double radius, string owner, byte device)
#endif
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            List <LineInfo> list = new List <LineInfo>();

            using (var db = BusWebDataService.GetServiceInstance())
            {
                DsBusWeb.UsageStatisticRow log = new DsBusWeb.UsageStatisticDataTable().NewUsageStatisticRow();
                log.Device    = device;
                log.Latitude  = Latitude;
                log.Longitude = Longitude;
                log.Radius    = radius;
                log.UserCode  = owner;
                db.LogAUsageCase(log);
                var dt = db.GetLinesList(Longitude, Latitude, radius, owner);
                foreach (var dr in dt)
                {
                    list.Add(new LineInfo()
                    {
                        LineID = dr.LineID, LineName = dr.LineName
                    });
                }
            }
            return(list.ToArray());
        }
示例#2
0
 protected void btnMerge_Click(object sender, EventArgs e)
 {
     using (var db = BusWebDataService.GetServiceInstance())
         db.MergeLines();
     Response.Redirect("~/DataManager.aspx");
     Response.End();
 }
示例#3
0
        private void removeBadRatingAndMergeLines(object obj)
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            BusWebDataService db = (BusWebDataService)obj;

            db.RemoveBadRatingStops();
            db.MergeLines();
        }
示例#4
0
 protected void btnQry_Click(object sender, EventArgs e)
 {
     using (var dao = BusWebDataService.GetServiceInstance())
     {
         gvData.DataSource = dao.QueryAnything(txtCmd.Text);
         gvData.DataBind();
     }
 }
示例#5
0
 protected void btnRun_Click(object sender, EventArgs e)
 {
     using (var dao = BusWebDataService.GetServiceInstance())
     {
         int effectRow = dao.ExecuteAnything(txtCmd.Text);
         lblRowCount.Text = effectRow.ToString();
     }
 }
示例#6
0
 protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     using (var dao = BusWebDataService.GetServiceInstance())
     {
         dao.DeleteStopByID(int.Parse(GridView2.Rows[e.RowIndex].Cells[0].Text));
         GridView2.DataSource = dao.GetStopsByLineID(LineID);
         GridView2.DataBind();
     }
 }
示例#7
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Button btnID = (Button)GridView1.Rows[e.RowIndex].Cells[0].Controls[0];

            LineID = int.Parse(btnID.Text);
            using (var dao = BusWebDataService.GetServiceInstance())
            {
                dao.DeleteLineByID(LineID);
                GridView1.DataSource = dao.GetLinesList();
                GridView1.DataBind();
            }
        }
示例#8
0
 private void refreshLineList()
 {
     using (var dao = BusWebDataService.GetServiceInstance())
     {
         var dt = dao.GetLinesList();
         foreach (var dr in dt)
         {
             dr.LineName = string.Format("{0}({1})", dr.LineName, dr.LineID);
         }
         ddlLine.DataSource = dt;
         ddlLine.DataBind();
     }
 }
示例#9
0
        private int insertNewLine(string lineName, string culture)
#endif
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            var dr = new DsBusWeb.LinesDataTable().NewLinesRow();

            dr.LineName = lineName;
            dr.Culture  = culture;
            using (var db = BusWebDataService.GetServiceInstance())
            {
                return(db.InsertNewLine(dr));
            }
        }
示例#10
0
 private void Grid2Bind()
 {
     using (var dao = BusWebDataService.GetServiceInstance())
     {
         DataTable dt = dao.GetStopsByLineID(LineID);
         if (!string.IsNullOrEmpty(Grid2SortExp))
         {
             dt.DefaultView.Sort = Grid2SortExp + " " + ((Grid2SortDir == SortDirection.Ascending) ? "ASC" : "DESC");
         }
         GridView2.DataSource = dt.DefaultView;
         GridView2.DataBind();
     }
 }
示例#11
0
 private void Grid1Bind()
 {
     using (var dao = BusWebDataService.GetServiceInstance())
     {
         DataTable dt = dao.GetLinesList(bgnDatePicker.SelectedDate, endDatePicker.SelectedDate);
         if (!string.IsNullOrEmpty(Grid1SortExp))
         {
             dt.DefaultView.Sort = Grid1SortExp + " " + ((Grid1SortDir == SortDirection.Ascending) ? "ASC" : "DESC");
         }
         GridView1.DataSource = dt.DefaultView;
         GridView1.DataBind();
     }
 }
示例#12
0
 protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     using (DsBusWeb ds = new DsBusWeb())
     {
         var dr = ds.Stops.NewStopsRow();
         dr.StopID   = int.Parse(((TextBox)GridView2.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
         dr.StopName = ((TextBox)GridView2.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
         using (var dao = BusWebDataService.GetServiceInstance())
         {
             dao.UpdateStop(dr);
         }
     }
     GridView2.EditIndex = -1;
     Grid2Bind();
 }
示例#13
0
        private void rateStop(int stopID, string goodOrBad)
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            using (var db = BusWebDataService.GetServiceInstance())
                switch (goodOrBad)
                {
                case "g":
                    db.RateStopGood(stopID);
                    break;

                case "b":
                    db.RateStopBad(stopID);
                    break;
                }
        }
示例#14
0
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if ("ID" == e.CommandName)
     {
         Button btnID = (Button)GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[0].Controls[0];
         LineID         = int.Parse(btnID.Text);
         LineName       = GridView1.Rows[int.Parse(e.CommandArgument.ToString())].Cells[1].Text;
         lblParent.Text = string.Format("這是[ID={0}][{1}]路線的站點清單:", LineID, LineName);
         using (var dao = BusWebDataService.GetServiceInstance())
         {
             GridView2.DataSource = dao.GetStopsByLineID(LineID);
             GridView2.DataBind();
         }
     }
 }
示例#15
0
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     using (DsBusWeb ds = new DsBusWeb())
     {
         var dr = ds.Lines.NewLinesRow();
         dr.LineID   = int.Parse(((Button)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text);
         dr.LineName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
         using (var dao = BusWebDataService.GetServiceInstance())
         {
             dao.UpdateLine(dr);
         }
     }
     GridView1.EditIndex = -1;
     Grid1Bind();
 }
示例#16
0
        private void insertNewStop(int lineID, string stopName, double longitude, double latitude, double curLongitude, double curLatitude, string owner, string culture)
#endif
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            #region issue #38 http://dowill-svr/btnet/edit_bug.aspx?id=38
            string hashData = string.Format("{0}{1}{2}{3}{4}", lineID, stopName, longitude, latitude, owner);
            lock (_preventDupSet)
            {
                if (_preventDupSet.Contains(hashData))
                {
                    _preventDupSet.Clear();
                    return;
                }
                _preventDupSet.Add(hashData);
            }
            #endregion

            var dr = new DsBusWeb.StopsDataTable().NewStopsRow();
            dr.Latitude         = latitude;
            dr.Longitude        = longitude;
            dr.StopName         = stopName;
            dr.CreatorLongitude = curLongitude;
            dr.CreatorLatitude  = curLatitude;
            dr.Culture          = culture;
            dr.Owner            = ((string.IsNullOrEmpty(owner)) ? "SYSTEM" : owner);

            var db = BusWebDataService.GetServiceInstance();
            dr.StopID = db.InsertNewStop(dr);
            var dr2 = new DsBusWeb.Line2StopDataTable().NewLine2StopRow();
            dr2.StopID = dr.StopID;
            dr2.LineID = lineID;
            db.InsertNewLine2StopRelation(dr2);



            #region Do remove bad rating stops and data merging
            lock (typeof(Spi))
            {
                if (null == _mergeDataThread ||
                    _mergeDataThread.ThreadState != ThreadState.Running)
                {
                    _mergeDataThread = new Thread(new ParameterizedThreadStart(removeBadRatingAndMergeLines));
                    _mergeDataThread.Start(db);
                }
            }
            #endregion
        }
示例#17
0
        protected void btnManualMerge_Click(object sender, EventArgs e)
        {
            bool success = false;

            using (var db = BusWebDataService.GetServiceInstance())
                success = db.MergeLines(int.Parse(txtLineId1.Text), int.Parse(txtLineId2.Text));

            if (success)
            {
                Response.Redirect("~/DataManager.aspx");
                Response.End();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "mergeError", "alert('路線合併失敗!');", true);
            }
        }
示例#18
0
        private bool deleteStop(int stopID, string owner)
#endif
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            bool success = false;

            using (var db = BusWebDataService.GetServiceInstance())
                if (0 != db.GetStopIDByOwnerAndStopID(stopID, owner))
                {
                    db.DeleteStopByID(stopID);
                    success = true;
                }
                else
                {
                    success = false;
                }
            return(success);
        }
示例#19
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            var gp = parseGMapUrl(txtGMapURL.Text);

            using (var dao = BusWebDataService.GetServiceInstance())
            {
                DsBusWeb ds     = new DsBusWeb();
                int      lineID = 0;
                if (!string.IsNullOrEmpty(txtNewLineName.Text))
                {
                    var dr = ds.Lines.NewLinesRow();
                    dr.LineName = txtNewLineName.Text;
                    lineID      = dao.InsertNewLine(dr);
                }
                else
                {
                    lineID = int.Parse(ddlLine.SelectedValue);
                }

                var dr2 = ds.Stops.NewStopsRow();
                dr2.StopName         = txtNewStopName.Text;
                dr2.Latitude         = gp.latitude;
                dr2.Longitude        = gp.longitude;
                dr2.CreatorLatitude  = 0d;
                dr2.CreatorLongitude = 0d;
                dr2.Owner            = "SYSTEM";

                dr2.StopID = dao.InsertNewStop(dr2);
                var dr3 = new DsBusWeb.Line2StopDataTable().NewLine2StopRow();
                dr3.StopID = dr2.StopID;
                dr3.LineID = lineID;
                dao.InsertNewLine2StopRelation(dr3);
            }
            if (!string.IsNullOrEmpty(txtNewLineName.Text))
            {
                refreshLineList();
            }
            txtNewLineName.Text = string.Empty;
            ClientScript.RegisterClientScriptBlock(typeof(string), "alert", "<script lang=jscript>alert('站點新增成功');</script>");
        }
示例#20
0
        private StopInfo[] getStopsByLineID(int lineID, string owner)
        {
            _log.Info(MethodInfo.GetCurrentMethod().Name);
            List <StopInfo> list = new List <StopInfo>();

            using (var db = BusWebDataService.GetServiceInstance())
            {
                var dt = db.GetStopsByLineID(lineID, owner);
                foreach (var dr in dt)
                {
                    list.Add(new StopInfo()
                    {
                        StopID     = dr.StopID,
                        StopName   = dr.StopName,
                        Latitude   = dr.Latitude,
                        Longtitude = dr.Longitude,
                        Bad        = Convert.ToInt32(dr["RatingBad"]),
                        Good       = Convert.ToInt32(dr["RatingGood"])
                    });
                }
            }
            return(list.ToArray());
        }