private string TransformCatalogEvent(CheckpointTag position, ResolvedEvent resolvedEvent) { if (_definesCatalogTransform) { return(_container.TransformCatalogEvent(position, resolvedEvent)); } return(SystemEventTypes.StreamReferenceEventToStreamId(resolvedEvent.EventType, resolvedEvent.Data)); }
private string ResolveEventText(string link) { var stream = SystemEventTypes.StreamReferenceEventToStreamId(SystemEventTypes.LinkTo, link); var eventNumber = SystemEventTypes.EventLinkToEventNumber(link); return(_streams[stream][eventNumber].EventType + ":" + Encoding.UTF8.GetString(_streams[stream][eventNumber].Data)); }
public void BeginRead() { _streamId = SystemEventTypes.StreamReferenceEventToStreamId(_event.EventType, _event.Data); var requestId = _ioDispatcher.ReadBackward( SystemStreams.MetastreamOf(_streamId), -1, 1, false, Reader.ReadAs, ReadCompleted); if (requestId != Guid.Empty) { Reader._activeReads.Add(requestId); } }
private void EnqueueStreamForProcessing(EventStore.Core.Data.ResolvedEvent resolvedEvent) { //TODO: consider catalog referring to earlier written events (should we check here?) if (resolvedEvent.OriginalEvent.LogPosition > _limitingCommitPosition) { return; } var streamId = SystemEventTypes.StreamReferenceEventToStreamId(resolvedEvent.Event.EventType, resolvedEvent.Event.Data); _pendingStreams.Enqueue(streamId); _catalogNextSequenceNumber = resolvedEvent.OriginalEventNumber; }
internal static AlertVariable[] GetVariables(SystemEventTypes eventType) { ObjectTypes objectType = (ObjectTypes)DBSystemEvents.GetObjectType((int)eventType); ObjectTypes relObjectType = (ObjectTypes)DBSystemEvents.GetRelObjectType((int)eventType); ArrayList vars = new ArrayList(); GetVariables(eventType, objectType, false, vars); GetVariables(eventType, relObjectType, true, vars); return(vars.ToArray(typeof(AlertVariable)) as AlertVariable[]); }
/// <summary> /// Exits windows (and tries to enable any required access rights, if necesarry). /// </summary> /// <param name="how">One of the RestartOptions values that specifies how to exit windows.</param> /// <param name="force">True if the exit has to be forced, false otherwise.</param> /// <exception cref="PrivilegeException">There was an error while requesting a required privilege.</exception> /// <exception cref="PlatformNotSupportedException">The requested exit method is not supported on this platform.</exception> public static void SystemEvent(SystemEventTypes how, bool force) { switch (how) { case SystemEventTypes.Suspend: SuspendSystem(false, force); break; case SystemEventTypes.Hibernate: SuspendSystem(true, force); break; default: ExitWindows((int)how, force); break; } }
protected override void ProcessEvent() { var channelGroup = _slaves.Channels["slave"]; var resolvedEvent = _message.Data; var streamId = SystemEventTypes.StreamReferenceEventToStreamId(resolvedEvent.EventType, resolvedEvent.Data); _loadBalancer.ScheduleTask( streamId, (streamId_, workerIndex) => { var channel = channelGroup[workerIndex]; _spoolRequestId = _spoolProcessingResponseDispatcher.PublishSubscribe( channel.PublishEnvelope, new ReaderSubscriptionManagement.SpoolStreamReading( channel.SubscriptionId, Guid.NewGuid(), streamId_, resolvedEvent.PositionSequenceNumber, _limitingCommitPosition), this); }); }
private static void CollectAllObjectSubscribers(SystemEventTypes eventType, ObjectTypes objectType, int?objectId, Guid?objectUid, ArrayList processedUsers, ArrayList infoRecipients) { using (IDataReader reader = GetAllObjectSubscribersReader(eventType, objectType, objectId, objectUid)) { if (reader != null) { while (reader.Read()) { int userId = (int)reader["UserId"]; if (!processedUsers.Contains(userId)) { processedUsers.Add(userId); infoRecipients.Add(userId); } } } } }
/// <summary> /// UserId, Email /// </summary> /// <returns></returns> public static IDataReader GetAllObjectSubscribersReader(SystemEventTypes eventTypeId, ObjectTypes objectType, int?objectId, Guid?objectUid) { switch (objectType) { case ObjectTypes.ToDo: return(DBSystemEvents.GetSubscribersForToDo((int)eventTypeId, objectId.Value, true, true, true)); case ObjectTypes.Document: return(DBSystemEvents.GetSubscribersForDocument((int)eventTypeId, objectId.Value, true, true, true)); case ObjectTypes.Issue: return(DBSystemEvents.GetSubscribersForIssue((int)eventTypeId, objectId.Value, true, true, true, true, true, true)); case ObjectTypes.List: return(DBSystemEvents.GetSubscribersForList((int)eventTypeId, objectId.Value)); case ObjectTypes.Project: return(DBSystemEvents.GetSubscribersForProject((int)eventTypeId, objectId.Value, true, true, true, true, true, true)); case ObjectTypes.Task: return(DBSystemEvents.GetSubscribersForTask((int)eventTypeId, objectId.Value, true, true, true)); case ObjectTypes.CalendarEntry: return(DBSystemEvents.GetSubscribersForCalendarEntry((int)eventTypeId, objectId.Value, true, true, true)); case ObjectTypes.IssueRequest: return(DBSystemEvents.GetSubscribersForPop3MailRequests((int)eventTypeId, objectId.Value)); case ObjectTypes.User: return(DBSystemEvents.GetSubscribersForUser((int)eventTypeId, objectId.Value)); case ObjectTypes.Assignment: return(DBSystemEvents.GetSubscribersForAssignment((int)eventTypeId, objectUid.Value, true, true, true)); default: return(null); } }
public static void AddSystemEvents(SystemEventTypes eventType, int objectId, Dictionary <string, string> additionalValues) { AddSystemEvents(eventType, objectId, null, -1, null, null, null, additionalValues); }
internal static void GetSystemEventObjectTypes(SystemEventTypes eventType, out ObjectTypes objectType, out ObjectTypes relObjectType) { objectType = (ObjectTypes)DBSystemEvents.GetObjectType((int)eventType); relObjectType = (ObjectTypes)DBSystemEvents.GetRelObjectType((int)eventType); }
public static void AddSystemEvents(SystemEventTypes eventType, Guid objectUid, int relObjectId) { AddSystemEvents(eventType, null, objectUid, relObjectId, null, null, null, null); }
public ResolvedEvent(EventStore.Core.Data.ResolvedEvent resolvedEvent, byte[] streamMetadata) { var positionEvent = resolvedEvent.Link ?? resolvedEvent.Event; _linkOrEventPosition = resolvedEvent.OriginalPosition.GetValueOrDefault(); var @event = resolvedEvent.Event; _positionStreamId = positionEvent.EventStreamId; _positionSequenceNumber = positionEvent.EventNumber; _eventStreamId = @event != null ? @event.EventStreamId : null; _eventSequenceNumber = @event != null ? @event.EventNumber : -1; _resolvedLinkTo = positionEvent != @event; _position = resolvedEvent.OriginalPosition ?? new TFPos(-1, positionEvent.LogPosition); EventId = @event != null ? @event.EventId : Guid.Empty; EventType = @event != null ? @event.EventType : null; IsJson = @event != null && (@event.Flags & PrepareFlags.IsJson) != 0; Timestamp = positionEvent.TimeStamp; //TODO: handle utf-8 conversion exception Data = @event != null && @event.Data != null?Helper.UTF8NoBom.GetString(@event.Data) : null; Metadata = @event != null && @event.Metadata != null?Helper.UTF8NoBom.GetString(@event.Metadata) : null; PositionMetadata = _resolvedLinkTo ? (positionEvent.Metadata != null ? Helper.UTF8NoBom.GetString(positionEvent.Metadata) : null) : null; StreamMetadata = streamMetadata != null?Helper.UTF8NoBom.GetString(streamMetadata) : null; TFPos eventOrLinkTargetPosition; if (_resolvedLinkTo) { Dictionary <string, JToken> extraMetadata = null; if (positionEvent.Metadata != null && positionEvent.Metadata.Length > 0) { //TODO: parse JSON only when unresolved link and just tag otherwise CheckpointTag tag; if (resolvedEvent.Link != null && resolvedEvent.Event == null) { var checkpointTagJson = positionEvent.Metadata.ParseCheckpointTagVersionExtraJson(default(ProjectionVersion)); tag = checkpointTagJson.Tag; extraMetadata = checkpointTagJson.ExtraMetadata; var parsedPosition = tag.Position; eventOrLinkTargetPosition = parsedPosition != new TFPos(long.MinValue, long.MinValue) ? parsedPosition : new TFPos(-1, positionEvent.LogPosition); } else { tag = positionEvent.Metadata.ParseCheckpointTagJson(); var parsedPosition = tag.Position; if (parsedPosition == new TFPos(long.MinValue, long.MinValue) && @event.Metadata.IsValidJson()) { tag = @event.Metadata.ParseCheckpointTagJson(); if (tag != null) { parsedPosition = tag.Position; } } eventOrLinkTargetPosition = parsedPosition != new TFPos(long.MinValue, long.MinValue) ? parsedPosition : new TFPos(-1, resolvedEvent.Event.LogPosition); } } else { eventOrLinkTargetPosition = @event != null ? new TFPos(-1, @event.LogPosition) : new TFPos(-1, positionEvent.LogPosition); } JToken deletedValue; IsLinkToDeletedStreamTombstone = extraMetadata != null && extraMetadata.TryGetValue("$deleted", out deletedValue); if (resolvedEvent.ResolveResult == ReadEventResult.NoStream || resolvedEvent.ResolveResult == ReadEventResult.StreamDeleted || IsLinkToDeletedStreamTombstone) { IsLinkToDeletedStream = true; var streamId = SystemEventTypes.StreamReferenceEventToStreamId( SystemEventTypes.LinkTo, resolvedEvent.Link.Data); _eventStreamId = streamId; } } else { // not a link eventOrLinkTargetPosition = resolvedEvent.OriginalPosition ?? new TFPos(-1, positionEvent.LogPosition); } _eventOrLinkTargetPosition = eventOrLinkTargetPosition; }
internal static Message GetMessage( string subjectTemplate , string bodyTemplate , SystemEventTypes eventType , int? objectId , Guid? objectUid , int relObjectId , int userId ) { ObjectTypes objectType, relObjectType; ArrayList vars = GetEventVariables(eventType, objectId, objectUid, relObjectId, out objectType, out relObjectType); UserInfo ui = new UserInfo(); ui.Load(userId); return GetMessage(subjectTemplate, bodyTemplate, ui, vars, (int)objectType, objectId, objectUid); }
public static bool CheckToDoSubscribtion(SystemEventTypes EventTypeId, int ObjectId, int UserId, bool CheckManagerSubscription, bool CheckResourcesSubscription, bool CheckGlobalSubscription) { return(DBSystemEvents.CheckToDoSubscribtion((int)EventTypeId, ObjectId, UserId, CheckManagerSubscription, CheckResourcesSubscription, CheckGlobalSubscription)); }
public static void AddSystemEvents(SystemEventTypes eventType, int?objectId, Guid?objectUid, int relObjectId, string emailTo, string emailFrom, ArrayList excludeUsers, Dictionary <string, string> additionalValues) { // User can be unregistered int CurrentUserId = -1; if (Security.CurrentUser != null) { CurrentUserId = Security.CurrentUser.UserID; } ObjectTypes objectType, relObjectType; string ObjectTitle = string.Empty; string RelObjectTitle = string.Empty; string XMLData = Alerts2.GetXmlData(eventType, objectId, objectUid, relObjectId, out objectType, out relObjectType, ref ObjectTitle, ref RelObjectTitle, additionalValues); // Здесь будем хранить обработанных пользователей и пользователей, которых не надо обрабатывать ArrayList processedUsers = new ArrayList(); if (CurrentUserId > 0 && !Alerts2.SendToCurrentUser) { processedUsers.Add(CurrentUserId); } // Получатели info-сообщений ArrayList infoRecipients = new ArrayList(); using (DbTransaction tran = DbTransaction.Begin()) { int eventId = DBSystemEvents.AddSystemEvents((int)eventType, objectId, objectUid, ObjectTitle, relObjectId, RelObjectTitle, CurrentUserId, XMLData, DbContext.Current.TransactionId); #region Персональные сообщения if ( eventType == SystemEventTypes.CalendarEntry_Updated_Manager_ManagerAdded || eventType == SystemEventTypes.CalendarEntry_Updated_Manager_ManagerDeleted || eventType == SystemEventTypes.CalendarEntry_Updated_ResourceList_AssignmentAdded || eventType == SystemEventTypes.CalendarEntry_Updated_ResourceList_AssignmentDeleted || eventType == SystemEventTypes.CalendarEntry_Updated_ResourceList_RequestAdded || eventType == SystemEventTypes.Document_Updated_ResourceList_AssignmentAdded || eventType == SystemEventTypes.Document_Updated_ResourceList_AssignmentDeleted || eventType == SystemEventTypes.Document_Updated_ResourceList_RequestAdded || eventType == SystemEventTypes.Issue_Created || eventType == SystemEventTypes.Issue_Updated_Forum_MessageAdded || eventType == SystemEventTypes.Issue_Updated_Manager_ManagerAdded || eventType == SystemEventTypes.Issue_Updated_Manager_ManagerDeleted || eventType == SystemEventTypes.Issue_Updated_ResourceList_AssignmentAdded || eventType == SystemEventTypes.Issue_Updated_ResourceList_AssignmentDeleted || eventType == SystemEventTypes.Issue_Updated_ResourceList_RequestAdded || eventType == SystemEventTypes.Issue_Updated_Responsible_Requested || eventType == SystemEventTypes.Issue_Updated_Responsible_Assigned || eventType == SystemEventTypes.Issue_Updated_Responsible_Resigned || eventType == SystemEventTypes.Issue_Updated_Controller_Assigned || eventType == SystemEventTypes.Issue_Updated_Controller_Resigned || eventType == SystemEventTypes.Project_Updated_ExecutiveManager_ExecutiveManagerAdded || eventType == SystemEventTypes.Project_Updated_ExecutiveManager_ExecutiveManagerDeleted || eventType == SystemEventTypes.Project_Updated_Manager_ManagerAdded || eventType == SystemEventTypes.Project_Updated_Manager_ManagerDeleted || eventType == SystemEventTypes.Project_Updated_SponsorList_SponsorAdded || eventType == SystemEventTypes.Project_Updated_SponsorList_SponsorDeleted || eventType == SystemEventTypes.Project_Updated_StakeholderList_StakeholderAdded || eventType == SystemEventTypes.Project_Updated_StakeholderList_StakeholderDeleted || eventType == SystemEventTypes.Project_Updated_TeamMemberList_TeamMemberAdded || eventType == SystemEventTypes.Project_Updated_TeamMemberList_TeamMemberDeleted || eventType == SystemEventTypes.Todo_Updated_Manager_ManagerAdded || eventType == SystemEventTypes.Todo_Updated_Manager_ManagerDeleted || eventType == SystemEventTypes.Todo_Updated_ResourceList_AssignmentAdded || eventType == SystemEventTypes.Todo_Updated_ResourceList_AssignmentDeleted || eventType == SystemEventTypes.Todo_Updated_ResourceList_RequestAdded || eventType == SystemEventTypes.Task_Updated_ResourceList_AssignmentAdded || eventType == SystemEventTypes.Task_Updated_ResourceList_AssignmentDeleted || eventType == SystemEventTypes.Task_Updated_ResourceList_RequestAdded || eventType == SystemEventTypes.User_Activated || eventType == SystemEventTypes.User_Created || eventType == SystemEventTypes.User_Created_External || eventType == SystemEventTypes.User_Created_Partner || eventType == SystemEventTypes.User_Deleted || eventType == SystemEventTypes.User_Deactivated || eventType == SystemEventTypes.Assignment_Updated_Participant_Assigned || eventType == SystemEventTypes.Assignment_Updated_Participant_Resigned ) { ArrayList users = new ArrayList(); if (objectType == ObjectTypes.User) { users.Add(objectId); } if (relObjectType == ObjectTypes.User) { if (User.IsGroup(relObjectId)) { // this method doesn't return inactive users using (IDataReader reader = SecureGroup.GetListAllUsersInGroup(relObjectId, false)) { while (reader.Read()) { users.Add((int)reader["UserId"]); } } } else { if (User.GetUserActivity(relObjectId) == User.UserActivity.Active) { users.Add(relObjectId); } } } foreach (int userId in users) { if (!processedUsers.Contains(userId)) { AddSystemEventRecipient(eventId, userId, MessageTypes.Resource); processedUsers.Add(userId); } } if (emailTo != null) { AddSystemEventRecipient(eventId, MessageTypes.Resource, emailTo, emailFrom); } } #endregion CollectAllObjectSubscribers(eventType, objectType, objectId, objectUid, processedUsers, infoRecipients); foreach (int userId in infoRecipients) { if ((excludeUsers == null || !excludeUsers.Contains(userId)) && CheckRights(eventType, objectType, relObjectType, objectId, relObjectId, objectUid, userId)) { AddSystemEventRecipient(eventId, userId, MessageTypes.Info); } } _hasNewEvent = true; tran.Commit(); } }
public static void AddSystemEvents(SystemEventTypes eventType, int objectId, string emailTo, string emailFrom) { AddSystemEvents(eventType, objectId, null, -1, emailTo, emailFrom, null, null); }
public static void AddSystemEvents(SystemEventTypes eventType, int objectId, int relObjectId, ArrayList excludeUsers) { AddSystemEvents(eventType, objectId, null, relObjectId, null, null, excludeUsers, null); }
private static void GetVariables(SystemEventTypes eventType, ObjectTypes objectType, bool isRelObject, ArrayList vars) { // Common variables if (!isRelObject) { vars.Add(new AlertVariable(Variable.ServerLink, isRelObject)); vars.Add(new AlertVariable(Variable.PortalLink, isRelObject)); vars.Add(new AlertVariable(Variable.InitiatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.UnsubscribeLink, true, true, isRelObject)); } AlertVariable var; switch (objectType) { case ObjectTypes.CalendarEntry: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); vars.Add(new AlertVariable(Variable.EventType, isRelObject)); if (eventType != SystemEventTypes.CalendarEntry_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.CalendarEntry_Updated_ResourceList_AssignmentDeleted, isRelObject)); } vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.Comment: vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.Document: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.DocumentStatus, isRelObject)); if (eventType != SystemEventTypes.Document_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Document_Updated_ResourceList_AssignmentDeleted, isRelObject)); } vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.File_FileStorage: vars.Add(new AlertVariable(Variable.FileSize, isRelObject)); if (eventType != SystemEventTypes.Todo_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Task_Updated_FileList_FileDeleted && eventType != SystemEventTypes.CalendarEntry_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Project_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Issue_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Document_Updated_FileList_FileDeleted ) { var = new AlertVariable(Variable.Link, true, true, isRelObject); var.disableNoMenu = true; vars.Add(var); } vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.Issue: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.IssueState, isRelObject)); if (eventType != SystemEventTypes.Issue_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Issue_Updated_ResourceList_AssignmentDeleted, isRelObject)); } vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.Ticket, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.IssueBox: vars.Add(new AlertVariable(Variable.Link, true, true, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.IssueRequest: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Email, isRelObject)); if (eventType != SystemEventTypes.IssueRequest_Approved && eventType != SystemEventTypes.IssueRequest_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, true, isRelObject)); } vars.Add(new AlertVariable(Variable.MailBoxLink, true, false)); vars.Add(new AlertVariable(Variable.MailBoxTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.List: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); if (eventType != SystemEventTypes.List_Deleted) { var = new AlertVariable(Variable.Link, true, true, isRelObject); if (eventType == SystemEventTypes.List_Updated_Data) { var.isDataLink = true; } vars.Add(var); } var = new AlertVariable(Variable.ListStatus, isRelObject); var.isResourceVariable = true; vars.Add(var); var = new AlertVariable(Variable.ListType, isRelObject); var.isResourceVariable = true; vars.Add(var); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.Project: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Project_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, false, isRelObject)); } vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.PercentCompleted, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectStatus, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.Task: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Task_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Task_Updated_ResourceList_AssignmentDeleted, isRelObject)); } vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.PercentCompleted, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.ToDo: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Todo_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Todo_Updated_ResourceList_AssignmentDeleted, isRelObject)); } vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.PercentCompleted, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.User: vars.Add(new AlertVariable(Variable.Email, isRelObject)); vars.Add(new AlertVariable(Variable.Login, isRelObject)); vars.Add(new AlertVariable(Variable.Password, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.Link, true, true, isRelObject)); break; case ObjectTypes.Assignment: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Assignment_Deleted) { vars.Add(new AlertVariable(Variable.Link, true, false, isRelObject)); } vars.Add(new AlertVariable(Variable.OwnerLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.OwnerTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Participant, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; } }
private static ArrayList GetEventVariables( SystemEventTypes eventType , int? objectId , Guid? objectUid , int relObjectId , out ObjectTypes objectType , out ObjectTypes relObjectType ) { SystemEvents.GetSystemEventObjectTypes(eventType, out objectType, out relObjectType); AlertVariable[] names = AlertVariable.GetVariables(eventType); // Add common variables ArrayList vars = new ArrayList(); foreach (AlertVariable var in names) { if (!var.isRelObject) { switch (var.name) { case Variable.InitiatedBy: AddVariableInitiatedBy(vars); break; case Variable.ServerLink: vars.Add(new VariableInfo(var, Configuration.ServerLink)); break; case Variable.PortalLink: vars.Add(new VariableInfo(var, Configuration.PortalLink)); break; case Variable.UnsubscribeLink: if (objectId.HasValue) vars.Add(new VariableInfo(var, string.Format("{0}/Directory/Unsubscribe.aspx?EventTypeId={1}&ObjectId={2}", Configuration.PortalLink, (int)eventType, objectId.Value))); else if (objectUid.HasValue) vars.Add(new VariableInfo(var, string.Format("{0}/Directory/Unsubscribe.aspx?EventTypeId={1}&ObjectUid={2}", Configuration.PortalLink, (int)eventType, objectUid.Value))); break; } } } GetObjectVariables(objectType, objectId, objectUid, false, names, vars); if (relObjectType != ObjectTypes.UNDEFINED) { if (relObjectId > 0 || relObjectType == ObjectTypes.User) GetObjectVariables(relObjectType, relObjectId, Guid.Empty, true, names, vars); else { foreach (AlertVariable var in names) { if (!var.isRelObject) vars.Add(new VariableInfo(var, string.Empty)); } } } return vars; }
public static void AddSystemEvents(SystemEventTypes eventType, int objectId) { AddSystemEvents(eventType, objectId, null, -1, null, null, null, null); }
public static void AddSystemEvents(SystemEventTypes eventType, Guid objectUid) { AddSystemEvents(eventType, null, objectUid, -1, null, null, null, null); }
internal static string GetXmlData(SystemEventTypes eventType, int? objectId, Guid? objectUid, int relObjectId, out ObjectTypes objectType, out ObjectTypes relObjectType, ref string objectTitle, ref string relObjectTitle, Dictionary<string, string> additionalValues) { ArrayList vars = GetEventVariables(eventType, objectId, objectUid, relObjectId, out objectType, out relObjectType); StringBuilder sb = new StringBuilder(); XmlTextWriter w = new XmlTextWriter(new StringWriter(sb)); w.WriteStartElement("variables"); foreach (VariableInfo var in vars) { // O.R. [2008-12-08]: Override variables from additionalValues if (additionalValues != null && additionalValues.ContainsKey(var.name)) { var.value = additionalValues[var.name]; } var.Save(w); if (var.name == "Title") objectTitle = var.value; else if (var.name == "RelTitle") relObjectTitle = var.value; } w.WriteEndElement(); return sb.ToString(); }
private static bool CheckRights(SystemEventTypes eventType, ObjectTypes objectType, ObjectTypes relObjectType, int?objectId, int?relObjectId, Guid?objectUid, int userId) { // если нужна дополнительная проверка в зависимости от типа события, то её нужно делать здесь bool retval = false; if (relObjectType == ObjectTypes.File_FileStorage && relObjectId != null) { FileInfo fileInfo = null; //Получаем оригинальный файл using (IDataReader reader = Mediachase.IBN.Database.ControlSystem.DBFile.GetById(0, relObjectId.Value)) { if (reader.Read()) { fileInfo = new Mediachase.IBN.Business.ControlSystem.FileInfo(reader); } } if (fileInfo != null) { return(CheckFileStorageRight(fileInfo, "Read", userId)); } } switch (objectType) { case ObjectTypes.ToDo: retval = ToDo.CanRead(objectId.Value, userId); break; case ObjectTypes.CalendarEntry: retval = CalendarEntry.CanRead(objectId.Value, userId); break; case ObjectTypes.Document: retval = Document.CanRead(objectId.Value, userId); break; case ObjectTypes.Issue: retval = Incident.CanRead(objectId.Value, userId); break; case ObjectTypes.List: retval = ListInfoBus.CanRead(objectId.Value, userId); break; case ObjectTypes.Project: retval = Project.CanRead(objectId.Value, userId); break; case ObjectTypes.Task: retval = Task.CanRead(objectId.Value, userId); break; case ObjectTypes.IssueRequest: retval = IssueRequest.CanUse(userId); break; case ObjectTypes.User: retval = Security.IsUserInGroup(userId, InternalSecureGroups.Administrator); break; case ObjectTypes.Assignment: AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid); if (entity != null && entity.OwnerDocumentId.HasValue) { retval = Document.CanRead(entity.OwnerDocumentId.Value, userId); } break; default: // Для остальных временно разрешаем любой доступ retval = true; break; } return(retval); }
internal static void UpdateList(ListAction action, ArrayList oldItems, ArrayList newItems, ObjectTypes objectType, int objectId, SystemEventTypes eventType, UpdateListDelegate fnUpdate, object context) { ArrayList add = new ArrayList(); ArrayList del = new ArrayList(); foreach (int id in newItems) { switch (action) { case ListAction.Add: if (!oldItems.Contains(id)) add.Add(id); break; case ListAction.Remove: if (oldItems.Contains(id)) del.Add(id); break; case ListAction.Set: if (oldItems.Contains(id)) oldItems.Remove(id); else add.Add(id); break; } } if (action == ListAction.Set) del.AddRange(oldItems); using (DbTransaction tran = DbTransaction.Begin()) { bool updated = false; foreach (int id in add) { fnUpdate(true, objectType, objectId, id, context); updated = true; } foreach (int id in del) { fnUpdate(false, objectType, objectId, id, context); updated = true; } if (updated) SystemEvents.AddSystemEvents(eventType, objectId); tran.Commit(); } }
internal static AlertVariable[] GetVariables(SystemEventTypes eventType) { ObjectTypes objectType = (ObjectTypes)DBSystemEvents.GetObjectType((int)eventType); ObjectTypes relObjectType = (ObjectTypes)DBSystemEvents.GetRelObjectType((int)eventType); ArrayList vars = new ArrayList(); GetVariables(eventType, objectType, false, vars); GetVariables(eventType, relObjectType, true, vars); return vars.ToArray(typeof(AlertVariable)) as AlertVariable[]; }
private static void GetVariables(SystemEventTypes eventType, ObjectTypes objectType, bool isRelObject, ArrayList vars) { // Common variables if (!isRelObject) { vars.Add(new AlertVariable(Variable.ServerLink, isRelObject)); vars.Add(new AlertVariable(Variable.PortalLink, isRelObject)); vars.Add(new AlertVariable(Variable.InitiatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.UnsubscribeLink, true, true, isRelObject)); } AlertVariable var; switch (objectType) { case ObjectTypes.CalendarEntry: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); vars.Add(new AlertVariable(Variable.EventType, isRelObject)); if (eventType != SystemEventTypes.CalendarEntry_Deleted) vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.CalendarEntry_Updated_ResourceList_AssignmentDeleted, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.Comment: vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.Document: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.DocumentStatus, isRelObject)); if (eventType != SystemEventTypes.Document_Deleted) vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Document_Updated_ResourceList_AssignmentDeleted, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.File_FileStorage: vars.Add(new AlertVariable(Variable.FileSize, isRelObject)); if (eventType != SystemEventTypes.Todo_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Task_Updated_FileList_FileDeleted && eventType != SystemEventTypes.CalendarEntry_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Project_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Issue_Updated_FileList_FileDeleted && eventType != SystemEventTypes.Document_Updated_FileList_FileDeleted ) { var = new AlertVariable(Variable.Link, true, true, isRelObject); var.disableNoMenu = true; vars.Add(var); } vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.Issue: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.IssueState, isRelObject)); if (eventType != SystemEventTypes.Issue_Deleted) vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Issue_Updated_ResourceList_AssignmentDeleted, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.Ticket, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.IssueBox: vars.Add(new AlertVariable(Variable.Link, true, true, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.IssueRequest: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Email, isRelObject)); if (eventType != SystemEventTypes.IssueRequest_Approved && eventType != SystemEventTypes.IssueRequest_Deleted) vars.Add(new AlertVariable(Variable.Link, true, true, isRelObject)); vars.Add(new AlertVariable(Variable.MailBoxLink, true, false)); vars.Add(new AlertVariable(Variable.MailBoxTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; case ObjectTypes.List: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); if (eventType != SystemEventTypes.List_Deleted) { var = new AlertVariable(Variable.Link, true, true, isRelObject); if (eventType == SystemEventTypes.List_Updated_Data) var.isDataLink = true; vars.Add(var); } var = new AlertVariable(Variable.ListStatus, isRelObject); var.isResourceVariable = true; vars.Add(var); var = new AlertVariable(Variable.ListType, isRelObject); var.isResourceVariable = true; vars.Add(var); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.Project: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Project_Deleted) vars.Add(new AlertVariable(Variable.Link, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.PercentCompleted, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectStatus, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.Task: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Task_Deleted) vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Task_Updated_ResourceList_AssignmentDeleted, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.PercentCompleted, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.ToDo: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.Description, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Todo_Deleted) vars.Add(new AlertVariable(Variable.Link, true, eventType != SystemEventTypes.Todo_Updated_ResourceList_AssignmentDeleted, isRelObject)); vars.Add(new AlertVariable(Variable.Manager, isRelObject)); vars.Add(new AlertVariable(Variable.PercentCompleted, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.ProjectTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Start, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.UpdatedBy, isRelObject)); break; case ObjectTypes.User: vars.Add(new AlertVariable(Variable.Email, isRelObject)); vars.Add(new AlertVariable(Variable.Login, isRelObject)); vars.Add(new AlertVariable(Variable.Password, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); vars.Add(new AlertVariable(Variable.Link, true, true, isRelObject)); break; case ObjectTypes.Assignment: vars.Add(new AlertVariable(Variable.CreatedBy, isRelObject)); vars.Add(new AlertVariable(Variable.End, isRelObject)); if (eventType != SystemEventTypes.Assignment_Deleted) vars.Add(new AlertVariable(Variable.Link, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.OwnerLink, true, false, isRelObject)); vars.Add(new AlertVariable(Variable.OwnerTitle, isRelObject)); vars.Add(new AlertVariable(Variable.Participant, isRelObject)); vars.Add(new AlertVariable(Variable.Priority, isRelObject)); vars.Add(new AlertVariable(Variable.State, isRelObject)); vars.Add(new AlertVariable(Variable.Title, isRelObject)); break; } }
public static void ProcessHandler(int handlerId, string argument, int hookId, int?objectId, Guid?objectUid, DateTime dateValue) { ObjectTypes objectType = ObjectTypes.UNDEFINED; DateTypes dateType = DateTypes.Undefined; if (handlerId == (int)DateTypeHandlers.SendReminder) { // Напоминать только о тех датах, которые еще не наступили. if (dateValue >= DateTime.UtcNow) { bool sendReminder = false; int userId = -1; using (IDataReader reader = DbSchedule2.GetReminderSubscriptionByHookId(hookId)) { if (reader.Read()) { sendReminder = true; if (reader["UserId"] != DBNull.Value) { userId = (int)reader["UserId"]; // O.R. [2010-04-01]: Don't process inactive user if (User.GetUserActivity(userId) != User.UserActivity.Active) { sendReminder = false; } } objectType = (ObjectTypes)reader["ObjectTypeId"]; dateType = (DateTypes)reader["DateTypeId"]; } } // Не напоминать о досрочно запущенных или досрочно завершённых объектах [2007-02-16] if (sendReminder) { sendReminder = ConfirmNotification(objectType, dateType, objectId, objectUid); } if (sendReminder) { SubscriptionTypes subscriptionType = (SubscriptionTypes)int.Parse(argument, CultureInfo.InvariantCulture); switch (subscriptionType) { case SubscriptionTypes.Global: ProcessGlobalSubscription(hookId, dateType, objectType, objectId, objectUid); break; case SubscriptionTypes.Personal: ProcessPersonalSubscription(hookId, dateType, userId, objectType, objectId, objectUid); break; case SubscriptionTypes.PersonalForObject: ProcessPersonalSubscriptionForObject(hookId, dateType, userId, objectType, objectId, objectUid); break; } } } } else if (handlerId == (int)DateTypeHandlers.RaiseSystemEvent) { bool raiseEvent = false; using (IDataReader reader = DbSchedule2.GetHook(hookId)) { if (reader.Read()) { raiseEvent = true; objectType = (ObjectTypes)reader["ObjectTypeId"]; dateType = (DateTypes)reader["DateTypeId"]; } } if (raiseEvent) { // Не уведомлять о досрочно запущенных или досрочно завершённых объектах [2008-07-29] raiseEvent = ConfirmNotification(objectType, dateType, objectId, objectUid); if (raiseEvent) { SystemEventTypes EventType = (SystemEventTypes)int.Parse(argument); if (objectId.HasValue) { SystemEvents.AddSystemEvents(EventType, objectId.Value); } else if (objectUid.HasValue) { SystemEvents.AddSystemEvents(EventType, objectUid.Value); } } if (objectType == ObjectTypes.Task) { Task.RecalculateAllStates(Task.GetProject(objectId.Value)); } else if (objectType == ObjectTypes.ToDo) { ToDo.RecalculateState(objectId.Value); } else if (objectType == ObjectTypes.CalendarEntry) { CalendarEntry.RecalculateState(objectId.Value); } } } else if (handlerId == (int)DateTypeHandlers.BatchAlert) { if (objectId.HasValue) { Alerts2.SendBatch(objectId.Value, dateValue); } } else if (handlerId == (int)DateTypeHandlers.LdapSync) { if (objectId.HasValue) { Ldap.Synchronize(objectId.Value, dateValue); } } }