public override void DoSaveFile(SaveFileEntityCollection saveFileEntityCollection)
 {
     if (string.IsNullOrEmpty(saveFileEntityCollection.UpdateLinkQueueSql))
     {
         foreach (SaveFileEntity saveFileEntity in saveFileEntityCollection)
         {
             if (!SaveFile(saveFileEntity))
             {
                 throw new Exception("文件" + saveFileEntity.FileFullName + "保存失败");
             }
         }
     }
     else
     {
         SqlCommand cmd = SQLHelper.GetTransactionSqlCommand(ConnStr);
         SQLHelper.ExecuteNonQuery(ref cmd, saveFileEntityCollection.UpdateLinkQueueSql);
         foreach (SaveFileEntity saveFileEntity in saveFileEntityCollection)
         {
             if (!SaveFile(saveFileEntity))
             {
                 cmd.Transaction.Rollback();
                 throw new Exception("文件" + saveFileEntity.FileFullName + "保存失败");
             }
         }
         cmd.Transaction.Commit();
         cmd.Connection.Close();
     }
 }
        protected virtual bool Verification(SaveFileEntityCollection saveFileEntityCollection)
        {
            string errMsg = string.Empty;

            foreach (SaveFileEntity saveFileEntity in saveFileEntityCollection)
            {
                PropertyInfo[] propertyInfos = saveFileEntity.GetType().GetProperties();
                foreach (PropertyInfo propertyInfo in propertyInfos)
                {
                    if (propertyInfo.GetValue(saveFileEntity, null) == null)
                    {
                        throw new Exception("SaveFileEntity的字段:" + propertyInfo.Name + "为必填项!");
                    }
                }
            }
            return(true);
        }
 public abstract void DoSaveFile(SaveFileEntityCollection saveFileEntityCollection);
 /// <summary>
 /// 检查默认编码,如果未添加就添加UTF8格式
 /// </summary>
 /// <param name="saveFileEntityCollection"></param>
 /// <returns></returns>
 protected virtual SaveFileEntityCollection CheckSaveFileEntityContextEncoding(SaveFileEntityCollection saveFileEntityCollection)
 {
     for (int i = 0; i < saveFileEntityCollection.Count; i++)
     {
         if (saveFileEntityCollection[i].ContentEncoding == null)
         {
             saveFileEntityCollection[i].ContentEncoding = new System.Text.UTF8Encoding(false);
         }
     }
     return(saveFileEntityCollection);
 }
 public void SaveFile(SaveFileEntityCollection saveFileEntityCollection)
 {
     saveFileEntityCollection = CheckSaveFileEntityContextEncoding(saveFileEntityCollection);
     Verification(saveFileEntityCollection);
     DoSaveFile(saveFileEntityCollection);
 }