Calculation of the critical current for type II superconducting wires in longitudinal fields