Explorar o código

1、配置项目信息
2、冒烟任务也接收停止处理。

scbc %!s(int64=5) %!d(string=hai) anos
pai
achega
fb958cb202

+ 1 - 1
SATService/SATService/PythonExecutor.cpp

@@ -48,7 +48,7 @@ DWORD CPythonExecutor::_WorkerThread(LPVOID lpParam)
 {
 	CPythonExecutor* that = (CPythonExecutor*)lpParam;
 
-#if defined _DEBUG || defined RTEST
+#if (defined _DEBUG && !defined DBG_SERVER) || defined RTEST
 	that->RunScriptProcess();
 #else
 	that->ServiceRunScriptProcess();

+ 13 - 0
SATService/SATService/SATExecutor.cpp

@@ -84,6 +84,19 @@ bool CSATExecutor::IsTaskExist(SATHTTP::STTask &task)
 			if ( !bExsit )
 				m_vtSmokingTask.push_back(task);
 		}
+		else
+		{
+			AutoThreadSection ats(&m_csTask);
+			std::vector<SATHTTP::STTask>::iterator it = m_vtTask.begin();
+			for ( ; it != m_vtTask.end(); it++ ) {
+				// 不要使用nTaskId,这个值没啥用;//不要使用Id这个值,如果任务被停止会变更;
+				if ( it->taskInfo.nInstanceId == task.taskInfo.nInstanceId ) {
+					it->taskInfo._nExecutionState = SATHTTP::EXECUTED;
+					it->taskInfo._nExecutionResult = SATHTTP::FAIL;
+					break;
+				}
+			} 
+		}
 		
 		return true;
 	}

+ 7 - 3
SATService/SATService/SATService.cpp

@@ -22,6 +22,9 @@ extern int test();
 // 工作启动回调函数;
 void CALLBACK WorkStart()
 {
+#ifdef DBG_SERVER
+	Sleep(30000);
+#endif
 	GLOBAL::GetIniInfo();
 	GLOBAL::GetMacAddress();
 	GLOBAL::GetLocalAddress();
@@ -73,7 +76,8 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 	{
 		GLOBAL::Init();
 		// TODO: 在此处为应用程序的行为编写代码。
-#if defined RTEST || defined _DEBUG
+
+#if (defined _DEBUG && !defined DBG_SERVER) || defined RTEST
 		WorkStart();
 
 		// 指定时间停止;
@@ -87,8 +91,7 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 
 		// 关闭TCP服务;
 		WorkEndof();		
-		return 0;
-#endif
+#else
 		// 进程存在,直接退出;
 		TCHAR szExeName[MAX_PATH] = {0};
 		TCHAR szDrive[_MAX_DRIVE] = { 0 };
@@ -149,6 +152,7 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 		};
 #endif 
 		WindowsService::SvcInstall();
+#endif
 	}
 
 	return nRetCode;

+ 105 - 4
SATService/SATService/SATService.vcproj

@@ -174,7 +174,7 @@
 			/>
 		</Configuration>
 		<Configuration
-			Name="RTest|Win32"
+			Name="ReleaseConsole|Win32"
 			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
 			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
 			ConfigurationType="1"
@@ -253,6 +253,83 @@
 				CommandLine="copy $(ProjectDir)SATProtocol.h ..\..\SATHelper\SATHelper\SATProtocol.h /y/a&#x0D;&#x0A;copy $(OutDir)\$(ProjectName).exe D:\SAT\SATService\$(ProjectName).exe /y/a&#x0D;&#x0A;"
 			/>
 		</Configuration>
+		<Configuration
+			Name="DebugService|Win32"
+			OutputDirectory="..\..\..\..\bin\$(SolutionName)"
+			IntermediateDirectory="$(OutDir)\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			UseOfMFC="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../cJSON;C:\Python27\Include;..\libssh2\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DBG_SERVER"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="SATHTTP.lib IRControl.lib libssh2.lib"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="C:\Python27\libs;..\libssh2"
+				UACExecutionLevel="2"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine="copy $(ProjectDir)SATProtocol.h ..\..\SATHelper\SATHelper\SATProtocol.h /y/a"
+			/>
+		</Configuration>
 	</Configurations>
 	<References>
 	</References>
@@ -298,7 +375,15 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="RTest|Win32"
+					Name="ReleaseConsole|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="DebugService|Win32"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
@@ -406,7 +491,15 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="RTest|Win32"
+					Name="ReleaseConsole|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="DebugService|Win32"
 					>
 					<Tool
 						Name="VCCLCompilerTool"
@@ -498,7 +591,15 @@
 					/>
 				</FileConfiguration>
 				<FileConfiguration
-					Name="RTest|Win32"
+					Name="ReleaseConsole|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="0"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="DebugService|Win32"
 					>
 					<Tool
 						Name="VCCLCompilerTool"

+ 2 - 1
SATService/SATService/stdafx.h

@@ -25,7 +25,8 @@
 #include <afxcmn.h>                     // MFC ¶Ô Windows ¹«¹²¿Ø¼þµÄÖ§³Ö
 #endif // _AFX_NO_AFXCMN_SUPPORT
 
-#define _DBG_SOMKING_
+//#define _DBG_SOMKING_
+#define _DBG_TEST_SERVER_
 
 #include <iostream>
 #include <string>