public VariableInfo(AlertVariable var, string value, string languageId, VariableType type) : this(var.isRelObject, var.name, value) { this.languageId = languageId; this.type = type.ToString(); if (var.isLink) { this._isLink = "1"; } if (var.external) { this._external = "1"; } this._disableNoMenu = var.disableNoMenu ? "1" : "0"; }
public static DataTable GetVariablesForTemplateEditor(AlertTemplateTypes type, string templateName) { DataTable table = new DataTable(); table.Columns.Add(new DataColumn("Name", typeof(string))); table.Columns.Add(new DataColumn("Description", typeof(string))); table.Columns.Add(new DataColumn("Value", typeof(string))); AlertVariable[] vars = null; switch (type) { case AlertTemplateTypes.Notification: string[] parts = templateName.Split('|'); vars = AlertVariable.GetVariables((SystemEventTypes)Enum.Parse(typeof(SystemEventTypes), parts[0])); break; case AlertTemplateTypes.Reminder: vars = Reminder.GetVariables((DateTypes)Enum.Parse(typeof(DateTypes), templateName)); break; case AlertTemplateTypes.Special: vars = SpecialMessage.GetVariables((SpecialMessageType)Enum.Parse(typeof(SpecialMessageType), templateName)); break; } if (vars != null) { foreach (AlertVariable var in vars) { DataRow row = table.NewRow(); row["Name"] = var.Name; row["Description"] = string.Empty; string value = "[=" + var.Name + "=]"; if (var.isLink) { value += "[=/" + var.Name + "=]"; } row["Value"] = value; table.Rows.Add(row); } } return(table); }
private static void GetObjectVariablesIssue(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { string id; EMail.IncidentBox box = EMail.IncidentBox.Load(Incident.GetIncidentBox(objectId)); using (IDataReader reader = DbAlert2.GetVariablesIssue(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.CreatedBy: case Variable.Manager: case Variable.UpdatedBy: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Title: case Variable.Description: case Variable.ProjectTitle: vars.Add(new VariableInfo(var, HttpUtility.HtmlDecode(reader[var.name.ToString()].ToString()))); break; case Variable.IssueState: multilangVars[var] = reader["StateId"]; break; case Variable.Link: vars.Add(new VariableInfo(var, MakeObjectLink(IssueLink, objectId))); break; case Variable.Priority: multilangVars[var] = reader["PriorityId"]; break; case Variable.ProjectLink: id = reader["ProjectId"].ToString(); vars.Add(new VariableInfo(var, id.Length == 0 ? id : MakeObjectLink(ProjectLink, id))); break; case Variable.Ticket: vars.Add(new VariableInfo(var, EMail.TicketUidUtil.Create(box.IdentifierMask, objectId))); break; } } } } } }
private static void GetObjectVariablesFile(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { string title = null; AlertVariable linkVariable = null; using (IDataReader reader = DbAlert2.GetVariablesFile(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.FileSize: case Variable.Title: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Link: title = reader[Variable.Title.ToString()].ToString(); linkVariable = var; break; } } } } } if (title != null && linkVariable != null) vars.Add(new VariableInfo(linkVariable, WebDAV.Common.WebDavUrlBuilder.GetFileStorageWebDavUrlForAlerts(objectId, title, false))); }
private static void GetObjectVariablesComment(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { using (IDataReader reader = DbAlert2.GetVariablesComment(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.Title: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString(), true)); break; } } } } } }
private static void GetObjectVariablesAssignment(bool isRelObject, Guid objectUid, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { using (IDataReader reader = DbAlert2.GetVariablesAssignment(objectUid)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { string link; switch (var.name) { case Variable.CreatedBy: case Variable.Participant: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Title: case Variable.OwnerTitle: vars.Add(new VariableInfo(var, HttpUtility.HtmlDecode(reader[var.name.ToString()].ToString()))); break; case Variable.End: vars.Add(new VariableInfo(var, DateTimeToString(reader[var.name.ToString()]), VariableType.DateTime)); break; case Variable.State: int state = (int)reader["State"]; if (state == (int)AssignmentState.Active) multilangVars[var] = "{IbnFramework.BusinessProcess:AssignmentStateActive}"; else if (state == (int)AssignmentState.Closed) multilangVars[var] = "{IbnFramework.BusinessProcess:AssignmentStateClosed}"; else if (state == (int)AssignmentState.Pending) multilangVars[var] = "{IbnFramework.BusinessProcess:AssignmentStatePending}"; else if (state == (int)AssignmentState.Suspended) multilangVars[var] = "{IbnFramework.BusinessProcess:AssignmentStateSuspended}"; break; case Variable.Link: link = string.Empty; if (reader["OwnerDocumentId"] != DBNull.Value) { link = string.Format(CultureInfo.InvariantCulture, "{0}/Documents/DocumentView.aspx?DocumentId={1}&assignmentId={2}&Tab=General", Configuration.PortalLink, reader["OwnerDocumentId"].ToString(), objectUid); } vars.Add(new VariableInfo(var, link)); break; case Variable.Priority: int priorityId = (int)reader["PriorityId"]; switch (priorityId) { case (int)AssignmentPriority.Low: multilangVars[var] = (int)Priority.Low; break; case (int)AssignmentPriority.Normal: multilangVars[var] = (int)Priority.Normal; break; case (int)AssignmentPriority.High: multilangVars[var] = (int)Priority.High; break; case (int)AssignmentPriority.VeryHigh: multilangVars[var] = (int)Priority.VeryHigh; break; case (int)AssignmentPriority.Urgent: multilangVars[var] = (int)Priority.Urgent; break; } break; case Variable.OwnerLink: link = string.Empty; if (reader["OwnerDocumentId"] != DBNull.Value) { link = string.Format(CultureInfo.InvariantCulture, "{0}/Documents/DocumentView.aspx?DocumentId={1}", Configuration.PortalLink, reader["OwnerDocumentId"].ToString()); } vars.Add(new VariableInfo(var, link)); break; } } } } } }
public VariableInfo(AlertVariable var, string value, bool isHtml) : this(var, value, string.Empty, VariableType.String) { this.IsHtml = isHtml; }
private static void GetObjectVariablesUser(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { if (isRelObject && objectId == -1) // Group responsibility for issues { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.Title: multilangVars[var] = "{IbnFramework.Incident:GroupResp}"; break; default: vars.Add(new VariableInfo(var, string.Empty)); break; } } } } else // User { using (IDataReader reader = DbAlert2.GetVariablesUser(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.Email: case Variable.Login: case Variable.Password: // TODO: remove case Variable.Title: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Link: vars.Add(new VariableInfo(var, MakeObjectLink(UserLink, objectId))); break; } } } } } } }
private static void GetObjectVariablesList(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { using (IDataReader reader = DbAlert2.GetVariablesList(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.CreatedBy: case Variable.Description: case Variable.Title: case Variable.UpdatedBy: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Link: string linkTemplate = var.isDataLink ? ListDataLink : ListInfoLink; vars.Add(new VariableInfo(var, MakeObjectLink(linkTemplate, objectId))); break; case Variable.ListStatus: case Variable.ListType: multilangVars[var] = reader[var.name.ToString()].ToString(); break; } } } } } }
public VariableInfo(AlertVariable var, string value, VariableType type) : this(var, value, string.Empty, type) { }
public VariableInfo(AlertVariable var, string value, string languageId) : this(var, value, languageId, VariableType.String) { }
public VariableInfo(AlertVariable var, string value, string languageId, VariableType type) : this(var.isRelObject, var.name, value) { this.languageId = languageId; this.type = type.ToString(); if (var.isLink) this._isLink = "1"; if (var.external) this._external = "1"; this._disableNoMenu = var.disableNoMenu ? "1" : "0"; }
private static void GetObjectVariablesIssueBox(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { using (IDataReader reader = DbAlert2.GetVariablesIssueBox(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.Manager: case Variable.Title: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Link: vars.Add(new VariableInfo(var, MakeObjectLink(IssueBoxLink, objectId))); break; } } } } } }
private static void GetObjectVariablesIssueRequest(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { using (IDataReader reader = DbAlert2.GetVariablesIssueRequest(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.CreatedBy: case Variable.Email: case Variable.MailBoxTitle: case Variable.Title: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Link: vars.Add(new VariableInfo(var, MakeObjectLink(IssueRequestLink, objectId))); break; case Variable.MailBoxLink: string id = reader["MailBoxId"].ToString(); vars.Add(new VariableInfo(var, id.Length == 0 ? id : MakeObjectLink(MailBoxLink, id))); break; case Variable.Priority: multilangVars[var] = reader["Priority"]; break; } } } } } }
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 void GetObjectVariablesTodo(bool isRelObject, int objectId, AlertVariable[] names, ArrayList vars, Hashtable multilangVars) { string id; using (IDataReader reader = DbAlert2.GetVariablesTodo(objectId)) { if (reader.Read()) { foreach (AlertVariable var in names) { if (var.isRelObject == isRelObject) { switch (var.name) { case Variable.CreatedBy: case Variable.Manager: case Variable.PercentCompleted: case Variable.UpdatedBy: vars.Add(new VariableInfo(var, reader[var.name.ToString()].ToString())); break; case Variable.Title: case Variable.Description: case Variable.ProjectTitle: vars.Add(new VariableInfo(var, HttpUtility.HtmlDecode(reader[var.name.ToString()].ToString()))); break; case Variable.End: case Variable.Start: vars.Add(new VariableInfo(var, DateTimeToString(reader[var.name.ToString()]), VariableType.DateTime)); break; case Variable.State: multilangVars[var] = reader["StateId"]; break; case Variable.Link: vars.Add(new VariableInfo(var, MakeObjectLink(TodoLink, objectId))); break; case Variable.Priority: multilangVars[var] = reader["PriorityId"]; break; case Variable.ProjectLink: id = reader["ProjectId"].ToString(); vars.Add(new VariableInfo(var, id.Length == 0 ? id : MakeObjectLink(ProjectLink, id))); break; } } } } } }
private static IDataReader GetMultilangVarsReader(AlertVariable var, int itemId) { switch (var.name) { case Variable.EventType: return DbAlert2.GetEventTypeNames(itemId); case Variable.IssueState: return DbAlert2.GetIssueStateNames(itemId); case Variable.Priority: return DbAlert2.GetPriorityNames(itemId); case Variable.ProjectStatus: return DbAlert2.GetProjectStatusNames(itemId); case Variable.State: return DbAlert2.GetObjectStateNames(itemId); default: throw new Exception("Unknown multilanguage variable."); } }
internal static void GetObjectVariables(ObjectTypes objectType, int? objectId, Guid? objectUid, bool isRelObject, AlertVariable[] names, ArrayList vars) { Hashtable multilangVars = new Hashtable(); switch (objectType) { case ObjectTypes.File_FileStorage: GetObjectVariablesFile(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.CalendarEntry: GetObjectVariablesCalendarEntry(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.Comment: GetObjectVariablesComment(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.Document: GetObjectVariablesDocument(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.Issue: GetObjectVariablesIssue(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.IssueBox: GetObjectVariablesIssueBox(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.IssueRequest: GetObjectVariablesIssueRequest(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.List: GetObjectVariablesList(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.Project: GetObjectVariablesProject(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.Task: GetObjectVariablesTask(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.ToDo: GetObjectVariablesTodo(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.User: GetObjectVariablesUser(isRelObject, objectId.Value, names, vars, multilangVars); break; case ObjectTypes.Assignment: GetObjectVariablesAssignment(isRelObject, objectUid.Value, names, vars, multilangVars); break; } // Load languages Dictionary<int, string> languages = new Dictionary<int, string>(); using (IDataReader reader = Common.GetListLanguages()) { while (reader.Read()) { int languageId = (int)reader["LanguageId"]; string locale = reader["Locale"].ToString(); languages.Add(languageId, locale); } } // Get multilanguage variables(multilangVars, vars); foreach (AlertVariable var in multilangVars.Keys) { string valueTemplate = multilangVars[var] as string; if (valueTemplate != null) { foreach (int languageId in languages.Keys) { string value = Common.GetWebResourceString(valueTemplate, CultureInfo.GetCultureInfo(languages[languageId])); vars.Add(new VariableInfo(var, value, languageId.ToString(CultureInfo.InvariantCulture))); } } else { using (IDataReader reader = GetMultilangVarsReader(var, (int)multilangVars[var])) { while (reader.Read()) vars.Add(new VariableInfo(var, reader["Name"].ToString(), reader["LanguageId"].ToString())); } } } }
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; } }