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

#IQRV #comment [ResourceWatcher] 新增实体接口UpdateDNS,GetNetworkInfo

gifur 4 лет назад
Родитель
Сommit
3476596be6

+ 26 - 1
Module/mod_ResourceWatcher/ResourceWatcher.xml

@@ -160,7 +160,32 @@
 				<param name="evtLogFileName" type="string" />
 			</res>
 		</twoway>
-		
+    <twoway  name="UpdateDNS" overlap="true">
+      <req>
+        <param name="interface" type="string" />
+        <param name="dns1" type="string" />
+        <param name="dns2" type="string" />
+      </req>
+      <res>
+        <param name="result" type="int" />
+        <param name="messsge" type="string" />
+      </res>
+    </twoway>
+    <twoway  name="GetNetworkInfo" overlap="true">
+      <req>
+        <param name="filter" type="int" />
+      </req>
+      <res>
+        <param name="status" type="int" />
+        <param name="default" type="string"/>
+        <param name="names" type="array_string"/>
+        <param name="ips" type="array_string"/>
+        <param name="macs" type="array_string"/>
+        <param name="masks" type="array_string"/>
+        <param name="gateways" type="array_string"/>
+        <param name="dns" type="array_string"/>
+      </res>
+    </twoway>
 	</class>
 	<message name="QueryCardSwiper">
 			<param name="status" type = "int" />	

+ 64 - 3
Module/mod_ResourceWatcher/ResourceWatcher_client_g.h

@@ -11,10 +11,13 @@
 namespace ResourceWatcher {
 class ResourceWatcherService_ClientBase : public CClientSessionBase {
 public:
-	ResourceWatcherService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
+	explicit ResourceWatcherService_ClientBase(CEntityBase *pEntity) : m_pEntityBase(pEntity), m_bSysManaged(false) {}
 
 protected:
-	virtual ~ResourceWatcherService_ClientBase() {}
+	virtual ~ResourceWatcherService_ClientBase()
+	{
+		/// override by user
+	}
 public:
 
 	ErrorCodeEnum Connect(CSmartPointer<IAsynWaitSp> &spAsyncWait)
@@ -210,6 +213,64 @@ public:
 		return Error;
 	}
 
+	ErrorCodeEnum UpdateDNS(ResourceWatcherService_UpdateDNS_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		return pFunc->AsyncRequest(ResourceWatcherService_Method_UpdateDNS, ResourceWatcherService_MethodSignature_UpdateDNS, Buf, spAsyncWait, dwTimeout);
+	}
+	ErrorCodeEnum UpdateDNS(ResourceWatcherService_UpdateDNS_Req &Req, ResourceWatcherService_UpdateDNS_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = UpdateDNS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum UpdateDNS(ResourceWatcherService_UpdateDNS_Req &Req, ResourceWatcherService_UpdateDNS_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = UpdateDNS(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum GetNetworkInfo(ResourceWatcherService_GetNetworkInfo_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		return pFunc->AsyncRequest(ResourceWatcherService_Method_GetNetworkInfo, ResourceWatcherService_MethodSignature_GetNetworkInfo, Buf, spAsyncWait, dwTimeout);
+	}
+	ErrorCodeEnum GetNetworkInfo(ResourceWatcherService_GetNetworkInfo_Req &Req, ResourceWatcherService_GetNetworkInfo_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = GetNetworkInfo(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum GetNetworkInfo(ResourceWatcherService_GetNetworkInfo_Req &Req, ResourceWatcherService_GetNetworkInfo_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = GetNetworkInfo(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
 
 	bool SafeDelete()
 	{
@@ -219,7 +280,7 @@ public:
 		return m_bSysManaged;
 	}
 
-protected:
+private:
 	bool m_bSysManaged;
 	CEntityBase *m_pEntityBase;
 };

+ 58 - 0
Module/mod_ResourceWatcher/ResourceWatcher_def_g.h

@@ -18,6 +18,8 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_Method_GetCpuType 2
 #define ResourceWatcherService_Method_OperateFile 3
 #define ResourceWatcherService_Method_ExtractEventLog 4
+#define ResourceWatcherService_Method_UpdateDNS 5
+#define ResourceWatcherService_Method_GetNetworkInfo 6
 
 #define ResourceWatcherService_MethodSignature_Fetch -1944912560
 #define ResourceWatcherService_MethodSignature_GetDevInfo 296205965
@@ -25,6 +27,8 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_MethodSignature_GetCpuType -1911838440
 #define ResourceWatcherService_MethodSignature_OperateFile 935567963
 #define ResourceWatcherService_MethodSignature_ExtractEventLog -1046715334
+#define ResourceWatcherService_MethodSignature_UpdateDNS -943970884
+#define ResourceWatcherService_MethodSignature_GetNetworkInfo 1741482404
 
 struct ResourceWatcherService_Fetch_Req
 {
@@ -199,6 +203,60 @@ struct ResourceWatcherService_ExtractEventLog_Ans
 
 };
 
+struct ResourceWatcherService_UpdateDNS_Req
+{
+	CSimpleStringA interface;
+	CSimpleStringA dns1;
+	CSimpleStringA dns2;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & interface & dns1 & dns2;
+	}
+
+};
+
+struct ResourceWatcherService_UpdateDNS_Ans
+{
+	int result;
+	CSimpleStringA messsge;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result & messsge;
+	}
+
+};
+
+struct ResourceWatcherService_GetNetworkInfo_Req
+{
+	int filter;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & filter;
+	}
+
+};
+
+struct ResourceWatcherService_GetNetworkInfo_Ans
+{
+	int status;
+	CSimpleStringA default;
+	CAutoArray<CSimpleStringA> names;
+	CAutoArray<CSimpleStringA> ips;
+	CAutoArray<CSimpleStringA> macs;
+	CAutoArray<CSimpleStringA> masks;
+	CAutoArray<CSimpleStringA> gateways;
+	CAutoArray<CSimpleStringA> dns;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & status & default & names & ips & macs & masks & gateways & dns;
+	}
+
+};
+
 
 ///////////////////////////
 

+ 58 - 2
Module/mod_ResourceWatcher/ResourceWatcher_server_g.h

@@ -12,9 +12,15 @@ namespace ResourceWatcher {
 class ResourceWatcherService_ServerSessionBase : public CServerSessionBase
 {
 public:
-	ResourceWatcherService_ServerSessionBase() { }
+	ResourceWatcherService_ServerSessionBase()
+	{
+		/// override by user
+	}
 
-	virtual ~ResourceWatcherService_ServerSessionBase() { }
+	virtual ~ResourceWatcherService_ServerSessionBase()
+	{
+		/// override by user
+	}
 
 	virtual bool IsExclusive() { return false; }
 
@@ -66,6 +72,20 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_UpdateDNS:
+			if (dwSignature == ResourceWatcherService_MethodSignature_UpdateDNS) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_GetNetworkInfo:
+			if (dwSignature == ResourceWatcherService_MethodSignature_GetNetworkInfo) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -107,6 +127,16 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_UpdateDNS:
+			if (dwSignature != ResourceWatcherService_MethodSignature_UpdateDNS) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_GetNetworkInfo:
+			if (dwSignature != ResourceWatcherService_MethodSignature_GetNetworkInfo) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -144,6 +174,16 @@ public:
 	/// override by user
 	}
 
+	virtual void Handle_UpdateDNS(SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req, ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_GetNetworkInfo(SpReqAnsContext<ResourceWatcherService_GetNetworkInfo_Req, ResourceWatcherService_GetNetworkInfo_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
 	virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		CAutoBuffer Buf;
@@ -208,6 +248,22 @@ public:
 						Handle_ExtractEventLog(ctx);
 					}
 					break;
+				case ResourceWatcherService_Method_UpdateDNS:
+					{
+						SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req,ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req,ResourceWatcherService_UpdateDNS_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						Handle_UpdateDNS(ctx);
+					}
+					break;
+				case ResourceWatcherService_Method_GetNetworkInfo:
+					{
+						SpReqAnsContext<ResourceWatcherService_GetNetworkInfo_Req,ResourceWatcherService_GetNetworkInfo_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetNetworkInfo_Req,ResourceWatcherService_GetNetworkInfo_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						Handle_GetNetworkInfo(ctx);
+					}
+					break;
 				default:
 					assert(0);
 					break;

+ 26 - 1
addin/res/StructConfig/ResourceWatcher.xml

@@ -160,7 +160,32 @@
 				<param name="evtLogFileName" type="string" />
 			</res>
 		</twoway>
-		
+    <twoway  name="UpdateDNS" overlap="true">
+      <req>
+        <param name="interface" type="string" />
+        <param name="dns1" type="string" />
+        <param name="dns2" type="string" />
+      </req>
+      <res>
+        <param name="result" type="int" />
+        <param name="messsge" type="string" />
+      </res>
+    </twoway>
+    <twoway  name="GetNetworkInfo" overlap="true">
+      <req>
+        <param name="filter" type="int" />
+      </req>
+      <res>
+        <param name="status" type="int" />
+        <param name="default" type="string"/>
+        <param name="names" type="array_string"/>
+        <param name="ips" type="array_string"/>
+        <param name="macs" type="array_string"/>
+        <param name="masks" type="array_string"/>
+        <param name="gateways" type="array_string"/>
+        <param name="dns" type="array_string"/>
+      </res>
+    </twoway>
 	</class>
 	<message name="QueryCardSwiper">
 			<param name="status" type = "int" />