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 ProcessMsg GenPosition(string positionFormat) { using (TransactionScope trans = new TransactionScope()) { using (IUnitOfWork unit = MSSqlHelper.DataContext()) { ProcessMsg msg = new ProcessMsg(); try { ITraysRep tr = new TraysRep(unit); string position = string.Empty; int count = tr.GetTrayCountByDay(); string[] positionFormats = positionFormat.Split(','); position = string.Format("{0} {1}", string.Format(positionFormats[0], DateTime.Now.Day), string.Format(positionFormats[1], count + 1)); msg.result = true; msg.AddMessage(ReturnCode.OK, position); } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!"); } finally { trans.Dispose(); } return(msg); } } }
private void BtnCancle_Click(object sender, RoutedEventArgs e) { if (DGTrayItemsDetail.Items.Count > 0 && DGTrayItemsDetail.SelectedItems.Count > 0) { List <string> cancleIds = DGTrayItemsDetail.SelectedCells.Where(i => ((Trays)i.Item).status != (int)TrayStatus.Cancled).Select(i => ((Trays)i.Item).trayId).Distinct().ToList <string>(); if (cancleIds.Count > 0) { ProcessMsg msg = packageStoreService.CancleStored(cancleIds); if (msg.result) { string errorMsg = msg.GetMessage(ReturnCode.Warning).Trim(); if (errorMsg.Length > 0) { new InfoBoard(MsgLevel.Warning, errorMsg).ShowDialog(); } new InfoBoard(MsgLevel.Successful, "取消成功!", 10000).ShowDialog(); BtnSearch_Click(sender, e); } else { new InfoBoard(MsgLevel.Warning, msg.GetAllLevelMsgs()).ShowDialog(); } } else { new InfoBoard(MsgLevel.Warning, "请选择未取消托盘").ShowDialog(); } } }
private void BtnSync_Click(object sender, RoutedEventArgs e) { if (DGTrayItemsDetail.Items.Count > 0) { ProcessMsg msg = packageStoreService.SyncStore(); new InfoBoard(MsgLevel.Info, msg.GetAllLevelMsgs()).ShowDialog(); } }
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 ProcessMsg ExportTraySumPartCSV(List <string> trayIds, string filename, List <string> fieldNames) { ProcessMsg msg = new ProcessMsg() { result = false }; try { List <TrayPackView> tpv = TrayPackViewHelper.GetTPVByTrayIdsGropSumPartNr(trayIds); // List<TrayPackView> ts = tpv.ToList(); List <string> updateTrayIds = new List <string>(); CSVDataSet ds = new CSVDataSet(); foreach (TrayPackView v in tpv) { CSVDataRecord r = new CSVDataRecord(); List <string> values = ClassUtil.GetModelValues(fieldNames, v); if (values != null) { foreach (string value in values) { r.Add(value); } } //r.Add(v.partNr); //r.Add(v.capa.ToString()); if (TrayPackStatusHelper.CanAddPrefix(v.tstatus)) { r.Add(v.TsStatusCN); } ds.Add(r); if (TrayPackStatusHelper.CanUpdateToExported(v.tstatus)) { updateTrayIds.Add(v.trayId); } } CSVUtil.GenCSVFile(ds, filename); if (updateTrayIds.Count > 0) { TraysHelper.UpdateTraysStatus(updateTrayIds, TrayStatus.Exported); } msg.result = true; msg.AddMessage(ReturnCode.OK, "成功导出CSV文件"); } catch (Exception e) { msg.AddMessage(ReturnCode.Error, e.Message); } return(msg); }
private void BtnFinsh_Click(object sender, RoutedEventArgs e) { if (TBWarehouse.Text.Length > 0 && TBPosition.Text.Length > 0) { if (int.Parse(LabPackNum.Content.ToString()) > 0) { if (SPDataSource != null) { ProcessMsg msg = packageStoreService.CompleteStore(SPDataSource.Select(t => t.packageID).ToList <string>(), TBWarehouse.Text, TBPosition.Text.ToString()); if (msg.result) { string errorMsg = msg.GetMessage(ReturnCode.Warning).Trim(); if (errorMsg.Length > 0) { new InfoBoard(MsgLevel.Warning, errorMsg).ShowDialog(); } TBTrayId.Text = msg.GetMessage(ReturnCode.OK).Trim(); TBPackageId.IsEnabled = false; BtnFinsh.IsEnabled = false; BtnRePrint.IsEnabled = true; BtnNew.IsEnabled = true; bool?print = new InfoBoard(MsgLevel.Successful, "入库成功,是否打印包装箱标签?\n标签号为:" + TBTrayId.Text).ShowDialog(); if ((bool)print) { this.PrintTrayLabel(TBTrayId.Text); } } else { new InfoBoard(MsgLevel.Warning, msg.GetAllLevelMsgs()).ShowDialog(); } } } else { new InfoBoard(MsgLevel.Warning, "未开始入库!").ShowDialog(); } } else { new InfoBoard(MsgLevel.Warning, "未输入仓库或库位!").ShowDialog(); } }
private void BtnExport_Click(object sender, RoutedEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "CSV 文件格式|*.csv"; sfd.Title = "导出CSV文件"; sfd.FileName = "CSVData" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"; sfd.ShowDialog(); if (sfd.FileName != "") { if (DGTrayItemsDetail.Items.Count > 0) { List <string> exportIds = new List <string>(); foreach (Trays t in DGTrayItemsDetail.Items) { exportIds.Add(t.trayId); } ConfigUtil config = new ConfigUtil("CSVFILEDS", "csv.ini"); List <string> csvFields = new List <string> (); string[] keys = config.GetAllNodeKey(); foreach (string key in keys) { if (config.Get(key) == "1") { csvFields.Add(key); } } ProcessMsg msg = exportService.ExportTraySumPartCSV(exportIds, sfd.FileName, csvFields); new InfoBoard(MsgLevel.Info, msg.GetAllLevelMsgs()).ShowDialog(); config = new ConfigUtil("AUTO", "config.ini"); if (msg.result && bool.Parse(config.Get("EXPORTLOAD"))) { BtnSearch_Click(sender, e); } } } }
public static Message PrintTrayLabel(string trayId) { Message msg = new Message(); PrintService printService = new PrintService(); PrintDataMessage pmsg = printService.GenSingleTrayLabel(trayId , new ConfigUtil("DATEFORMAT", "config.ini").Get("DATEFORMAT") , new ConfigUtil("KEEPER", "config.ini").Get("KEEPER").Split(',')); if (pmsg.ReturnedResult) { Hashtable printConfig = PrinterUtil.GetPrinterConfig();; ProcessMsg prmsg = printService.Print(printConfig, pmsg); msg.Result = prmsg.result; msg.Content = prmsg.GetAllLevelMsgs(); } else { msg.Result = pmsg.ReturnedResult; msg.Content = pmsg.GetMsgText(); } return(msg); }
public ProcessMsg Print(Hashtable printConfig, PrintDataMessage pmsg) { ProcessMsg msg = new ProcessMsg(); try { IReportGen gen = new TecITGener(); foreach (PrintTask task in pmsg.PrintTask) { task.Config.Printer = printConfig["PrinterName"].ToString(); task.Config.NumberOfCopies = int.Parse(printConfig["Copy"].ToString()); task.Config.Template = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, printConfig["Template"].ToString()); gen.Print(task.DataSet, task.Config); } msg.result = true; msg.AddMessage(ReturnCode.OK, "打印成功!"); } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Fail, "打印错误:" + e.Message); } return msg; }
public ProcessMsg ExportTraySumPartCSV(List<string> trayIds, string filename, List<string> fieldNames) { ProcessMsg msg = new ProcessMsg() { result = false }; try { List<TrayPackView> tpv = TrayPackViewHelper.GetTPVByTrayIdsGropSumPartNr(trayIds); // List<TrayPackView> ts = tpv.ToList(); List<string> updateTrayIds = new List<string>(); CSVDataSet ds = new CSVDataSet(); foreach (TrayPackView v in tpv) { CSVDataRecord r = new CSVDataRecord(); List<string> values = ClassUtil.GetModelValues(fieldNames, v); if (values != null) foreach (string value in values) r.Add(value); //r.Add(v.partNr); //r.Add(v.capa.ToString()); if (TrayPackStatusHelper.CanAddPrefix(v.tstatus)) r.Add(v.TsStatusCN); ds.Add(r); if (TrayPackStatusHelper.CanUpdateToExported(v.tstatus)) updateTrayIds.Add(v.trayId); } CSVUtil.GenCSVFile(ds, filename); if (updateTrayIds.Count > 0) TraysHelper.UpdateTraysStatus(updateTrayIds, TrayStatus.Exported); msg.result = true; msg.AddMessage(ReturnCode.OK, "成功导出CSV文件"); } catch (Exception e) { msg.AddMessage(ReturnCode.Error, e.Message); } return msg; }
private void BtnNew_Click(object sender, RoutedEventArgs e) { ConfigUtil config = new ConfigUtil("STORE", "config.ini"); ProcessMsg msg = conditionService.GenPosition(config.Get("POSITION")); if (msg.result) { SPDataSource = null; DGTrayItemsDetail.ItemsSource = null; BtnFinsh.IsEnabled = false; BtnRePrint.IsEnabled = false; TBPackageId.IsEnabled = true; LabPackNum.Content = "0"; TBTrayId.Text = ""; TBPackageId.Text = ""; // LoadWarehouseConfig(); TBWarehouse.Text = config.Get("WAREHOUSE"); TBPosition.Text = msg.GetAllLevelMsgs().Trim(); } else { new InfoBoard(MsgLevel.Mistake, msg.GetAllLevelMsgs()).ShowDialog(); } }
public ProcessMsg Print(Hashtable printConfig, PrintDataMessage pmsg) { ProcessMsg msg = new ProcessMsg(); try { IReportGen gen = new TecITGener(); foreach (PrintTask task in pmsg.PrintTask) { task.Config.Printer = printConfig["PrinterName"].ToString(); task.Config.NumberOfCopies = int.Parse(printConfig["Copy"].ToString()); task.Config.Template = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, printConfig["Template"].ToString()); gen.Print(task.DataSet, task.Config); } msg.result = true; msg.AddMessage(ReturnCode.OK, "打印成功!"); } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Fail, "打印错误:" + e.Message); } return(msg); }
public ProcessMsg CompleteStore(List<string> packageIds, string whouse, string posi) { using (TransactionScope trans = new TransactionScope()) { using (IUnitOfWork unit = MSSqlHelper.DataContext()) { ProcessMsg msg = new ProcessMsg(); try { string trayId = "T" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); ITraysRep tr = new TraysRep(unit); ITrayItemRep tir = new TrayItemRep(unit); ISinglePackageRep spr = new SinglePackageRep(unit); Trays ts = new Trays() { trayId = trayId, createTime = DateTime.Now, warehouse = whouse, position = posi, status = (int)TrayStatus.Stored, rowguid = Guid.NewGuid() }; List<TrayItem> tis = new List<TrayItem>(); foreach (string pid in packageIds) { tis.Add(new TrayItem() { itemId = Guid.NewGuid(), trayId = ts.trayId, packageId = pid, rowguid = Guid.NewGuid() }); } bool synced = false; // sync container data try { List<SinglePackage> singlePackages = spr.GetListByIds(packageIds); synced = new ApiService().SyncStoreContainer(GenContainers(ts, singlePackages, GetWhouse())); } catch (ApiException ae) { msg.AddMessage(ReturnCode.Warning, ae.Message); synced = false; } catch { synced = false; } ts.sync = synced; tr.AddSingle(ts); tir.AddMuti(tis); unit.Submit(); trans.Complete(); msg.result = true; if (synced) { msg.AddMessage(ReturnCode.OK, ts.trayId); } else { msg.AddMessage(ReturnCode.OK, ts.trayId); msg.AddMessage(ReturnCode.Warning, "托盘生成成功,但WMS同步失败,请检查网络,稍候重新同步!"); } } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!"); } finally { trans.Dispose(); } return msg; } } }
public ProcessMsg SyncStore() { 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.GetUnsync(); ITrayItemRep tir = new TrayItemRep(unit); bool all_synced = true; bool error_loged = false; string error_log = DateTime.Now.ToString("yyyyMMddHHmmsss") + ".txt"; string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ErrorLog", error_log); using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (StreamWriter sw = new StreamWriter(fs)) { foreach (Trays ts in tis) { bool synced = false; try { if (ts.status == (int)TrayStatus.Cancled) { synced = new ApiService().SyncUnStoreContainer(ts.trayId, GetWhouse()); } else { List<SinglePackage> singlePackages = tir.GetSPByTrayId(ts.trayId); synced = new ApiService().SyncStoreContainer(GenContainers(ts, singlePackages, GetWhouse())); } } catch (ApiException ae) { sw.WriteLine(ae.Message); error_loged = true; synced = false; } catch { synced = false; } ts.sync = synced; if (synced == false) { all_synced = false; } } } } unit.Submit(); trans.Complete(); msg.result = all_synced; if (all_synced) { msg.AddMessage(ReturnCode.OK, "WMS同步成功!"); } else { if (error_loged) { msg.AddMessage(ReturnCode.Warning, "WMS同步失败,查看错误日志:" + error_log + "请稍候重新同步!\n或联系程序管理员!"); } else { msg.AddMessage(ReturnCode.Warning, "WMS同步失败,请检查网络,稍候重新同步!\n或联系程序管理员!"); } } } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!"); } finally { trans.Dispose(); } return msg; } } }
public ProcessMsg SyncStore() { 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.GetUnsync(); ITrayItemRep tir = new TrayItemRep(unit); bool all_synced = true; bool error_loged = false; string error_log = DateTime.Now.ToString("yyyyMMddHHmmsss") + ".txt"; string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ErrorLog", error_log); using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (StreamWriter sw = new StreamWriter(fs)) { foreach (Trays ts in tis) { bool synced = false; try { if (ts.status == (int)TrayStatus.Cancled) { synced = new ApiService().SyncUnStoreContainer(ts.trayId, GetWhouse()); } else { List <SinglePackage> singlePackages = tir.GetSPByTrayId(ts.trayId); synced = new ApiService().SyncStoreContainer(GenContainers(ts, singlePackages, GetWhouse())); } } catch (ApiException ae) { sw.WriteLine(ae.Message); error_loged = true; synced = false; } catch { synced = false; } ts.sync = synced; if (synced == false) { all_synced = false; } } } } unit.Submit(); trans.Complete(); msg.result = all_synced; if (all_synced) { msg.AddMessage(ReturnCode.OK, "WMS同步成功!"); } else { if (error_loged) { msg.AddMessage(ReturnCode.Warning, "WMS同步失败,查看错误日志:" + error_log + "请稍候重新同步!\n或联系程序管理员!"); } else { msg.AddMessage(ReturnCode.Warning, "WMS同步失败,请检查网络,稍候重新同步!\n或联系程序管理员!"); } } } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!"); } finally { trans.Dispose(); } return(msg); } } }
public ProcessMsg CompleteStore(List <string> packageIds, string whouse, string posi) { using (TransactionScope trans = new TransactionScope()) { using (IUnitOfWork unit = MSSqlHelper.DataContext()) { ProcessMsg msg = new ProcessMsg(); try { string trayId = "T" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); ITraysRep tr = new TraysRep(unit); ITrayItemRep tir = new TrayItemRep(unit); ISinglePackageRep spr = new SinglePackageRep(unit); Trays ts = new Trays() { trayId = trayId, createTime = DateTime.Now, warehouse = whouse, position = posi, status = (int)TrayStatus.Stored, rowguid = Guid.NewGuid() }; List <TrayItem> tis = new List <TrayItem>(); foreach (string pid in packageIds) { tis.Add(new TrayItem() { itemId = Guid.NewGuid(), trayId = ts.trayId, packageId = pid, rowguid = Guid.NewGuid() }); } bool synced = false; // sync container data try { List <SinglePackage> singlePackages = spr.GetListByIds(packageIds); synced = new ApiService().SyncStoreContainer(GenContainers(ts, singlePackages, GetWhouse())); } catch (ApiException ae) { msg.AddMessage(ReturnCode.Warning, ae.Message); synced = false; } catch { synced = false; } ts.sync = synced; tr.AddSingle(ts); tir.AddMuti(tis); unit.Submit(); trans.Complete(); msg.result = true; if (synced) { msg.AddMessage(ReturnCode.OK, ts.trayId); } else { msg.AddMessage(ReturnCode.OK, ts.trayId); msg.AddMessage(ReturnCode.Warning, "托盘生成成功,但WMS同步失败,请检查网络,稍候重新同步!"); } } catch (Exception e) { msg.result = false; msg.AddMessage(ReturnCode.Error, "错误:" + e.Message + "\n请联系程序管理员!"); } finally { trans.Dispose(); } return(msg); } } }