public void Follow(User follower, string followedId) { var following = this.followerRepository.All().FirstOrDefault(x => x.FollowedUserId == followedId); if (following == null) { following = new Following(); following.FollowedUserId = followedId; this.followerRepository.Add(following); this.followerRepository.Save(); } following.Followers.Add(follower); this.followerRepository.Add(following); this.followerRepository.Save(); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); var exists = _context.Followings.Any(a => a.FollowerId == userId && a.FolloweeId == dto.FolloweeId); if (exists) { return BadRequest(""); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return Ok(); }
public async Task IsCheckingExistFollowingInRepo() { FollowingModel model = new FollowingModel { FollowerId = "11", FolloweeId = "1" }; _dbContext.Add <FollowingModel>(model); _dbContext.SaveChanges(); Following f = new Following { FollowerId = "11", FolloweeId = "1" }; bool exist = await _repository.ExistFollowing(f); Assert.IsTrue(exist); f.FolloweeId = "199"; exist = await _repository.ExistFollowing(f); Assert.IsFalse(exist); }
public IHttpActionResult Follow(FollowingDto dto) { var currentUser = User.Identity.GetUserId(); if (_applicationDbContext.Followings. Any(f => f.FolloweeId == currentUser && f.FolloweeId == dto.FolloweeId)) { return(BadRequest()); } var following = new Following { FolloweeId = dto.FolloweeId, FollowerId = currentUser }; _applicationDbContext.Followings.Add(following); _applicationDbContext.SaveChanges(); return(Ok()); }
public bool Follow(ProfileAggregate otherAggregate) { if (otherAggregate == default) { throw new ArgumentException("The user cannot be null"); } if (otherAggregate.Id == Guid.Empty) { throw new ArgumentException("userid cannot be empty"); } Follower follow = Following.Find(follow => follow.FollowerId == Id && follow.FollowingId == otherAggregate.Id); if (follow != default) { return(false); } follow = new(Id, otherAggregate.Id); otherAggregate.AddFollower(follow); Following.Add(follow); return(true); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); var following = _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId); if (following != null) { return(BadRequest("Following already exists.")); } following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _unitOfWork.Followings.Add(following); _unitOfWork.Complete(); return(Ok()); }
public IHttpActionResult Follow(FollowingDTO dto) { var userId = User.Identity.GetUserId(); if (_context.Followings. Any(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId)) { return(BadRequest("Following already exists")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult AddFollower(FollowingDto dto) { var userId = User.Identity.GetUserId(); if (_context.Followings.Any(f => f.ArtistId == dto.ArtistId && f.UserId == userId)) { return(BadRequest("Already Following")); } var following = new Following { ArtistId = dto.ArtistId, UserId = userId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public ActionResult Follow(FollowingDto dto) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var exists = _context.Followings.Any(a => a.FollowerId == userId && a.FollowerId == dto.FolloweeId); if (exists) { return(BadRequest("The attendance allready exists")); } var follow = new Following { FolloweeId = dto.FolloweeId, FollowerId = User.FindFirstValue(ClaimTypes.NameIdentifier) }; _context.Followings.Add(follow); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Follow(FollowingDTO dto) { var userId = User.Identity.GetUserId(); var duplicated = _unitOfWork.Followings.GetFollowing(dto.FolloweeId, userId) != null; if (duplicated) { return(BadRequest("Following already exists")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _unitOfWork.Followings.Add(following); _unitOfWork.Complete(); return(Ok()); }
public async Task <IActionResult> Follow([FromBody] string followeeId) { var userId = "1"; var existed = await _unitOfWork.FollowingRepository.IsExist(userId, followeeId); if (existed) { return(BadRequest(followeeId + " existed")); } var follow = new Following() { FolloweeId = followeeId, FollowerId = userId }; _unitOfWork.FollowingRepository.AddAsync(follow); await _unitOfWork.CompleteAsync(); return(Ok(followeeId)); }
public ApiFollowing Follow(Guid publisherId, Guid subscriberId) { var apiFollowing = followingsRepository.GetApiFollowing(publisherId, subscriberId); if (apiFollowing == null) { var publisher = usersRepository.GetById(publisherId); var subscriber = usersRepository.GetById(subscriberId); if (publisher != null && subscriber != null) { var following = new Following() { Publisher = publisher, Subscriber = subscriber }; followingsRepository.Save(following); apiFollowing = followingsRepository.GetApiFollowing(publisherId, subscriberId); } } return(apiFollowing); }
// POST: api/Follow public IHttpActionResult Post(FollowDto FollowDto) { try { string FolloweeId = FollowDto.FolloweeId; string userID = User.Identity.GetUserId(); bool exist = _context.Followings .Any(c => c.FolloweeId == FolloweeId && c.FollowerId == userID); if (exist) { return(BadRequest("this Attendance Already Exists.")); } var followee = _context.Users .FirstOrDefault(c => c.Id == FolloweeId); if (followee == null) { return(Content(System.Net.HttpStatusCode.NotFound, $"The Artist with id {FolloweeId} is not found.")); } var follow = new Following() { FollowerId = userID, FolloweeId = FolloweeId }; _context.Followings.Add(follow); _context.SaveChanges(); } catch (System.Exception e) { return(StatusCode(System.Net.HttpStatusCode.InternalServerError)); } return(Ok("Added Successfully.")); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); var existed = _context.Followings .Any(a => a.FollowerId == userId && a.FolloweeId == dto.FolloweeId); if (existed) { return(BadRequest("The attendance is already existed")); } var following = new Following { FolloweeId = dto.FolloweeId, FollowerId = userId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); if (_context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId)) { var rFollowing = _context.Followings.Single(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId); _context.Followings.Remove(rFollowing); _context.SaveChanges(); return(BadRequest("The attendance is already exists.")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public Following GetFollowById(int subscriberid, int subscribedToId) { using (var conn = Connection) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = @" SELECT f.Id, f.SubscriberId, f.SubscribedToId FROM Following f WHERE f.SubscriberId = @subscriberId AND f.SubscribedToId = @subscribedToId "; cmd.Parameters.AddWithValue("@subscriberId", subscriberid); cmd.Parameters.AddWithValue("@subscribedToId", subscribedToId); Following follow = new Following(); var reader = cmd.ExecuteReader(); if (reader.Read()) { follow = new Following() { Id = reader.GetInt32(reader.GetOrdinal("Id")), SubscriberId = DbUtils.GetInt(reader, "SubscriberId"), SubscribedToId = DbUtils.GetInt(reader, "SubscribedToId"), }; } reader.Close(); return(follow); } } }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); if (_context.Followings.Any(f => f.UserFollowedId == dto.UserFollowedId && f.FollowerId == userId)) { return(BadRequest("User has already followed this artist.")); } var following = new Following() { FollowerId = userId, UserFollowedId = dto.UserFollowedId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); if (!_context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId)) { if (userId != dto.FolloweeId) { var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); } return(BadRequest("You can not follow yourself!")); } return(BadRequest("Following already exist!")); }
public IHttpActionResult Follow(string FolloweeId) { var userId = User.Identity.GetUserId(); var exists = db.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == FolloweeId); if (!exists) { var following = new Following { FollowerId = userId, FolloweeId = FolloweeId, }; db.Followings.Add(following); db.SaveChanges(); return(Ok()); } else { return(BadRequest("Isso ja existe")); } }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); //if (_context.Followings.Any(f => f.FolloweeId == userId && f.FollowerId == dto.FollowerId)) // return BadRequest("Followings Already Exist"); if (_unitOfWork.Followings.GetFollowing(userId, dto.FollowerId) != null) { return(BadRequest("Followings Already Exist")); } Following following = new Following { FollowerId = userId, FolloweeId = dto.FollowerId }; _unitOfWork.Followings.Add(following); _unitOfWork.Complete(); return(Ok()); }
public ActionResult Follow(string submitValue) { if (Session["user"] == null) { return(RedirectToAction("Login", "UsersManage")); } if (ModelState.IsValid) { var user = db.Users.Find(Session["user"]); user.followers += 1; db.Users.Add(user); Following f = new Following(); f.username = Session["user"].ToString(); f.subreddit_name = submitValue; db.Followings.Add(f); db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public IHttpActionResult Attend(FollowingDto dto) { var userId = User.Identity.GetUserId(); //var exists = _context.Attendances.Any(a => a.AttendeeId == userId && a.GigId == gigId); if (_context.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId)) { return(BadRequest("The attendance already exists")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); Following follow = _unitofwork.Follows.AllMyFollowings(dto, userId); if (follow != null) { return(BadRequest("Following already exists")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _unitofwork.Follows.Add(following); _unitofwork.Complete(); return(Ok()); }
public IHttpActionResult Follow(FollowingDTO followingdto) { var UserId = User.Identity.GetUserId(); var IsExist = _context.Followings.Any(f => f.FollowerId == UserId && f.FolloweeId == followingdto.followeeId); if (IsExist == true) { return(BadRequest("Following Already Exists !!! ")); } else { var following = new Following { FollowerId = UserId, FolloweeId = followingdto.followeeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); } }
public IHttpActionResult Follow(FollowingDto followingDto) { var userId = User.Identity.GetUserId(); if (_dbContext.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == followingDto.FolloweeId)) { return(BadRequest("Following already exists!")); } var folowing = new Following { FollowerId = userId, FolloweeId = followingDto.FolloweeId }; _dbContext.Followings.Add(folowing); _dbContext.SaveChanges(); folowing = _dbContext.Followings .Where(x => x.FolloweeId == followingDto.FolloweeId && x.FollowerId == userId) .Include(x => x.Followee) .Include(x => x.Follower).SingleOrDefault(); return(Ok()); }
public IActionResult Follow([FromBody] FollowingDto dto) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var exists = _context.Followings.Any(a => a.FollowerId == userId && a.FolloweeId == dto.FolloweeId); if (exists) { return(BadRequest("Following already exists.")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok(JsonConvert.SerializeObject(dto))); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); var exists = _context.Followings .Any(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId); if (exists) { return(BadRequest("The Attendence Already Exists")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; _context.Followings.Add(following); _context.SaveChanges(); return(Ok()); }
public IHttpActionResult Follow(FollowingDto followingDto) { var userId = User.Identity.GetUserId(); var exist = _context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == followingDto.ArtistId); if (exist) { return(BadRequest("You Are already following this artist")); } var follow = new Following { FollowerId = userId, FolloweeId = followingDto.ArtistId }; _context.Followings.Add(follow); _context.SaveChanges(); return(Ok("Success")); }
public IHttpActionResult Follow(FollowingDto dto) { var userId = User.Identity.GetUserId(); if (db.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId)) { return(BadRequest("You two are already friends.")); } var following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId, DateTime = DateTime.Now, Friends = true }; db.Followings.Add(following); db.SaveChanges(); return(Ok()); }
public override int GetHashCode() { unchecked { var hashCode = (Login != null ? Login.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Id.GetHashCode(); hashCode = (hashCode * 397) ^ (NodeId != null ? NodeId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AvatarUrl != null ? AvatarUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GravatarId != null ? GravatarId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Url != null ? Url.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FollowersUrl != null ? FollowersUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FollowingUrl != null ? FollowingUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (GistsUrl != null ? GistsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (StarredUrl != null ? StarredUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SubscriptionsUrl != null ? SubscriptionsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OrganizationsUrl != null ? OrganizationsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReposUrl != null ? ReposUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (EventsUrl != null ? EventsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ReceivedEventsUrl != null ? ReceivedEventsUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ SiteAdmin.GetHashCode(); hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Company != null ? Company.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Blog != null ? Blog.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Email != null ? Email.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Hireable != null ? Hireable.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Bio != null ? Bio.GetHashCode() : 0); hashCode = (hashCode * 397) ^ PublicRepos.GetHashCode(); hashCode = (hashCode * 397) ^ PublicGists.GetHashCode(); hashCode = (hashCode * 397) ^ Followers.GetHashCode(); hashCode = (hashCode * 397) ^ Following.GetHashCode(); hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode(); hashCode = (hashCode * 397) ^ UpdatedAt.GetHashCode(); return(hashCode); } }
public virtual HttpResponseMessage Follow(int entityTypeId, int entityId) { var person = GetPerson(); if (person == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } SetProxyCreation(true); var following = new Following { EntityTypeId = entityTypeId, EntityId = entityId, PersonAliasId = GetPerson().PrimaryAliasId.Value }; Service.Add(following); if (!following.IsValid) { return(ControllerContext.Request.CreateErrorResponse( HttpStatusCode.BadRequest, string.Join(",", following.ValidationResults.Select(r => r.ErrorMessage).ToArray()))); } if (!System.Web.HttpContext.Current.Items.Contains("CurrentPerson")) { System.Web.HttpContext.Current.Items.Add("CurrentPerson", GetPerson()); } Service.Context.SaveChanges(); var response = ControllerContext.Request.CreateResponse(HttpStatusCode.Created, following.Id); return(response); }
public async Task <IActionResult> Follow([FromBody] FollowingDto dto) { var userId = _userManager.GetUserId(User); var following = _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId); if (following != null) { return(BadRequest("Following already exists.")); } following = new Following { FollowerId = userId, FolloweeId = dto.FolloweeId }; await _unitOfWork.Followings.AddAsycn(following); await _unitOfWork.CompleteAsync(); return(Ok()); }
public void OnEventSelected(UInt32 eventID) { if (IsDisposed) return; if (!CurrentTextureIsLocked || (CurrentTexture != null && m_TexDisplay.texid != CurrentTexture.ID)) UI_OnTextureSelectionChanged(true); if (m_Output == null) return; UI_CreateThumbnails(); BoundResource[] RTs = Following.GetOutputTargets(m_Core); BoundResource Depth = Following.GetDepthTarget(m_Core); int rwIndex = 0; int roIndex = 0; var curDraw = m_Core.GetDrawcall(eventID); bool copy = curDraw != null && (curDraw.flags & (DrawcallFlags.Copy|DrawcallFlags.Resolve)) != 0; bool compute = curDraw != null && (curDraw.flags & (DrawcallFlags.Dispatch)) != 0; for(int rt=0; rt < RTs.Length; rt++) { ResourcePreview prev; if (rwIndex < rwPanel.Thumbnails.Length) prev = rwPanel.Thumbnails[rwIndex]; else prev = UI_CreateThumbnail(rwPanel); rwIndex++; Following follow = new Following(FollowType.OutputColour, ShaderStageType.Pixel, rt, 0); string bindName = copy ? "Destination" : ""; string slotName = copy ? "DST" : String.Format("{0}{1}", m_Core.CurPipelineState.OutputAbbrev(), rt); InitResourcePreview(prev, RTs[rt].Id, RTs[rt].typeHint, false, follow, bindName, slotName); } // depth { ResourcePreview prev; if (rwIndex < rwPanel.Thumbnails.Length) prev = rwPanel.Thumbnails[rwIndex]; else prev = UI_CreateThumbnail(rwPanel); rwIndex++; Following follow = new Following(FollowType.OutputDepth, ShaderStageType.Pixel, 0, 0); InitResourcePreview(prev, Depth.Id, Depth.typeHint, false, follow, "", "DS"); } ShaderStageType[] stages = new ShaderStageType[] { ShaderStageType.Vertex, ShaderStageType.Hull, ShaderStageType.Domain, ShaderStageType.Geometry, ShaderStageType.Pixel }; if (compute) stages = new ShaderStageType[] { ShaderStageType.Compute }; // display resources used for all stages foreach (ShaderStageType stage in stages) { Dictionary<BindpointMap, BoundResource[]> RWs = Following.GetReadWriteResources(m_Core, stage); Dictionary<BindpointMap, BoundResource[]> ROs = Following.GetReadOnlyResources(m_Core, stage); ShaderReflection details = Following.GetReflection(m_Core, stage); ShaderBindpointMapping mapping = Following.GetMapping(m_Core, stage); if (mapping == null) continue; InitStageResourcePreviews(stage, details != null ? details.ReadWriteResources : new ShaderResource[0], mapping.ReadWriteResources, RWs, rwPanel, ref rwIndex, copy, true); InitStageResourcePreviews(stage, details != null ? details.ReadOnlyResources : new ShaderResource[0], mapping.ReadOnlyResources, ROs, roPanel, ref roIndex, copy, false); } // hide others for (; rwIndex < rwPanel.Thumbnails.Length; rwIndex++) { rwPanel.Thumbnails[rwIndex].Init(); rwPanel.Thumbnails[rwIndex].Visible = false; } rwPanel.RefreshLayout(); for (; roIndex < roPanel.Thumbnails.Length; roIndex++) { roPanel.Thumbnails[roIndex].Init(); roPanel.Thumbnails[roIndex].Visible = false; } roPanel.RefreshLayout(); m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay); if(autoFit.Checked) AutoFitRange(); }
private void thumbsLayout_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && sender is ResourcePreview) { var prev = (ResourcePreview)sender; var follow = (Following)prev.Tag; foreach (var p in rwPanel.Thumbnails) p.Selected = false; foreach (var p in roPanel.Thumbnails) p.Selected = false; m_Following = follow; prev.Selected = true; var id = m_Following.GetResourceId(m_Core); if (id != ResourceId.Null) { UI_OnTextureSelectionChanged(false); m_PreviewPanel.Show(); } } if (e.Button == MouseButtons.Right) { ResourceId id = ResourceId.Null; if (sender is ResourcePreview) { var prev = (ResourcePreview)sender; var tagdata = (Following)prev.Tag; id = tagdata.GetResourceId(m_Core); if (id == ResourceId.Null && tagdata == m_Following) id = m_TexDisplay.texid; } OpenResourceContextMenu(id, true, (Control)sender, e.Location); } }
private void InitStageResourcePreviews(ShaderStageType stage, ShaderResource[] resourceDetails, BindpointMap[] mapping, Dictionary<BindpointMap, BoundResource[]> ResList, ThumbnailStrip prevs, ref int prevIndex, bool copy, bool rw) { for (int idx = 0; idx < mapping.Length; idx++) { var key = mapping[idx]; BoundResource[] resArray = null; if (ResList.ContainsKey(key)) resArray = ResList[key]; int arrayLen = resArray != null ? resArray.Length : 1; for (int arrayIdx = 0; arrayIdx < arrayLen; arrayIdx++) { ResourceId id = resArray != null ? resArray[arrayIdx].Id : ResourceId.Null; FormatComponentType typeHint = resArray != null ? resArray[arrayIdx].typeHint : FormatComponentType.None; bool used = key.used; bool samplerBind = false; bool otherBind = false; string bindName = ""; foreach (var bind in resourceDetails) { if (bind.bindPoint == idx && bind.IsSRV) { bindName = bind.name; otherBind = true; break; } if (bind.bindPoint == idx) { if(bind.IsSampler && !bind.IsSRV) samplerBind = true; else otherBind = true; } } if (samplerBind && !otherBind) continue; if (copy) { used = true; bindName = "Source"; } Following follow = new Following(rw ? FollowType.ReadWrite : FollowType.ReadOnly, stage, idx, arrayIdx); string slotName = String.Format("{0} {1}{2}", m_Core.CurPipelineState.Abbrev(stage), rw ? "RW " : "", idx); if (arrayLen > 1) slotName += String.Format("[{0}]", arrayIdx); if (copy) slotName = "SRC"; // show if bool show = (used || // it's referenced by the shader - regardless of empty or not (showDisabled.Checked && !used && id != ResourceId.Null) || // it's bound, but not referenced, and we have "show disabled" (showEmpty.Checked && id == ResourceId.Null) // it's empty, and we have "show empty" ); ResourcePreview prev; if (prevIndex < prevs.Thumbnails.Length) { prev = prevs.Thumbnails[prevIndex]; } else { // don't create it if we're not actually going to show it if (!show) continue; prev = UI_CreateThumbnail(prevs); } prevIndex++; InitResourcePreview(prev, show ? id : ResourceId.Null, typeHint, show, follow, bindName, slotName); } } }
private void InitResourcePreview(ResourcePreview prev, ResourceId id, FormatComponentType typeHint, bool force, Following follow, string bindName, string slotName) { if (id != ResourceId.Null || force) { FetchTexture tex = null; foreach (var t in m_Core.CurTextures) if (t.ID == id) tex = t; FetchBuffer buf = null; foreach (var b in m_Core.CurBuffers) if (b.ID == id) buf = b; if (tex != null) { string fullname = bindName; if (tex.customName) { if (fullname.Length > 0) fullname += " = "; fullname += tex.name; } if (fullname.Length == 0) fullname = tex.name; prev.Init(fullname, tex.width, tex.height, tex.depth, tex.mips); IntPtr handle = prev.ThumbnailHandle; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, id, typeHint); }); } else if (buf != null) { string fullname = bindName; if (buf.customName) { if (fullname.Length > 0) fullname += " = "; fullname += buf.name; } if (fullname.Length == 0) fullname = buf.name; prev.Init(fullname, buf.length, 0, 0, 1); IntPtr handle = prev.ThumbnailHandle; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None); }); } else { prev.Init(); IntPtr handle = prev.ThumbnailHandle; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None); }); } prev.Tag = follow; prev.SlotName = slotName; prev.Visible = true; prev.Selected = (m_Following == follow); } else if (m_Following == follow) { FetchTexture tex = null; if(id != ResourceId.Null) foreach (var t in m_Core.CurTextures) if (t.ID == id) tex = t; IntPtr handle = prev.ThumbnailHandle; if (id == ResourceId.Null || tex == null) prev.Init(); else prev.Init("Unused", tex.width, tex.height, tex.depth, tex.mips); prev.Selected = true; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None); }); } else { prev.Init(); prev.Visible = false; } }
/// <summary> /// Handles the Click event of the btnComplete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnComplete_Click( object sender, EventArgs e ) { if ( Page.IsValid ) { var rockContext = new RockContext(); var personService = new PersonService( rockContext ); var ids = Individuals.Select( i => i.PersonId ).ToList(); var personEntityType = EntityTypeCache.Read( "Rock.Model.Person" ); if ( personEntityType != null ) { int personEntityTypeId = personEntityType.Id; var people = personService.Queryable().Where( p => ids.Contains( p.Id ) ).ToList(); #region Individual Details Updates int? newTitleId = ddlTitle.SelectedValueAsInt(); int? newSuffixId = ddlSuffix.SelectedValueAsInt(); int? newConnectionStatusId = ddlStatus.SelectedValueAsInt(); int? newRecordStatusId = ddlRecordStatus.SelectedValueAsInt(); int? newInactiveReasonId = ddlInactiveReason.SelectedValueAsInt(); string newInactiveReasonNote = tbInactiveReasonNote.Text; Gender? newGender = ddlGender.SelectedValue.ConvertToEnumOrNull<Gender>(); int? newMaritalStatusId = ddlMaritalStatus.SelectedValueAsInt(); DateTime? newGraduationDate = null; if ( ypGraduation.SelectedYear.HasValue ) { newGraduationDate = new DateTime( ypGraduation.SelectedYear.Value, _gradeTransitionDate.Month, _gradeTransitionDate.Day ); } int? newCampusId = cpCampus.SelectedCampusId; bool? newEmailActive = null; if ( !string.IsNullOrWhiteSpace( ddlIsEmailActive.SelectedValue ) ) { newEmailActive = ddlIsEmailActive.SelectedValue == "Active"; } EmailPreference? newEmailPreference = ddlEmailPreference.SelectedValue.ConvertToEnumOrNull<EmailPreference>(); string newEmailNote = tbEmailNote.Text; bool? newFollow = null; if ( !string.IsNullOrWhiteSpace( ddlFollow.SelectedValue ) ) { newFollow = ddlFollow.SelectedValue == "Add"; } int? newReviewReason = ddlReviewReason.SelectedValueAsInt(); string newSystemNote = tbSystemNote.Text; string newReviewReasonNote = tbReviewReasonNote.Text; var allChanges = new Dictionary<int, List<string>>(); foreach ( var person in people ) { var changes = new List<string>(); allChanges.Add( person.Id, changes ); if ( newTitleId.HasValue ) { History.EvaluateChange( changes, "Title", DefinedValueCache.GetName( person.TitleValueId ), DefinedValueCache.GetName( newTitleId ) ); person.TitleValueId = newTitleId; } if ( newSuffixId.HasValue ) { History.EvaluateChange( changes, "Suffix", DefinedValueCache.GetName( person.SuffixValueId ), DefinedValueCache.GetName( newSuffixId ) ); person.SuffixValueId = newSuffixId; } if ( newConnectionStatusId.HasValue ) { History.EvaluateChange( changes, "Connection Status", DefinedValueCache.GetName( person.ConnectionStatusValueId ), DefinedValueCache.GetName( newConnectionStatusId ) ); person.ConnectionStatusValueId = newConnectionStatusId; } if ( newRecordStatusId.HasValue ) { History.EvaluateChange( changes, "Record Status", DefinedValueCache.GetName( person.RecordStatusValueId ), DefinedValueCache.GetName( newRecordStatusId ) ); person.RecordStatusValueId = newRecordStatusId; } if ( newInactiveReasonId.HasValue ) { History.EvaluateChange( changes, "Inactive Reason", DefinedValueCache.GetName( person.RecordStatusReasonValueId ), DefinedValueCache.GetName( newInactiveReasonId ) ); person.RecordStatusReasonValueId = newInactiveReasonId; } if ( !string.IsNullOrWhiteSpace( newInactiveReasonNote ) ) { History.EvaluateChange( changes, "Inactive Reason Note", person.InactiveReasonNote, newInactiveReasonNote ); person.InactiveReasonNote = newInactiveReasonNote; } if ( newGender.HasValue ) { History.EvaluateChange( changes, "Gender", person.Gender, newGender.Value ); person.Gender = newGender.Value; } if ( newMaritalStatusId.HasValue ) { History.EvaluateChange( changes, "Marital Status", DefinedValueCache.GetName( person.MaritalStatusValueId ), DefinedValueCache.GetName( newMaritalStatusId ) ); person.MaritalStatusValueId = newMaritalStatusId; } if ( newGraduationDate.HasValue ) { History.EvaluateChange( changes, "Graduation Date", person.GraduationDate, newGraduationDate ); person.GraduationDate = newGraduationDate; } if ( newEmailActive.HasValue ) { History.EvaluateChange( changes, "Email Is Active", person.IsEmailActive ?? true, newEmailActive.Value ); person.IsEmailActive = newEmailActive; } if ( newEmailPreference.HasValue ) { History.EvaluateChange( changes, "Email Preference", person.EmailPreference, newEmailPreference ); person.EmailPreference = newEmailPreference.Value; } if ( !string.IsNullOrWhiteSpace( newEmailNote ) ) { History.EvaluateChange( changes, "Email Note", person.EmailNote, newEmailNote ); person.EmailNote = newEmailNote; } if ( !string.IsNullOrWhiteSpace( newSystemNote ) ) { History.EvaluateChange( changes, "System Note", person.SystemNote, newSystemNote ); person.SystemNote = newSystemNote; } if ( newReviewReason.HasValue ) { History.EvaluateChange( changes, "Review Reason", DefinedValueCache.GetName( person.ReviewReasonValueId ), DefinedValueCache.GetName( newReviewReason ) ); person.ReviewReasonValueId = newReviewReason; } if ( !string.IsNullOrWhiteSpace( newReviewReasonNote ) ) { History.EvaluateChange( changes, "Review Reason Note", person.ReviewReasonNote, newReviewReasonNote ); person.ReviewReasonNote = newReviewReasonNote; } } // Update following if ( newFollow.HasValue && CurrentPersonAlias != null ) { var followingService = new FollowingService( rockContext ); if ( newFollow.Value ) { var alreadyFollingIds = followingService.Queryable() .Where( f => f.EntityTypeId == personEntityTypeId && f.PersonAlias.Id == CurrentPersonAlias.Id ) .Select( f => f.EntityId ) .Distinct() .ToList(); foreach ( int id in ids.Where( id => !alreadyFollingIds.Contains( id ) ) ) { var following = new Following { EntityTypeId = personEntityTypeId, EntityId = id, PersonAliasId = CurrentPersonAlias.Id }; followingService.Add( following ); } } else { foreach ( var following in followingService.Queryable() .Where( f => f.EntityTypeId == personEntityTypeId && ids.Contains( f.EntityId ) && f.PersonAlias.Id == CurrentPersonAlias.Id ) ) { followingService.Delete( following ); } } } rockContext.SaveChanges(); #endregion #region Attributes var selectedCategories = new List<CategoryCache>(); foreach ( string categoryGuid in GetAttributeValue( "AttributeCategories" ).SplitDelimitedValues() ) { var category = CategoryCache.Read( categoryGuid.AsGuid(), rockContext ); if ( category != null ) { selectedCategories.Add( category ); } } var attributes = new List<AttributeCache>(); var attributeValues = new Dictionary<int, string>(); int categoryIndex = 0; foreach ( var category in selectedCategories.OrderBy( c => c.Name ) ) { PanelWidget pw = null; string controlId = "pwAttributes_" + category.Id.ToString(); if ( categoryIndex % 2 == 0 ) { pw = phAttributesCol1.FindControl( controlId ) as PanelWidget; } else { pw = phAttributesCol2.FindControl( controlId) as PanelWidget; } categoryIndex++; if ( pw != null ) { var orderedAttributeList = new AttributeService( rockContext ).GetByCategoryId( category.Id ) .OrderBy( a => a.Order ).ThenBy( a => a.Name ); foreach ( var attribute in orderedAttributeList ) { if ( attribute.IsAuthorized( Authorization.EDIT, CurrentPerson ) ) { var attributeCache = AttributeCache.Read( attribute.Id ); Control attributeControl = pw.FindControl( string.Format( "attribute_field_{0}", attribute.Id ) ); if ( attributeControl != null ) { string newValue = attributeCache.FieldType.Field.GetEditValue( attributeControl, attributeCache.QualifierValues ); if (!string.IsNullOrWhiteSpace(newValue)) { attributes.Add( attributeCache); attributeValues.Add( attributeCache.Id, newValue ); } } } } } } if (attributes.Any()) { foreach ( var person in people ) { person.LoadAttributes(); foreach ( var attribute in attributes ) { string originalValue = person.GetAttributeValue( attribute.Key ); string newValue = attributeValues[attribute.Id]; if ( ( originalValue ?? string.Empty ).Trim() != ( newValue ?? string.Empty ).Trim() ) { Rock.Attribute.Helper.SaveAttributeValue( person, attribute, newValue, rockContext ); string formattedOriginalValue = string.Empty; if ( !string.IsNullOrWhiteSpace( originalValue ) ) { formattedOriginalValue = attribute.FieldType.Field.FormatValue( null, originalValue, attribute.QualifierValues, false ); } string formattedNewValue = string.Empty; if ( !string.IsNullOrWhiteSpace( newValue ) ) { formattedNewValue = attribute.FieldType.Field.FormatValue( null, newValue, attribute.QualifierValues, false ); } History.EvaluateChange( allChanges[person.Id], attribute.Name, formattedOriginalValue, formattedNewValue ); } } } } // Create the history records foreach ( var changes in allChanges ) { if ( changes.Value.Any() ) { HistoryService.AddChanges( rockContext, typeof( Person ), Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(), changes.Key, changes.Value ); } } rockContext.SaveChanges(); #endregion #region Add Note if ( !string.IsNullOrWhiteSpace( tbNote.Text ) && CurrentPerson != null ) { string text = tbNote.Text; bool isAlert = cbIsAlert.Checked; bool isPrivate = cbIsPrivate.Checked; var noteTypeService = new NoteTypeService( rockContext ); var noteService = new NoteService( rockContext ); string noteTypeName = GetAttributeValue( "NoteType" ); var noteType = noteTypeService.Get( personEntityTypeId, noteTypeName ); if ( noteType != null ) { var notes = new List<Note>(); foreach ( int id in ids ) { var note = new Note(); note.IsSystem = false; note.EntityId = id; note.Caption = isPrivate ? "You - Personal Note" : string.Empty; note.Text = tbNote.Text; note.IsAlert = cbIsAlert.Checked; note.NoteType = noteType; notes.Add( note ); noteService.Add( note ); } rockContext.WrapTransaction( () => { rockContext.SaveChanges(); foreach( var note in notes) { note.AllowPerson( Authorization.EDIT, CurrentPerson, rockContext ); if ( isPrivate) { note.MakePrivate( Authorization.VIEW, CurrentPerson, rockContext ); } } } ); } } #endregion } string message = string.Format("{0} {1} succesfully updated!", ids.Count().ToString("N0"), (ids.Count() > 1 ? "people were" : "person was") ); ShowResult( message ); } }
/// <summary> /// Handles the Click event of the btnConfirm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnConfirm_Click( object sender, EventArgs e ) { if ( Page.IsValid ) { var rockContext = new RockContext(); var personService = new PersonService( rockContext ); var ids = Individuals.Select( i => i.PersonId ).ToList(); #region Individual Details Updates int? newTitleId = ddlTitle.SelectedValueAsInt(); int? newSuffixId = ddlSuffix.SelectedValueAsInt(); int? newConnectionStatusId = ddlStatus.SelectedValueAsInt(); int? newRecordStatusId = ddlRecordStatus.SelectedValueAsInt(); int? newInactiveReasonId = ddlInactiveReason.SelectedValueAsInt(); string newInactiveReasonNote = tbInactiveReasonNote.Text; Gender newGender = ddlGender.SelectedValue.ConvertToEnum<Gender>(); int? newMaritalStatusId = ddlMaritalStatus.SelectedValueAsInt(); int? newGraduationYear = null; if ( ypGraduation.SelectedYear.HasValue ) { newGraduationYear = ypGraduation.SelectedYear.Value; } int? newCampusId = cpCampus.SelectedCampusId; bool? newEmailActive = null; if ( !string.IsNullOrWhiteSpace( ddlIsEmailActive.SelectedValue ) ) { newEmailActive = ddlIsEmailActive.SelectedValue == "Active"; } EmailPreference? newEmailPreference = ddlEmailPreference.SelectedValue.ConvertToEnumOrNull<EmailPreference>(); string newEmailNote = tbEmailNote.Text; int? newReviewReason = ddlReviewReason.SelectedValueAsInt(); string newSystemNote = tbSystemNote.Text; string newReviewReasonNote = tbReviewReasonNote.Text; int inactiveStatusId = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_RECORD_STATUS_INACTIVE ).Id; var allChanges = new Dictionary<int, List<string>>(); var people = personService.Queryable().Where( p => ids.Contains( p.Id ) ).ToList(); foreach ( var person in people ) { var changes = new List<string>(); allChanges.Add( person.Id, changes ); if ( SelectedFields.Contains( ddlTitle.ClientID ) ) { History.EvaluateChange( changes, "Title", DefinedValueCache.GetName( person.TitleValueId ), DefinedValueCache.GetName( newTitleId ) ); person.TitleValueId = newTitleId; } if ( SelectedFields.Contains( ddlSuffix.ClientID ) ) { History.EvaluateChange( changes, "Suffix", DefinedValueCache.GetName( person.SuffixValueId ), DefinedValueCache.GetName( newSuffixId ) ); person.SuffixValueId = newSuffixId; } if ( SelectedFields.Contains( ddlStatus.ClientID ) ) { History.EvaluateChange( changes, "Connection Status", DefinedValueCache.GetName( person.ConnectionStatusValueId ), DefinedValueCache.GetName( newConnectionStatusId ) ); person.ConnectionStatusValueId = newConnectionStatusId; } if ( SelectedFields.Contains( ddlRecordStatus.ClientID ) ) { History.EvaluateChange( changes, "Record Status", DefinedValueCache.GetName( person.RecordStatusValueId ), DefinedValueCache.GetName( newRecordStatusId ) ); person.RecordStatusValueId = newRecordStatusId; if ( newRecordStatusId.HasValue && newRecordStatusId.Value == inactiveStatusId ) { History.EvaluateChange( changes, "Inactive Reason", DefinedValueCache.GetName( person.RecordStatusReasonValueId ), DefinedValueCache.GetName( newInactiveReasonId ) ); person.RecordStatusReasonValueId = newInactiveReasonId; if ( !string.IsNullOrWhiteSpace( newInactiveReasonNote ) ) { History.EvaluateChange( changes, "Inactive Reason Note", person.InactiveReasonNote, newInactiveReasonNote ); person.InactiveReasonNote = newInactiveReasonNote; } } } if ( SelectedFields.Contains( ddlGender.ClientID ) ) { History.EvaluateChange( changes, "Gender", person.Gender, newGender ); person.Gender = newGender; } if ( SelectedFields.Contains( ddlMaritalStatus.ClientID ) ) { History.EvaluateChange( changes, "Marital Status", DefinedValueCache.GetName( person.MaritalStatusValueId ), DefinedValueCache.GetName( newMaritalStatusId ) ); person.MaritalStatusValueId = newMaritalStatusId; } if ( SelectedFields.Contains( ddlGradePicker.ClientID ) ) { History.EvaluateChange( changes, "Graduation Year", person.GraduationYear, newGraduationYear ); person.GraduationYear = newGraduationYear; } if ( SelectedFields.Contains( ddlIsEmailActive.ClientID ) ) { History.EvaluateChange( changes, "Email Is Active", person.IsEmailActive ?? true, newEmailActive.Value ); person.IsEmailActive = newEmailActive; } if ( SelectedFields.Contains( ddlEmailPreference.ClientID ) ) { History.EvaluateChange( changes, "Email Preference", person.EmailPreference, newEmailPreference ); person.EmailPreference = newEmailPreference.Value; } if ( SelectedFields.Contains( tbEmailNote.ClientID ) ) { History.EvaluateChange( changes, "Email Note", person.EmailNote, newEmailNote ); person.EmailNote = newEmailNote; } if ( SelectedFields.Contains( tbSystemNote.ClientID ) ) { History.EvaluateChange( changes, "System Note", person.SystemNote, newSystemNote ); person.SystemNote = newSystemNote; } if ( SelectedFields.Contains( ddlReviewReason.ClientID ) ) { History.EvaluateChange( changes, "Review Reason", DefinedValueCache.GetName( person.ReviewReasonValueId ), DefinedValueCache.GetName( newReviewReason ) ); person.ReviewReasonValueId = newReviewReason; } if ( SelectedFields.Contains( tbReviewReasonNote.ClientID ) ) { History.EvaluateChange( changes, "Review Reason Note", person.ReviewReasonNote, newReviewReasonNote ); person.ReviewReasonNote = newReviewReasonNote; } } if ( SelectedFields.Contains( cpCampus.ClientID ) && cpCampus.SelectedCampusId.HasValue ) { int campusId = cpCampus.SelectedCampusId.Value; Guid familyGuid = new Guid( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY ); var familyMembers = new GroupMemberService( rockContext ).Queryable() .Where( m => ids.Contains( m.PersonId ) && m.Group.GroupType.Guid == familyGuid ) .Select( m => new { m.PersonId, m.GroupId } ) .Distinct() .ToList(); var families = new GroupMemberService( rockContext ).Queryable() .Where( m => ids.Contains( m.PersonId ) && m.Group.GroupType.Guid == familyGuid ) .Select( m => m.Group ) .Distinct() .ToList(); foreach ( int personId in ids ) { var familyIds = familyMembers.Where( m => m.PersonId == personId ).Select( m => m.GroupId ).ToList(); if ( familyIds.Count == 1 ) { int familyId = familyIds.FirstOrDefault(); var family = families.Where( g => g.Id == familyId ).FirstOrDefault(); { if ( family != null ) { family.CampusId = campusId; } familyMembers.RemoveAll( m => m.GroupId == familyId ); } } } rockContext.SaveChanges(); } // Update following if ( SelectedFields.Contains( ddlFollow.ClientID ) ) { var personAliasEntityType = EntityTypeCache.Read( "Rock.Model.PersonAlias" ); if ( personAliasEntityType != null ) { int personAliasEntityTypeId = personAliasEntityType.Id; bool follow = true; if ( !string.IsNullOrWhiteSpace( ddlFollow.SelectedValue ) ) { follow = ddlFollow.SelectedValue == "Add"; } var personAliasService = new PersonAliasService( rockContext ); var followingService = new FollowingService( rockContext ); if ( follow ) { var paQry = personAliasService.Queryable(); var alreadyFollowingIds = followingService.Queryable() .Where( f => f.EntityTypeId == personAliasEntityTypeId && f.PersonAlias.Id == CurrentPersonAlias.Id ) .Join( paQry, f => f.EntityId, p => p.Id, ( f, p ) => new { PersonAlias = p } ) .Select( p => p.PersonAlias.PersonId ) .Distinct() .ToList(); foreach ( int id in ids.Where( id => !alreadyFollowingIds.Contains( id ) ) ) { var following = new Following { EntityTypeId = personAliasEntityTypeId, EntityId = ( people.FirstOrDefault( p => p.Id == id ).PrimaryAliasId ) ?? 0, PersonAliasId = CurrentPersonAlias.Id }; followingService.Add( following ); } } else { var paQry = personAliasService.Queryable() .Where( p => ids.Contains( p.PersonId ) ) .Select( p => p.Id ); foreach ( var following in followingService.Queryable() .Where( f => f.EntityTypeId == personAliasEntityTypeId && paQry.Contains( f.EntityId ) && f.PersonAlias.Id == CurrentPersonAlias.Id ) ) { followingService.Delete( following ); } } } } rockContext.SaveChanges(); #endregion #region Attributes var selectedCategories = new List<CategoryCache>(); foreach ( string categoryGuid in GetAttributeValue( "AttributeCategories" ).SplitDelimitedValues() ) { var category = CategoryCache.Read( categoryGuid.AsGuid(), rockContext ); if ( category != null ) { selectedCategories.Add( category ); } } var attributes = new List<AttributeCache>(); var attributeValues = new Dictionary<int, string>(); int categoryIndex = 0; foreach ( var category in selectedCategories.OrderBy( c => c.Name ) ) { PanelWidget pw = null; string controlId = "pwAttributes_" + category.Id.ToString(); if ( categoryIndex % 2 == 0 ) { pw = phAttributesCol1.FindControl( controlId ) as PanelWidget; } else { pw = phAttributesCol2.FindControl( controlId ) as PanelWidget; } categoryIndex++; if ( pw != null ) { var orderedAttributeList = new AttributeService( rockContext ).GetByCategoryId( category.Id ) .OrderBy( a => a.Order ).ThenBy( a => a.Name ); foreach ( var attribute in orderedAttributeList ) { if ( attribute.IsAuthorized( Authorization.EDIT, CurrentPerson ) ) { var attributeCache = AttributeCache.Read( attribute.Id ); Control attributeControl = pw.FindControl( string.Format( "attribute_field_{0}", attribute.Id ) ); if ( attributeControl != null && SelectedFields.Contains( attributeControl.ClientID ) ) { string newValue = attributeCache.FieldType.Field.GetEditValue( attributeControl, attributeCache.QualifierValues ); attributes.Add( attributeCache ); attributeValues.Add( attributeCache.Id, newValue ); } } } } } if ( attributes.Any() ) { foreach ( var person in people ) { person.LoadAttributes(); foreach ( var attribute in attributes ) { string originalValue = person.GetAttributeValue( attribute.Key ); string newValue = attributeValues[attribute.Id]; if ( ( originalValue ?? string.Empty ).Trim() != ( newValue ?? string.Empty ).Trim() ) { Rock.Attribute.Helper.SaveAttributeValue( person, attribute, newValue, rockContext ); string formattedOriginalValue = string.Empty; if ( !string.IsNullOrWhiteSpace( originalValue ) ) { formattedOriginalValue = attribute.FieldType.Field.FormatValue( null, originalValue, attribute.QualifierValues, false ); } string formattedNewValue = string.Empty; if ( !string.IsNullOrWhiteSpace( newValue ) ) { formattedNewValue = attribute.FieldType.Field.FormatValue( null, newValue, attribute.QualifierValues, false ); } History.EvaluateChange( allChanges[person.Id], attribute.Name, formattedOriginalValue, formattedNewValue ); } } } } // Create the history records foreach ( var changes in allChanges ) { if ( changes.Value.Any() ) { HistoryService.AddChanges( rockContext, typeof( Person ), Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(), changes.Key, changes.Value ); } } rockContext.SaveChanges(); #endregion #region Add Note if ( !string.IsNullOrWhiteSpace( tbNote.Text ) && CurrentPerson != null ) { string text = tbNote.Text; bool isAlert = cbIsAlert.Checked; bool isPrivate = cbIsPrivate.Checked; var noteTypeService = new NoteTypeService( rockContext ); var noteType = noteTypeService.Get( Rock.SystemGuid.NoteType.PERSON_TIMELINE.AsGuid() ); if ( noteType != null ) { var notes = new List<Note>(); var noteService = new NoteService( rockContext ); foreach ( int id in ids ) { var note = new Note(); note.IsSystem = false; note.EntityId = id; note.Caption = isPrivate ? "You - Personal Note" : string.Empty; note.Text = tbNote.Text; note.IsAlert = cbIsAlert.Checked; note.NoteType = noteType; notes.Add( note ); noteService.Add( note ); } rockContext.WrapTransaction( () => { rockContext.SaveChanges(); foreach ( var note in notes ) { note.AllowPerson( Authorization.EDIT, CurrentPerson, rockContext ); if ( isPrivate ) { note.MakePrivate( Authorization.VIEW, CurrentPerson, rockContext ); } } } ); } } #endregion #region Group int? groupId = gpGroup.SelectedValue.AsIntegerOrNull(); if ( groupId.HasValue ) { var group = new GroupService( rockContext ).Get( groupId.Value ); if ( group != null ) { var groupMemberService = new GroupMemberService( rockContext ); var existingMembers = groupMemberService.Queryable( "Group" ) .Where( m => m.GroupId == group.Id && ids.Contains( m.PersonId ) ) .ToList(); string action = ddlGroupAction.SelectedValue; if ( action == "Remove" ) { groupMemberService.DeleteRange( existingMembers ); rockContext.SaveChanges(); } else { var roleId = ddlGroupRole.SelectedValueAsInt(); var status = ddlGroupMemberStatus.SelectedValueAsEnum<GroupMemberStatus>(); // Get the attribute values updated var gm = new GroupMember(); gm.Group = group; gm.GroupId = group.Id; gm.LoadAttributes( rockContext ); var selectedGroupAttributes = new List<AttributeCache>(); var selectedGroupAttributeValues = new Dictionary<string, string>(); foreach ( var attributeCache in gm.Attributes.Select( a => a.Value ) ) { Control attributeControl = phAttributes.FindControl( string.Format( "attribute_field_{0}", attributeCache.Id ) ); if ( attributeControl != null && ( action == "Add" || SelectedFields.Contains( attributeControl.ClientID ) ) ) { string newValue = attributeCache.FieldType.Field.GetEditValue( attributeControl, attributeCache.QualifierValues ); selectedGroupAttributes.Add( attributeCache ); selectedGroupAttributeValues.Add( attributeCache.Key, newValue ); } } if ( action == "Add" ) { if ( roleId.HasValue ) { var newGroupMembers = new List<GroupMember>(); var existingIds = existingMembers.Select( m => m.PersonId ).Distinct().ToList(); foreach ( int id in ids.Where( id => !existingIds.Contains( id ) ) ) { var groupMember = new GroupMember(); groupMember.GroupId = group.Id; groupMember.GroupRoleId = roleId.Value; groupMember.GroupMemberStatus = status; groupMember.PersonId = id; groupMemberService.Add( groupMember ); newGroupMembers.Add( groupMember ); } rockContext.SaveChanges(); if ( selectedGroupAttributes.Any() ) { foreach ( var groupMember in newGroupMembers ) { foreach ( var attribute in selectedGroupAttributes ) { Rock.Attribute.Helper.SaveAttributeValue( groupMember, attribute, selectedGroupAttributeValues[attribute.Key], rockContext ); } } } } } else // Update { if ( SelectedFields.Contains( ddlGroupRole.ClientID ) && roleId.HasValue ) { foreach ( var member in existingMembers.Where( m => m.GroupRoleId != roleId.Value ) ) { if ( !existingMembers.Where( m => m.PersonId == member.PersonId && m.GroupRoleId == roleId.Value ).Any() ) { member.GroupRoleId = roleId.Value; } } } if ( SelectedFields.Contains( ddlGroupMemberStatus.ClientID ) ) { foreach ( var member in existingMembers ) { member.GroupMemberStatus = status; } } rockContext.SaveChanges(); if ( selectedGroupAttributes.Any() ) { foreach ( var groupMember in existingMembers ) { foreach ( var attribute in selectedGroupAttributes ) { Rock.Attribute.Helper.SaveAttributeValue( groupMember, attribute, selectedGroupAttributeValues[attribute.Key], rockContext ); } } } } } } } #endregion pnlEntry.Visible = false; pnlConfirm.Visible = false; nbResult.Text = string.Format( "{0} {1} succesfully updated.", ids.Count().ToString( "N0" ), ( ids.Count() > 1 ? "people were" : "person was" ) ); ; pnlResult.Visible = true; } }
public void OnLogfileLoaded() { var outConfig = new OutputConfig(); outConfig.m_Type = OutputType.TexDisplay; saveTex.Enabled = gotoLocationButton.Enabled = viewTexBuffer.Enabled = true; m_Following = Following.Default; rwPanel.ClearThumbnails(); roPanel.ClearThumbnails(); RecreateRenderPanel(); RecreateContextPanel(); m_HighWaterStatusLength = 0; IntPtr contextHandle = pixelContext.Handle; IntPtr renderHandle = render.Handle; m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { m_Output = r.CreateOutput(renderHandle, OutputType.TexDisplay); m_Output.SetPixelContext(contextHandle); m_Output.SetOutputConfig(outConfig); this.BeginInvoke(new Action(UI_CreateThumbnails)); }); m_FSWatcher = new FileSystemWatcher(Core.ConfigDirectory, "*" + m_Core.APIProps.ShaderExtension); m_FSWatcher.EnableRaisingEvents = true; m_FSWatcher.Changed += new FileSystemEventHandler(CustomShaderModified); m_FSWatcher.Renamed += new RenamedEventHandler(CustomShaderModified); m_FSWatcher.Created += new FileSystemEventHandler(CustomShaderModified); m_FSWatcher.Deleted += new FileSystemEventHandler(CustomShaderModified); ReloadCustomShaders(""); texturefilter.SelectedIndex = 0; texturefilter.Text = ""; textureList.FillTextureList("", true, true); m_TexDisplay.darkBackgroundColour = darkBack; m_TexDisplay.lightBackgroundColour = lightBack; m_TexDisplay.typeHint = FormatComponentType.None; m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay); }
private void ResetDictionaries() { FollowingDictionary.Clear(); TwitterConnections.Clear(); foreach (Yedda.Twitter.Account a in ClientSettings.AccountsList) { Twitter.Account AccountInfo = new Twitter.Account { ServerURL = a.ServerURL, UserName = a.UserName, Password = a.Password, OAuth_token = a.OAuth_token, OAuth_token_secret = a.OAuth_token_secret, Enabled = a.Enabled }; Twitter TwitterConn = Servers.CreateConnection(AccountInfo); TwitterConnections.Add(TwitterConn); Following f = new Following(TwitterConn); FollowingDictionary.Add(TwitterConn, f); } SetConnectedMenus(); Manager = new TimelineManagement(); Manager.Progress += Manager_Progress; Manager.CompleteLoaded += Manager_CompleteLoaded; Manager.Startup(TwitterConnections); Manager.FriendsUpdated += Manager_FriendsUpdated; Manager.MessagesUpdated += Manager_MessagesUpdated; Manager.SearchesUpdated += Manager_SearchesUpdated; foreach (Following f in FollowingDictionary.Values) { f.LoadFromTwitter(); } }
public TextureViewer(Core core) { m_Core = core; InitializeComponent(); textureList.Font = texturefilter.Font = rangeBlack.Font = rangeWhite.Font = customShader.Font = hdrMul.Font = channels.Font = mipLevel.Font = sliceFace.Font = zoomOption.Font = core.Config.PreferredFont; Icon = global::renderdocui.Properties.Resources.icon; textureList.m_Core = core; textureList.GoIconClick += new EventHandler<GoIconClickEventArgs>(textureList_GoIconClick); UI_SetupToolstrips(); UI_SetupDocks(); UI_UpdateTextureDetails(); statusLabel.Text = ""; zoomOption.SelectedText = ""; mipLevel.Enabled = false; sliceFace.Enabled = false; rangeBlack.ResizeToFit = false; rangeWhite.ResizeToFit = false; PixelPicked = false; mainLayout.Dock = DockStyle.Fill; render.Painting = true; pixelContext.Painting = true; saveTex.Enabled = false; DockHandler.GetPersistStringCallback = PersistString; renderContainer.MouseWheelHandler = render_MouseWheel; render.MouseWheel += render_MouseWheel; renderContainer.MouseDown += render_MouseClick; renderContainer.MouseMove += render_MouseMove; render.KeyHandler = render_KeyDown; pixelContext.KeyHandler = render_KeyDown; rangeHistogram.RangeUpdated += new EventHandler<RangeHistogramEventArgs>(rangeHistogram_RangeUpdated); this.DoubleBuffered = true; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); channels.SelectedIndex = 0; FitToWindow = true; overlay.SelectedIndex = 0; m_Following = new Following(FollowType.OutputColour, 0); texturefilter.SelectedIndex = 0; if (m_Core.LogLoaded) OnLogfileLoaded(); }
/// <summary> /// Adds the following records from the given XML element. /// </summary> /// <example> /// <following> /// <follows personGuid="1dfff821-e97c-4324-9883-cf59b5c5bdd6" followsGuid="1dfff821-e97c-4324-9883-cf59b5c5bdd6" type="person" /> /// </connections> /// </example> /// <param name="elemFollowing">The element with the following XML fragment.</param> /// <param name="rockContext">The rock context.</param> private void AddFollowing( XElement elemFollowing, RockContext rockContext ) { if ( elemFollowing == null ) { return; } FollowingService followingService = new FollowingService( rockContext ); int entityTypeId; int entityId; // Find the type and it's corresponding opportunity and then add a connection request for the given person. foreach ( var element in elemFollowing.Elements( "follows" ) ) { Guid personGuid = element.Attribute( "personGuid" ).Value.Trim().AsGuid(); Guid entityGuid = element.Attribute( "followsGuid" ).Value.Trim().AsGuid(); string entityTypeName = element.Attribute( "type" ).Value.Trim(); // only person (person aliases) are supported now. if ( entityTypeName.ToLower() == "person" ) { entityTypeId = EntityTypeCache.Read( typeof( Rock.Model.PersonAlias ) ).Id; entityId = _peopleAliasDictionary[entityGuid]; } else if ( entityTypeName.ToLower() == "group" ) { entityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Group ) ).Id; entityId = _groupDictionary[entityGuid]; } else { // only person (person aliases) are supported as of now. continue; } Following following = new Following() { PersonAliasId = _peopleAliasDictionary[personGuid], EntityTypeId = entityTypeId, EntityId = entityId, CreatedByPersonAliasId = _peopleAliasDictionary[personGuid], CreatedDateTime = RockDateTime.Now, ModifiedDateTime = RockDateTime.Now, ModifiedByPersonAliasId = _peopleAliasDictionary[personGuid] }; followingService.Add( following ); } }
private void ResetDictionaries() { FollowingDictionary.Clear(); TwitterConnections.Clear(); foreach (Yedda.Twitter.Account a in ClientSettings.AccountsList) { Yedda.Twitter TwitterConn = new Yedda.Twitter(); TwitterConn.AccountInfo.ServerURL = a.ServerURL; TwitterConn.AccountInfo.UserName = a.UserName; TwitterConn.AccountInfo.Password = a.Password; TwitterConn.AccountInfo.Enabled = a.Enabled; TwitterConnections.Add(TwitterConn); Following f = new Following(TwitterConn); FollowingDictionary.Add(TwitterConn, f); } SetConnectedMenus(); Manager = new TimelineManagement(); Manager.Progress += new TimelineManagement.delProgress(Manager_Progress); Manager.CompleteLoaded += new TimelineManagement.delComplete(Manager_CompleteLoaded); Manager.Startup(TwitterConnections); Manager.FriendsUpdated += new TimelineManagement.delFriendsUpdated(Manager_FriendsUpdated); Manager.MessagesUpdated += new TimelineManagement.delMessagesUpdated(Manager_MessagesUpdated); foreach (Following f in FollowingDictionary.Values) { f.LoadFromTwitter(); } }
/// <summary> /// Gets the suggestions. /// </summary> /// <param name="followingSuggestionType">Type of the following suggestion.</param> /// <param name="followerPersonIds">The follower person ids.</param> /// <returns></returns> public override List<PersonEntitySuggestion> GetSuggestions( FollowingSuggestionType followingSuggestionType, List<int> followerPersonIds ) { var suggestions = new List<PersonEntitySuggestion>(); var personAliasEntityType = EntityTypeCache.Read( typeof( Rock.Model.PersonAlias ) ); bool isAutoFollow = GetAttributeValue( followingSuggestionType, "AutoFollow" ).AsBoolean(); // Get the grouptype guid Guid? groupTypeGuid = GetAttributeValue( followingSuggestionType, "GroupType" ).AsGuidOrNull(); if ( groupTypeGuid.HasValue ) { using ( var rockContext = new RockContext() ) { var groupMemberService = new GroupMemberService( rockContext ); var personAliasService = new PersonAliasService( rockContext ); // Get all the groupmember records for any follower and the selected group type var followers = groupMemberService.Queryable().AsNoTracking() .Where( m => m.GroupMemberStatus == GroupMemberStatus.Active && m.Group != null && m.Group.IsActive && m.Group.GroupType.Guid.Equals( groupTypeGuid.Value ) && followerPersonIds.Contains( m.PersonId ) ); // If a specific group or security role was specifed, limit groupmembers to only those of the selected group Guid? groupGuid = GetAttributeValue( followingSuggestionType, "Group" ).AsGuidOrNull(); if ( !groupGuid.HasValue ) { groupGuid = GetAttributeValue( followingSuggestionType, "SecurityRole" ).AsGuidOrNull(); } if ( groupGuid.HasValue ) { followers = followers.Where( m => m.Group.Guid.Equals( groupGuid.Value ) ); } // If a specific role for the follower was specified, limit groupmembers to only those with the selected role Guid? followerRoleGuid = GetAttributeValue( followingSuggestionType, "FollowerGroupType" ).AsGuidOrNull(); if ( followerRoleGuid.HasValue ) { followers = followers.Where( m => m.GroupRole.Guid.Equals( followerRoleGuid.Value ) ); } // Run the query to get all the groups that follower is a member of with selected filters var followerPersonGroup = followers .Select( f => new { f.PersonId, f.GroupId } ) .ToList(); // Get a unique list of any of the groups that followers belong to var followedGroupIds = followerPersonGroup .Select( f => f.GroupId ) .Distinct() .ToList(); // Start building query to get the people to follow from any group that contains a follower var followed = groupMemberService .Queryable().AsNoTracking() .Where( m => followedGroupIds.Contains( m.GroupId ) ); // If a specific role for the people being followed was specified, limit the query to only those with the selected role Guid? followedRoleGuid = GetAttributeValue( followingSuggestionType, "FollowedGroupType" ).AsGuidOrNull(); if ( followedRoleGuid.HasValue ) { followed = followed.Where( m => m.GroupRole.Guid.Equals( followedRoleGuid.Value ) ); } // Get all the people in any of the groups that contain a follower var followedPersonGroup = followed .Select( f => new { f.PersonId, f.GroupId } ) .ToList(); // Get distinct list of people var followedPersonIds = followedPersonGroup .Select( f => f.PersonId ) .Distinct() .ToList(); // Build a dictionary of the personid->personaliasid var personAliasIds = new Dictionary<int, int>(); personAliasService.Queryable().AsNoTracking() .Where( a => followedPersonIds.Contains( a.PersonId ) && a.PersonId == a.AliasPersonId ) .ToList() .ForEach( a => personAliasIds.AddOrIgnore( a.PersonId, a.Id ) ); // Loop through each follower/group combination foreach ( var followedGroup in followerPersonGroup ) { // Loop through the other people in that group foreach ( int followedPersonId in followedPersonGroup .Where( f => f.GroupId == followedGroup.GroupId && f.PersonId != followedGroup.PersonId ) .Select( f => f.PersonId ) ) { // If the person has a valid personalias id if ( personAliasIds.ContainsKey( followedPersonId ) ) { if ( !isAutoFollow ) { // add them to the list of suggestions suggestions.Add( new PersonEntitySuggestion( followedGroup.PersonId, personAliasIds[followedPersonId] ) ); } else { // auto-add the follow var followingService = new FollowingService( rockContext ); int followerPersonAliasId = personAliasIds[followedGroup.PersonId]; int followeePersonAliasId = personAliasIds[followedPersonId]; // if person is not already following the person bool isFollowing = followingService.Queryable().Where( f => f.EntityTypeId == personAliasEntityType.Id && f.EntityId == followeePersonAliasId && f.PersonAliasId == followerPersonAliasId ).Any(); if ( !isFollowing ) { var following = new Following(); following.EntityTypeId = personAliasEntityType.Id; following.EntityId = personAliasIds[followedPersonId]; following.PersonAliasId = personAliasIds[followedGroup.PersonId]; followingService.Add( following ); rockContext.SaveChanges(); } } } } } } } return suggestions; }
public void OnLogfileLoaded() { var outConfig = new OutputConfig(); outConfig.m_Type = OutputType.TexDisplay; saveTex.Enabled = true; m_Following = new Following(FollowType.RT_UAV, 0); IntPtr contextHandle = pixelContext.Handle; IntPtr renderHandle = render.Handle; m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { m_Output = r.CreateOutput(renderHandle); m_Output.SetPixelContext(contextHandle); m_Output.SetOutputConfig(outConfig); this.BeginInvoke(new Action(UI_CreateThumbnails)); }); m_FSWatcher = new FileSystemWatcher(Core.ConfigDirectory, "*.hlsl"); m_FSWatcher.EnableRaisingEvents = true; m_FSWatcher.Changed += new FileSystemEventHandler(CustomShaderModified); m_FSWatcher.Renamed += new RenamedEventHandler(CustomShaderModified); m_FSWatcher.Created += new FileSystemEventHandler(CustomShaderModified); m_FSWatcher.Deleted += new FileSystemEventHandler(CustomShaderModified); ReloadCustomShaders(""); texturefilter.SelectedIndex = 0; texturefilter.Text = ""; textureList.FillTextureList("", true, true); m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay); }
public TextureViewer(Core core) { m_Core = core; InitializeComponent(); if (SystemInformation.HighContrast) { dockPanel.Skin = Helpers.MakeHighContrastDockPanelSkin(); zoomStrip.Renderer = new ToolStripSystemRenderer(); overlayStrip.Renderer = new ToolStripSystemRenderer(); subStrip.Renderer = new ToolStripSystemRenderer(); rangeStrip.Renderer = new ToolStripSystemRenderer(); channelStrip.Renderer = new ToolStripSystemRenderer(); actionsStrip.Renderer = new ToolStripSystemRenderer(); } m_Goto = new Dialogs.TextureGoto(GotoLocation); textureList.Font = texturefilter.Font = rangeBlack.Font = rangeWhite.Font = customShader.Font = hdrMul.Font = channels.Font = mipLevel.Font = sliceFace.Font = zoomOption.Font = core.Config.PreferredFont; Icon = global::renderdocui.Properties.Resources.icon; textureList.m_Core = core; textureList.GoIconClick += new EventHandler<GoIconClickEventArgs>(textureList_GoIconClick); UI_SetupToolstrips(); UI_SetupDocks(); UI_UpdateTextureDetails(); statusLabel.Text = ""; zoomOption.SelectedText = ""; mipLevel.Enabled = false; sliceFace.Enabled = false; rangeBlack.ResizeToFit = false; rangeWhite.ResizeToFit = false; PixelPicked = false; mainLayout.Dock = DockStyle.Fill; saveTex.Enabled = gotoLocationButton.Enabled = viewTexBuffer.Enabled = false; DockHandler.GetPersistStringCallback = PersistString; renderContainer.MouseWheelHandler = render_MouseWheel; renderContainer.MouseDown += render_MouseClick; renderContainer.MouseMove += render_MouseMove; RecreateRenderPanel(); RecreateContextPanel(); rangeHistogram.RangeUpdated += new EventHandler<RangeHistogramEventArgs>(rangeHistogram_RangeUpdated); this.DoubleBuffered = true; SetStyle(ControlStyles.OptimizedDoubleBuffer, true); channels.SelectedIndex = 0; FitToWindow = true; overlay.SelectedIndex = 0; m_Following = Following.Default; texturefilter.SelectedIndex = 0; }
/// <summary> /// Handles the Click event of the lbUnfollow control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void lbFollow_Click( object sender, EventArgs e ) { // Get the suggestion ids that were selected var itemsSelected = new List<int>(); gSuggestions.SelectedKeys.ToList().ForEach( f => itemsSelected.Add( f.ToString().AsInteger() ) ); // Get the personAlias entity type var personAliasEntityType = EntityTypeCache.Read( typeof( Rock.Model.PersonAlias )); // If we have a valid current person and items were selected if ( personAliasEntityType != null && CurrentPersonAliasId.HasValue && itemsSelected.Any() ) { using ( var rockContext = new RockContext() ) { // Get all the person alias id's that were selected var followingSuggestedService = new FollowingSuggestedService( rockContext ); var selectedPersonAliasIds = followingSuggestedService .Queryable() .Where( f => itemsSelected.Contains( f.Id ) ) .Select( f => f.EntityId ) .Distinct() .ToList(); // Find any of the selected person alias ids that current person is already following var followingService = new FollowingService( rockContext ); var alreadyFollowing = followingService .Queryable() .Where( f => f.EntityTypeId == personAliasEntityType.Id && f.PersonAliasId == CurrentPersonAliasId.Value && selectedPersonAliasIds.Contains( f.EntityId ) ) .Select( f => f.EntityId ) .Distinct() .ToList(); // For each selected person alias id that the current person is not already following foreach ( var personAliasId in selectedPersonAliasIds.Where( p => !alreadyFollowing.Contains( p ) ) ) { // Add a following record var following = new Following(); following.EntityTypeId = personAliasEntityType.Id; following.EntityId = personAliasId; following.PersonAliasId = CurrentPersonAliasId.Value; followingService.Add( following ); } rockContext.SaveChanges(); } } BindGrid(); }