Added ability for copying DCIs from one node to another
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 29 Sep 2004 14:46:26 +0000 (14:46 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 29 Sep 2004 14:46:26 +0000 (14:46 +0000)
22 files changed:
TODO
include/nms_cscp.h
include/nxclapi.h
src/console/win32/CreateContainerDlg.cpp
src/console/win32/DataCollectionEditor.cpp
src/console/win32/DataCollectionEditor.h
src/console/win32/ObjectBrowser.cpp
src/console/win32/ThresholdDlg.cpp
src/console/win32/comm.cpp
src/console/win32/globals.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/libnxcl/datacoll.cpp
src/libnxcl/main.cpp
src/server/core/dcitem.cpp
src/server/core/dcithreshold.cpp
src/server/core/nms_core.h
src/server/core/nms_dcoll.h
src/server/core/nms_objects.h
src/server/core/node.cpp
src/server/core/session.cpp

diff --git a/TODO b/TODO
index 7c163ed..6ef80a1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -20,6 +20,8 @@ GENERAL:
 - Add new data types for data collection: unsigned integer 32 bits
   and unsigned integer 64 bits
 - Allow converting counters to deltas in data collection
+- Add ability to clear collected DCI data
+- Add ability to send Wake-On-LAN packets to managed nodes
 
 
 SERVER:
index 79723af..ad22739 100644 (file)
@@ -253,6 +253,7 @@ typedef struct
 #define CMD_MODIFY_CONTAINER_CAT    0x0058
 #define CMD_POLL_NODE               0x0059
 #define CMD_POLLING_INFO            0x005A
+#define CMD_COPY_DCI                0x005B
 
 
 //
@@ -367,6 +368,10 @@ typedef struct
 #define VID_DCI_FORMULA             ((DWORD)106)
 #define VID_POLL_TYPE               ((DWORD)107)
 #define VID_POLLER_MESSAGE          ((DWORD)108)
+#define VID_SOURCE_OBJECT_ID        ((DWORD)109)
+#define VID_DESTINATION_OBJECT_ID   ((DWORD)110)
+#define VID_NUM_ITEMS               ((DWORD)111)
+#define VID_ITEM_LIST               ((DWORD)112)
 
 // Variable ranges for object's ACL
 #define VID_ACL_USER_BASE           ((DWORD)0x00001000)
index 19c3440..7170bd8 100644 (file)
@@ -223,6 +223,7 @@ typedef unsigned long HREQUEST;
 #define RCC_INVALID_ALARM_ID        ((DWORD)21)
 #define RCC_INVALID_ACTION_ID       ((DWORD)22)
 #define RCC_OPERATION_IN_PROGRESS   ((DWORD)23)
+#define RCC_DCI_COPY_ERRORS         ((DWORD)24)
 
 
 //
@@ -852,6 +853,8 @@ DWORD LIBNXCL_EXPORTABLE NXCCloseNodeDCIList(NXC_DCI_LIST *pItemList);
 DWORD LIBNXCL_EXPORTABLE NXCCreateNewDCI(NXC_DCI_LIST *pItemList, DWORD *pdwItemId);
 DWORD LIBNXCL_EXPORTABLE NXCUpdateDCI(DWORD dwNodeId, NXC_DCI *pItem);
 DWORD LIBNXCL_EXPORTABLE NXCDeleteDCI(NXC_DCI_LIST *pItemList, DWORD dwItemId);
+DWORD LIBNXCL_EXPORTABLE NXCCopyDCI(DWORD dwSrcNodeId, DWORD dwDstNodeId, 
+                                    DWORD dwNumItems, DWORD *pdwItemList);
 DWORD LIBNXCL_EXPORTABLE NXCItemIndex(NXC_DCI_LIST *pItemList, DWORD dwItemId);
 DWORD LIBNXCL_EXPORTABLE NXCGetDCIData(DWORD dwNodeId, DWORD dwItemId, DWORD dwMaxRows,
                                        DWORD dwTimeFrom, DWORD dwTimeTo, NXC_DCI_DATA **ppData);
index f11f9b1..93f171b 100644 (file)
@@ -56,6 +56,7 @@ BOOL CCreateContainerDlg::OnInitDialog()
    // Setup list of container categories
    for(i = 0; i < g_pCCList->dwNumElements; i++)
       m_wndCategoryList.AddString(g_pCCList->pElements[i].szName);
+   m_wndCategoryList.SelectString(-1, g_pCCList->pElements[0].szName);
 
    return TRUE;
 }
index aa0e0d1..9d081f5 100644 (file)
@@ -52,6 +52,7 @@ BEGIN_MESSAGE_MAP(CDataCollectionEditor, CMDIChildWnd)
        ON_UPDATE_COMMAND_UI(ID_ITEM_SHOWDATA, OnUpdateItemShowdata)
        ON_COMMAND(ID_ITEM_GRAPH, OnItemGraph)
        ON_UPDATE_COMMAND_UI(ID_ITEM_GRAPH, OnUpdateItemGraph)
+       ON_COMMAND(ID_ITEM_COPY, OnItemCopy)
        //}}AFX_MSG_MAP
        ON_NOTIFY(NM_DBLCLK, IDC_LIST_VIEW, OnListViewDblClk)
 END_MESSAGE_MAP()
@@ -504,3 +505,45 @@ BOOL CDataCollectionEditor::PreCreateWindow(CREATESTRUCT& cs)
                                          AfxGetApp()->LoadIcon(IDI_DATACOLLECT));
        return CMDIChildWnd::PreCreateWindow(cs);
 }
+
+
+//
+// WM_COMMAND::ID_ITEM_COPY message handler
+//
+
+void CDataCollectionEditor::OnItemCopy() 
+{
+   CObjectSelDlg dlg;
+   int iPos, iItem;
+   DWORD dwResult, dwNumItems, *pdwItemList;
+
+   dwNumItems = m_wndListCtrl.GetSelectedCount();
+   if (dwNumItems > 0)
+   {
+      pdwItemList = (DWORD *)malloc(sizeof(DWORD) * dwNumItems);
+
+      // Build list of items to be copied
+      iPos = 0;
+      iItem = m_wndListCtrl.GetNextItem(-1, LVNI_SELECTED);
+      while(iItem != -1)
+      {
+         pdwItemList[iPos++] = m_wndListCtrl.GetItemData(iItem);
+         iItem = m_wndListCtrl.GetNextItem(iItem, LVNI_SELECTED);
+      }
+
+      // Ask for destination nodes
+      dlg.m_dwAllowedClasses = SCL_NODE;
+      if (dlg.DoModal() == IDOK)
+      {
+         // Perform request to server
+         dwResult = DoRequestArg4(NXCCopyDCI, (void *)m_pItemList->dwNodeId, 
+               (void *)dlg.m_pdwObjectList[0], (void *)dwNumItems, 
+               pdwItemList, "Copying items...");
+         if (dwResult != RCC_SUCCESS)
+            theApp.ErrorBox(dwResult, "Error copying items: %s");
+      }
+
+      // Cleanup
+      free(pdwItemList);
+   }
+}
index 7460411..41c89dd 100644 (file)
@@ -57,6 +57,7 @@ protected:
        afx_msg void OnUpdateItemShowdata(CCmdUI* pCmdUI);
        afx_msg void OnItemGraph();
        afx_msg void OnUpdateItemGraph(CCmdUI* pCmdUI);
+       afx_msg void OnItemCopy();
        //}}AFX_MSG
    afx_msg void OnListViewDblClk(LPNMITEMACTIVATE pNMHDR, LRESULT *pResult);
        DECLARE_MESSAGE_MAP()
index 2172fe2..7d5ade5 100644 (file)
@@ -705,8 +705,11 @@ restart_parent_check:;
          {
             // Check if current item has been changed
             hItem = m_wndTreeCtrl.GetSelectedItem();
-            if (m_wndTreeCtrl.GetItemData(hItem) == dwObjectId)
-               m_wndPreviewPane.Refresh();
+            if (hItem != NULL)
+            {
+               if (m_wndTreeCtrl.GetItemData(hItem) == dwObjectId)
+                  m_wndPreviewPane.Refresh();
+            }
          }
       }
    }
index 7586d2b..b8e39df 100644 (file)
@@ -110,7 +110,7 @@ void CThresholdDlg::OnButtonSelect()
 {
    CEventSelDlg dlg;
 
-   if (dlg.DoModal())
+   if (dlg.DoModal() == IDOK)
    {
       m_dwEventId = dlg.m_pdwEventList[0];
       m_wndEventName.SetWindowText(NXCGetEventName(m_dwEventId));
index d1d3921..57fd5dc 100644 (file)
@@ -232,8 +232,12 @@ static DWORD WINAPI RequestThread(void *pArg)
       case 3:
          dwResult = pData->pFunc(pData->pArg1, pData->pArg2, pData->pArg3);
          break;
+      case 4:
+         dwResult = pData->pFunc(pData->pArg1, pData->pArg2, pData->pArg3, pData->pArg4);
+         break;
       case 6:
-         dwResult = pData->pFunc(pData->pArg1, pData->pArg2, pData->pArg3, pData->pArg4, pData->pArg5, pData->pArg6);
+         dwResult = pData->pFunc(pData->pArg1, pData->pArg2, pData->pArg3, 
+                                 pData->pArg4, pData->pArg5, pData->pArg6);
          break;
    }
    if (pData->hWnd != NULL)
@@ -349,6 +353,26 @@ DWORD DoRequestArg3(void *pFunc, void *pArg1, void *pArg2, void *pArg3, char *ps
 }
 
 
+//
+// Perform request with 4 parameter
+//
+
+DWORD DoRequestArg4(void *pFunc, void *pArg1, void *pArg2, void *pArg3, 
+                    void *pArg4, char *pszInfoText)
+{
+   RqData rqData;
+
+   rqData.hWnd = NULL;
+   rqData.dwNumParams = 4;
+   rqData.pArg1 = pArg1;
+   rqData.pArg2 = pArg2;
+   rqData.pArg3 = pArg3;
+   rqData.pArg4 = pArg4;
+   rqData.pFunc = (DWORD (*)(...))pFunc;
+   return ExecuteRequest(&rqData, pszInfoText);
+}
+
+
 //
 // Perform request with 6 parameter
 //
index bcac083..7f42c42 100644 (file)
@@ -140,6 +140,7 @@ DWORD DoRequest(DWORD (* pFunc)(void), char *pszInfoText);
 DWORD DoRequestArg1(void *pFunc, void *pArg1, char *pszInfoText);
 DWORD DoRequestArg2(void *pFunc, void *pArg1, void *pArg2, char *pszInfoText);
 DWORD DoRequestArg3(void *pFunc, void *pArg1, void *pArg2, void *pArg3, char *pszInfoText);
+DWORD DoRequestArg4(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4, char *pszInfoText);
 DWORD DoRequestArg6(void *pFunc, void *pArg1, void *pArg2, void *pArg3, void *pArg4, 
                     void *pArg5, void *pArg6, char *pszInfoText);
 DWORD WINAPI PollerThread(void *pArg);
index 94f2725..f843938 100644 (file)
@@ -17,20 +17,20 @@ Class9=CMapView
 
 ResourceCount=83
 Resource1=IDD_THRESHOLD (English (U.S.))
-Resource2=IDD_EDIT_RULE_COMMENT
+Resource2=IDD_DCI_THRESHOLDS
 Resource3=IDM_VIEW_SPECIFIC (English (U.S.))
-Resource4=IDD_SELECT_USER
-Resource5=IDD_OBJECT_NODE_GENERAL
+Resource4=IDD_OBJECT_CAPS
+Resource5=IDA_ALARM_BROWSER
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDA_OBJECT_BROWSER
+Resource6=IDD_CREATE_CONTAINER
 Class11=CProgressDialog
-Resource7=IDD_NEW_USER
+Resource7=IDD_REQUEST_PROCESSING
 Class12=CObjectBrowser
-Resource8=IDD_EDIT_EVENT
+Resource8=IDA_EPP
 Class13=CObjectPropDlg
 Resource9=IDD_CP_GENERAL (English (U.S.))
 Resource10=IDA_OBJECT_BROWSER (English (U.S.))
@@ -46,7 +46,7 @@ Resource17=IDD_SET_PASSWORD (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDD_OBJECT_SECURITY (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
-Resource20=IDD_DCI_TRANSFORM
+Resource20=IDD_ACTION_PROPERTIES
 Class17=CObjectPreview
 Resource21=IDD_DCI_TRANSFORM (English (U.S.))
 Class18=CToolBox
@@ -59,32 +59,32 @@ Class23=CNodePropsGeneral
 Resource23=IDD_LOGIN (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
-Resource24=IDD_EDIT_RULE_SEVERITY
+Resource24=IDD_SELECT_OBJECT
 Class26=CRequestProcessingDlg
 Resource25=IDD_EDIT_EVENT (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
-Resource27=IDD_GROUP_PROPERTIES
+Resource27=IDD_OBJECT_SECURITY
 Resource28=IDD_USER_PROPERTIES (English (U.S.))
 Class27=CObjectPropsGeneral
 Resource29=IDA_ALARM_BROWSER (English (U.S.))
 Class28=CObjectPropsSecurity
 Resource30=IDD_CREATE_NODE (English (U.S.))
-Resource31=IDD_ABOUTBOX
-Resource32=IDD_OBJECT_CAPS
+Resource31=IDA_MDI_DEFAULT
+Resource32=IDD_ABOUTBOX
 Class29=CUserSelectDlg
-Resource33=IDA_MDI_DEFAULT
+Resource33=IDD_SELECT_ACTION
 Class30=CUserEditor
 Resource34=IDD_DCI_PROPERTIES
 Class31=CNewUserDlg
-Resource35=IDR_MAINFRAME
-Resource36=IDD_MIB_BROWSER
+Resource35=IDM_VIEW_SPECIFIC
+Resource36=IDD_SET_PASSWORD
 Class32=CUserPropDlg
 Resource37=IDM_CONTEXT (English (U.S.))
-Resource38=IDD_SET_PASSWORD
+Resource38=IDD_SELECT_USER
 Class33=CGroupPropDlg
-Resource39=IDD_OBJECT_GENERAL
-Resource40=IDD_SELECT_EVENT
-Resource41=IDD_THRESHOLD
+Resource39=IDD_EDIT_EVENT
+Resource40=IDD_THRESHOLD
+Resource41=IDD_GROUP_PROPERTIES
 Resource42=IDD_SELECT_OBJECT (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
@@ -100,55 +100,55 @@ Class41=CGraphFrame
 Class42=CDCIThresholdsPage
 Resource46=IDA_MDI_DEFAULT (English (U.S.))
 Resource47=IDD_OBJECT_CAPS (English (U.S.))
-Resource48=IDD_CREATE_CONTAINER
+Resource48=IDD_CP_GENERAL
 Class43=CThresholdDlg
 Resource49=IDD_SELECT_USER (English (U.S.))
-Resource50=IDA_EPP
+Resource50=IDD_CREATE_NODE
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
 Resource51=IDR_MAINFRAME (English (U.S.))
-Resource52=IDM_VIEW_SPECIFIC
+Resource52=IDD_SELECT_EVENT
 Class48=CObjectSelDlg
-Resource53=IDD_EDIT_RULE_ALARM
-Resource54=IDD_OBJECT_SECURITY
+Resource53=IDD_EDIT_RULE_COMMENT
+Resource54=IDD_OBJECT_NODE_GENERAL
 Class49=CRuleCommentDlg
-Resource55=IDD_CREATE_NODE
+Resource55=IDD_NEW_ACTION
 Class50=CEventSelDlg
-Resource56=IDA_ALARM_BROWSER
+Resource56=IDR_MAINFRAME
 Resource57=IDD_REQUEST_PROCESSING (English (U.S.))
-Resource58=IDD_LOGIN
+Resource58=IDA_OBJECT_BROWSER
 Resource59=IDD_ABOUTBOX (English (U.S.))
 Resource60=IDD_MIB_BROWSER (English (U.S.))
 Class51=CObjectPropsPresentation
 Resource61=IDD_OBJECT_PRESENTATION (English (U.S.))
-Resource62=IDD_SELECT_ACTION
+Resource62=IDD_EDIT_RULE_ALARM
 Class52=CRuleSeverityDlg
-Resource63=IDD_REQUEST_PROCESSING
+Resource63=IDD_LOGIN
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
 Resource64=IDD_SELECT_EVENT (English (U.S.))
-Resource65=IDD_SELECT_OBJECT
+Resource65=IDD_DCI_COLLECTION
 Resource66=IDD_NEW_ACTION (English (U.S.))
 Resource67=IDD_DCI_COLLECTION (English (U.S.))
 Resource68=IDD_NEW_USER (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
-Resource69=IDD_NEW_ACTION
-Resource70=IDD_DCI_THRESHOLDS
+Resource69=IDD_OBJECT_PRESENTATION
+Resource70=IDD_USER_PROPERTIES
 Class57=CNewActionDlg
-Resource71=IDD_USER_PROPERTIES
+Resource71=IDD_OBJECT_GENERAL
 Class58=CEditActionDlg
-Resource72=IDD_OBJECT_PRESENTATION
+Resource72=IDD_MIB_BROWSER
 Class59=CActionSelDlg
-Resource73=IDD_DCI_COLLECTION
+Resource73=IDD_NEW_USER
 Resource74=IDD_EDIT_RULE_COMMENT (English (U.S.))
 Resource75=IDD_EDIT_RULE_ALARM (English (U.S.))
 Resource76=IDM_CONTEXT
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
-Resource77=IDD_ACTION_PROPERTIES
+Resource77=IDD_EDIT_RULE_SEVERITY
 Class62=CCreateNodeDlg
 Resource78=IDA_EPP (English (U.S.))
 Resource79=IDD_CREATE_CONTAINER (English (U.S.))
@@ -158,7 +158,7 @@ Resource81=IDD_ACTION_PROPERTIES (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
-Resource83=IDD_CP_GENERAL
+Resource83=IDD_DCI_TRANSFORM
 
 [CLS:CConsoleApp]
 Type=0
@@ -604,31 +604,32 @@ Command26=ID_USER_PROPERTIES
 Command27=ID_ITEM_NEW
 Command28=ID_ITEM_EDIT
 Command29=ID_ITEM_DELETE
-Command30=ID_ITEM_ACTIVATE
-Command31=ID_ITEM_DISABLE
-Command32=ID_ITEM_SHOWDATA
-Command33=ID_ITEM_GRAPH
-Command34=ID_POLICY_ADD
-Command35=ID_POLICY_DELETE
-Command36=ID_POLICY_EDIT
-Command37=ID_POLICY_NEGATECELL
-Command38=ID_POLICY_INSERTRULE_ABOVE
-Command39=ID_POLICY_INSERTRULE_BELOW
-Command40=ID_POLICY_INSERTRULE_TOP
-Command41=ID_POLICY_INSERTRULE_BOTTOM
-Command42=ID_POLICY_DELETERULE
-Command43=ID_POLICY_ENABLERULE
-Command44=ID_POLICY_DISABLERULE
-Command45=ID_ALARM_ACKNOWLEGE
-Command46=ID_ALARM_DELETE
-Command47=ID_ALARM_GOTOSOURCE
-Command48=ID_UPDATE_EVENT_LIST
-Command49=ID_CONTROLPANEL_ACTIONS
-Command50=ID_CONTROLPANEL_EVENTS
-Command51=ID_CONTROLPANEL_EVENTPOLICY
-Command52=ID_CONTROLPANEL_USERS
-Command53=ID_CONTROLPANEL_DCT
-CommandCount=53
+Command30=ID_ITEM_COPY
+Command31=ID_ITEM_ACTIVATE
+Command32=ID_ITEM_DISABLE
+Command33=ID_ITEM_SHOWDATA
+Command34=ID_ITEM_GRAPH
+Command35=ID_POLICY_ADD
+Command36=ID_POLICY_DELETE
+Command37=ID_POLICY_EDIT
+Command38=ID_POLICY_NEGATECELL
+Command39=ID_POLICY_INSERTRULE_ABOVE
+Command40=ID_POLICY_INSERTRULE_BELOW
+Command41=ID_POLICY_INSERTRULE_TOP
+Command42=ID_POLICY_INSERTRULE_BOTTOM
+Command43=ID_POLICY_DELETERULE
+Command44=ID_POLICY_ENABLERULE
+Command45=ID_POLICY_DISABLERULE
+Command46=ID_ALARM_ACKNOWLEGE
+Command47=ID_ALARM_DELETE
+Command48=ID_ALARM_GOTOSOURCE
+Command49=ID_UPDATE_EVENT_LIST
+Command50=ID_CONTROLPANEL_ACTIONS
+Command51=ID_CONTROLPANEL_EVENTS
+Command52=ID_CONTROLPANEL_EVENTPOLICY
+Command53=ID_CONTROLPANEL_USERS
+Command54=ID_CONTROLPANEL_DCT
+CommandCount=54
 
 [ACL:IDA_MDI_DEFAULT]
 Type=1
@@ -1201,44 +1202,45 @@ Command17=ID_OBJECT_PROPERTIES
 Command18=ID_ITEM_NEW
 Command19=ID_ITEM_EDIT
 Command20=ID_ITEM_DELETE
-Command21=ID_ITEM_ACTIVATE
-Command22=ID_ITEM_DISABLE
-Command23=ID_ITEM_SHOWDATA
-Command24=ID_ITEM_GRAPH
-Command25=ID_POLICY_INSERTRULE_ABOVE
-Command26=ID_POLICY_INSERTRULE_BELOW
-Command27=ID_POLICY_INSERTRULE_TOP
-Command28=ID_POLICY_INSERTRULE_BOTTOM
-Command29=ID_POLICY_DELETERULE
-Command30=ID_POLICY_ENABLERULE
-Command31=ID_POLICY_DISABLERULE
-Command32=ID_POLICY_ADD
-Command33=ID_POLICY_DELETE
-Command34=ID_POLICY_NEGATECELL
-Command35=ID_POLICY_INSERTRULE_ABOVE
-Command36=ID_POLICY_INSERTRULE_BELOW
-Command37=ID_POLICY_INSERTRULE_TOP
-Command38=ID_POLICY_INSERTRULE_BOTTOM
-Command39=ID_POLICY_DELETERULE
-Command40=ID_POLICY_ENABLERULE
-Command41=ID_POLICY_DISABLERULE
-Command42=ID_POLICY_EDIT
-Command43=ID_POLICY_INSERTRULE_ABOVE
-Command44=ID_POLICY_INSERTRULE_BELOW
-Command45=ID_POLICY_INSERTRULE_TOP
-Command46=ID_POLICY_INSERTRULE_BOTTOM
-Command47=ID_POLICY_DELETERULE
-Command48=ID_POLICY_ENABLERULE
-Command49=ID_POLICY_DISABLERULE
-Command50=ID_ALARM_ACKNOWLEGE
-Command51=ID_ALARM_DELETE
-Command52=ID_ALARM_GOTOSOURCE
-Command53=ID_ACTION_NEW
-Command54=ID_ACTION_RENAME
-Command55=ID_ACTION_DELETE
-Command56=ID_ACTION_PROPERTIES
-Command57=ID_POLL_RESTART
-CommandCount=57
+Command21=ID_ITEM_COPY
+Command22=ID_ITEM_ACTIVATE
+Command23=ID_ITEM_DISABLE
+Command24=ID_ITEM_SHOWDATA
+Command25=ID_ITEM_GRAPH
+Command26=ID_POLICY_INSERTRULE_ABOVE
+Command27=ID_POLICY_INSERTRULE_BELOW
+Command28=ID_POLICY_INSERTRULE_TOP
+Command29=ID_POLICY_INSERTRULE_BOTTOM
+Command30=ID_POLICY_DELETERULE
+Command31=ID_POLICY_ENABLERULE
+Command32=ID_POLICY_DISABLERULE
+Command33=ID_POLICY_ADD
+Command34=ID_POLICY_DELETE
+Command35=ID_POLICY_NEGATECELL
+Command36=ID_POLICY_INSERTRULE_ABOVE
+Command37=ID_POLICY_INSERTRULE_BELOW
+Command38=ID_POLICY_INSERTRULE_TOP
+Command39=ID_POLICY_INSERTRULE_BOTTOM
+Command40=ID_POLICY_DELETERULE
+Command41=ID_POLICY_ENABLERULE
+Command42=ID_POLICY_DISABLERULE
+Command43=ID_POLICY_EDIT
+Command44=ID_POLICY_INSERTRULE_ABOVE
+Command45=ID_POLICY_INSERTRULE_BELOW
+Command46=ID_POLICY_INSERTRULE_TOP
+Command47=ID_POLICY_INSERTRULE_BOTTOM
+Command48=ID_POLICY_DELETERULE
+Command49=ID_POLICY_ENABLERULE
+Command50=ID_POLICY_DISABLERULE
+Command51=ID_ALARM_ACKNOWLEGE
+Command52=ID_ALARM_DELETE
+Command53=ID_ALARM_GOTOSOURCE
+Command54=ID_ACTION_NEW
+Command55=ID_ACTION_RENAME
+Command56=ID_ACTION_DELETE
+Command57=ID_ACTION_PROPERTIES
+Command58=ID_POLL_RESTART
+CommandCount=58
 
 [MNU:IDM_CONTEXT (English (U.S.))]
 Type=1
index 95c3617..36241cc 100644 (file)
@@ -236,6 +236,7 @@ BEGIN
         MENUITEM "&New...\tIns",                ID_ITEM_NEW
         MENUITEM "&Edit...\tAlt+Enter",         ID_ITEM_EDIT
         MENUITEM "&Delete\tDel",                ID_ITEM_DELETE
+        MENUITEM "&Copy to other node(s)...\tCtrl+C", ID_ITEM_COPY
         MENUITEM SEPARATOR
         MENUITEM "&Activate\tAlt+A",            ID_ITEM_ACTIVATE
         MENUITEM "D&isable\tAlt+D",             ID_ITEM_DISABLE
@@ -332,6 +333,7 @@ BEGIN
         MENUITEM "&New...",                     ID_ITEM_NEW
         MENUITEM "&Edit...",                    ID_ITEM_EDIT
         MENUITEM "&Delete",                     ID_ITEM_DELETE
+        MENUITEM "&Copy to other node(s)...",   ID_ITEM_COPY
         MENUITEM SEPARATOR
         MENUITEM "&Activate",                   ID_ITEM_ACTIVATE
         MENUITEM "D&isable",                    ID_ITEM_DISABLE
index 04b63ef..4343608 100644 (file)
 #define ID_OBJECT_POLL_CONFIGURATION    32877
 #define ID_CONTROLPANEL_DCT             32880
 #define ID_POLL_RESTART                 32881
+#define ID_ITEM_COPY                    32882
 #define IDS_GETFOLDERPATH_FAILED        61216
 #define IDS_WORKDIR_CREATION_FAILED     61217
 
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        229
-#define _APS_NEXT_COMMAND_VALUE         32882
+#define _APS_NEXT_COMMAND_VALUE         32883
 #define _APS_NEXT_CONTROL_VALUE         1173
 #define _APS_NEXT_SYMED_VALUE           120
 #endif
index 980cfc6..e1a6006 100644 (file)
@@ -541,3 +541,27 @@ BOOL LIBNXCL_EXPORTABLE NXCSwapThresholds(NXC_DCI *pItem, DWORD dwIndex1, DWORD
    }
    return bResult;
 }
+
+
+//
+// Copy data collection items from one node to another
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCCopyDCI(DWORD dwSrcNodeId, DWORD dwDstNodeId, 
+                                    DWORD dwNumItems, DWORD *pdwItemList)
+{
+   CSCPMessage msg;
+   DWORD dwRqId;
+
+   dwRqId = g_dwMsgId++;
+
+   msg.SetCode(CMD_COPY_DCI);
+   msg.SetId(dwRqId);
+   msg.SetVariable(VID_SOURCE_OBJECT_ID, dwSrcNodeId);
+   msg.SetVariable(VID_DESTINATION_OBJECT_ID, dwDstNodeId);
+   msg.SetVariable(VID_NUM_ITEMS, dwNumItems);
+   msg.SetVariableToInt32Array(VID_ITEM_LIST, dwNumItems, pdwItemList);
+   SendMsg(&msg);
+
+   return WaitForRCC(dwRqId);
+}
index 60b6ebf..a018dd1 100644 (file)
@@ -116,9 +116,10 @@ const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError)
       "Invalid object name",
       "Invalid alarm ID",
       "Invalid action ID",
-      "Operation in progress"
+      "Operation in progress",
+      "Copy operation failed for one or more DCI(s)"
    };
-   return ((dwError >= 0) && (dwError <= RCC_OPERATION_IN_PROGRESS)) ? pszErrorText[dwError] : "Unknown error code";
+   return ((dwError >= 0) && (dwError <= RCC_DCI_COPY_ERRORS)) ? pszErrorText[dwError] : "Unknown error code";
 }
 
 
index 6374744..c4f97c8 100644 (file)
@@ -43,11 +43,48 @@ DCItem::DCItem()
    m_szName[0] = 0;
    m_szDescription[0] = 0;
    m_tLastPoll = 0;
-   m_pszFormula = strdup("");
+   m_pszFormula = _tcsdup(_T(""));
+   m_pNode = NULL;
+   m_hMutex = MutexCreate();
+   m_dwCacheSize = 0;
+   m_ppValueCache = NULL;
+}
+
+
+//
+// Create DCItem from another DCItem
+//
+
+DCItem::DCItem(const DCItem *pSrc)
+{
+   DWORD i;
+
+   m_dwId = pSrc->m_dwId;
+   m_dwTemplateId = pSrc->m_dwTemplateId;
+   m_iBusy = 0;
+   m_iDataType = pSrc->m_iDataType;
+   m_iPollingInterval = pSrc->m_iPollingInterval;
+   m_iRetentionTime = pSrc->m_iRetentionTime;
+   m_iDeltaCalculation = pSrc->m_iDeltaCalculation;
+   m_iSource = pSrc->m_iSource;
+   m_iStatus = pSrc->m_iStatus;
+   _tcscpy(m_szName, pSrc->m_szName);
+   _tcscpy(m_szDescription, pSrc->m_szDescription);
+   m_tLastPoll = 0;
+   m_pszFormula = _tcsdup(pSrc->m_pszFormula);
    m_pNode = NULL;
    m_hMutex = MutexCreate();
    m_dwCacheSize = 0;
    m_ppValueCache = NULL;
+
+   // Copy thresholds
+   m_dwNumThresholds = pSrc->m_dwNumThresholds;
+   m_ppThresholdList = (Threshold **)malloc(sizeof(Threshold *) * m_dwNumThresholds);
+   for(i = 0; i < m_dwNumThresholds; i++)
+   {
+      m_ppThresholdList[i] = new Threshold(pSrc->m_ppThresholdList[i]);
+      m_ppThresholdList[i]->CreateId();
+   }
 }
 
 
index fac6b65..18e31b4 100644 (file)
@@ -42,6 +42,28 @@ Threshold::Threshold(DCItem *pRelatedItem)
 }
 
 
+//
+// Create from another threshold object
+//
+
+Threshold::Threshold(Threshold *pSrc)
+{
+   m_dwId = pSrc->m_dwId;
+   m_dwItemId = pSrc->m_dwItemId;
+   m_dwEventCode = pSrc->m_dwEventCode;
+   m_pszValueStr = (pSrc->m_pszValueStr == NULL) ? NULL : _tcsdup(pSrc->m_pszValueStr);
+   m_iFunction = pSrc->m_iFunction;
+   m_iOperation = pSrc->m_iOperation;
+   m_iDataType = pSrc->m_iDataType;
+   m_iParam1 = pSrc->m_iParam1;
+   m_iParam2 = pSrc->m_iParam2;
+   m_bIsReached = FALSE;
+
+   if (m_pszValueStr != NULL)
+      UpdateBinaryValueFromString();
+}
+
+
 //
 // Constructor for creating object from database
 // This constructor assumes that SELECT query look as following:
@@ -62,6 +84,26 @@ Threshold::Threshold(DB_RESULT hResult, int iRow, DCItem *pRelatedItem)
    m_iParam2 = DBGetFieldLong(hResult, iRow, 6);
    m_bIsReached = FALSE;
 
+   UpdateBinaryValueFromString();
+}
+
+
+//
+// Destructor
+//
+
+Threshold::~Threshold()
+{
+   safe_free(m_pszValueStr);
+}
+
+
+//
+// Update binary value from string value
+//
+
+void Threshold::UpdateBinaryValueFromString(void)
+{
    switch(m_iDataType)
    {
       case DCI_DT_INT:
@@ -85,16 +127,6 @@ Threshold::Threshold(DB_RESULT hResult, int iRow, DCItem *pRelatedItem)
 }
 
 
-//
-// Destructor
-//
-
-Threshold::~Threshold()
-{
-   safe_free(m_pszValueStr);
-}
-
-
 //
 // Create new unique id for object
 //
index 09ca610..1862324 100644 (file)
@@ -281,6 +281,7 @@ private:
    void OpenNodeDCIList(CSCPMessage *pRequest);
    void CloseNodeDCIList(CSCPMessage *pRequest);
    void ModifyNodeDCI(CSCPMessage *pRequest);
+   void CopyDCI(CSCPMessage *pRequest);
    void GetCollectedData(CSCPMessage *pRequest);
    void OpenEPP(DWORD dwRqId);
    void CloseEPP(DWORD dwRqId);
index 04c50aa..a0e12d9 100644 (file)
@@ -108,8 +108,11 @@ private:
    int m_iParam2;             // Function's parameter #2
    BOOL m_bIsReached;
 
+   void UpdateBinaryValueFromString(void);
+
 public:
    Threshold(DCItem *pRelatedItem);
+   Threshold(Threshold *pSrc);
    Threshold(DB_RESULT hResult, int iRow, DCItem *pRelatedItem);
    ~Threshold();
 
@@ -166,6 +169,7 @@ private:
 
 public:
    DCItem();
+   DCItem(const DCItem *pItem);
    DCItem(DB_RESULT hResult, int iRow, Node *pNode);
    DCItem(DWORD dwId, char *szName, int iSource, int iDataType, 
           int iPollingInterval, int iRetentionTime, Node *pNode);
@@ -190,6 +194,7 @@ public:
    void SetLastPollTime(time_t tLastPoll) { m_tLastPoll = tLastPoll; }
    void SetStatus(int iStatus) { m_iStatus = (BYTE)iStatus; }
    void SetBusyFlag(BOOL bIsBusy) { m_iBusy = (BYTE)bIsBusy; }
+   void SetId(DWORD dwNewId) { m_dwId = dwNewId; }
 
    void NewValue(DWORD dwTimeStamp, const char *pszValue);
 
index 4d2baff..e4e2b45 100644 (file)
@@ -275,6 +275,7 @@ public:
                    DWORD **ppdwMapIndex, DWORD **ppdwMapId);
    BOOL DeleteItem(DWORD dwItemId);
    int GetItemType(DWORD dwItemId);
+   const DCItem *GetItemById(DWORD dwItemId);
    BOOL LockDCIList(DWORD dwSessionId);
    BOOL UnlockDCIList(DWORD dwSessionId);
    void SendItemsToClient(ClientSession *pSession, DWORD dwRqId);
index d44cdc3..37d83e0 100644 (file)
@@ -1103,3 +1103,26 @@ int Node::GetItemType(DWORD dwItemId)
    Unlock();
    return iType;
 }
+
+
+//
+// Get item by it's id
+//
+
+const DCItem *Node::GetItemById(DWORD dwItemId)
+{
+   DWORD i;
+   DCItem *pItem = NULL;
+
+   Lock();
+   // Check if that item exists
+   for(i = 0; i < m_dwNumItems; i++)
+      if (m_ppItems[i]->Id() == dwItemId)
+      {
+         pItem = m_ppItems[i];
+         break;
+      }
+
+   Unlock();
+   return pItem;
+}
index 836c4eb..3287fa7 100644 (file)
@@ -482,6 +482,9 @@ void ClientSession::ProcessingThread(void)
          case CMD_DELETE_NODE_DCI:
             ModifyNodeDCI(pMsg);
             break;
+         case CMD_COPY_DCI:
+            CopyDCI(pMsg);
+            break;
          case CMD_GET_DCI_DATA:
             GetCollectedData(pMsg);
             break;
@@ -1650,6 +1653,102 @@ void ClientSession::ModifyNodeDCI(CSCPMessage *pRequest)
 }
 
 
+//
+// Copy DCI from one node to another
+//
+
+void ClientSession::CopyDCI(CSCPMessage *pRequest)
+{
+   CSCPMessage msg;
+   NetObj *pSource, *pDestination;
+
+   // Prepare responce message
+   msg.SetCode(CMD_REQUEST_COMPLETED);
+   msg.SetId(pRequest->GetId());
+
+   // Get source and destination
+   pSource = FindObjectById(pRequest->GetVariableLong(VID_SOURCE_OBJECT_ID));
+   pDestination = FindObjectById(pRequest->GetVariableLong(VID_DESTINATION_OBJECT_ID));
+   if ((pSource != NULL) && (pDestination != NULL))
+   {
+      // Check object types
+      if ((pSource->Type() == OBJECT_NODE) && (pDestination->Type() == OBJECT_NODE))
+      {
+         if (((Node *)pSource)->IsLockedBySession(m_dwIndex))
+         {
+            // Check access rights
+            if ((pSource->CheckAccessRights(m_dwUserId, OBJECT_ACCESS_READ)) &&
+                (pDestination->CheckAccessRights(m_dwUserId, OBJECT_ACCESS_MODIFY)))
+            {
+               // Attempt to lock destination's DCI list
+               if (((Node *)pDestination)->LockDCIList(m_dwIndex))
+               {
+                  DWORD i, *pdwItemList, dwNumItems;
+                  const DCItem *pSrcItem;
+                  DCItem *pDstItem;
+                  int iErrors = 0;
+
+                  // Get list of items to be copied
+                  dwNumItems = pRequest->GetVariableLong(VID_NUM_ITEMS);
+                  pdwItemList = (DWORD *)malloc(sizeof(DWORD) * dwNumItems);
+                  pRequest->GetVariableInt32Array(VID_ITEM_LIST, dwNumItems, pdwItemList);
+
+                  // Copy items
+                  for(i = 0; i < dwNumItems; i++)
+                  {
+                     pSrcItem = ((Node *)pSource)->GetItemById(pdwItemList[i]);
+                     if (pSrcItem != NULL)
+                     {
+                        pDstItem = new DCItem(pSrcItem);
+                        pDstItem->SetId(CreateUniqueId(IDG_ITEM));
+                        pDstItem->SetStatus(ITEM_STATUS_ACTIVE);
+                        if (!((Node *)pDestination)->AddItem(pDstItem))
+                        {
+                           delete pDstItem;
+                           iErrors++;
+                        }
+                     }
+                     else
+                     {
+                        iErrors++;
+                     }
+                  }
+
+                  // Cleanup
+                  free(pdwItemList);
+                  ((Node *)pDestination)->UnlockDCIList(m_dwIndex);
+                  msg.SetVariable(VID_RCC, (iErrors == 0) ? RCC_SUCCESS : RCC_DCI_COPY_ERRORS);
+               }
+               else  // Destination's DCI list already locked by someone else
+               {
+                  msg.SetVariable(VID_RCC, RCC_COMPONENT_LOCKED);
+               }
+            }
+            else  // User doesn't have enough rights on object(s)
+            {
+               msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+            }
+         }
+         else  // Source node DCI list not locked by this session
+         {
+            msg.SetVariable(VID_RCC, RCC_OUT_OF_STATE_REQUEST);
+         }
+      }
+      else     // Object(s) is not a node
+      {
+         msg.SetVariable(VID_RCC, RCC_INVALID_OBJECT_ID);
+      }
+   }
+   else  // No object(s) with given ID
+   {
+      msg.SetVariable(VID_RCC, RCC_INVALID_OBJECT_ID);
+   }
+
+   // Send responce
+   SendMessage(&msg);
+}
+
+
 //
 // Get collected data
 //