package cn.net.caoyao.cpzshandset.service.bll;

import java.util.List;

import android.content.Context;
import cn.net.caoyao.cpzshandset.bean.UploadBean;
import cn.net.caoyao.cpzshandset.common.config.ConfigCreateService;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.UploadStatusDal;

public class UploadStatusBll {
	private UploadStatusDal dal;
	public UploadStatusBll(Context context) {
		ConfigCreateService service = new ConfigCreateService();
		dal = service.createUploadStatusDal(new CacheGet(), context);
	}

	/**
	 * 插入提交状态到数据库
	 * @param b
	 */
	public void insertUploadStatus(UploadBean b){
		if (dal == null) {
			return;
		}
		dal.insertUploadStatus(b);
	}
	/**
	 * 通过实践信息删除上传数据
	 * @param date
	 */
	public void deleteUploadStatusByDate(String date){
		if (dal == null) {
			return;
		}
		dal.deleteUploadStatusByDate(date);
	}
	/**
	 * 查询所有的上传数据
	 * @param date
	 * @return
	 */
	public List<UploadBean> queryAllUploadStatus(String date){
		if (dal == null) {
			return null;
		}
		return dal.queryAllUploadStatus(date);
	}
	/**
	 * 删除七天前的数据
	 */
	public void delete7DaysBefore(){
		if (dal == null) {
			return;
		}
		dal.delete7DaysBefore();
	}
	/**
	 * 查询最近七天的提交状态信息
	 * @return
	 */
	public List<UploadBean> queryUploadStatusFor7Days(){
		if (dal == null) {
			return null;
		}
		return dal.queryUploadStatusFor7Days();
	}
	
	/**
	 * 查询七天内存在操作的日期
	 * @return
	 */
	public List<String> queryUploadDateFor7Days(){
		if (dal == null) {
			return null;
		}
		return dal.queryUploadDateFor7Days();
	}
	/**
	 * 根据日期和操作查询标签数量
	 * @param option_type
	 * @param date
	 * @return
	 */
	public int queryLabelCountByOptionAndDate(int option_type,String date){
		if (dal == null) {
			return -1;
		}
		return dal.queryLabelCountByOptionAndDate(option_type, date);
	}
	
	
	/**
	 * 删除所有的提交状态信息
	 */
	public void deleteAllUploadStatus(){
		if (dal == null) {
			return;
		}
		dal.deleteAllUploadStatus();
	}
	
	/**
	 * 插入提交状态的错误码
	 * @param b
	 */
	public void insertErrorUploadStatus(int option_type,int error_code){
		if(dal == null) return;
		dal.insertErrorUploadStatus(option_type, error_code);
	}
	
//	public void delete
	/**
	 * 查询某个操作的错误码
	 * @param option_type
	 * @return
	 */
    public UploadBean queryErrorUploadByOptionType(int option_type){
    	if(dal == null) return null;
    	return dal.queryErrorUploadByOptionType(option_type);
    }
    
    /**
     * 删除某个操作的错误码信息
     * @param option_type
     */
    public void deleteErrorUploadStatusByOptionType(int option_type) {
    	if(dal == null) return;
		dal.deleteErrorUploadStatusByOptionType(option_type);
    	
    }
	
}
