private static void UpdateProjectAndManager(int objectId, int projectId, int managerId) { int oldProjectId = DBEvent.GetProject(objectId); int oldManagerId = DBEvent.GetManager(objectId); if (managerId == 0) // Don't change manager { managerId = oldManagerId; } if (projectId == 0) // Don't change project { projectId = oldProjectId; } if (projectId != oldProjectId || managerId != oldManagerId) { using (DbTransaction tran = DbTransaction.Begin()) { DbCalendarEntry2.UpdateProjectAndManager(objectId, projectId, managerId); // OZ: User Role Addon if (managerId != oldManagerId) { UserRoleHelper.DeleteEventManagerRole(objectId, oldManagerId); UserRoleHelper.AddEventManagerRole(objectId, managerId); } if (projectId != oldProjectId) { ForeignContainerKey.Delete(UserRoleHelper.CreateEventContainerKey(objectId), UserRoleHelper.CreateProjectContainerKey(oldProjectId)); if (projectId > 0) { ForeignContainerKey.Add(UserRoleHelper.CreateEventContainerKey(objectId), UserRoleHelper.CreateProjectContainerKey(projectId)); } } // end OZ if (projectId != oldProjectId) { if (projectId > 0) { SystemEvents.AddSystemEvents(SystemEventTypes.Project_Updated_CalendarEntryList_CalendarEntryAdded, projectId, objectId); } else { SystemEvents.AddSystemEvents(SystemEventTypes.Project_Updated_CalendarEntryList_CalendarEntryDeleted, oldProjectId, objectId); } } if (managerId != oldManagerId) { SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_Manager_ManagerDeleted, objectId, oldManagerId); SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_Manager_ManagerAdded, objectId, managerId); } tran.Commit(); } } }
// 08 Jan 2019 12:00:00 GMT #endregion void Update() { if (addFollowingEventToCal) { addFollowingEventToCal = false; DBEvent toAdd = new DBEvent(0, DateTime.Parse(StartTime), DateTime.Parse(EndTime), "", ""); debugCalendar.Add(toAdd); } if (generateCalWith2DaysAndBuils) { generateCalWith2DaysAndBuils = false; debugCalendar.Clear(); DBEvent toAdd = new DBEvent(0, DateTime.Parse("08 Jan 2019 12:00:00 GMT"), DateTime.Parse("08 Jan 2019 13:00:00 GMT"), "", ""); debugCalendar.Add(toAdd); toAdd = new DBEvent(0, DateTime.Parse("09 Jan 2019 12:00:00 GMT"), DateTime.Parse("09 Jan 2019 13:00:00 GMT"), "", ""); debugCalendar.Add(toAdd); BuildNewCalendarGO(debugCalendar); } if (!buildTheCal) { return; } buildTheCal = false; BuildNewCalendarGO(debugCalendar); }
public Event getEvent(string from, object obj) { DBEvent dBEvent = new DBEvent(); dBEvent.from = from; dBEvent.obj = obj; return(dBEvent); }
public List <DBEvent> LoadEvents() { if (!Directory.Exists(EVPath)) { Directory.CreateDirectory(EVPath); return(null); } string[] files = Directory.GetFiles(EVPath, $"*{EVExtension}", SearchOption.AllDirectories); foreach (var file in files) { Assembly.LoadFile(Path.GetFullPath(file)); if (EventFileLoaded != null) { EventFileLoaded.Invoke(file); } } List <DBEvent> events = new List <DBEvent>(); try { Type interfaceType = typeof(DBEvent); Type[] types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(a => a.GetTypes()) .Where(p => interfaceType.IsAssignableFrom(p) && p.IsClass) .ToArray(); foreach (Type type in types) { try { DBEvent ev = (DBEvent)Activator.CreateInstance(type); events.Add(ev); if (EventLoad != null) { EventLoad.Invoke(type.FullName, true, ev); } } catch (Exception e) { if (EventLoad != null) { EventLoad.Invoke(type.FullName, false, null, e); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } return(events); }
private void OnEventLoaded(string typename, bool success, DBEvent eve, Exception exception) { if (eve != null && success) { eve.Start(client); } if (onEVELoad != null) { onEVELoad.Invoke(typename, success, exception); } }
public static int GetSharingLevel(ObjectTypes ObjectType, int ObjectId) { int UserId = Security.CurrentUser.UserID; int RetVal = -1; switch (ObjectType) { case ObjectTypes.ToDo: RetVal = DBToDo.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Task: RetVal = DBTask.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.CalendarEntry: RetVal = DBEvent.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Issue: RetVal = DBIncident.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Project: RetVal = DBProject.GetSharingLevel(UserId, ObjectId); break; case ObjectTypes.Document: RetVal = DBDocument.GetSharingLevel(UserId, ObjectId); break; default: RetVal = -1; break; } return(RetVal); }
internal static void UpdateProject(int eventId, int projectId, bool checkAccess) { bool update = true; if (checkAccess) { int oldProjectId = DBEvent.GetProject(eventId); if (oldProjectId != projectId && !CalendarEntry.CanChangeProject(eventId)) { throw new AccessDeniedException(); } if (oldProjectId == projectId) { update = false; } } if (update) { UpdateProjectAndManager(eventId, projectId, 0); } }
public LayoutEvent(DBEvent dBEvent) { this.dBEvent = dBEvent; }
private ManagementEvent() { DBEvent BD = new DBEvent(); BD.ReadAllEvent(Events); }
private async Task UpdateFixtures(EPS3838Sport sport) { var sinceKey = $"Fixtures_{(int)sport}"; await using var db = _serviceProvider.CreateScope().ServiceProvider.GetRequiredService <AppDatabase>(); var since = await db.Sinces.FirstOrDefaultAsync(f => f.For == sinceKey); if (since == null) { since = new DBSince { For = sinceKey }; await db.Sinces.AddAsync(since); } var line = await _ps3838Client.FixturesV3Async(sport, since : since.Value); since.Value = line.Last; foreach (var league in line.League) { var existLeague = await db.Leagues.FirstOrDefaultAsync(f => f.Id == league.Id); if (existLeague == null) { existLeague = new DBLeague { Id = league.Id, Name = league.Name, SportId = (int)sport }; await db.Leagues.AddAsync(existLeague); } foreach (var @event in league.Events.Where(w => w.ParentId == null && w.ResultingUnit == EPS3838Unit.Regular)) { var existEvent = await db.Events.FirstOrDefaultAsync(f => f.Id == @event.Id); if (existEvent == null) { var newEvent = new DBEvent { Id = @event.Id, Home = @event.Home, Away = @event.Away, IsLive = @event.LiveStatus == EPS3838LiveStatus.Live, IsOpen = @event.Status != EPS3838EventStatus.Unavailable, StartAt = @event.Starts, LeagueId = existLeague.Id }; await db.Events.AddAsync(newEvent); } else { existEvent.IsLive = @event.LiveStatus == EPS3838LiveStatus.Live; existEvent.IsOpen = @event.Status != EPS3838EventStatus.Unavailable; } } } await db.SaveChangesAsync(); }
/// <summary> /// Constructor to instantiate _DbEvent /// </summary> public EventController() { _DbEvent = new DBEvent(); }
private static void ProcessGlobalSubscription(int hookId, DateTypes dateType, ObjectTypes objectType, int?objectId, Guid?objectUid) { // Формируем список пользователей, связанных с объектом List <int> users = new List <int>(); if (objectType == ObjectTypes.Project) { using (IDataReader reader = DBProject.GetProjectSecurity(objectId.Value)) { while (reader.Read()) { users.Add((int)reader["UserId"]); } } } else if (objectType == ObjectTypes.Task) { using (IDataReader reader = DBTask.GetTaskSecurity(objectId.Value)) { while (reader.Read()) { if ((bool)reader["IsRealTaskResource"] || (bool)reader["IsRealTaskManager"] || (bool)reader["IsCreator"]) { users.Add((int)reader["UserId"]); } } } } else if (objectType == ObjectTypes.ToDo) { using (IDataReader reader = DBToDo.GetToDoSecurity(objectId.Value)) { while (reader.Read()) { users.Add((int)reader["UserId"]); } } } else if (objectType == ObjectTypes.CalendarEntry) { using (IDataReader reader = DBEvent.GetListUsersForEvent(objectId.Value)) { while (reader.Read()) { users.Add((int)reader["UserId"]); } } } else if (objectType == ObjectTypes.Document) { using (IDataReader reader = DBDocument.GetDocumentSecurity(objectId.Value)) { while (reader.Read()) { users.Add((int)reader["UserId"]); } } } else if (objectType == ObjectTypes.Assignment) { AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value); if (entity != null && entity.OwnerDocumentId.HasValue) { using (IDataReader reader = DBDocument.GetDocumentSecurity(entity.OwnerDocumentId.Value)) { while (reader.Read()) { users.Add((int)reader["UserId"]); } } } } // Проверим отсутствие индивидуальной подписки for (int i = 0; i < users.Count; i++) { int userId = users[i]; // O.R. [2010-04-01]: Don't process inactive users if (User.GetUserActivity(userId) != User.UserActivity.Active) { users.RemoveAt(i); i--; } else if (objectId.HasValue) { if (GetSubscriptionType(dateType, userId, objectId.Value) != SubscriptionTypes.Global) { users.RemoveAt(i); i--; } } } // Send Reminder if (users.Count > 0) { SendReminder(dateType, objectType, objectId, objectUid, users); } }
private static void UpdateListResources(int objectId, DataTable items, bool checkAccess) { if (checkAccess) { VerifyCanUpdate(objectId); } ArrayList oldItems = new ArrayList(); using (IDataReader reader = DBEvent.GetListResources(objectId, Security.CurrentUser.TimeZoneId)) { Common.LoadPrincipals(reader, oldItems); } ArrayList add = new ArrayList(); ArrayList del = new ArrayList(); foreach (DataRow row in items.Rows) { int id = (int)row["PrincipalId"]; if (oldItems.Contains(id)) { oldItems.Remove(id); } else { add.Add(id); } } del.AddRange(oldItems); using (DbTransaction tran = DbTransaction.Begin()) { foreach (int id in del) { DBEvent.DeleteResource(objectId, id); // OZ: User Role Addon UserRoleHelper.DeleteEventResourceRole(objectId, id); // SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_ResourceList_AssignmentDeleted, objectId, id); } foreach (DataRow row in items.Rows) { int id = (int)row["PrincipalId"]; bool mustBeConfirmed = (bool)row["MustBeConfirmed"]; bool updated = true; if (add.Contains(id)) { DbCalendarEntry2.ResourceAdd(objectId, id, mustBeConfirmed); if (User.IsExternal(id)) { DBCommon.AddGate((int)OBJECT_TYPE, objectId, id); } } else { updated = (0 < DbCalendarEntry2.ResourceUpdate(objectId, id, mustBeConfirmed)); } // OZ: User Role Addon UserRoleHelper.AddEventResourceRole(objectId, id); // end if (updated) { if (mustBeConfirmed) { SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_ResourceList_RequestAdded, objectId, id); } else { SystemEvents.AddSystemEvents(SystemEventTypes.CalendarEntry_Updated_ResourceList_AssignmentAdded, objectId, id); } } } tran.Commit(); } }