// Integrate.cpp : implementation file
//
#include "stdafx.h"
#include "scmtool.h"
#include "Integrate.h"
#include "reports.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Integrate dialog
Integrate::Integrate(CWnd* pParent )
: CDialog(Integrate::IDD, pParent)
{
//{{AFX_DATA_INIT(Integrate)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void Integrate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Integrate)
DDX_Control(pDX, IDC_RESOLVE, m_Resolve);
DDX_Control(pDX, ID_IPROJECT_TYPE, m_Iproject);
DDX_Control(pDX, ID_TARGET, m_Target);
DDX_Control(pDX, ID_SOURCE, m_Source);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Integrate, CDialog)
//{{AFX_MSG_MAP(Integrate)
ON_CBN_SELCHANGE(ID_IPROJECT_TYPE, OnSelchangeProjectType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Integrate message handlers
BOOL Integrate::OnInitDialog()
{
CDialog::OnInitDialog();
CString Buf = _T("");
CString project=_T(""),Command=_T("");
CString dir = "\\TempTxt\\mm.txt";
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
m_Iproject.ResetContent();
CAllPages::AddStringToCombo(&m_Iproject,Buf);
m_Iproject.SetCurSel(0);
OnSelchangeProjectType() ;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Integrate::OnOK()
{
CString Slist=_T(""),Command=_T(""),TestCommand=_T(""),Buf=_T("");
CString Source=_T(""),Target=_T(""),project=_T(""),Buffer=_T("");
CString dir = _T("\\TempTxt\\List.txt");
TCHAR* pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Slist);
Slist.TrimRight();
CString res = Slist.SpanIncluding( _T("\r\n1234567890 ") );
Slist = res ;
dir = "\\TempTxt\\Integrate.txt";
int CurProjectSel = m_Iproject.GetCurSel();
m_Iproject.GetLBText(CurProjectSel,project);
int CurSourceSel = m_Source.GetCurSel();
m_Source.GetLBText(CurSourceSel,Source );
Source = CAllPages::ReplaceAll(Source,"\\", "/");
int CurTargetSel = m_Target.GetCurSel();
m_Target.GetLBText(CurTargetSel, Target);
Target= CAllPages::ReplaceAll(Target,"\\", "/");
/* Check whether the files in the target can be overigth" */
Command = CAllPages::rep("-mintegchcheck ") + project + " " + Source + " " + Target + " " + Slist;
Command += " > " + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
if( ( Buf.Find(_T("Error")) || Buf.Find(_T("NOT")) ) && (!Buf.Find(_T("overwritten"))) ){
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
return;
}
if(-1 == Buf.Find(_T("OK, ")))
{
CString Message = Buf + _T("\n Do you want to continue integrate anyway?");
if(MessageBox(Message,_T("NSCM"),MB_ICONWARNING|MB_YESNO) == IDNO) return;
}
Command.Empty();
Buf.Empty();
int getcheck = m_Resolve.GetCheck();
if(getcheck == 0)
Command = CAllPages::rep("-mintegch -nr ") + project + " " + Source + " " + Target + " " + Slist;
else
Command = CAllPages::rep("-mintegch -r ") + project + " " + Source + " " + Target + " " + Slist;
TestCommand = CAllPages::rep(" -mintegchcheck ") + project + " " + Source + " " + Target + " " + Slist;
TestCommand += " > " + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(TestCommand,1,NULL,NULL); //chek before run the real one
pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buffer);
if(-1<Buffer.Find(_T("Warning !, Files will be overwritten :")))
{
Buffer += _T("\nDo you want to continue anyway?");
if(MessageBox(Buffer,_T("NSCM"),MB_ICONWARNING|MB_YESNO) == IDNO) return;
}
Command += " > " + CAllPages::GetCurDir() + dir;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
int i = Buf.Find( _T("NO Files were Integrated"));
int m = Buf.Find(_T("Error"));
int n = Buf.Find(_T("NOT"));
if(i == -1 && m == -1 && n == -1 )
{
if (MessageBox(_T("Do you want to Submit the New ChangeList Now?"),_T("NSCM"),MB_ICONQUESTION|MB_YESNO)==IDNO)
CDialog::OnOK();
else
{
int index = Buf.FindOneOf( _T("0123456789") );
Buf = Buf.Mid(index);
int j = Buf.Find(_T(" "));
CString ChNum = Buf.Mid(0,j);
dir = "\\TempTxt\\ChNum.txt";
Command = CAllPages::Cmd() + " /c p4 submit -c " + ChNum + " 2> " + CAllPages::GetCurDir() + dir; ;
CSCMToolApp::Waiting(Command,1,NULL,NULL);
pFileName = dir.GetBuffer(0);
CAllPages::ConvertFileIntoString(pFileName,&Buf);
i = Buf.Find(_T("failed"));
j = Buf.Find(_T("unknown"));
if(i > -1 || j > -1 )
{
MessageBox(Buf,_T("NSCM"),MB_ICONWARNING);
CDialog::OnOK();
}
else
{
MessageBox(_T("Submit finished Successfully"),_T("NSCM"),MB_ICONWARNING);
CDialog::OnOK();
}
}
}
else
CDialog::OnOK();
}
void Integrate::OnSelchangeProjectType()
{
CString project=_T(""),Buf=_T(""),Sdir=_T(""),Tdir=_T(""),Command1=_T(""),Command2=_T("");
int place = m_Iproject.GetCurSel();
m_Iproject.GetLBText(place,project);
project.TrimRight();
Sdir = "\\TempTxt\\spc.txt";//source project configuration
Tdir = "\\TempTxt\\tpc.txt";//target project configuration
if(project == "IT")
{
Command1 = CAllPages::rep("-pc") + project + " > " + CAllPages::GetCurDir() + Sdir;
Command2 = CAllPages::rep("-pc2") + project + " > " + CAllPages::GetCurDir() + Tdir;
}
else
{
Command1 = CAllPages::rep("-pc") + project + " > " + CAllPages::GetCurDir() + Sdir;
Command2 = CAllPages::rep("-pc") + project + " > " + CAllPages::GetCurDir() + Tdir;
}
CSCMToolApp::Waiting(Command1,1,NULL,NULL);
CSCMToolApp::Waiting(Command2,1,NULL,NULL);
TCHAR *pSFileName = Sdir.GetBuffer(0);
Buf.Empty();
CAllPages::ConvertFileIntoString(pSFileName,&Buf);
m_Source.ResetContent();
CAllPages::AddStringToCombo(&m_Source,Buf);
TCHAR *pTFileName = Tdir.GetBuffer(0);
Buf.Empty();
CAllPages::ConvertFileIntoString(pTFileName,&Buf);
m_Target.ResetContent();
CAllPages::AddStringToCombo(&m_Target,Buf);
m_Source.SetCurSel(0);
m_Target.SetCurSel(0);
}
void Integrate::OnSubmitbutton()
{
}