Пример #1
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()));
            }
        }
Пример #2
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream deleteWaitUp(ImpContext context)
        {
            MongWaitUp mongWaitUp = new MongWaitUp(Constants.daname);
            //反序列化
            WaitUpModel waitUpModel = JsonConvert.DeserializeObject <WaitUpModel>(context.json.Replace("\0", ""), new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

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

            pic = string.Format("{0}{1}", @"C:\web\akidImg\", pic);
            if (File.Exists(pic))
            {
                File.Delete(pic);
            }
            return(new ToStream().ToStreams(mongWaitUp.obtainAll()));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Stream obtainAll(ImpContext context)
        {
            MongWaitUp mongWaitUp = new MongWaitUp(Constants.daname);

            return(new ToStream().ToStreams(mongWaitUp.obtainAll()));
        }