Пример #1
0
        public static double earthRadius = 6378137.0; // m
        public static MongoDatabase getDB()
        {
            string        connectionStr = ZConfig.GetConfigString("MongoDB");
            MongoClient   client        = new MongoClient(connectionStr);
            MongoServer   server        = client.GetServer();
            MongoDatabase db            = server.GetDatabase(ZConfig.GetConfigString("MongoDB_DBNAME"));

            return(db);
        }
Пример #2
0
        public static List <UserLocationResult> GetNear(double lon, double lat, int pageIndex, int pageSize, long Day, long StartTime)
        {
            double rangeInM = Convert.ToDouble(ZConfig.GetConfigString("Aotopddistance"));
            List <UserLocationResult> objList = new List <UserLocationResult>();

            try
            {
                // lat = 24.47871208190918, lon = 118.18478393554690
                var         options    = DBManager.getGeoNearOption(rangeInM);
                var         db         = DBManager.getDB();
                var         collection = db.GetCollection(TableName);
                IMongoQuery query      = Query <UserLocation> .Where(o => o.Day == Day && o.StartTime < StartTime);// Query<UserLocation>.Where(o=>o.StartTime>=DateTime.Now.AddHours(8).AddHours(1)  &&  o.Day.Date==DateTime.Now.Date);//<ObjectId>(t => t._id, 0);

                var req = collection.GeoNearAs <UserLocation>(query, lon, lat, pageSize * (pageIndex + 1), options).Hits.Skip(pageSize * pageIndex).Take(pageSize);
                if (req != null)
                {
                    foreach (var item in req)
                    {
                        UserLocationResult objResult = new UserLocationResult();
                        objResult.Loc        = item.Document;
                        objResult.StartTime  = item.Document.StartTime;
                        objResult.EmployeeId = item.Document.EmployeeId;
                        objResult.Day        = item.Document.Day;
                        objResult.BillNo     = item.Document.BillNo;
                        objResult.Distance   = item.Distance;
                        objList.Add(objResult);
                    }
                }
                return(objList);
            }
            catch (Exception exp)
            {
                NLogger.Error("查询附近的人:" + exp.ToString());
                return(objList);
            }
        }
Пример #3
0
        /// <summary>
        /// 订单号转手签保存路径
        /// </summary>
        /// <param name="NO"></param>
        public static string SignaturePath(string NO)
        {
            string SignedPath = ZConfig.GetConfigString("SignedPath");

            return(Path.Combine(SignedPath, NO.Substring(0, 2), NO.Substring(2, 2), NO.Substring(4, 2), NO.Substring(5, (NO.Length - 1) - 5) + ".jpg"));
        }