public JsonResult GetLocation(int id)
        {
            var            name = "";
            LatLng         ll   = new LatLng();
            LocationRecord lr   = new LocationRecord();

            if (Session["Ctx"] != null)
            {
                var       ctx = Session["ctx"] as Ctx;
                MLocation loc = MLocation.Get(ctx, id, null);

                if (loc == null)
                {
                    return(Json(lr, JsonRequestBehavior.AllowGet));
                }

                name = loc.ToString();

                ll.Longitude = loc.GetLongitude();
                ll.Latitude  = loc.GetLatitude();
            }
            lr.LocItem   = new KeyNamePair(id, name);
            lr.LocLatLng = ll;

            return(Json(lr, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        /// <summary>
        /// Get Location List
        /// </summary>
        /// <param name="ctx">client context</param>
        /// <returns>keyname pair dictionary</returns>
        internal static LocationData GetAllLocations(VAdvantage.Utility.Ctx ctx)
        {
            IDataReader  dr      = null;
            LocationData locData = new LocationData();


            int MAX_ROWS = 10000;
            int count    = 0;
            Dictionary <int, KeyNamePair> locs      = new Dictionary <int, KeyNamePair>();
            Dictionary <int, LatLng>      lstLatLng = new Dictionary <int, LatLng>();

            try
            {
                dr = VAdvantage.DataBase.DB.ExecuteReader("SELECT * FROM C_Location");
                while (dr.Read())
                {
                    if (count > MAX_ROWS)
                    {
                        break;
                    }
                    MLocation loc = MLocation.Get(ctx, Convert.ToInt32(dr["C_Location_ID"]), null);
                    locs[loc.Get_ID()] = new KeyNamePair(loc.Get_ID(), loc.ToString());

                    lstLatLng[loc.Get_ID()] = new LatLng()
                    {
                        Latitude = loc.GetLatitude(), Longitude = loc.GetLongitude()
                    };
                    count++;
                }
                dr.Close();
            }
            catch
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
            }
            locData.LocLookup = locs;
            locData.LocLatLng = lstLatLng;
            return(locData);
        }