public void DecrementUnreadMessages(string appName, ObjectId userId, int decrementBy) { var dataBase = _serverWrapper.ServerConnection.GetDatabase(appName); var collection = dataBase.GetCollection<DatingBookUserInfo>(DATING_BOOK_USERS_COLLECTION_NAME); var selectQuery = Query.EQ("_id", userId); collection.Update(selectQuery, Update.Inc("new_messages", -decrementBy)); }
/// <summary> /// 查询角色下面所有用户 /// </summary> /// <param name="UserRoleId"></param> /// <returns>返回所有用户</returns> public BsonArray UserInRole(ObjectId UserRoleId) { BsonDocument Query = new BsonDocument { { "UserRole", UserRoleId} }; return GetUsersToArray(Query); }
public DatingBookUserInfo GetDatingBookUserInfo(string appName, ObjectId userId) { var datingBookUserInfo = _userDataProvider.GetDatingBookUserInfoByFacebookId(appName, userId); if (datingBookUserInfo == null) return null; if (!CheckIfUserPictureExist(appName, datingBookUserInfo)) DownloadUserPicture(appName, datingBookUserInfo); datingBookUserInfo.LastVisit = DateTime.Now; ObjectId visitId = ObjectId.Empty; var whiteList = _userDataProvider.GetUsersWhitelist(appName); if (!whiteList.Exists((usr) => usr == datingBookUserInfo.FacebookId)) { BsonDocument visit = new BsonDocument(); visit.Add("dating_book_id", datingBookUserInfo.ObjectId); visit.Add("entered_at", datingBookUserInfo.LastVisit); visitId = _userDataProvider.InsertVisit(appName, visit); } datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo, visitId); var userEventInfo = new UserEventInfo { UserId = datingBookUserInfo.ObjectId, EventType = 1, DateCreated = DateTime.Now }; _userDataProvider.InsertUserEvent(appName, userEventInfo); return datingBookUserInfo; }
public void ObjectIdWithDifferentValuesAreNotEqual() { var a = new ObjectId("4b883faad657000000002665"); var b = new ObjectId("4b883faad657000000002666"); Assert.NotEqual(a, b); Assert.True(a != b); }
public dynamic GetSessionDetails(string appName, ObjectId from, string to) { MessageSessionInfo session = _userMessagesDataProvider.GetSession(appName, CalculateSessionId(from.ToString(), to)); ObjectId fromWho = ObjectId.Empty; if (from == session.User1) { fromWho = session.User1; } else if (from == session.User2) { fromWho = session.User2; } if (fromWho == ObjectId.Empty) { return new { error = "1" }; } var toUser = _userDataProvider.GetDatingBookUserInfo(appName, session.User1 == from ? session.User2 : session.User1, "facebook_user_id", "user_id", "picture", "location", "fname", "real_birthday"); return new { from = from.ToString(), to = toUser.Id.ToString(), to_picture = GenerateUserProfilePictureUrl(appName, toUser, 45, 55), to_location = toUser.Location, to_name = toUser.FirstName, to_age = (int)(Math.Round((DateTime.Now.Subtract(toUser.RealBirthday).TotalDays) / 365)), session_updated = session.LastUpdated.ToString("dd/MM/yyyy dddd hh:mm") }; }
public void TestFromRqlIds() { var rqlIds = new RqlId[] { new RqlId("$0"), new RqlId("$0"), new RqlId("$1F2mgA9gNyZtkTIf6"), new RqlId("$1Ad4Xro7A6yeAl77J") // This one caused problems }; var objIds = new ObjectId[] { ObjectId.Empty, new ObjectId(0, 0, 0, 0), new ObjectId("8000000000006400c800ffff"), new ObjectId("53d5244dec98e866c0d800f4") }; for (int i = 0; i < rqlIds.Length; i++) { var objId = rqlIds[i].ToObjectId(); var rqlId = objId.ToRqlId(); var objId2 = rqlId.ToObjectId(); Assert.AreEqual(rqlIds[i], rqlId, "ObjectId value {0}", i); Assert.AreEqual(objIds[i], objId2, "RqlId value {0}", i); } }
public ActionResult Delete(ObjectId id) { var collection = Database.GetCollection<ProfileProperty>("ProfileProperty"); collection.Remove(Query.EQ("_id", id)); return RedirectToAction("Index"); }
public void GivenAMongoMessageDataRepository_WhenPuttingMessageDataWithExpiration() { var db = new MongoClient().GetDatabase("messagedatastoretests"); _bucket = new GridFSBucket(db); _now = DateTime.UtcNow; SystemDateTime.Set(_now); var fixture = new Fixture(); var resolver = new Mock<IMongoMessageUriResolver>(); resolver.Setup(x => x.Resolve(It.IsAny<ObjectId>())) .Callback((ObjectId id) => _id = id); var nameCreator = new Mock<IFileNameCreator>(); nameCreator.Setup(x => x.CreateFileName()) .Returns(fixture.Create<string>()); var sut = new MongoMessageDataRepository(resolver.Object, _bucket, nameCreator.Object); _expectedTtl = TimeSpan.FromHours(1); using (var stream = new MemoryStream(fixture.Create<byte[]>())) { sut.Put(stream, _expectedTtl).GetAwaiter().GetResult(); } }
public DatingBookUserInfo UpsertDatingBookUserInfo(string appName, ObjectId userId, DatingBookUserInfo datingBookUserInfo) { datingBookUserInfo = _userDataProvider.UpsertDatingbookUserInfo(appName, userId, datingBookUserInfo); if (datingBookUserInfo.IsNew) { if (!CheckIfUserPictureExist(appName, datingBookUserInfo)) DownloadUserPicture(appName, datingBookUserInfo); var userEventInfo = new UserEventInfo { UserId = datingBookUserInfo.ObjectId, EventType = 0, DateCreated = DateTime.Now }; _userDataProvider.InsertUserEvent(appName, userEventInfo); datingBookUserInfo.IsNew = false; } datingBookUserInfo.LastVisit = DateTime.Now; datingBookUserInfo = _userDataProvider.UpdateDatingBookLastVisit(appName, datingBookUserInfo); return datingBookUserInfo; }
public FetchHeadRecord(ObjectId newValue, bool notForMerge, string sourceName, URIish sourceUri) { NewValue = newValue; NotForMerge = notForMerge; SourceName = sourceName; SourceURI = sourceUri; }
public ReadRangeRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, Option<RangeType> range) { this.ObjectIdentifier = objectIdentifier; this.PropertyIdentifier = propertyIdentifier; this.PropertyArrayIndex = propertyArrayIndex; this.Range = range; }
static void Main(string[] args) { var client = new MongoClient(); var db = client.GetDatabase("CustomerDb"); var CustColl = db.GetCollection<Customer>("Customer"); // query customer var customerID = new ObjectId("xxx"); var customers = CustColl .Find(c => c.Id == customerID) .SortBy(c => c.fullName) .Limit(3) .ToListAsync() .Result; foreach (var customer in customers) { Console.WriteLine(customer.fullName); } //Update Customer var cust = customers.First(); cust.fullName = cust.fullName.ToUpper(); }
public MockCommit(ObjectId id = null) { idEx = id ?? new ObjectId(Guid.NewGuid().ToString().Replace("-", "")+ "00000000"); MessageEx = ""; ParentsEx = new List<Commit> { null }; CommitterEx = new Signature("Joe", "*****@*****.**", DateTimeOffset.Now); }
public IAmRequest(ObjectId iAmDeviceIdentifier, uint maxAPDULengthAccepted, Segmentation segmentationSupported, uint vendorID) { this.IAmDeviceIdentifier = iAmDeviceIdentifier; this.MaxAPDULengthAccepted = maxAPDULengthAccepted; this.SegmentationSupported = segmentationSupported; this.VendorID = vendorID; }
// // GET: /Project/Details/5 public ActionResult Details(ObjectId id) { var project = session.GetById<Project>(id); ViewBag.ProjectConfigurations = session.GetAll<Configuration>().Where(c => c.ProjectId == project.Id).ToArray(); return View(project); }
public Comment(String contentID) { try { Comment obj = new Comment(); MongoDatabase md = MongoDBHelper.MongoDB; MongoCollection<Comment> mc = md.GetCollection<Comment>(Comment.GetCollectionName()); obj = mc.FindOne(Query.EQ("_id", ObjectId.Parse(contentID))); this._id = obj._id; this.MemberID = obj.MemberID; this.Creater = new Moooyo.BiZ.Creater.Creater(obj.MemberID); this.CommentToID = obj.CommentToID; this.Content = obj.Content; this.CreatedTime = obj.CreatedTime; this.UpdateTime = obj.UpdateTime; this.CommentType = obj.CommentType; this.DeleteFlag = obj.DeleteFlag; } catch (System.Exception err) { throw new CBB.ExceptionHelper.OperationException( CBB.ExceptionHelper.ErrType.SystemErr, CBB.ExceptionHelper.ErrNo.DBOperationError, err); } }
public void TestFromObjectIds() { var objIds = new ObjectId[] { ObjectId.Empty, new ObjectId(0, 0, 0, 0), new ObjectId(0, 100, 200, 65535), new ObjectId(int.MaxValue, 0xffffff, short.MaxValue, 0xffffff), }; var rqlIds = new RqlId[] { new RqlId("$0"), new RqlId("$0"), new RqlId("$1F2mgA9gNyZtkTId2"), new RqlId("$1F2si9jk4p8AzQuuP") }; for (int i = 0; i < objIds.Length; i++) { var rqlId = objIds[i].ToRqlId(); var objId = rqlId.ToObjectId(); var rqlId2 = objId.ToRqlId(); Assert.AreEqual(objIds[i], objId, "ObjectId value {0}", i); Assert.AreEqual(rqlIds[i], rqlId2, "RqlId value {0}", i); } }
public static void PublishChatMessages(this BahamutPubSubService service, ObjectId senderId, ShareChat chat, ChatMessage msg) { foreach (var user in chat.UserIds) { if (user != senderId) { var idstr = user.ToString(); var cacheModel = new BahamutCacheModel { AppUniqueId = Startup.Appname, CacheDateTime = DateTime.UtcNow, UniqueId = idstr, DeserializableString = msg.Id.ToString(), Type = ChatMessage.NotifyType, ExtraInfo = chat.Id.ToString() }; Startup.ServicesProvider.GetBahamutCacheService().PushCacheModelToList(cacheModel); var pbModel = new BahamutPublishModel { NotifyType = "Toronto", ToUser = idstr, CustomCmd = "UsrNewMsg", NotifyInfo = JsonConvert.SerializeObject(new { LocKey = "NEW_MSG_NOTIFICATION" }) }; Startup.ServicesProvider.GetBahamutPubSubService().PublishBahamutUserNotifyMessage(PublishConstants.NotifyId, pbModel); } } }
public PersistentFiddlerSession GetSessionWithId(string id) { var repo = new MongoRepository.MongoRepository<PersistentFiddlerSession>(); var resultSession = repo.GetById(id); if (null == resultSession) { throw new KeyNotFoundException(string.Format("Could not find a session id '{0}'", id)); } // checked if actual data is compressed vs expected length //if (resultSession.Len > resultSession.Data.Length) //{ // var uncompressed = Utility.UnZip(resultSession.Data); // resultSession.Data = uncompressed; //} var gridFsId = new ObjectId(resultSession.Data); var sessions = LoadSessionsFromGridFs(gridFsId); resultSession.SetSession(sessions[0]); return resultSession; }
public EmailTracking Get(ObjectId id) { var query = Builders<EmailTracking>.Filter.Eq(e => e.Id, id); var temp = _collection.Find(query).ToListAsync(); return temp.Result.FirstOrDefault(); }
/// <summary> /// Initializes a new instance of the <see cref="ReflogEntry"/> class. /// </summary> /// <param name="entryHandle">a <see cref="SafeHandle"/> to the reflog entry</param> public ReflogEntry(SafeHandle entryHandle) { _from = Proxy.git_reflog_entry_id_old(entryHandle); _to = Proxy.git_reflog_entry_id_new(entryHandle); _commiter = Proxy.git_reflog_entry_committer(entryHandle); message = Proxy.git_reflog_entry_message(entryHandle); }
public IEnumerable<Tuple<Category, IEnumerable<Category>>> GetCategoryTree(ObjectId categoryId) { var category = Get(categoryId); if (category == null) { // 分类不存在,返回顶级分类 return GetByParentNumber(null).Select(c => new Tuple<Category, IEnumerable<Category>>(c, null)); } // 获取下级分类 var subCategories = GetBySourceAndParentNumber(category.Source, category.Number).ToList(); var brotherCategories = GetBySourceAndParentNumber(category.Source, category.ParentNumber).ToList(); if (subCategories.Count > 0) { // 有下级分类,返回兄弟分类及当前分类的下级分类 return brotherCategories.Select(bc => new Tuple<Category, IEnumerable<Category>>(bc, bc.Id == categoryId ? subCategories : null)); } // 无下级分类 var parentCategory = GetBySourceAndNumber(category.Source, category.ParentNumber); if (parentCategory != null) { // 返回父分类的兄弟分类及当前分类的兄弟分类 var parentBrotherCategories = GetBySourceAndParentNumber(parentCategory.Source, parentCategory.ParentNumber); return parentBrotherCategories.Select(pbc => new Tuple<Category, IEnumerable<Category>>(pbc, pbc.Number == category.ParentNumber ? brotherCategories : null)); } else { // 没有父分类也没有子分类,返回当前分类的兄弟分类 return brotherCategories.Select(bc => new Tuple<Category, IEnumerable<Category>>(bc, null)); } }
public async Task<Sharelinker> GetUserOfUserId(string userId) { var collection = Client.GetDatabase("Sharelink").GetCollection<Sharelinker>("Sharelinker"); var uOId = new ObjectId(userId); var user = await collection.Find(u => u.Id == uOId).SingleAsync(); return user; }
public async Task<bool> RemoveTodoItem(ObjectId id) { var query = Builders<TodoItem>.Filter.Eq(e => e.Id, id); await this.collection.DeleteOneAsync(query); return await GetTodoItem(id) == null; }
public void ObjectIdWithSameValueAreEqual() { var a = new ObjectId("4b883faad657000000002665"); var b = new ObjectId("4b883faad657000000002665"); Assert.Equal(a, b); Assert.True(a == b); }
public SubscribeCOVRequest(uint subscriberProcessIdentifier, ObjectId monitoredObjectIdentifier, Option<bool> issueConfirmedNotifications, Option<uint> lifetime) { this.SubscriberProcessIdentifier = subscriberProcessIdentifier; this.MonitoredObjectIdentifier = monitoredObjectIdentifier; this.IssueConfirmedNotifications = issueConfirmedNotifications; this.Lifetime = lifetime; }
public dynamic AddMessage(string appName, ObjectId from, string to, string header, string message, long appId) { string fromStr = from.ToString(); var toObjId = new ObjectId(to); MessageInfo msgInfo = _userMessagesDataProvider.InsertMessage(appName, CalculateSessionId(fromStr, to), from, toObjId, HttpUtility.HtmlEncode(header), HttpUtility.HtmlEncode(message)); var toUserInfo = _userDataProvider.GetDatingBookUserInfo(appName, toObjId); var fromUserInfo = _userDataProvider.GetDatingBookUserInfo(appName, from); var appInfo = _appsDataProvider.GetAppInfo(appId); //inc the to user unread _userMessagesDataProvider.IncrementUnreadMessages(appName, toObjId); string msg = string.Format("You received a new message from {0} !", fromUserInfo.FirstName); _facebookDataProvider.SendFacebookAppNotification(toUserInfo.FacebookId, msg, msg, appInfo.AppAccessToken); return new { mid = msgInfo.Id.ToString(), text = msgInfo.Body, date = msgInfo.DateCreated, from_id = msgInfo.From.ToString(), picture = GenerateUserProfilePictureUrl(appName, fromUserInfo, 50, 50), from_name = fromUserInfo.FirstName }; }
public double? GetPriceInDay(ObjectId id, DateTime day) { var prices = GetPricesInDay(id, day); if (prices.Length > 0) return prices[0]; return null; }
internal Commit(Repo repo, ObjectId objId, byte[] objectContents) : base(repo, objId) { var texty = TextyObject.Parse(objectContents); var parents = new List<ObjectId>(); foreach (var kvp in texty.Attributes) { switch (kvp.Key) { case "tree": if (!Tree.IsZero) throw new Exception("Too many trees!"); Tree = ObjectId.Parse(kvp.Value); break; case "parent": parents.Add(ObjectId.Parse(kvp.Value)); break; case "author": Author = PersonTime.Parse(kvp.Value); break; case "committer": Committer = PersonTime.Parse(kvp.Value); break; default: throw new Exception("Unexpected commit attribute: " + kvp.Key); } } }
public static Autodesk.AutoCAD.Colors.Color GetColorByLayer(ObjectId layer) { Autodesk.AutoCAD.Colors.Color cl = new Autodesk.AutoCAD.Colors.Color(); try { using (var loc = AcadApp.AcaDoc.LockDocument()) { using (var trans = StartTransaction()) { LayerTableRecord ltr = trans.GetObject(layer, OpenMode.ForRead) as LayerTableRecord; if (ltr == null) { LufsGenplan.AcadApp.AcaEd.WriteMessage("\nDEBUG: GetColorByLayer ltr == null\n"); } cl = ltr.Color; trans.Commit(); } } return cl; } catch (System.Exception ex) { AcadApp.AcaEd.WriteMessage("\nERROR: AcadApp.GetColorByLayer() " + ex.Message + "\n"); } return cl; }