コード例 #1
0
        public static void StartWebServer()
        {
            if (_started)
            {
                return;
            }

            //setup routes
            RouteManager.AddRoute("/Now", RouteHandlers.Now);

            _ws = new WebServer();
            _ws.Start();

            _started = true;
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Route route = new Route();

                City fromcity = new City();
                if (dpFromCity.SelectedItem.Value != "None" && dpFromCity.SelectedItem.Value != "None")
                {
                    fromcity.CityId = long.Parse(dpFromCity.SelectedItem.Value);
                }
                fromcity.Name  = dpFromCity.SelectedItem.Text;
                route.FromCity = fromcity;

                City tocity = new City();
                if (dpToCity.SelectedItem.Value != "None" && dpToCity.SelectedItem.Value != "None")
                {
                    tocity.CityId = long.Parse(dpToCity.SelectedItem.Value);
                }
                tocity.Name  = dpToCity.SelectedItem.Text;
                route.ToCity = tocity;

                if (txtDistance.Text != "" && txtDistance.Text != null)
                {
                    route.DistanceInKms = double.Parse(txtDistance.Text);
                }

                route.IsActive = chkActive.Checked;
                if (obj.AddRoute(route))
                {
                    lblError.Text = "Route Added Successfully";
                }
                else
                {
                    lblError.Text = "Unable to add Route";
                }
            }
            catch (RouteManagerException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }