Exemplo n.º 1
0
        /// <summary>
        /// 根据是否采集时间和是否推荐来读取数据列表
        /// </summary>
        /// <param name="dateTime">创建时间</param>
        /// <param name="recommend">是否推荐</param>
        /// <returns></returns>
        public List <OnLineModel> obtainAll(OnLineModel querys)
        {
            List <OnLineModel> agenters = new List <OnLineModel>();
            IMongoQuery        query    = null;

            query = Query.And(Query.EQ("onLine", true));
            if (querys != null)
            {
                if (!string.IsNullOrEmpty(querys.brand))
                {
                    query = Query.And(Query.EQ("brand", querys.brand));
                }
                if (!string.IsNullOrEmpty(querys.origin))
                {
                    query = Query.And(Query.EQ("origin", querys.origin));
                }
            }
            foreach (var record in _mongoCollection.FindAs <Object>(query).ToList())
            {
                Dictionary <String, Object> dictionary = record.ToBsonDocument().ToDictionary();
                OnLineModel onLineModel = new OnLineModel();
                agenters.Add(toEntity <OnLineModel>(dictionary, onLineModel));
            }
            return(agenters);
        }
 /// <summary>
 /// 创建医生在线时长记录
 /// </summary>
 /// <param name="model"></param>
 public string CreateDoctorOnlineRecord(OnLineModel model)
 {
     using (var conn = MySqlHelper.GetConnection())
     {
         return(conn.Insert <string, OnLineModel>(model));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 用户出席通知
        /// </summary>
        /// <param name="client"></param>
        /// <param name="presence"></param>
        private static void Client_OnPresence(Client client, XmppPresence presence)
        {
            Settings settings            = Factory.GetSettings("host.json");
            var      doctorPresentSwitch = settings["DoctorPresentSwitch"];

            if (bool.TryParse(doctorPresentSwitch, out bool doctorPresentSwitchRes))
            {
                if (!doctorPresentSwitchRes)
                {
                    return;
                }
            }
            var userGuid = presence.Sender;
            var isOnline = presence.Online;

            Logger.Debug($"用户出席通知{userGuid}({presence.Resource})-{isOnline.ToString()}");

            #region 检测出席用户是否是医生
            var checkDoctorList = RedisHelper.Get <string>("CloudDoctor:DoctorList");
            if (checkDoctorList != null)
            {
                var doctorGuids = JsonConvert.DeserializeObject <List <string> >(checkDoctorList);
                if (!doctorGuids.Contains(userGuid))
                {
                    return;
                }
            }
            #endregion

            new UserPresenceBiz().SetPresenceStatus(userGuid, isOnline);

            var result = new UserPresenceBiz().GetPresenceStatus(userGuid);
            if (!result.IsOnline && result.LatestOnlineTime != null)
            {
                var model = new OnLineModel()
                {
                    OnlineGuid    = Guid.NewGuid().ToString("N"),
                    DoctorGuid    = userGuid,
                    LoginTime     = result.LatestOnlineTime.Value,
                    LogoutTime    = DateTime.Now,
                    CreatedBy     = userGuid,
                    LastUpdatedBy = userGuid,
                    OrgGuid       = ""
                };

                model.Duration = (decimal)Math.Round((model.LogoutTime - model.LoginTime).TotalMinutes, 2);

                var onlineResult = new HospitalManagerBiz().CreateDoctorOnlineRecord(model);
                if (string.IsNullOrEmpty(onlineResult))
                {
                    Logger.Warn($"添加医生“{userGuid}”在线时长记录失败");
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 新增上线信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream addOnLine(ImpContext context)
        {
            MongOnLine mongOnLine = new MongOnLine(Constants.daname);
            MongWaitUp mongWaitUp = new MongWaitUp(Constants.daname);
            //反序列dd化
            OnLineModel onLineModel = JsonConvert.DeserializeObject <OnLineModel>(context.json.Replace("\0", ""), new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            if (string.IsNullOrEmpty(onLineModel.guid))
            {
                if (onLineModel.createDate.Year == 1)
                {
                    onLineModel.createDate = DateTime.Now;
                }
                onLineModel.guid = Guid.NewGuid().ToString();
                if (string.IsNullOrEmpty(onLineModel._id))
                {
                    onLineModel._id = Guid.NewGuid().ToString();
                }
                onLineModel.onLine = true;
                onLineModel.clickN = 0;
                mongOnLine.insert(onLineModel);
                mongWaitUp.delete(new WaitUpModel()
                {
                    _id = onLineModel._id
                });
                //微信小程序同步
                saveOnLine();
                //微博同步
                WeiBoHelper weiBoHelper         = new WeiBoHelper();
                Dictionary <string, object> asy = new Dictionary <string, object>();
                string pic = onLineModel.pictiue.Replace("https://www.aikid360.com:8010/", "");
                pic = string.Format("{0}{1}", @"C:\web\akidImg\", pic);
                FileInfo file = new FileInfo(pic);
                if (file.Exists)
                {
                    asy.Add("pic", file);
                }
                string content = string.Format("{0}  详情请点击链接查看:https://www.aikid360.com/view.htm?{2}",
                                               onLineModel.remark, onLineModel.origin, onLineModel.guid);
                asy.Add("status", content);
                weiBoHelper.send(asy);
                return(new ToStream().ToStreams(mongWaitUp.obtainAll()));
            }
            else
            {
                mongOnLine.update(onLineModel);
                //重新保存数据
                saveOnLine();
                return(new ToStream().ToStreams(mongOnLine.obtainAll()));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream checkExist(ImpContext context)
        {
            MongOnLine mongOnLine = new MongOnLine(Constants.daname);
            //反序列化
            OnLineModel onLineModel = JsonConvert.DeserializeObject <OnLineModel>(context.json.Replace("\0", ""), new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(new ToStream().ToStreams(mongOnLine.isExist(onLineModel)));
        }
Exemplo n.º 6
0
 /// <summary>
 /// 录入一条数据
 /// </summary>
 /// <param name="brandModel"></param>
 /// <returns></returns>
 public int insert(OnLineModel onLineModel)
 {
     //判断是否存在重复项
     if (!isExist(onLineModel))
     {
         //增加8个小时
         onLineModel.createDate = onLineModel.createDate.AddHours(8);
         var state = _mongoCollection.Insert(onLineModel);
         return(1);
     }
     return(0);
 }
Exemplo n.º 7
0
        /// <summary>
        ///根据条件查询所需要的数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream obtainBrandNo(ImpContext context)
        {
            MongOnLine mongOnLine = new MongOnLine(Constants.daname);
            DateTime   dateTime   = DateTime.Now.AddDays(-4);
            //反序列化
            OnLineModel onLineModel = JsonConvert.DeserializeObject <OnLineModel>(context.json.Replace("\0", ""), new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });
            List <OnLineModel> list = mongOnLine.obtainAll(onLineModel);

            list = (from q in list orderby q.createDate descending select q).ToList();
            return(new ToStream().ToStreams(list));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 查询所有的在线或下线的奶粉活动信息
        /// </summary>
        /// <returns></returns>
        public List <OnLineModel> obtainAll(bool onLine = true)
        {
            List <OnLineModel> agenters = new List <OnLineModel>();
            IMongoQuery        query    = null;

            query = Query.And(Query.EQ("onLine", onLine));
            foreach (var record in _mongoCollection.FindAs <Object>(query).ToList())
            {
                Dictionary <String, Object> dictionary = record.ToBsonDocument().ToDictionary();
                OnLineModel onLineModel = new OnLineModel();
                agenters.Add(toEntity <OnLineModel>(dictionary, onLineModel));
            }
            return(agenters);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 判断数据是否重复,根据URL判断
        /// </summary>
        /// <param name="brandModel"></param>
        /// <returns>true:存在,false:不存在</returns>
        public bool isExist(OnLineModel onLineModel)
        {
            IMongoQuery query = null;// Query.EQ("name", brandModel.name);

            query = Query.And(
                Query.EQ("url", onLineModel.url)
                );
            object item = _mongoCollection.FindAs <Object>(query).FirstOrDefault();

            if (item != null)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream obtainAll(ImpContext context)
        {
            MongOnLine mongOnLine = new MongOnLine(Constants.daname);
            bool       onLine     = true;

            if (!string.IsNullOrEmpty(context.json))
            {
                //反序列化
                OnLineModel onLineModel = JsonConvert.DeserializeObject <OnLineModel>(context.json.Replace("\0", ""), new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });
                onLine = onLineModel.onLine;
            }
            return(new ToStream().ToStreams(mongOnLine.obtainAll(onLine)));
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream deleteOnLine(ImpContext context)
        {
            MongOnLine mongOnLine = new MongOnLine(Constants.daname);
            //反序列化
            OnLineModel onLineModel = JsonConvert.DeserializeObject <OnLineModel>(context.json.Replace("\0", ""), new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            mongOnLine.delete(onLineModel);
            string pic = onLineModel.pictiue.Replace("https://www.aikid360.com:8010/", "");

            pic = string.Format("{0}{1}", @"C:\web\akidImg\", pic);
            if (File.Exists(pic))
            {
                File.Delete(pic);
            }
            //重新保存数据
            saveOnLine();
            return(new ToStream().ToStreams(mongOnLine.obtainAll()));
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="agenter"></param>
        public void delete(OnLineModel onLineModel)
        {
            IMongoQuery query = Query.EQ("_id", onLineModel._id);

            _mongoCollection.Remove(query);
        }
Exemplo n.º 13
0
 /// <summary>
 /// 录入一条数据
 /// </summary>
 /// <param name="brandModel"></param>
 /// <returns></returns>
 public int update(OnLineModel onLineModel)
 {
     //先删除再添加
     delete(onLineModel);
     return(insert(onLineModel));
 }