protected override void ProcessResponse( ISyncContext context, ChangeRequest request, ChangeResponse response) { SetSelfID(response.userId); MessagesSyncHelper.AddNewMessages( context, response.newMessages ?? new JanusMessageInfo[] {}, response.newRating ?? new JanusRatingInfo[] {}, response.newModerate ?? new JanusModerateInfo[] {}, response.userId); context.DBVars()[_lastRatingRVName] = response.lastRatingRowVersion.ToHexString(); context.DBVars()[_lastForumRVName] = response.lastForumRowVersion.ToHexString(); context.DBVars()[_lastModerRVName] = response.lastModerateRowVersion.ToHexString(); }
protected override ChangeRequest PrepareRequest(ISyncContext context) { var cfg = GetSyncConfig(); var rq = new ChangeRequest { userName = cfg.Login, password = cfg.Password, ratingRowVersion = context.DBVars()[_lastRatingRVName].FromHexString(), messageRowVersion = context.DBVars()[_lastForumRVName].FromHexString(), moderateRowVersion = context.DBVars()[_lastModerRVName].FromHexString(), maxOutput = cfg.MaxMessagesPerSession, subscribedForums = GetSubscribedForums(context).ToArray() }; return(rq); }
protected override void ProcessResponse(ISyncContext context, UserRequest request, UserResponse response) { AddNewUsers(context, response.users); context.DBVars()["LastUserRowVersion"] = response.lastRowVersion.ToHexString(); var receiveUsers = response.users.Length; context.StatisticsContainer.AddValue(JanusATInfo.UsersStats, receiveUsers); }
protected override ForumRequest PrepareRequest(ISyncContext context) { var cfg = GetSyncConfig(); return (new ForumRequest { userName = cfg.Login, password = cfg.Password, forumsRowVersion = context.DBVars()[_lastForumListRowVersion].FromHexString(), }); }
protected override UserRequest PrepareRequest(ISyncContext context) { var cfg = GetSyncConfig(); return (new UserRequest { userName = cfg.Login, password = cfg.Password, lastRowVersion = context.DBVars()["LastUserRowVersion"].FromHexString(), maxOutput = cfg.MaxUsersPerSession }); }
protected override ViolationRequest PrepareRequest(ISyncContext context) { var cfg = GetSyncConfig(); using (var db = context.CreateDBContext()) return new ViolationRequest { UserName = cfg.Login, Password = cfg.Password, LastRowVersion = context.DBVars()[_rvVarSlotName].FromHexString(), SubscribedForums = db.GetSubscribedForums() }; }
protected override void ProcessResponse( ISyncContext context, ViolationRequest request, ViolationResponse response) { using (var db = context.CreateDBContext()) using (var tx = db.BeginTransaction()) { foreach (var violation in response.Violations) { db .Violations() // ReSharper disable AccessToModifiedClosure .Value(_ => _.MessageID, () => violation.MessageID) .Value(_ => _.PenaltyType, () => (PenaltyType)violation.PenaltyType) .Value(_ => _.Reason, () => violation.Reason) .Value(_ => _.Create, () => violation.CreatedOn) // ReSharper restore AccessToModifiedClosure .Insert(); } tx.Commit(); } if (response.Violations.Length > 0) { JanusViolationInfo max = null; foreach (var v in response.Violations) { if (max == null || RVValue(max.RowVersion) < RVValue(v.RowVersion)) { max = v; } } if (max != null) { context.DBVars()[_rvVarSlotName] = max.RowVersion.ToHexString(); } } }
protected override void ProcessResponse( ISyncContext context, ForumRequest request, ForumResponse response) { var newForums = 0; if (response.forumList.Length > 0) { using (var db = context.CreateDBContext()) using (var tx = db.BeginTransaction()) { newForums = SyncServerForums(db, response.forumList); tx.Commit(); } } context.DBVars()[_lastForumListRowVersion] = response.forumsRowVersion.ToHexString(); context.StatisticsContainer.AddValue(JanusATInfo.ForumsStats, response.forumList.Length); if (newForums > 0) { context.StatisticsContainer.AddValue(JanusATInfo.NewForumsStat, newForums); } }