using Cksoft.Data; using Cksoft.Data.Repository; using Cksoft.Unity; using Cksoft.Unity.Log4NetConfig; using DllEapDal; using DllEapEntity; using Newtonsoft.Json; using System; using System.Collections; using System.Collections.Generic; namespace DllEapBll { public class EapBll : IDisposable { private string CurrDbCode = "sqlconn"; private IDatabase CurrDb = null; public EapBll(string dbcode) { CurrDbCode = dbcode; CurrDb = DbFactory.Base(CurrDbCode); } public void Dispose() { if (CurrDb != null) CurrDb.Close(); } public Hashtable Login(Hashtable imputds, ref string errorinfo, ref int error) { try { //errorinfo = "到了登录函数Login"; //return null; if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); Staff entity = JsonConvert.DeserializeObject((string)imputds[nameof(Staff)]); string usercode = order.usercode; CurrDb.BeginTrans(); StaffDal tempdal = new StaffDal(CurrDb); entity = tempdal.Login(entity, ref errorinfo); if (entity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(Staff), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable IUMacModel(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); MacModel entity = JsonConvert.DeserializeObject((string)imputds[nameof(MacModel)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(MMSecDetail)]); string usercode = order.usercode; CurrDb.BeginTrans(); MacModelDal tempdal = new MacModelDal(CurrDb); entity = tempdal.IUMacModel(entity, details, order.usercode, ref errorinfo); if (entity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(MacModel), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable DelMacModel(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(MacModel)]); string usercode = order.usercode; CurrDb.BeginTrans(); MacModelDal tempdal = new MacModelDal(CurrDb); foreach (var item in details) { //entity = tempdal.IUMacModel(entity, details, order.usercode, ref errorinfo); //if (entity == null) //{ // CurrDb.Rollback(); // return null; //} } Hashtable reds = new Hashtable(); //reds.Add(nameof(MacModel), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable IUMachine(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); Machine entity = JsonConvert.DeserializeObject((string)imputds[nameof(Machine)]); string usercode = order.usercode; CurrDb.BeginTrans(); MachineDal tempdal = new MachineDal(CurrDb); entity = tempdal.IUMachine(entity, order.usercode, ref errorinfo); if (entity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(Machine), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); LogHelper.LogFatal("新增Machine-->" + Json.ToJson(entity), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable IUOrderMst(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderDetail)]); List datas = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderData)]); List secs = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderDetailSec)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); entity = tempdal.IUOrderMst(entity, details, datas, secs, order.usercode, ref errorinfo); if (entity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); LogHelper.LogFatal("新增OrderMst-->" + Json.ToJson(entity), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable AutoProcessOac(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.AutoProcessOac(entity.ID, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); LogHelper.LogFatal("AutoProcessOac-->" + Json.ToJson(entity), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable AddVersionOrder(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.AddVersionOrder(entity, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); LogHelper.LogFatal("新增OrderMst-->" + Json.ToJson(entity), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable CopyOrderDetailTo(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List desordermst = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderMst)]); List orgorderdetails = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderDetail)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); foreach (var item in desordermst) { int result = tempdal.CopyOrderDetail(orgorderdetails, item, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(desordermst[0])); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } finally { if (CurrDb != null) CurrDb.Close(); } } public Hashtable CopyOrder(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.CopyOrder(entity, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable DelOrderMst(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List entitys = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.DelOrderMst(entitys, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entitys[0])); CurrDb.Commit(); LogHelper.LogFatal("删除OrderMst-->" + Json.ToJson(entitys), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable OrderRelationMca(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); List entitys = JsonConvert.DeserializeObject>((string)imputds[nameof(Machine)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.OrderRelationMca(entity, entitys, usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable IUSec(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); Sec entity = JsonConvert.DeserializeObject((string)imputds[nameof(Sec)]); string usercode = order.usercode; CurrDb.BeginTrans(); SecDal tempdal = new SecDal(CurrDb); Sec reentity = tempdal.IUSec(entity, usercode, ref errorinfo); if (reentity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(Sec), JsonConvert.SerializeObject(reentity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable DelReportMst(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List entitys = JsonConvert.DeserializeObject>((string)imputds[nameof(ReportMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); ReportMstDal tempdal = new ReportMstDal(CurrDb); int result = tempdal.DelReportMst(entitys, ref errorinfo); if (result < 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(ReportMst), JsonConvert.SerializeObject(entitys[0])); CurrDb.Commit(); LogHelper.LogFatal("删除ReportMst-->" + Json.ToJson(entitys), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable IUReportMst(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); ReportMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(ReportMst)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(ReportDetail)]); string usercode = order.usercode; CurrDb.BeginTrans(); ReportMstDal tempdal = new ReportMstDal(CurrDb); ReportMst reentity = tempdal.IUReportMst(entity, details, usercode, ref errorinfo); if (reentity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(ReportMst), JsonConvert.SerializeObject(reentity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable CopyReportMst(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); ReportMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(ReportMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); ReportMstDal tempdal = new ReportMstDal(CurrDb); ReportMst reentity = tempdal.CopyReportMst(entity, usercode, ref errorinfo); if (reentity == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(ReportMst), JsonConvert.SerializeObject(reentity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable DelMachine(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(Machine)]); string usercode = order.usercode; CurrDb.BeginTrans(); MachineDal tempdal = new MachineDal(CurrDb); object result = tempdal.DelMachine(details, ref errorinfo); if (result == null) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add("result", JsonConvert.SerializeObject(result)); CurrDb.Commit(); LogHelper.LogFatal("删除Machine-->" + Json.ToJson(details), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable DelMacOrder(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List entitys = JsonConvert.DeserializeObject>((string)imputds[nameof(MacOrder)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.DelMacOrder(entitys); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(MacOrder), JsonConvert.SerializeObject(entitys[0])); CurrDb.Commit(); LogHelper.LogFatal("删除MacOrder-->" + Json.ToJson(entitys), "用户操作", usercode); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable IUOrderEvent(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderEvent)]); List datas = JsonConvert.DeserializeObject>((string)imputds[nameof(EventReportDetail)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.IUOrderEvent(details, datas, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable IUOrderStatus(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List details = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderStatus)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.IUOrderStatus(details, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable AccountOrderSecDetail(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.AccountOrderSecDetail(entity, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable UOrderSecDetail(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); //List details = JsonConvert.DeserializeObject>((string)imputds[nameof(OrderSecDetail)]); //string usercode = order.usercode; //CurrDb.BeginTrans(); //OrderMstDal tempdal = new OrderMstDal(CurrDb); //int result = tempdal.UOrderSecDetail(details, order.usercode, ref errorinfo); //if (result <= 0) //{ // CurrDb.Rollback(); // return null; //} Hashtable reds = new Hashtable(); reds.Add(nameof(ConstOrder), JsonConvert.SerializeObject(order)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable CopyOrderToModel(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); OrderMst entity = JsonConvert.DeserializeObject((string)imputds[nameof(OrderMst)]); MacModel model = JsonConvert.DeserializeObject((string)imputds[nameof(MacModel)]); string usercode = order.usercode; CurrDb.BeginTrans(); OrderMstDal tempdal = new OrderMstDal(CurrDb); int result = tempdal.CopyOrderToModel(entity, model, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add(nameof(OrderMst), JsonConvert.SerializeObject(entity)); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } public Hashtable ImportFileParams(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); List entity = JsonConvert.DeserializeObject>((string)imputds[nameof(FileParams)]); if (entity.Count <= 0) { errorinfo = "未找到传入的机型参数。"; return null; } string usercode = order.usercode; CurrDb.BeginTrans(); int modelid = entity[0].ModelID; FileParamsDal tempdal = new FileParamsDal(CurrDb); int result = tempdal.ImportFileParams(modelid, entity, order.usercode, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return null; } Hashtable reds = new Hashtable(); reds.Add("result", result); CurrDb.Commit(); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; CurrDb.Rollback(); return null; } } /// /// 根据机台编号,时间范围,读取机台对应的日志信息 /// /// /// /// /// public Hashtable ReadLog(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); Machine mac = JsonConvert.DeserializeObject((string)imputds[nameof(Machine)]); //DateTime starttime= JsonConvert.DeserializeObject((string)imputds["starttime"]); //DateTime endtime = JsonConvert.DeserializeObject((string)imputds["endtime"]); DateTime starttime = DateTime.Parse(imputds["starttime"].ToString()); DateTime endtime = DateTime.Parse(imputds["endtime"].ToString()); string usercode = order.usercode; LogDal tempdal = new LogDal(CurrDb); List logs = tempdal.ReadLog(mac, starttime, endtime, ref errorinfo); if (logs == null) { return null; } Hashtable reds = new Hashtable(); reds.Add("log", JsonConvert.SerializeObject(logs)); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; return null; } } public Hashtable ReadBusinessLog(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); Machine mac = JsonConvert.DeserializeObject((string)imputds[nameof(Machine)]); //DateTime starttime= JsonConvert.DeserializeObject((string)imputds["starttime"]); //DateTime endtime = JsonConvert.DeserializeObject((string)imputds["endtime"]); DateTime starttime = DateTime.Parse(imputds["starttime"].ToString()); DateTime endtime = DateTime.Parse(imputds["endtime"].ToString()); string usercode = order.usercode; LogDal tempdal = new LogDal(CurrDb); List logs = tempdal.ReadBusinessLog(mac, starttime, endtime, ref errorinfo); if (logs == null) { return null; } Hashtable reds = new Hashtable(); reds.Add("log", JsonConvert.SerializeObject(logs)); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; return null; } } public Hashtable SaveProgram(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); Machine mac = JsonConvert.DeserializeObject((string)imputds[nameof(Machine)]); CurrDb.BeginTrans(); string usercode = order.usercode; MacProgram resultprogram = null; if (mac.SupplierFCode == "KNS") { KnsProgramDal dal = new KnsProgramDal(CurrDb); resultprogram = dal.SaveProgram(mac.FCode, usercode, ref errorinfo); } else { AsmProgramDal dal = new AsmProgramDal(CurrDb); resultprogram = dal.SaveProgram(mac.FCode, usercode, ref errorinfo); } int result = 1; if (resultprogram == null) { result = -1; } Hashtable reds = new Hashtable(); reds.Add("result", result.ToString()); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; return null; } } public Hashtable SendStopOrder(Hashtable imputds, ref string errorinfo, ref int error) { try { if (imputds == null) { errorinfo = "传入数据不能为空,请确认"; error = 1; return null; } ConstOrder order = JsonConvert.DeserializeObject((string)imputds[nameof(ConstOrder)]); string maccode = (string)imputds["maccode"]; CurrDb.BeginTrans(); MacOrderSendDal dal = new MacOrderSendDal(CurrDb); int result = dal.SendStopMac(maccode, ref errorinfo); Hashtable reds = new Hashtable(); reds.Add("result", result.ToString()); return reds; } catch (Exception ex) { errorinfo = ex.Message.ToString(); error = 1; return null; } } public int ModifyProgramName(string maccode, string orgname, string desname, ref string errorinfo) { try { CurrDb.BeginTrans(); MacProgramDal dal = new MacProgramDal(CurrDb); int result = dal.ModifyProgramName(maccode, orgname, desname, ref errorinfo); if (result <= 0) { CurrDb.Rollback(); return -1; } CurrDb.Commit(); return 1; } catch (Exception ex) { errorinfo = ex.Message.ToString(); CurrDb.Rollback(); return -1; } } } }