Ejemplo n.º 1
0
        public List <Dictionary <String, Object> > GetDiscussList()
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context = new LOJEntities3();
            var discuss = from e in context.Discusses select e;

            foreach (var t in discuss)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                hash.Add("commentNum", getReplyListNum((int)t.discussid));
                hash.Add("tid", t.discussid);
                hash.Add("msg", t.comment);
                hash.Add("time", t.discuestime);
                hash.Add("title", t.title);
                hash.Add("type", t.type);
                //  hash.Add("commentNum", getReplyListNum((int)t.discussid));
                list.Add(hash);
            }
            return(list);
        }
Ejemplo n.º 2
0
        public List <Dictionary <String, Object> > GetProblemList()
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context = new LOJEntities3();
            var problem = from e in context.QuestionSets select e;

            foreach (var t in problem)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                hash.Add("category", t.category);
                hash.Add("difficulty", t.difficulty);
                hash.Add("problemID", t.id);
                hash.Add("problemInfo", t.queInfo);
                hash.Add("source", t.source);
                hash.Add("time", t.time);
                hash.Add("title", t.title);
                list.Add(hash);
            }
            return(list);
        }
Ejemplo n.º 3
0
        public List <Dictionary <String, Object> > getMyTwitter(int uid)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context = new LOJEntities3();
            var marks   = from e in context.MarkProblems where e.uid == uid select e;

            foreach (var t in marks)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User        user     = UserInfoController.getUser((int)t.uid);
                QuestionSet question = ProblemController.GetProblemByQueId((int)t.queid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("markid", t.markid);
                hash.Add("phone", user.phone);
                hash.Add("queid", question.id);
                hash.Add("avator", user.avator);
                hash.Add("queTitle", question.title);
                hash.Add("queSource", question.source);
                hash.Add("queCategory", question.category);
                hash.Add("queDifficulty", question.difficulty);
                list.Add(hash);
            }
            return(list);
        }
Ejemplo n.º 4
0
        public List <Dictionary <String, Object> > getFriendTwitter(int uid)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var         context = new LOJEntities3();
            List <User> friends = UserInfoController.getFriends(uid);

            for (int i = 0; i < friends.Count; i++)
            {
                int id      = friends[i].id;
                var twitter = from e in context.Twitters where e.uid == id select e;
                foreach (var t in twitter)
                {
                    Dictionary <String, Object> hash = new Dictionary <string, object>();
                    User user = UserInfoController.getUser(id);
                    hash.Add("name", user.name);
                    hash.Add("phone", user.phone);
                    hash.Add("avator", user.avator);
                    hash.Add("uid", id);
                    hash.Add("tid", t.tid);
                    hash.Add("msg", t.msg);
                    hash.Add("time", t.date);
                    list.Add(hash);
                }
            }
            return(list);
        }
Ejemplo n.º 5
0
 public Dictionary <string, object> GetUpdateSendList(int ChatSessionId, String msg, int uid)
 {
     using (var dbContext = new LOJEntities3())
     {
         ChatSession chat    = new ChatSession();
         var         session = from e in dbContext.ChatSessions where e.sessionid == ChatSessionId select e;
         foreach (var u in session)
         {
             chat = u;
             break;
         }
         //List<Dictionary<String, Object>> list = new List<Dictionary<string, object>>();
         JArray array = new JArray();
         if (chat.content != "[]")
         {
             array = JArray.Parse(chat.content);
             // list = JsonConvert.DeserializeObject<List<Dictionary<String, Object>>>(chat.content);
         }
         Dictionary <string, object> dict = new Dictionary <string, object>();
         dict.Add("message", msg);
         dict.Add("uid", uid);
         dict.Add("name", UserInfoController.getUser(uid).name);
         dict.Add("avator", UserInfoController.getUser(uid).avator);
         dict.Add("date", DateTime.Now.ToString());
         String jsonStr = JsonConvert.SerializeObject(dict);
         array.Add((JObject)JsonConvert.DeserializeObject(jsonStr));
         chat.content = array.ToString();
         dbContext.Entry(chat).State = System.Data.Entity.EntityState.Modified;
         try
         {
             if (dbContext.SaveChanges() > 0)
             {
                 return(dict);
             }
             else
             {
                 return(null);
             }
         }
         catch (Exception e)
         {
             return(null);
         }
     }
 }
Ejemplo n.º 6
0
        public List <Dictionary <String, Object> > GetChatSessionList(int uid)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var    context = new LOJEntities3();
            User   u       = UserInfoController.getUser(uid);
            String name    = u.name;
            var    session = from e in context.ChatSessions where e.username1 == name || e.username2 == name select e;

            foreach (var s in session)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                hash.Add("sessionID", s.sessionid);
                hash.Add("username1", s.username1);
                hash.Add("username2", s.username2);
                hash.Add("content", s.content);
                list.Add(hash);
            }
            return(list);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 返回相关解答的评论
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List <Dictionary <String, Object> > GetDiscussReplyList(int id)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context          = new LOJEntities3();
            var solutionComments = from e in context.SolutionComments where e.solutionid == id select e;

            foreach (var t in solutionComments)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                hash.Add("commenttime", t.date);
                hash.Add("commentid", t.commentid);
                hash.Add("solutionid", t.solutionid);
                hash.Add("comment", t.comment);
                list.Add(hash);
            }
            return(list);
        }
Ejemplo n.º 8
0
        public List <Dictionary <String, Object> > GetRecordListByQid(int qid)
        {
            List <Dictionary <String, Object> > list = new List <Dictionary <string, object> >();
            var context = new LOJEntities3();
            var records = from e in context.Records where e.questionid == qid select e;

            foreach (var t in records)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                hash.Add("time", t.submittime);
                hash.Add("qid", t.questionid);
                hash.Add("recordid", t.recordid);
                hash.Add("qname", ProblemController.GetProblemByQueId((int)t.questionid).title);
                hash.Add("status", t.status);
                //  hash.Add("commentNum", getReplyListNum((int)t.discussid));
                list.Add(hash);
            }
            return(list);
        }
Ejemplo n.º 9
0
        public Dictionary <String, Object> GetDiscuss(int id)
        {
            var context = new LOJEntities3();
            var discuss = from e in context.Discusses where e.discussid == id select e;

            foreach (var t in discuss)
            {
                Dictionary <String, Object> hash = new Dictionary <string, object>();
                User user = UserInfoController.getUser((int)t.userid);
                hash.Add("uid", user.id);
                hash.Add("name", user.name);
                hash.Add("phone", user.phone);
                hash.Add("avator", user.avator);
                // hash.Add("replynum", t.DiscussComments.Count());
                hash.Add("tid", t.discussid);
                hash.Add("msg", t.comment);
                hash.Add("time", t.discuestime);
                hash.Add("title", t.title);
                hash.Add("type", t.type);
                hash.Add("commentNum", getReplyListNum((int)t.discussid));
                return(hash);
            }
            return(null);
        }