Пример #1
0
        public static DataTable InsertToWarehouse(TotMastrActions totMastrAction, string uniqueIdentifier, string status)
        {
            DataTable warehouseA1ShipRequestRecords = ReadSchemaFromWarehouse();

            warehouseA1ShipRequestRecords.Rows.Add(warehouseA1ShipRequestRecords.NewRow());
            warehouseA1ShipRequestRecords.Rows[0]["id"]               = Guid.NewGuid();
            warehouseA1ShipRequestRecords.Rows[0]["action"]           = (short)totMastrAction;
            warehouseA1ShipRequestRecords.Rows[0]["uniqueIdentifier"] = uniqueIdentifier;
            warehouseA1ShipRequestRecords.Rows[0]["status"]           = status;
            warehouseA1ShipRequestRecords.Rows[0]["threadName"]       = Thread.CurrentThread.Name;
            warehouseA1ShipRequestRecords.Rows[0]["createdDate"]      = DateTime.UtcNow;

            lock (databaseSyncObject)
                using (DBConnection warehouseDBConnection = WarehouseDatabaseConnectionAdapter.GetDatabaseConnection())
                    using (DBAdapter a1ShipRequestDBAdapter = new DBAdapter(A1ShipRequestTableSchemaQuery, warehouseDBConnection.SqlConnection))
                        a1ShipRequestDBAdapter.Update(warehouseA1ShipRequestRecords);

            return(warehouseA1ShipRequestRecords);
        }
Пример #2
0
        public static DataTable UpdateWarehouse(DataTable warehouseA1ShipRequestRecords, string a1ShipRequestStatus)
        {
            if (warehouseA1ShipRequestRecords.Rows.Count == 0)
            {
                throw new Exception("The A1ShipRequest table update failed because the submitted table contains no rows!");
            }

            foreach (DataRow warehouseA1ShipRequestRecord in warehouseA1ShipRequestRecords.Rows)
            {
                warehouseA1ShipRequestRecord["status"]     = a1ShipRequestStatus;
                warehouseA1ShipRequestRecord["threadName"] = string.Empty;
            }

            lock (databaseSyncObject)
                using (DBConnection warehouseDBConnection = WarehouseDatabaseConnectionAdapter.GetDatabaseConnection())
                    using (DBAdapter a1ShipRequestDBAdapter = new DBAdapter(A1ShipRequestTableSchemaQuery, warehouseDBConnection.SqlConnection))
                        a1ShipRequestDBAdapter.Update(warehouseA1ShipRequestRecords);

            return(warehouseA1ShipRequestRecords);
        }