Beispiel #1
0
 public static function reminderInvoker(Folder $folder)
 {
     $configuration = new Configuration();
     //parameter to know the max gap between last parsing done on the folder.
     $invokeMinutes = $configuration->getConfiguration(ConfigurationKeys::$reminderInvokeMinutes);
     //parameter to know the max gap between notifications
     $intervalMinutes = $configuration->getConfiguration(ConfigurationKeys::$reminderIntervalMinutes);
     $invokeMinutes = intval($invokeMinutes);
     $intervalMinutes = intval($intervalMinutes);
     $parsedSinceMinutes = self::getDatesDifferenceInMinutes($folder->getLastParsedOn(), date("Y-m-d H:i:s"));
     if ($parsedSinceMinutes > 0) {
         //OK we have some minutes passed with no parsing undertook
         if ($parsedSinceMinutes > $invokeMinutes) {
             //if reminder already sent, check interval and send again
             if ($folder->getLastRemindedOn() != null) {
                 $lastRemindedSince = self::getDatesDifferenceInMinutes($folder->getLastRemindedOn(), date("Y-m-d H:i:s"));
                 if ($lastRemindedSince > $intervalMinutes) {
                     self::sendNotification($folder);
                     FolderDataStore::getInstance()->updateLastReminderDate($folder->getSeq());
                 }
             } else {
                 self::sendNotification($folder);
                 FolderDataStore::getInstance()->updateLastReminderDate($folder->getSeq());
             }
         } else {
             //time still there to remind
         }
     }
 }
Beispiel #2
0
 private function getLatestInfo($locSeq)
 {
     $folders = FolderDataStore::getInstance()->FindByLocation($locSeq);
     $WQD = WQDDataDataStore::getInstance();
     $channelInfo = new ArrayObject();
     foreach ($folders as $folder) {
         $cifo = $WQD->getChannelsLatestInfo($folder->getSeq());
         $cifo['folderSeq'] = $folder->getSeq();
         $cifo['folderName'] = $folder->getFolderName();
         $channelInfo[$folder->getSeq()] = $cifo;
     }
     return $channelInfo;
 }
 public function getStationReport($GET)
 {
     $infoType = $GET['infoTypeRadio'];
     $periodType = $GET['periodTypeRadio'];
     $folSeq = $GET['stationsSelect'];
     $fromDateStr = $GET['fromDate'];
     $toDateStr = $GET['toDate'];
     $timeBase = $GET['timeBase'];
     $channelNoArray = $GET['channelNos'];
     if ($channelNoArray == null) {
         return null;
     }
     if ($periodType != "recent" && false === strtotime($fromDateStr)) {
         return null;
     }
     if ($periodType == "period" && (false === strtotime($fromDateStr) || false === strtotime($toDateStr))) {
         return null;
     }
     $datesArr = self::getFromToDates($periodType, $fromDateStr, $toDateStr);
     if ($infoType == "grid") {
         $gridDataJson = self::getGridData($datesArr['fromDate'], $datesArr['toDate'], $folSeq, $timeBase, $channelNoArray, $periodType);
         return $gridDataJson;
     } elseif ($infoType == "graph") {
         $graphDataJson = self::getGridData($datesArr['fromDate'], $datesArr['toDate'], $folSeq, $timeBase, $channelNoArray, $periodType);
         $graphChannelsJSON = array();
         $graphDataJSON = array();
         foreach ($graphDataJson['channels'] as $key => $value) {
             array_push($graphChannelsJSON, $key);
             $graphDataJSON[$key] = array();
         }
         $graphDatesJSON = array();
         foreach ($graphDataJson['data'] as $data) {
             array_push($graphDatesJSON, $data['dated']);
             foreach ($data['values'] as $key1 => $val1) {
                 array_push($graphDataJSON[$graphChannelsJSON[$key1]], (double) $val1);
             }
         }
         $finalJSON = new ArrayObject();
         $finalJSON['dates'] = $graphDatesJSON;
         $finalJSON['values'] = $graphDataJSON;
         return $finalJSON;
     } elseif ($infoType == "export") {
         $gridDataJson = self::getGridData($datesArr['fromDate'], $datesArr['toDate'], $folSeq, $timeBase, $channelNoArray, $periodType);
         $FDS = FolderDataStore::getInstance();
         $folder = $FDS->FindBySeq($folSeq);
         ExportUtils::exportStationGridReport($gridDataJson, $folder->getFolderName());
         return null;
     }
 }
 public function getMultiStationReport($GET)
 {
     $infoType = $GET['infoTypeRadio'];
     $exportType = $GET['exportTypeRadio'];
     $valueType = $GET['valueTypeRadio'];
     $folSeq = $GET['stationsSelect'];
     $fromDateStr = $GET['fromDate'];
     $toDateStr = $GET['toDate'];
     $timeBase = $GET['timeBase'];
     $timeBaseQuick = $GET['timeBaseQuick'];
     $quickReportType = $GET['quickReportType'];
     if ($quickReportType != "null") {
         $timeBase = $timeBaseQuick;
     }
     if ($valueType != "normal") {
         $timeBase = "5min";
     }
     $isValidated = $GET['isValidated'];
     $isAverage = $GET['isAverage'];
     $folSeqArray = array();
     //holds all folderseqs
     $folChannelsArray = array();
     //holds selected channels by foldSeq as key
     foreach ($GET as $key => $value) {
         if (strpos($key, "channelNos_") !== false) {
             $folSeq = (double) substr($key, 11);
             array_push($folSeqArray, $folSeq);
             $folChannelsArray[$folSeq] = $value;
         }
     }
     //a few validation checks
     if (count($folChannelsArray) == 0) {
         return null;
     }
     if ($quickReportType == "null" && (false === strtotime($fromDateStr) || false === strtotime($toDateStr))) {
         return null;
     }
     //get folderNames from DB
     $FDS = FolderDataStore::getInstance();
     $foldersObjArray = $FDS->FindBySeqs($folSeqArray);
     //calculating from to dates from provided $_GET
     $fromToDates = DateUtils::getDatesArrayForStationReports($quickReportType, $fromDateStr, $toDateStr);
     //calculating Date Slices now from DateUtils
     $fromDate = new DateTime($fromToDates['fromDate']);
     $toDate = new DateTime($fromToDates['toDate']);
     $folChannelsNamesArray = array();
     //holds selected channels by foldSeq as key
     $allChannelsArray = array();
     $channelUnitArray = array();
     foreach ($folChannelsArray as $folSeq => $folChannelChannelsArr) {
         $folName = $foldersObjArray[$folSeq]->getFolderName();
         $CCDS = ChannelConfigurationDataStore::getInstance();
         $ChannelsInfo = $CCDS->FindByFolderAndChannelNos($folSeq, $folChannelChannelsArr);
         $channelNamesArr = array();
         foreach ($ChannelsInfo as $chInfo) {
             if ($valueType != "normal") {
                 if (!self::isZeroSpanChannel($chInfo->getChannelName())) {
                     $chNo = $chInfo->getChannelNumber();
                     $chArr = $folChannelsArray[$folSeq];
                     if (($key = array_search($chNo, $chArr)) !== false) {
                         unset($folChannelsArray[$folSeq][$key]);
                         $folChannelsArray[$folSeq] = array_values($folChannelsArray[$folSeq]);
                     }
                     continue;
                 }
             }
             $chUnit = $chInfo->getChannelUnit();
             if (ConvertorUtils::getPrescribedUnit($chInfo->getChannelName()) != null) {
                 $chUnit = ConvertorUtils::getPrescribedUnit($chInfo->getChannelName());
             }
             $chUnit = mb_check_encoding($chUnit, 'UTF-8') ? $chUnit : utf8_encode($chUnit);
             $chStation = $chInfo->getChannelStation();
             if (!empty($chStation)) {
                 $chStation = " - " . $chStation;
             }
             $chStr = $folName . '<br>' . $chInfo->getChannelName() . $chStation . '<br>' . $chUnit;
             array_push($allChannelsArray, $chStr);
             array_push($channelUnitArray, $chUnit);
             array_push($channelNamesArr, $chInfo->getChannelName());
         }
         $folChannelsNamesArray[$folSeq] = $channelNamesArr;
     }
     //Created an array with folSeq and seelcted channels for it
     $folChannelDataArray = array();
     foreach ($folSeqArray as $folSeq) {
         $channelNoArray = $folChannelsArray[$folSeq];
         $EDS = ExemptionDataStore::getInstance();
         $exemptions = $EDS->FindExemptionsByFolderDatesChannels($folSeq, $fromToDates['fromDate'], $fromToDates['toDate'], implode(', ', $channelNoArray));
         //Stack or AQMS
         $stationType = $foldersObjArray[$folSeq]->getStationType();
         $dataJson = self::getDataJSON($fromToDates['fromDate'], $fromToDates['toDate'], $folSeq, "5min", $channelNoArray, $periodType, $exemptions, $stationType);
         //$avgData = self::getAverageData($fromToDates['fromDate'],$fromToDates['toDate'],$folSeq,$channelNoArray);
         $folChannelDataArray[$folSeq] = $dataJson['data'];
     }
     //Created an array with folSeq -> date->chanelvalues
     $CMD = CommentsDataStore::getInstance();
     $commentsObjs = $CMD->FindCommentsMasterByFolChannel($folSeqArray[0], $folChannelsArray[$folSeqArray[0]]);
     $dataSlices = null;
     //if its stack type we are supporting single station/folder data only
     $stationType = $foldersObjArray[$folSeqArray[0]]->getStationType();
     if ($stationType == 'stack' || $stationType == 'effluent') {
         //if($isAverage == "on"){
         //$dateSlices = DateUtils::getDateSlicesByInterval($fromDate,$toDate,$timeBase);
         //}else{
         if ($timeBase == "instant") {
             $dateSlices = DateUtils::getDateSlicesForData($folChannelDataArray[$folSeqArray[0]], $isAverage, $timeBase);
         } else {
             $dateSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, $timeBase);
         }
         //}
     } else {
         $dateSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, $timeBase);
     }
     //$dateSlices = $dateSlicesValid;
     $dataFinal = self::getFinalDataByValueType($timeBase, $dateSlices, $folSeqArray, $folChannelDataArray, $folChannelsNamesArray, $valueType, $isAverage, $stationType);
     if ($isValidated == "on") {
         $dateSlicesValidByChannelNumber = DateUtils::getDateSlicesByComments($commentsObjs, $timeBase, $folChannelsArray[$folSeqArray[0]]);
         $dataFinal = self::getValidatedDataOnly($dataFinal, $dateSlicesValidByChannelNumber);
     }
     if ($valueType != "normal") {
         $dataFinal = self::getZeroSpanValues($dataFinal);
     }
     $channelDataJSON = array();
     $channelDataJSON['channels'] = $allChannelsArray;
     //all channels with key as chno and val as chname
     $channelDataJSON['data'] = $dataFinal;
     //dateFinal is date as key and array of channel values as value
     $finalDataJSON = self::processDataJsonForGridGraph($channelDataJSON, $infoType);
     $finalDataJSON["units"] = $channelUnitArray;
     if ($infoType == "export") {
         ExportUtils::exportMultiStationGridReport($finalDataJSON, $exportType);
         return null;
     } else {
         if (count($channelDataJSON['channels']) == 1) {
             $chName = $channelNamesArr[0];
             $presLimit = PrescribedLimitsUtils::getPrescribedLimit($chName);
             if ($presLimit != null) {
                 $finalDataJSON['presLimit'] = $presLimit;
             }
         }
         return self::getAvgMinMaxValues($finalDataJSON);
     }
 }
Beispiel #5
0
require_once 'IConstants.inc';
require_once $ConstantsArray['dbServerUrl'] . "admin//configuration.php";
require_once $ConstantsArray['dbServerUrl'] . "FormValidator//validator.php";
require_once $ConstantsArray['dbServerUrl'] . "/DataStoreMgr/UserDataStore.php";
require_once $ConstantsArray['dbServerUrl'] . "/DataStoreMgr/FolderDataStore.php";
require_once $ConstantsArray['dbServerUrl'] . "/DataStoreMgr/LocationDataStore.php";
require_once $ConstantsArray['dbServerUrl'] . "/Utils/DropDownUtils.php";
require_once $ConstantsArray['dbServerUrl'] . "/BusinessObjects/Folder.php";
//$configuration = new Configuration();
Session_start();
$managerSession = $_SESSION["managerSession"];
$userDataStore = UserDataStore::getInstance();
$LDS = LocationDataStore::getInstance();
$userSeq = $managerSession['seq'];
$locSeq = $managerSession['locSeq'];
$FDS = FolderDataStore::getInstance();
$locationSeqs = $LDS->FindLocationsByUser($userSeq);
if (!in_array($locSeq, $locationSeqs)) {
    array_push($locationSeqs, $locSeq);
}
$folders = $FDS->FindByLocation(implode(",", $locationSeqs));
$folder = new Folder();
$selSeq = 0;
if ($_POST["call"] == "loadMeta") {
    $slectedFolder = $_POST["F_DropDown"];
    if ($slectedFolder == "0") {
        $msg = "Please Select Folder.";
    }
    if ($msg != null && $msg != "") {
        $div = "         <div class='ui-widget'>\n                   <div  class='ui-state-error ui-corner-all' style='padding: 0 .7em;'>\n                           <p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span>\n                           <strong>Error during Edit Meta</strong> <br/>" . $msg . "</p>\n                   </div></div>";
    } else {
$fromDate = new DateTime($_GET["fromDate"]);
$toDate = new DateTime($_GET["toDate"]);
$toDate->setTime(23, 59, 59);
$chSeq = $_GET["chSeq"];
$CCDS = ChannelConfigurationDataStore::getInstance();
$channel = $CCDS->FindBySeq($chSeq);
$channelNumber = $channel->getChannelNumber();
$channelName = $channel->getChannelName();
$channelUnit = $channel->getChannelUnit();
$fromDate = $fromDate->format("Y/m/d  H:i:s");
$toDate = $toDate->format("Y/m/d  H:i:s");
$WQDS = WQDDataDataStore::getInstance();
$dailyAverageArray = null;
foreach ($folSeqArray as $folSeq) {
    $arr = $WQDS->getDailyAverageValues($fromDate, $toDate, $folSeq, $channelNumber);
    $folder = FolderDataStore::getInstance()->FindBySeq($folSeq);
    $dailyAverageArray[$folder->getFolderName()] = $arr;
}
//get values for the whole day average
//$channelConfig = ChannelConfigurationDataStore::getInstance()->FindByFolderAndChannelNo($folSeqArray[0],$channelNumber);
$limit = PrescribedLimitsUtils::getPrescribedLimit($channelName);
if (ConvertorUtils::getPrescribedUnit($channelName) != null) {
    $channelUnit = ConvertorUtils::getPrescribedUnit($channelName);
}
?>

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Channel Values Table</title>
 public function SaveList($wqdDataArr)
 {
     $wqData = new WQDData();
     $syncDate = "";
     $folderSeq = "";
     foreach ($wqdDataArr as $wqData) {
         self::Save($wqData);
         $syncDate = $wqData->getDatadate();
         $folderSeq = $wqData->getFolderSeq();
     }
     if (!empty($syncDate)) {
         $FDS = FolderDataStore::getInstance();
         $FDS->updateLastSyncedOn($syncDate, $folderSeq);
     }
 }
Beispiel #8
0
$CCDS = ChannelConfigurationDataStore::getInstance();
$channel = $CCDS->FindBySeq($chSeq);
$channelName = $channel->getChannelName();
$toDate = new DateTime($_GET["fromDate"]);
//get todate from post
$toDateFormatted = $toDate->format("m/d/Y H:i:s");
//formatting date to add interval
$interval = '24';
$fromDate = date("m/d/Y  h:i:s A", strtotime($toDateFormatted . " - " . $interval . " hour"));
//from date dateformat
$fromDate = new DateTime($fromDate);
$fromDate = $fromDate->format("Y/m/d  H:i:s");
$toDateStr = $toDate->format("Y/m/d  H:i:s");
$WQDS = WQDDataDataStore::getInstance();
$arr = $WQDS->getChannel($fromDate, $toDateStr, $channel->getFolderSeq(), $channel->getChannelNumber(), "1hrs");
$folder = FolderDataStore::getInstance()->FindBySeq($channel->getFolderSeq());
$locationSeq = $folder->getLocationSeq();
$location = LocationDataStore::getInstance()->FindBySeq($locationSeq);
if ($_SESSION["userlogged"]["locSeq"] != $locationSeq) {
    header("location: index.php?err=true&locSeq=" . $locationSeq);
    die;
}
$channelUnit = $channel->getChannelUnit();
if ($isPL == 1) {
    if (ConvertorUtils::getPrescribedUnit($channelName) != null) {
        $channelUnit = ConvertorUtils::getPrescribedUnit($channelName);
    }
}
?>

<!DOCTYPE HTML>
 public function updateLastSyncedOn($lastSyncedOn, $folderSeq, $isDataExist = true)
 {
     $conn = self::$db->getConnection();
     $stmt = $conn->prepare(self::$UPDATE_LAST_SYNCEDON);
     $stmt->bindValue(':lastsyncedon', $lastSyncedOn);
     $stmt->bindValue(':folderseq', $folderSeq);
     $stmt->execute();
     $error = $stmt->errorInfo();
     if ($isDataExist) {
         $FDS = FolderDataStore::getInstance();
         $FDS->updateLastSyncedOn($lastSyncedOn, $folderSeq);
     }
 }
 public function saveSyncedData($wqdDataList, $isM2MSite = false)
 {
     $syncDate = "";
     $folderSeq = "";
     foreach ($wqdDataList as $wqdData) {
         try {
             $this->Save($wqdData);
             $syncDate = $wqdData->getDatadate();
             $folderSeq = $wqdData->getFolderSeq();
         } catch (Exception $e) {
             $message = $e->getMessage();
             if (strpos($message, "Duplicate entry") === 0) {
             } else {
                 throw $e;
             }
         }
     }
     if (!empty($syncDate)) {
         if ($isM2MSite) {
             $M2MDs = M2MSynchronizerDataStore::getInstance();
             $M2MDs->updateLastSyncedOn($syncDate, $folderSeq);
         } else {
             $FDS = FolderDataStore::getInstance();
             $FDS->updateLastSyncedOn($syncDate, $folderSeq);
         }
     }
 }
if (!empty($_GET['folSeq'])) {
    $folderSeq = $_GET['folSeq'];
}
if (empty($folderSeq) && !empty($_POST['submit'])) {
    $folderSeq = $_POST['folSeq'];
}
if (empty($folderSeq)) {
    die;
}
$folder = FolderDataStore::getInstance()->FindBySeq($folderSeq);
$CCDS = ChannelConfigurationDataStore::getInstance();
$ChannelsInfo = $CCDS->FindByFolder($folderSeq);
$locationSeq = $folder->getLocationSeq();
$allFolders = null;
if ($locationSeq != null) {
    $allFolders = FolderDataStore::getInstance()->FindByLocation($locationSeq);
}
if ($_SESSION["userlogged"]["locSeq"] != $locationSeq) {
    header("location: index.php?err=true&locSeq=" . $locationSeq);
    die;
}
$jsonDatesPlots = 'null';
$jsonDataOtherFols = null;
$chNumber = null;
$channelSelected = null;
$fromDateSelected = null;
$toDateSelected = null;
$graphTypeSelected = null;
$msgDisplay = null;
$fromDate = null;
$toDate = null;
 public function generateFile()
 {
     echo "MANIKGARH Generator starts...\n";
     $CCDS = ChannelConfigurationDataStore::getInstance();
     $FDS = FolderDataStore::getInstance();
     $WQDS = WQDDataDataStore::getInstance();
     $folders = $FDS->FindByLocationSeqs("11");
     echo "<br>--------TotalFolders:" . count($folders);
     foreach ($folders as $folder) {
         $folSeq = $folder->getSeq();
         //$latestDataRows = $WQDS->getChannelsLatestInfo($folSeq);
         echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n";
         echo "<br>\n ToDateFromLatestData " . $latestDataRows['dated'];
         $channelConfigs = $CCDS->FindByFolder($folSeq);
         $toDateStr = date('Y/m/d H:00:00');
         $fromDateStr = date('Y/m/d H:00:00', strtotime('-1 hour'));
         //$toDateStr = "2014/02/15 18:00:00";
         //            $fromDateStr = "2014/02/15 17:00:00";
         $toDate = new DateTime($toDateStr);
         $fromDate = new DateTime($fromDateStr);
         echo "<br>From:" . $fromDateStr . "<br>\n";
         echo "To:" . $toDateStr . "<br>\n";
         $dataArray = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq);
         $channelNoArr = self::getChannelNumberNameArray(self::$channelsList, $channelConfigs);
         $addDatesData = array();
         foreach ($dataArray as $data) {
             $channelData = array();
             $dated = $data['wqdfiledatadated'];
             $chValues = array();
             $chStatuses = array();
             foreach ($channelNoArr as $key => $value) {
                 $vl = (double) $data["ch" . $key . "value"];
                 if ($vl < 0) {
                     $vl = "n.o";
                 }
                 array_push($chValues, $vl);
                 array_push($chStatuses, (double) $data["ch" . $key . "status"]);
             }
             $allDatesData[strtotime($dated)]['channelValue'] = $chValues;
             $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses;
         }
         $channelArr = array();
         foreach ($channelNoArr as $chName) {
             array_push($channelArr, $chName);
         }
         $dataSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, "15min");
         $dataRows = $WQDS->getAverageDataByDataArrayDataSlices("15min", $allDatesData, $dataSlices, $channelArr, "normal", array());
         $repStr = "";
         if (count($dataRows) > 1) {
             $repStr = "";
             foreach ($dataRows as $dateStr => $row) {
                 $chNameValueArr = array();
                 foreach ($row as $rowId => $rowVal) {
                     $chNameValueArr[$channelArr[$rowId]] = $rowVal;
                 }
                 $dated = new DateTime($dateStr);
                 $repStr .= $dated->format("Y-m-d H:i:s");
                 $channelsList = self::$channelsList;
                 foreach ($channelsList as $chName) {
                     if ($chNameValueArr[$chName] != null) {
                         $repStr .= "," . $chNameValueArr[$chName];
                     } else {
                         $repStr .= ",NA";
                     }
                 }
                 $repStr .= "\r\n";
             }
             echo $repStr;
             $currDate = new DateTime();
             $fileName = "MHCHDMANIKGARHC011_" . $dated->format("YmdHis") . ".csv";
             $repFileName = "/home/envirote/public_html/Generated/Manikgarh/" . $folSeq . "/" . $fileName;
             //$repFileName = $fileName;
             if (!file_exists(dirname($repFileName))) {
                 mkdir(dirname($repFileName), 0777, true);
             }
             $fh = fopen($repFileName, 'w') or die("can't open file");
             fwrite($fh, $repStr);
             fclose($fh);
         }
         unset($channelArr);
         unset($latestDataRows);
         unset($channelConfigs);
         unset($channelNoArr);
         unset($dataSlices);
         unset($dataRows);
         unset($chNameValueArr);
         unset($allDatesData);
         unset($channelsList);
     }
     //for loop ends
 }
 public function generateFile()
 {
     echo "APPCB Generator starts...\n";
     $CCDS = ChannelConfigurationDataStore::getInstance();
     $FDS = FolderDataStore::getInstance();
     $WQDS = WQDDataDataStore::getInstance();
     $folders = $FDS->FindByLocationSeqs("7,10");
     echo "<br>--------TotalFolders:" . count($folders);
     foreach ($folders as $folder) {
         $stationName = $folder->getFolderName();
         $stationNumber = substr($stationName, 7);
         $districtCode = "kham";
         $industryCode = "ITCPBCM";
         //if($folder->getSeq() == 20){
         if ($folder->getLocationSeq() == 10) {
             $stationNumber = 1;
             if ($folder->getSeq() == 26) {
                 $stationNumber = 2;
             } else {
                 if ($folder->getSeq() == 27) {
                     $stationNumber = 3;
                 } else {
                     if ($folder->getSeq() == 28) {
                         $stationNumber = 4;
                     } else {
                         if ($folder->getSeq() == 29) {
                             $stationNumber = 5;
                         }
                     }
                 }
             }
             $districtCode = "hyde";
             $industryCode = "APPCB";
         }
         $folSeq = $folder->getSeq();
         $latestDataRows = $WQDS->getChannelsLatestInfo($folSeq);
         echo "FolderSeq:" . $folSeq . " FolderName:" . $folder->getFolderName() . "<br>\n";
         //echo ("<br>\nTotal Rows found:". count($latestDataRows));
         echo "<br>\n ToDateFromLatestData " . $latestDataRows['dated'];
         if (count($latestDataRows) > 0) {
             $channelConfigs = $CCDS->FindByFolder($folSeq);
             $toDateStr = $latestDataRows['dated'];
             $toDate = new DateTime($toDateStr);
             $fromDate = new DateTime($toDateStr);
             $fromDate->setTime(0, 0, 0);
             $fromDateStr = DateUtils::getSQLDateFromDateObj($fromDate);
             echo "<br>From:" . $fromDateStr . "<br>\n";
             echo "To:" . $toDateStr . "<br>\n";
             $dataArray = $WQDS->getAllDataByFol($fromDateStr, $toDateStr, $folSeq);
             $channelNoArr = self::getChannelNumberNameArray(self::$channelsList, $channelConfigs);
             $addDatesData = array();
             foreach ($dataArray as $data) {
                 $channelData = array();
                 $dated = $data['wqdfiledatadated'];
                 $chValues = array();
                 $chStatuses = array();
                 foreach ($channelNoArr as $key => $value) {
                     $vl = (double) $data["ch" . $key . "value"];
                     if ($vl < 0) {
                         $vl = "n.o";
                     }
                     array_push($chValues, $vl);
                     array_push($chStatuses, (double) $data["ch" . $key . "status"]);
                 }
                 $allDatesData[strtotime($dated)]['channelValue'] = $chValues;
                 $allDatesData[strtotime($dated)]['channelStatuses'] = $chStatuses;
             }
             $channelArr = array();
             foreach ($channelNoArr as $chName) {
                 array_push($channelArr, $chName);
             }
             $dataSlices = DateUtils::getDateSlicesByInterval($fromDate, $toDate, "1hour");
             $dataRows = $WQDS->getAverageDataByDataArrayDataSlices("1hour", $allDatesData, $dataSlices, $channelArr, "normal", array());
         } else {
             echo " \n<br>Null FromDate";
         }
         if (count($dataRows) > 1) {
             $repStr = "";
             foreach ($dataRows as $dateStr => $row) {
                 $chNameValueArr = array();
                 foreach ($row as $rowId => $rowVal) {
                     $chNameValueArr[$channelArr[$rowId]] = $rowVal;
                 }
                 $repStr .= $districtCode;
                 $repStr .= "," . $industryCode;
                 $repStr .= "," . $stationNumber . ",";
                 $dated = new DateTime($dateStr);
                 $repStr .= $dated->format("m/d/Y h:i:s A");
                 $channelsList = self::$channelsList;
                 foreach ($channelsList as $chName) {
                     if ($chNameValueArr[$chName] != null) {
                         $repStr .= "," . $chNameValueArr[$chName];
                     } else {
                         $repStr .= ",NA";
                     }
                 }
                 $repStr .= "\r\n";
             }
             echo $repStr;
             //$fileName = "khmmitcl".$folder->getFolderName(). date("Ymd") .".txt";
             //$fileName = "air". date("Ymd") .".txt";
             $fileName = "air" . $fromDate->format("Ymd") . ".txt";
             $repFileName = "/home/envirote/public_html/Generated/APPCB/" . $folSeq . "/" . $fileName;
             //$repFileName ="d:". $folSeq ."/" . $fileName;
             if (!file_exists(dirname($repFileName))) {
                 mkdir(dirname($repFileName), 0777, true);
             }
             $fh = fopen($repFileName, 'w') or die("can't open file");
             fwrite($fh, $repStr);
             fclose($fh);
         }
         unset($channelArr);
         unset($latestDataRows);
         unset($channelConfigs);
         unset($channelNoArr);
         unset($dataSlices);
         unset($dataRows);
         unset($chNameValueArr);
         unset($allDatesData);
         unset($channelsList);
     }
     //for loop ends
 }