Example #1
0
        private void handle(JToken jt, string coll, bool hasProjId = false)
        {
            string username         = jt["username"].ToString();
            string email            = jt["email"].ToString();
            string emailVerifyState = jt["emailVerifyState"].ToString();
            string vcode            = UIDHelper.generateVerifyCode();
            string projId           = hasProjId ? jt["projId"].ToString() : "";

            if (toMessage(emailVerifyState, username, email, projId, vcode, out string message, out string hasSendState))
            {
                eh.send(message, email, true);
                var findStr = new JObject {
                    { "email", email }
                }.ToString();
                var updateStr = new JObject {
                    { "$set", new JObject {
                          { "emailVerifyCode", vcode }, { "emailVerifyState", hasSendState }, { "lastUpdateTime", TimeHelper.GetTimeStamp() }
                      } }
                }.ToString();
                mh.UpdateData(daoConn.connStr, daoConn.connDB, coll, updateStr, findStr);
            }
        }
Example #2
0
        private void processProjTeam()
        {
            var match = new JObject {
                { "$match", new JObject {
                      { "emailVerifyState", EmailState.sendBeforeStateAtInvited }
                  } }
            }.ToString();
            var lookup = new JObject {
                { "$lookup", new JObject {
                      { "from", userInfoCol },
                      { "localField", "userId" },
                      { "foreignField", "userId" },
                      { "as", "us" }
                  } }
            }.ToString();
            var project = new JObject {
                { "$project",
                  MongoFieldHelper.toReturn(new string[] { "projId", "userId", "emailVerifyState", "us.username", "us.email" }) }
            }.ToString();
            var list = new List <string>();
            var sort = new JObject {
                { "$sort", new JObject {
                      { "time", 1 }
                  } }
            }.ToString();
            var limit = new JObject {
                { "$limit", 100 }
            }.ToString();

            list.Add(match);
            list.Add(lookup);
            list.Add(sort);
            list.Add(limit);
            list.Add(project);
            var queryRes = mh.Aggregate(daoConn.connStr, daoConn.connDB, projTeamInfoCol, list);

            if (queryRes.Count > 0)
            {
                foreach (var item in queryRes)
                {
                    string projId           = item["projId"].ToString();
                    string userId           = item["userId"].ToString();
                    string username         = ((JArray)item["us"])[0]["username"].ToString();
                    string email            = ((JArray)item["us"])[0]["email"].ToString();
                    string emailVerifyState = item["emailVerifyState"].ToString();
                    string vcode            = UIDHelper.generateVerifyCode();
                    if (toMessage(emailVerifyState, username, email, projId, vcode, out string message, out string hasSendState))
                    {
                        eh.send(message, email, true);
                        var findStr = new JObject {
                            { "projId", projId }, { "userId", userId }
                        }.ToString();
                        var updateStr = new JObject {
                            { "$set", new JObject {
                                  { "emailVerifyCode", vcode }, { "emailVerifyState", hasSendState }, { "lastUpdateTime", TimeHelper.GetTimeStamp() }
                              } }
                        }.ToString();
                        mh.UpdateData(daoConn.connStr, daoConn.connDB, projTeamInfoCol, updateStr, findStr);
                    }
                }
            }
        }