// SCMToolDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SCMTool.h"
#include "SCMToolDlg.h"
#include "AllPages.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSCMToolDlg dialog
CSCMToolDlg::CSCMToolDlg() : CPropertyPage(CSCMToolDlg::IDD)
{
}
void CSCMToolDlg::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSCMToolDlg)
DDX_Control(pDX, ID_SYNC, m_Sync);
DDX_Control(pDX, ID_MODULE, m_Module);
DDX_Control(pDX, ID_CORR, m_Correction);
DDX_Control(pDX, ID_PROJECT_TYPE, m_Project);
DDX_Radio(pDX, ID_CONFIG1, m_Config);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSCMToolDlg, CPropertyPage)
//{{AFX_MSG_MAP(CSCMToolDlg)
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_CBN_SELCHANGE(ID_PROJECT_TYPE, OnSelchangeProjectType)
ON_BN_CLICKED(ID_CONFIG5, OnConfig5)
ON_BN_CLICKED(ID_CONFIG1, OnConfig1)
ON_BN_CLICKED(ID_CONFIG2, OnConfig2)
ON_BN_CLICKED(ID_CONFIG3, OnConfig3)
ON_BN_CLICKED(ID_CONFIG4, OnConfig4)
ON_BN_CLICKED(ID_CREATE_LABEL, OnCreateLabel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSCMToolDlg message handlers
BOOL CSCMToolDlg::OnInitDialog() //presents the relevant projects
{
CPropertyPage::OnInitDialog();
CWnd *MainWindow,*win;
CSCMToolApp* CurrApp;
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CurrApp = (CSCMToolApp*) AfxGetApp();
MainWindow = CurrApp->GetPropertySheet();
//delete 'OK' button.
win = MainWindow->GetDlgItem(1);
win->EnableWindow(FALSE);
win->ShowWindow(SW_HIDE);
win = MainWindow->GetDlgItem(2);
win->SetWindowText(_T("Close"));
win = MainWindow->GetDlgItem(9);
win->SetWindowText(_T("Help"));
//delete 'Apply' button.
win = MainWindow->GetDlgItem(0x3021);
win->EnableWindow(FALSE);
win->ShowWindow(SW_HIDE);
CString Buf=_T(""),Command=_T("");
CString dir = _T("\\TempTxt\\mm.txt");
Command += CAllPages::tdl(_T("-d"));
Command += " > " + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CString project=_T("");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
if(Buf.Find(_T("NOTE"))>-1) { AfxMessageBox(Buf); return (0);}
CAllPages::AddStringToCombo(&m_Project,Buf);
m_Project.SetCurSel(0);
OnSelchangeProjectType();
return TRUE; // return TRUE unless you set the focus to a control
}
void CSCMToolDlg::OnDestroy()
{
WinHelp(0L, HELP_QUIT);
CPropertyPage::OnDestroy();
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSCMToolDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPropertyPage::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSCMToolDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSCMToolDlg::OnSelchangeProjectType() //give the modules belong to the selected project
{
CString Buf=_T(""),ProName=_T(""),Module=_T(""),Command=_T("");
CString dir = _T("\\TempTxt\\ll.txt");
TCHAR* pFileName = dir.GetBuffer(0);
int place = m_Project.GetCurSel( );
m_Project.GetLBText(place,ProName);
ProName = ProName.Mid(0,ProName.GetLength());
Command += CAllPages::tdl(_T("-m"));
Command += ProName;
Command += _T(" DEV > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Module.ResetContent( ); //clean the list box for another use
CAllPages::AddStringToList(&m_Module,Buf);
OnConfig1();
m_Config=1;
UpdateData(FALSE);
}
void CSCMToolDlg::OnConfig5()
{
CString Buf=_T(""),ProName=_T(""),Command=_T(""),Correct=_T("");
int index=0;
CString dir = _T("\\TempTxt\\pm.txt");
TCHAR* pFileName = dir.GetBuffer(0);
int place = m_Project.GetCurSel( );
m_Project.GetLBText(place,ProName);
ProName.TrimRight( );
Command += CAllPages::tdl(_T("-pm"));
Command += ProName;
Command += _T(" > ") + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
if (Buf.IsEmpty())
{
AfxMessageBox(_T("There are no PRD corrections for this project!!!"));
m_Correction.EnableWindow(FALSE);
return;
}
m_Correction.ResetContent( ); //clean the list box for another use
if(Buf.Find(_T("Erorr"))>-1) AfxMessageBox(_T("Error"));
CAllPages::AddStringToCombo(&m_Correction,Buf);
int count = m_Correction.GetCount( ) - 1;
m_Correction.SetCurSel(count);
m_Correction.EnableWindow(TRUE);
}
void CSCMToolDlg::OnConfig1()
{
m_Correction.EnableWindow(FALSE);
}
void CSCMToolDlg::OnConfig2()
{
m_Correction.EnableWindow(FALSE);
}
void CSCMToolDlg::OnConfig3()
{
m_Correction.EnableWindow(FALSE);
}
void CSCMToolDlg::OnConfig4()
{
m_Correction.EnableWindow(FALSE);
}
BOOL CSCMToolDlg::OnCreateLabel()
{
int flag = 0;
CString dir = _T("\\TempTxt\\meslab.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CString Buf=_T(""),project=_T(""),correction=_T(""),module=_T(""),config=_T(""),Message=_T(""),Command=_T("");
if(m_Module.GetCurSel() == LB_ERR)
{
MessageBox(_T("Can not Create Label,\n Please choose Module"),_T("NSCM"),MB_ICONINFORMATION);
return (0);
}
UpdateData(TRUE);
if((m_Module.GetCurSel() != LB_ERR)&&(m_Project.GetCurSel() != LB_ERR))
{
m_Project.GetLBText(m_Project.GetCurSel(),project);
m_Module.GetText(m_Module.GetCurSel(),module);
switch(m_Config)
{
case 0: config = _T("PRE");
break;
case 1: config = _T("DEV");
break;
case 2: config = _T("INT");
break;
case 3: config = _T("QAT");
break;
case 4: config = _T("PRD");
int ii=m_Correction.GetCurSel();
if (ii!=-1) m_Correction.GetLBText(ii,correction);
else
{
AfxMessageBox(_T("You have to choose the PRD correction before clicking the <CREATE LABEL> button"));
return (FALSE);
}
flag = 1; break;
}
project.TrimLeft();
config.TrimLeft();
module.TrimRight();
project.TrimRight();
Command.Empty();
Command += CAllPages::tdl(_T("-ch"));
Command += project + _T(" ") + config;
DWORD Ret = CSCMToolApp::Waiting(Command,1,NULL,NULL);
if (Ret!=1)
{
AfxMessageBox(_T("Sorry, but ") + config + _T(" configuration is not available for the project: ") + project);
return (FALSE);
}
Command.Empty();
Command += CAllPages::tdl(_T("-p"));
int check = m_Sync.GetCheck( );
if (check)
Command += _T("-s -l "); //create sync locking label
else
Command += _T("-ns -l ");
Command += project + _T(" ") + config + _T(" ") + module + _T(" > ") + CAllPages::GetCurDir() + dir ;
if (flag)
{
Command += _T(" ");
Command += correction;
}
Message += _T("Are you sure you want to ");
if(check) Message += _T("SYNCHRONIZE and ");
Message += _T("create Label to the\n ");
Message += project + _T(" project in ") + config + _T(" configuration for module ") + module +_T("?");
if(AfxMessageBox(Message,MB_YESNO)== IDNO) return (0);
CSCMToolApp::Waiting(Command,1,NULL,NULL);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
AfxMessageBox(Buf);
}
return (0);
}