本文整理汇总了C#中UserRepository.GetUserUuidByOpenid方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.GetUserUuidByOpenid方法的具体用法?C# UserRepository.GetUserUuidByOpenid怎么用?C# UserRepository.GetUserUuidByOpenid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.GetUserUuidByOpenid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostInitialize
public async Task<HttpResponseMessage> PostInitialize([FromBody]DualParameter postParameter)
{
string openid = postParameter.openID;
Guid uuid = postParameter.uuid;
if (string.IsNullOrEmpty(openid) && uuid == Guid.Empty)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using (UserRepository userRepository = new UserRepository())
{
userinfo = await userRepository.GetUserInfoByUuidAsync(uuid);
if (userinfo == null)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
VisitBetweenUser newVisitor = new VisitBetweenUser() { UserGuest_uuid = userUuid, UserHost_uuid = uuid, VisitTime = DateTime.Now };
await userRepository.AddVisitBetweenUser(newVisitor);
userinfo.NumOfContacts = await userRepository.GetUserContactNumber(uuid);
userinfo.NumOfVisitor = await userRepository.GetUserVisitorNumber(uuid);
userinfo.NumOfFavorite = await userRepository.GetuserFavoriteNumber(uuid);
userinfo.IsContact = await userRepository.IsUserContact(userUuid, uuid);
userinfo.IsFavorite = (await userRepository.IsUserFavorite(userUuid, uuid)).ToString();
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, userinfo, HttpStatusCode.OK, customStatus.Success);
}
}
示例2: PostChatCenterInitialize
public async Task<HttpResponseMessage> PostChatCenterInitialize([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
var uuid = await userRepository.GetUserUuidByOpenid(openid);
var sessions = await MessageRedisOp.GetSessionsTimeStampByUuid(uuid.ToString().ToUpper(), Order.Descending, 0, -1);
List<Tuple<double, UserInfo, string>> ChatCenterList = new List<Tuple<double, UserInfo, string>>();
foreach(var s in sessions)
{
double unreadNum = await MessageRedisOp.GetUnreadScore(uuid.ToString().ToUpper(), s.Key);
List<string> uuidPair = await MessageRedisOp.GetUUidsBySessionId(s.Key);
string userUuid = uuidPair[0] == uuid.ToString().ToUpper() ? uuidPair[1] : uuidPair[0];
Guid userGUID;
if(!Guid.TryParse(userUuid, out userGUID) || userGUID.Equals(Guid.Empty))
continue;
UserInfo toUser = await userRepository.GetUserInfoByUuidAsync(userGUID);
var latestMessage = await WeChatReceiveHelper.GetFirstMessagesFromRedis(uuid.ToString().ToUpper(), userUuid.ToUpper());
ChatCenterList.Add(Tuple.Create(unreadNum, toUser, latestMessage));
}
return WebApiHelper.HttpRMtoJson(ChatCenterList, HttpStatusCode.OK, customStatus.Success);
}
}
示例3: PostChatInitialize
public async Task<HttpResponseMessage> PostChatInitialize([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
int pageIndex = postParameter.pageIndex;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
var user = await userRepository.GetUserUuidByOpenid(openid);
if(user == null)
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound);
}
var noticeList = await WeChatNoticeReceiveHelper.GetNotice(user, pageIndex);
if(noticeList != null)
foreach(var n in noticeList)
{
if(n != null)
n.RelationObj = await userRepository.GetUserInfoByUuidAsync(n.RelationID_uuid);
}
return WebApiHelper.HttpRMtoJson(Tuple.Create(user, noticeList), HttpStatusCode.OK, customStatus.Success);
}
}
示例4: PostChatCenterInitialize
public async Task<HttpResponseMessage> PostChatCenterInitialize([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
var uuid = await userRepository.GetUserUuidByOpenid(openid);
double unreadNum = await NoticeRedisOp.GetUnreadScore(uuid);
var latestNotice = await WeChatNoticeReceiveHelper.GetFirstNoticeFromRedis(uuid);
if(latestNotice != null)
latestNotice.RelationObj = await userRepository.GetUserInfoByUuidAsync(latestNotice.RelationID_uuid);
return WebApiHelper.HttpRMtoJson(Tuple.Create(unreadNum, latestNotice), HttpStatusCode.OK, customStatus.Success);
}
}
示例5: PostInitializeMyContact
public async Task<HttpResponseMessage> PostInitializeMyContact([FromBody]LoginParameter postParameter)
{
string openid = postParameter.openID;
int pageIndex = postParameter.pageIndex;
int pageSize = postParameter.pageSize;
if (string.IsNullOrEmpty(openid) || pageSize == 0)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using (UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if(userUuid == Guid.Empty)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
var uclist = await userRepository.GetUserContact(userUuid, pageIndex, pageSize);
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, uclist, HttpStatusCode.OK, customStatus.Success);
}
}
示例6: PostInitializeMyRecords
public async Task<HttpResponseMessage> PostInitializeMyRecords([FromBody]LoginParameter postParameter)
{
string openid = postParameter.openID;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if(userUuid == Guid.Empty)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
else
{
List<UserSkill> userSkillList = await userRepository.GetUserRecords(new UserSkill() { AccountEmail_uuid = userUuid });
List<UserCourse> userCourseList = await userRepository.GetUserRecords(new UserCourse() { AccountEmail_uuid = userUuid });
List<UserEducation> userEducationList = await userRepository.GetUserRecords(new UserEducation() { AccountEmail_uuid = userUuid });
List<UserExperience> userExperienceList = await userRepository.GetUserRecords(new UserExperience() { AccountEmail_uuid = userUuid });
int userArticleNumber = await userRepository.GetUserRecordsNumber(new UserArticle() { AccountEmail_uuid = userUuid });
int visitorsBeenToNumber = await userRepository.GetVisitorBeenToNumber(userUuid);
List<UserInfo> visitorsBeenTo = await userRepository.GetVisitorBeenTo(userUuid, 6);
Dictionary<string,object> tempResult = new Dictionary<string, object>();
tempResult.Add("userSkillList", userSkillList);
tempResult.Add("userCourseList", userCourseList);
tempResult.Add("userEducationList", userEducationList);
tempResult.Add("userExperienceList", userExperienceList);
tempResult.Add("userArticleNumber", userArticleNumber);
tempResult.Add("visitorsBeenToNumber", visitorsBeenToNumber);
tempResult.Add("visitorsBeenToTopSix", visitorsBeenTo);
return WebApiHelper.HttpRMtoJson(tempResult, HttpStatusCode.OK, customStatus.Success);
}
}
}
示例7: IsThereUnredMessage
public async Task<HttpResponseMessage> IsThereUnredMessage([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson("没有传openid", HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if(userUuid.Equals(Guid.Empty))
{
return WebApiHelper.HttpRMtoJson("没有取到uuid,openid=" + openid, HttpStatusCode.OK, customStatus.Fail);
}
else
{
bool flag = await MessageRedisOp.IsGetUnredScore(userUuid.ToString().ToUpper());
return WebApiHelper.HttpRMtoJson(flag, HttpStatusCode.OK, customStatus.Success);
}
}
}
示例8: PostSendChat
public async Task<HttpResponseMessage> PostSendChat([FromBody]DualParameter postParameter)
{
string openid = postParameter.openID;
Guid uuid = postParameter.uuid;
string textMsg = postParameter.textMsg;
if(string.IsNullOrEmpty(openid) || uuid == Guid.Empty || string.IsNullOrEmpty(textMsg))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
var result = await WeChatSendMQHelper.SendMessage(userUuid.ToString().ToUpper(), uuid.ToString().ToUpper(), textMsg);
if(result)
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success);
}
else
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Fail);
}
}
}
示例9: WeixinCallback
protected virtual async Task<ActionResult> WeixinCallback(string code, string state, string redirectUrl)
{
try
{
if (code == null)
return Content("code是空!");
//LogHelper.LogInfoAsync(typeof(WeChatCallBackController), @"1\code=" + code);
var config = BK.Configuration.BK_ConfigurationManager.GetConfig<WeixinConfig>();
bool Isbinded = true;
var openid = await WXAuthHelper.GetOpenIdWXCallBackAsync(config.WeixinAppId, config.WeixinAppSecret, code, async delegate (OAuthAccessTokenResult result)
{
//是否需要绑定账号
using (UserRepository userRepository = new UserRepository())
{
//如果OPenid绑定了,就不需要再向微信请求userinfo的信息了.
//如果没有绑定,则需要刷新accesstoken,然后请求userinfo;并将userinfo存入redis。
Isbinded = await userRepository.IsUserOpenidExist(result.openid);
}
if (!Isbinded)
//如果没有绑定就要存储token信息
await WeChatCallBackControllerHelper.SaveOAuthUserTokenAsync(result);
return !Isbinded;//如果绑定了就不需要获取userinfo信息了
}, async delegate (OAuthUserInfo user)
{
//如果需要绑定用户信息则,此处存储用户信息
return await WeChatCallBackControllerHelper.SaveOAuthUserInfoToRedis(user);
});
//再次判断是否需要绑定
//存入cookie供前端代码调用
Response.Cookies["openid"].Value = openid;
Response.Cookies["openid"].Expires = DateTime.Now.AddYears(1);
//如果是tester则不管怎么样都要去注册。
//可以通过wechat.51science.cn/weixinapi/addtester/?openid=xxx来添加
//wechat.51science.cn/weixinapi/rmtester/?openid=xxx删除
bool isToRegister = !Isbinded || await WXAuthHelper.IsTester(openid);
if (!isToRegister)
{
//记录用户行为
await UserLoginBehaviorOp.AddLoginCountAsync(openid);
await UserLoginBehaviorOp.AddUpdateLastLoginTimeAsync(openid);
//跳转到个人主页
using (UserRepository userRepository = new UserRepository())
{
//存入uuid
Response.Cookies["uuid"].Value = (await userRepository.GetUserUuidByOpenid(openid)).ToString();
Response.Cookies["uuid"].Expires = DateTime.Now.AddYears(1);
}
return Redirect(redirectUrl);
}
else
{
// login页面
return Redirect(LOGIN_PAGE_URL);
}
}
catch (Exception ex)
{
LogHelper.LogErrorAsync(typeof(MVCNeedWeixinCallBackBaseController), ex);
return Content(ex.ToString());
}
}
示例10: PostInitializeUserPatent
public async Task<HttpResponseMessage> PostInitializeUserPatent([FromBody]UserRecordsParameter postParameter)
{
string openid = postParameter.openID;
long id = postParameter.id;
int pageIndex = postParameter.pageIndex;
int pageSize = postParameter.pageSize;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
dynamic resultList;
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if(id != 0)
{
resultList = null;
//resultList = await userRepository.GetUserRecordsById<UserPatent>(id);
}
else if(pageIndex != 0 && pageSize != 0)
{
resultList = await userRepository.GetUserRecords(new UserPatent() { AccountEmail_uuid = userUuid }, pageIndex, pageSize);
}
else
{
resultList = await userRepository.GetUserRecords(new UserPatent() { AccountEmail_uuid = userUuid });
}
return WebApiHelper.HttpRMtoJson(resultList, HttpStatusCode.OK, customStatus.Success);
}
}
示例11: PostDeleteUserRecordsById
public async Task<HttpResponseMessage> PostDeleteUserRecordsById([FromBody]UserRecordsParameter postParameter)
{
string openid = postParameter.openID;
if(string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using(UserRepository userRepository = new UserRepository())
{
dynamic input = null;
Guid uuid = await userRepository.GetUserUuidByOpenid(openid);
if(uuid == Guid.Empty)
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound);
foreach(System.Reflection.PropertyInfo pi in postParameter.GetType().GetProperties())
{
if(pi.PropertyType.BaseType.Equals(typeof(DBModelBase)) && pi.GetValue(postParameter) != null)
{
input = Convert.ChangeType(pi.GetValue(postParameter), pi.PropertyType);
break;
}
}
if(input == null)
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
if(uuid != input.AccountEmail_uuid)
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Forbidden);
if(await userRepository.DeleteUserRecordsById(input))
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Success);
else
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.Fail);
}
}
示例12: PostGetInterests
public async Task<HttpResponseMessage> PostGetInterests([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
if (string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using (UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if (userUuid == Guid.Empty)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
else
{
UserInfo userinfo = await userRepository.GetUserInfoByOpenid(openid);
//研究兴趣
string researchField = userinfo.Interests;
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, researchField, HttpStatusCode.OK, customStatus.Success);
}
}
}
示例13: PostUpdateResearchField
public async Task<HttpResponseMessage> PostUpdateResearchField([FromBody]DualParameter postParameter)
{
string openid = postParameter.openID;
if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(postParameter.textMsg))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using (UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if (userUuid == Guid.Empty)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
else
{
UserInfo userinfo = await userRepository.GetUserInfoByOpenid(openid);
//更新研究兴趣
userinfo.Interests = postParameter.textMsg;
bool flag = await userRepository.SaveUserInfo(userinfo);
if(flag)
return WebApiHelper.HttpRMtoJson(flag, HttpStatusCode.OK, customStatus.Success);
else
return WebApiHelper.HttpRMtoJson("没有保存成功", HttpStatusCode.OK, customStatus.Fail);
}
}
}
示例14: PostIsThereUnreadNotice
public async Task<HttpResponseMessage> PostIsThereUnreadNotice([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
if (string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using (UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if (userUuid.Equals(Guid.Empty))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.NotFound);
}
else
{
bool flag = await NoticeRedisOp.GetUnreadScore(userUuid) > 0;
return WebApiHelper.HttpRMtoJson(flag, HttpStatusCode.OK, customStatus.Success);
}
}
}
示例15: PostInitializeProfessorRecords
public async Task<HttpResponseMessage> PostInitializeProfessorRecords([FromBody]BaseParameter postParameter)
{
string openid = postParameter.openID;
if (string.IsNullOrEmpty(openid))
{
return WebApiHelper.HttpRMtoJson(null, HttpStatusCode.OK, customStatus.InvalidArguments);
}
using (UserRepository userRepository = new UserRepository())
{
var userUuid = await userRepository.GetUserUuidByOpenid(openid);
if (userUuid == Guid.Empty)
{
return WebApiHelper.HttpRMtoJson(postParameter.jsonpCallback, null, HttpStatusCode.OK, customStatus.NotFound);
}
else
{
Dictionary<string, object> tempResult = new Dictionary<string, object>();
UserInfo userinfo = await userRepository.GetUserInfoByOpenid(openid);
//研究兴趣
string researchField = userinfo.Interests;
tempResult.Add("yjly", researchField);
//学术地位
List<UserAcademic> userAcademicList = await userRepository.GetUserRecords(new UserAcademic { AccountEmail_uuid = userUuid });
List<string> acadmeicList = RepositoryHelper.ConvertUserAcademicToString(userAcademicList);
tempResult.Add("xsdw", Tuple.Create("UserAcademic", acadmeicList));
//项目资助
List<UserAwards> userAwardList = await userRepository.GetUserRecords(new UserAwards() { AccountEmail_uuid = userUuid });
tempResult.Add("zzxm", Tuple.Create("UserAwards", userAwardList));
//教育经历
List<UserEducation> userEducationList = await userRepository.GetUserRecords(new UserEducation() { AccountEmail_uuid = userUuid });
tempResult.Add("jyjl", Tuple.Create("UserEducation", userEducationList));
//工作经历
List<UserExperience> userExperienceList = await userRepository.GetUserRecords(new UserExperience() { AccountEmail_uuid = userUuid });
tempResult.Add("gzjl", Tuple.Create("UserExperience", userExperienceList));
//论文数
int userArticleNumber = await userRepository.GetUserRecordsNumber(new UserArticle() { AccountEmail_uuid = userUuid });
tempResult.Add("lws", Tuple.Create("UserArticle", userArticleNumber));
//专利数
int userPatendNumber = await userRepository.GetUserRecordsNumber(new UserPatent() { AccountEmail_uuid = userUuid });
tempResult.Add("zls", Tuple.Create("UserPatent", userPatendNumber));
//访问过我的人还访问过谁
int visitorsBeenToNumber = await userRepository.GetVisitorBeenToNumber(userUuid);
List<UserInfo> visitorsBeenTo = await userRepository.GetVisitorBeenTo(userUuid, 6);
tempResult.Add("visitorsBeenToNumber", visitorsBeenToNumber);
tempResult.Add("visitorsBeenToTopSix", visitorsBeenTo);
return WebApiHelper.HttpRMtoJson(tempResult, HttpStatusCode.OK, customStatus.Success);
}
}
}