/// <summary> /// 异步委托方法,根据coldCoilNo卷号 查询数据库 得到colorCode颜色代码和Thick厚度和Width宽度 /// </summary> /// <param name="colorCode">out 颜色代码</param> /// <param name="coldCoilNo">卷号</param> public void getColorCodeAndThickAndWeight(out string colorCode, string coldCoilNo) { string strCon = "server=10.0.1.12" + ";Database=LEVEL3" + ";Uid=sa" + ";Pwd=bule71" + ";Connection Timeout = 5;"; SqlConnection sqlcon = new SqlConnection(strCon); sqlcon.Open(); SqlDataAdapter da = new SqlDataAdapter("select COLOR_UP_CD,COLDCOILNO,COILSEQ,ORDWTH,ORDTHK from PDI where COLDCOILNO=" + "'" + coldCoilNo + "'", sqlcon); DataTable dt = new DataTable();//填充DataTable da.Fill(dt); //da.Fill(new DataSet(),"s"); var row = dt.Rows[0]; ERP obj = new ERP() { COLOR_UP_CD = row["COLOR_UP_CD"].ToString().Trim(), COILSEQ = row["COILSEQ"].ToString().Trim(), ORDTHK = row["ORDTHK"].ToString().Trim(), ORDWTH = row["ORDWTH"].ToString().Trim(), }; colorCode = obj.COLOR_UP_CD; spiDomain.colorCode = obj.COLOR_UP_CD; spiDomain.subRollNumber = obj.COILSEQ; spiDomain.width = obj.ORDWTH; spiDomain.thickness = obj.ORDTHK; }
/// <summary> /// 导出报表 /// </summary> /// <param name="obj"></param> private void OrderOptionBase_OnPostCompletedEventHandle(List <OMS.Models.OrderEntity> obj, OptionType optionType) { if (obj != null && obj.Any()) { try { ERP.ExportExcel <OrderEntity>(optionType, obj); } catch (Exception ex) { Util.Logs.Log.GetLog(nameof(AppServer)).Error($"{obj.First().SourceDesc}-{Util.Helpers.Enum.GetDescription<OptionType>(optionType)}生成失败.\r\n{ex.Message}\r\n{ex.StackTrace}"); } } else { //if (Environment.UserInteractive) //{ // var commcolor = Console.ForegroundColor; // Console.ForegroundColor = ConsoleColor.Green; // Console.WriteLine($"没有检测到新订单数据。ERP-{obj[0].Source}导入订单生成失败"); // Console.ForegroundColor = commcolor; //} } }
private void OrderOptionBase_ExceptionMessageEventHandle1(ICollection <ExceptionOrder> obj) { if (obj != null && obj.Any()) { ERP.ExportExcel <ExceptionOrder>(OptionType.ExceptionExcel, obj.ToList()); var glst = obj.GroupBy(e => e.ErrorCode); foreach (var item in glst) { WxPushNews.SendErrorText($"错误类型:{Util.Helpers.Enum.GetDescription<ExceptionType>(item.Key)},数量:{item.Count()}"); } } else { } }
/// <summary> /// ���ÿ��ư�ť��ʼ״̬ /// </summary> /// <param name="BWS.ERP.BasePublic.OperateFlag">����״̬</param> public virtual void initButtonsState(ERP.BasePublic.OperateFlag operateflag) { switch (operateflag) { case BWS.ERP.BasePublic.OperateFlag.View: { btnView.Enabled = true; btnAdd.Enabled = true; btnEdit.Enabled = true; btnCancel.Enabled = false; btnSave.Enabled = false; btnDelete.Enabled = true; btnPrint.Enabled = true; btnClose.Enabled = true; btnCopy.Enabled = true; break; } case BWS.ERP.BasePublic.OperateFlag.Insert: { btnView.Enabled = false; btnAdd.Enabled = false; btnEdit.Enabled = false; btnCancel.Enabled = true; btnSave.Enabled = true; btnDelete.Enabled = false; btnPrint.Enabled = false; btnClose.Enabled = true; btnCopy.Enabled = false; break; } case BWS.ERP.BasePublic.OperateFlag.Edit: { btnView.Enabled = false; btnAdd.Enabled = false; btnEdit.Enabled = false; btnCancel.Enabled = true; btnSave.Enabled = true; btnDelete.Enabled = false; btnPrint.Enabled = false; btnClose.Enabled = true; btnCopy.Enabled = false; break; } case BWS.ERP.BasePublic.OperateFlag.Cancel: { btnView.Enabled = true; btnAdd.Enabled = true; btnEdit.Enabled = true; btnCancel.Enabled = false; btnSave.Enabled = false; btnDelete.Enabled = true; btnPrint.Enabled = true; btnClose.Enabled = true; btnCopy.Enabled = true; break; } case BWS.ERP.BasePublic.OperateFlag.Save: { btnView.Enabled = true; btnAdd.Enabled = true; btnEdit.Enabled = true; btnCancel.Enabled = false; btnSave.Enabled = false; btnDelete.Enabled = true; btnPrint.Enabled = true; btnClose.Enabled = true; btnCopy.Enabled = true; break; } case BWS.ERP.BasePublic.OperateFlag.Copy: { btnView.Enabled = false; btnAdd.Enabled = false; btnEdit.Enabled = false; btnCancel.Enabled = true; btnSave.Enabled = true; btnDelete.Enabled = false; btnPrint.Enabled = false; btnClose.Enabled = true; btnCopy.Enabled = false; break; } case BWS.ERP.BasePublic.OperateFlag.Delete: { btnView.Enabled = true; btnAdd.Enabled = true; btnEdit.Enabled = true; btnCancel.Enabled = false; btnSave.Enabled = false; btnDelete.Enabled = true; btnPrint.Enabled = true; btnClose.Enabled = true; btnCopy.Enabled = true; break; } case BWS.ERP.BasePublic.OperateFlag.None: { btnView.Enabled = true; btnAdd.Enabled = true; btnEdit.Enabled = false; btnCancel.Enabled = false; btnSave.Enabled = false; btnDelete.Enabled = false; btnPrint.Enabled = false; btnClose.Enabled = true; btnCopy.Enabled = false; break; } default: { btnView.Enabled = true; btnAdd.Enabled = true; btnEdit.Enabled = true; btnCancel.Enabled = false; btnSave.Enabled = false; btnDelete.Enabled = true; btnPrint.Enabled = true; btnClose.Enabled = true; btnCopy.Enabled = true; break; } } }
static void Main(string[] args) { var invoice = new { CustomerId = 33, ProductId = 22, Quantity = 9, Amount = 3423.34m, }; var startTime = Environment.TickCount; #region Versión secuencial /* * if (!Stock.HasStock(invoice.ProductId, invoice.Quantity)) * throw new Exception(); * * if (!CRM.HasCredit(invoice.CustomerId, invoice.Amount)) * throw new Exception(); * * DateTime deliveryDate = Delivery.GetDeliveryDate(invoice.CustomerId, invoice.ProductId, invoice.Quantity); * * decimal discount = CRM.ValidateDiscount(invoice.CustomerId, invoice.CustomerId, invoice.Quantity, invoice.Amount, 7m); * * ERP.SaveInvoice(invoice.CustomerId, invoice.ProductId, invoice.Quantity, discount); * * CRM.NewInvoice(invoice.CustomerId, invoice.ProductId, invoice.Quantity, deliveryDate, discount); * * Delivery.RequestDelivery(invoice.CustomerId, invoice.ProductId, invoice.Quantity, deliveryDate); * * Console.WriteLine(Environment.TickCount - startTime); */ #endregion #region Version concurrente var validateStock = Task.Factory.StartNew(() => { Console.WriteLine("Stock Validation - Start"); var result = Stock.HasStock(invoice.ProductId, invoice.Quantity); Console.WriteLine("Stock Validation - End"); return(result); } ); var hasCredit = Task.Factory.StartNew(() => { Console.WriteLine("Credit Validation - Start"); var result = CRM.HasCredit(invoice.CustomerId, invoice.Amount); Console.WriteLine("Credit Validation - End"); return(result); } ); var validation = Task.Factory.ContinueWhenAll( new Task[] { validateStock, hasCredit }, (tasks) => tasks.Cast <Task <bool> >().All((task) => task.Result) ); if (!validation.Result) { throw new Exception(); } var getDeliveryDate = Task.Factory.StartNew(() => Delivery.GetDeliveryDate(invoice.CustomerId, invoice.ProductId, invoice.Quantity) ); var validateDiscount = Task.Factory.StartNew(() => CRM.ValidateDiscount(invoice.CustomerId, invoice.CustomerId, invoice.Quantity, invoice.Amount, 7m) ); var saveInvoice = validateDiscount.ContinueWith( (task) => ERP.SaveInvoice(invoice.CustomerId, invoice.ProductId, invoice.Quantity, task.Result) ); var newInvoice = Task.Factory.ContinueWhenAll( new Task[] { getDeliveryDate, validateDiscount }, (task) => CRM.NewInvoice(invoice.CustomerId, invoice.ProductId, invoice.Quantity, getDeliveryDate.Result, validateDiscount.Result) ); var requestDelivery = Task.Factory.ContinueWhenAll( new Task[] { getDeliveryDate, saveInvoice }, (task) => Delivery.RequestDelivery(invoice.CustomerId, invoice.ProductId, invoice.Quantity, getDeliveryDate.Result) ); Console.Write("*"); requestDelivery.Wait(); Console.WriteLine(Environment.TickCount - startTime); #endregion Console.ReadKey(); }