public void Should_Log_EmptyProperties_When_Configured_WhileDeleting() { //arrange EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); GlobalTrackingConfig.TrackEmptyPropertiesOnAdditionAndDeletion = true; var entity = new TrackedModelWithMultipleProperties(); Db.TrackedModelsWithMultipleProperties.Add(entity); Db.SaveChanges(); //act Db.TrackedModelsWithMultipleProperties.Remove(entity); Db.SaveChanges(); //assert entity.AssertAuditForDeletion(Db, entity.Id, null, x => x.Id, x => x.Description, x => x.IsSpecial, x => x.Name, x => x.StartDate, x => x.Value); }
public SkillResult(EachSkillResultServerMessage message, EntityTracker entityRegistry, PlayerTracker playerTracker, SkillDatabase skillDatabase) { Time = message.Time; Amount = message.Amount; IsCritical = message.IsCritical; IsHeal = message.IsHeal; SkillId = message.SkillId; Source = entityRegistry.GetOrPlaceholder(message.Source); Target = entityRegistry.GetOrPlaceholder(message.Target); var userNpc = UserEntity.ForEntity(Source); var npc = (NpcEntity)userNpc["source"]; var sourceUser = userNpc["root_source"] as UserEntity; // Attribute damage dealt by owned entities to the owner var targetUser = Target as UserEntity; // But don't attribute damage received by owned entities to the owner if (sourceUser != null) { Skill = skillDatabase.Get(sourceUser, message); if (Skill == null && npc != null) { Skill = new UserSkill(message.SkillId, sourceUser.RaceGenderClass, npc.Info.Name); } SourcePlayer = playerTracker.Get(sourceUser.PlayerId); if (Skill == null) { Skill = new UserSkill(message.SkillId, sourceUser.RaceGenderClass, "Unknown"); } } if (targetUser != null) { TargetPlayer = playerTracker.Get(targetUser.PlayerId); } }
public CustomPageMap() { this.ToTable("CustomPage"); this.HasKey(cp => cp.Id); this.Property(b => b.BodyHtml).IsOptional(); this.Property(b => b.DisplayOrder).IsOptional(); this.Property(b => b.IncludeInFooterColumn1).IsOptional(); this.Property(b => b.IncludeInFooterColumn2).IsOptional(); this.Property(b => b.IncludeInFooterColumn3).IsOptional(); this.Property(b => b.IncludeInFooterMenu).IsOptional(); this.Property(b => b.IncludeInTopMenu).IsOptional(); this.Property(b => b.MetaDescription).IsOptional(); this.Property(b => b.MetaKeywords).IsOptional(); this.Property(b => b.MetaTitle).IsOptional(); this.Property(b => b.Name).IsRequired(); this.Property(b => b.PermissionOriented).IsOptional(); this.Property(b => b.PermissionRecordId).IsOptional(); this.Property(b => b.SystemName).IsOptional(); this.Property(b => b.TemplateId).IsRequired(); this.Property(b => b.Url).IsOptional(); // Relationships this.HasRequired(temp => temp.Template) .WithMany() .HasForeignKey(temp => temp.TemplateId); this.HasRequired(cust => cust.User) .WithMany() .HasForeignKey(cust => cust.UserId); this.HasOptional(cust => cust.PermissionRecord) .WithMany() .HasForeignKey(cust => cust.PermissionRecordId); EntityTracker.TrackAllProperties <CustomPage>().Except(x => x.User).And(x => x.PermissionRecord).And(x => x.ModifiedOn).And(x => x.CreatedOn); }
public void CanRaiseDeleteEvent() { using (TestTrackerContext context = GetNewContextInstance()) { EntityTracker.TrackAllProperties <NormalModel>(); bool eventRaised = false; context.OnAuditLogGenerated += (sender, args) => { NormalModel eventEntity = args.Entity as NormalModel; if (args.Log.EventType == EventType.Deleted && args.Log.TypeFullName == typeof(NormalModel).FullName && eventEntity != null) { eventRaised = true; } }; NormalModel existingEntity = ObjectFactory .Create <NormalModel>(save: true, testDbContext: context); context.NormalModels.Remove(existingEntity); context.SaveChanges(); //assert Assert.IsTrue(eventRaised); existingEntity.AssertAuditForDeletion(context, existingEntity.Id, null, x => x.Description, x => x.Id); } }
public void should_be_able_to_delete() { EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); TrackedModelWithMultipleProperties existingModel = GetDisconnectedExistingComplexModel(); TestTrackerContext newContextInstance = GetNewContextInstance(); var newModel = new TrackedModelWithMultipleProperties { Id = existingModel.Id }; newContextInstance.TrackedModelsWithMultipleProperties.Attach(newModel); newContextInstance.Entry(newModel).State = EntityState.Deleted; newContextInstance.SaveChanges(); existingModel.AssertAuditForDeletion(newContextInstance, newModel.Id, null, model => model.Id, model => model.IsSpecial, model => model.Name, model => model.StartDate, model => model.Value, model => model.Description ); }
private CustomerCaseServiceResponse SaveCaseStatus(int supplierId, int customerId, int departmentId, Guid userId, bool supplierEmployeeLimitForOrder, Guid orderId) { CustomerCase @case = new CustomerCase { ForSupplierId = supplierId, FromCustomerId = customerId, FromDepartmentId = departmentId, FromUserId = userId, OrderId = orderId, Tracking = EntityTracker.StartTracking(ServiceId) // not directly by user, disputable }; CustomerCaseStatusEntry caseEntry = new CustomerCaseStatusEntry { Status = (supplierEmployeeLimitForOrder) ? CaseStatus.PendingSupplier : CaseStatus.PendingInternal, UserComments = (supplierEmployeeLimitForOrder) ? @"Waiting for Supplier response." : @"Waiting for Support response. Customer-Case has been sent to Support.", Tracking = EntityTracker.StartTracking(ServiceId) // not directly by user, disputable }; @case.CaseHistory.Add(caseEntry); //return CustomerCaseServiceLogic.SaveCustomerCase(work, @case); return(_customerCaseService.SaveCustomerCase(@case)); }
public async Task <EntityTracker> GetEntityTrackerAsync(int companyId, string FinYear) { var finyear = DateTimeUtil.GetIndianFinancialYear(DateTime.Now); var entityTracker = new EntityTracker(); SqlConnection conn = new SqlConnection(ConnectionSettings.ConnectionString); var commandText = string.Format($"SELECT [CompanyId] ,[FinYear] ,[Entity] ,[AvailableNo] FROM [dbo].[EntityTracker] where CompanyId = '{companyId}' "); using (SqlCommand cmd = new SqlCommand(commandText, conn)) { cmd.CommandType = CommandType.Text; conn.Open(); var dataReader = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection); while (dataReader.Read()) { entityTracker.CompanyId = Convert.ToInt32(dataReader["CompanyId"]); entityTracker.FinYear = Convert.ToString(dataReader["FinYear"]); //Enum.TryParse(Convert.ToString(dataReader["Entity"]), out EntityType entityType); //entityTracker.Entity = entityType; //entityTracker.AvailableNo = Convert.ToInt32(dataReader["AvailableNo"]); } conn.Close(); } return(entityTracker); }
public SchoolMap() { this.ToTable("School"); this.HasKey(ui => ui.Id); this.Property(b => b.AcadmicYearId).IsRequired(); this.Property(b => b.AffiliationNumber).IsOptional(); this.Property(b => b.City).IsOptional(); this.Property(b => b.State).IsOptional(); this.Property(b => b.Country).IsOptional(); this.Property(b => b.CoverPictureId).IsOptional(); this.Property(b => b.FacebookLink).IsOptional(); this.Property(b => b.FreelancerLink).IsOptional(); this.Property(b => b.FullName).IsRequired(); this.Property(b => b.GooglePlusLink).IsOptional(); this.Property(b => b.GuruLink).IsOptional(); this.Property(b => b.InstagramLink).IsOptional(); this.Property(b => b.Landmark).IsOptional(); this.Property(b => b.Latitude).IsOptional(); this.Property(b => b.LinkedInLink).IsOptional(); this.Property(b => b.Longitude).IsOptional(); this.Property(b => b.PInterestLink).IsOptional(); this.Property(b => b.ProfilePictureId).IsOptional(); this.Property(b => b.RegistrationNumber).IsOptional(); this.Property(b => b.Street1).IsOptional(); this.Property(b => b.Street2).IsOptional(); this.Property(b => b.TweeterLink).IsOptional(); this.Property(b => b.UpworkLink).IsOptional(); this.Property(b => b.UserName).IsOptional(); this.Property(b => b.ZipCode).IsOptional(); this.Property(b => b.Email).IsRequired(); //relationship this.HasRequired(cust => cust.User).WithMany().HasForeignKey(cust => cust.UserId); EntityTracker.TrackAllProperties <School>().Except(x => x.User).And(x => x.AcadmicYearId).And(x => x.ModifiedOn).And(x => x.CreatedOn); }
public void Can_recognise_global_tracking_indicator_when_enabled() { var options = new DbContextOptionsBuilder <TestTrackerContext>() .UseSqlServer(TestConnectionString) .Options; EntityTracker .TrackAllProperties <POCO>(); POCO model = new POCO { Color = "Red", Height = 67.4, StartTime = new DateTime(2015, 5, 5) }; using (TestTrackerContext ttc = new TestTrackerContext(options)) { ttc.POCOes.Add(model); ttc.SaveChanges(); model.AssertAuditForAddition(ttc, model.Id, null, x => x.Color, x => x.Id, x => x.Height, x => x.StartTime); } }
public static void Destroy(this EntityTracker m, EntityId e) { var idx = e.Index(); m.generations[idx]++; m.free.Enqueue(idx); }
private void Start() { botEntity = GetComponent <BotEntity>(); entityTracker = GetComponent <EntityTracker>(); entityTracker.condition = (entity) => entity.health > 0; entityTracker.targetTeam = GameManager.instance.currentGame.GetTarget(botEntity.owner); }
public void CanSkipTrackingUsingEvent() { using (TestTrackerContext context = GetNewContextInstance()) { EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); bool eventRaised = false; context.OnAuditLogGenerated += (sender, args) => { TrackedModelWithMultipleProperties eventEntity = args.Entity as TrackedModelWithMultipleProperties; if (args.Log.EventType == EventType.Added && args.Log.TypeFullName == typeof(TrackedModelWithMultipleProperties).FullName && eventEntity != null) { eventRaised = true; args.SkipSavingLog = true; } }; TrackedModelWithMultipleProperties entity = ObjectFactory.Create <TrackedModelWithMultipleProperties>(save: true, testDbContext: context); //assert Assert.IsTrue(eventRaised); //make sure log is saved in database entity.AssertNoLogs(context, entity.Id, EventType.Added); } }
public void Can_Override_annotation_based_configuration_for_property() { var model = new TrackedModelWithMultipleProperties { Category = RandomChar, //tracked ->skipped Description = RandomText, //skipped IsSpecial = true, //tracked -> skipped StartDate = new DateTime(2015, 5, 5), //skipped Name = RandomText, //tracked Value = RandomNumber //skipped -> Tracked }; EntityTracker .OverrideTracking <TrackedModelWithMultipleProperties>() //enable vaue .Enable(x => x.Value) //disable for isSpecial .Disable(x => x.IsSpecial) //disable category .Disable(x => x.Category); Db.TrackedModelsWithMultipleProperties.Add(model); string userName = RandomText; Db.SaveChanges(userName); model.AssertAuditForAddition(Db, model.Id, userName, x => x.Id, x => x.Name, x => x.Value); }
public void should_update_with_no_logs() { EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); var entity = ObjectFactory.Create <TrackedModelWithMultipleProperties>(save: true); TrackedModelWithMultipleProperties newEntity = new TrackedModelWithMultipleProperties { Id = entity.Id, Description = entity.Description, IsSpecial = entity.IsSpecial, Name = entity.Name, StartDate = entity.StartDate, Value = entity.Value, Category = entity.Category }; TestTrackerContext newContext2 = GetNewContextInstance(options); newContext2.TrackedModelsWithMultipleProperties.Attach(newEntity); newContext2.Entry(newEntity).State = EntityState.Modified; newContext2.SaveChanges(); newEntity.AssertNoLogs(newContext2, newEntity.Id, EventType.Modified); }
public async Task ShouldAddSingleMetadata_WhenSingleMetadataIsProvided_Async() { var options = new DbContextOptionsBuilder <TestTrackerContext>() .UseSqlServer(TestConnectionString) .Options; using (TestTrackerContext ttc = new TestTrackerContext(options)) { ttc.ConfigureMetadata(m => { m.IpAddress = "192.168.2.23"; }); EntityTracker.TrackAllProperties <POCO>(); POCO entity = new POCO(); ttc.POCOes.Add(entity); await ttc.SaveChangesAsync("bilal"); entity.AssertAuditForAddition(ttc, entity.Id, "bilal", x => x.Color, x => x.Height, x => x.StartTime, x => x.Id); entity.AssertMetadata(ttc, entity.Id, new Dictionary <string, string> { ["IpAddress"] = "192.168.2.23" }); } }
public void Should_Log_EmptyProperties_When_Configured_WhileDeleting() { var options = new DbContextOptionsBuilder <TestTrackerContext>() .UseSqlServer(TestConnectionString) .Options; //arrange EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); GlobalTrackingConfig.TrackEmptyPropertiesOnAdditionAndDeletion = true; var entity = new TrackedModelWithMultipleProperties(); using (TestTrackerContext ttc = new TestTrackerContext(options)) { ttc.TrackedModelWithMultipleProperties.Add(entity); ttc.SaveChanges(); //act ttc.TrackedModelWithMultipleProperties.Remove(entity); ttc.SaveChanges(); //assert entity.AssertAuditForDeletion(ttc, entity.Id, null, x => x.Id, x => x.Description, x => x.IsSpecial, x => x.Name, x => x.StartDate, x => x.Value); } }
public SkillResult(EachSkillResultServerMessage message, EntityTracker entityRegistry, PlayerTracker playerTracker, SkillDatabase skillDatabase) { Time = message.Time; Amount = message.Amount; IsCritical = message.IsCritical; IsHeal = message.IsHeal; SkillId = message.SkillId; Debug.Assert(!message.IsUseless); Source = entityRegistry.GetOrPlaceholder(message.Source); Target = entityRegistry.GetOrPlaceholder(message.Target); var sourceUser = UserEntity.ForEntity(Source); // Attribute damage dealt by owned entities to the owner var targetUser = Target as UserEntity; // But don't attribute damage received by owned entities to the owner if (sourceUser != null) { Skill = skillDatabase.Get(sourceUser, message); SourcePlayer = playerTracker.Get(sourceUser.PlayerId); } if (targetUser != null) { TargetPlayer = playerTracker.Get(targetUser.PlayerId); } }
public void ShouldNotAddMetadata_WhenValueIsNull() { var options = new DbContextOptionsBuilder <TestTrackerContext>() .UseSqlServer(TestConnectionString) .Options; using (TestTrackerContext ttc = new TestTrackerContext(options)) { ttc.ConfigureMetadata(m => { m.IpAddress = "192.168.2.23"; m.Country = null; m.Device = string.Empty; }); EntityTracker.TrackAllProperties <POCO>(); POCO entity = new POCO(); ttc.POCOes.Add(entity); ttc.SaveChanges(); entity.AssertAuditForAddition(ttc, entity.Id, null, x => x.Color, x => x.Height, x => x.StartTime, x => x.Id); entity.AssertMetadata(ttc, entity.Id, new Dictionary <string, string> { ["IpAddress"] = "192.168.2.23", ["Device"] = string.Empty }); } }
public SkillResult(int amount, bool isCritical, bool isHp, bool isHeal, HotDot hotdot, EntityId source, EntityId target, DateTime time, EntityTracker entityRegistry, PlayerTracker playerTracker) { Time = time; Amount = isHp ? Math.Abs(amount) : amount; IsCritical = isCritical; IsHp = isHp; IsHeal = isHeal; SkillId = hotdot.Id; Abnormality = true; Source = entityRegistry.GetOrPlaceholder(source); Target = entityRegistry.GetOrPlaceholder(target); var userNpc = UserEntity.ForEntity(Source); var sourceUser = userNpc["root_source"] as UserEntity; // Attribute damage dealt by owned entities to the owner var targetUser = Target as UserEntity; // But don't attribute damage received by owned entities to the owner var pclass = PlayerClass.Common; if (sourceUser != null) { SourcePlayer = playerTracker.Get(sourceUser.ServerId, sourceUser.PlayerId); pclass = SourcePlayer.RaceGenderClass.Class; } Skill = new UserSkill(hotdot.Id, pclass, hotdot.Name, "DOT", null, hotdot.IconName); if (targetUser != null) { TargetPlayer = playerTracker.Get(targetUser.ServerId, targetUser.PlayerId); } HitDirection = HitDirection.Dot; }
public TeacherExamMap() { this.ToTable("Teacher_Exam"); this.HasKey(b => b.Id); this.Property(b => b.AcadmicYearId).IsRequired(); this.Property(b => b.BreakAllowed).IsOptional(); this.Property(b => b.BreakTime).HasMaxLength(20).IsOptional(); this.Property(b => b.ClassRoomId).IsRequired(); this.Property(b => b.EndDate).IsOptional(); this.Property(b => b.EndTime).HasMaxLength(20).IsOptional(); this.Property(b => b.ExamId).IsRequired(); this.Property(b => b.GradeSystemId).IsOptional(); this.Property(b => b.MarksObtained).IsOptional(); this.Property(b => b.ResultStatusId).IsOptional(); this.Property(b => b.StartDate).IsOptional(); this.Property(b => b.StartTime).HasMaxLength(20).IsOptional(); this.Property(b => b.TeacherId).IsRequired(); this.Property(b => b.PassingMarks).IsOptional(); this.Property(b => b.MaxMarks).IsOptional(); // Relationships this.HasMany(e => e.Comments).WithMany(c => c.TeacherExams).Map(m => m.ToTable("Teacher_Exam_Comment_Map").MapLeftKey("TeacherExamId").MapRightKey("CommentId")); this.HasRequired(ca => ca.Teacher).WithMany(e => e.TeacherExams).HasForeignKey(ca => ca.TeacherId); this.HasRequired(ca => ca.Exam).WithMany(e => e.TeacherExams).HasForeignKey(ca => ca.ExamId); this.HasRequired(ca => ca.ClassRoom).WithMany().HasForeignKey(ca => ca.ClassRoomId); EntityTracker.TrackAllProperties <TeacherExam>().Except(x => x.CreatedOn).And(x => x.ModifiedOn).And(x => x.ClassRoom).And(x => x.Teacher).And(x => x.Exam); }
public void CanRaiseAddEvent() { using (var context = GetNewContextInstance()) { EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); bool eventRaised = false; context.OnAuditLogGenerated += (sender, args) => { if (args.Log.EventType == EventType.Added && args.Log.TypeFullName == typeof(TrackedModelWithMultipleProperties).FullName) { eventRaised = true; } }; var entity = GetObjectFactory <TrackedModelWithMultipleProperties>().Create(false); entity.Description = RandomText; context.TrackedModelsWithMultipleProperties.Add(entity); context.SaveChanges(); //assert Assert.IsTrue(eventRaised); //make sure log is saved in database entity.AssertAuditForAddition(context, entity.Id, null, x => x.Id, x => x.Description); } }
public ProductMap() { this.ToTable("Product"); this.HasKey(pro => pro.Id); this.Property(b => b.Description).IsOptional(); this.Property(b => b.Description).IsOptional(); this.Property(b => b.Name).IsRequired(); this.Property(b => b.VendorId).IsOptional(); this.Property(b => b.MetaDescription).IsOptional(); this.Property(b => b.MetaKeywords).IsOptional(); this.Property(b => b.MetaTitle).IsOptional(); this.Property(b => b.MarkAsNewStartDate).IsOptional(); this.Property(b => b.MarkAsNewEndDate).IsOptional(); this.Property(b => b.MarkAsNew).IsOptional(); this.Property(b => b.IsUpcoming).IsOptional(); this.Property(b => b.DisableBuyButton).IsOptional(); this.Property(b => b.AvailableEndDate).IsOptional(); this.Property(b => b.AvailableStartDate).IsOptional(); this.Property(b => b.AcadmicYearId).IsOptional(); this.Property(b => b.OldPrice).IsOptional(); this.Property(b => b.BasePrice).IsRequired(); this.Property(b => b.Price).IsRequired(); this.Property(b => b.StockQuantity).IsRequired(); // Relationships this.HasMany(pro => pro.Files).WithMany(p => p.Products).Map(m => m.ToTable("Product_File_Map").MapLeftKey("ProductId").MapRightKey("FileId")); this.HasMany(pro => pro.Comments).WithMany(p => p.Products).Map(m => m.ToTable("Product_Comment_Map").MapLeftKey("ProductId").MapRightKey("CommentId")); EntityTracker.TrackAllProperties <Product>().Except(x => x.Pictures).And(x => x.AcadmicYearId).And(x => x.ModifiedOn).And(x => x.CreatedOn); }
public StudentExamMap() { this.ToTable("Student_Exam_Mapping"); this.HasKey(b => b.Id); this.Property(b => b.StudentId).IsRequired(); this.Property(b => b.ExamId).IsRequired(); this.Property(b => b.BreakAllowed).IsOptional(); this.Property(b => b.BreakTime).HasMaxLength(20).IsOptional(); this.Property(b => b.ClassRoomId).IsRequired(); this.Property(b => b.EndDate).IsOptional(); this.Property(b => b.EndTime).HasMaxLength(20).IsOptional(); this.Property(b => b.GradeSystemId).IsOptional(); this.Property(b => b.MarksObtained).IsOptional(); this.Property(b => b.ResultStatusId).IsOptional(); this.Property(b => b.StartDate).IsOptional(); this.Property(b => b.StartTime).HasMaxLength(20).IsOptional(); this.Property(b => b.PassingMarks).IsOptional(); this.Property(b => b.MaxMarks).IsOptional(); this.HasMany(e => e.Comments).WithMany(c => c.StudentExams).Map(m => m.ToTable("Student_Exam_Comment_Map").MapLeftKey("StudentExamId").MapRightKey("CommentId")); this.HasRequired(all => all.Student).WithMany(e => e.StudentExams).HasForeignKey(all => all.StudentId); this.HasRequired(all => all.Exam).WithMany(e => e.StudentExams).HasForeignKey(all => all.ExamId); this.HasRequired(all => all.ClassRoom).WithMany().HasForeignKey(all => all.ClassRoomId); EntityTracker.TrackAllProperties <StudentExam>().Except(x => x.Student).And(x => x.Exam).And(x => x.ClassRoom).And(x => x.CreatedOn).And(x => x.ModifiedOn); }
public void Should_Not_Log_When_Value_Not_changed() { //arrange EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>(); string oldDescription = RandomText; var entity = new TrackedModelWithMultipleProperties() { Description = oldDescription, StartDate = RandomDate, }; Db.TrackedModelsWithMultipleProperties.Add(entity); Db.SaveChanges(); entity.AssertAuditForAddition(Db, entity.Id, null, x => x.Id, x => x.Description, x => x.StartDate); //make change to state Db.Entry(entity).State = EntityState.Modified; Db.SaveChanges(); //make sure there are no unnecessaary logs entity.AssertNoLogs(Db, entity.Id, EventType.Modified); }
public void should_be_able_to_delete() { EntityTracker.TrackAllProperties <TrackedModelWithMultipleProperties>() .Except(x => x.IsSpecial); TrackedModelWithMultipleProperties existingModel = ObjectFactory .Create <TrackedModelWithMultipleProperties>(save: true); var newModel = new TrackedModelWithMultipleProperties { Id = existingModel.Id }; TestTrackerContext newContextInstance = GetNewContextInstance(options); newContextInstance.TrackedModelsWithMultipleProperties.Attach(newModel); newContextInstance.Entry(newModel).State = EntityState.Deleted; newContextInstance.SaveChanges(); existingModel.AssertAuditForDeletion(newContextInstance, newModel.Id, null, model => model.Id, model => model.Name, model => model.StartDate, model => model.Value, model => model.Category, model => model.Description ); }
public PermissionRecordMap() { this.ToTable("Permission"); this.HasKey(per => per.Id); this.Property(b => b.Name).IsRequired(); this.Property(b => b.SystemName).IsOptional(); EntityTracker.TrackAllProperties <PermissionRecord>().Except(x => x.IsSystemDefined).And(x => x.ModifiedOn).And(x => x.CreatedOn); }
public DamageTracker(EntityTracker entityRegistry, PlayerTracker playerTracker, SkillDatabase skillDatabase) { _entityTracker = entityRegistry; _skillDatabase = skillDatabase; _playerTracker = playerTracker; TotalDealt = new SkillStats(); TotalReceived = new SkillStats(); }
private void RemoveFromTracking(EntityProperty prop, EntityTracker tracker) { if (_trackers.Remove(tracker)) { CallRemovedHook(prop, tracker); LogEntity("removed", tracker.Entity); } }
public IPAddressMap() { this.ToTable("IPAddress"); this.HasKey(ip => ip.Id); //relationship EntityTracker.TrackAllProperties <Location>().Except(x => x.User).And(x => x.ModifiedOn).And(x => x.CreatedOn); }
public DivisionMap() { this.ToTable("Division"); this.HasKey(b => b.Id); this.Property(b => b.Description).IsOptional(); this.Property(b => b.Name).IsRequired(); EntityTracker.TrackAllProperties <Division>().Except(x => x.CreatedOn).And(x => x.ModifiedOn); }
private void SendOrderToPrimaryEmail(AspNetUser user, string subject, string body, int caseId, string supplier, List <email_attachment> attachmentList, string channelId, int customerId, int deptId, ICollection <CustomerOrderAttachment> customer_Order_Attachment) { try { Logger.Info(String.Format("Email Sending to {0} with PrimaryEmail {1}", user.FirstName, user.Email)); EmailProvider client = new EmailProvider(channelId); var cwaUrl = ConfigurationManager.AppSettings["ChannelOneLoginUrl"] + channelId; if (channelId == "12") { cwaUrl = ConfigurationManager.AppSettings["ChannelTwoLoginUrl"] + channelId; } var emailContents = new Dictionary <string, string>(); emailContents.Add("SUPPLIER", supplier); emailContents.Add("NAME", user.FirstName + " " + user.LastName); emailContents.Add("URL", cwaUrl); emailContents.Add("TABLEBODY", body); var type = client.GetTemplateType("OfferRequestOrder", user.LanguageCode, Convert.ToInt32(channelId)); var slug = client.GetTemplateName(type); bool sent = false; if (attachmentList != null && attachmentList.ToList().Count > 0) { sent = client.Send(user.Email, emailContents, type, attachmentList); } else { sent = client.Send(user.Email, emailContents, type); } var mail = new MailMessage() { CustomerId = customerId, DepartmentId = deptId, CauseTrackingId = caseId, Kind = MessageKind.Received, ToAddress = user.Email, UserId = user.Id, HideFromUser = true, Tracking = EntityTracker.StartTracking(ServiceId) // not directly by user, disputable }; _mailMessageService.SaveMailMessage(mail, slug, channelId, emailContents); if (attachmentList != null && attachmentList.ToList().Count > 0) { SaveCustomerAttachmentsInMailMessage(customer_Order_Attachment, mail.MessageId); } Logger.Info($"Email Sent to {user.FirstName} with PrimaryEmail {user.Email}"); } catch (Exception ex) { Logger.Error(ex); } }
protected EntityRenderer(EntityWorld entityWorld, Aspect aspect) { _entityWorld = entityWorld; _entityTracker = EntityTracker.FromAspect(aspect); _entityTracker.EntityAdded += this.OnEntityAdded; _entityTracker.EntityRemoved += this.OnEntityRemoved; entityWorld.AddEntityTracker(_entityTracker); }
public void AddTracker(EntityTracker entityTracker) { _entityTrackers.Add(entityTracker); for(int i = 0; i < _entityWorld.AllEntities.Count; i++) { entityTracker.OnEntityAddedToWorld(_entityWorld.AllEntities[i]); } }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemMagicRod() { this.id = "item_magic_rod"; this.name = new string[] { "Magic Rod" }; this.description = new string[] { "Burn, baby burn!" }; this.maxLevel = Item.Level1; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWhileInHole; this.sprite = new Sprite[] { GameData.SPR_ITEM_ICON_MAGIC_ROD }; this.fireTracker = new EntityTracker<MagicRodFire>(2); }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemSeedShooter() { this.id = "item_seed_shooter"; this.name = new string[] { "Seed Shooter" }; this.description = new string[] { "Used to bounce seeds around." }; this.currentAmmo = 0; this.sprite = new Sprite[] { GameData.SPR_ITEM_ICON_SEED_SHOOTER }; this.spriteEquipped = new Sprite[] { GameData.SPR_ITEM_ICON_SEED_SHOOTER_EQUIPPED }; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWhileInHole; this.seedTracker = new EntityTracker<SeedProjectile>(1); }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemSlingshot() { this.id = "item_slingshot"; this.name = new string[] { "Slingshot", "Hyper Slingshot" }; this.description = new string[] { "Used to shoot seeds.", "Shoots in 3 directions." }; this.maxLevel = Item.Level2; this.currentAmmo = 0; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWhileInHole; this.sprite = new Sprite[] { GameData.SPR_ITEM_ICON_SLINGSHOT_1, GameData.SPR_ITEM_ICON_SLINGSHOT_2 }; this.spriteEquipped = new Sprite[] { GameData.SPR_ITEM_ICON_SLINGSHOT_1, GameData.SPR_ITEM_ICON_SLINGSHOT_2_EQUIPPED }; this.seedTracker = new EntityTracker<SeedProjectile>(3); }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemSword() { this.id = "item_sword"; this.name = new string[] { "Wooden Sword", "Noble Sword", "Master Sword" }; this.description = new string[] { "A hero's blade.", "A sacred blade.", "The blade of legends." }; this.maxLevel = Item.Level3; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWhileInHole; this.beamTracker = new EntityTracker<SwordBeam>(1); sprite = new Sprite[] { GameData.SPR_ITEM_ICON_SWORD_1, GameData.SPR_ITEM_ICON_SWORD_2, GameData.SPR_ITEM_ICON_SWORD_3 }; }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemBoomerang() { this.id = "item_boomerang"; this.name = new string[] { "Boomerang", "Magic Boomerang" }; this.description = new string[] { "Always comes back to you.", "A remote-control weapon." }; this.level = 0; this.maxLevel = Item.Level2; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWithSword | ItemFlags.UsableWhileInHole; this.boomerangTracker = new EntityTracker<Boomerang>(1); sprite = new Sprite[] { GameData.SPR_ITEM_ICON_BOOMERANG_1, GameData.SPR_ITEM_ICON_BOOMERANG_2 }; }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemBow() { this.id = "item_bow"; this.name = new string[] { "Wooden Bow", "Wooden Bow", "Wooden Bow" }; this.description = new string[] { "Weapon of a marksman.", "Weapon of a marksman.", "Weapon of a marksman." }; this.maxLevel = Item.Level3; this.currentAmmo = 0; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWithSword | ItemFlags.UsableWhileInHole; this.arrowTracker = new EntityTracker<Arrow>(2); sprite = new Sprite[] { GameData.SPR_ITEM_ICON_BOW, GameData.SPR_ITEM_ICON_BOW, GameData.SPR_ITEM_ICON_BOW }; }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemBombs() { this.id = "item_bombs"; this.name = new string[] { "Bombs", "Bombs", "Bombs" }; this.description = new string[] { "Very explosive.", "Very explosive.", "Very explosive." }; this.maxLevel = Item.Level3; this.currentAmmo = 0; this.bombTracker = new EntityTracker<Bomb>(1); this.flags = ItemFlags.UsableWhileInHole; sprite = new Sprite[] { GameData.SPR_ITEM_ICON_BOMB, GameData.SPR_ITEM_ICON_BOMB, GameData.SPR_ITEM_ICON_BOMB, }; }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public ItemSeedSatchel() { this.id = "item_seed_satchel"; this.name = new string[] { "Seed Satchel", "Seed Satchel", "Seed Satchel" }; this.description = new string[] { "A bag for carrying seeds.", "A bag for carrying seeds.", "A bag for carrying seeds." }; this.maxLevel = Item.Level3; this.currentAmmo = 0; this.flags = ItemFlags.UsableInMinecart | ItemFlags.UsableWhileJumping | ItemFlags.UsableWithSword | ItemFlags.UsableWhileInHole; this.emberSeedTracker = new EntityTracker<Seed>(1); this.scentSeedTracker = new EntityTracker<Seed>(1); this.galeSeedTracker = new EntityTracker<Seed>(1); this.mysterySeedTracker = new EntityTracker<Seed>(1); sprite = new Sprite[] { GameData.SPR_ITEM_ICON_SATCHEL, GameData.SPR_ITEM_ICON_SATCHEL, GameData.SPR_ITEM_ICON_SATCHEL, }; spriteEquipped = new Sprite[] { GameData.SPR_ITEM_ICON_SATCHEL_EQUIPPED, GameData.SPR_ITEM_ICON_SATCHEL_EQUIPPED, GameData.SPR_ITEM_ICON_SATCHEL_EQUIPPED, }; }
public bool RemoveTracker(EntityTracker entityTracker) { return _entityTrackers.Remove(entityTracker); }
static void WriteEntityTree(EntityTracker<AdentureWorksLTDataContext> tracker) { Console.WriteLine("---------------------------------------"); Console.WriteLine("Entity Tree:"); foreach (EntityState entityState in tracker.EntityStates) { Console.WriteLine(entityState.Entity.GetType().Name + ": " + entityState.Status + (entityState.IsRoot?" is Root.":".")); } Console.WriteLine("+++++++++++++++++++++++++++++++++++++++"); }
private void HandleMessageReceived(Message obj) { var message = _messageFactory.Create(obj); if (DamageTracker.IsArchived) { var npcOccupier = message as SNpcOccupierInfo; if (npcOccupier != null) { Entity ent = _entityTracker.GetOrPlaceholder(npcOccupier.NPC); if (ent is NpcEntity) { var npce = ent as NpcEntity; if (npce.Info.Boss && npcOccupier.Target != EntityId.Empty) { CasualMessenger.Instance.ResetPlayerStats(true); //Stop viewing saved encounter on boss aggro } } return; } } _entityTracker?.Update(message); var skillResultMessage = message as EachSkillResultServerMessage; if (skillResultMessage != null) { if (skillResultMessage.IsValid(DamageTracker)) { var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase, null, _abnormalityTracker); CheckUpdate(skillResult); } return; } _playerTracker?.UpdateParty(message); _abnormalityTracker?.Update(message); var despawnNpc = message as SDespawnNpc; if (despawnNpc != null) { Entity ent = _entityTracker.GetOrPlaceholder(despawnNpc.Npc); if (ent is NpcEntity) { var npce = ent as NpcEntity; if (npce.Info.Boss && despawnNpc.Dead && !DamageTracker.IsArchived) { //no need to do something if we didn't count any skill against this boss if (DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Any(x => x.Target == npce)) { DamageTracker.PrimaryTarget = npce; //Name encounter with the last dead boss DamageTracker.IsPrimaryTargetDead = despawnNpc.Dead; //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) exportType = exportType | ExportType.Excel; if (SettingsHelper.Instance.Settings.SiteExport) exportType = exportType | ExportType.Upload; if (exportType != ExportType.None) DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData); if (AutosaveEncounters) ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } } return; } var sLogin = message as LoginServerMessage; if (sLogin != null) { if (_needInit) { Server = BasicTeraData.Servers.GetServer(sLogin.ServerId, Server); _messageFactory.Version = Server.Region; Logger.Info($"Logged in to server {Server.Name}."); _teraData = BasicTeraData.DataForRegion(Server.Region); _entityTracker = new EntityTracker(_teraData.NpcDatabase); _playerTracker = new PlayerTracker(_entityTracker, BasicTeraData.Servers); _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); _entityTracker.Update(message); _needInit = false; } _abnormalityStorage.EndAll(message.Time.Ticks); _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); return; } var cVersion = message as C_CHECK_VERSION; if (cVersion != null) { var opCodeNamer = new OpCodeNamer(Path.Combine(BasicTeraData.ResourceDirectory, $"opcodes/{cVersion.Versions[0]}.txt")); _messageFactory = new MessageFactory(opCodeNamer, Server.Region); return; } }
private void HandleNewConnection(Server server) { Text = $"Damage Meter connected to {server.Name}"; _server = server; _teraData = BasicTeraData.DataForRegion(server.Region); _entityRegistry = new EntityTracker(); _playerTracker = new PlayerTracker(_entityRegistry); _damageTracker = new DamageTracker(_entityRegistry, _playerTracker, _teraData.SkillDatabase); _messageFactory = new MessageFactory(_teraData.OpCodeNamer); }
private void HandleNewConnection(Server server) { Text = string.Format("Damage Meter connected to {0}", server.Name); _server = server; _teraData = _basicTeraData.DataForRegion(server.Region); _entityTracker = new EntityTracker(_teraData.NpcDatabase); _playerTracker = new PlayerTracker(_entityTracker); _damageTracker = new DamageTracker(); _messageFactory = new MessageFactory(_teraData.OpCodeNamer); Logger.Log(Text); }
private void HandleNewConnection(Server server) { Server = server; _teraData = BasicTeraData.DataForRegion(server.Region); _entityTracker = new EntityTracker(); _playerTracker = new PlayerTracker(_entityTracker); _messageFactory = new MessageFactory(_teraData.OpCodeNamer); Reset(null); DamageTracker = DamageTracker ?? new DamageTracker(); Logger.Info($"Connected to server {server.Name}."); }