LboxNTSchedule

  コンストラクタ



  
// *********************************************************
// コンストラクタ
// *********************************************************
LboxNTSchedule::LboxNTSchedule()
{
	this->ServerName.SetChar( 0, 0 );
	// サーバ名をセットする場合は、先頭は "\\" である必要がある
	// C の文字列としては "\\\\"
}

// *********************************************************
// デストラクタ
// *********************************************************
LboxNTSchedule::~LboxNTSchedule()
{

}
  



  Add



  
// *********************************************************
// スケジュール追加
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// DaysOfWeek : 1 -> 月
// *********************************************************
BOOL LboxNTSchedule::Add(
	LboxString *LTime, LboxString *LCommand,
	LboxString *LDaysOfMonth,
    LboxString *LDaysOfWeek,
	BOOL bEvery,
	BOOL bUseToday )
{
	return LboxNTSchedule::Add(
		LTime->szLboxString,
		LCommand->szLboxString,
		LDaysOfMonth->szLboxString,
		LDaysOfWeek->szLboxString,
		bEvery,
		bUseToday
	);
}
BOOL LboxNTSchedule::Add(
	LPTSTR lpTime, LPTSTR lpCommand,
	LPTSTR lpDaysOfMonth,
    LPTSTR lpDaysOfWeek,
	BOOL bEvery,
	BOOL bUseToday )
{
	NET_API_STATUS nRet;
	LPCWSTR lpwServerName;
	_bstr_t ServerName;
	_bstr_t Command;

	// コマンド文字列の設定
	Command.operator = (lpCommand);

	// エラー文字列の初期化
	this->ErrMessage.operator = ("");

	// サーバーの設定
	if ( this->ServerName.operator == ("") ) {
		lpwServerName = NULL;
	}
	else {
		ServerName.operator = (this->ServerName.szLboxString);
		lpwServerName = ServerName.operator const wchar_t * ();
	}

	AT_INFO ai;
	DWORD nTime1,nTime2;
	LboxToken Ltoken;

	// 時間文字列の処理
	Ltoken.CreateToken( lpTime, ":" );
	if ( Ltoken.nCount != 2 ) {
		this->ErrMessage.operator = (
			"時間フォーマットは 99:99 です"
		);
		return false;
	}

	LboxString LString;

	LString.operator = (Ltoken.Token[0]);
	nTime1 = (DWORD)(LString.Atoi());
	LString.operator = (Ltoken.Token[1]);
	nTime2 = (DWORD)(LString.Atoi());

	ai.JobTime = (nTime1 * 3600 + nTime2 * 60) * 1000;

	// 実行日の処理
	DWORD	DayBit,WorkBit;
	LONG	nShiftCnt;

	ai.DaysOfMonth = 0;

	LString.operator = (lpDaysOfMonth);
	if ( LString.operator != ("") ) {
		Ltoken.CreateToken( lpDaysOfMonth, "," );
		DayBit = 0;
		int i;
		for( i = 0; i < Ltoken.nCount; i++ ) {
			LString.operator = (Ltoken.Token[i]);
			nShiftCnt = LString.Atoi() - 1;
			WorkBit = 1;
			WorkBit = WorkBit << nShiftCnt;
			DayBit |= WorkBit;
		}
		ai.DaysOfMonth = DayBit;
	}

	// 実行週の処理
	ai.DaysOfWeek = 0;
	LString.operator = (lpDaysOfWeek);
	if ( LString.operator != ("") ) {
		Ltoken.CreateToken( lpDaysOfWeek, "," );
		DayBit = 0;
		int i;
		for( i = 0; i < Ltoken.nCount; i++ ) {
			if ( lstrcmp( Ltoken.Token[i], "1" ) == 0 ) {
				DayBit |= 1;
			}
			if ( lstrcmp( Ltoken.Token[i], "2" ) == 0 ) {
				DayBit |= 2;
			}
			if ( lstrcmp( Ltoken.Token[i], "3" ) == 0 ) {
				DayBit |= 4;
			}
			if ( lstrcmp( Ltoken.Token[i], "4" ) == 0 ) {
				DayBit |= 8;
			}
			if ( lstrcmp( Ltoken.Token[i], "5" ) == 0 ) {
				DayBit |= 16;
			}
			if ( lstrcmp( Ltoken.Token[i], "6" ) == 0 ) {
				DayBit |= 32;
			}
			if ( lstrcmp( Ltoken.Token[i], "7" ) == 0 ) {
				DayBit |= 64;
			}
		}
		ai.DaysOfWeek = (UCHAR)DayBit;
	}

	ai.Flags = 0;
	if ( bEvery ) {
		ai.Flags |= JOB_RUN_PERIODICALLY;
		if ( bUseToday ) {
			ai.Flags |= JOB_ADD_CURRENT_DATE;
		}
	}

	ai.Command = Command.operator wchar_t * ();

	nRet = NetScheduleJobAdd(
		lpwServerName,
		(LPBYTE)&ai,
		&(this->dwJobId)
	);

	if ( nRet != NERR_Success ) {
		this->ErrMessage.operator = (
			"NetScheduleJobAdd の実行が失敗しました"
		);
		return false;
	}

	return true;
}
  



  AddOnlyOnce

  
// *********************************************************
// スケジュール追加( 一番近い指定時刻を1回限り )
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// DaysOfWeek : 1 -> 月
// *********************************************************
BOOL LboxNTSchedule::AddOnlyOnce( LboxString *LTime, LboxString *LCommand )
{
	return LboxNTSchedule::AddOnlyOnce(
		LTime->szLboxString,
		LCommand->szLboxString
	);
}
BOOL LboxNTSchedule::AddOnlyOnce( LPTSTR lpTime, LPTSTR lpCommand )
{
	return LboxNTSchedule::Add(
		lpTime,
		lpCommand,
		"",
		"",
		false,
		false
	);
}
  



  AddMonthOnlyOnce

  
// *********************************************************
// スケジュール追加( 一番近い指定日の時刻を1回限り )
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// *********************************************************
BOOL LboxNTSchedule::AddMonthOnlyOnce(
	LboxString *LTime, LboxString *LCommand, LboxString *LDaysOfManth )
{
	return LboxNTSchedule::AddMonthOnlyOnce(
		LTime->szLboxString,
		LCommand->szLboxString,
		LDaysOfManth->szLboxString
	);
}
BOOL LboxNTSchedule::AddMonthOnlyOnce(
	LPTSTR lpTime, LPTSTR lpCommand, LPTSTR lpDaysOfManth )
{
	return LboxNTSchedule::Add(
		lpTime,
		lpCommand,
		lpDaysOfManth,
		"",
		false,
		false
	);
}
  



  AddWeekOnlyOnce

  
// *********************************************************
// スケジュール追加( 一番近い指定曜日の時刻を1回限り )
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// *********************************************************
BOOL LboxNTSchedule::AddWeekOnlyOnce(
	LboxString *LTime, LboxString *LCommand, LboxString *LDaysOfWeek )
{
	return LboxNTSchedule::AddWeekOnlyOnce(
		LTime->szLboxString,
		LCommand->szLboxString,
		LDaysOfWeek->szLboxString
	);

}
BOOL LboxNTSchedule::AddWeekOnlyOnce(
	LPTSTR lpTime, LPTSTR lpCommand, LPTSTR lpDaysOfWeek )
{
	return LboxNTSchedule::Add(
		lpTime,
		lpCommand,
		"",
		lpDaysOfWeek,
		false,
		false
	);
}
  



  AddEveryDay

  
// *********************************************************
// スケジュール追加( 指定時刻を毎日 )
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// *********************************************************
BOOL LboxNTSchedule::AddEveryDay(
	LboxString *LTime, LboxString *LCommand )
{
	return LboxNTSchedule::AddEveryDay(
		LTime->szLboxString,
		LCommand->szLboxString
	);

}
BOOL LboxNTSchedule::AddEveryDay(
	LPTSTR lpTime, LPTSTR lpCommand )
{
	return LboxNTSchedule::Add(
		lpTime,
		lpCommand,
		"",
		"1,2,3,4,5,6,7",
		true,
		false
	);
}
  



  AddEveryDaysOfMonth

  
// *********************************************************
// スケジュール追加( 指定日を継続して実行 )
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// *********************************************************
BOOL LboxNTSchedule::AddEveryDaysOfMonth(
	LboxString *LTime, LboxString *LCommand, LboxString *LDaysOfManth )
{
	return LboxNTSchedule::AddEveryDaysOfMonth(
		LTime->szLboxString,
		LCommand->szLboxString,
		LDaysOfManth->szLboxString
	);

}
BOOL LboxNTSchedule::AddEveryDaysOfMonth(
	LPTSTR lpTime, LPTSTR lpCommand, LPTSTR lpDaysOfManth )
{
	return LboxNTSchedule::Add(
		lpTime,
		lpCommand,
		lpDaysOfManth,
		"",
		true,
		false
	);
}
  



  AddEveryDaysOfWeek

  
// *********************************************************
// スケジュール追加( 指定曜日を継続して実行 )
// 戻り値 : true 成功, false 失敗
// lpTime : "99:99"
// *********************************************************
BOOL LboxNTSchedule::AddEveryDaysOfWeek(
	LboxString *LTime, LboxString *LCommand, LboxString *LDaysOfWeek )
{
	return LboxNTSchedule::AddEveryDaysOfWeek(
		LTime->szLboxString,
		LCommand->szLboxString,
		LDaysOfWeek->szLboxString
	);

}
BOOL LboxNTSchedule::AddEveryDaysOfWeek(
	LPTSTR lpTime, LPTSTR lpCommand, LPTSTR lpDaysOfWeek )
{
	return LboxNTSchedule::Add(
		lpTime,
		lpCommand,
		"",
		lpDaysOfWeek,
		true,
		false
	);
}
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ