#include "StdAfx.h" #include "MBPsnDocAttrWnd.h" #include "MBDocSvrCommomFtn.h" CMBPsnDocAttrWnd::CMBPsnDocAttrWnd() : SHostDialog(_T("LAYOUT:DLG_PSNDOCATTR")) { m_bLayoutInited = FALSE; m_pVerLstAdapter = NULL; m_pLvVerLst = NULL; m_pDocInfo = NULL; m_pSvrMgr = NULL; m_pHisDocMgr = new CMBHisDocMgr(); // ÀúÊ·Îĵµ¹ÜÀíÆ÷ m_pFileSvrClientMgr = new CMBFileSvrClientMgr();// Îļþ·þÎñ¹ÜÀíÆ÷ } CMBPsnDocAttrWnd::~CMBPsnDocAttrWnd() { UnRegisterNotifyCenter(); MBSAFE_DELETE(m_pHisDocMgr) MBSAFE_DELETE(m_pFileSvrClientMgr) } int CMBPsnDocAttrWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) { SetMsgHandled(FALSE); return 0; } BOOL CMBPsnDocAttrWnd::OnInitDialog(HWND hWnd, LPARAM lParam) { m_bLayoutInited = TRUE; // ×¢²á RegisterNotifyCenter(); // ³õʼ»¯Îļþ·þÎñ InitFileSvrCientMgr(); //Ðи߹̶¨µÄÁбí m_pLvVerLst = FindChildByName2("lv_verlst"); if(m_pLvVerLst) { m_pVerLstAdapter = new CMBPsnVerLstAdapter(); m_pVerLstAdapter->SetDocInfo(m_pDocInfo); m_pLvVerLst->SetAdapter(m_pVerLstAdapter); m_pVerLstAdapter->Release(); } SetTimer(WM_TIMER_INIT,20); return 0; } //TODO:ÏûÏ¢Ó³Éä void CMBPsnDocAttrWnd::OnClose() { SHostDialog::OnOK(); } void CMBPsnDocAttrWnd::OnMaximize() { SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE); } void CMBPsnDocAttrWnd::OnRestore() { SendMessage(WM_SYSCOMMAND, SC_RESTORE); } void CMBPsnDocAttrWnd::OnMinimize() { SendMessage(WM_SYSCOMMAND, SC_MINIMIZE); } void CMBPsnDocAttrWnd::OnSize(UINT nType, SOUI::CSize size) { SetMsgHandled(FALSE); if (!m_bLayoutInited) return; SWindow *pBtnMax = FindChildByName(L"btn_max"); SWindow *pBtnRestore = FindChildByName(L"btn_restore"); if(!pBtnMax || !pBtnRestore) return; if (nType == SIZE_MAXIMIZED) { pBtnRestore->SetVisible(TRUE); pBtnMax->SetVisible(FALSE); } else if (nType == SIZE_RESTORED) { pBtnRestore->SetVisible(FALSE); pBtnMax->SetVisible(TRUE); } } // Çл»tab¼ü void CMBPsnDocAttrWnd::OnPsnDocTabPageRadioSwitch(int nID) { CString strErrInfo; STabCtrl *pTab = FindChildByName2(L"tab_psndocattr"); if( NULL == pTab ) return; switch (nID){ case PAGE_DLG_PSNDOCATTR_ATTR_ID: // ÊôÐÔ { pTab->SetCurSel(_T("ÊôÐÔ")); } break; case PAGE_DLG_PSNDOCATTR_HIS_ID: // ÀúÊ· { // µÃµ½ÀúÊ· °æ±¾ if( !m_pHisDocMgr->m_bGetHistoryDocList ) { CMBHisDocInfo *pHisDocInfo = new CMBHisDocInfo(); pHisDocInfo->m_strID = m_pDocInfo->m_strID; pHisDocInfo->m_strHistoryID = m_pDocInfo->m_strFileID; pHisDocInfo->m_strFileName = m_pDocInfo->m_strFileName; pHisDocInfo->m_strVer = m_pDocInfo->m_strVer; pHisDocInfo->m_strFileTime = m_pDocInfo->m_strFileTime; if( !m_pHisDocMgr->AddHisDocInfo(pHisDocInfo) ) { delete pHisDocInfo; pHisDocInfo = NULL; } // µÃµ½ÀúÊ·°æ±¾ if(!CMBDocSvrCommomFtn::GetHistoryDocList(m_pSvrMgr,m_pDocInfo,m_pHisDocMgr,strErrInfo)) { MBMessageBox(m_hWnd,strErrInfo,_T("´íÎóÌáʾ"),MB_OK); return ; } ReVerLstAdapter(); m_pLvVerLst->SetSel(0); } pTab->SetCurSel(_T("ÀúÊ·")); } break; } } void CMBPsnDocAttrWnd::ReVerLstAdapter() { CMBBaseObjVector vectorObj; m_pHisDocMgr->GetBaseObjVector(vectorObj); m_pVerLstAdapter->SetVectorObj( vectorObj ); m_pVerLstAdapter->notifyDataSetChanged(); } // ÉèÖÃshow¶ÔÏó void CMBPsnDocAttrWnd::SetDocInfo( CMBPsnDocInfo *pDocInfo ) { m_pDocInfo = pDocInfo; } void CMBPsnDocAttrWnd::SetSvrMgr( CMBServerMgr *pSvrMgr ) { m_pSvrMgr = pSvrMgr; } // ÉèÖÃĿ¼·¾¶ void CMBPsnDocAttrWnd::SetCatalogName( CString strCatalogName ) { m_strCatalogName = strCatalogName; } // ³õʼ»¯Êý¾Ý void CMBPsnDocAttrWnd::InitData( CMBPsnDocInfo *pDocInfo ) { CStringArray arTags; CString strTmpTag,strTags; //////////////////////////////////////////// SWindow *pWndVer = FindChildByName(_T("attr_version")); // °æ±¾ if( pWndVer ) pWndVer->SetWindowText(pDocInfo->m_strVer); SWindow *pWndFileName = FindChildByName(_T("attr_filename")); // ÎļþÃû³Æ if( pWndFileName ) pWndFileName->SetWindowText(pDocInfo->m_strFileName); SWindow *pWndSize = FindChildByName(_T("attr_size")); // ´óС if( pWndSize ) pWndSize->SetWindowText(CStrFileUtils::GetFileSizeDisplayStr(pDocInfo->m_nFileSize)); SWindow *pWndUploadTime = FindChildByName(_T("attr_upload_time")); // ÉÏ´«Ê±¼ä if( pWndUploadTime ) pWndUploadTime->SetWindowText(pDocInfo->m_strDTCreate); SWindow *pWndCatalogName = FindChildByName(_T("attr_catalog_name")); // Ŀ¼ if( pWndCatalogName ) //pWndCatalogName->SetWindowText(pDocInfo->m_strCatalogName); pWndCatalogName->SetWindowText(m_strCatalogName); ///////////////////±êÇ© SStatic *pTxtTag = FindChildByName2("attr_tag"); if( NULL == pTxtTag ) return ; pDocInfo->GetTags(arTags); for( int i = 0;i < arTags.GetCount();i++ ) { CString strTag = arTags[i]; if( i == 0 ) { strTags += strTag; }else{ strTmpTag.Format(_T(" / %s"),strTag); strTags += strTmpTag; } } pTxtTag->SetWindowText(strTags); //STagView *pTagV = FindChildByName2(_T("tagv_tag"));// ±êÇ© //if( pTagV ) //{ // pDocInfo->GetTags(arTags); // for( int i = 0;i < arTags.GetCount();i++ ) // { // CString strTag = arTags[i]; // SWindow *pWnd = pTagV->InsertTag(); // pWnd->FindChildByName(_T("txt_item"))->SetWindowText(strTag); // } //} //pTagV->ReLayout(); SWindow *pWndRemark = FindChildByName(_T("attr_remark")); // ±¸×¢ if( pWndRemark ) pWndRemark->SetWindowText(pDocInfo->m_strNote); } bool CMBPsnDocAttrWnd::RegisterNotifyCenter() { SNotifyCenter::getSingleton().addEvent(EVENTID(EventPsnHistoryDocEnable)); SNotifyCenter::getSingleton().addEvent(EVENTID(EventPsnHistoryDocDld)); SNotifyCenter::getSingleton().addEvent(EVENTID(EventPsnHistoryDocDel)); return true; } bool CMBPsnDocAttrWnd::UnRegisterNotifyCenter() { SNotifyCenter::getSingleton().removeEvent(EventPsnHistoryDocEnable::EventID); SNotifyCenter::getSingleton().removeEvent(EventPsnHistoryDocDld::EventID); SNotifyCenter::getSingleton().removeEvent(EventPsnHistoryDocDel::EventID); return true; } void CMBPsnDocAttrWnd::InitFileSvrCientMgr() { CString strErrInfo; CString strLogin,strName; CMBFileSvrMgr *pFileSvrMgr = m_pSvrMgr->GetFileSvrMgr(); strLogin = m_pSvrMgr->GetUserLogin()->m_strLoginName; strName = m_pSvrMgr->GetUserLogin()->m_strUserName; if( !m_pFileSvrClientMgr->InitFileSvrCientMgr( m_hWnd,pFileSvrMgr,strLogin,strName,strErrInfo,false) ) return ; } bool CMBPsnDocAttrWnd::OnEventPsnHistoryDocEnable(EventArgs *e) { EventPsnHistoryDocEnable *pTmpEnable = (EventPsnHistoryDocEnable*)e; if( NULL == pTmpEnable->m_pBaseObj ) return false; int nIndex = pTmpEnable->m_nIndex; CString strID,strHisID,strErrInfo,strFileName,strVer,strFileTime; CMBBaseObj *pBaseObj = pTmpEnable->m_pBaseObj; if( pBaseObj->IsKindOf( RUNTIME_CLASS(CMBHisDocInfo))) { CMBHisDocInfo *pHisDocInfo = (CMBHisDocInfo *)pBaseObj; strID = pHisDocInfo->m_strID; strHisID = pHisDocInfo->m_strHistoryID; strFileName = pHisDocInfo->m_strFileName; strVer = pHisDocInfo->m_strVer; strFileTime = pHisDocInfo->m_strFileTime; } // Õâ¸ö½Ó¿Ú£¬¿ÉÄÜÓÐÎÊÌâ if(!m_pSvrMgr->GetNetDiskWebCMgr()->NDSetHistoryDocActive(strHisID,strErrInfo)) { MBMessageBox(m_hWnd,strErrInfo,_T("´íÎóÌáʾ"),MB_OK); return false; } m_pDocInfo->m_bGetDocInfo = false; m_pDocInfo->m_strFileName = strFileName; m_pDocInfo->m_strVer = strVer; m_pDocInfo->m_strFileTime = strFileTime; m_pLvVerLst->SetSel(nIndex,true); return true; } bool CMBPsnDocAttrWnd::OnEventPsnHistoryDocDld(EventArgs *e) { EventPsnHistoryDocDld *pTmpEnable = (EventPsnHistoryDocDld*)e; if( NULL == pTmpEnable->m_pBaseObj ) return false; CString strFileID,strFileName, strFileServer,strPath,strErrInfo; CMBBaseObj *pBaseObj = pTmpEnable->m_pBaseObj; if( pBaseObj->IsKindOf( RUNTIME_CLASS(CMBHisDocInfo))) { CMBHisDocInfo *pHisDocInfo = (CMBHisDocInfo *)pBaseObj; if(!CMBDocSvrCommomFtn::GetNDDocInfo(m_pSvrMgr,pHisDocInfo,strErrInfo )) { MBMessageBox(m_hWnd,strErrInfo,_T("´íÎóÌáʾ"),MB_OK); return false; } strFileID = pHisDocInfo->m_strFileID; strFileName = pHisDocInfo->m_strFileName; strFileServer = pHisDocInfo->m_strFileServer; } /////////////// CMBDownloadPathWnd dlgDownloadPathWnd; dlgDownloadPathWnd.SetDownloadPath( m_pSvrMgr->GetUserLogin()->m_strDownloadPath ); if( IDOK != dlgDownloadPathWnd.DoModal()) return false; strPath = dlgDownloadPathWnd.m_strSelPath; REQLOADSERVER_ITEM reqLoadServerItem; reqLoadServerItem.hWnd = m_hWnd; //reqLoadServerItem.strItemType = ; //reqLoadServerItem.pItem = ; CMBFileClientMgr *pClientMgr = m_pFileSvrClientMgr->GetFileClientMgr(strFileServer,strErrInfo); if( NULL != pClientMgr ) { pClientMgr->DownloadFile_Asyn(reqLoadServerItem,strFileID,_T(""),strPath + _T("\\") + strFileName); } return true; } bool CMBPsnDocAttrWnd::OnEventPsnHistoryDocDel(EventArgs *e) { CString strErrInfo; EventPsnHistoryDocDel *pTmpEnable = (EventPsnHistoryDocDel*)e; if( NULL == pTmpEnable->m_pBaseObj ) return false; CMBBaseObj *pBaseObj = pTmpEnable->m_pBaseObj; if( !pBaseObj->IsKindOf( RUNTIME_CLASS(CMBHisDocInfo))) return false; ///////////Ìáʾ/////////////////////////////// CMBTipCancelWnd dlg; dlg.SetTipInfo(_T("È·¶¨ÒªÉ¾³ýÕâÌõ¼Ç¼Âð£¿")); if(IDCANCEL == dlg.DoModal()) return false; ///////////end Ìáʾ////////////////////////// CMBHisDocInfo *pHisDocInfo = (CMBHisDocInfo *)pBaseObj; if(!m_pSvrMgr->GetNetDiskWebCMgr()->NDDeleteHistoryDoc(pHisDocInfo->m_strHistoryID, strErrInfo )) { MBMessageBox(m_hWnd,strErrInfo,_T("´íÎóÌáʾ"),MB_OK); return false; } // Çå³ý m_pHisDocMgr->RemoveHisDocObj(pHisDocInfo); ReVerLstAdapter(); return true; } void CMBPsnDocAttrWnd::OnTimer(UINT_PTR nIDEvent) { switch (nIDEvent) { case WM_TIMER_INIT: { KillTimer(WM_TIMER_INIT); CString strErrInfo; // µÃµ½ÎĵµÐÅÏ¢ if( !CMBDocSvrCommomFtn::GetDocInfo(m_pSvrMgr,m_pDocInfo,strErrInfo ) ) // µÃµ½ÎĵµÐÅÏ¢ { MBMessageBox(m_hWnd,strErrInfo,_T("´íÎóÌáʾ"),MB_OK); return ; } // ³õʼ»¯Êý¾Ý InitData( m_pDocInfo ); }break; default: SetMsgHandled(FALSE); break; } }