package com.cnd3b.service;

import com.cnd3b.common.BaseClass;
import com.cnd3b.common.data.db.SQLiteJDBC;
import com.cnd3b.utility.obs.BucketCESManage;
import p2.pao.PaoSetRemote;
import p2.application.tobsmag.tobsmag;

/**
 * 存储容量定时刷新
 */
public class ObsVolumeQuery extends BaseClass implements Runnable {

    @Override
    public void run() {
        if (new SQLiteJDBC().checkServicesUsed("ObsVolumeQuery", true)) {
            PaoSetRemote tobsmagSet = null;
            tobsmag tobsmag = null;
            try {
                tobsmagSet = getP2ServerSystemPaoSet("tobsmag");
                int i = 0;
                while ((tobsmag = (tobsmag) tobsmagSet.getPao(i)) != null) {
                    if (!tobsmag.getPaoSet("tattachment").isEmpty()) {
                        try {
                            tobsmag.getVolume();
                        } catch (Exception e) {
                            printErrOut("获取存储容量" + tobsmag.getString("siteid"), e.getMessage());
                            e.printStackTrace();
                        }
                    }
                    new BucketCESManage(tobsmag.getString("siteid")).getData();
                    i++;
                }
                tobsmagSet.save();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    tobsmagSet.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
