public static void RegisterTriggers() { TriggerManager.AddTrigger(TimeTrackingBlock.GetAssignedMetaClass(), new Trigger("RecalculateProjectByTimeTrackingBlock", "Recalculates project fields by time tracking block", false, false, true, string.Empty, "RecalculateProject")); TriggerManager.AddTrigger(TimeTrackingEntry.GetAssignedMetaClass(), new Trigger("RecalculateObjectByTimeTrackingEntry", "Recalculates project fields by time tracking block", true, true, true, string.Empty, "RecalculateObject")); }
protected void btnSave_Click(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } using (MetaClassManagerEditScope editScope = DataContext.Current.MetaModel.BeginEdit()) { Trigger trigger; if (TriggerName != String.Empty) { trigger = TriggerManager.GetTrigger(ClassName, TriggerName); } else { trigger = new Trigger(); trigger.Name = txtName.Text.Trim(); } trigger.ActionName = ddlAction.SelectedValue; trigger.ConditionName = ddlCondition.SelectedValue; trigger.Create = chkInsert.Checked; trigger.Delete = chkDelete.Checked; trigger.Update = chkUpdate.Checked; trigger.Description = txtDescription.Text; List <string> conditionInParameters = new List <string>(); for (int i = 0; i < tblCondition.Rows.Count; i++) { TextBox txt = (TextBox)tblCondition.Rows[i].Cells[1].Controls[0]; conditionInParameters.Add(txt.Text.Trim()); } trigger.ConditionInParameters = conditionInParameters; List <string> actionInParameters = new List <string>(); for (int i = 0; i < tblAction.Rows.Count; i++) { TextBox txt = (TextBox)tblAction.Rows[i].Cells[1].Controls[0]; actionInParameters.Add(txt.Text.Trim()); } trigger.ActionInParameters = actionInParameters; if (TriggerName == String.Empty) { TriggerManager.AddTrigger(ClassName, trigger); } editScope.SaveChanges(); } // Closing window if (RefreshButton == String.Empty) { CHelper.CloseItAndRefresh(Response); } else // Dialog Mode { CHelper.CloseItAndRefresh(Response, RefreshButton); } }