Exemplo n.º 1
0
        public DataCleanResult DataClean(DataCleanCommand command)
        {
            if (command.StartDate == default)
            {
                throw new Exception("Missing parameter: StartDate");
            }

            if (command.EndDate == default)
            {
                throw new Exception("Missing parameter: EndDate");
            }

            if (command.EndDate <= command.StartDate)
            {
                throw new Exception("StartDate must come before EndDate.");
            }

            var startedAt = DateTime.Now;

            using (var conn = NewConnection())
            {
                conn.Open();

                WriteToolDataCleanResult  writeToolDataCleanProcessResult  = null;
                WriteRoomDataCleanResult  writeRoomDataCleanProcessResult  = null;
                WriteStoreDataCleanResult writeStoreDataCleanProcessResult = null;

                if ((command.BillingCategory & BillingCategory.Tool) > 0)
                {
                    writeToolDataCleanProcessResult = new WriteToolDataCleanProcess(new WriteToolDataCleanConfig {
                        Connection = conn, Context = "ProcessRepository.DataClean", StartDate = command.StartDate, EndDate = command.EndDate, ClientID = command.ClientID
                    }).Start();
                }

                if ((command.BillingCategory & BillingCategory.Room) > 0)
                {
                    writeRoomDataCleanProcessResult = new WriteRoomDataCleanProcess(new WriteRoomDataCleanConfig {
                        Connection = conn, Context = "ProcessRepository.DataClean", StartDate = command.StartDate, EndDate = command.EndDate, ClientID = command.ClientID
                    }).Start();
                }

                if ((command.BillingCategory & BillingCategory.Store) > 0)
                {
                    using (var uow = NewUnitOfWork())
                        writeStoreDataCleanProcessResult = new WriteStoreDataCleanProcess(new WriteStoreDataCleanConfig {
                            Connection = conn, Context = "ProcessRepository.DataClean", StartDate = command.StartDate, EndDate = command.EndDate, ClientID = command.ClientID
                        }).Start();
                }

                conn.Close();

                DataCleanResult result = new DataCleanResult(startedAt)
                {
                    WriteToolDataCleanProcessResult  = writeToolDataCleanProcessResult,
                    WriteRoomDataCleanProcessResult  = writeRoomDataCleanProcessResult,
                    WriteStoreDataCleanProcessResult = writeStoreDataCleanProcessResult
                };

                return(result);
            }
        }
Exemplo n.º 2
0
 public DataCleanResult DataClean(DataCleanCommand command)
 {
     return(Post <DataCleanResult>("webapi/billing/process/data/clean", command));
 }