/// <summary> /// ћетод запуска операции на выполнение, Ђвходна¤ї точка операции /// ѕ≈–≈√–”∆≈ЌЌџ…, —“–ќ√ќ “»ѕ»«»–ќ¬јЌЌџ… ћ≈“ќƒ /// ¬џ«џ¬ј≈“—я яƒ–ќћ ј¬“ќћј“»„≈— » /// </summary> /// <param name="request">«апрос на выполнение операции</param> /// <param name="context"> онтекст выполнени¤ операции</param> /// <returns>–езультат выполнени¤</returns> public virtual XResponse Execute(UserSubscriptionForEventClassRequest request, IXExecutionContext context) { // ѕервым делом получим идентификатор пользовател¤ Guid employeeID = ((ITUser)XSecurityManager.Instance.GetCurrentUser()).EmployeeID; // —формируем запрос using (XDbCommand cmd = context.Connection.CreateCommand()) { string sParamEmployeeID = context.Connection.GetParameterName("emp"); string sParamEventClass = context.Connection.GetParameterName("evt"); // ќтпишем StringBuilder sb = new StringBuilder(); sb.AppendFormat(@" SET NOCOUNT ON SET ROWCOUNT 0 DELETE dbo.EventSubscription WHERE [User]={0} AND ( ([EventCreationRule] IN (SELECT ObjectID FROM dbo.EventType WHERE EventType={1})) OR {1}=0 ) ", sParamEmployeeID, sParamEventClass); if (request.Action == UserSubscriptionForEventClassAction.SwitchToDigestOnly) { sb.AppendFormat(@" INSERT INTO dbo.EventSubscription([User], [IncludeInDigest], [InstantDelivery], [EventCreationRule]) ( SELECT {0}, 1, 0, ObjectID FROM dbo.EventType WHERE EventType={1} OR {1}=0 ) ", sParamEmployeeID, sParamEventClass); } else if (request.Action == UserSubscriptionForEventClassAction.Unsubscribe) { sb.AppendFormat(@" INSERT INTO dbo.EventSubscription([User], [IncludeInDigest], [InstantDelivery], [EventCreationRule]) ( SELECT {0}, 0, 0, ObjectID FROM dbo.EventType WHERE EventType={1} OR {1}=0 ) ", sParamEmployeeID, sParamEventClass); } cmd.CommandTimeout = int.MaxValue - 128; cmd.CommandText = sb.ToString(); cmd.Parameters.Add(sParamEmployeeID, employeeID); cmd.Parameters.Add(sParamEventClass, request.EventClass); cmd.ExecuteNonQuery(); } return(new XResponse()); }
public override XResponse Execute(XRequest request, IXExecutionContext context) { using (XDbCommand cmd = context.Connection.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "dbo.app_messagingCheckIncidentsDeadline"; cmd.CommandTimeout = int.MaxValue - 128; cmd.ExecuteNonQuery(); } return(new XResponse()); }