Просмотр исходного кода

add missing files to OTSTools.

sunyi 5 лет назад
Родитель
Сommit
a9ffe5c48a

+ 115 - 0
OTS/OTSTools/CLogExportForCSharp.h

@@ -0,0 +1,115 @@
+#pragma once
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#pragma managed
+
+
+// 注意: 修改  配置属性->常规->公共语言运行时支持 修改为: 使用公共语言扩展 /clr
+
+#include "MyLogger.h"
+#include "CLogExportForCpp.h"
+using namespace System;      //for  String^
+
+namespace NSLogTools
+{
+	//using namespace NSLogFunExport::MethodFunction;
+	public ref class CFunExportClass
+	{
+		
+	public:
+
+		CFunExportClass()
+		{
+			int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+			tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
+			_CrtSetDbgFlag(tmpFlag);
+
+			//_CrtSetBreakAlloc(8218);
+		
+		}
+
+		~CFunExportClass()
+		{
+			EndLogFile();
+		}
+		!CFunExportClass()
+		{
+			 EndLogFile();
+		}
+
+		void InitLog(String^ LogName)
+		{
+	
+			CString cs = CString(LogName);
+			LPCTSTR lpStr =cs.GetString ();
+
+			 InitLogFile(lpStr);
+			
+
+		}
+
+		void EndCSharpLogFile()
+		{			
+
+
+			 EndLogFile();
+		}
+
+		// 打印Log信息
+		BOOL TraceLog(String^ TraceData)
+		{
+		
+			CString cs = CString(TraceData);
+			LPCTSTR lpTraceData = cs.GetString ();
+			 LogTrace(__FILE__, __LINE__, lpTraceData);
+		
+			return TRUE;
+		}
+
+		// 打印LogError信息
+		BOOL TraceErrorLog(String^ TraceData)
+		{
+	
+			CString cs = CString(TraceData);
+			LPCTSTR lpTraceData = cs.GetString();
+			 LogErrorTrace(__FILE__, __LINE__, lpTraceData);
+
+		
+			return TRUE;
+		}
+
+
+		// 打印Log二进制信息信息
+		BOOL LogBinaryDataLog(array<System::Byte>^  byteArray)
+		{
+	
+
+			pin_ptr<System::Byte> LpData = &byteArray[0];
+			int ilen = byteArray->Length;
+			 LogBinaryTrace("Binary", LpData, ilen);
+
+			return TRUE;
+		}
+
+
+		//延迟时间
+		BOOL Waiting(int iMilliseconds)
+		{
+		
+
+			 WaitingTime(iMilliseconds);
+			return TRUE;
+		}
+
+
+
+
+	private:
+		
+	};
+
+}
+
+
+

+ 103 - 0
OTS/OTSTools/CLogExportForCpp.cpp

@@ -0,0 +1,103 @@
+#pragma once
+//#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#include "stdafx.h"
+#include "CLogExportForCpp.h"
+
+#include "MyLogger.h"
+
+#define LOGINFO_SWITCH
+
+namespace NSLogTools
+{
+
+	MyLogger* myLogFile = NULL;
+	void  InitLogFile(LPCTSTR lpLogName)
+	{
+		/*int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+		tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
+		_CrtSetDbgFlag(tmpFlag);*/
+
+		//_CrtSetBreakAlloc(131090);
+		// is log file created?
+		if (NULL == myLogFile)
+		{
+			myLogFile = new MyLogger();
+			myLogFile->InitLogFile(lpLogName);
+
+
+		}
+	}
+
+	void  LogTrace(LPCTSTR szFile, long lLine, LPCTSTR lpTraceLog, ...)
+	{
+		if (NULL == myLogFile)
+		{
+			return;
+		}
+
+
+		myLogFile->LogTrace(szFile, lLine, lpTraceLog);
+	}
+
+	void  LogInfoTrace(LPCTSTR szFile, long lLine, LPCTSTR lpTraceLog, ...)
+	{
+#ifdef LOGINFO_SWITCH
+		if (NULL == myLogFile)
+		{
+			return;
+		}
+
+
+		myLogFile->LogInfoTrace(szFile, lLine, lpTraceLog);
+#endif
+	}
+
+	void  LogErrorTrace(LPCTSTR szFile, long lLine, LPCTSTR lpErrorTrace, ...)
+	{
+		if (NULL == myLogFile)
+		{
+			return;
+		}
+
+
+
+		myLogFile->LogErrorTrace(szFile, lLine, lpErrorTrace);
+	}
+
+	void  LogBinaryTrace(LPCTSTR szHead, BYTE * pbyData, UINT nLen)
+	{
+		if (NULL == myLogFile)
+		{
+			//	InitLogFile(g_csLogName);
+			return;
+		}
+
+		myLogFile->LogBinaryTrace(szHead, pbyData, nLen);
+	}
+
+	void  WaitingTime(int iMilliseconds)
+	{
+		if (NULL == myLogFile)
+		{
+			//	InitLogFile(g_csLogName);
+			return;
+		}
+
+		myLogFile->WaitingTime(iMilliseconds);
+	}
+
+	void  EndLogFile()
+	{
+		if (NULL != myLogFile)
+		{
+			delete myLogFile;
+			myLogFile = NULL;
+		}
+
+
+	}
+}
+
+

+ 16 - 0
OTS/OTSTools/LogResource.h

@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by OTSLog.rc
+//
+
+// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE	30000
+#define _APS_NEXT_CONTROL_VALUE		30000
+#define _APS_NEXT_SYMED_VALUE		30000
+#define _APS_NEXT_COMMAND_VALUE		32771
+#endif
+#endif

+ 63 - 0
OTS/OTSTools/OTSLog.cpp

@@ -0,0 +1,63 @@
+// OTSLog.cpp : 定义 DLL 的初始化例程。
+//
+
+#include "stdafx.h"
+#include "OTSLog.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+//
+//TODO:  如果此 DLL 相对于 MFC DLL 是动态链接的,
+//		则从此 DLL 导出的任何调入
+//		MFC 的函数必须将 AFX_MANAGE_STATE 宏添加到
+//		该函数的最前面。
+//
+//		例如: 
+//
+//		extern "C" BOOL PASCAL EXPORT ExportedFunction()
+//		{
+//			AFX_MANAGE_STATE(AfxGetStaticModuleState());
+//			// 此处为普通函数体
+//		}
+//
+//		此宏先于任何 MFC 调用
+//		出现在每个函数中十分重要。  这意味着
+//		它必须作为函数中的第一个语句
+//		出现,甚至先于所有对象变量声明,
+//		这是因为它们的构造函数可能生成 MFC
+//		DLL 调用。
+//
+//		有关其他详细信息,
+//		请参阅 MFC 技术说明 33 和 58。
+//
+
+// COTSLogApp
+
+BEGIN_MESSAGE_MAP(COTSLogApp, CWinApp)
+END_MESSAGE_MAP()
+
+
+// COTSLogApp 构造
+
+COTSLogApp::COTSLogApp()
+{
+	// TODO:  在此处添加构造代码,
+	// 将所有重要的初始化放置在 InitInstance 中
+}
+
+
+// 唯一的一个 COTSLogApp 对象
+
+COTSLogApp theApp;
+
+
+// COTSLogApp 初始化
+
+BOOL COTSLogApp::InitInstance()
+{
+	CWinApp::InitInstance();
+
+	return TRUE;
+}

+ 4 - 0
OTS/OTSTools/OTSTools.vcxproj.user

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup />
+</Project>

+ 80 - 0
OTS/OTSTools/Tools/GdiplusNew.h

@@ -0,0 +1,80 @@
+//// Ensure that GdiPlus header files work properly with MFC DEBUG_NEW and STL header files.
+
+/*
+PRB: Microsoft Foundation Classes DEBUG_NEW Does Not Work with GDI+
+
+SYMPTOMS:
+When you build a debug version of a Microsoft Foundation Classes (MFC) application that uses GDI+, 
+you may receive an error message that resembles the following:
+error C2660: 'Gdiplus::GdiplusBase::operator new' : function does not take 3 parameters
+
+CAUSE:
+In debug builds, MFC defines a preprocessor macro that expands the new operator to an overloaded new operator 
+that takes two extra parameters. The extra parameters are the source file name and code line number. 
+MFC can use this information to report memory leaks to the programmer when in debug mode. 
+This works for MFC classes because MFC provides overloads for new that accept the extra parameters.
+
+However, because this expansion is done by the preprocessor, it affects all usage of the new operator. 
+If any non-MFC classes are used in the project, their new operator is also expanded, even if no suitable overload 
+of new is available in that class. This is what happens in GDI+, and as a result, you receive a compile-time error message.
+*/
+
+#pragma once
+
+#define iterator _iterator
+ 
+#ifdef _DEBUG
+ 
+namespace Gdiplus
+{
+     namespace DllExports
+     {
+         #include "GdiplusMem.h"
+     };
+ 
+     #ifndef _GDIPLUSBASE_H
+     #define _GDIPLUSBASE_H
+     class GdiplusBase
+     {
+         public:
+              void (operator delete)(void* in_pVoid)
+              {
+                   DllExports::GdipFree(in_pVoid);
+              }
+ 
+              void* (operator new)(size_t in_size)
+              {
+                   return DllExports::GdipAlloc(in_size);
+              }
+ 
+              void (operator delete[])(void* in_pVoid)
+              {
+                   DllExports::GdipFree(in_pVoid);
+              }
+ 
+              void* (operator new[])(size_t in_size)
+              {
+                   return DllExports::GdipAlloc(in_size);
+              }
+ 
+              void * (operator new)(size_t nSize, LPCSTR lpszFileName, int nLine)
+              {
+                   return DllExports::GdipAlloc(nSize);
+              }
+ 
+              void operator delete(void* p, LPCSTR lpszFileName, int nLine)
+              {
+                   DllExports::GdipFree(p);
+              }
+ 
+         };
+     #endif // #ifndef _GDIPLUSBASE_H
+}
+#endif // #ifdef _DEBUG
+ 
+#include "gdiplus.h"
+ 
+#undef iterator
+ 
+//// Ensure that Gdiplus.lib is linked.
+#pragma comment(lib, "gdiplus.lib")