Пример #1
0
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static ServiceLogEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            ServiceLogEntity info = new ServiceLogEntity();

            info.ItemID          = rdr.GetInt32("ItemID");
            info.ClientID        = rdr.GetInt32("ClientID");
            info.ContacterID     = rdr.GetInt32("ContacterID");
            info.OrderID         = rdr.GetInt32("OrderID");
            info.ServiceTime     = rdr.GetNullableDateTime("ServiceTime");
            info.ServiceType     = rdr.GetString("ServiceType");
            info.ServiceMode     = rdr.GetString("ServiceMode");
            info.ServiceTitle    = rdr.GetString("ServiceTitle");
            info.ServiceContent  = rdr.GetString("ServiceContent");
            info.ServiceResult   = rdr.GetInt32("ServiceResult");
            info.TakeTime        = rdr.GetInt32("TakeTime");
            info.ServicePoint    = rdr.GetInt32("ServicePoint");
            info.Processor       = rdr.GetString("Processor");
            info.Inputer         = rdr.GetString("Inputer");
            info.Feedback        = rdr.GetString("Feedback");
            info.ConfirmTime     = rdr.GetNullableDateTime("ConfirmTime");
            info.ConfirmCaller   = rdr.GetString("ConfirmCaller");
            info.ConfirmScore    = rdr.GetInt32("ConfirmScore");
            info.ConfirmFeedback = rdr.GetString("ConfirmFeedback");
            info.Remark          = rdr.GetString("Remark");
            return(info);
        }
Пример #2
0
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(ServiceLogEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update ServiceLog SET " +
                            "ClientID = @ClientID," +
                            "ContacterID = @ContacterID," +
                            "OrderID = @OrderID," +
                            "ServiceTime = @ServiceTime," +
                            "ServiceType = @ServiceType," +
                            "ServiceMode = @ServiceMode," +
                            "ServiceTitle = @ServiceTitle," +
                            "ServiceContent = @ServiceContent," +
                            "ServiceResult = @ServiceResult," +
                            "TakeTime = @TakeTime," +
                            "ServicePoint = @ServicePoint," +
                            "Processor = @Processor," +
                            "Inputer = @Inputer," +
                            "Feedback = @Feedback," +
                            "ConfirmTime = @ConfirmTime," +
                            "ConfirmCaller = @ConfirmCaller," +
                            "ConfirmScore = @ConfirmScore," +
                            "ConfirmFeedback = @ConfirmFeedback," +
                            "Remark = @Remark" +
                            " WHERE " +

                            "ItemID = @ItemID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
Пример #3
0
        /// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <ServiceLogEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            ServiceLogEntity obj    = null;
            string           strSQL = "select top 1 * from ServiceLog where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
Пример #4
0
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(ServiceLogEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into ServiceLog (" +
                            "ClientID," +
                            "ContacterID," +
                            "OrderID," +
                            "ServiceTime," +
                            "ServiceType," +
                            "ServiceMode," +
                            "ServiceTitle," +
                            "ServiceContent," +
                            "ServiceResult," +
                            "TakeTime," +
                            "ServicePoint," +
                            "Processor," +
                            "Inputer," +
                            "Feedback," +
                            "ConfirmTime," +
                            "ConfirmCaller," +
                            "ConfirmScore," +
                            "ConfirmFeedback," +
                            "Remark) " +
                            "values(" +
                            "@ClientID," +
                            "@ContacterID," +
                            "@OrderID," +
                            "@ServiceTime," +
                            "@ServiceType," +
                            "@ServiceMode," +
                            "@ServiceTitle," +
                            "@ServiceContent," +
                            "@ServiceResult," +
                            "@TakeTime," +
                            "@ServicePoint," +
                            "@Processor," +
                            "@Inputer," +
                            "@Feedback," +
                            "@ConfirmTime," +
                            "@ConfirmCaller," +
                            "@ConfirmScore," +
                            "@ConfirmFeedback," +
                            "@Remark)";

            return(await Task.Run(() => _DB.ReturnID(strSQL, dict)));
        }
Пример #5
0
 public void WriteServiceLog(ServiceLogEntity serviceLogEntity)
 {
     using (var Db = GetDbConnection())
     {
         try
         {
             var sql = @"INSERT INTO dbo.sys_ServiceLog(ServiceLogId,ServiceName,Module,Method,Request,Response,UId,Code,Msg,Platform,TransactionId,CreateTime)
                              VALUES (@ServiceLogId,@ServiceName,@Module,@Method,@Request,@Response,@UId,@Code,@Msg,@Platform,@TransactionId,@CreateTime)";
             Db.Execute(sql, serviceLogEntity);
         }
         catch
         {
             return;
         }
     }
 }
Пример #6
0
        public static void WriteServiceLog(ServiceLogEntity serviceLogEntity)
        {
            //日志开关
            if (!ConfigHelper.GetBool("ServiceLogIsOpen"))
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                serviceLogEntity.ServiceLogId = Guid.NewGuid();
                serviceLogEntity.CreateTime   = DateTime.Now;
                serviceLogEntity.ServiceName  = ConfigHelper.GetString("ServiceName");
                logDal.WriteServiceLog(serviceLogEntity);
            });
        }
Пример #7
0
 /// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(ServiceLogEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("ItemID", entity.ItemID);
     dict.Add("ClientID", entity.ClientID);
     dict.Add("ContacterID", entity.ContacterID);
     dict.Add("OrderID", entity.OrderID);
     dict.Add("ServiceTime", entity.ServiceTime);
     dict.Add("ServiceType", entity.ServiceType);
     dict.Add("ServiceMode", entity.ServiceMode);
     dict.Add("ServiceTitle", entity.ServiceTitle);
     dict.Add("ServiceContent", entity.ServiceContent);
     dict.Add("ServiceResult", entity.ServiceResult);
     dict.Add("TakeTime", entity.TakeTime);
     dict.Add("ServicePoint", entity.ServicePoint);
     dict.Add("Processor", entity.Processor);
     dict.Add("Inputer", entity.Inputer);
     dict.Add("Feedback", entity.Feedback);
     dict.Add("ConfirmTime", entity.ConfirmTime);
     dict.Add("ConfirmCaller", entity.ConfirmCaller);
     dict.Add("ConfirmScore", entity.ConfirmScore);
     dict.Add("ConfirmFeedback", entity.ConfirmFeedback);
     dict.Add("Remark", entity.Remark);
 }
Пример #8
0
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(ServiceLogEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
Пример #9
0
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(ServiceLogEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }