public Dictionary <long, UserName> NickForUsers(IEnumerable <long> uids) { var result = new Dictionary <long, UserName>(); if (uids == null) { return(result); } var ids = uids.Where(id => id > 0).Distinct().ToArray(); if (ids.Length == 0) { return(result); } var names = new Dictionary <long, string>(); if (_Uid > 0) { var user = _UserServiceFactory.GetService(_Uid); var userService = user.GetUserSeriviceState(); var myInfoInOtherAddressBook = GetMyInfoFromOrtherAddressBook(user, ids); names = GetMyNameToUser(user, ids, myInfoInOtherAddressBook); } foreach (var item in ids) { result.Add(item, new UserName(names.ContainsKey(item) ? names[item] : String.Empty, NameKind.Name)); } return(result); }
public object Delete([FromQuery] long id) { var user = _UserServiceFactory.GetService(1); var service = _DailyFoodServiceFactory.GetService(id, user); service.Delete(); return(this.JsonApiResult(ErrorCode.None)); }
public void NotifyFriendsOnecAWeek() { var uid = _FootPrintService.Uid; var user = _UserServiceFactory.GetService(uid); var timeBefore7Days = DateTime.Now.AddDays(-7); var isPublishedIn7Days = _FootPrintRepository.Entities.Count(p => p.uid == uid && p.state == FootPrintState.Pass && p.orderUpdated > timeBefore7Days) > 1; var name = user.Name; if (!isPublishedIn7Days) { var inTgAnNotInFc = _AddressBookMobileRepository.GetTgUidAndNotFootUidOfInBook(uid).Distinct().ToArray(); var mobiles = _UserManager.GetEnableUser().Where(p => inTgAnNotInFc.Contains(p.uid)).Select(p => p.mobile).ToArray().Where(p => !string.IsNullOrWhiteSpace(p)).ToArray(); if (mobiles.Any()) { Dictionary <string, string> values = new Dictionary <string, string>(); values.Add("name", name); _PushManager.SendSms(130, mobiles, values, "足聊"); } } }
public object Detail(long id) { var user = _UserServiceFactory.GetService(1); int count = 0; var diary = _KitFitDiaryManager.GetDiaryList(user.Uid, 0, 1, out count).FirstOrDefault(); var foods = _DailyFoodManager.GetFoodsByKfIds(new long[diary.Kid]); var result = new Models.KeepFitDiaryListItem(diary, foods) { Num = 0 }; return(this.JsonApiResult(ErrorCode.None, result)); }
public object List(int?start, int?limit) { start = start ?? 0; start = start < 0 ? 0 : start; limit = limit ?? 10; limit = limit < 1 ? 10 : limit; var user = _UserServiceFactory.GetService(1); int count = 0; var diaries = _KitFitDiaryManager.GetDiaryList(user.Uid, start.Value, limit.Value, out count); var kids = diaries.Select(p => p.Kid).ToArray(); var foods = _DailyFoodManager.GetFoodsByKfIds(kids); var result = new List <KeepFitDiaryListItem>(); for (int i = 0; i < diaries.Length; i++) { var p = diaries[i]; var diaryFoods = foods.Where(f => f.KFId == p.Kid); var diary = new Models.KeepFitDiaryListItem(p, diaryFoods); diary.Num = count - start.Value - i; result.Add(diary); } return(this.JsonApiResult(ErrorCode.None, result.ToArray())); }
private void AddUser(long uid) { var now = DateTime.Now; var verifiedlockDate = new DateTime(1900, 1, 1); var uids = new long[] { uid }; var user = _UserManager.GetTgUserInfos(uids).FirstOrDefault(); if (user != null) { ExceptionHelper.ThrowIfNullOrWhiteSpace(nameof(user), "查询不到用户资料"); } ExceptionHelper.ThrowIfNullOrWhiteSpace(nameof(user.mobile), "用户手机号为空"); string[] businesAreaNos = null; string[] products = null; string[] brands = null; var businessAreasDic = _UserManager.GetTgUserBusinessAreas(uids); if (businessAreasDic.ContainsKey(uid)) { businesAreaNos = businessAreasDic[uid]; } var tgProducts = _UserManager.GetTgUserProducts(uid); if (tgProducts != null && tgProducts.Count() > 0) { products = tgProducts.Where(p => !string.IsNullOrWhiteSpace(p.Name) && p.Name.Length < 50).Select(p => p.Name).Distinct().ToArray(); brands = tgProducts.SelectMany(p => p.Brands).Where(p => !string.IsNullOrWhiteSpace(p) && p.Length < 50).Distinct().ToArray(); } var password = GetRandomPsw(); var areaNo = _StaticResourceManager.GetAreaByAreaName(user.area_province, user.area_city, user.area_county); using (var scope = new TransactionScope()) { if (!CheckExistFootUser(uid)) { _FootChatUserRepository.Add(new FootUser() { mobile = user.mobile, uid = uid, password = password, areaNo = areaNo, isInner = false, isLocked = false, loginCount = 0, lastLogin = now, created = now, verifyImage = String.Empty, verifyStatus = VerifyStatus.None, cover = "", name = user.name, company = user.company, sex = user.sex == "男" ? UserSex.Man : user.sex == "女" ? UserSex.Woman : new UserSex?(), job = user.job, }); _FootChatUserRepository.SaveChanges(); var userService = _UserServiceFactory.GetService(uid); userService.UpdateBusinessAreaNos(businesAreaNos); userService.UpdateProducts(products); userService.UpdateBrands(brands); _ImportUserRecordRepository.Add(new ImportUserRecord() { importTime = now, uid = uid }); _ImportUserRecordRepository.SaveChanges(); //推送到图数据库 _PushManager.AddUser(uid, user.mobile, true); } scope.Complete(); } }