public void AddShopOprLog <T, D>(int shopId, string objType, int objId, string operation, T beforeValue, D afterValue, string Remark) where T : class where D : class { ParameterChecker.CheckNullOrEmpty(objType, "objType"); ParameterChecker.CheckNullOrEmpty(operation, "operation"); var oprLog = new ShopEditOprLog(); oprLog.ShopID = shopId; oprLog.ObjectType = objType; oprLog.ObjectID = objId; oprLog.ChangeDatetime = DateTime.Now; oprLog.Operation = operation; oprLog.Author = ThreadIdentity.Operator.Name; oprLog.IPAddress = ThreadIdentity.Operator.IPAddress; oprLog.Remark = Remark; if (typeof(T) == typeof(string)) { oprLog.BeforeValue = (string)(object)beforeValue; } else { if (beforeValue != null) { var valueBuilder = new StringBuilder(); foreach (var property in typeof(T).GetProperties()) { var value = property.GetValue(beforeValue, null); valueBuilder.AppendFormat("{0} = {1}", property.Name, value ?? "NULL").AppendLine(); } oprLog.BeforeValue = valueBuilder.ToString(); } } if (typeof(D) == typeof(string)) { oprLog.AfterValue = (string)(object)afterValue; } else { if (afterValue != null) { var valueBuilder = new StringBuilder(); foreach (var property in typeof(D).GetProperties()) { var value = property.GetValue(afterValue, null); valueBuilder.AppendFormat("{0} = {1}", property.Name, value ?? "NULL").AppendLine(); } oprLog.AfterValue = valueBuilder.ToString(); } } dbManager.Execute(connection => DalOprLog.AddShopEditOprLog(connection, oprLog)); }
/// <summary> /// 拼接保养短信 /// </summary> /// <param name="orderId"></param> /// <returns></returns> //public string GetBaoYangEmailProcess(int orderId) //{ // var bizOrder = dbManager.Execute(connection => DalOrder.SelectOrderByOrderId(connection, orderId)); // var orderHash = // WebSecurity.Hash(string.Concat(bizOrder.Refno, bizOrder.UserId, // bizOrder.OrderDatetime.ToString("yyyy-MM-dd HH:mm"))); // var shortUrl = // TuhuUtil.GetShortUrl(string.Format(ConfigurationManager.AppSettings["LongUrl"], orderId, orderHash)); // if (bizOrder.OrderChannel.Contains("天猫")) // { // bizOrder.OrderChannel = "天猫"; // } // else // if (bizOrder.OrderChannel.Contains("淘宝")) // { // bizOrder.OrderChannel = "淘宝"; // } // string message = string.Format(ConfigurationManager.AppSettings["MaintainPackageMessage"], bizOrder.UserName, bizOrder.OrderChannel, bizOrder.Refno, shortUrl); // //new JobServerManager().SendMaintainPackageMessage(item.OrderId, item.Refno, item.UserId.ToString(), // // item.OrderDatetime, item.UserName, item.UserTel, item.OrderChannel); // return message; //} ///// <summary> ///// 直接发短信 ///// </summary> //public void SendMaintainPackageMessage(int orderId, BizEmailProcess bizEmailProcess) //{ // var item = dbManager.Execute(connection => DalOrder.SelectOrderByOrderId(connection, orderId)); // new JobServerManager().SendMaintainPackageMessage(item.OrderId, item.OrderNo, item.Refno, item.UserId.ToString(), // item.OrderDatetime, item.UserName, bizEmailProcess.ToMail, item.OrderChannel); //} #region 门店日志 public void AddShopOprLog(ShopEditOprLog 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; } dbManager.Execute(connection => DalOprLog.AddShopEditOprLog(connection, oprLog)); }