123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- // ShowLOg.cpp : implementation file
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ShowLOg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // ShowLOg dialog
- ShowLOg::ShowLOg(CWnd* pParent /*=NULL*/)
- : CDialog(ShowLOg::IDD, pParent)
- , m_StartTime(0)
- , m_EndTime(0)
- {
- //{{AFX_DATA_INIT(ShowLOg)
- //}}AFX_DATA_INIT
- m_nIndex = 0;
- }
- void ShowLOg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ShowLOg)
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- //}}AFX_DATA_MAP
- DDX_DateTimeCtrl(pDX, DTP_StartTime, m_StartTime); // Jeff.add
- DDX_DateTimeCtrl(pDX, DTP_EndTime, m_EndTime); // Jeff.add
- }
- BEGIN_MESSAGE_MAP(ShowLOg, CDialog)
- //{{AFX_MSG_MAP(ShowLOg)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(Btn_TimeFilter, OnBnClickedTimefilter) // Jeff.add
- ON_BN_CLICKED(Btn_ContentFind, OnBnClickedContentfind) // Jeff.add
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ShowLOg message handlers
- BOOL ShowLOg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_combo1.AddString ("1个月");
- m_combo1.AddString ("2个月");
- m_combo1.AddString ("3个月");
- m_combo1.AddString ("6个月");
- CString str = g_cominfoarray.ElementAt(0).ElementAt(112);
- if(str=="")str="6个月";
- m_combo1.SetCurSel(m_combo1.FindString(0, str));
- #if 1 // Jeff.add
- m_EndTime = CTime::GetCurrentTime();
- // printf("Jeff:GetYear=%d,GetMonth=%d,GetDay=%d\n\n",m_EndTime.GetYear(),m_EndTime.GetMonth(),m_EndTime.GetDay());
- int nCurSel = m_combo1.GetCurSel();
- // printf("Jeff:nCurSel=%d\n\n",nCurSel);
- switch( nCurSel )
- {
- case 0:
- {
- CTimeSpan ts(31,0,0,0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- case 1:
- {
- CTimeSpan ts(62,0,0,0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- case 2:
- {
- CTimeSpan ts(93,0,0,0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- case 3:
- {
- CTimeSpan ts(186,0,0,0);
- m_StartTime = m_EndTime - ts;
- }
- break;
- default:
- break;
- }
- UpdateData(FALSE);
- //m_List1.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP);
- #endif
- CRect rc;
- GetClientRect(rc);
- int wid=rc.Width ()-30;
- wid/=5;
-
- str.Format ("日期,%d;内容,%d", wid, wid*4);
- m_List1.SetHeadings(str);
- GetData();
- CenterWindow();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void ShowLOg::GetData()
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=185; // Jeff.case 185: log表;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)return;
- DataToArray(&m_List1array);
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize(), 1 );
- int count=0;
- for(ii=0; ii<m_List1.m_arLabels.GetSize(); ii++)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- }
- void ShowLOg::OnButton1()
- {
- // TODO: Add your control notification handler code here
- int pos=m_combo1.GetCurSel ();
- if(pos==-1)return;
- CString str;
- m_combo1.GetLBText(pos, str);
- CString sql;
- sql.Format("update version set [logdays]='"+str+"'");
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
-
- if(g_bSendOK==0)return;
-
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- g_cominfoarray.ElementAt(0).SetAt(112, str);
- }
- // Jeff.查询日志功能.
- // 1.从时间段上获取数据库里的时间范围;
- // 2.在1的基础上,模糊查询数据内容;
- // 3.是否需要做一个导出xls功能;
- //
- void ShowLOg::OnBnClickedTimefilter()
- {
- // TODO: 在此添加控件通知处理程序代码
- UpdateData();
- CString strStartTime = m_StartTime.Format("%Y-%m-%d");
- CString strEndTime = m_EndTime.Format("%Y-%m-%d");
- CString strFilter;
- //strFilter.Format("date >='%s' and date <='%s'",strStartTime,strEndTime);
- strFilter.Format("date between '%s' and '%s'",strStartTime,strEndTime);
- // printf("Jeff:strFilter=%s\n\n",strFilter);
- g_sendhead.bsql=0;
- g_sendhead.code[0]=185; // Jeff.case 185: log表;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(strFilter);
- if(g_bSendOK==0) return;
- DataToArray(&m_List1array);
- SetDlgItemText(Btn_ContentFind,"查询");
- m_nIndex = 0;
- m_List1.DeleteAllItems2();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize(), 1 );
- int count=0;
- for(ii=0; ii<m_List1.m_arLabels.GetSize(); ii++)
- {
- m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx(ii);
- }
- void ShowLOg::OnBnClickedContentfind()
- {
- UpdateData();
- //static int nIndex = 0;//用成员变量m_nIndex代替;
- CString strFind;
- GetDlgItemText(Edt_ContentFind,strFind);
- if ( strFind == "")
- {
- AfxMessageBox("请输入查找内容");
- return;
- }
- int nCount = m_List1.GetItemCount();
-
- BOOL bFind = FALSE;
- for( int i = m_nIndex; i < nCount; i++)
- {
- CString strContent = m_List1.m_arLabels.ElementAt(i).ElementAt(1);
- // printf("Jeff:当前项数=%d,查找:%s,内容:%s\n\n",nCount,strFind,strContent);
- if(strContent.Find(strFind) != -1)
- {
- int nItem = m_List1.GetTopIndex();
- CRect rc;
- m_List1.GetItemRect(nItem, rc, LVIR_BOUNDS);
- CSize sz(0, (i - nItem)*rc.Height());
- m_List1.Scroll(sz);//m_List1.SendMessage(WM_VSCROLL,SB_LINERIGHT,0);
- m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- //m_List1.SetItemState(i,LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- m_List1.SetFocus();
- m_nIndex = i+1;
- bFind = TRUE;
- SetDlgItemText(Btn_ContentFind,"下一个");
- break;
- }
- }
- if ( bFind == FALSE )
- {
- m_nIndex = 0;
- SetDlgItemText(Btn_ContentFind,"查询");
- AfxMessageBox("未找到相关内容!");
- }
- }
|