Пример #1
0
        public IAlertsDalSetAlertStatusResult SetAlertSubscriptionStatus(IAlertsDalSetAlertStatusParams setSubsStatusParams)
        {
            IAlertsDalSetAlertStatusResult result = new MSSQL.AlertsDalSetAlertStatusResult();

            string spName = "[SP_Set_Alert_Subscription_Status]";

            SqlConnection conn = OpenConnection(connName);

            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = schema + "." + spName;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = conn;

            try
            {
                if (setSubsStatusParams.Subscriptions != null)
                {
                    foreach (var s in setSubsStatusParams.Subscriptions)
                    {
                        cmd.Parameters.Clear();

                        SqlParameter paramAlertId = new SqlParameter("@Alert_Subscription_Id", SqlDbType.BigInt, 0, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Current, s.Id);

                        SqlParameter paramStatusId = new SqlParameter("@Status_Id", SqlDbType.BigInt, 0, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Current, s.StatusId);

                        cmd.Parameters.Add(paramAlertId);
                        cmd.Parameters.Add(paramStatusId);

                        cmd.ExecuteNonQuery();
                    }
                }

                result.Success = true;
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Errors.Add(new Interfaces.Error()
                {
                    Code    = Interfaces.EErrorCodes.AlertsSourceFail,
                    Type    = Interfaces.EErrorType.Error,
                    Message = ex.Message
                });
            }

            conn.Close();

            return(result);
        }
Пример #2
0
        public void SetAlertSubscriptionStatus_Success()
        {
            RunInitSql("040.SetAccountSubscriptionStatus_Success", _conn);

            IAlertsDal dal = PrepareAlertsDal();

            IAlertsDalGetAccountSubscriptionsParams getGetSubsParams = dal.CreateGetAccountSubscrParams();

            getGetSubsParams.AccountKey = ConfigurationManager.AppSettings["AccountKey"];

            var getSubsResult = dal.GetAccountSubscriptions(getGetSubsParams);

            IAlertsDalSetAlertStatusParams updSubParam = dal.CreateSetAlertStatusParams();

            getSubsResult.Subscriptions[0].StatusId = Int32.Parse(ConfigurationManager.AppSettings["Status_Id_Disabled"]);
            updSubParam.Subscriptions.Add(getSubsResult.Subscriptions[0]);

            IAlertsDalSetAlertStatusResult updSubsResult = dal.SetAlertSubscriptionStatus(updSubParam);

            RunFinalizeSql("040.SetAccountSubscriptionStatus_Success", _conn);

            Assert.IsTrue(updSubsResult.Success);
        }