Пример #1
0
bool FdoSmPhPostGisOwner::Delete()
{
    FdoSmPhPostGisMgrP mgr(GetManager()->SmartCast<FdoSmPhPostGisMgr>());
    
    GdbiConnection* gdbiConn = NULL;
    gdbiConn = mgr->GetGdbiConnection();

    FdoStringP sqlStmt = FdoStringP::Format(
        L"DROP DATABASE %ls",
        static_cast<FdoString*>(GetDbName()));

    gdbiConn->ExecuteNonQuery(static_cast<const char*>(sqlStmt), true);

    return true;
}
Пример #2
0
bool FdoSmPhSqsIndex::Delete()
{
    FdoSmPhDbObjectP dbObject = GetDbObject();

    // Index name must be qualified by table name.
    FdoStringP sqlStmt = FdoStringP::Format(
        L"drop index %ls.%ls",
        (FdoString*) ((FdoSmPhDbObject*)dbObject)->GetDbName(),
        (FdoString*) GetDbName()
    );

    // SqlServer does not allow qualified name for index to create.
    // Therefore, must switch to the index's owning database before deleting
    // it.
    ActivateOwnerAndExecute( sqlStmt );

    return true;
}
Пример #3
0
bool FdoSmPhSqsIndex::Add()
{
    FdoSmPhDbObjectP dbObject = GetDbObject();

    FdoStringP sqlStmt = FdoStringP::Format(
        L"create %lsindex %ls on %ls ( %ls )",
        GetIsUnique() ? L"unique " : L"",
        (FdoString*) GetDbName(),
        (FdoString*) dbObject->GetDbQName(),
        (FdoString*) GetKeyColsSql(GetColumns())->ToString( L", " )
    );

    // SqlServer does not allow qualified name for index to create.
    // Therefore, must switch to the index's owning database before creating
    // it.
    ActivateOwnerAndExecute( sqlStmt );

    return true;
}
//  20-Aug-1999 SFK		Version 2.05 Added printing of maximum value and time for use in direction search
//										Fixed columns so they line up correctly
void MeasurementSummariesMenuOption()
{                                 
                                                    
	// these parameters remain unchanged for each execution of the menu option                                                    
    static DATE dUserIntervalStart = 0.0;
	static unsigned long ulIntervalInDays = 0;
	static unsigned int iUserUnits = 0;                 
	static DATE dLastSearchIntervalInDays = 0;
	static BOOL bFirst = TRUE;
	static struct IDStruct StaID;
	static short sFacNum;
    static unsigned int uiStaChoice;
	static unsigned short usMeasChoice;        
//static char szOldDbName[DRIVE_LEN+PATH_LEN+1] = {""};

    struct GEN_DATE_STRUCT GenDate;
    struct GEN_TIME_STRUCT GenTime;
	struct db_event_rec dbChanEvent;

	CGFmtStr szInterval;
    
    GUI_ACTION DlgReturn;                                     
    
	int status;     
	int j;    
	short sNumStas;
	short sMaxNameLen;
	unsigned long ulDbIntervalInDays;
	DATE dSearchIntervalInDays;
	DATE dEnd;
	DATE dDum;
	unsigned long ulTotalPts;
	unsigned long ulNumMatches;
	char szFirstDate[DT_LEN+1], szLastDate[DT_LEN+1];  	
	BOOL bAssay = FALSE;
	BOOL bCfNorm = FALSE;
	BOOL bNormBkg = FALSE;
	BOOL bEmptyAssay = FALSE;
	BOOL bTotalsAssay = FALSE;
	BOOL bCfCheck = FALSE;
	BOOL bLowBkg = FALSE;
	BOOL bHighBkg = FALSE;
	struct IDStruct TempID;	

	// verify the facility is defined
	char szFacName[DB_NAME_LEN+1];
	if (!pglFacCfg->IsFacilityDefined(glsFacNum)) return;
	// 3.0.3.16 Dec 1, 2004  Check that there are some stations in the currently defined facility
	if (!pglFacCfg->DoesFacilityHaveAnyData(glsFacNum)) return;

	pglFacCfg->GetFacilityLongName(glsFacNum, szFacName, DB_NAME_LEN);

    
   /* ------------------------------------------------------------------
    *	Always find the first and last days in the database and set
	*	up the strings for display in the dialog box.
    * ----------------------------------------------------------------*/
	SetCurrentDrive();
	status = GetDatabaseIntervalParameters(szFirstDate, szLastDate, &ulDbIntervalInDays, &dSearchIntervalInDays);
	if (status != TRUE) return;
	if (dSearchIntervalInDays <= 0.0) {
		RadReviewMsg(uiDB_EMPTY_STATUS);
		return;
	}
	
	    
	if ((bFirst == TRUE) || (!SameDb(glszOldDbName)) || (dSearchIntervalInDays != dLastSearchIntervalInDays) || (sFacNum != glsFacNum)) {
	   /* ------------------------------------------------------------------
	    *	Get the default parameters from the Default database.
	    * ----------------------------------------------------------------*/
		if ((!AccessDefaultDatabase(READ, S_MEAS_SUMM_TYPE, (short *)&usMeasChoice)) ||
			(!AccessDefaultDatabase(READ, S_MEAS_SUMM_STATION, &StaID.sStaID)) ||
			(!AccessDefaultDatabase(READ, S_MEAS_SUMM_STATION_TYPE, &StaID.sStaType))) {
			RadReviewMsg(status, "when reading from Default database.  Cannot proceed.");			
			return;
		} 

		// make sure have a valid station
		if (StaID.sStaID == ANY_STATION) {
			if (pglFacCfg->GetNumStations(glsFacNum) < 1) {
  				RadReviewMsg(uiNO_STATIONS_FOR_FACILITY_ERR);
				return;
			}
		}
		else {
			if (!pglFacCfg->IsStationEnabled(glsFacNum, &StaID)) {
				if (pglFacCfg->GetNumStations(glsFacNum) > 0) {
					pglFacCfg->GetFirstStationID(glsFacNum, &StaID);
				}
				else {
	  				RadReviewMsg(uiNO_STATIONS_FOR_FACILITY_ERR);
					return;
				}
			}
		}
				
	   /* ------------------------------------------------------------------
	    *	Calculate the user interval
	    * ----------------------------------------------------------------*/
		GetReviewPeriodParameters(&dUserIntervalStart, &dEnd, &ulIntervalInDays);
		iUserUnits = 0;
	
		// remember the current conditions for future entries to this option
		sFacNum = glsFacNum;
	    GetDbName(glszOldDbName);								
		dLastSearchIntervalInDays = dSearchIntervalInDays;	
		bFirst = FALSE;

	}	

   /* ------------------------------------------------------------------
    *	Define the dialog box
    * ----------------------------------------------------------------*/
    CGUI_Dlg Dlg(IDD_SUMMARIES_MEASUREMENTS, NULL, DLG_POSN_NO_SAVE);
	if (Dlg.IsValid()) {
	   /* ------------------------------------------------------------------
	    *	Define the buttons and actions in the dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		Dlg.DefinePushBtn(IDOK, GUI_OK);                   
		Dlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateDbParms);  		       
				                                               
	   /* ------------------------------------------------------------------
	    *	Set facility label in dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefineFldStaticTxt(IDC_MEASUREMENT_SUMM_FACILITY);
		Dlg.FldStaticTxtSetValue(IDC_MEASUREMENT_SUMM_FACILITY, szFacName);
			
	   /* ------------------------------------------------------------------
	    *	Display current starting ending database dates and interval in dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefineFldStaticTxt(IDC_MEASUREMENT_SUMM_CURR_DB_START);
		Dlg.FldStaticTxtSetValue(IDC_MEASUREMENT_SUMM_CURR_DB_START, szFirstDate);
					
		Dlg.DefineFldStaticTxt(IDC_MEASUREMENT_SUMM_CURR_DB_END);
		Dlg.FldStaticTxtSetValue(IDC_MEASUREMENT_SUMM_CURR_DB_END, szLastDate);

		szInterval.Printf("%ld days", ulDbIntervalInDays);  
		Dlg.DefineFldStaticTxt(IDC_MEASUREMENT_SUMM_CURR_DB_INTERVAL);
		Dlg.FldStaticTxtSetValue(IDC_MEASUREMENT_SUMM_CURR_DB_INTERVAL, szInterval);
		
	   /* ------------------------------------------------------------------
	    *	Set up the search interval parameters in dialog box
	    * ----------------------------------------------------------------*/
		//Date.DATETimestampToGenStructs(dUserIntervalStart, &GenDate, &GenTime);
		glMyDateTime.DATETimestampToGenStructs(dUserIntervalStart, &GenDate, &GenTime);
		Dlg.DefineFldDate(IDC_MEASUREMENT_SUMM_SRCH_STRTDATE, &GenDate);
		Dlg.DefineFldTime(IDC_MEASUREMENT_SUMM_SRCH_STRTTIME, &GenTime);
		
		Dlg.DefineFldNum(IDC_MEASUREMENT_SUMM_SRCH_INTERVAL, &ulIntervalInDays, 1, 10000,"%ld");
		Dlg.DefinePickList(IDC_MEASUREMENT_SUMM_INTRVL_UNITS_PL, glnaszIntervalUnitsPicklist, &iUserUnits);

	   /* ------------------------------------------------------------------
	    *	Set up the station and measurement type options in dialog box
	    * ----------------------------------------------------------------*/
		// Explode usMeasChoice into individual components
		if ((usMeasChoice & ASSAY_BIT) == ASSAY_BIT) bAssay = TRUE;
		if ((usMeasChoice & CF_NORM_BIT) == CF_NORM_BIT) bCfNorm = TRUE;
		if ((usMeasChoice & NORM_BKG_BIT) == NORM_BKG_BIT) bNormBkg = TRUE;
		if ((usMeasChoice & EMPTY_BIT) == EMPTY_BIT) bEmptyAssay = TRUE;
		if ((usMeasChoice & TOTALS_BIT) == TOTALS_BIT) bTotalsAssay = TRUE;
		if ((usMeasChoice & CF_CHECK_BIT) == CF_CHECK_BIT) bCfCheck = TRUE;
		if ((usMeasChoice & LOW_BKG_BIT) == LOW_BKG_BIT) bLowBkg = TRUE;
		if ((usMeasChoice & HIGH_BKG_BIT) == HIGH_BKG_BIT) bHighBkg = TRUE;
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_ASSAY, &bAssay);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_CF_NORM, &bCfNorm);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_STATIC_BKG, &bNormBkg);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_TOTALS, &bTotalsAssay);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_CF_CHECK, &bCfCheck);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_EMPTY, &bEmptyAssay);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_LOW_BKG, &bLowBkg);	
		Dlg.DefineCheckBox(IDC_MEAS_SUMM_HIGH_BKG, &bHighBkg);	

		int iTemp;
		if (!pglFacCfg->CreateStationPicklist(glsFacNum, true, &gllaszStaList, &iTemp)) return;
		sMaxNameLen = iTemp;
		short sTemp = (short)uiStaChoice;
		if (!pglFacCfg->GetPicklistChoiceForStationID(StaID, &sTemp)) return;
		uiStaChoice = sTemp;
		Dlg.DefinePickList(IDC_MEASUREMENT_STATION, gllaszStaList, &uiStaChoice);
			    
	   /* ------------------------------------------------------------------
	    *	Set up the focus and display the dialog box
	    * ----------------------------------------------------------------*/
		Dlg.SetFocus(IDC_MEASUREMENT_SUMM_SRCH_INTERVAL);   
		DlgReturn = Dlg.Go();
			    
	   /* ------------------------------------------------------------------
	    *	Returned from dialog box, now process it.
	    * ----------------------------------------------------------------*/
	    if (DlgReturn == GUI_OK) {  
			    	
	    	Dlg.RetrieveAllControlValues();	/* get dialog values */
	    	
			// Implode the individual components back into usMeasChoice
			usMeasChoice = 0;
			if (bAssay)			usMeasChoice = usMeasChoice | ASSAY_BIT;
			if (bCfNorm)		usMeasChoice = usMeasChoice | CF_NORM_BIT; 
			if (bNormBkg)		usMeasChoice = usMeasChoice | NORM_BKG_BIT;
			if (bEmptyAssay)	usMeasChoice = usMeasChoice | EMPTY_BIT;
			if (bTotalsAssay)	usMeasChoice = usMeasChoice | TOTALS_BIT;
			if (bCfCheck)		usMeasChoice = usMeasChoice | CF_CHECK_BIT;
			if (bLowBkg)		usMeasChoice = usMeasChoice | LOW_BKG_BIT;
			if (bHighBkg)		usMeasChoice = usMeasChoice | HIGH_BKG_BIT;

			if (usMeasChoice == 0) {
				RadReviewMsg(uiNO_MEAS_TYPES_SELECTED_WARN);
				return;
			}

		   /* ------------------------------------------------------------------
			*   Calculate the search interval
			* ----------------------------------------------------------------*/
			status = ConvertStructsToSearchIntervalParameters(&GenDate, &GenTime, iUserUnits, ulIntervalInDays, &dUserIntervalStart, &dEnd);
			if (status != TRUE) {	// no data for any station in the interval
				RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, dUserIntervalStart, dEnd, "any station");
				return;
			}

		   /* ------------------------------------------------------------------
			*   Handle the special case of all stations
			* ----------------------------------------------------------------*/
			if (!pglFacCfg->GetStationIDForPicklistChoice(uiStaChoice, &StaID)) return;
		   /* ------------------------------------------------------------------
			*   Verify that some data exists
			* ----------------------------------------------------------------*/
			if (StaID.sStaID == -1) {		// -1 indicates all stations; verify at least one has data
				BOOL bDataExists = FALSE;
				int iNumStas = pglFacCfg->GetNumStations(glsFacNum);
				for (int i=0; i<iNumStas; i++) {
					if (!pglFacCfg->GetStationIDForPicklistChoice(i, &TempID)) return;
					status = GetDataStatistics(TempID, true, dUserIntervalStart, dEnd, &dDum, &dDum, &ulTotalPts);
					if ((status == TRUE) && (ulTotalPts > 0)) {
						bDataExists = TRUE;
						break;
					}
				}
				if (bDataExists == FALSE) {	
					RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, dUserIntervalStart, dEnd, "any station");
					pglFacCfg->DestroyPicklist(gllaszStaList);
					gllaszStaList = NULL;
					return;	
				}
			}
			else {					// see if the choice selected has data
				status = GetDataStatistics(StaID, true, dUserIntervalStart, dEnd, &dDum, &dDum, &ulTotalPts);
				if ((status != TRUE) || (ulTotalPts == 0)) {
					RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, dUserIntervalStart, dEnd, (const char*)gllaszStaList[uiStaChoice]);
					pglFacCfg->DestroyPicklist(gllaszStaList);
					gllaszStaList = NULL;
					return;	
				}
			}


		   /* ------------------------------------------------------------------
		    *	Open up the text window where the events will be displayed
		    * ----------------------------------------------------------------*/
			if (pWin == NULL) {                
				pWin = new CGUI_TextWin("Summary of Measurements Found");
				if (pWin != NULL) pWin->ShowStatusBar(TRUE);
			}   
			else {
				pWin->Clear();
			} 
			pWin->SetFocus();
			
		   /* ------------------------------------------------------------------
			*   Display the general part of the header:
			*	facility name,
			*	search interval
			*	channels involved in search
			* ----------------------------------------------------------------*/
			if (!PrintFacilityHeader(pWin, sFacNum, dUserIntervalStart, dEnd)) return;

			if (StaID.sStaID != -1) {
				if (pWin != NULL) pWin->Printf("\n\nStation = %s", gllaszStaList[uiStaChoice]);		//print station name
			}
			else {
				sNumStas = pglFacCfg->GetNumStations(glsFacNum);
				pWin->Printf("\nStations Searched:");
				for (j=0; j<(sNumStas); j++) { 
					pWin->Printf("\n     %s", gllaszStaList[j]);
				}	
			}
			if ((StaID.sStaID != -1) && (StaID.sStaType == MCA_TYPE)) {
				if (pWin != NULL) pWin->Printf("\nMeasurement summaries are not applicable to MCA data.");
				if (pWin != NULL) pWin->EnableUserClose(CloseWindow);	// 20-Sep-2005 SFK Allow user to close window
				return;
			}
			if ((StaID.sStaID != -1) && (StaID.sStaType == GRAND_TYPE)) {
				if (pWin != NULL) pWin->Printf("\nMeasurement summaries are not applicable to GRAND data.");
				if (pWin != NULL) pWin->EnableUserClose(CloseWindow);	// 20-Sep-2005 SFK Allow user to close window
				return;
			}
			if ((StaID.sStaID != -1) && (StaID.sStaType == BINARY_TYPE)) {
				if (pWin != NULL) pWin->Printf("\nMeasurement summaries are not applicable to binary data.");
				if (pWin != NULL) pWin->EnableUserClose(CloseWindow);	// 20-Sep-2005 SFK Allow user to close window
				return;

			}

		   /* ------------------------------------------------------------------
			*   Scan through the measurements and count those that match.
			* ----------------------------------------------------------------*/
			ulNumMatches = 0;
			status = ScanChannelEvents(dUserIntervalStart, FIRST, &dbChanEvent);
			if (dbChanEvent.d_event_beg_time_key <= dEnd) {
				do {
					//if (EvaluateEvent(sStaNum, usMeasChoice, &dbChanEvent)) ulNumMatches++;
					if (EvaluateEvent(StaID, usMeasChoice, &dbChanEvent)) ulNumMatches++;
					status = ScanChannelEvents(dUserIntervalStart, NEXT, &dbChanEvent);
				} while ((status ==TRUE) && (dbChanEvent.d_event_beg_time_key <= dEnd));
			}

			if (ulNumMatches == 0) {
				if (pWin != NULL) pWin->Printf("\nNo measurements found in interval.");
				pglFacCfg->DestroyPicklist(gllaszStaList);
				gllaszStaList = NULL;
				if (pWin != NULL) pWin->EnableUserClose(CloseWindow);				
				return;
			}

			if (pWin != NULL) pWin->Printf("\n\n         Start    End      ID          Width Measurement   Maximum Maximum    Avg Totals    Avg Reals Dir        R/     Station");
			if (pWin != NULL) pWin->Printf(  "\nDate     Time     Time                (secs) Type             Rate    Time       Rate         Rate               T");
						                       /*90.05.07 10:10:01 10:20:25 12345 Assay*/
			pWin->Printf("\n");
		    
		   /* ------------------------------------------------------------------
			*   Scan through the measurements and print those that match.
			* ----------------------------------------------------------------*/
			ulNumMatches = 0;
			status = ScanChannelEvents(dUserIntervalStart, FIRST, &dbChanEvent);
			char szStaName[DB_NAME_LEN+1];
			do {
				if (dbChanEvent.d_event_beg_time_key <= dEnd)
				{
					if (EvaluateEvent(StaID, usMeasChoice, &dbChanEvent)) {
						PrintMeasEventToTextWin(&dbChanEvent, pWin, &ulNumMatches);
						TempID.sChanID = dbChanEvent.us_event_chan;
						TempID.sStaID = dbChanEvent.us_event_sta;
						TempID.sStaType = dbChanEvent.us_event_sta_type;
						pglFacCfg->GetStationLongName(glsFacNum, &TempID, szStaName, DB_NAME_LEN);
						if (pWin != NULL) pWin->Printf(" %s", szStaName );
					}
					status = ScanChannelEvents(dUserIntervalStart, NEXT, &dbChanEvent);
				}
			} while ((status ==TRUE) && (dbChanEvent.d_event_beg_time_key <= dEnd));

			if (pWin != NULL) pWin->Printf("\n\nTotal Measurements Found for %s = %ld", gllaszStaList[uiStaChoice], ulNumMatches); 

			if (pWin != NULL) pWin->EnableUserClose(CloseWindow);				

			pglFacCfg->DestroyPicklist(gllaszStaList);
			gllaszStaList = NULL;
	    }	      
	}
}   		                                 
Пример #5
0
//  27-Aug-2004 SFK		Created
void CopyLogsMenuOption()
{                                 

    static char szDfltRootPath[PATH_LEN+1] = "";
    static char szDfltCurrentDbPath[PATH_LEN+1] = "";                   
    static BOOL bFirst = TRUE;
    
	char szCurrentDbPath[PATH_LEN+1] = "";    
	char szMainCurrentDbPath[PATH_LEN+1] = "";    
    char szRootBackupPath[PATH_LEN+1] = "";
	char szMainBackupPath[PATH_LEN+1] = "";
    unsigned long ulDirSize, ulDiskSize, ulDiskAvailable;
    BOOL bRoom;     
    int status;
    char *pStr;

    
    GUI_ACTION DlgReturn;         
    CGFmtStr msg;

	SetCurrentDrive();    
    GetDbName(szCurrentDbPath);
    
   /* ------------------------------------------------------------------
    *	First time or when change databases, get the default values
    *	from the .ini file else use the last successful values.
    * ------------------------------------------------------------------*/
    if ((bFirst == TRUE) || (!SameDb(szDfltCurrentDbPath))) {
    	pStr = pRAD_Init->Get_LogCopy_To_Path(); 
		MyStrnCpy(szDfltRootPath, pStr, PATH_LEN); 
   		bFirst = FALSE;
    	strcpy(szDfltCurrentDbPath, szCurrentDbPath);
	}
	
	strcpy(szRootBackupPath, szDfltRootPath);

   /* ------------------------------------------------------------------
    *	Define the buttons and actions in the dialog box
    * ----------------------------------------------------------------*/
    CGUI_Dlg BackupDbDlg(IDD_FILE_COPY_LOGS, NULL, DLG_POSN_NO_SAVE);
    if (BackupDbDlg.IsValid()) {
		BackupDbDlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		BackupDbDlg.DefinePushBtn(IDOK, GUI_OK);
		BackupDbDlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateINI_Parms);              
			                                               
		BackupDbDlg.DefineFldTxt(IDC_CLOG_EDIT_NEW_PATH, szRootBackupPath, PATH_LEN);
			
		BackupDbDlg.SetFocus(IDOK);
		
	    DlgReturn = BackupDbDlg.Go();
		    
	    if (DlgReturn == GUI_OK) {  
		    	
	    	BackupDbDlg.RetrieveAllControlValues();

		   /* ------------------------------------------------------------------
		    *	Remove spaces, check length
		    * ----------------------------------------------------------------*/
	    	if (PathCopy(szMainBackupPath, szRootBackupPath) != TRUE) return;
	    	strcat(szMainBackupPath, "logs\\rad\\");

	    	if (PathCopy(szMainCurrentDbPath, szCurrentDbPath) != TRUE) return;
	    	strcat(szMainCurrentDbPath, "logs\\rad\\");

		   /* ------------------------------------------------------------------
		    *	See if the new path exists, if not make it.  If can't make it give
		    *	reason why.
		    * ----------------------------------------------------------------*/
		    status = PathExists(szMainBackupPath); // returns TRUE, uiPATH_TOO_LONG_ERR, uiDRIVE_DOES_NOT_EXIST_ERR oruiPATH_DOES_NOT_EXIST_ERR
		    if ( status == uiPATH_DOES_NOT_EXIST_ERR) {
		    	status = AskAndMakePath(szMainBackupPath);
		    	if (status != TRUE) return;
		    }	
		    if ( status != TRUE) {
		    	RadReviewMsg(status, (const char *)szMainBackupPath);
				return;
			}	

		   /* ------------------------------------------------------------------
		    *	See if a log file exists at the location specified.  If yes,
		    *	see if they want to overwrite it.
		    * ----------------------------------------------------------------*/
		    if (FileExists(szMainBackupPath, "RadReviewLog.txt") == TRUE) {
		    	status = AskOverwriteQuestion(szMainBackupPath);
		    	if (status == FALSE) return;
		    }	
		    
		   /* ------------------------------------------------------------------
		    *	Figure out how many bytes will need to be copied and if there
		    *	is room on the destination drive.  (Destination drive must have
		    *	directory size + 10000 to allow for directory entries, etc.)
		    * ----------------------------------------------------------------*/
		    if (GetDirSize(szMainCurrentDbPath, "*.*", &ulDirSize) != TRUE) return;	/* check number of bytes filled in szCurrentDbPath */
			
			// Customize for COMs, if don't write to this log directory

		    if (GetDriveSize(szMainBackupPath, &ulDiskSize, &ulDiskAvailable) != TRUE) return;	/* check number of bytes available on drive */
			
			bRoom = TRUE;
			if ((ulDirSize + 10000) > ulDiskAvailable) bRoom = FALSE;	    
		    	    
		    if (bRoom == FALSE) {
		    	if (AskNotEnoughRoomQuestion(ulDirSize, ulDiskAvailable, szMainBackupPath) == FALSE) return;
		    }
		    
		   /* ------------------------------------------------------------------
		    *	Close the current database in case are trying to copy it.
		    *	Copy the data and show progress. Inform of the results of the copy.	
		    * ----------------------------------------------------------------*/
		    GetDbName(szCurrentDbPath);
			_flushall();
			    
		    status = CopyDirectory(szMainCurrentDbPath, szMainBackupPath);

			// Customize for COMs, if don't write to this log directory

		    if (status != TRUE) { 
		    	RadReviewMsg(uiCOPY_DB_ERR, (const char *)szCurrentDbPath, (const char *)szRootBackupPath);
		    }
		    else {	
		    	MyStrnCpy(szDfltRootPath,szRootBackupPath, PATH_LEN);	// remember the default for next time
				msg.Printf("Logs copied to %s.", szRootBackupPath);	
			    GUI_MsgBox(msg, GUI_ICON_INFO);
		    }	

	    }	
	}    
}   		                                 
Пример #6
0
/*===========================================================================
 *
 *  Name	 :  	ImportAllDialogBox
 *
 *  Purpose	 :		Displays dialog box where user selects path(s) and
 *                  wildcard filename of files to import and whether or not to
 *					overwrite files or initialize the database.
 *
 *  Return value :  TRUE - selected new valid parameters
 *					FALSE - invalid parameters or chose to cancel
 *
 *  Special notes:  
 *
 *  Implicit Input :
     				    				
 *  Implicit Input/Output:
 *  Implicit Output:
 *
 *  date    /	author	revision
 *  -----------------	--------
 *  16-Mar-1996 SFK		Created
 *	15-Oct-1996 SFK		Broke function apart from main import routine.
 *
===========================================================================*/
static BOOL OnlyDialogBox(BOOL bAuto)
{                                 
    static BOOL bFirst = TRUE;
//	static char szOldDbName[DRIVE_LEN+PATH_LEN+1] = "";

	char szPaths[PATH_LEN+1];
	char szWildCards[WILDCARDS+1]; 
	
    GUI_ACTION DlgReturn;
    
   /* ------------------------------------------------------------------
    *	If this is the first time in option or you have switched databases,
	*	use the defaults read from the rad.ini file.
    * ------------------------------------------------------------------*/
    SetCurrentDrive();
    if ((bFirst == TRUE) || (!SameDb(glszOldDbName))) {
    	ReadINI_Parms();
   		bFirst = FALSE;
   		GetDbName(glszOldDbName);
    }	

   /* ------------------------------------------------------------------
    *	Use the path just read from ini if first time or 
	*	last known good path if not first time in option
    * ----------------------------------------------------------------*/
    MyStrnCpy(szWildCards, gllszWildCards, WILDCARDS);
    if (PathCopy(szPaths, gllszPaths) != TRUE) strcpy(szPaths, "C:\\"); // default to c: if problem
    
   /* ------------------------------------------------------------------
    *	Define the buttons and actions in the dialog box
    * ----------------------------------------------------------------*/
    CGUI_Dlg ImportAllDlg(IDD_IMPORT_DIALOG, NULL, DLG_POSN_NO_SAVE);
    if (ImportAllDlg.IsValid()) {
    
	   	ImportAllDlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		ImportAllDlg.DefinePushBtn(IDOK, GUI_OK);
		ImportAllDlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateINI_Parms);            
					                                               
		ImportAllDlg.DefineFldStaticTxt(IDC_IMPORT_DEFAULT_DB_NAME);
		ImportAllDlg.FldStaticTxtSetValue(IDC_IMPORT_DEFAULT_DB_NAME, glszOldDbName);
			
		ImportAllDlg.DefineFldTxt(IDC_IMPORT_EDIT_PATH, szPaths, PATH_LEN);
		ImportAllDlg.DefineFldTxt(IDC_IMPORT_EDIT_WILDCARD, szWildCards, WILDCARDS);
		ImportAllDlg.DefinePushBtn(IDC_IMPORT_BROWSE, GUI_BROWSE);
		ImportAllDlg.SetBrowseOutputCtrl(IDC_IMPORT_BROWSE, IDC_IMPORT_EDIT_PATH);
			
		ImportAllDlg.DefineCheckBox(IDC_IMPORT_OVERWRITE_BOX, &gllbAllOverwrite);		
		ImportAllDlg.DefineCheckBox(IDC_IMPORT_INITDB_BOX, &gllbAllInitDB);		
		ImportAllDlg.DefineCheckBox(IDC_IMPORT_SUBFOLDER_BOX, &gllbIncludeSubfolders);		
		
		ImportAllDlg.SetDlgExitValidateFn(ValidateImportPath);	// check for path with some files
		ImportAllDlg.SetFocus(IDOK);
	    DlgReturn = ImportAllDlg.Go();
	    if (DlgReturn == GUI_OK) {  
	    	ImportAllDlg.RetrieveAllControlValues();
	    	gllbDialogParmsOk = TRUE;	// have good values for DoIt
			MyStrnCpy(gllszPaths,szPaths, PATH_LEN);	// remember these as the last good values
			MyStrnCpy(gllszWildCards, szWildCards, WILDCARDS);
			// if got to this dialog box thru /SETUP start, then save values for ini write
			if (bAuto) UpdateValuesForIni(&ImportAllDlg, IDD_IMPORT_DIALOG);
	    	return(TRUE);
	    }	
    	return(FALSE); // chose to exit dialog box with Cancel
	}    
	return(FALSE); // problem creating dialog box
}   		                                 
Пример #7
0
bool FdoSmPhPostGisOwner::Add()
{
    FdoSmPhPostGisMgrP mgr(GetManager()->SmartCast<FdoSmPhPostGisMgr>());

    GdbiConnection* gdbiConn = NULL;
    gdbiConn = mgr->GetGdbiConnection();

    FdoStringP sqlStmt = FdoStringP::Format(
    L"CREATE DATABASE %ls TEMPLATE template_postgis_20 ENCODING 'UTF8'", static_cast<FdoString*>(GetDbName()));
    try
    {
        gdbiConn->ExecuteNonQuery(static_cast<const char*>(sqlStmt), true);
    }
    catch(...)
    {
        // On error, try old template
        sqlStmt = FdoStringP::Format(
        L"CREATE DATABASE %ls TEMPLATE template_postgis ENCODING 'UTF8'", static_cast<FdoString*>(GetDbName()));

        gdbiConn->ExecuteNonQuery(static_cast<const char*>(sqlStmt), true);
    }

    // Put datastore description into the database comments. 
    // While listing datastores, it is not easy to look into each 
    // database to find out if it has metaschema, and to extract the
    // description. Putting description in the database comments makes
    // it more readily available in this case.
    //
    // Another benefit is that descriptions, for datastores without metaschema,
    // can be persisted.

    FdoStringP description;

    // Encode whether the datastore has metaschema into the description.
    if ( GetHasMetaSchema() )
        description = FdoStringP(L"FDO Enabled: ") + GetDescription();
    else
        description = GetDescription();

    if ( description != L"" ) 
    {
        sqlStmt = FdoStringP::Format(
            L"comment on database \"%ls\" is %ls",
            GetName(),
            (FdoString*) mgr->FormatSQLVal(description, FdoSmPhColType_String)
        );
      
        gdbiConn->ExecuteNonQuery( (const char*) sqlStmt );
    }

    if (GetHasMetaSchema())
    {
        FdoStringsP keywords(FdoStringCollection::Create());
        keywords->Add(rdbi_vndr_name(mgr->GetRdbiContext()));
        keywords->Add(L"PostGIS" );

        // Switch to newly created owner and add the MetaSchema
        SetCurrent();

        try
        {
            AddMetaSchema(keywords, GetIsSystem());
        }
        catch (...)
        {
            try
            {
                // On error, switch back to default owner
                FdoSmPhOwnerP prevOwner(mgr->FindOwner());                
                if (prevOwner)
                    prevOwner->SetCurrent();
            }
            catch (...)
            {
                // Skip forward
            }
            throw;
        }
		
		if (!GetIsSystem())
        {
			SetOptions();
        }

        // Switch back to default owner
        FdoSmPhOwnerP prevOwner(mgr->FindOwner());
        if (prevOwner)
            prevOwner->SetCurrent();
    }
    
    return true;
}
// 12-Aug-2002	SFK	Changed to DATE
// 03-Oct-2003	SFK	Changed for new FacMgr
void RadMarksSummariesMenuOption()
{                                 
    static struct DATA_ANALYZE AnalyzeParms= {60, 10, 3.0, FALSE};
                                                    
	// these parameters remain unchanged for each execution of the menu option                                                    
	static DATE dUserIntervalStart = 0;
	static unsigned long ulUserInterval = 0;
	static unsigned int iUserUnits = 0;                 
	static unsigned int uiMarkType;
	static BOOL bFirst = TRUE;
	static DATE dLastSearchIntervalInDays = 0.0;
	static short sFacNum;
    
    //struct db_fac_rec dbFac;    
    struct GEN_DATE_STRUCT GenDate;
    struct GEN_TIME_STRUCT GenTime;
    struct db_mark_rec dbMark;
    
    GUI_ACTION DlgReturn;                                     
    CGFmtStr szInterval;

	int status;     
	unsigned long ulDbIntervalInWholeDays;
	DATE dSearchIntervalInDays;
	DATE dEnd;
	DATE dCurrentDay;
 	unsigned long ulTotalMarks;
 	unsigned long ulDailyMarks;
 	char szDate[DT_LEN+1], szTime[DT_LEN+1];
	char szFirstDate[DT_LEN+1];              
	char szLastDate[DT_LEN+1];              
	char **aszStaList = NULL; 

	// verify the facility is defined
	char szFacName[DB_NAME_LEN+1];
	if (!pglFacCfg->IsFacilityDefined(glsFacNum)) return;
	// 3.0.3.16 Dec 1, 2004  Check that there are some stations in the currently defined facility
	if (!pglFacCfg->DoesFacilityHaveAnyData(glsFacNum)) return;

	pglFacCfg->GetFacilityLongName(glsFacNum, szFacName, DB_NAME_LEN);


   /* ------------------------------------------------------------------
    *	Always find the first and last days in the database and set
	*	up the strings for display in the dialog box.
    * ----------------------------------------------------------------*/
	SetCurrentDrive();
	status = GetDatabaseIntervalParameters(szFirstDate, szLastDate, &ulDbIntervalInWholeDays, &dSearchIntervalInDays);
	if (status != TRUE) return;
	if (dSearchIntervalInDays <= 0.0) {
		RadReviewMsg(uiDB_EMPTY_STATUS);
		return;
	}
	

	if ((bFirst == TRUE) || (!SameDb(glszOldDbName)) || (dSearchIntervalInDays != dLastSearchIntervalInDays) || (sFacNum != glsFacNum)) {
	   /* ------------------------------------------------------------------
	    *	Get the default parameters from the Default database.
	    * ----------------------------------------------------------------*/
		status = AccessDefaultDatabase(READ, S_MARK_SUMM_TYPE, (short *)&uiMarkType);
		if (status != TRUE) {
   			RadReviewMsg(status, "when reading from Default database.  Cannot proceed.");			
			return;
		}
		
	   /* ------------------------------------------------------------------
	    *	Calculate the user interval
	    * ----------------------------------------------------------------*/
		GetReviewPeriodParameters(&dUserIntervalStart, &dEnd, &ulUserInterval);
		iUserUnits = 0;
	
		// remember the current conditions for future entries to this option
		sFacNum = glsFacNum;
	    GetDbName(glszOldDbName);								
		dLastSearchIntervalInDays = dSearchIntervalInDays;	
		bFirst = FALSE;
	}	
	    
   /* ------------------------------------------------------------------
    *	Define the dialog box
    * ----------------------------------------------------------------*/
    CGUI_Dlg Dlg(IDD_SUMMARIES_MARKS, NULL, DLG_POSN_NO_SAVE);
	if (Dlg.IsValid()) {
	   /* ------------------------------------------------------------------
	    *	Define the buttons and actions in the dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		Dlg.DefinePushBtn(IDOK, GUI_OK);                   
		Dlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateDbParms);  		       
				                                               
	   /* ------------------------------------------------------------------
	    *	Set facility label in dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefineFldStaticTxt(IDC_RAD_FACILITY);
		Dlg.FldStaticTxtSetValue(IDC_RAD_FACILITY, szFacName);
			
	   /* ------------------------------------------------------------------
	    *	Display current starting ending database dates and interval in dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefineFldStaticTxt(IDC_RAD_CURR_DB_START);
		Dlg.FldStaticTxtSetValue(IDC_RAD_CURR_DB_START, szFirstDate);
					
		Dlg.DefineFldStaticTxt(IDC_RAD_CURR_DB_END);
		Dlg.FldStaticTxtSetValue(IDC_RAD_CURR_DB_END, szLastDate);
		
		szInterval.Printf("%ld days", ulDbIntervalInWholeDays);  	
		Dlg.DefineFldStaticTxt(IDC_RAD_CURR_DB_INTERVAL);
		Dlg.FldStaticTxtSetValue(IDC_RAD_CURR_DB_INTERVAL, szInterval);
		
	   /* ------------------------------------------------------------------
	    *	Set up the search interval parameters in dialog box
	    * ----------------------------------------------------------------*/
		glMyDateTime.DATETimestampToGenStructs(dUserIntervalStart, &GenDate, &GenTime);
		Dlg.DefineFldDate(IDC_RAD_SRCH_STRTDATE, &GenDate);
		Dlg.DefineFldTime(IDC_RAD_SRCH_STRTTIME, &GenTime);
		
		Dlg.DefineFldNum(IDC_RAD_SRCH_INTERVAL, &ulUserInterval, 1, 10000,"%ld");
		Dlg.DefinePickList(IDC_RAD_INTRVL_UNITS_PL, glnaszIntervalUnitsPicklist, &iUserUnits);

	   /* ------------------------------------------------------------------
	    *	Set up the output display options in dialog box
	    * ----------------------------------------------------------------*/
		Dlg.DefinePickList(IDC_MARK_TYPE, gllMarkTypePicklist, &uiMarkType);

	   /* ------------------------------------------------------------------
	    *	Set up the focus and display the dialog box
	    * ----------------------------------------------------------------*/
		Dlg.SetFocus(IDC_RAD_SRCH_INTERVAL);   
		DlgReturn = Dlg.Go();
			    
	   /* ------------------------------------------------------------------
	    *	Returned from dialog box, now process it.
	    * ----------------------------------------------------------------*/
	    if (DlgReturn == GUI_OK) {  
			    	
	    	Dlg.RetrieveAllControlValues();	/* get dialog values */
	    	
		   /* ------------------------------------------------------------------
		    *	Setup the search interval and determine whether there is any
			*	data in the interval
		    * ----------------------------------------------------------------*/
			status = ConvertStructsToSearchIntervalParameters(&GenDate, &GenTime, iUserUnits, ulUserInterval, &dUserIntervalStart, &dEnd);
			if (status != TRUE) {	// no data for any station in the interval
				RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, dUserIntervalStart, dEnd, "any station");
				return;
			}

	
		   /* ------------------------------------------------------------------
			*	Some data exists,
			*	Open up the text window where the events will be displayed
			* ----------------------------------------------------------------*/
			if (pWin == NULL) {                
				pWin = new CGUI_TextWin("Summary of Marks Found");
				if (pWin != NULL) pWin->ShowStatusBar(TRUE);
			}   
			else {
				pWin->Clear();
			}
			pWin->SetFocus();
			
		   /* ------------------------------------------------------------------
			*   Display the general part of the header:
			*	facility name, search interval
			* ----------------------------------------------------------------*/
			if (!PrintFacilityHeader(pWin, sFacNum, dUserIntervalStart, dEnd)) return;
			
			status = ScanMarkRecs(dUserIntervalStart, FIRST, &dbMark);
			if (status != TRUE) {
				pWin->Printf("\n\nNo marks in database\n");
				pWin->Printf("______________________________________________________________________\n");
				if (pWin != NULL) pWin->EnableUserClose(CloseTextWindow);
				return;
			}	
					
		   /* ------------------------------------------------------------------
			*   Based on the choices specified, provide the appropriate summaries
			* ----------------------------------------------------------------*/
			switch (uiMarkType) {
				case ALL_MARKS:
					ulTotalMarks = 0;
					gllulPtsPrinted = 0;
					gllulTotalPtsPrinted = 0;
					pWin->Printf("Search Method: all marks\n");
					pWin->Printf("______________________________________________________________________\n");
	 		    	pWin->Printf("\nTime              Channel");		    
								  //96.10.10 13:44:44  PCAS-1
                	while ((status == TRUE) && (dbMark.d_mark_time_key < dEnd)) {
						if (status == TRUE) {
							PrintMarkSummary(&dbMark, pWin);
							ulTotalMarks++;
						}	
						status = ScanMarkRecs(dUserIntervalStart, NEXT, &dbMark);
					}	
					break;
															  
				case DAILY_MARK_SUMMARIES:
					ulTotalMarks = 0;	
					ulDailyMarks = 0;
					pWin->Printf("Search Method: daily summaries of all marks\n");
					pWin->Printf("______________________________________________________________________\n");
					pWin->Printf("\nDate       Marks");		    
								  //96.10.10 = 1234
					dCurrentDay = dbMark.d_mark_time_key;
					while ((status == TRUE) && (dbMark.d_mark_time_key < dEnd)) {					
						if (status == TRUE) {
							if ((int)dCurrentDay != (int)dbMark.d_mark_time_key) {
								glMyDateTime.DATETimestampToDateTimeStrs(dCurrentDay, szDate, szTime);
								pWin->Printf("\n%s = %4ld  ", szDate,  ulDailyMarks);
								dCurrentDay = dbMark.d_mark_time_key;
								ulDailyMarks = 1;
							}
							else {
								ulDailyMarks++;
							}	    
							ulTotalMarks++;
						}	
						status = ScanMarkRecs(dUserIntervalStart, NEXT, &dbMark);
					}
					if (ulDailyMarks > 0) {
						glMyDateTime.DATETimestampToDateTimeStrs(dCurrentDay, szDate, szTime);
						pWin->Printf("\n%s = %4ld  ", szDate,  ulDailyMarks);
					}	
				break;	
			}		
			pWin->Printf("\nTotal Marks Found = %lu\n", ulTotalMarks);		    			
			pWin->Printf("______________________________________________________________________\n");
			if (pWin != NULL) pWin->EnableUserClose(CloseTextWindow);
		}	
	}	
}   		                                 
Пример #9
0
///////////////////////////////////////////////////////////////////////////////////////////////
//	This displays only the dialog box part of this menu option
////////////////////////////////////////////////////////////////////////////////////////////////
static int OnlyDialogBox(BOOL bAutomated)
{                                 
//	static char szOldDbName[DRIVE_LEN+PATH_LEN+1] = {""};;
 	static BOOL bFirst = TRUE;
	static int sFacNum;
	static double dDbExactIntervalLastTime = 0;

    CGFmtStr szInterval;
	CGStr DumStr;
	char szFirstDate[DT_LEN+1], szLastDate[DT_LEN+1];
	unsigned long ulDbIntervalInDays, ulTotalPts;
	GUI_ACTION DlgReturn;                                     
	CGFmtStr msg;   
	int iStatus;
	double dDbExactInterval;
	DATE dDum;
	char szFacName[DB_NAME_LEN+1];
	unsigned int uiPicklistChoice;
	
	SetCurrentDrive();

	// verify the facility is defined
	if (!pglFacCfg->IsFacilityDefined(glsFacNum)) return(FALSE);
	// 3.0.3.16 Dec 1, 2004  Check that there are some stations in the currently defined facility
	if (!pglFacCfg->DoesFacilityHaveAnyData(glsFacNum)) return(FALSE);

	pglFacCfg->GetFacilityLongName(glsFacNum, szFacName, DB_NAME_LEN);

	// always get the current range of data in the db for display
	iStatus = GetDatabaseIntervalParameters(szFirstDate, szLastDate, &ulDbIntervalInDays, &dDbExactInterval);
	if (iStatus != TRUE) return(FALSE);
	if (dDbExactInterval <= 0.0) {
		RadReviewMsg(uiDB_EMPTY_STATUS);
		return(FALSE);
	}

	// only the first time or when something changes, read the default parameters
	// and get new search intervals (possibly from .ini)
    if ((bFirst == TRUE) || 
		(!SameDb(glszOldDbName)) || 
		(dDbExactInterval != dDbExactIntervalLastTime) ||
		(sFacNum != glsFacNum)) {

		ReadDefaultDbParameters();

		// Get the period the user wants to review
		GetReviewPeriodParameters(&glldReviewPeriodStart, &glldReviewPeriodEnd, &gllulInterval);
		glliUserUnits = 0;

		// remember the current conditions for future entries to this option
		sFacNum = glsFacNum;
	    GetDbName(glszOldDbName);								
		dDbExactIntervalLastTime = dDbExactInterval;
		bFirst = FALSE;
	}
	 
    CGUI_Dlg IntegrityDlg(IDD_TOOLS_INTEGRITY, NULL, DLG_POSN_NO_SAVE);
	if (IntegrityDlg.IsValid()) {	
	   /* ------------------------------------------------------------------
	    *	Define the buttons and actions in the dialog box
	    * ----------------------------------------------------------------*/
		IntegrityDlg.DefinePushBtn(IDCANCEL, GUI_CANCEL);
		IntegrityDlg.DefinePushBtn(IDOK, GUI_OK);
		IntegrityDlg.DefinePushBtn(IDUPDATE, GUI_NONE, UpdateDbParms);  		  
		//This push button was silly, change based on Picklist choices HN 3-26-08
//		IntegrityDlg.DefinePushBtn(IDUPDATECONDITIONS, GUI_NONE, ValidateStation);  		  
	
		// Fill in Facility portion of dialog
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_FACILITY);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_FACILITY, szFacName);

		// Fill in Station portion of dialog
		int iMaxLen;		// longest name in list -- not used
		if (!pglFacCfg->CreateStationPicklist(glsFacNum, TRUE, &aszStaList, &iMaxLen)) return (FALSE);	// list with All Stations as member
		short sTemp;
		pglFacCfg->GetPicklistChoiceForStationID(gllStaID, &sTemp);
		uiPicklistChoice = sTemp;
		IntegrityDlg.DefinePickList(IDC_INTEGRITY_STATION, aszStaList, &uiPicklistChoice);
		//HN 3-26-08  Set choices based on what is chosen.
		IntegrityDlg.SetCtrlNotifyFn(IDC_INTEGRITY_STATION,ValidateStation);

	   /* ------------------------------------------------------------------
	    * 	Display current starting ending database dates and interval
	    * ----------------------------------------------------------------*/
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_CURR_DB_START);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_CURR_DB_START, szFirstDate);
					
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_CURR_DB_END);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_CURR_DB_END, szLastDate);
		
		szInterval.Printf("%ld days", ulDbIntervalInDays);  			
		IntegrityDlg.DefineFldStaticTxt(IDC_INTEGRITY_CURR_DB_INTERVAL);
		IntegrityDlg.FldStaticTxtSetValue(IDC_INTEGRITY_CURR_DB_INTERVAL, szInterval);
		
	   /* ------------------------------------------------------------------
	    *	Fill in default values for search start date and time plus interval
	    * ----------------------------------------------------------------*/
		//Date.DATETimestampToGenStructs(glldReviewPeriodStart, &gllGenDate, &gllGenTime);
		glMyDateTime.DATETimestampToGenStructs(glldReviewPeriodStart, &gllGenDate, &gllGenTime);
		IntegrityDlg.DefineFldDate(IDC_INTEGRITY_SRCH_STRTDATE, &gllGenDate);
		IntegrityDlg.DefineFldTime(IDC_INTEGRITY_SRCH_STRTTIME, &gllGenTime);
			                                                          
		IntegrityDlg.DefineFldNum(IDC_INTEGRITY_SRCH_INTERVAL, &gllulInterval, 1, 10000,"%ld");
		IntegrityDlg.DefinePickList(IDC_INTEGRITY_INTRVL_UNITS_PL, glnaszIntervalUnitsPicklist, &glliUserUnits);

		IntegrityDlg.DefineFldNum(IDC_INTEGRITY_TOLERANCE, &gllsTolerance, 0, 100,"%d");
			
	   /* ------------------------------------------------------------------
	    *	Define all checkboxes
	    * ----------------------------------------------------------------*/
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_AC_POWER, &gllFlags.bACPower);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_BATTERY_LOW, &gllFlags.bBatteryLow);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_COLDSTART, &gllFlags.bColdStart);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_AUTHENTICATION, &gllFlags.bAuthentication);
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_ORDER, &gllFlags.bOutOfOrder);		
		IntegrityDlg.DefineCheckBox(IDC_INTEGRITY_GAP, &gllFlags.bGaps);		
		SetCheckboxes(&IntegrityDlg, &gllStaID);

		IntegrityDlg.SetFocus(IDC_INTEGRITY_SRCH_INTERVAL);
		if (bAutomated) IntegrityDlg.SetFocus(IDOK);
			
tryagain:	    DlgReturn = IntegrityDlg.Go();
			    
	    if (DlgReturn == GUI_OK) {  
			    	
	    	IntegrityDlg.RetrieveAllControlValues();                                          
	    //	gllsStaChoice = uiTemp;		// do I need this
	    	
		    // Get the station number first, we exit if they pick EOSS HN 3-26-08
			// get the station number associated with the station choice
			if (!pglFacCfg->GetStationIDForPicklistChoice(uiPicklistChoice, &gllStaID)) return(FALSE);

			if (gllStaID.sStaType == EOSS_TYPE)
			{
				GUI_MsgBox ("EOSS instruments cannot be analyzed for data integrity.\nChoose another instrument for analysis.",GUI_ICON_INFO, GUI_OK);
				goto abort;
			}
			
			/* ------------------------------------------------------------------
		    *	Check that at least one condition is checked
		    * ----------------------------------------------------------------*/    
		    if ((gllFlags.bACPower == FALSE ) && (gllFlags.bBatteryLow == FALSE) &&
		    	(gllFlags.bColdStart == FALSE ) && (gllFlags.bAuthentication == FALSE) &&
		    	(gllFlags.bOutOfOrder == FALSE ) && (gllFlags.bGaps == FALSE)) 
			{ 
				GUI_MsgBox("No conditions selected for integrity check.\nTry again.", GUI_ICON_INFO, GUI_OK);
				goto tryagain;
		    }	
			// get the station number associated with the station choice
			if (gllStaID.sStaType == BINARY_TYPE) 
			{
				if (gllFlags.bOutOfOrder == FALSE)
				{
					GUI_MsgBox("Binary data can only be checked for Out of Order condition.\nIntegrity check will abort now.", GUI_ICON_INFO, GUI_OK);
					goto abort;
				}
			}
			// if running in automated mode, then record the parameters
		    if (bAutomated) {
		    	WriteDefaultDbParameters(&IntegrityDlg, IDD_TOOLS_INTEGRITY);
			}	
		   /* ------------------------------------------------------------------
			*	Check to see that there is data for station(s) in the interval selected.
			* ----------------------------------------------------------------*/   
			iStatus = ConvertStructsToSearchIntervalParameters(&gllGenDate, &gllGenTime, glliUserUnits, gllulInterval, &glldReviewPeriodStart, &glldReviewPeriodEnd);
			if (gllStaID.sStaID == -1) {
				if (iStatus != TRUE) {	// no data for any station in the interval
					RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, glldReviewPeriodStart, glldReviewPeriodEnd, "any station");
					goto abort;
				}
			}
			else {
				iStatus = GetDataStatistics(gllStaID, true, glldReviewPeriodStart, glldReviewPeriodEnd, &dDum, &dDum, &ulTotalPts);
				if ((iStatus != TRUE) || (ulTotalPts == 0)) {
					RadReviewMsg(uiNO_DATA_IN_INTERVAL_WARN, glldReviewPeriodStart, glldReviewPeriodEnd, (const char*)aszStaList[gllsStaChoice]);
					goto abort;
				}
			}
			
			pglFacCfg->DestroyPicklist(aszStaList);
			aszStaList = NULL;
			return(TRUE);
		}
	}
	return(FALSE);

abort:
	pglFacCfg->DestroyPicklist(aszStaList);
	aszStaList = NULL;
    return(FALSE);
}