Example #1
0
        public static void AcceptInvoice(int claimId)
        {
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString))
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "income.dbo.up_RegPaymentsFromBankInvoices";

                    using (OperationDurationLimit.ShortOperation(command))
                    {
                        connection.Open();
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                        }
                    }
                }
            }

            //отправка сообщений
            {
                var reservation = BookingProvider.GetReservationState(UrlLanguage.CurrentLanguage, claimId);


                Task[] tasks = new Task[]
                {
                    Task.Factory.StartNew(() => new SimpleEmailService().SendEmail <ReservationState>(reservation.customer.mail, "payment", reservation.customer.language, reservation)),
                    Task.Factory.StartNew(() => new SmsSender().SendMessage <ReservationState>(reservation.customer.phone, "payment", reservation.customer.language, reservation))
                };

                Task.WaitAll(tasks);
            }
        }
Example #2
0
        public static ConfirmInvoiceResult ConfirmInvoice(string invoiceNumber)
        {
            if (string.IsNullOrEmpty(invoiceNumber))
            {
                throw new System.ArgumentNullException("invoiceNumber");
            }
            ConfirmInvoiceResult result = new ConfirmInvoiceResult();

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString))
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "invoicesforbank.dbo.up_ConfirmInvoiceByINumber";
                    command.Parameters.Add("INumber", SqlDbType.VarChar).Value = invoiceNumber;
                    using (OperationDurationLimit.ShortOperation(command))
                    {
                        connection.Open();
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                int[] fields = new int[]
                                {
                                    reader.GetOrdinal("ret"),
                                    reader.GetOrdinal("message")
                                };
                                result.Error        = new int?(reader.ReadInt(fields[0]));
                                result.ErrorMessage = reader.ReadNullableTrimmedString(fields[1]);
                            }
                        }
                    }
                }
            }
            return(result);
        }