/// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(ComplainLogEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update ComplainLog SET " +
                            "ClientID = @ClientID," +
                            "ContacterID = @ContacterID," +
                            "ComplainType = @ComplainType," +
                            "ComplainMode = @ComplainMode," +
                            "Title = @Title," +
                            "Content = @Content," +
                            "FirstReceiver = @FirstReceiver," +
                            "DateAndTime = @DateAndTime," +
                            "ExigenceLevel = @ExigenceLevel," +
                            "Process = @Process," +
                            "Processor = @Processor," +
                            "Result = @Result," +
                            "EndTime = @EndTime," +
                            "Feedback = @Feedback," +
                            "ConfirmTime = @ConfirmTime," +
                            "ConfirmCaller = @ConfirmCaller," +
                            "ConfirmScore = @ConfirmScore," +
                            "ConfirmFeedback = @ConfirmFeedback," +
                            "Status = @Status," +
                            "CurrentOwner = @CurrentOwner," +
                            "Remark = @Remark," +
                            "Defendant = @Defendant" +
                            " WHERE " +

                            "ItemID = @ItemID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static ComplainLogEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            ComplainLogEntity info = new ComplainLogEntity();

            info.ItemID          = rdr.GetInt32("ItemID");
            info.ClientID        = rdr.GetInt32("ClientID");
            info.ContacterID     = rdr.GetInt32("ContacterID");
            info.ComplainType    = rdr.GetInt32("ComplainType");
            info.ComplainMode    = rdr.GetInt32("ComplainMode");
            info.Title           = rdr.GetString("Title");
            info.Content         = rdr.GetString("Content");
            info.FirstReceiver   = rdr.GetString("FirstReceiver");
            info.DateAndTime     = rdr.GetNullableDateTime("DateAndTime");
            info.ExigenceLevel   = rdr.GetInt32("ExigenceLevel");
            info.Process         = rdr.GetString("Process");
            info.Processor       = rdr.GetString("Processor");
            info.Result          = rdr.GetString("Result");
            info.EndTime         = rdr.GetNullableDateTime("EndTime");
            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.Status          = rdr.GetInt32("Status");
            info.CurrentOwner    = rdr.GetString("CurrentOwner");
            info.Remark          = rdr.GetString("Remark");
            info.Defendant       = rdr.GetString("Defendant");
            return(info);
        }
 /// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(ComplainLogEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("ItemID", entity.ItemID);
     dict.Add("ClientID", entity.ClientID);
     dict.Add("ContacterID", entity.ContacterID);
     dict.Add("ComplainType", entity.ComplainType);
     dict.Add("ComplainMode", entity.ComplainMode);
     dict.Add("Title", entity.Title);
     dict.Add("Content", entity.Content);
     dict.Add("FirstReceiver", entity.FirstReceiver);
     dict.Add("DateAndTime", entity.DateAndTime);
     dict.Add("ExigenceLevel", entity.ExigenceLevel);
     dict.Add("Process", entity.Process);
     dict.Add("Processor", entity.Processor);
     dict.Add("Result", entity.Result);
     dict.Add("EndTime", entity.EndTime);
     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("Status", entity.Status);
     dict.Add("CurrentOwner", entity.CurrentOwner);
     dict.Add("Remark", entity.Remark);
     dict.Add("Defendant", entity.Defendant);
 }
        /// <summary>
        /// 获取实体(异步方式)
        /// </summary>
        /// <param name="strWhere">参数化查询条件(例如: and Name = @Name )</param>
        /// <param name="dict">参数的名/值集合</param>
        /// <returns></returns>
        public virtual async Task <ComplainLogEntity> GetEntityAsync(string strWhere, Dictionary <string, object> dict = null)
        {
            ComplainLogEntity obj    = null;
            string            strSQL = "select top 1 * from ComplainLog where 1=1 " + strWhere;

            using (NullableDataReader reader = await Task.Run(() => _DB.GetDataReader(strSQL, dict)))
            {
                if (reader.Read())
                {
                    obj = GetEntityFromrdr(reader);
                }
            }
            return(obj);
        }
 /// <summary>
 /// 增加或更新一条记录(异步方式)
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual async Task <bool> AddOrUpdateAsync(ComplainLogEntity entity, bool IsSave)
 {
     return(IsSave ? await AddAsync(entity) : await UpdateAsync(entity));
 }
 /// <summary>
 /// 增加或更新一条记录
 /// </summary>
 /// <param name="entity">实体模型</param>
 /// <param name="IsSave">是否增加</param>
 /// <returns></returns>
 public virtual bool AddOrUpdate(ComplainLogEntity entity, bool IsSave)
 {
     return(IsSave ? Add(entity) : Update(entity));
 }
        /// <summary>
        /// 增加一条记录,返回新的ID号。需要有一个单一主键,并且开启有标识符属性(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <int> InsertAsync(ComplainLogEntity entity)
        {
            if (entity.ItemID <= 0)
            {
                entity.ItemID = GetNewID();
            }
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);

            string strSQL = "insert into ComplainLog (" +
                            "ItemID," +
                            "ClientID," +
                            "ContacterID," +
                            "ComplainType," +
                            "ComplainMode," +
                            "Title," +
                            "Content," +
                            "FirstReceiver," +
                            "DateAndTime," +
                            "ExigenceLevel," +
                            "Process," +
                            "Processor," +
                            "Result," +
                            "EndTime," +
                            "Feedback," +
                            "ConfirmTime," +
                            "ConfirmCaller," +
                            "ConfirmScore," +
                            "ConfirmFeedback," +
                            "Status," +
                            "CurrentOwner," +
                            "Remark," +
                            "Defendant) " +
                            "values(" +
                            "@ItemID," +
                            "@ClientID," +
                            "@ContacterID," +
                            "@ComplainType," +
                            "@ComplainMode," +
                            "@Title," +
                            "@Content," +
                            "@FirstReceiver," +
                            "@DateAndTime," +
                            "@ExigenceLevel," +
                            "@Process," +
                            "@Processor," +
                            "@Result," +
                            "@EndTime," +
                            "@Feedback," +
                            "@ConfirmTime," +
                            "@ConfirmCaller," +
                            "@ConfirmScore," +
                            "@ConfirmFeedback," +
                            "@Status," +
                            "@CurrentOwner," +
                            "@Remark," +
                            "@Defendant)";

            if (await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)))
            {
                return(DataConverter.CLng(entity.ItemID));
            }
            return(-1);
        }