/// <summary> /// 活动表操作历史进行记录 /// </summary> /// <param name="activeID"></param> /// <param name="Operation"></param> /// <param name="Author"></param> /// <param name="HostName"></param> /// <param name="IPAddress"></param> /// <returns></returns> public static int InsertHistoryActions(int activeID, string ObjectType, string AfterValue, string Operation, string Author, string HostName, string IPAddress) { OprLogManager log = new OprLogManager(); OprLogModel model = new OprLogModel(); model.ObjectId = activeID; model.ObjectType = ObjectType; model.AfterValue = AfterValue; model.Operation = Operation; //model.Author = Author; model.Author = ThreadIdentity.Operator.Name; model.HostName = HostName; model.IpAddress = IPAddress; int flag = 0; using (var client = new OprLogClient()) { var result = client.AddOprLog(model); if (result.Result > 0) { flag = 1; } } return(flag); }
public static IEnumerable <ConfigHistory> SelectOprLogByObjectTypeAndAftervalue(string objectType, string afterValue) { IEnumerable <ConfigHistory> result = null; switch (objectType) { case "TireTJ": case "T-ListAct": result = DALLogger.SelectOprLogByObjectTypeAndAftervalue(objectType, afterValue); break; default: using (var client = new OprLogClient()) { var oprlist = client.SelectOrderOprLog(0, objectType); if (oprlist != null && oprlist.Result.Count() > 0) { var tempList = oprlist.Result.Where(t => t.AfterValue.Equals(afterValue) || t.AfterValue.Equals(afterValue + ",")).ToList(); //AutoMapper初始化配置文件 var config = new MapperConfiguration(cfg => cfg.CreateMap <OprLogModel, ConfigHistory>()); var mapper = config.CreateMapper(); //集合类型转换 result = mapper.Map <IEnumerable <ConfigHistory> >(tempList); } } break; } return(result); }
public static IEnumerable <ConfigHistory> SelectOprLogByParams(string objectType, string objectId) { OperationResult <IEnumerable <OprLogModel> > oprlist = null; using (var client = new OprLogClient()) { oprlist = client.SelectOrderOprLog(int.Parse(objectId), objectType); } //AutoMapper初始化配置文件 var config = new MapperConfiguration(cfg => cfg.CreateMap <OprLogModel, ConfigHistory>()); var mapper = config.CreateMapper(); //集合类型转换 return(mapper.Map <IEnumerable <ConfigHistory> >(oprlist.Result)); }
public static void AddOprLog(string pid, bool isDelete) { using (var client = new OprLogClient()) { var result = client.AddOprLog(new Service.OprLog.Models.OprLogModel() { Author = "Job定时更新", ChangeDatetime = DateTime.Now, AfterValue = pid, ObjectType = "StockWhite", Operation = isDelete ? "移除白名单(系统)" : "加入白名单(系统)" }); result.ThrowIfException(true); } }
/// <summary> /// 活动表的操作历史记录的查看 /// </summary> /// <param name="activeID"></param> /// <returns></returns> public static IEnumerable <OprLogModel> HistoryActions(int activeID, string type) { //return DALWebActivityDetail.HistoryActions(activeID, type).Rows.Cast<DataRow>().Select(row => new ConfigHistory(row)); using (var client = new OprLogClient()) { var result = client.SelectOrderOprLog(activeID, type); if (result.Success) { return(result.Result); } else { return(new List <OprLogModel>()); } } }
public List <ConfigHistory> GetOprLog(int pkid, DateTime startTime, DateTime endTime) { OperationResult <IEnumerable <OprLogModel> > oprlist = null; using (var client = new OprLogClient()) { oprlist = client.SelectOrderOprLog(pkid, "CVPage"); } var tempList = oprlist.Result.Where(t => t.ChangeDatetime >= startTime && t.ChangeDatetime <= endTime).ToList(); //AutoMapper初始化配置文件 var config = new MapperConfiguration(cfg => cfg.CreateMap <OprLogModel, ConfigHistory>()); var mapper = config.CreateMapper(); //集合类型转换 return(mapper.Map <IEnumerable <ConfigHistory> >(tempList).ToList()); }
public void Add(OprLog oprLog) { ParameterChecker.CheckNull(oprLog, "oprLog"); if (string.IsNullOrEmpty(oprLog.Author)) { oprLog.Author = ThreadIdentity.Operator.Name; } if (string.IsNullOrEmpty(oprLog.IPAddress)) { oprLog.IPAddress = ThreadIdentity.Operator.IPAddress; } OprLogModel opl = new OprLogModel(); opl.ObjectId = oprLog.ObjectID; opl.ObjectType = oprLog.ObjectType; opl.Operation = oprLog.Operation; opl.Author = oprLog.Author; opl.BeforeValue = oprLog.BeforeValue; opl.AfterValue = oprLog.AfterValue; opl.HostName = oprLog.HostName; opl.IpAddress = oprLog.IPAddress; opl.ChangeDatetime = DateTime.Now; try { using (var client = new OprLogClient()) { var result2 = client.AddOprLog(opl); bool EnablePower = false; if (bool.TryParse(WebConfigurationManager.AppSettings["EnablePower"], out EnablePower) && EnablePower) { result2.ThrowIfException(true); } } } catch (Exception ex) { Logger.Log(Level.Error, ex, "AddOprLog"); throw ex; } }
public static bool InsertOplog(ConfigHistory model) { //AutoMapper初始化配置文件 var config = new MapperConfiguration(cfg => cfg.CreateMap <ConfigHistory, OprLogModel>()); var mapper = config.CreateMapper(); //集合类型转换 var oprLogModel = mapper.Map <OprLogModel>(model); bool flag = false; using (var client = new OprLogClient()) { var result = client.AddOprLog(oprLogModel); if (result.Result > 0) { flag = true; } } return(flag); }
public ActionResult SelectOprLog(string type)//轮胎到店 1 轮胎非到店2 保养到店3 保养非到店4 轮毂到店 5 轮毂非到店6 { var content = ""; OperationResult <IEnumerable <OprLogModel> > oprlist = null; using (var client = new OprLogClient()) { oprlist = client.SelectOrderOprLog(int.Parse(type), "SetYunFei"); } if (oprlist.Result == null || oprlist.Result.Count() == 0) { content = "暂无记录"; } else { foreach (OprLogModel model in oprlist.Result) { content += "<span style='display:block;margin-bottom:5px;'>操作人:" + model.Author + " 操作:" + model.Operation + " 操作时间:" + model.ChangeDatetime + "</span>"; } } return(Content(content)); }
/// <summary> /// 第二次发送:发送承保数据 /// </summary> /// <param name="logger"></param> //public static void SecondSend(ILog logger) //{ // List<DInsuranceTyre> _TyreList = DALInsuranceTyre.GetSecondTypeListFromOrder().OrderBy(p => p.orderNo).ThenBy(p => p.PID).ToList(); // string _ExitOrderID = string.Empty; // string _ExitPID = string.Empty; // foreach (var item in _TyreList) // { // try // { // if (string.Equals(item.orderNo, _ExitOrderID) && string.Equals(item.PID, _ExitPID)) // { // continue; // } // item.type = "2"; // item.state = 0; // item.SentTime = DateTime.Now; // var _TyreIDList = DALInsuranceTyre.GetTyreID(int.Parse(item.orderNo), item.PID); // if (_TyreIDList != null && _TyreIDList.Tables[0].Rows.Count > 0) // { // logger.Info("处理开始,OrderList:" + JsonConvert.SerializeObject(item)); // foreach (DataRow dr in _TyreIDList.Tables[0].Rows) // { // item.tyreId = dr["InsuranceCode"].ToString(); // item.tyreBatchNo = dr["WeekYear"].ToString(); // bool IsRight = true; // if (string.IsNullOrEmpty(item.tyreId)) // { // logger.Error("轮胎条形码为空,OrderListPkid:" + item.OrderListPkid); // DalMonitor.AddMonitorOperation(new MonitorOperation() // { // SubjectType = "Order", // SubjectId = item.orderNo, // ErrorMessage = "轮胎条形码为空,OrderListPkid:" + item.OrderListPkid, // OperationUser = "******", // OperationName = "Insurance", // MonitorLevel = 2, // MonitorModule = "JobSchedulerService" // }); // IsRight = false; // } // if (string.IsNullOrEmpty(item.tyreBatchNo)) // { // logger.Error("轮胎批号为空,OrderListPkid:" + item.OrderListPkid); // DalMonitor.AddMonitorOperation(new MonitorOperation() // { // SubjectType = "Order", // SubjectId = item.orderNo, // ErrorMessage = "轮胎批号为空,OrderListPkid:" + item.OrderListPkid, // OperationUser = "******", // OperationName = "Insurance", // MonitorLevel = 2, // MonitorModule = "JobSchedulerService" // }); // IsRight = false; // } // if (IsRight) // { // var insuranceTyreSuc = DALInsuranceTyre.GetInsuranceType(item.tyreId, item.type, 1, item.orderNo); // if (insuranceTyreSuc != null) // { // continue; // } // string _PKID = string.Empty; // var insuranceTyre = DALInsuranceTyre.GetInsuranceType(item.tyreId, item.type, 0, item.orderNo); // if (insuranceTyre != null) // { // _PKID = insuranceTyre.PKID.ToString(); // } // else // { // _PKID = DALInsuranceTyre.AddInsuranceTyre(item); // } // item.PKID = int.Parse(_PKID); // IDictionary<String, String> _Result = DataInteraction.ZAOP.SendData(item); // logger.Info("发送数据结束,OrderListPkid:" + item.OrderListPkid + ",返回" + JsonConvert.SerializeObject(_Result)); // string _BizContentString = _Result["bizContent"]; // if (!string.IsNullOrEmpty(_BizContentString)) // { // IDictionary<String, String> _BizContent = JsonConvert.DeserializeObject<Dictionary<String, String>>(_BizContentString); // string _ReturnCode = _BizContent["returnCode"]; // if (!string.IsNullOrEmpty(_ReturnCode) && _ReturnCode == "00") // { // DInsuranceNO _DInsuranceNO = new DInsuranceNO() // { // tyreId = _BizContent["tyreId"], // policyNo = _BizContent["policyNo"], // effectiveDate = _BizContent["effectiveDate"], // endDate = _BizContent["endDate"], // issueDate = _BizContent["issueDate"], // }; // DALInsuranceNO.AddInsuranceNO(_DInsuranceNO); // logger.Info("更新发送表,OrderListPkid:" + item.OrderListPkid + ",返回" + _ReturnCode); // DALInsuranceTyre.UpdateState(1, item.PKID); // var oprLog = new DOprLog() // { // Author = "ZhongAnJob", // ObjectType = "Order", // ObjectID = int.Parse(item.orderNo.Trim()), // BeforeValue = string.Format("轮胎保险号:{0}", item.tyreId), // AfterValue = string.Format("众安保单号:{0}", _DInsuranceNO.policyNo), // ChangeDatetime = DateTime.Now, // Operation = "众安保险投保", // }; // ThreadPool.QueueUserWorkItem(_ => // { // OprLogModel opl = new OprLogModel() // { // ObjectId = int.Parse(item.orderNo.Trim()), // ObjectType = "Order", // Operation = "众安保险投保", // Author = "ZhongAnJob", // BeforeValue = string.Format("轮胎保险号:{0}", item.tyreId), // AfterValue = string.Format("众安保单号:{0}", _DInsuranceNO.policyNo), // ChangeDatetime = DateTime.Now // }; // try // { // using (var client = new OprLogClient()) // { // var result = client.Invoke(channel => channel.AddOprLog(opl)); // if (!result.Success) // { // oprLog.HostName += "Error"; // DALOprLog.InsertOprLog(oprLog); // } // } // } // catch (Exception ex) // { // oprLog.HostName += "Error"; // DALOprLog.InsertOprLog(oprLog); // } // }, oprLog); // } // else // { // DalMonitor.AddMonitorOperation(new MonitorOperation() // { // SubjectType = "Order", // SubjectId = item.orderNo, // ErrorMessage = "更新发送表错误:" + _BizContentString, // OperationUser = "******", // OperationName = "Insurance", // MonitorLevel = 2, // MonitorModule = "JobSchedulerService" // }); // } // } // } // } // } // } // catch (Exception ex) // { // logger.Error("第二次发送错误:", ex); // DalMonitor.AddMonitorOperation(new MonitorOperation() // { // SubjectType = "Order", // SubjectId = item.orderNo, // ErrorMessage = "第二次发送错误:" + ex.ToString(), // OperationUser = "******", // OperationName = "Insurance", // MonitorLevel = 2, // MonitorModule = "JobSchedulerService" // }); // } // } //} public static void SecondSend(ILog logger) { var orders = DALOrder.SelectSecondSendOrders(); foreach (var order in orders) { #region 投保 var orderToinsuranceTyreId = -1; var isNeedUpdateInsuranceStatus = false; var insuranceTyres = DALInsuranceTyre.GetFirstTypeListFromOrder(order.PKID); var orderToinsuranceTyre = DALOrderToInsuranceTyre.GetOrderToInsuranceTyre(order.PKID, 2, 1); if (orderToinsuranceTyre != null) { continue; } orderToinsuranceTyre = DALOrderToInsuranceTyre.GetOrderToInsuranceTyre(order.PKID, 2, 0); if (orderToinsuranceTyre == null) { orderToinsuranceTyreId = DALOrderToInsuranceTyre.InsertOrderToInsuranceTyre(new DOrderToInsuranceTyre() { OrderId = order.PKID, InsuranceType = 2, InsuranceStatus = 0, CreatedBy = "ZhongAnJob" }); } else { orderToinsuranceTyreId = orderToinsuranceTyre.PKID; } string _ExitOrderID = string.Empty; string _ExitPID = string.Empty; var insuranceNos = new List <string>(); foreach (var item in insuranceTyres) { item.orderNo = order.PKID.ToString(); item.orderDate = string.Format("{0:yyyy-MM-dd HH:mm:ss}", order.OrderDate); item.customerName = order.UserName; // item.customerPhoneNo = order.UserTel; item.plateNumber = order.CarPlate; item.storeAddress = order.StoreAddress; item.storeName = order.StoreName; try { if (string.Equals(item.orderNo, _ExitOrderID) && string.Equals(item.PID, _ExitPID)) { continue; } item.type = "2"; item.state = 0; item.SentTime = DateTime.Now; var _TyreIDList = DALInsuranceTyre.GetTyreID(int.Parse(item.orderNo), item.PID); if (_TyreIDList != null && _TyreIDList.Tables[0].Rows.Count > 0) { var olCount = 0; logger.Info("处理开始,OrderList:" + JsonConvert.SerializeObject(item)); foreach (DataRow dr in _TyreIDList.Tables[0].Rows) { item.tyreId = dr["InsuranceCode"].ToString(); item.tyreBatchNo = dr["WeekYear"].ToString(); bool IsRight = true; if (string.IsNullOrEmpty(item.tyreId)) { logger.Error("轮胎条形码为空,OrderListPkid:" + item.OrderListPkid); DalMonitor.AddMonitorOperation(new MonitorOperation() { SubjectType = "Order", SubjectId = item.orderNo, ErrorMessage = "轮胎条形码为空,OrderListPkid:" + item.OrderListPkid, OperationUser = "******", OperationName = "Insurance", MonitorLevel = 2, MonitorModule = "JobSchedulerService" }); IsRight = false; } if (string.IsNullOrEmpty(item.tyreBatchNo)) { logger.Error("轮胎批号为空,OrderListPkid:" + item.OrderListPkid); DalMonitor.AddMonitorOperation(new MonitorOperation() { SubjectType = "Order", SubjectId = item.orderNo, ErrorMessage = "轮胎批号为空,OrderListPkid:" + item.OrderListPkid, OperationUser = "******", OperationName = "Insurance", MonitorLevel = 2, MonitorModule = "JobSchedulerService" }); IsRight = false; } olCount++; if (olCount > item.Num) { // 部分取消的单子只需要随即选条码导入 IsRight = false; } if (IsRight) { var insuranceTyreSuc = DALInsuranceTyre.GetInsuranceType(item.tyreId, item.type, 1, item.orderNo); if (insuranceTyreSuc != null) { continue; } string _PKID = string.Empty; var insuranceTyre = DALInsuranceTyre.GetInsuranceType(item.tyreId, item.type, 0, item.orderNo); if (insuranceTyre != null) { _PKID = insuranceTyre.PKID.ToString(); } else { _PKID = DALInsuranceTyre.AddInsuranceTyre(item); } item.PKID = int.Parse(_PKID); IDictionary <String, String> _Result = DataInteraction.ZAOP.SendData(item); logger.Info("发送数据结束,OrderListPkid:" + item.OrderListPkid + ",返回" + JsonConvert.SerializeObject(_Result)); string _BizContentString = _Result["bizContent"]; if (!string.IsNullOrEmpty(_BizContentString)) { IDictionary <String, String> _BizContent = JsonConvert.DeserializeObject <Dictionary <String, String> >(_BizContentString); string _ReturnCode = _BizContent["returnCode"]; if (!string.IsNullOrEmpty(_ReturnCode) && _ReturnCode == "00") { DInsuranceNO _DInsuranceNO = new DInsuranceNO() { tyreId = _BizContent["tyreId"], policyNo = _BizContent["policyNo"], effectiveDate = _BizContent["effectiveDate"], endDate = _BizContent["endDate"], issueDate = _BizContent["issueDate"], }; DALInsuranceNO.AddInsuranceNO(_DInsuranceNO); logger.Info("更新发送表,OrderListPkid:" + item.OrderListPkid + ",返回" + _ReturnCode); DALInsuranceTyre.UpdateState(1, item.PKID); isNeedUpdateInsuranceStatus = true; if (!insuranceNos.Contains(_DInsuranceNO.policyNo)) { insuranceNos.Add(_DInsuranceNO.policyNo); } var oprLog = new DOprLog() { Author = "ZhongAnJob", ObjectType = "Order", ObjectID = int.Parse(item.orderNo.Trim()), BeforeValue = string.Format("轮胎保险号:{0}", item.tyreId), AfterValue = string.Format("众安保单号:{0}", _DInsuranceNO.policyNo), ChangeDatetime = DateTime.Now, Operation = "众安保险投保", }; ThreadPool.QueueUserWorkItem(_ => { OprLogModel opl = new OprLogModel() { ObjectId = int.Parse(item.orderNo.Trim()), ObjectType = "Order", Operation = "众安保险投保", Author = "ZhongAnJob", BeforeValue = string.Format("轮胎保险号:{0}", item.tyreId), AfterValue = string.Format("众安保单号:{0}", _DInsuranceNO.policyNo), ChangeDatetime = DateTime.Now }; try { using (var client = new OprLogClient()) { var result = client.Invoke(channel => channel.AddOprLog(opl)); if (!result.Success) { oprLog.HostName += "Error"; // DALOprLog.InsertOprLog(oprLog); } } } catch (Exception ex) { oprLog.HostName += "Error"; // DALOprLog.InsertOprLog(oprLog); } }, oprLog); } else { DalMonitor.AddMonitorOperation(new MonitorOperation() { SubjectType = "Order", SubjectId = item.orderNo, ErrorMessage = "更新发送表错误:" + _BizContentString, OperationUser = "******", OperationName = "Insurance", MonitorLevel = 2, MonitorModule = "JobSchedulerService" }); } } } } } } catch (Exception ex) { logger.Error("第二次发送错误:", ex); DalMonitor.AddMonitorOperation(new MonitorOperation() { SubjectType = "Order", SubjectId = item.orderNo, ErrorMessage = "第二次发送错误:" + ex.ToString(), OperationUser = "******", OperationName = "Insurance", MonitorLevel = 2, MonitorModule = "JobSchedulerService" }); } } #endregion #region 更新订单承保数据的投保状态 if (isNeedUpdateInsuranceStatus) { var needInsureNum = insuranceTyres.Sum(_ => _.Num); var insuredNum = DALInsuranceTyre.SelectInsuranceTypes(2, 1, order.PKID).Count; if (needInsureNum == insuredNum) { DALOrderToInsuranceTyre.UpdateOrderToInsuranceTyreStatus(orderToinsuranceTyreId, 1); } if (insuranceNos.Any()) { try { var insuranceMessage = string.Format(ConfigurationManager.AppSettings["Sms_ZhongAnInsurance"], order.OrderNo, string.Join(",", insuranceNos)); // 模板:【133】尊敬的途虎用户,您的轮胎保(途虎轮胎订单号{0})已由众安保险成功承保,保险凭证号{1},如有任何疑问请致电400-111-8868。 using (var smsClient = new SmsClient()) { var result = smsClient.SendSms(new SendTemplateSmsRequest { Cellphone = order.UserTel, UserData = order.OrderNo, TemplateId = 133, TemplateArguments = new [] { order.OrderNo, string.Join(",", insuranceNos) } }); logger.Info($"Tuhu.Yewu.Job.ZhongAn 途虎养车轮胎险投保发送短信,请求信息:{JsonConvert.SerializeObject(result)},响应信息:{JsonConvert.SerializeObject(result)}"); result.ThrowIfException(true); if (result.Result <= 0) { logger.Error("Tuhu.Yewu.Job.ZhongAn 途虎养车轮胎险投保发送短信发送短信失败,请求信息:{JsonConvert.SerializeObject(result)},响应信息:{JsonConvert.SerializeObject(result)}", new Exception($"ErrorCode:{result.ErrorCode??result.Result.ToString()},ErrorMsg:{result.ErrorMessage}")); } } } catch (Exception ex) { DalMonitor.AddMonitorOperation(new MonitorOperation() { SubjectType = "Order", SubjectId = order.PKID.ToString(), ErrorMessage = "第二次发送错误:" + ex.ToString(), OperationUser = "******", OperationName = "Insurance", MonitorLevel = 2, MonitorModule = "JobSchedulerService" }); } } } #endregion } }