// configurationCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "scmtool.h"
#include "configurationCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// configurationCtrl property page
IMPLEMENT_DYNCREATE(configurationCtrl, CPropertyPage)
configurationCtrl::configurationCtrl() : CPropertyPage(configurationCtrl::IDD)
{
//{{AFX_DATA_INIT(configurationCtrl)
//}}AFX_DATA_INIT
}
configurationCtrl::~configurationCtrl()
{
}
void configurationCtrl::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(configurationCtrl)
DDX_Control(pDX, ID_FILES, m_ListFiles);
DDX_Control(pDX, ID_MYPENDLIST, m_MyPendingList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(configurationCtrl, CPropertyPage)
//{{AFX_MSG_MAP(configurationCtrl)
ON_LBN_DBLCLK(ID_MYPENDLIST, OnDblclkMypendlist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// configurationCtrl message handlers
BOOL configurationCtrl::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_MyPendingList.SetHorizontalExtent(1000);
m_ListFiles.SetHorizontalExtent(500);
TCHAR UserName[ 256 ];
CString Buf=_T("");
GetEnvironmentVariable( _T("USERNAME"), UserName, sizeof(UserName) );
CString User = UserName;
CString dir = _T("\\TempTxt\\MyPending.txt");
CString Command = CAllPages::rep(_T("-cp -u ")) + UserName;
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting( Command,1,NULL,NULL);
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_MyPendingList.ResetContent( ); //clean the list box for another use
CAllPages::AddStringToList(&m_MyPendingList,Buf);
m_MyPendingList.AddString(_T("default by ") + User);
return TRUE;
}
void configurationCtrl::OnDblclkMypendlist()
{
CString Command=_T(""),Change=_T(""),Buf=_T("");
int it,off202,elite,index=0;
int flag =0;
int m_Sel = m_MyPendingList.GetCurSel();
m_MyPendingList.GetText(m_Sel,Change);
int i = Change.Find(_T(" on "));
if(i==(-1)) flag=1;
Change = Change.Left(i);
CString dir = _T("\\TempTxt\\filelist.txt");
if (flag) //if chose by default
{
TCHAR UserName[ 256 ];
GetEnvironmentVariable( _T("USERNAME"), UserName, sizeof(UserName) );
Command += CAllPages::rep(_T(" -cfp -ndt default -u ")) + UserName;
}
else
Command = CAllPages::rep(_T("-cfp -ndt")) + Change;
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_ListFiles.ResetContent();
CAllPages::AddStringToList(&m_ListFiles,Buf);
//**** clean all the old tables ***********
GetDlgItem(IDC_CHECK1)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK2)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK3)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK4)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK5)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK6)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK7)->ShowWindow( SW_HIDE );
//**** check which configuration *********
CString P4CTRL =_T(""),PAF=_T(""),Caption=_T("");
Buf.MakeLower();
it = Buf.Find(_T("//it"));
off202 = Buf.Find(_T("//off202"));
elite = Buf.Find(_T("//elite"));
//******* find where is the file that hold the active configutration ********
dir = _T("\\TempTxt\\p4ctrl.txt");
if(it > -1 || off202 > -1)
{
Command = CAllPages::Cmd() + " /c p4 where //p4ctrl/PCFS/IT/PAF > ";
Command += CAllPages::GetCurDir() + dir;
}
else if(elite > -1)
{
Command = CAllPages::Cmd() + " /c p4 where //p4ctrl/PCFS/Elite/PAF > ";
Command += CAllPages::GetCurDir() + dir;
}
else
{
MessageBox(_T("Inactive Configuration"),_T("NSCM"),MB_ICONWARNING);
return;
}
//m_ListFiles.ResetContent();
//CAllPages::AddStringToList(&m_ListFiles,Buf);
CSCMToolApp::Waiting(Command,1,NULL,NULL);
pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&P4CTRL);
int p4 = P4CTRL.ReverseFind(_T(' '));
P4CTRL = P4CTRL.Mid(p4+1);
P4CTRL.TrimRight();
pFileName = P4CTRL.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&PAF,0);
int IDC,counter = 1,hide = 1 ,Myflag;
while(index > -1)
{
flag = 0;Myflag=0;
index = PAF.Find(_T("\n"));
if (index == -1) break;
Caption = PAF.Left(index);
Caption.TrimRight();
CString caption = Caption;
caption.MakeLower();
int j = Buf.Find(caption);
if(j>-1) flag = 1;
switch(counter)
{
case 1:
IDC = IDC_CHECK1;
if(flag) Myflag=1;
break;
case 2:
IDC = IDC_CHECK2;
if(flag) Myflag=1;
break;
case 3:
IDC = IDC_CHECK3;
if(flag) Myflag=1;
break;
case 4:
IDC = IDC_CHECK4;
if(flag) Myflag=1;
break;
case 5:
IDC = IDC_CHECK5;
if(flag) Myflag=1;
break;
case 6:
IDC = IDC_CHECK6;
if(flag) Myflag=1;
break;
case 7:
IDC = IDC_CHECK7;
if(flag) Myflag=1;
break;
}
GetDlgItem( IDC )->SetWindowText( Caption );
GetDlgItem( IDC )->ShowWindow( SW_SHOW );
if(Myflag)
{
CheckDlgButton( IDC, 1 );
hide = 0;
}
counter++;
PAF = PAF.Mid(index+1);
Caption.Empty();
}
if(hide)
{
GetDlgItem(IDC_CHECK1)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK2)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK3)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK4)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK5)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK6)->ShowWindow( SW_HIDE );
GetDlgItem(IDC_CHECK7)->ShowWindow( SW_HIDE );
MessageBox(_T("Inactive Configuration"),_T("NSCM"),MB_ICONWARNING);
return;
}
int Count = m_ListFiles.GetCount( );
for(i=0;i<Count;i++)
m_ListFiles.SetCheck(i, 1 );
}