public async Task <ActionResult <UserActivityType> > PostUserActivityType(UserActivityType userActivityType, [FromRoute] string userId) { _context.UserActivityType.Add(userActivityType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetUserActivityType", new { userId = userId, activityTypeId = userActivityType.UserActivityTypeId }, userActivityType)); }
public override async Task AddUserActivity(Guid Id, UserActivityType userActivityType, DateTime date, Guid userId) { SqlCommandHelper commandHelper = new SqlCommandHelper(_connectionString); SqlParameter[] parameters = new SqlParameter[4] { new SqlParameter("@Id", System.Data.SqlDbType.UniqueIdentifier) { Value = Id }, new SqlParameter("@userActivityTypeId", System.Data.SqlDbType.Int) { Value = (int)userActivityType }, new SqlParameter("@date", System.Data.SqlDbType.SmallDateTime) { Value = date }, new SqlParameter("@userId", System.Data.SqlDbType.UniqueIdentifier) { Value = userId }, }; await commandHelper.ExecuteNonQueryAsync(_cmdText, false, parameters); }
public async Task <IActionResult> PutUserActivityType(int id, UserActivityType userActivityType) { if (id != userActivityType.UserActivityTypeId) { return(BadRequest()); } _context.Entry(userActivityType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserActivityTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ActivityType> > PostActivityType(ActivityTypeDto activityTypeDto, [FromRoute] string userId) { var activityType = new ActivityType(); activityType.ActivityTypeName = activityTypeDto.ActivityTypeName; _context.ActivityType.Add(activityType); await _context.SaveChangesAsync(); var userActivityType = new UserActivityType(); userActivityType.TimeFrom = activityTypeDto.TimeFrom; userActivityType.TimeTo = activityTypeDto.TimeTo; userActivityType.ActivityType = activityType; userActivityType.ActivityTypeId = activityType.ActivityTypeId; var user = _context.User.Where(r => r.UserId == Int32.Parse(userId)).FirstOrDefault(); userActivityType.User = user; userActivityType.UserId = user.UserId; _context.UserActivityType.Add(userActivityType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetActivityType", new { userId = userId, id = activityType.ActivityTypeId }, activityType)); }
public static UserActivityDto ToUserActivityDto(this StockEntity entity, UserActivityType activityType) { var dto = new UserActivityDto { EntityID = entity.ID, Type = activityType, EntityName = ObjectContext.GetObjectType(entity.GetType()).BaseType?.Name }; switch (activityType) { case UserActivityType.Creation: dto.DateTime = entity.CreatedDate; break; case UserActivityType.Updating: dto.DateTime = entity.ModifiedDate; break; case UserActivityType.Deletion: if (entity.DeletedDate != null) { dto.DateTime = entity.DeletedDate.Value; } break; default: throw new ArgumentException(nameof(activityType)); } return(dto); }
public static void SetUserActivity(UserActivityType ut, string message) { using (var db = new CarDB()) { var ua = new UserActivity(); ua.Description = message; ua.UserId = Program.User.Id; ua.UserActivityType = ut; } }
public static void SetUserActivity(UserActivityType ut, string message) { //using (var db = new CarManagementDB()) //{ // var ua = new UserActivity(); // ua.Description = message; // ua.UserId = Program.User.Id; // ua.UserActivityType = ut; //} }
// --- /// <summary> /// Persist user activity record /// </summary> public static UserActivity CreateUserActivity(DAL.Models.Identity.User user, UserActivityType type, string comment, string ip, string agent, Locale locale) { return(new UserActivity() { UserId = user.Id, Ip = ip, Agent = agent, Type = type.ToString().ToLowerInvariant(), Comment = comment, TimeCreated = DateTime.UtcNow, Locale = locale, }); }
// Token: 0x06000B8F RID: 2959 RVA: 0x0002CBB8 File Offset: 0x0002ADB8 internal static void GenerateMessageNotDeliveredPayload(InstantMessageNotifier notifier, string methodName, int conversationId, Exception exception) { string arg = string.Empty; if (exception != null && exception.Message != null) { arg = exception.Message; } ExTraceGlobals.InstantMessagingTracer.TraceError <string, string>(0L, "{0} failed. {1}", methodName, arg); UserActivityType alertType = UserActivityType.FailedDelivery; InstantMessagingException ex = exception as InstantMessagingException; if (ex != null && ex.SubCode == 504) { alertType = UserActivityType.DeliveryTimeout; } InstantMessagePayloadUtilities.GenerateInstantMessageAlertPayload(notifier, conversationId, alertType); }
public override int GetHashCode() { int hash = 1; if (UserId.Length != 0) { hash ^= UserId.GetHashCode(); } if (UserActivityType != 0) { hash ^= UserActivityType.GetHashCode(); } if (System.Length != 0) { hash ^= System.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Gets the contacts by activity. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="moduleName">Name of the module.</param> /// <param name="activityName">Name of the activity.</param> /// <param name="contactIDs">The contact i ds.</param> /// <param name="sort">The sort.</param> /// <param name="accountId">The account identifier.</param> /// <returns></returns> public IList <int> GetContactsByActivity(int userId, AppModules moduleName, UserActivityType activityName, int[] contactIDs, string sort, int accountId) { var db = ObjectContextFactory.Create(); IList <int> activities = new List <int>(); /*For Recently Updated */ if (sort == "1") { activities = db.UserActivitiesLog .Where(c => c.UserID == userId && c.AccountID == accountId && c.ModuleID == (byte)moduleName && c.UserActivityID == (byte)activityName && c.AccountID == accountId). Join(db.Contacts, u => u.EntityID, c => c.ContactID, (u, c) => new { u.EntityID, u.LogDate, c.IsDeleted, c.LastUpdatedOn, c.AccountID }) .Where(i => i.IsDeleted == false && i.AccountID == accountId).OrderByDescending(u => u.LastUpdatedOn).Take(1000).Select(i => i.EntityID).ToList(); } /*For Full Name */ else if (sort == "2") { activities = db.UserActivitiesLog .Where(c => c.UserID == userId && c.AccountID == accountId && c.ModuleID == (byte)moduleName && c.UserActivityID == (byte)activityName && c.AccountID == accountId). Join(db.Contacts, u => u.EntityID, c => c.ContactID, (u, c) => new { u.EntityID, u.LogDate, c.IsDeleted, name = c.FirstName + " " + c.LastName, c.AccountID }) .Where(i => i.IsDeleted == false && i.AccountID == accountId).OrderBy(u => u.name).Take(1000).Select(i => i.EntityID).ToList(); } /*For Company Name */ else if (sort == "3") { activities = db.UserActivitiesLog .Where(c => c.UserID == userId && c.AccountID == accountId && c.ModuleID == (byte)moduleName && c.UserActivityID == (byte)activityName && c.AccountID == accountId). Join(db.Contacts, u => u.EntityID, c => c.ContactID, (u, c) => new { u.EntityID, u.LogDate, c.IsDeleted, c.Company, c.AccountID }) .Where(i => i.IsDeleted == false && i.AccountID == accountId).OrderBy(u => u.Company).Take(1000).Select(i => i.EntityID).ToList(); } /*For Recently Viewed */ else { activities = db.UserActivitiesLog .Where(c => c.UserID == userId && c.AccountID == accountId && c.ModuleID == (byte)moduleName && c.UserActivityID == (byte)activityName && c.AccountID == accountId). Join(db.Contacts, u => u.EntityID, c => c.ContactID, (u, c) => new { u.EntityID, u.LogDate, c.IsDeleted, c.AccountID }) .Where(i => i.IsDeleted == false && i.AccountID == accountId).OrderByDescending(u => u.LogDate).Take(1000).Select(i => i.EntityID).ToList(); } var recentlyViewedContactIds = activities.Select(u => u).GroupBy(g => g).Select(f => f.First()).ToList(); if (sort == "") { Logger.Current.Informational("RecentlyViewed Contacts Ids: " + recentlyViewedContactIds.Count()); } else if (sort == "1") { Logger.Current.Informational("RecentlyUpdated Contacts Ids: " + recentlyViewedContactIds.Count()); } else if (sort == "2") { Logger.Current.Informational("FullName Contacts Ids: " + recentlyViewedContactIds.Count()); } else if (sort == "3") { Logger.Current.Informational("Company Contacts Ids: " + recentlyViewedContactIds.Count()); } if (contactIDs != null) { recentlyViewedContactIds = recentlyViewedContactIds.Where(p => contactIDs.Contains(p)).ToList(); } return(recentlyViewedContactIds); }
/// <summary> /// Inserts the contact read activity. /// </summary> /// <param name="entityId">The entity identifier.</param> /// <param name="entityName">Name of the entity.</param> /// <param name="userId">The user identifier.</param> /// <param name="module">The module.</param> /// <param name="activityName">Name of the activity.</param> /// <param name="accountId">The account identifier.</param> public void InsertContactReadActivity(int entityId, string entityName, int userId, AppModules module, UserActivityType activityName, int accountId) { var db = ObjectContextFactory.Create(); UserActivityLogsDb userActivityLog = new UserActivityLogsDb() { EntityID = entityId, EntityName = entityName, LogDate = DateTime.Now.ToUniversalTime(), ModuleID = (byte)module, UserActivityID = (byte)activityName, UserID = userId, AccountID = accountId }; db.UserActivitiesLog.Add(userActivityLog); db.SaveChanges(); }
/// <summary> /// Inserts the change owner activity. /// </summary> /// <param name="entityId">The entity identifier.</param> /// <param name="userId">The user identifier.</param> /// <param name="module">The module.</param> /// <param name="activityType">Type of the activity.</param> public void InsertChangeOwnerActivity(int entityId, int?userId, AppModules module, UserActivityType activityType) { var db = ObjectContextFactory.Create(); UserActivityLogsDb activityLog = new UserActivityLogsDb() { EntityID = entityId, LogDate = DateTime.Now.ToUniversalTime(), UserID = userId, ModuleID = (byte)module, UserActivityID = (byte)activityType }; db.UserActivitiesLog.Add(activityLog); db.SaveChanges(); }
/// <summary> /// 初始化经验值计算器实例 /// </summary> /// <param name="userID"></param> /// <param name="activityType"></param> public EmpiricalCalculator(long userID, UserActivityType activityType) { this._userID = userID; this._activityType = activityType; }
public abstract Task AddUserActivity(Guid Id, UserActivityType userActivityType, DateTime date, Guid userId);
// Token: 0x06000B90 RID: 2960 RVA: 0x0002CC15 File Offset: 0x0002AE15 internal static void GenerateMessageNotDeliveredPayload(InstantMessageNotifier notifier, string methodName, int chatId, UserActivityType alertType) { ExTraceGlobals.InstantMessagingTracer.TraceError <string, UserActivityType>(0L, "{0} failed. {1}", methodName, alertType); InstantMessagePayloadUtilities.GenerateInstantMessageAlertPayload(notifier, chatId, alertType); }
// Token: 0x06000B91 RID: 2961 RVA: 0x0002CC32 File Offset: 0x0002AE32 internal static void GenerateInstantMessageAlertPayload(InstantMessageNotifier notifier, int chatId, UserActivityType alertType) { InstantMessagePayloadUtilities.GenerateInstantMessageAlertPayload(notifier, chatId, alertType, null); }
/// <summary> /// 初始化积分计算器实例 /// </summary> /// <param name="userID"></param> /// <param name="activityType"></param> public PointCalculator(long userID, UserActivityType activityType) { this._userID = userID; this._activityType = activityType; }
// Token: 0x06000B92 RID: 2962 RVA: 0x0002CC40 File Offset: 0x0002AE40 internal static void GenerateInstantMessageAlertPayload(InstantMessageNotifier notifier, int chatId, UserActivityType alertType, string imAddress) { if (notifier == null) { ExTraceGlobals.InstantMessagingTracer.TraceError(0L, "InstantMessagePayloadUtilities.GenerateInstantMessageAlertPayload. Notifier is null."); return; } lock (notifier) { notifier.Add(new InstantMessagePayload(InstantMessagePayloadType.UserActivity) { ChatSessionId = new int?(chatId), UserActivity = alertType, SipUri = imAddress }); } notifier.PickupData(); }
protected override void Seed(ApplicationDbContext context) { var type1 = new FoodConsistencyType { Name = "Твердый" }; var type2 = new FoodConsistencyType { Name = "Жидкий" }; var foodConsistencyTypeService = new FoodConsistencyTypeService(context); foodConsistencyTypeService.Add(type1); foodConsistencyTypeService.Add(type2); var fakeFoodCategory = new FoodCategory { DateModification = DateTime.Now, Name = "fake", Image = new byte[] { 3, 3 } }; var foodCategoryService = new FoodCategoryService(context); foodCategoryService.Add(fakeFoodCategory); var fakeDishCategory = new DishCategory { DateModification = DateTime.Now, Name = "fake", Image = new byte[] { 4 } }; var dishCategoryService = new DishCategoryService(context); dishCategoryService.Add(fakeDishCategory); var fakeDish1 = new Dish { Name = "fake1", DishCategory = fakeDishCategory, TotalAmountWater = 1, TotalCarbs = 1, TotalCcal = 1, TotalFat = 1, TotalProteins = 1, TotalSugar = 1 }; var fakeDish2 = new Dish { Name = "fake2", DishCategory = fakeDishCategory, TotalAmountWater = 2, TotalCarbs = 2, TotalCcal = 2, TotalFat = 2, TotalProteins = 2, TotalSugar = 2, IsDeleted = true }; var fakeDish3 = new Dish { Name = "fake3", DishCategory = fakeDishCategory, TotalAmountWater = 3, TotalCarbs = 3, TotalCcal = 3, TotalFat = 3, TotalProteins = 3, TotalSugar = 3 }; var fakeDish4 = new Dish { Name = "fake4", DishCategory = fakeDishCategory, TotalAmountWater = 4, TotalCarbs = 4, TotalCcal = 4, TotalFat = 4, TotalProteins = 4, TotalSugar = 4 }; var fakeDish5 = new Dish { Name = "fake5", DishCategory = fakeDishCategory, TotalAmountWater = 5, TotalCarbs = 5, TotalCcal = 5, TotalFat = 5, TotalProteins = 5, TotalSugar = 5 }; var dishService = new DishService(context); dishService.Add(fakeDish1); dishService.Add(fakeDish2); dishService.Add(fakeDish3); dishService.Add(fakeDish4); dishService.Add(fakeDish5); var fakeFood1 = new Food { Name = "fake1", FoodCategory = fakeFoodCategory, FoodConsistencyType = type1, Image = new byte[] { 1 }, AmountOfWater = 1, Carbs = 1, Ccal = 1, Fat = 1, Proteins = 1, Sugar = 1 }; var fakeFood2 = new Food { Name = "fake2", FoodCategory = fakeFoodCategory, FoodConsistencyType = type1, Image = new byte[] { 3 }, AmountOfWater = 2, Carbs = 2, Ccal = 2, Fat = 2, Proteins = 2, Sugar = 2 }; var foodService = new FoodService(context); foodService.Add(fakeFood1); foodService.Add(fakeFood2); var fakePortion1 = new PortionFood { Dish = fakeDish1, Food = fakeFood1, Amount = 3 }; var fakePortion2 = new PortionFood { Dish = fakeDish1, Food = fakeFood2, Amount = 5 }; var portionFoodService = new PortionFoodService(context); portionFoodService.Add(fakePortion1); portionFoodService.Add(fakePortion2); var fakeActivityType = new UserActivityType() { Description = "fake", Name = "fake" }; var fakeActivityTypeService = new UserActivityTypeService(context); fakeActivityTypeService.Add(fakeActivityType); RoleManager <IdentityRole> roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); ApplicationUserManager userManager = new ApplicationUserManager(new UserStore <ApplicationUser>(context)); roleManager.Create(new IdentityRole("Admin")); roleManager.Create(new IdentityRole("User")); string adminEmail = "*****@*****.**"; if (userManager.Create(new ApplicationUser() { Email = adminEmail, UserName = "******" }, "bsuirhealthproject").Succeeded == true) { ApplicationUser user = userManager.FindByEmail(adminEmail); userManager.AddToRole(user.Id, "Admin"); userManager.AddToRole(user.Id, "User"); var userService = new UserService(context); userService.Add(new User { DateOfBirth = DateTime.Now, FirstName = "fake", IdActivityType = fakeActivityType.Id, IdUserCredential = user.Id, LastName = "fake", Sex = false }); } }