Esempio n. 1
0
void CViewMessages::OnMessagesEditFilter(wxCommandEvent& /* event */) {
    DlgMsgFilter dlg(this);
    dlg.SetFilterData(m_msgFilterData);
    if (dlg.ShowModal() == wxID_OK) {
        m_msgFilterData = dlg.GetFilterData();
        m_maxFilteredIndex = 0;
        m_filteredIndexes.clear();
        
        // Refresh the list if filtering is currently enabled:
        if (m_enableMsgFilter) {
            long docCount = GetDocCount();
            m_pListPane->SetItemCount(docCount);
            m_pListPane->RefreshItems(0, docCount - 1);
        }
    }
}
Esempio n. 2
0
void CViewMessages::OnMessagesEnableFilter(wxCommandEvent& /* event */) {
    m_enableMsgFilter = !m_enableMsgFilter;
    if (m_enableMsgFilter) {
        m_pTaskPane->UpdateTask(m_TaskGroups[0]->m_Tasks[BTN_ENABLEFILTER],
                                _("Disable message filter"),
                                _("Disable message filtering."));
    } else {
        m_pTaskPane->UpdateTask(m_TaskGroups[0]->m_Tasks[BTN_ENABLEFILTER],
                                _("Enable message filter"),
                                _("Enable message filtering based on the current filter settings."));
    }

    // Refresh the list:
    long docCount = GetDocCount();
    m_pListPane->SetItemCount(docCount);
    m_pListPane->RefreshItems(0, docCount - 1);
}
Esempio n. 3
0
int CBOINCBaseView::SynchronizeCache() {
    int         iRowIndex        = 0;
    int         iRowTotal        = 0;
    int         iColumnIndex     = 0;
    int         iColumnTotal     = 0;
    bool        bNeedRefreshData = false;

    iRowTotal = GetDocCount();
    iColumnTotal = m_pListPane->GetColumnCount();

    for (iRowIndex = 0; iRowIndex < iRowTotal; iRowIndex++) {
        bNeedRefreshData = false;

        for (iColumnIndex = 0; iColumnIndex < iColumnTotal; iColumnIndex++) {
            if (SynchronizeCacheItem(iRowIndex, iColumnIndex)) {
#ifdef __WXMAC__
                bNeedRefreshData = true;
#else
                // To reduce flicker, refresh only changed columns
                m_pListPane->RefreshCell(iRowIndex, iColumnIndex);
#endif
                if (iColumnIndex >= 0) {
                    if (m_iColumnIndexToColumnID[iColumnIndex] == m_iSortColumnID) {
                        m_bNeedSort = true;
                    }
                }
            }
        }

        // Mac is double-buffered to avoid flicker, so this is more efficient
        if (bNeedRefreshData) {
            m_pListPane->RefreshItem(iRowIndex);
        }
    }

    if (m_bNeedSort) {
        sortData();     // Will mark moved items as needing refresh
        m_bNeedSort = false;
    }
    
    return 0;
}
Esempio n. 4
0
void CViewMessages::OnListRender (wxTimerEvent& event) {
    bool isConnected;
    static bool was_connected = false;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        isConnected = pDoc->IsConnected();
        wxInt32 iDocCount = GetDocCount();
        if (0 >= iDocCount) {
            m_pListPane->DeleteAllItems();
        } else {
            // If connection status changed, adjust color of messages display
            if (was_connected != isConnected) {
                was_connected = isConnected;
                if (isConnected) {
                    m_pMessageInfoAttr->SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
                    m_pMessageErrorAttr->SetTextColour(*wxRED);
                } else {
                    m_pMessageInfoAttr->SetTextColour(CBOINCListCtrl::GetBlendedColour(
                                wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),
                                wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.5));
                    m_pMessageErrorAttr->SetTextColour(CBOINCListCtrl::GetBlendedColour(*wxRED,
                                wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.5));
                }
                m_pMessageInfoAttr->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
                m_pMessageErrorAttr->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
                // Force a complete update
                m_pListPane->DeleteAllItems();
                m_pListPane->SetItemCount(iDocCount);
           }
            
            if (m_iPreviousDocCount != iDocCount)
                m_pListPane->SetItemCount(iDocCount);
        }

        if ((iDocCount > 1) && (_EnsureLastItemVisible()) && (m_iPreviousDocCount != iDocCount)) {
            m_pListPane->EnsureVisible(iDocCount - 1);
        }

        if (isConnected) {
            pDoc->GetConnectedComputerName(strNewMachineName);
            if (strLastMachineName != strNewMachineName) {
                strLastMachineName = strNewMachineName;
                if (iDocCount > 1) {
                    m_pListPane->EnsureVisible(iDocCount - 1);
                }
            }
        }

        if (m_iPreviousDocCount != iDocCount) {
            m_iPreviousDocCount = iDocCount;
        }

        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
void CBOINCBaseView::OnListRender(wxTimerEvent& event) {
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        // Remember the key values of currently selected items
        SaveSelections();
    
        int iDocCount = GetDocCount();
        int iCacheCount = GetCacheCount();
        if (iDocCount != iCacheCount) {
            if (0 >= iDocCount) {
                EmptyCache();
                m_pListPane->DeleteAllItems();
            } else {
                int iIndex = 0;
                int iReturnValue = -1;
                if (iDocCount > iCacheCount) {
                    for (iIndex = 0; iIndex < (iDocCount - iCacheCount); iIndex++) {
                        iReturnValue = AddCacheElement();
                        wxASSERT(!iReturnValue);
                    }
                    wxASSERT(GetDocCount() == GetCacheCount());
                    m_pListPane->SetItemCount(iDocCount);
                    m_bNeedSort = true;
               } else {
                    // The virtual ListCtrl keeps a separate its list of selected rows; 
                    // make sure it does not reference any rows beyond the new last row.
                    // We can ClearSelections() because we called SaveSelections() above.
                    ClearSelections();
                    m_pListPane->SetItemCount(iDocCount);
                    for (iIndex = (iCacheCount - 1); iIndex >= iDocCount; --iIndex) {
                        iReturnValue = RemoveCacheElement();
                        wxASSERT(!iReturnValue);
                    }
                    wxASSERT(GetDocCount() == GetCacheCount());
                    m_pListPane->RefreshItems(0, iDocCount - 1);
                    m_bNeedSort = true;
                }
            }
        }

        if (iDocCount > 0) {
            SynchronizeCache();
            if (iDocCount > 1) {
                if (_EnsureLastItemVisible() && (iDocCount != iCacheCount)) {
                    m_pListPane->EnsureVisible(iDocCount - 1);
                }
            }

            if (m_pListPane->m_bIsSingleSelection) {
                // If no item has been selected yet, select the first item.
#ifdef __WXMSW__
                if ((m_pListPane->GetSelectedItemCount() == 0) &&
                    (m_pListPane->GetItemCount() >= 1)) {

                    long desiredstate = wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED;
                    m_pListPane->SetItemState(0, desiredstate, desiredstate);
                }
#else
                if ((m_pListPane->GetFirstSelected() < 0) &&
                    (m_pListPane->GetItemCount() >= 1)) {
                    m_pListPane->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, 
                                                    wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
                }
#endif
            }
        }
        
        // Find the previously selected items by their key values and reselect them
        RestoreSelections();

        UpdateSelection();
        
        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
Esempio n. 6
0
void CViewMessages::OnListRender (wxTimerEvent& event) {
    bool isConnected;
    static bool was_connected = false;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        isConnected = pDoc->IsConnected();
        wxInt32 iRowCount = GetDocCount();
        if (0 >= iRowCount) {
            m_pListPane->DeleteAllItems();
        } else {
            // If connection status changed, adjust color of messages display
            if (was_connected != isConnected) {
                was_connected = isConnected;
                if (isConnected) {
                    m_pMessageInfoAttr->SetTextColour(*wxBLACK);
                    m_pMessageErrorAttr->SetTextColour(*wxRED);
                    m_pMessageInfoGrayAttr->SetTextColour(*wxBLACK);
                    m_pMessageErrorGrayAttr->SetTextColour(*wxRED);
                } else {
                    wxColourDatabase colorBase;
                    m_pMessageInfoAttr->SetTextColour(wxColour(128, 128, 128));
                    m_pMessageErrorAttr->SetTextColour(wxColour(255, 128, 128));
                    m_pMessageInfoGrayAttr->SetTextColour(wxColour(128, 128, 128));
                    m_pMessageErrorGrayAttr->SetTextColour(wxColour(255, 128, 128));
                }
                // Force a complete update
                m_pListPane->DeleteAllItems();
                m_pListPane->SetItemCount(iRowCount);
                m_iPreviousRowCount = 0;    // Force scrolling to bottom
            } else {
                // Connection status didn't change
                if (m_iPreviousRowCount != iRowCount) {
                    m_pListPane->SetItemCount(iRowCount);
                }
            }
        }

        if ((iRowCount>1) && (_EnsureLastItemVisible()) && (m_iPreviousRowCount != iRowCount)) {
            m_pListPane->EnsureVisible(iRowCount - 1);
        }

        if (isConnected) {
            pDoc->GetConnectedComputerName(strNewMachineName);
            if (strLastMachineName != strNewMachineName) {
                strLastMachineName = strNewMachineName;
                     if (iRowCount) {
                        m_pListPane->EnsureVisible(iRowCount - 1);
                    }
            }
        }

        if (m_iPreviousRowCount != iRowCount) {
            m_iPreviousRowCount = iRowCount;
        }

        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
Esempio n. 7
0
/*!
 * called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event
 */
void CDlgEventLog::OnRefresh() {
    bool isConnected;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!IsShown()) return;

    if (!m_bProcessingRefreshEvent) {
        m_bProcessingRefreshEvent = true;
        wxASSERT(m_pList);

        wxInt32 iRowCount = GetDocCount();
        long topItem = m_pList->GetTopItem();
        
        if (0 >= iRowCount) {
            m_pList->DeleteAllItems();
            ResetMessageFiltering();
            m_iPreviousFirstMsgSeqNum = 0;
            m_iPreviousLastMsgSeqNum = 0;
        } else {
            // If connected computer changed, reset message filtering
            isConnected = wxGetApp().GetDocument()->IsConnected();
            if (isConnected) {
                pDoc->GetConnectedComputerName(strNewMachineName);
                if (strLastMachineName != strNewMachineName) {
                    strLastMachineName = strNewMachineName;
                    m_bWasConnected = false;
                    ResetMessageFiltering();
                    m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
                    m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1;
                    iRowCount = m_iTotalDocCount;   // In case we had filtering set
                }
            }

            // If connection status changed, adjust color of messages display
            if (m_bWasConnected != isConnected) {
                m_bWasConnected = isConnected;
                SetTextColor();

                // Force a complete update
                m_pList->DeleteAllItems();
                m_pList->SetItemCount(iRowCount);
                m_iPreviousRowCount = 0;    // Force scrolling to bottom

            } else {
                // Connection status didn't change
                if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) {
                    if (m_iPreviousRowCount == iRowCount) {
                        m_pList->Refresh();
                    } else {
                        m_pList->SetItemCount(iRowCount);
                    }
                }
            }
        }

        if (iRowCount > 1) {
            if (s_bFilteringChanged) {
                m_pList->EnsureVisible(iRowCount - 1);
                s_bFilteringChanged = false;
            } else {
                if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) {
                    if (EnsureLastItemVisible()) {
                        m_pList->EnsureVisible(iRowCount - 1);
                    } else if (topItem > 0) {
                        int n = topItem - m_iNumDeletedFilteredRows;
                        if (n < 0) n = 0;
                        Freeze();   // Avoid flicker if selected rows are visible
                        m_pList->EnsureVisible(n);
                        Thaw();
                    }
                }
            }
        }

        m_iPreviousRowCount = iRowCount;
        if (m_iTotalDocCount > 0) {
            m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum();
            m_iPreviousLastMsgSeqNum = pDoc->GetLastMsgSeqNum();
        }
        
        UpdateButtons();

        m_bProcessingRefreshEvent = false;
    }
}
void CViewTransfersGrid::OnListRender( wxTimerEvent& WXUNUSED(event) ) {
    wxInt32 docCount = GetDocCount();

    // We haven't connected up to the CC yet, there is nothing to display, make sure
    //   everything is deleted.
    if ( docCount <= 0 ) {
        if ( m_pGridPane->GetNumberRows() ) {
            m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows());
        }
        return;
    }
    
    // Right-size the grid so that the number of rows matches
    //   the document state.
    if(docCount != m_pGridPane->GetNumberRows()) {
        if (docCount > m_pGridPane->GetNumberRows()) {
    	    m_pGridPane->AppendRows(docCount - m_pGridPane->GetNumberRows());
        } else {
            m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount);
    	    m_bForceUpdateSelection = true;
        }
        wxASSERT(docCount == m_pGridPane->GetNumberRows());
    }

    m_bIgnoreUIEvents = true;
    m_pGridPane->SaveSelection();
    m_bIgnoreUIEvents = false;

	//update cell values
	wxString strBuffer;
    int iMax = m_pGridPane->GetNumberRows();
    for(int iRow = 0; iRow < iMax; iRow++) {

        FormatProjectName(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_PROJECT) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_PROJECT, strBuffer);
        }

		FormatFileName(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_FILE) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_FILE, strBuffer);
        }

        FormatProgress(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_PROGRESS) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_PROGRESS, strBuffer);
		    m_pGridPane->SetCellAlignment(iRow, COLUMN_PROGRESS, wxALIGN_CENTRE, wxALIGN_CENTRE);
        }

        FormatSize(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_SIZE) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_SIZE, strBuffer);
        }

        FormatTime(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_TIME) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_TIME, strBuffer);
        }
		
        FormatSpeed(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_SPEED) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_SPEED, strBuffer);
        }

        strBuffer = wxEmptyString;
        FormatStatus(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_STATUS) != strBuffer) {
    		m_pGridPane->SetCellValue(iRow, COLUMN_STATUS, strBuffer);
        }

        FormatProjectURL(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_HIDDEN_URL) != strBuffer) {
    		m_pGridPane->SetCellValue(iRow, COLUMN_HIDDEN_URL, strBuffer);
        }
    }

    m_pGridPane->SortData();

    m_bIgnoreUIEvents = true;
    m_pGridPane->RestoreSelection();
    m_bIgnoreUIEvents = false;

    UpdateSelection();
}
Esempio n. 9
0
void CBOINCBaseView::OnListRender(wxTimerEvent& event) {
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        // Remember the key values of currently selected items
        SaveSelections();
    
        int iDocCount = GetDocCount();
        int iCacheCount = GetCacheCount();
        if (iDocCount != iCacheCount) {
            if (0 >= iDocCount) {
                EmptyCache();
                m_pListPane->DeleteAllItems();
            } else {
                int iIndex = 0;
                int iReturnValue = -1;
                if (iDocCount > iCacheCount) {
                    for (iIndex = 0; iIndex < (iDocCount - iCacheCount); iIndex++) {
                        iReturnValue = AddCacheElement();
                        wxASSERT(!iReturnValue);
                    }
                    wxASSERT(GetDocCount() == GetCacheCount());
                    m_pListPane->SetItemCount(iDocCount);
                    m_bNeedSort = true;
               } else {
                    // The virtual ListCtrl keeps a separate its list of selected rows; 
                    // make sure it does not reference any rows beyond the new last row.
                    // We can ClearSelections() because we called SaveSelections() above.
                    ClearSelections();
                    m_pListPane->SetItemCount(iDocCount);
                    for (iIndex = (iCacheCount - 1); iIndex >= iDocCount; --iIndex) {
                        iReturnValue = RemoveCacheElement();
                        wxASSERT(!iReturnValue);
                    }
                    wxASSERT(GetDocCount() == GetCacheCount());
//fprintf(stderr, "CBOINCBaseView::OnListRender(): m_pListPane->RefreshItems(0, %d)\n", iDocCount - 1);
                    m_pListPane->RefreshItems(0, iDocCount - 1);
#ifdef __WXGTK__
                    // Work around an apparent bug in wxWidgets 3.0
                    // which drew blank lines at the top and failed
                    // to draw the bottom items.  This could happen
                    // if the list was scrolled near the bottom and
                    // the user selected "Show active tasks."
                    m_pListPane->EnsureVisible(iDocCount - 1);
#endif
                    m_bNeedSort = true;
                }
            }
        }

        if (iDocCount > 0) {
            SynchronizeCache();
            if (iDocCount > 1) {
                if (_EnsureLastItemVisible() && (iDocCount != iCacheCount)) {
                    m_pListPane->EnsureVisible(iDocCount - 1);
                }
            }
        }
        
        // Find the previously selected items by their key values and reselect them
        RestoreSelections();

        UpdateSelection();

        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
void CViewMessagesGrid::OnListRender (wxTimerEvent& WXUNUSED(event)) {
    wxInt32 docCount = GetDocCount();
    wxASSERT(m_pGridPane);

    // We haven't connected up to the CC yet, there is nothing to display, make sure
    //   everything is deleted.
    if ( docCount <= 0 ) {
        if ( m_pGridPane->GetNumberRows() ) {
            m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows());
        }
        return;
    }

    // Right-size the grid so that the number of rows matches
    //   the document state.
    if(docCount != m_pGridPane->GetNumberRows()) {
        if (docCount > m_pGridPane->GetNumberRows()) {
    	    m_pGridPane->AppendRows(docCount - m_pGridPane->GetNumberRows());
        } else {
		    m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount);
        }
        wxASSERT(docCount == m_pGridPane->GetNumberRows());
    }

    m_bIgnoreUIEvents = true;
    m_pGridPane->SaveSelection();
    m_bIgnoreUIEvents = false;

	//update cell values (unsorted, like delivered from core client)
	wxString strBuffer;
    int iMax = m_pGridPane->GetNumberRows();
	for(int iRow = 0; iRow < iMax; iRow++) {

        FormatProjectName(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_PROJECT) != strBuffer) {
		    m_pGridPane->SetCellValue(iRow, COLUMN_PROJECT, strBuffer);
        }

		FormatSeqNo(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_SEQNO) != strBuffer) {
    		m_pGridPane->SetCellValue(iRow, COLUMN_SEQNO, strBuffer);
        }

		FormatPriority(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_PRIO) != strBuffer) {
    		m_pGridPane->SetCellValue(iRow, COLUMN_PRIO, strBuffer);
        }

		FormatTime(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_TIME) != strBuffer) {
    		m_pGridPane->SetCellValue(iRow, COLUMN_TIME, strBuffer);
        }

		FormatMessage(iRow, strBuffer);
        if (m_pGridPane->GetCellValue(iRow, COLUMN_MESSAGE) != strBuffer) {
    		m_pGridPane->SetCellValue(iRow, COLUMN_MESSAGE, strBuffer);
        }
    }

    //sorting
	m_pGridPane->SortData();

    m_bIgnoreUIEvents = true;
    m_pGridPane->RestoreSelection();
    m_bIgnoreUIEvents = false;

    UpdateSelection();
}
//*=================================================================================
//*原型: void TSmartServer::Run()
//*功能: 服务器执行服务
//*参数: 无
//*返回: 无
//*说明: 前置采集服务器类
//*=================================================================================
void TSmartServer::Run()
{
	bool bReloadFlag = false;
	try
	{
		m_OutThread.Start();
		m_SmartMonitor.Start();

		//如果没有获取到系统的设备档案数据,则始终向金仕达发获取档案的任务.
		while(1 )
		{
			if( GetDocCount() <= 0 )
			{
				ReportLog("没有设备档案信息! 服务器自动重新装入设备档案表!");
				InitSmartDocList();
				Sleep(4000);				
			}
			else
			{
				break;
			}
		}

		bool  bRet=false;
		long  nNoTaskTick=0,nTick=0,nCollDataTick=0;
		
		m_CollDataTaskObj.nTaskPlanID  = 100 ;
		strcpy(m_CollDataTaskObj.szTaskName, "收数");
		m_CollDataTaskObj.nTaskCycle   = 1 ;
		GetCurDateTime(m_CollDataTaskObj.szBeginTime);
		m_CollDataTaskObj.nRepeatTime  = 0 ;                 //持续多长时间(分钟)
		m_CollDataTaskObj.nRepeatTimes = 0;                //重复次数

		int  k = 0;
		long i = 0 ;
		for(i=0; i< m_DocList.GetCount(); i++)
		{
			TSmartDocObj *pObj = (TSmartDocObj*)m_DocList[i];
			if(!pObj->m_nParentID)
			{
				m_CollDataTaskObj.pTask[k].nTaskID     = i + 100 ;
				m_CollDataTaskObj.pTask[k].nTaskPlanID = 01;
				m_CollDataTaskObj.pTask[k].nAuthID     = pObj->m_nAuthID ;
				strcpy(m_CollDataTaskObj.pTask[k].szTaskCode, "01");
				strcpy(m_CollDataTaskObj.pTask[k].szName, "实时收数");
				strcpy(m_CollDataTaskObj.pTask[k].szType, "01");
				m_CollDataTaskObj.pTask[k].nPriority = 0 ;
				m_CollDataTaskObj.nTask++;  //设备总数量
				k++;
			}
		}
		m_CollDataTaskObj.SetBeginTime();
		ExecuteTask(&m_CollDataTaskObj);
		//执行任务
		static TSmartTaskObj curObj;
		BOOL bNoTask=FALSE;
		int ret=-1;
		nCollDataTick = GetTickCount();
		while( !IsShutdown() )
		{	
				bRet = false;
				//如果后台没有任务要处理,则开始采集数据任务
				while(bNoTask)
				{
					ExecuteCollDataTask();
					nTick = GetTickCount();
					nCollDataTick = nTick;
					//如果采集数据时间超过了2秒钟,则跳出,开始向后台请求新的任务
					if(nTick-nNoTaskTick>=m_nNoTask_Tick)//2秒
					{
						break;
					}
					Sleep(1000);
				}
				nTick=GetTickCount();
				//如果距离上次采集数据的时间已经超过了5秒钟,则再发起一次采集数据的任务
				if(nTick-nCollDataTick>=m_nCollData_Tick)
				{
					nCollDataTick = nTick;
					ExecuteCollDataTask();
				}
				//发送心跳请求包
				ret=m_Channels.SendTick();
				if(ret!=RET_OK)
				{
					continue;
				}
				ZeroMemory(&curObj, sizeof(curObj));
				curObj.Clear();
				ret=m_Channels.GetSmartTaskPlan(&curObj);
				switch(ret)
				{	
					case RET_OK:
						ReportLog("选中任务: %s(%d), 执行次数:%d, 执行时长:%d, 设备数:%d.\n",curObj.szTaskName, curObj.nTaskPlanID,curObj.nRepeatTimes, curObj.nRepeatTime, curObj.nTask); 
						curObj.SetBeginTime();
						bRet = ExecuteTask(&curObj);
						if(!bRet)
						{
							for(int j=0; j< curObj.nTask; j++)
							{
								TSResultData  data;
								ZeroMemory(&data, sizeof(data));
								strcpy(data.sMsg, "任务执行失败[可能终端正忙]!");
								m_Channels.ReportTaskResult(&curObj.pTask[j], RET_TERME_NOANSWER, &data);
							}
						}
						bNoTask=FALSE;
						break;
					case RET_NOTASK:
						ReportLog("金仕达没有任务下达"); 
						nNoTaskTick = GetTickCount();
						bNoTask=TRUE;
						break;
					default:
						ReportLog("向金仕达请求任务失败"); 
						bNoTask=FALSE;
						break;
				}
			/*
			if(!GetMemoryInfo())
			{
				ReportError("获取系统内存信息失败,请关闭前置程序,重新启动!");				
			}
			printf("TotalMemory %dK,UseMemory %dK,FreeMemory %dK\n",nTotalMemory,nUseMemory,nFreeMemory);	
			if(nFreeMemory/1024<10)
			{
				ReportError("可用内存小于10M,请关闭一些其它无用的程序");				
			}
			*/
		}
		m_OutThread.Shutdown();
	}
	catch(TException& e)
	{
		ReportError(e.GetText());
		printf("------ e error ----\n");
		Shutdown();
	}
	catch(...)
	{
		ReportError("未知的错误导致服务器终止!");
		Shutdown();
	}

	PostQuitMessage(0);
}
Esempio n. 12
0
void CBOINCBaseView::OnListRender(wxTimerEvent& event) {
    if (!m_bProcessingListRenderEvent) {
        m_bProcessingListRenderEvent = true;

        wxASSERT(m_pListPane);

        // Remember the key values of currently selected items
        SaveSelections();
    
        int iDocCount = GetDocCount();
        int iCacheCount = GetCacheCount();
        if (iDocCount != iCacheCount) {
            if (0 >= iDocCount) {
                EmptyCache();
                m_pListPane->DeleteAllItems();
            } else {
                int iIndex = 0;
                int iReturnValue = -1;
                if (iDocCount > iCacheCount) {
                    for (iIndex = 0; iIndex < (iDocCount - iCacheCount); iIndex++) {
                        iReturnValue = AddCacheElement();
                        wxASSERT(!iReturnValue);
                    }
                    wxASSERT(GetDocCount() == GetCacheCount());
                    m_pListPane->SetItemCount(iDocCount);
                    m_bNeedSort = true;
               } else {
                    // The virtual ListCtrl keeps a separate its list of selected rows; 
                    // make sure it does not reference any rows beyond the new last row.
                    // We can ClearSelections() because we called SaveSelections() above.
                    ClearSelections();
                    m_pListPane->SetItemCount(iDocCount);
                    for (iIndex = (iCacheCount - 1); iIndex >= iDocCount; --iIndex) {
                        iReturnValue = RemoveCacheElement();
                        wxASSERT(!iReturnValue);
                    }
                    wxASSERT(GetDocCount() == GetCacheCount());
//fprintf(stderr, "CBOINCBaseView::OnListRender(): m_pListPane->RefreshItems(0, %d)\n", iDocCount - 1);
                    m_pListPane->RefreshItems(0, iDocCount - 1);
                    m_bNeedSort = true;
                }
            }
        }

        if (iDocCount > 0) {
            SynchronizeCache();
            if (iDocCount > 1) {
                if (_EnsureLastItemVisible() && (iDocCount != iCacheCount)) {
                    m_pListPane->EnsureVisible(iDocCount - 1);
                }
            }
        }
        
        // Find the previously selected items by their key values and reselect them
        RestoreSelections();

        UpdateSelection();
        
        m_bProcessingListRenderEvent = false;
    }

    event.Skip();
}
/*!
 * called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event
 */
void CDlgEventLog::OnRefresh() {
    bool isConnected;
    static bool was_connected = false;
    static wxString strLastMachineName = wxEmptyString;
    wxString strNewMachineName = wxEmptyString;
    CMainDocument* pDoc     = wxGetApp().GetDocument();
    wxASSERT(pDoc);
    wxASSERT(wxDynamicCast(pDoc, CMainDocument));
    
    if (!IsShown()) return;

    if (!m_bProcessingRefreshEvent) {
        m_bProcessingRefreshEvent = true;

        wxASSERT(m_pList);

        wxInt32 iRowCount = GetDocCount();
        if (0 >= iRowCount) {
            m_pList->DeleteAllItems();
            ResetMessageFiltering();
        } else {
            // If connected computer changed, reset message filtering
            isConnected = wxGetApp().GetDocument()->IsConnected();
            if (isConnected) {
                pDoc->GetConnectedComputerName(strNewMachineName);
                if (strLastMachineName != strNewMachineName) {
                    strLastMachineName = strNewMachineName;
                    was_connected = false;
                    ResetMessageFiltering();
                }
            }

            // If connection status changed, adjust color of messages display
            if (was_connected != isConnected) {
                was_connected = isConnected;
                SetTextColor();

                // Force a complete update
                m_pList->DeleteAllItems();
                m_pList->SetItemCount(iRowCount);
                m_iPreviousRowCount = 0;    // Force scrolling to bottom

            } else {
                // Connection status didn't change
                if (m_iPreviousRowCount != iRowCount) {
                    m_pList->SetItemCount(iRowCount);
                }
            }
        }

        if ((iRowCount > 1) && (EnsureLastItemVisible()) && (m_iPreviousRowCount != iRowCount)) {
            m_pList->EnsureVisible(iRowCount - 1);
        }

        if (m_iPreviousRowCount != iRowCount) {
            m_iPreviousRowCount = iRowCount;
        }

        UpdateButtons();

        m_bProcessingRefreshEvent = false;
    }
}
Esempio n. 14
0
//----------------------------------------------------------------------------
// OnUpdateZoomAll enables Menu-Zoom-ZoomAllAsActive command
//----------------------------------------------------------------------------
void CippsDemoApp::OnUpdateZoomAll(CCmdUI* pCmdUI) 
{
   pCmdUI->Enable(((CWnd*)ACTIVE_FRAME == (CWnd*)ACTIVE_DOC->GetDemoFrame()) &&
                  GetDocCount() > 1);
}