public ProcessMsg CancleStored(List <string> trayIds) { using (TransactionScope trans = new TransactionScope()) { using (IUnitOfWork unit = MSSqlHelper.DataContext()) { ProcessMsg msg = new ProcessMsg() { result = true }; try { ITraysRep tr = new TraysRep(unit); List <Trays> tis = tr.GetByIds(trayIds); bool all_synced = true; foreach (Trays ts in tis) { bool synced = false; try { synced = new ApiService().SyncUnStoreContainer(ts.trayId, config.Get("WAREHOUSE")); } catch { all_synced = false; } if (synced == false) { all_synced = false; } ts.sync = synced; ts.status = (int)TrayStatus.Cancled; } unit.Submit(); trans.Complete(); if (all_synced) { msg.AddMessage(ReturnCode.OK, "入库取消成功!"); } else { msg.AddMessage(ReturnCode.OK, "入库取消成功!"); msg.AddMessage(ReturnCode.Warning, "入库取消成功,但WMS同步失败,请稍候重新同步!"); } msg.result = true; } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!"); } finally { trans.Dispose(); } return(msg); } } }
public static void UpdateTraysStatus(List <string> trayIds, TrayStatus status) { using (IUnitOfWork unit = MSSqlHelper.DataContext()) { ValidateMsg <Trays> msg = new ValidateMsg <Trays>() { Valid = false }; ITraysRep tr = new TraysRep(unit); List <Trays> ts = tr.GetByIds(trayIds); foreach (Trays t in ts) { t.status = (int)status; } unit.Submit(); } }