📄 oldapp_sync728view.cpp
字号:
if (GetDiskFreeSpaceEx(TEXT("\\USERDATA"),&callerBytes,&totalBytes,&freeBytes))
{
if(freeBytes.QuadPart>1000*1024)
{
CString strSD;
int len = m_strFile.Find(TEXT("\\"), 1);
if (len >= 0)
{
strSD = m_strFile.Left(len);
if (GetDiskFreeSpaceEx((LPCTSTR)strSD,&callerBytes,&totalBytes,&freeBytes))
{
if(freeBytes.QuadPart>500*1024)
{
bEnoughSpace = TRUE;
m_pDataManager->Backup(vctItems, (LPTSTR)(LPCTSTR)m_strFile);
}
else
{
bIsUserData = FALSE;
}
}
}
}
}
}
else if (m_pTabItem->GetCurSel() == VIEW_858)
{
bEnoughSpace = TRUE;
m_pDataManager->Recover(vctItems, (LPTSTR)(LPCTSTR)m_strFile);
}
if (!bEnoughSpace)
{
pBnt1->EnableWindow(TRUE);
pBnt2->EnableWindow(TRUE);
m_pTabItem->EnableWindow(TRUE);
m_listItem.EnableWindow(TRUE);
GetParent()->EnableWindow(TRUE);
bIsUserData?(::MessageBox(NULL, TEXT("UserData空间不够操作失败"), TEXT("信息"), MB_OK)):(::MessageBox(NULL, TEXT("空间不够操作失败"), TEXT("信息"), MB_OK));
}
}
else
{
pBnt1->EnableWindow(TRUE);
pBnt2->EnableWindow(TRUE);
m_pTabItem->EnableWindow(TRUE);
m_listItem.EnableWindow(TRUE);
GetParent()->EnableWindow(TRUE);
::MessageBox(NULL, TEXT("请选择您要操作的数据项"), TEXT("信息"), MB_OK);
}
}
BOOL CApp_Sync728View::GetCheckedItems(vector<Item_t> &vctItems)
{
for (int i=0; i<m_listItem.GetItemCount(); i++)
{
if (m_listItem.GetCheck(i))
{
Item_t item;
item.no = (E_ITEM_NO)m_listItem.GetItemData(i);
wcscpy(item.szName, m_listItem.GetItemText(i, 1));
vctItems.push_back(item);
}
}
return vctItems.size() > 0;
return TRUE;
}
void CApp_Sync728View::SendMessage(wchar_t *pszMsg)
{
//::PostMessage(m_hwndDlg, WM_SYNC_MESSAGE, 0, (LPARAM)pszMsg);
m_strMsg = pszMsg;
CStatic *pMsg = (CStatic *)GetDlgItem(IDC_STATIC_MSG);
pMsg->SetWindowText(pszMsg);
//UpdateData(TRUE);
//m_ctrlProgress.SetPos(nProgress);
}
void CApp_Sync728View::SendProgress(int nProgress)
{
//::PostMessage(m_hwndDlg, WM_SYNC_PROGRESS, 0, (LPARAM)nProgress);
m_ctrlProgress.SetPos(nProgress);
}
void CApp_Sync728View::Finished()
{
CButton *pBnt1 = (CButton *)GetDlgItem(IDC_BUTTON_RECOVER);
CButton *pBnt2 = (CButton *)GetDlgItem(IDC_BUTTON_BROWSE);
pBnt1->EnableWindow(TRUE);
pBnt2->EnableWindow(TRUE);
m_pTabItem->EnableWindow(TRUE);
m_listItem.EnableWindow(TRUE);
GetParent()->EnableWindow(TRUE);
switch (m_pTabItem->GetCurSel())
{
case VIEW_BACKUP:
//::MessageBox(NULL, TEXT("数据备份完成"), TEXT("信息"), MB_OK);
SendMessage(TEXT("数据备份完成"));
wcscpy(wszLastZip, (LPCTSTR)m_strFile);
break;
case VIEW_RECOVER:
//::MessageBox(NULL, TEXT("数据恢复完成"), TEXT("信息"), MB_OK);
SendMessage(TEXT("数据恢复完成, 请重启手机"));
wcscpy(wszLastZip, (LPCTSTR)m_strFile);
break;
case VIEW_858:
//::MessageBox(NULL, TEXT("数据导入完成"), TEXT("信息"), MB_OK);
wcscpy(wszLastXDB, (LPCTSTR)m_strFile);
SendMessage(TEXT("数据导入完成, 请重启手机"));
break;
}
SendProgress(0);
//::PostMessage(m_hwndDlg, WM_CLOSE, 0, 0);
CFile file;
file.Open(TEXT("\\DbData\\SYSCONFIG\\SDSync.cfg"), CFile::modeCreate | CFile::modeWrite);
file.Write(&bAutoRemind, sizeof (bAutoRemind));
file.Write(&bReplace, sizeof (bReplace));
file.Write(&bPassword, sizeof (bPassword));
file.Write(&wszLastZip, MAX_PATH_LEN);
file.Write(&wszLastXDB, MAX_PATH_LEN);
file.Close();
}
//void CApp_Sync728View::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
void CApp_Sync728View::OnSelchangeTabSel(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your control notification handler code here
RefreshView();
// *pResult = 0;
}
void CApp_Sync728View::RefreshView()
{
if (m_pDataManager != NULL)
{
delete m_pDataManager;
m_pDataManager = NULL;
}
m_strMsg = TEXT("");
m_ctrlProgress.SetPos(0);
CButton *pBnt2 = (CButton *)GetDlgItem(IDC_BUTTON_RECOVER);
// m_nSelected = m_tab.GetCurSel();
CFile file;
if (file.Open(TEXT("\\DbData\\SYSCONFIG\\SDSync.cfg"), CFile::modeRead))
{
file.Read(&bAutoRemind, sizeof (bAutoRemind));
file.Read(&bReplace, sizeof (bReplace));
file.Read(&bPassword, sizeof (bPassword));
file.Read(&wszLastZip, MAX_PATH_LEN);
file.Read(&wszLastXDB, MAX_PATH_LEN);
file.Close();
}
BOOL bSetPath = FALSE;
if (VIEW_BACKUP == m_pTabItem->GetCurSel())
{
SendMessage(TEXT("将数据备份到SD卡或其他位置"));
WIN32_FIND_DATA fileData;
if (wcslen(wszLastZip))
{
HANDLE hFindFile = FindFirstFile(wszLastZip, &fileData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
m_strFile = wszLastZip;
bSetPath = TRUE;
}
FindClose(hFindFile);
}
if (!bSetPath)
{
WIN32_FIND_DATA fileData;
HANDLE hFindFile = FindFirstFile(TEXT("\\SD"), &fileData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
m_strFile = WSZ_DEFAULT_SD_ZIP;
bSetPath = TRUE;
}
else
{
m_strFile = WSZ_DEFAULT_USERDATA_ZIP;
}
FindClose(hFindFile);
}
pBnt2->SetWindowText(TEXT("备份"));
m_pDataManager = new CDataManager();
}
if (m_pTabItem->GetCurSel() == VIEW_RECOVER)
{
SendMessage(TEXT("将您需要的数据恢复到手机"));
WIN32_FIND_DATA fileData;
if (wcslen(wszLastZip))
{
HANDLE hFindFile = FindFirstFile(wszLastZip, &fileData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
m_strFile = wszLastZip;
bSetPath = TRUE;
}
FindClose(hFindFile);
}
if (!bSetPath)
{
WIN32_FIND_DATA fileData;
HANDLE hFindFile = FindFirstFile(TEXT("\\SD"), &fileData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
m_strFile = WSZ_DEFAULT_SD_ZIP;
bSetPath = TRUE;
}
else
{
m_strFile = WSZ_DEFAULT_USERDATA_ZIP;
}
FindClose(hFindFile);
}
pBnt2->SetWindowText(TEXT("恢复"));
m_pDataManager = new CDataManager();
}
else if (m_pTabItem->GetCurSel() == VIEW_858)
{
WIN32_FIND_DATA fileData;
if (wcslen(wszLastXDB)>0)
{
HANDLE hFindFile = FindFirstFile(wszLastXDB, &fileData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
m_strFile = wszLastXDB;
bSetPath = TRUE;
}
FindClose(hFindFile);
}
if (!bSetPath)
{
WIN32_FIND_DATA fileData;
HANDLE hFindFile = FindFirstFile(TEXT("\\SD"), &fileData);
if (hFindFile != INVALID_HANDLE_VALUE)
{
m_strFile = WSZ_DEFAULT_SD_XDB;
bSetPath = TRUE;
}
else
{
m_strFile = WSZ_DEFAULT_USERDATA_XDB;
}
FindClose(hFindFile);
}
SendMessage(TEXT("将858数据导入您的手机"));
pBnt2->SetWindowText(TEXT("导入"));
m_pDataManager = new C858DataManager();
}
m_pDataManager->Init(m_pMsgUI);
m_pDataManager->GetAllItems(m_vctItems);
DisplayItems();
UpdateData(FALSE);
}
void CApp_Sync728View::OnButtonBrowse()
{
// TODO: Add your control notification handler code here
LPCTSTR lpszFilter=NULL;
if (m_pTabItem->GetCurSel() == VIEW_858)
{
lpszFilter=TEXT("XBase Files (.xdb)");
}
else
{
lpszFilter=TEXT("Zip Files (.zip)");
}
CFileDialog dlg(TRUE,lpszFilter,NULL,
OFN_ALLOWMULTISELECT,lpszFilter,NULL);
if (IDOK == dlg.DoModal())
{
POSITION pos;
pos = dlg.GetStartPosition();
while (pos)
{
m_strFile = dlg.GetNextPathName(pos);
DisplayItems();
}
UpdateData(FALSE);
}
UpdateData(FALSE);
}
void CApp_Sync728View::OnChangeEditFile()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CFormView::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
CSD728Msg::CSD728Msg(CApp_Sync728View *pUI/* = NULL*/)
{
m_pUI = pUI;
}
CSD728Msg::~CSD728Msg()
{
}
void CSD728Msg::Finished()
{
m_pUI->Finished();
}
void CSD728Msg::SendMessage(wchar_t *pszMsg)
{
m_pUI->SendMessage(pszMsg);
}
void CSD728Msg::SendProgress(int nProgress)
{
m_pUI->SendProgress(nProgress);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -